account-decoder: don't use strings to convert between Pubkey types (#17391)

* account-decoder: don't use strings to convert between Pubkey types

* transaction-status: don't use strings to convert between Pubkey types
This commit is contained in:
Alexander Polakov
2021-05-22 01:53:53 +03:00
committed by GitHub
parent 855ae79598
commit 51178ccb33
3 changed files with 9 additions and 14 deletions

View File

@@ -3,12 +3,11 @@ use crate::parse_instruction::{
};
use serde_json::json;
use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey};
use std::str::FromStr;
// A helper function to convert spl_associated_token_account_v1_0::id() as spl_sdk::pubkey::Pubkey
// to solana_sdk::pubkey::Pubkey
pub fn spl_associated_token_id_v1_0() -> Pubkey {
Pubkey::from_str(&spl_associated_token_account_v1_0::id().to_string()).unwrap()
Pubkey::new_from_array(spl_associated_token_account_v1_0::id().to_bytes())
}
pub fn parse_associated_token(
@@ -58,7 +57,7 @@ mod test {
};
fn convert_pubkey(pubkey: Pubkey) -> SplAssociatedTokenPubkey {
SplAssociatedTokenPubkey::from_str(&pubkey.to_string()).unwrap()
SplAssociatedTokenPubkey::new_from_array(pubkey.to_bytes())
}
fn convert_compiled_instruction(