Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/helpers/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ export interface BlockchainStreamOptions {
mode?: BlockchainMode
}

/**
* Blockchain
* ----------
* API to get block information from the blockchain
*
* Example:
* ```js
* const {Client, BlockchainMode} = require('dsteem')
*
* const client = new Client('https://api.steemit.com')
*
* async function main() {
* var latestBlock = await client.blockchain.getCurrentBlockNum(BlockchainMode.Latest)
* console.log(`The latest block number is: ${ latestBlock }`)
* }
*
* main().catch(console.error)
* ```
*/
export class Blockchain {

constructor(readonly client: Client) {}
Expand Down
97 changes: 96 additions & 1 deletion src/helpers/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,98 @@ export interface CreateAccountOptions {
metadata?: {[key: string]: any}
}

/**
* Broadcast API
* -------------
* API to broadcast transactions to the blockchain.
*
* Example:
* ```js
* const {Client, PrivateKey} = require('dsteem')
*
* const client = new Client('https://api.steemit.com')
*
* async function main() {
*
* const operation = [
* 'transfer_to_vesting',
* {
* from: 'alice',
* to: '',
* amount: '1000.000 STEEM'
* }
* ]
*
* const key = PrivateKey.fromString('5K5zUqyz8JjKq8hLYE3SM7SmBP6uK2PYewX4JvhsRDFT3VDtvBR')
*
* const response = await client.broadcast.sendOperations([operation], key)
* console.log(`Power up of 1000 STEEM. Block ${ response.block_num }`)
* }
*
* main().catch(console.error)
* ```
*
* List of operations:
*
* - Accounts
* * [[AccountCreateOperation]]
* * [[AccountUpdateOperation]]
* * [[ChangeRecoveryAccountOperation]]
* * [[ClaimAccountOperation]]
* * [[CreateClaimedAccountOperation]]
* * [[DeclineVotingRightsOperation]]
* * [[RecoverAccountOperation]]
* * [[RequestAccountRecoveryOperation]]
*
* - Posts
* * [[CommentOperation]]
* * [[CommentOptionsOperation]]
* * [[DeleteCommentOperation]]
* * [[VoteOperation]]
* * [[ClaimRewardBalanceOperation]]
* * [[DelegateVestingSharesOperation]]
*
* - Wallet
* * [[TransferOperation]]
* * [[ConvertOperation]]
* * [[TransferToVestingOperation]]
* * [[WithdrawVestingOperation]]
* * [[SetWithdrawVestingRouteOperation]]
* * [[TransferFromSavingsOperation]]
* * [[TransferToSavingsOperation]]
* * [[CancelTransferFromSavingsOperation]]
*
* - Escrow
* * [[EscrowTransferOperation]]
* * [[EscrowApproveOperation]]
* * [[EscrowReleaseOperation]]
* * [[EscrowDisputeOperation]]
*
* - Market
* * [[LimitOrderCancelOperation]]
* * [[LimitOrderCreateOperation]]
* * [[LimitOrderCreate2Operation]]
*
* - Custom
* * [[CustomOperation]]
* * [[CustomBinaryOperation]]
* * [[CustomJsonOperation]]
*
* - Witness
* * [[WitnessUpdateOperation]]
* * [[WitnessSetPropertiesOperation]]
* * [[FeedPublishOperation]]
* * [[AccountWitnessVoteOperation]]
* * [[AccountWitnessProxyOperation]]
*
* - Deprecated
* * [[AccountCreateWithDelegationOperation]]
* * [[PowOperation]]
* * [[Pow2Operation]]
* * [[ReportOverProductionOperation]]
* * [[ResetAccountOperation]]
* * [[SetResetAccountOperation]]
*/
export class BroadcastAPI {

/**
Expand Down Expand Up @@ -273,7 +365,8 @@ export class BroadcastAPI {

/**
* Sign and broadcast transaction with operations to the network. Throws if the transaction expires.
* @param operations List of operations to send.
* @param operations List of operations to send. An updated list of operations can be found
* at https://developers.steem.io/apidefinitions/#apidefinitions-broadcast-ops
* @param key Private key(s) used to sign transaction.
*/
public async sendOperations(operations: Operation[],
Expand Down Expand Up @@ -315,6 +408,8 @@ export class BroadcastAPI {

/**
* Convenience for calling `condenser_api`.
* @param method An updated list of methods can be found at
* https://github.com/steemit/steem/blob/master/libraries/plugins/apis/condenser_api/condenser_api.cpp
*/
public call(method: string, params?: any[]) {
return this.client.call('condenser_api', method, params)
Expand Down
23 changes: 22 additions & 1 deletion src/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,33 @@ export interface DisqussionQuery {
parent_permlink?: string
}

/**
* Database API
* ------------
* API to get data from the blockchain
*
* Example:
* ```js
* const {Client} = require('dsteem')
*
* const client = new Client('https://api.steemit.com')
*
* async function main() {
* const dgp = await client.database.getDynamicGlobalProperties()
* console.log(`The current supply is: ${ dgp.current_supply }`)
* }
*
* main().catch(console.error)
* ```
*/
export class DatabaseAPI {

constructor(readonly client: Client) {}

/**
* Convenience for calling `database_api`.
* @param method An updated list of methods can be found at
* https://github.com/steemit/steem/blob/master/libraries/plugins/apis/condenser_api/condenser_api.cpp
*/
public call(method: string, params?: any[]) {
return this.client.call('condenser_api', method, params)
Expand Down Expand Up @@ -134,7 +155,7 @@ export class DatabaseAPI {

/**
* Return server config. See:
* https://github.com/steemit/steem/blob/master/libraries/protocol/include/steemit/protocol/config.hpp
* https://github.com/steemit/steem/blob/master/libraries/protocol/include/steem/protocol/config.hpp
*/
public getConfig(): Promise<{[name: string]: string|number|boolean}> {
return this.call('get_config')
Expand Down
Loading