Add RpcClient::get_stake_activation() (bp #16165) (#16294)

* Add RpcClient::get_stake_activation()

(cherry picked from commit 5791b95b17)

# Conflicts:
#	client/src/rpc_client.rs

* Fix conflicts

* Derive PartialEq for StakeActivationState

Co-authored-by: Michael Vines <mvines@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-04-01 07:30:25 +00:00
committed by GitHub
parent f69ee59e21
commit a9a7f21f51
3 changed files with 22 additions and 3 deletions

View File

@ -7,7 +7,7 @@ use crate::{
RpcConfirmedBlockConfig, RpcConfirmedTransactionConfig,
RpcGetConfirmedSignaturesForAddress2Config, RpcLargestAccountsConfig,
RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcSimulateTransactionConfig,
RpcTokenAccountsFilter,
RpcStakeConfig, RpcTokenAccountsFilter,
},
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter},
rpc_response::*,
@ -24,7 +24,7 @@ use solana_account_decoder::{
use solana_sdk::{
account::Account,
clock::{
Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT,
Epoch, Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT,
MAX_HASH_AGE_IN_SECONDS,
},
commitment_config::{CommitmentConfig, CommitmentLevel},
@ -421,6 +421,23 @@ impl RpcClient {
})
}
pub fn get_stake_activation(
&self,
stake_account: Pubkey,
epoch: Option<Epoch>,
) -> ClientResult<RpcStakeActivation> {
self.send(
RpcRequest::GetStakeActivation,
json!([
stake_account.to_string(),
RpcStakeConfig {
epoch,
commitment: Some(self.commitment_config),
}
]),
)
}
pub fn supply(&self) -> RpcResult<RpcSupply> {
self.supply_with_commitment(self.commitment_config)
}

View File

@ -44,6 +44,7 @@ pub enum RpcRequest {
GetStorageTurn,
GetStorageTurnRate,
GetSlotsPerSegment,
GetStakeActivation,
GetStoragePubkeysForSlot,
GetSupply,
GetTokenAccountBalance,
@ -100,6 +101,7 @@ impl fmt::Display for RpcRequest {
RpcRequest::GetSlot => "getSlot",
RpcRequest::GetSlotLeader => "getSlotLeader",
RpcRequest::GetSlotLeaders => "getSlotLeaders",
RpcRequest::GetStakeActivation => "getStakeActivation",
RpcRequest::GetStorageTurn => "getStorageTurn",
RpcRequest::GetStorageTurnRate => "getStorageTurnRate",
RpcRequest::GetSlotsPerSegment => "getSlotsPerSegment",

View File

@ -313,7 +313,7 @@ pub struct RpcSupply {
pub non_circulating_accounts: Vec<String>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum StakeActivationState {
Activating,