diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 1ece95ad..3d81ada3 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -27,10 +27,8 @@ use serde::de::DeserializeOwned; use solana_account_decoder::parse_token::UiTokenAmount; use solana_cli_output::display::println_transaction; use solana_transaction_status::{EncodedConfirmedTransactionWithStatusMeta, UiTransactionEncoding}; -// The deprecated `create_associated_token_account` function is used because of different versions -// of some crates are required in this `client` crate and `anchor-spl` crate -#[allow(deprecated)] -use spl_associated_token_account::{create_associated_token_account, get_associated_token_address}; +use spl_associated_token_account::get_associated_token_address; +use spl_associated_token_account::instruction::create_associated_token_account; use std::{mem, rc::Rc}; use std::{thread::sleep, time::Duration}; @@ -646,11 +644,11 @@ impl Client { #[throws] pub async fn create_associated_token_account(&self, owner: &Keypair, mint: Pubkey) -> Pubkey { self.send_transaction( - #[allow(deprecated)] &[create_associated_token_account( &self.payer().pubkey(), &owner.pubkey(), &mint, + &spl_token::ID, )], &[], ) diff --git a/crates/explorer/src/parse/associated_token_account.rs b/crates/explorer/src/parse/associated_token_account.rs index a5b496da..d9acfb3c 100644 --- a/crates/explorer/src/parse/associated_token_account.rs +++ b/crates/explorer/src/parse/associated_token_account.rs @@ -17,7 +17,7 @@ pub fn parse_associated_token_account( )); } } - check_num_associated_token_accounts(&instruction.accounts, 7)?; + check_num_associated_token_accounts(&instruction.accounts, 6)?; Ok(ParsedInstructionEnum { instruction_type: "Create".to_string(), info: json!({ @@ -27,7 +27,6 @@ pub fn parse_associated_token_account( "Mint": account_keys[instruction.accounts[3] as usize].to_string(), "System Program": account_keys[instruction.accounts[4] as usize].to_string(), "Token Program": account_keys[instruction.accounts[5] as usize].to_string(), - "Rent Sysvar": account_keys[instruction.accounts[6] as usize].to_string(), }), }) } @@ -42,14 +41,12 @@ fn check_num_associated_token_accounts( #[cfg(test)] mod test { use super::*; - use solana_account_decoder::parse_token::pubkey_from_spl_token; - #[allow(deprecated)] - use spl_associated_token_account::create_associated_token_account as create_associated_token_account_deprecated; + use spl_associated_token_account::instruction::create_associated_token_account; use spl_associated_token_account::{ get_associated_token_address, solana_program::{ instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction, - message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, sysvar, + message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, }, }; @@ -66,33 +63,23 @@ mod test { data: instruction.data.clone(), } } - - fn convert_account_keys(message: &Message) -> Vec { - message - .account_keys - .iter() - .map(pubkey_from_spl_token) - .collect() - } - #[test] - fn test_parse_associated_token_deprecated() { + fn test_parse_associated_token() { let funder = Pubkey::new_unique(); let wallet_address = Pubkey::new_unique(); let mint = Pubkey::new_unique(); let associated_account_address = get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint)); - #[allow(deprecated)] - let create_ix = create_associated_token_account_deprecated( + let create_ix = create_associated_token_account( &convert_pubkey(funder), &convert_pubkey(wallet_address), &convert_pubkey(mint), + &&spl_token::id(), ); let message = Message::new(&[create_ix], None); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( - parse_associated_token_account(&compiled_instruction, &convert_account_keys(&message)) - .unwrap(), + parse_associated_token_account(&compiled_instruction, &message.account_keys).unwrap(), ParsedInstructionEnum { instruction_type: "Create".to_string(), info: json!({ @@ -101,8 +88,7 @@ mod test { "Wallet": wallet_address.to_string(), "Mint": mint.to_string(), "System Program": solana_sdk::system_program::id().to_string(), - "Token Program": spl_token::id().to_string(), - "Rent Sysvar": sysvar::rent::id().to_string(), + "Token Program": &spl_token::id().to_string(), }) } ); diff --git a/crates/explorer/src/parse/token.rs b/crates/explorer/src/parse/token.rs index 731ef697..a90a25d1 100644 --- a/crates/explorer/src/parse/token.rs +++ b/crates/explorer/src/parse/token.rs @@ -507,7 +507,6 @@ fn check_num_token_accounts(accounts: &[u8], num: usize) -> Result<(), ParseInst #[cfg(test)] mod test { use super::*; - use solana_account_decoder::parse_token::pubkey_from_spl_token; use solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey}; use spl_token::{ instruction::*, @@ -533,14 +532,6 @@ mod test { } } - fn convert_account_keys(message: &Message) -> Vec { - message - .account_keys - .iter() - .map(pubkey_from_spl_token) - .collect() - } - fn make_coerced_message( mut instruction: SplTokenInstruction, program_id: &SplTokenPubkey, @@ -573,7 +564,7 @@ mod test { let message = make_coerced_message(initialize_mint_ix, program_id); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( - parse_token(&compiled_instruction, &convert_account_keys(&message)).unwrap(), + parse_token(&compiled_instruction, &message.account_keys).unwrap(), ParsedInstructionEnum { instruction_type: "initializeMint".to_string(), info: json!({ @@ -597,7 +588,7 @@ mod test { let message = make_coerced_message(initialize_mint_ix, program_id); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( - parse_token(&compiled_instruction, &convert_account_keys(&message)).unwrap(), + parse_token(&compiled_instruction, &message.account_keys).unwrap(), ParsedInstructionEnum { instruction_type: "initializeMint".to_string(), info: json!({ @@ -622,7 +613,7 @@ mod test { let message = make_coerced_message(initialize_account_ix, program_id); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( - parse_token(&compiled_instruction, &convert_account_keys(&message)).unwrap(), + parse_token(&compiled_instruction, &message.account_keys).unwrap(), ParsedInstructionEnum { instruction_type: "initializeAccount".to_string(), info: json!({ @@ -645,7 +636,7 @@ mod test { let message = make_coerced_message(initialize_account_ix, program_id); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( - parse_token(&compiled_instruction, &convert_account_keys(&message)).unwrap(), + parse_token(&compiled_instruction, &message.account_keys).unwrap(), ParsedInstructionEnum { instruction_type: "initializeAccount2".to_string(), info: json!({ diff --git a/crates/explorer/src/parse/vote.rs b/crates/explorer/src/parse/vote.rs index 88304ceb..bcda9dfd 100644 --- a/crates/explorer/src/parse/vote.rs +++ b/crates/explorer/src/parse/vote.rs @@ -214,6 +214,7 @@ fn check_num_vote_accounts(accounts: &[u8], num: usize) -> Result<(), ParseInstr #[cfg(test)] mod test { use super::*; + use solana_program::vote::instruction::CreateVoteAccountConfig; use solana_sdk::{hash::Hash, message::Message, pubkey::Pubkey, sysvar}; use solana_vote_program::{ vote_instruction, @@ -236,11 +237,12 @@ mod test { commission, }; - let instructions = vote_instruction::create_account( + let instructions = vote_instruction::create_account_with_config( &Pubkey::new_unique(), &vote_pubkey, &vote_init, lamports, + CreateVoteAccountConfig::default(), ); let message = Message::new(&instructions, None); assert_eq!(