casper_client/rpcs/v1_6_0/
get_account.rs

1use serde::{Deserialize, Serialize};
2
3use casper_types::{
4    account::{Account, AccountHash},
5    ProtocolVersion, PublicKey,
6};
7
8use crate::rpcs::common::BlockIdentifier;
9pub(crate) use crate::rpcs::v1_4_5::get_account::GET_ACCOUNT_METHOD;
10
11/// Identifier of an account.
12#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
13#[serde(deny_unknown_fields, untagged)]
14pub enum AccountIdentifier {
15    /// The public key of an account
16    PublicKey(PublicKey),
17    /// The account hash of an account
18    AccountHash(AccountHash),
19}
20
21#[derive(Serialize, Deserialize, Debug)]
22#[serde(deny_unknown_fields)]
23pub(crate) struct GetAccountParams {
24    /// The identifier of an Account. (named public key to match the JSON-RPC API)
25    account_identifier: AccountIdentifier,
26    /// The block identifier.
27    block_identifier: Option<BlockIdentifier>,
28}
29
30impl GetAccountParams {
31    pub(crate) fn new(
32        account_identifier: AccountIdentifier,
33        block_identifier: Option<BlockIdentifier>,
34    ) -> Self {
35        GetAccountParams {
36            account_identifier,
37            block_identifier,
38        }
39    }
40}
41
42/// The `result` field of a successful JSON-RPC response to a `state_get_account_info` request.
43#[derive(Serialize, Deserialize, Debug, Clone)]
44#[serde(deny_unknown_fields)]
45pub struct GetAccountResult {
46    /// The JSON-RPC server version.
47    pub api_version: ProtocolVersion,
48    /// The account.
49    pub account: Account,
50    /// The merkle proof of the value.
51    pub merkle_proof: String,
52}