Expose getTotalSupply
RPC method (#370)
This commit is contained in:
committed by
Michael Vines
parent
fd2ddef520
commit
034f31d3bc
@ -214,6 +214,11 @@ const GetSignatureStatusRpcResult = jsonRpcResult(
|
||||
*/
|
||||
const GetTransactionCountRpcResult = jsonRpcResult('number');
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getTotalSupply" message
|
||||
*/
|
||||
const GetTotalSupplyRpcResult = jsonRpcResult('number');
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getRecentBlockhash" message
|
||||
*/
|
||||
@ -524,6 +529,19 @@ export class Connection {
|
||||
return Number(res.result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current total currency supply of the cluster
|
||||
*/
|
||||
async getTotalSupply(): Promise<number> {
|
||||
const unsafeRes = await this._rpcRequest('getTotalSupply', []);
|
||||
const res = GetTotalSupplyRpcResult(unsafeRes);
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message);
|
||||
}
|
||||
assert(typeof res.result !== 'undefined');
|
||||
return Number(res.result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a recent blockhash from the cluster
|
||||
*/
|
||||
|
Reference in New Issue
Block a user