Decode native-program and sysvar accounts (#11463)
* Pass pubkey in to account-decoder for sysvars * Decode sysvar accounts * Decode config accounts; move validator-info lower * Decode stake accounts * Review comments * Stringify any account lamports and epochs that can be set to u64::MAX
This commit is contained in:
@@ -247,7 +247,7 @@ impl JsonRpcRequestProcessor {
|
||||
let mut response = None;
|
||||
if let Some(account) = bank.get_account(pubkey) {
|
||||
if account.owner == spl_token_id_v1_0() && encoding == UiAccountEncoding::JsonParsed {
|
||||
response = get_parsed_token_account(bank.clone(), account);
|
||||
response = get_parsed_token_account(bank.clone(), pubkey, account);
|
||||
} else if encoding == UiAccountEncoding::Binary && account.data.len() > 128 {
|
||||
let message = "Encoded binary (base 58) data should be less than 128 bytes, please use Binary64 encoding.".to_string();
|
||||
return Err(error::Error {
|
||||
@@ -256,7 +256,7 @@ impl JsonRpcRequestProcessor {
|
||||
data: None,
|
||||
});
|
||||
} else {
|
||||
response = Some(UiAccount::encode(account, encoding, None));
|
||||
response = Some(UiAccount::encode(pubkey, account, encoding, None));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ impl JsonRpcRequestProcessor {
|
||||
keyed_accounts
|
||||
.map(|(pubkey, account)| RpcKeyedAccount {
|
||||
pubkey: pubkey.to_string(),
|
||||
account: UiAccount::encode(account, encoding.clone(), None),
|
||||
account: UiAccount::encode(&pubkey, account, encoding.clone(), None),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -1134,7 +1134,7 @@ impl JsonRpcRequestProcessor {
|
||||
keyed_accounts
|
||||
.map(|(pubkey, account)| RpcKeyedAccount {
|
||||
pubkey: pubkey.to_string(),
|
||||
account: UiAccount::encode(account, encoding.clone(), None),
|
||||
account: UiAccount::encode(&pubkey, account, encoding.clone(), None),
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
@@ -1185,7 +1185,7 @@ impl JsonRpcRequestProcessor {
|
||||
keyed_accounts
|
||||
.map(|(pubkey, account)| RpcKeyedAccount {
|
||||
pubkey: pubkey.to_string(),
|
||||
account: UiAccount::encode(account, encoding.clone(), None),
|
||||
account: UiAccount::encode(&pubkey, account, encoding.clone(), None),
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
@@ -1242,11 +1242,16 @@ fn get_filtered_program_accounts(
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_parsed_token_account(bank: Arc<Bank>, account: Account) -> Option<UiAccount> {
|
||||
pub(crate) fn get_parsed_token_account(
|
||||
bank: Arc<Bank>,
|
||||
pubkey: &Pubkey,
|
||||
account: Account,
|
||||
) -> Option<UiAccount> {
|
||||
get_token_account_mint(&account.data)
|
||||
.and_then(|mint_pubkey| get_mint_owner_and_decimals(&bank, &mint_pubkey).ok())
|
||||
.map(|(_, decimals)| {
|
||||
UiAccount::encode(
|
||||
pubkey,
|
||||
account,
|
||||
UiAccountEncoding::JsonParsed,
|
||||
Some(AccountAdditionalData {
|
||||
@@ -1274,6 +1279,7 @@ where
|
||||
RpcKeyedAccount {
|
||||
pubkey: pubkey.to_string(),
|
||||
account: UiAccount::encode(
|
||||
&pubkey,
|
||||
account,
|
||||
UiAccountEncoding::JsonParsed,
|
||||
Some(AccountAdditionalData { spl_token_decimals }),
|
||||
|
Reference in New Issue
Block a user