From 36838427d4f23cca4e9d959e5cc000edea34400b Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Mon, 13 Dec 2021 08:48:40 -0700 Subject: [PATCH] Revert "spl-token: New program feature flag (backport #21354) (#21376)" This reverts commit 42a67d30fcbcd8997fe0752de77aaed7a2676957. --- account-decoder/Cargo.toml | 2 +- account-decoder/src/parse_account_data.rs | 4 +- account-decoder/src/parse_token.rs | 18 ++-- accounts-cluster-bench/Cargo.toml | 2 +- accounts-cluster-bench/src/main.rs | 34 +++--- rpc/Cargo.toml | 2 +- rpc/src/parsed_token_accounts.rs | 8 +- rpc/src/rpc.rs | 75 ++++++------- rpc/src/rpc_subscriptions.rs | 9 +- runtime/src/accounts_db.rs | 8 +- runtime/src/accounts_index.rs | 30 +++--- runtime/src/bank.rs | 75 +++++++------ ..._spl_token.rs => inline_spl_token_v2_0.rs} | 4 +- runtime/src/lib.rs | 2 +- sdk/src/feature_set.rs | 5 - tokens/Cargo.toml | 4 +- tokens/src/commands.rs | 13 +-- tokens/src/spl_token.rs | 43 ++++---- transaction-status/Cargo.toml | 4 +- .../src/parse_associated_token.rs | 8 +- transaction-status/src/parse_instruction.rs | 8 +- transaction-status/src/parse_token.rs | 102 +++++++++--------- transaction-status/src/token_balances.rs | 14 +-- 23 files changed, 245 insertions(+), 229 deletions(-) rename runtime/src/{inline_spl_token.rs => inline_spl_token_v2_0.rs} (87%) diff --git a/account-decoder/Cargo.toml b/account-decoder/Cargo.toml index 0e59215e2b..8e59121e6a 100644 --- a/account-decoder/Cargo.toml +++ b/account-decoder/Cargo.toml @@ -22,7 +22,7 @@ serde_json = "1.0.56" solana-config-program = { path = "../programs/config", version = "=1.8.6" } solana-sdk = { path = "../sdk", version = "=1.8.6" } solana-vote-program = { path = "../programs/vote", version = "=1.8.6" } -spl-token = { version = "=3.2.0", features = ["no-entrypoint"] } +spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] } thiserror = "1.0" zstd = "0.5.1" diff --git a/account-decoder/src/parse_account_data.rs b/account-decoder/src/parse_account_data.rs index 40993ee59d..0c26b4003e 100644 --- a/account-decoder/src/parse_account_data.rs +++ b/account-decoder/src/parse_account_data.rs @@ -4,7 +4,7 @@ use crate::{ parse_nonce::parse_nonce, parse_stake::parse_stake, parse_sysvar::parse_sysvar, - parse_token::{parse_token, spl_token_id}, + parse_token::{parse_token, spl_token_id_v2_0}, parse_vote::parse_vote, }; use inflector::Inflector; @@ -19,7 +19,7 @@ lazy_static! { static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id(); static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id(); static ref SYSVAR_PROGRAM_ID: Pubkey = sysvar::id(); - static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id(); + static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id_v2_0(); static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id(); pub static ref PARSABLE_PROGRAM_IDS: HashMap = { let mut m = HashMap::new(); diff --git a/account-decoder/src/parse_token.rs b/account-decoder/src/parse_token.rs index 2b31f07e8a..b1bccfc537 100644 --- a/account-decoder/src/parse_token.rs +++ b/account-decoder/src/parse_token.rs @@ -3,7 +3,7 @@ use crate::{ StringAmount, StringDecimals, }; use solana_sdk::pubkey::Pubkey; -use spl_token::{ +use spl_token_v2_0::{ solana_program::{ program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey, }, @@ -11,25 +11,25 @@ use spl_token::{ }; use std::str::FromStr; -// A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to +// A helper function to convert spl_token_v2_0::id() as spl_sdk::pubkey::Pubkey to // solana_sdk::pubkey::Pubkey -pub fn spl_token_id() -> Pubkey { - Pubkey::new_from_array(spl_token::id().to_bytes()) +pub fn spl_token_id_v2_0() -> Pubkey { + Pubkey::new_from_array(spl_token_v2_0::id().to_bytes()) } -// A helper function to convert spl_token::native_mint::id() as spl_sdk::pubkey::Pubkey to +// A helper function to convert spl_token_v2_0::native_mint::id() as spl_sdk::pubkey::Pubkey to // solana_sdk::pubkey::Pubkey -pub fn spl_token_native_mint() -> Pubkey { - Pubkey::new_from_array(spl_token::native_mint::id().to_bytes()) +pub fn spl_token_v2_0_native_mint() -> Pubkey { + Pubkey::new_from_array(spl_token_v2_0::native_mint::id().to_bytes()) } // A helper function to convert a solana_sdk::pubkey::Pubkey to spl_sdk::pubkey::Pubkey -pub fn spl_token_pubkey(pubkey: &Pubkey) -> SplTokenPubkey { +pub fn spl_token_v2_0_pubkey(pubkey: &Pubkey) -> SplTokenPubkey { SplTokenPubkey::new_from_array(pubkey.to_bytes()) } // A helper function to convert a spl_sdk::pubkey::Pubkey to solana_sdk::pubkey::Pubkey -pub fn pubkey_from_spl_token(pubkey: &SplTokenPubkey) -> Pubkey { +pub fn pubkey_from_spl_token_v2_0(pubkey: &SplTokenPubkey) -> Pubkey { Pubkey::new_from_array(pubkey.to_bytes()) } diff --git a/accounts-cluster-bench/Cargo.toml b/accounts-cluster-bench/Cargo.toml index 83634da168..f5d2c913f8 100644 --- a/accounts-cluster-bench/Cargo.toml +++ b/accounts-cluster-bench/Cargo.toml @@ -27,7 +27,7 @@ solana-sdk = { path = "../sdk", version = "=1.8.6" } solana-streamer = { path = "../streamer", version = "=1.8.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.8.6" } solana-version = { path = "../version", version = "=1.8.6" } -spl-token = { version = "=3.2.0", features = ["no-entrypoint"] } +spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] } [dev-dependencies] solana-local-cluster = { path = "../local-cluster", version = "=1.8.6" } diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index dd34f2cb9f..58b5fa2a15 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -3,13 +3,13 @@ use clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg}; use log::*; use rand::{thread_rng, Rng}; use rayon::prelude::*; -use solana_account_decoder::parse_token::spl_token_pubkey; +use solana_account_decoder::parse_token::spl_token_v2_0_pubkey; use solana_clap_utils::input_parsers::pubkey_of; use solana_client::rpc_client::RpcClient; use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT}; use solana_gossip::gossip_service::discover; use solana_measure::measure::Measure; -use solana_runtime::inline_spl_token; +use solana_runtime::inline_spl_token_v2_0; use solana_sdk::{ commitment_config::CommitmentConfig, message::Message, @@ -21,7 +21,7 @@ use solana_sdk::{ transaction::Transaction, }; use solana_streamer::socket::SocketAddrSpace; -use solana_transaction_status::parse_token::spl_token_instruction; +use solana_transaction_status::parse_token::spl_token_v2_0_instruction; use std::{ net::SocketAddr, process::exit, @@ -274,7 +274,7 @@ fn make_create_message( .into_iter() .map(|_| { let program_id = if mint.is_some() { - inline_spl_token::id() + inline_spl_token_v2_0::id() } else { system_program::id() }; @@ -291,12 +291,12 @@ fn make_create_message( &program_id, )]; if let Some(mint_address) = mint { - instructions.push(spl_token_instruction( - spl_token::instruction::initialize_account( - &spl_token::id(), - &spl_token_pubkey(&to_pubkey), - &spl_token_pubkey(&mint_address), - &spl_token_pubkey(&base_keypair.pubkey()), + instructions.push(spl_token_v2_0_instruction( + spl_token_v2_0::instruction::initialize_account( + &spl_token_v2_0::id(), + &spl_token_v2_0_pubkey(&to_pubkey), + &spl_token_v2_0_pubkey(&mint_address), + &spl_token_v2_0_pubkey(&base_keypair.pubkey()), ) .unwrap(), )); @@ -322,7 +322,7 @@ fn make_close_message( .into_iter() .map(|_| { let program_id = if spl_token { - inline_spl_token::id() + inline_spl_token_v2_0::id() } else { system_program::id() }; @@ -330,12 +330,12 @@ fn make_close_message( let address = Pubkey::create_with_seed(&base_keypair.pubkey(), &seed, &program_id).unwrap(); if spl_token { - spl_token_instruction( - spl_token::instruction::close_account( - &spl_token::id(), - &spl_token_pubkey(&address), - &spl_token_pubkey(&keypair.pubkey()), - &spl_token_pubkey(&base_keypair.pubkey()), + spl_token_v2_0_instruction( + spl_token_v2_0::instruction::close_account( + &spl_token_v2_0::id(), + &spl_token_v2_0_pubkey(&address), + &spl_token_v2_0_pubkey(&keypair.pubkey()), + &spl_token_v2_0_pubkey(&base_keypair.pubkey()), &[], ) .unwrap(), diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 935f8f5e81..e0c37b2e5e 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -47,7 +47,7 @@ solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.8.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.8.6" } solana-version = { path = "../version", version = "=1.8.6" } solana-vote-program = { path = "../programs/vote", version = "=1.8.6" } -spl-token = { version = "=3.2.0", features = ["no-entrypoint"] } +spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] } stream-cancel = "0.8.1" thiserror = "1.0" tokio = { version = "1", features = ["full"] } diff --git a/rpc/src/parsed_token_accounts.rs b/rpc/src/parsed_token_accounts.rs index ab0342de6c..1e2c22007b 100644 --- a/rpc/src/parsed_token_accounts.rs +++ b/rpc/src/parsed_token_accounts.rs @@ -2,7 +2,7 @@ use { jsonrpc_core::{Error, Result}, solana_account_decoder::{ parse_account_data::AccountAdditionalData, - parse_token::{get_token_account_mint, spl_token_id, spl_token_native_mint}, + parse_token::{get_token_account_mint, spl_token_id_v2_0, spl_token_v2_0_native_mint}, UiAccount, UiAccountData, UiAccountEncoding, }, solana_client::rpc_response::RpcKeyedAccount, @@ -11,7 +11,7 @@ use { account::{AccountSharedData, ReadableAccount}, pubkey::Pubkey, }, - spl_token::{solana_program::program_pack::Pack, state::Mint}, + spl_token_v2_0::{solana_program::program_pack::Pack, state::Mint}, std::{collections::HashMap, sync::Arc}, }; @@ -74,8 +74,8 @@ where /// Analyze a mint Pubkey that may be the native_mint and get the mint-account owner (token /// program_id) and decimals pub fn get_mint_owner_and_decimals(bank: &Arc, mint: &Pubkey) -> Result<(Pubkey, u8)> { - if mint == &spl_token_native_mint() { - Ok((spl_token_id(), spl_token::native_mint::DECIMALS)) + if mint == &spl_token_v2_0_native_mint() { + Ok((spl_token_id_v2_0(), spl_token_v2_0::native_mint::DECIMALS)) } else { let mint_account = bank.get_account(mint).ok_or_else(|| { Error::invalid_params("Invalid param: could not find mint".to_string()) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index d7f03397ed..2e2becd03d 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -13,7 +13,7 @@ use { jsonrpc_derive::rpc, serde::{Deserialize, Serialize}, solana_account_decoder::{ - parse_token::{spl_token_id, token_amount_to_ui_amount, UiTokenAmount}, + parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount}, UiAccount, UiAccountEncoding, UiDataSliceConfig, MAX_BASE58_BYTES, }, solana_client::{ @@ -46,7 +46,7 @@ use { bank::Bank, bank_forks::{BankForks, SnapshotConfig}, commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots}, - inline_spl_token::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, + inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, non_circulating_supply::calculate_non_circulating_supply, snapshot_utils::get_highest_snapshot_archive_path, }, @@ -75,7 +75,7 @@ use { TransactionConfirmationStatus, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, }, solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY}, - spl_token::{ + spl_token_v2_0::{ solana_program::program_pack::Pack, state::{Account as TokenAccount, Mint}, }, @@ -384,7 +384,9 @@ impl JsonRpcRequestProcessor { self.get_filtered_program_accounts(&bank, program_id, filters)? } }; - let result = if program_id == &spl_token_id() && encoding == UiAccountEncoding::JsonParsed { + let result = if program_id == &spl_token_id_v2_0() + && encoding == UiAccountEncoding::JsonParsed + { get_parsed_token_accounts(bank.clone(), keyed_accounts.into_iter()).collect() } else { keyed_accounts @@ -1605,13 +1607,14 @@ impl JsonRpcRequestProcessor { Error::invalid_params("Invalid param: could not find account".to_string()) })?; - if account.owner() != &spl_token_id() { + if account.owner() != &spl_token_id_v2_0() { return Err(Error::invalid_params( - "Invalid param: not a Token account".to_string(), + "Invalid param: not a v2.0 Token account".to_string(), )); } - let token_account = TokenAccount::unpack(account.data()) - .map_err(|_| Error::invalid_params("Invalid param: not a Token account".to_string()))?; + let token_account = TokenAccount::unpack(account.data()).map_err(|_| { + Error::invalid_params("Invalid param: not a v2.0 Token account".to_string()) + })?; let mint = &Pubkey::from_str(&token_account.mint.to_string()) .expect("Token account mint should be convertible to Pubkey"); let (_, decimals) = get_mint_owner_and_decimals(&bank, mint)?; @@ -1628,9 +1631,9 @@ impl JsonRpcRequestProcessor { let mint_account = bank.get_account(mint).ok_or_else(|| { Error::invalid_params("Invalid param: could not find account".to_string()) })?; - if mint_account.owner() != &spl_token_id() { + if mint_account.owner() != &spl_token_id_v2_0() { return Err(Error::invalid_params( - "Invalid param: not a Token mint".to_string(), + "Invalid param: not a v2.0 Token mint".to_string(), )); } let mint = Mint::unpack(mint_account.data()).map_err(|_| { @@ -1648,9 +1651,9 @@ impl JsonRpcRequestProcessor { ) -> Result>> { let bank = self.bank(commitment); let (mint_owner, decimals) = get_mint_owner_and_decimals(&bank, mint)?; - if mint_owner != spl_token_id() { + if mint_owner != spl_token_id_v2_0() { return Err(Error::invalid_params( - "Invalid param: not a Token mint".to_string(), + "Invalid param: not a v2.0 Token mint".to_string(), )); } let mut token_balances: Vec = self @@ -1861,7 +1864,7 @@ impl JsonRpcRequestProcessor { } Ok(bank .get_filtered_indexed_accounts(&IndexKey::SplTokenOwner(*owner_key), |account| { - account.owner() == &spl_token_id() + account.owner() == &spl_token_id_v2_0() && filters.iter().all(|filter_type| match filter_type { RpcFilterType::DataSize(size) => account.data().len() as u64 == *size, RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()), @@ -1871,7 +1874,7 @@ impl JsonRpcRequestProcessor { message: e.to_string(), })?) } else { - self.get_filtered_program_accounts(bank, &spl_token_id(), filters) + self.get_filtered_program_accounts(bank, &spl_token_id_v2_0(), filters) } } @@ -1909,7 +1912,7 @@ impl JsonRpcRequestProcessor { } Ok(bank .get_filtered_indexed_accounts(&IndexKey::SplTokenMint(*mint_key), |account| { - account.owner() == &spl_token_id() + account.owner() == &spl_token_id_v2_0() && filters.iter().all(|filter_type| match filter_type { RpcFilterType::DataSize(size) => account.data().len() as u64 == *size, RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()), @@ -1919,7 +1922,7 @@ impl JsonRpcRequestProcessor { message: e.to_string(), })?) } else { - self.get_filtered_program_accounts(bank, &spl_token_id(), filters) + self.get_filtered_program_accounts(bank, &spl_token_id_v2_0(), filters) } } } @@ -2062,7 +2065,7 @@ fn get_encoded_account( ) -> Result> { match bank.get_account(pubkey) { Some(account) => { - let response = if account.owner() == &spl_token_id() + let response = if account.owner() == &spl_token_id_v2_0() && encoding == UiAccountEncoding::JsonParsed { get_parsed_token_account(bank.clone(), pubkey, account) @@ -2102,7 +2105,7 @@ fn encode_account( /// NOTE: `optimize_filters()` should almost always be called before using this method because of /// the strict match on `MemcmpEncodedBytes::Bytes`. fn get_spl_token_owner_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option { - if program_id != &spl_token_id() { + if program_id != &spl_token_id_v2_0() { return None; } let mut data_size_filter: Option = None; @@ -2144,7 +2147,7 @@ fn get_spl_token_owner_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> /// NOTE: `optimize_filters()` should almost always be called before using this method because of /// the strict match on `MemcmpEncodedBytes::Bytes`. fn get_spl_token_mint_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option { - if program_id != &spl_token_id() { + if program_id != &spl_token_id_v2_0() { return None; } let mut data_size_filter: Option = None; @@ -2190,15 +2193,15 @@ fn get_token_program_id_and_mint( match token_account_filter { TokenAccountsFilter::Mint(mint) => { let (mint_owner, _) = get_mint_owner_and_decimals(bank, &mint)?; - if mint_owner != spl_token_id() { + if mint_owner != spl_token_id_v2_0() { return Err(Error::invalid_params( - "Invalid param: not a Token mint".to_string(), + "Invalid param: not a v2.0 Token mint".to_string(), )); } Ok((mint_owner, Some(mint))) } TokenAccountsFilter::ProgramId(program_id) => { - if program_id == spl_token_id() { + if program_id == spl_token_id_v2_0() { Ok((program_id, None)) } else { Err(Error::invalid_params( @@ -4100,7 +4103,7 @@ pub mod tests { vote_instruction, vote_state::{BlockTimestamp, Vote, VoteInit, VoteStateVersions, MAX_LOCKOUT_HISTORY}, }, - spl_token::{ + spl_token_v2_0::{ solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey}, state::AccountState as TokenAccountState, state::Mint, @@ -6944,7 +6947,7 @@ pub mod tests { let token_account = AccountSharedData::from(Account { lamports: 111, data: account_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); let token_account_pubkey = solana_sdk::pubkey::new_rand(); @@ -6963,7 +6966,7 @@ pub mod tests { let mint_account = AccountSharedData::from(Account { lamports: 111, data: mint_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account); @@ -7040,7 +7043,7 @@ pub mod tests { let token_account = AccountSharedData::from(Account { lamports: 111, data: account_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand(); @@ -7055,7 +7058,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, owner, - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7073,7 +7076,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}, {{"encoding": "jsonParsed"}}] }}"#, owner, - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7090,7 +7093,7 @@ pub mod tests { "method":"getProgramAccounts", "params":["{}", {{"encoding": "jsonParsed"}}] }}"#, - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7154,7 +7157,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, solana_sdk::pubkey::new_rand(), - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7172,7 +7175,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, delegate, - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7237,7 +7240,7 @@ pub mod tests { "params":["{}", {{"programId": "{}"}}] }}"#, solana_sdk::pubkey::new_rand(), - spl_token_id(), + spl_token_id_v2_0(), ); let res = io.handle_request_sync(&req, meta.clone()); let result: Value = serde_json::from_str(&res.expect("actual response")) @@ -7259,7 +7262,7 @@ pub mod tests { let mint_account = AccountSharedData::from(Account { lamports: 111, data: mint_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); bank.store_account( @@ -7281,7 +7284,7 @@ pub mod tests { let token_account = AccountSharedData::from(Account { lamports: 111, data: account_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); let token_with_smaller_balance = solana_sdk::pubkey::new_rand(); @@ -7345,7 +7348,7 @@ pub mod tests { let token_account = AccountSharedData::from(Account { lamports: 111, data: account_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); let token_account_pubkey = solana_sdk::pubkey::new_rand(); @@ -7364,7 +7367,7 @@ pub mod tests { let mint_account = AccountSharedData::from(Account { lamports: 111, data: mint_data.to_vec(), - owner: spl_token_id(), + owner: spl_token_id_v2_0(), ..Account::default() }); bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account); diff --git a/rpc/src/rpc_subscriptions.rs b/rpc/src/rpc_subscriptions.rs index d2b7137322..a6ba0942e8 100644 --- a/rpc/src/rpc_subscriptions.rs +++ b/rpc/src/rpc_subscriptions.rs @@ -14,7 +14,7 @@ use { crossbeam_channel::{Receiver, RecvTimeoutError, SendError, Sender}, rayon::prelude::*, serde::Serialize, - solana_account_decoder::{parse_token::spl_token_id, UiAccount, UiAccountEncoding}, + solana_account_decoder::{parse_token::spl_token_id_v2_0, UiAccount, UiAccountEncoding}, solana_client::{ rpc_filter::RpcFilterType, rpc_response::{ @@ -307,7 +307,9 @@ fn filter_account_result( // If last_modified_slot < last_notified_slot this means that we last notified for a fork // and should notify that the account state has been reverted. let results: Box> = if last_modified_slot != last_notified_slot { - if account.owner() == &spl_token_id() && params.encoding == UiAccountEncoding::JsonParsed { + if account.owner() == &spl_token_id_v2_0() + && params.encoding == UiAccountEncoding::JsonParsed + { Box::new(iter::once(get_parsed_token_account( bank, ¶ms.pubkey, @@ -358,7 +360,8 @@ fn filter_program_results( RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()), }) }); - let accounts: Box> = if params.pubkey == spl_token_id() + let accounts: Box> = if params.pubkey + == spl_token_id_v2_0() && params.encoding == UiAccountEncoding::JsonParsed && !accounts_is_empty { diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index b7103a41be..e9bab4b66d 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -6316,7 +6316,7 @@ pub mod tests { accounts_index::RefCount, accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude}, append_vec::{test_utils::TempFile, AccountMeta}, - inline_spl_token, + inline_spl_token_v2_0, }; use assert_matches::assert_matches; use rand::{thread_rng, Rng}; @@ -7805,14 +7805,14 @@ pub mod tests { // Set up account to be added to secondary index let mint_key = Pubkey::new_unique(); let mut account_data_with_mint = - vec![0; inline_spl_token::state::Account::get_packed_len()]; + vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()]; account_data_with_mint[..PUBKEY_BYTES].clone_from_slice(&(mint_key.to_bytes())); let mut normal_account = AccountSharedData::new(1, 0, AccountSharedData::default().owner()); - normal_account.set_owner(inline_spl_token::id()); + normal_account.set_owner(inline_spl_token_v2_0::id()); normal_account.set_data(account_data_with_mint.clone()); let mut zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner()); - zero_account.set_owner(inline_spl_token::id()); + zero_account.set_owner(inline_spl_token_v2_0::id()); zero_account.set_data(account_data_with_mint); //store an account diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index b36316707e..680577e47a 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1,7 +1,7 @@ use crate::{ ancestors::Ancestors, contains::Contains, - inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, + inline_spl_token_v2_0::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, secondary_index::*, }; use bv::BitVec; @@ -1334,8 +1334,8 @@ impl = [ @@ -318,7 +314,6 @@ lazy_static! { (ed25519_program_enabled::id(), "enable builtin ed25519 signature verify program"), (requestable_heap_size::id(), "Requestable heap frame size"), (add_compute_budget_program::id(), "Add compute_budget_program"), - (spl_token_v3_3_0_release::id(), "spl-token v3.3.0 release"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter() diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index b9c1417c35..f500d8fce4 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -29,8 +29,8 @@ solana-runtime = { path = "../runtime", version = "=1.8.6" } solana-sdk = { path = "../sdk", version = "=1.8.6" } solana-transaction-status = { path = "../transaction-status", version = "=1.8.6" } solana-version = { path = "../version", version = "=1.8.6" } -spl-associated-token-account = { version = "=1.0.3" } -spl-token = { version = "=3.2.0", features = ["no-entrypoint"] } +spl-associated-token-account-v1-0 = { package = "spl-associated-token-account", version = "=1.0.3" } +spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] } tempfile = "3.1.0" thiserror = "1.0" diff --git a/tokens/src/commands.rs b/tokens/src/commands.rs index 8fe955811d..c4da5dabed 100644 --- a/tokens/src/commands.rs +++ b/tokens/src/commands.rs @@ -12,7 +12,7 @@ use indicatif::{ProgressBar, ProgressStyle}; use pickledb::PickleDb; use serde::{Deserialize, Serialize}; use solana_account_decoder::parse_token::{ - pubkey_from_spl_token, real_number_string, spl_token_pubkey, + pubkey_from_spl_token_v2_0, real_number_string, spl_token_v2_0_pubkey, }; use solana_client::{ client_error::{ClientError, Result as ClientResult}, @@ -36,8 +36,8 @@ use solana_sdk::{ transaction::Transaction, }; use solana_transaction_status::TransactionStatus; -use spl_associated_token_account::get_associated_token_address; -use spl_token::solana_program::program_error::ProgramError; +use spl_associated_token_account_v1_0::get_associated_token_address; +use spl_token_v2_0::solana_program::program_error::ProgramError; use std::{ cmp::{self}, io, @@ -310,11 +310,12 @@ fn build_messages( let wallet_address = allocation.recipient.parse().unwrap(); let associated_token_address = get_associated_token_address( &wallet_address, - &spl_token_pubkey(&spl_token_args.mint), + &spl_token_v2_0_pubkey(&spl_token_args.mint), ); let do_create_associated_token_account = client - .get_multiple_accounts(&[pubkey_from_spl_token(&associated_token_address)])?[0] - .is_none(); + .get_multiple_accounts(&[pubkey_from_spl_token_v2_0(&associated_token_address)])? + [0] + .is_none(); if do_create_associated_token_account { *created_accounts += 1; } diff --git a/tokens/src/spl_token.rs b/tokens/src/spl_token.rs index 57b54d84a5..a5a2e1136a 100644 --- a/tokens/src/spl_token.rs +++ b/tokens/src/spl_token.rs @@ -4,13 +4,16 @@ use crate::{ }; use console::style; use solana_account_decoder::parse_token::{ - pubkey_from_spl_token, real_number_string, real_number_string_trimmed, spl_token_pubkey, + pubkey_from_spl_token_v2_0, real_number_string, real_number_string_trimmed, + spl_token_v2_0_pubkey, }; use solana_client::rpc_client::RpcClient; use solana_sdk::{instruction::Instruction, native_token::lamports_to_sol}; -use solana_transaction_status::parse_token::spl_token_instruction; -use spl_associated_token_account::{create_associated_token_account, get_associated_token_address}; -use spl_token::{ +use solana_transaction_status::parse_token::spl_token_v2_0_instruction; +use spl_associated_token_account_v1_0::{ + create_associated_token_account, get_associated_token_address, +}; +use spl_token_v2_0::{ solana_program::program_pack::Pack, state::{Account as SplTokenAccount, Mint}, }; @@ -21,7 +24,7 @@ pub fn update_token_args(client: &RpcClient, args: &mut Option) -> .get_account(&spl_token_args.token_account_address) .unwrap_or_default(); let mint_address = - pubkey_from_spl_token(&SplTokenAccount::unpack(&sender_account.data)?.mint); + pubkey_from_spl_token_v2_0(&SplTokenAccount::unpack(&sender_account.data)?.mint); spl_token_args.mint = mint_address; update_decimals(client, args)?; } @@ -51,31 +54,33 @@ pub fn build_spl_token_instructions( .as_ref() .expect("spl_token_args must be some"); let wallet_address = allocation.recipient.parse().unwrap(); - let associated_token_address = - get_associated_token_address(&wallet_address, &spl_token_pubkey(&spl_token_args.mint)); + let associated_token_address = get_associated_token_address( + &wallet_address, + &spl_token_v2_0_pubkey(&spl_token_args.mint), + ); let mut instructions = vec![]; if do_create_associated_token_account { let create_associated_token_account_instruction = create_associated_token_account( - &spl_token_pubkey(&args.fee_payer.pubkey()), + &spl_token_v2_0_pubkey(&args.fee_payer.pubkey()), &wallet_address, - &spl_token_pubkey(&spl_token_args.mint), + &spl_token_v2_0_pubkey(&spl_token_args.mint), ); - instructions.push(spl_token_instruction( + instructions.push(spl_token_v2_0_instruction( create_associated_token_account_instruction, )); } - let spl_instruction = spl_token::instruction::transfer_checked( - &spl_token::id(), - &spl_token_pubkey(&spl_token_args.token_account_address), - &spl_token_pubkey(&spl_token_args.mint), + let spl_instruction = spl_token_v2_0::instruction::transfer_checked( + &spl_token_v2_0::id(), + &spl_token_v2_0_pubkey(&spl_token_args.token_account_address), + &spl_token_v2_0_pubkey(&spl_token_args.mint), &associated_token_address, - &spl_token_pubkey(&args.sender_keypair.pubkey()), + &spl_token_v2_0_pubkey(&args.sender_keypair.pubkey()), &[], allocation.amount, spl_token_args.decimals, ) .unwrap(); - instructions.push(spl_token_instruction(spl_instruction)); + instructions.push(spl_token_v2_0_instruction(spl_instruction)); instructions } @@ -129,11 +134,11 @@ pub fn print_token_balances( let address = allocation.recipient.parse().unwrap(); let expected = allocation.amount; let associated_token_address = get_associated_token_address( - &spl_token_pubkey(&address), - &spl_token_pubkey(&spl_token_args.mint), + &spl_token_v2_0_pubkey(&address), + &spl_token_v2_0_pubkey(&spl_token_args.mint), ); let recipient_account = client - .get_account(&pubkey_from_spl_token(&associated_token_address)) + .get_account(&pubkey_from_spl_token_v2_0(&associated_token_address)) .unwrap_or_default(); let (actual, difference) = if let Ok(recipient_token) = SplTokenAccount::unpack(&recipient_account.data) diff --git a/transaction-status/Cargo.toml b/transaction-status/Cargo.toml index 6368e2d260..7eaccde2ad 100644 --- a/transaction-status/Cargo.toml +++ b/transaction-status/Cargo.toml @@ -25,9 +25,9 @@ solana-metrics = { path = "../metrics", version = "=1.8.6" } solana-sdk = { path = "../sdk", version = "=1.8.6" } solana-runtime = { path = "../runtime", version = "=1.8.6" } solana-vote-program = { path = "../programs/vote", version = "=1.8.6" } -spl-associated-token-account = { version = "=1.0.3", features = ["no-entrypoint"] } +spl-associated-token-account-v1-0 = { package = "spl-associated-token-account", version = "=1.0.3", features = ["no-entrypoint"] } spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] } -spl-token = { version = "=3.2.0", features = ["no-entrypoint"] } +spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] } thiserror = "1.0" [package.metadata.docs.rs] diff --git a/transaction-status/src/parse_associated_token.rs b/transaction-status/src/parse_associated_token.rs index 71f67a8ee4..a5d15e8bde 100644 --- a/transaction-status/src/parse_associated_token.rs +++ b/transaction-status/src/parse_associated_token.rs @@ -6,10 +6,10 @@ use { solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey}, }; -// A helper function to convert spl_associated_token_account::id() as spl_sdk::pubkey::Pubkey +// 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() -> Pubkey { - Pubkey::new_from_array(spl_associated_token_account::id().to_bytes()) +pub fn spl_associated_token_id_v1_0() -> Pubkey { + Pubkey::new_from_array(spl_associated_token_account_v1_0::id().to_bytes()) } pub fn parse_associated_token( @@ -51,7 +51,7 @@ fn check_num_associated_token_accounts( mod test { use { super::*, - spl_associated_token_account::{ + spl_associated_token_account_v1_0::{ create_associated_token_account, solana_program::{ instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction, diff --git a/transaction-status/src/parse_instruction.rs b/transaction-status/src/parse_instruction.rs index 47c70c13c6..081bbf23cc 100644 --- a/transaction-status/src/parse_instruction.rs +++ b/transaction-status/src/parse_instruction.rs @@ -1,7 +1,7 @@ use { crate::{ extract_memos::{spl_memo_id_v1, spl_memo_id_v3}, - parse_associated_token::{parse_associated_token, spl_associated_token_id}, + parse_associated_token::{parse_associated_token, spl_associated_token_id_v1_0}, parse_bpf_loader::{parse_bpf_loader, parse_bpf_upgradeable_loader}, parse_stake::parse_stake, parse_system::parse_system, @@ -10,7 +10,7 @@ use { }, inflector::Inflector, serde_json::Value, - solana_account_decoder::parse_token::spl_token_id, + solana_account_decoder::parse_token::spl_token_id_v2_0, solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey, stake, system_program}, std::{ collections::HashMap, @@ -20,14 +20,14 @@ use { }; lazy_static! { - static ref ASSOCIATED_TOKEN_PROGRAM_ID: Pubkey = spl_associated_token_id(); + static ref ASSOCIATED_TOKEN_PROGRAM_ID: Pubkey = spl_associated_token_id_v1_0(); static ref BPF_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader::id(); static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id(); static ref MEMO_V1_PROGRAM_ID: Pubkey = spl_memo_id_v1(); static ref MEMO_V3_PROGRAM_ID: Pubkey = spl_memo_id_v3(); static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id(); static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id(); - static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id(); + static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id_v2_0(); static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id(); static ref PARSABLE_PROGRAM_IDS: HashMap = { let mut m = HashMap::new(); diff --git a/transaction-status/src/parse_token.rs b/transaction-status/src/parse_token.rs index 6908008cb9..afaf0a2d6e 100644 --- a/transaction-status/src/parse_token.rs +++ b/transaction-status/src/parse_token.rs @@ -3,12 +3,12 @@ use { check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum, }, serde_json::{json, Map, Value}, - solana_account_decoder::parse_token::{pubkey_from_spl_token, token_amount_to_ui_amount}, + solana_account_decoder::parse_token::{pubkey_from_spl_token_v2_0, token_amount_to_ui_amount}, solana_sdk::{ instruction::{AccountMeta, CompiledInstruction, Instruction}, pubkey::Pubkey, }, - spl_token::{ + spl_token_v2_0::{ instruction::{AuthorityType, TokenInstruction}, solana_program::{ instruction::Instruction as SplTokenInstruction, program_option::COption, @@ -438,14 +438,14 @@ fn check_num_token_accounts(accounts: &[u8], num: usize) -> Result<(), ParseInst check_num_accounts(accounts, num, ParsableProgram::SplToken) } -pub fn spl_token_instruction(instruction: SplTokenInstruction) -> Instruction { +pub fn spl_token_v2_0_instruction(instruction: SplTokenInstruction) -> Instruction { Instruction { - program_id: pubkey_from_spl_token(&instruction.program_id), + program_id: pubkey_from_spl_token_v2_0(&instruction.program_id), accounts: instruction .accounts .iter() .map(|meta| AccountMeta { - pubkey: pubkey_from_spl_token(&meta.pubkey), + pubkey: pubkey_from_spl_token_v2_0(&meta.pubkey), is_signer: meta.is_signer, is_writable: meta.is_writable, }) @@ -459,7 +459,7 @@ mod test { use { super::*, solana_sdk::instruction::CompiledInstruction, - spl_token::{ + spl_token_v2_0::{ instruction::*, solana_program::{ instruction::CompiledInstruction as SplTokenCompiledInstruction, message::Message, @@ -493,7 +493,7 @@ mod test { // Test InitializeMint variations let initialize_mint_ix = initialize_mint( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[2]), Some(&convert_pubkey(keys[3])), @@ -517,7 +517,7 @@ mod test { ); let initialize_mint_ix = initialize_mint( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[2]), None, @@ -541,7 +541,7 @@ mod test { // Test InitializeAccount let initialize_account_ix = initialize_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), @@ -564,7 +564,7 @@ mod test { // Test InitializeMultisig let initialize_multisig_ix = initialize_multisig( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &[ &convert_pubkey(keys[2]), @@ -591,7 +591,7 @@ mod test { // Test Transfer, incl multisig let transfer_ix = transfer( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -615,7 +615,7 @@ mod test { ); let transfer_ix = transfer( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -641,7 +641,7 @@ mod test { // Test Approve, incl multisig let approve_ix = approve( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -665,7 +665,7 @@ mod test { ); let approve_ix = approve( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -691,7 +691,7 @@ mod test { // Test Revoke let revoke_ix = revoke( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[0]), &[], @@ -712,7 +712,7 @@ mod test { // Test SetOwner let set_authority_ix = set_authority( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), Some(&convert_pubkey(keys[2])), AuthorityType::FreezeAccount, @@ -736,7 +736,7 @@ mod test { ); let set_authority_ix = set_authority( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), None, AuthorityType::CloseAccount, @@ -762,7 +762,7 @@ mod test { // Test MintTo let mint_to_ix = mint_to( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -787,7 +787,7 @@ mod test { // Test Burn let burn_ix = burn( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -812,7 +812,7 @@ mod test { // Test CloseAccount let close_account_ix = close_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -835,7 +835,7 @@ mod test { // Test FreezeAccount let freeze_account_ix = freeze_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -858,7 +858,7 @@ mod test { // Test ThawAccount let thaw_account_ix = thaw_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -881,7 +881,7 @@ mod test { // Test TransferChecked, incl multisig let transfer_ix = transfer_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), @@ -913,7 +913,7 @@ mod test { ); let transfer_ix = transfer_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -947,7 +947,7 @@ mod test { // Test ApproveChecked, incl multisig let approve_ix = approve_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), @@ -979,7 +979,7 @@ mod test { ); let approve_ix = approve_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -1013,7 +1013,7 @@ mod test { // Test MintToChecked let mint_to_ix = mint_to_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1044,7 +1044,7 @@ mod test { // Test BurnChecked let burn_ix = burn_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1074,7 +1074,7 @@ mod test { ); // Test SyncNative - let sync_native_ix = sync_native(&spl_token::id(), &convert_pubkey(keys[0])).unwrap(); + let sync_native_ix = sync_native(&spl_token_v2_0::id(), &convert_pubkey(keys[0])).unwrap(); let message = Message::new(&[sync_native_ix], None); let compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert_eq!( @@ -1098,7 +1098,7 @@ mod test { // Test InitializeMint variations let initialize_mint_ix = initialize_mint( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[1]), Some(&convert_pubkey(keys[2])), @@ -1113,7 +1113,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); let initialize_mint_ix = initialize_mint( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[1]), None, @@ -1129,7 +1129,7 @@ mod test { // Test InitializeAccount let initialize_account_ix = initialize_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), @@ -1144,7 +1144,7 @@ mod test { // Test InitializeMultisig let initialize_multisig_ix = initialize_multisig( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[0]), &[ &convert_pubkey(keys[1]), @@ -1163,7 +1163,7 @@ mod test { // Test Transfer, incl multisig let transfer_ix = transfer( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1179,7 +1179,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); let transfer_ix = transfer( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -1196,7 +1196,7 @@ mod test { // Test Approve, incl multisig let approve_ix = approve( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1212,7 +1212,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); let approve_ix = approve( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -1229,7 +1229,7 @@ mod test { // Test Revoke let revoke_ix = revoke( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[0]), &[], @@ -1244,7 +1244,7 @@ mod test { // Test SetAuthority let set_authority_ix = set_authority( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), Some(&convert_pubkey(keys[2])), AuthorityType::FreezeAccount, @@ -1261,7 +1261,7 @@ mod test { // Test MintTo let mint_to_ix = mint_to( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1278,7 +1278,7 @@ mod test { // Test Burn let burn_ix = burn( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1295,7 +1295,7 @@ mod test { // Test CloseAccount let close_account_ix = close_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1311,7 +1311,7 @@ mod test { // Test FreezeAccount let freeze_account_ix = freeze_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1327,7 +1327,7 @@ mod test { // Test ThawAccount let thaw_account_ix = thaw_account( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1343,7 +1343,7 @@ mod test { // Test TransferChecked, incl multisig let transfer_ix = transfer_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), @@ -1361,7 +1361,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); let transfer_ix = transfer_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -1380,7 +1380,7 @@ mod test { // Test ApproveChecked, incl multisig let approve_ix = approve_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), @@ -1398,7 +1398,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); let approve_ix = approve_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[2]), &convert_pubkey(keys[3]), &convert_pubkey(keys[4]), @@ -1417,7 +1417,7 @@ mod test { // Test MintToChecked let mint_to_ix = mint_to_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1435,7 +1435,7 @@ mod test { // Test BurnChecked let burn_ix = burn_checked( - &spl_token::id(), + &spl_token_v2_0::id(), &convert_pubkey(keys[1]), &convert_pubkey(keys[2]), &convert_pubkey(keys[0]), @@ -1452,7 +1452,7 @@ mod test { assert!(parse_token(&compiled_instruction, &keys).is_err()); // Test SyncNative - let sync_native_ix = sync_native(&spl_token::id(), &convert_pubkey(keys[0])).unwrap(); + let sync_native_ix = sync_native(&spl_token_v2_0::id(), &convert_pubkey(keys[0])).unwrap(); let message = Message::new(&[sync_native_ix], None); let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]); assert!(parse_token(&compiled_instruction, &[]).is_err()); diff --git a/transaction-status/src/token_balances.rs b/transaction-status/src/token_balances.rs index 91ed4cdaf1..924c9c878e 100644 --- a/transaction-status/src/token_balances.rs +++ b/transaction-status/src/token_balances.rs @@ -1,14 +1,14 @@ use { crate::TransactionTokenBalance, solana_account_decoder::parse_token::{ - pubkey_from_spl_token, spl_token_id, spl_token_native_mint, token_amount_to_ui_amount, - UiTokenAmount, + pubkey_from_spl_token_v2_0, spl_token_id_v2_0, spl_token_v2_0_native_mint, + token_amount_to_ui_amount, UiTokenAmount, }, solana_measure::measure::Measure, solana_metrics::datapoint_debug, solana_runtime::{bank::Bank, transaction_batch::TransactionBatch}, solana_sdk::{account::ReadableAccount, pubkey::Pubkey}, - spl_token::{ + spl_token_v2_0::{ solana_program::program_pack::Pack, state::{Account as TokenAccount, Mint}, }, @@ -36,12 +36,12 @@ impl TransactionTokenBalancesSet { } fn is_token_program(program_id: &Pubkey) -> bool { - program_id == &spl_token_id() + program_id == &spl_token_id_v2_0() } fn get_mint_decimals(bank: &Bank, mint: &Pubkey) -> Option { - if mint == &spl_token_native_mint() { - Some(spl_token::native_mint::DECIMALS) + if mint == &spl_token_v2_0_native_mint() { + Some(spl_token_v2_0::native_mint::DECIMALS) } else { let mint_account = bank.get_account(mint)?; @@ -113,7 +113,7 @@ fn collect_token_balance_from_account( let account = bank.get_account(account_id)?; let token_account = TokenAccount::unpack(account.data()).ok()?; - let mint = pubkey_from_spl_token(&token_account.mint); + let mint = pubkey_from_spl_token_v2_0(&token_account.mint); let decimals = mint_decimals.get(&mint).cloned().or_else(|| { let decimals = get_mint_decimals(bank, &mint)?;