Cli: Add solana supply command; hide total-supply (#9956)

* Add cli supply command; hide total-supply

* Use print-accounts arg instead of verbose
This commit is contained in:
Tyera Eulberg
2020-05-10 12:05:14 -06:00
committed by GitHub
parent af6a8f5fac
commit dd78184f8f
5 changed files with 108 additions and 2 deletions

View File

@ -179,6 +179,19 @@ impl RpcClient {
self.send(RpcRequest::GetSlot, json!([commitment_config]), 0)
}
pub fn supply_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> RpcResult<RpcSupply> {
let response = self
.client
.send(&RpcRequest::GetSupply, json!([commitment_config]), 0)
.map_err(|err| err.into_with_command("GetSupply"))?;
serde_json::from_value::<Response<RpcSupply>>(response)
.map_err(|err| ClientError::new_with_command(err.into(), "GetSupply"))
}
pub fn total_supply(&self) -> ClientResult<u64> {
self.total_supply_with_commitment(CommitmentConfig::default())
}

View File

@ -31,6 +31,7 @@ pub enum RpcRequest {
GetStorageTurnRate,
GetSlotsPerSegment,
GetStoragePubkeysForSlot,
GetSupply,
GetTotalSupply,
GetTransactionCount,
GetVersion,
@ -73,6 +74,7 @@ impl fmt::Display for RpcRequest {
RpcRequest::GetStorageTurnRate => "getStorageTurnRate",
RpcRequest::GetSlotsPerSegment => "getSlotsPerSegment",
RpcRequest::GetStoragePubkeysForSlot => "getStoragePubkeysForSlot",
RpcRequest::GetSupply => "getSupply",
RpcRequest::GetTotalSupply => "getTotalSupply",
RpcRequest::GetTransactionCount => "getTransactionCount",
RpcRequest::GetVersion => "getVersion",