Skip to content

Commit

Permalink
feat: add getblockbynumber
Browse files Browse the repository at this point in the history
  • Loading branch information
gridcat committed Jun 30, 2021
1 parent bbec1c3 commit 9991c67
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/RPC/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,32 @@ export class Network extends RPCBase {
}

/**
* Returns information about the block with the given hash.
* Returns information about the block with the given hash.
*
* @template Type
* @param {string} hash
* @param {boolean} [txinfo]
* @returns {Promise<IBlock>}
* @memberof GridcoinRPC
* @param {boolean} [txinfo] - optional to print more detailed tx info
* @returns {Promise<Type extends true ? BlockWithTX : Block>}
* @memberof Network
*/
public async getBlock(hash: string): Promise<Block>;
public async getBlock<Type extends boolean>(
hash: string, txinfo: Type,
): Promise<Type extends true ? BlockWithTX : Block> {
return this.call('getblock', hash, txinfo);
}

/**
* Returns information about the block with the given hash.
* Returns details of a block with given block-number
*
* @param {string} hash
* @param {boolean} [txinfo]
* @returns {(Promise<Block | BlockWithTX>)}
* @template Type
* @param {number} number
* @param {Type} txinfo - optional to print more detailed tx info
* @returns {Promise<Type extends true ? BlockWithTX : Block>}
* @memberof Network
*/
public async getBlock(hash: string, txinfo?: boolean): Promise<Block | BlockWithTX> {
return this.call('getblock', hash, txinfo);
public async getBlockByNumber<Type extends boolean>(
number: number, txinfo: Type,
): Promise<Type extends true ? BlockWithTX : Block> {
return this.call('getblockbynumber', number, txinfo);
}
}

0 comments on commit 9991c67

Please sign in to comment.