spl-token: New program feature flag (#21354)
* spl-token: Add feature flag for new release * Remove all spl token version declarations
This commit is contained in:
parent
2ed7e3af89
commit
02bc4e3fc1
|
@ -22,7 +22,7 @@ serde_json = "1.0.71"
|
||||||
solana-config-program = { path = "../programs/config", version = "=1.9.0" }
|
solana-config-program = { path = "../programs/config", version = "=1.9.0" }
|
||||||
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] }
|
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
zstd = "0.9.0"
|
zstd = "0.9.0"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
parse_nonce::parse_nonce,
|
parse_nonce::parse_nonce,
|
||||||
parse_stake::parse_stake,
|
parse_stake::parse_stake,
|
||||||
parse_sysvar::parse_sysvar,
|
parse_sysvar::parse_sysvar,
|
||||||
parse_token::{parse_token, spl_token_id_v2_0},
|
parse_token::{parse_token, spl_token_id},
|
||||||
parse_vote::parse_vote,
|
parse_vote::parse_vote,
|
||||||
};
|
};
|
||||||
use inflector::Inflector;
|
use inflector::Inflector;
|
||||||
|
@ -19,7 +19,7 @@ lazy_static! {
|
||||||
static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id();
|
static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id();
|
||||||
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
|
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
|
||||||
static ref SYSVAR_PROGRAM_ID: Pubkey = sysvar::id();
|
static ref SYSVAR_PROGRAM_ID: Pubkey = sysvar::id();
|
||||||
static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id_v2_0();
|
static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id();
|
||||||
static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
|
static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
|
||||||
pub static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableAccount> = {
|
pub static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableAccount> = {
|
||||||
let mut m = HashMap::new();
|
let mut m = HashMap::new();
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
StringAmount, StringDecimals,
|
StringAmount, StringDecimals,
|
||||||
};
|
};
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use spl_token_v2_0::{
|
use spl_token::{
|
||||||
solana_program::{
|
solana_program::{
|
||||||
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
|
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
|
||||||
},
|
},
|
||||||
|
@ -11,25 +11,25 @@ use spl_token_v2_0::{
|
||||||
};
|
};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
// A helper function to convert spl_token_v2_0::id() as spl_sdk::pubkey::Pubkey to
|
// A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to
|
||||||
// solana_sdk::pubkey::Pubkey
|
// solana_sdk::pubkey::Pubkey
|
||||||
pub fn spl_token_id_v2_0() -> Pubkey {
|
pub fn spl_token_id() -> Pubkey {
|
||||||
Pubkey::new_from_array(spl_token_v2_0::id().to_bytes())
|
Pubkey::new_from_array(spl_token::id().to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function to convert spl_token_v2_0::native_mint::id() as spl_sdk::pubkey::Pubkey to
|
// A helper function to convert spl_token::native_mint::id() as spl_sdk::pubkey::Pubkey to
|
||||||
// solana_sdk::pubkey::Pubkey
|
// solana_sdk::pubkey::Pubkey
|
||||||
pub fn spl_token_v2_0_native_mint() -> Pubkey {
|
pub fn spl_token_native_mint() -> Pubkey {
|
||||||
Pubkey::new_from_array(spl_token_v2_0::native_mint::id().to_bytes())
|
Pubkey::new_from_array(spl_token::native_mint::id().to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function to convert a solana_sdk::pubkey::Pubkey to spl_sdk::pubkey::Pubkey
|
// A helper function to convert a solana_sdk::pubkey::Pubkey to spl_sdk::pubkey::Pubkey
|
||||||
pub fn spl_token_v2_0_pubkey(pubkey: &Pubkey) -> SplTokenPubkey {
|
pub fn spl_token_pubkey(pubkey: &Pubkey) -> SplTokenPubkey {
|
||||||
SplTokenPubkey::new_from_array(pubkey.to_bytes())
|
SplTokenPubkey::new_from_array(pubkey.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function to convert a spl_sdk::pubkey::Pubkey to solana_sdk::pubkey::Pubkey
|
// A helper function to convert a spl_sdk::pubkey::Pubkey to solana_sdk::pubkey::Pubkey
|
||||||
pub fn pubkey_from_spl_token_v2_0(pubkey: &SplTokenPubkey) -> Pubkey {
|
pub fn pubkey_from_spl_token(pubkey: &SplTokenPubkey) -> Pubkey {
|
||||||
Pubkey::new_from_array(pubkey.to_bytes())
|
Pubkey::new_from_array(pubkey.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
||||||
solana-streamer = { path = "../streamer", version = "=1.9.0" }
|
solana-streamer = { path = "../streamer", version = "=1.9.0" }
|
||||||
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
||||||
solana-version = { path = "../version", version = "=1.9.0" }
|
solana-version = { path = "../version", version = "=1.9.0" }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] }
|
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
solana-local-cluster = { path = "../local-cluster", version = "=1.9.0" }
|
solana-local-cluster = { path = "../local-cluster", version = "=1.9.0" }
|
||||||
|
|
|
@ -3,12 +3,12 @@ use clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg};
|
||||||
use log::*;
|
use log::*;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use solana_account_decoder::parse_token::spl_token_v2_0_pubkey;
|
use solana_account_decoder::parse_token::spl_token_pubkey;
|
||||||
use solana_clap_utils::input_parsers::pubkey_of;
|
use solana_clap_utils::input_parsers::pubkey_of;
|
||||||
use solana_client::{rpc_client::RpcClient, transaction_executor::TransactionExecutor};
|
use solana_client::{rpc_client::RpcClient, transaction_executor::TransactionExecutor};
|
||||||
use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT};
|
use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT};
|
||||||
use solana_gossip::gossip_service::discover;
|
use solana_gossip::gossip_service::discover;
|
||||||
use solana_runtime::inline_spl_token_v2_0;
|
use solana_runtime::inline_spl_token;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
instruction::{AccountMeta, Instruction},
|
instruction::{AccountMeta, Instruction},
|
||||||
|
@ -20,7 +20,7 @@ use solana_sdk::{
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
use solana_streamer::socket::SocketAddrSpace;
|
use solana_streamer::socket::SocketAddrSpace;
|
||||||
use solana_transaction_status::parse_token::spl_token_v2_0_instruction;
|
use solana_transaction_status::parse_token::spl_token_instruction;
|
||||||
use std::{
|
use std::{
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
process::exit,
|
process::exit,
|
||||||
|
@ -115,7 +115,7 @@ fn make_create_message(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
let program_id = if mint.is_some() {
|
let program_id = if mint.is_some() {
|
||||||
inline_spl_token_v2_0::id()
|
inline_spl_token::id()
|
||||||
} else {
|
} else {
|
||||||
system_program::id()
|
system_program::id()
|
||||||
};
|
};
|
||||||
|
@ -132,12 +132,12 @@ fn make_create_message(
|
||||||
&program_id,
|
&program_id,
|
||||||
)];
|
)];
|
||||||
if let Some(mint_address) = mint {
|
if let Some(mint_address) = mint {
|
||||||
instructions.push(spl_token_v2_0_instruction(
|
instructions.push(spl_token_instruction(
|
||||||
spl_token_v2_0::instruction::initialize_account(
|
spl_token::instruction::initialize_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&spl_token_v2_0_pubkey(&to_pubkey),
|
&spl_token_pubkey(&to_pubkey),
|
||||||
&spl_token_v2_0_pubkey(&mint_address),
|
&spl_token_pubkey(&mint_address),
|
||||||
&spl_token_v2_0_pubkey(&base_keypair.pubkey()),
|
&spl_token_pubkey(&base_keypair.pubkey()),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
));
|
));
|
||||||
|
@ -163,7 +163,7 @@ fn make_close_message(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
let program_id = if spl_token {
|
let program_id = if spl_token {
|
||||||
inline_spl_token_v2_0::id()
|
inline_spl_token::id()
|
||||||
} else {
|
} else {
|
||||||
system_program::id()
|
system_program::id()
|
||||||
};
|
};
|
||||||
|
@ -171,12 +171,12 @@ fn make_close_message(
|
||||||
let address =
|
let address =
|
||||||
Pubkey::create_with_seed(&base_keypair.pubkey(), &seed, &program_id).unwrap();
|
Pubkey::create_with_seed(&base_keypair.pubkey(), &seed, &program_id).unwrap();
|
||||||
if spl_token {
|
if spl_token {
|
||||||
spl_token_v2_0_instruction(
|
spl_token_instruction(
|
||||||
spl_token_v2_0::instruction::close_account(
|
spl_token::instruction::close_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&spl_token_v2_0_pubkey(&address),
|
&spl_token_pubkey(&address),
|
||||||
&spl_token_v2_0_pubkey(&keypair.pubkey()),
|
&spl_token_pubkey(&keypair.pubkey()),
|
||||||
&spl_token_v2_0_pubkey(&base_keypair.pubkey()),
|
&spl_token_pubkey(&base_keypair.pubkey()),
|
||||||
&[],
|
&[],
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
|
|
@ -49,7 +49,7 @@ solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.9.0" }
|
||||||
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
||||||
solana-version = { path = "../version", version = "=1.9.0" }
|
solana-version = { path = "../version", version = "=1.9.0" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] }
|
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||||
stream-cancel = "0.8.1"
|
stream-cancel = "0.8.1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
|
@ -2,7 +2,7 @@ use {
|
||||||
jsonrpc_core::{Error, Result},
|
jsonrpc_core::{Error, Result},
|
||||||
solana_account_decoder::{
|
solana_account_decoder::{
|
||||||
parse_account_data::AccountAdditionalData,
|
parse_account_data::AccountAdditionalData,
|
||||||
parse_token::{get_token_account_mint, spl_token_id_v2_0, spl_token_v2_0_native_mint},
|
parse_token::{get_token_account_mint, spl_token_id, spl_token_native_mint},
|
||||||
UiAccount, UiAccountData, UiAccountEncoding,
|
UiAccount, UiAccountData, UiAccountEncoding,
|
||||||
},
|
},
|
||||||
solana_client::rpc_response::RpcKeyedAccount,
|
solana_client::rpc_response::RpcKeyedAccount,
|
||||||
|
@ -11,7 +11,7 @@ use {
|
||||||
account::{AccountSharedData, ReadableAccount},
|
account::{AccountSharedData, ReadableAccount},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
},
|
},
|
||||||
spl_token_v2_0::{solana_program::program_pack::Pack, state::Mint},
|
spl_token::{solana_program::program_pack::Pack, state::Mint},
|
||||||
std::{collections::HashMap, sync::Arc},
|
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
|
/// Analyze a mint Pubkey that may be the native_mint and get the mint-account owner (token
|
||||||
/// program_id) and decimals
|
/// program_id) and decimals
|
||||||
pub fn get_mint_owner_and_decimals(bank: &Arc<Bank>, mint: &Pubkey) -> Result<(Pubkey, u8)> {
|
pub fn get_mint_owner_and_decimals(bank: &Arc<Bank>, mint: &Pubkey) -> Result<(Pubkey, u8)> {
|
||||||
if mint == &spl_token_v2_0_native_mint() {
|
if mint == &spl_token_native_mint() {
|
||||||
Ok((spl_token_id_v2_0(), spl_token_v2_0::native_mint::DECIMALS))
|
Ok((spl_token_id(), spl_token::native_mint::DECIMALS))
|
||||||
} else {
|
} else {
|
||||||
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
||||||
Error::invalid_params("Invalid param: could not find mint".to_string())
|
Error::invalid_params("Invalid param: could not find mint".to_string())
|
||||||
|
|
|
@ -10,7 +10,7 @@ use {
|
||||||
jsonrpc_derive::rpc,
|
jsonrpc_derive::rpc,
|
||||||
serde::{Deserialize, Serialize},
|
serde::{Deserialize, Serialize},
|
||||||
solana_account_decoder::{
|
solana_account_decoder::{
|
||||||
parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount},
|
parse_token::{spl_token_id, token_amount_to_ui_amount, UiTokenAmount},
|
||||||
UiAccount, UiAccountEncoding, UiDataSliceConfig, MAX_BASE58_BYTES,
|
UiAccount, UiAccountEncoding, UiDataSliceConfig, MAX_BASE58_BYTES,
|
||||||
},
|
},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
|
@ -43,7 +43,7 @@ use {
|
||||||
bank::{Bank, TransactionSimulationResult},
|
bank::{Bank, TransactionSimulationResult},
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
|
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
|
||||||
inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
inline_spl_token::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
||||||
non_circulating_supply::calculate_non_circulating_supply,
|
non_circulating_supply::calculate_non_circulating_supply,
|
||||||
snapshot_config::SnapshotConfig,
|
snapshot_config::SnapshotConfig,
|
||||||
snapshot_utils,
|
snapshot_utils,
|
||||||
|
@ -78,7 +78,7 @@ use {
|
||||||
TransactionConfirmationStatus, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding,
|
TransactionConfirmationStatus, TransactionStatus, UiConfirmedBlock, UiTransactionEncoding,
|
||||||
},
|
},
|
||||||
solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY},
|
solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY},
|
||||||
spl_token_v2_0::{
|
spl_token::{
|
||||||
solana_program::program_pack::Pack,
|
solana_program::program_pack::Pack,
|
||||||
state::{Account as TokenAccount, Mint},
|
state::{Account as TokenAccount, Mint},
|
||||||
},
|
},
|
||||||
|
@ -396,9 +396,7 @@ impl JsonRpcRequestProcessor {
|
||||||
self.get_filtered_program_accounts(&bank, program_id, filters)?
|
self.get_filtered_program_accounts(&bank, program_id, filters)?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let result = if program_id == &spl_token_id_v2_0()
|
let result = if program_id == &spl_token_id() && encoding == UiAccountEncoding::JsonParsed {
|
||||||
&& encoding == UiAccountEncoding::JsonParsed
|
|
||||||
{
|
|
||||||
get_parsed_token_accounts(bank.clone(), keyed_accounts.into_iter()).collect()
|
get_parsed_token_accounts(bank.clone(), keyed_accounts.into_iter()).collect()
|
||||||
} else {
|
} else {
|
||||||
keyed_accounts
|
keyed_accounts
|
||||||
|
@ -1628,14 +1626,13 @@ impl JsonRpcRequestProcessor {
|
||||||
Error::invalid_params("Invalid param: could not find account".to_string())
|
Error::invalid_params("Invalid param: could not find account".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if account.owner() != &spl_token_id_v2_0() {
|
if account.owner() != &spl_token_id() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token account".to_string(),
|
"Invalid param: not a Token account".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let token_account = TokenAccount::unpack(account.data()).map_err(|_| {
|
let token_account = TokenAccount::unpack(account.data())
|
||||||
Error::invalid_params("Invalid param: not a v2.0 Token account".to_string())
|
.map_err(|_| Error::invalid_params("Invalid param: not a Token account".to_string()))?;
|
||||||
})?;
|
|
||||||
let mint = &Pubkey::from_str(&token_account.mint.to_string())
|
let mint = &Pubkey::from_str(&token_account.mint.to_string())
|
||||||
.expect("Token account mint should be convertible to Pubkey");
|
.expect("Token account mint should be convertible to Pubkey");
|
||||||
let (_, decimals) = get_mint_owner_and_decimals(&bank, mint)?;
|
let (_, decimals) = get_mint_owner_and_decimals(&bank, mint)?;
|
||||||
|
@ -1652,9 +1649,9 @@ impl JsonRpcRequestProcessor {
|
||||||
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
let mint_account = bank.get_account(mint).ok_or_else(|| {
|
||||||
Error::invalid_params("Invalid param: could not find account".to_string())
|
Error::invalid_params("Invalid param: could not find account".to_string())
|
||||||
})?;
|
})?;
|
||||||
if mint_account.owner() != &spl_token_id_v2_0() {
|
if mint_account.owner() != &spl_token_id() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token mint".to_string(),
|
"Invalid param: not a Token mint".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let mint = Mint::unpack(mint_account.data()).map_err(|_| {
|
let mint = Mint::unpack(mint_account.data()).map_err(|_| {
|
||||||
|
@ -1672,9 +1669,9 @@ impl JsonRpcRequestProcessor {
|
||||||
) -> Result<RpcResponse<Vec<RpcTokenAccountBalance>>> {
|
) -> Result<RpcResponse<Vec<RpcTokenAccountBalance>>> {
|
||||||
let bank = self.bank(commitment);
|
let bank = self.bank(commitment);
|
||||||
let (mint_owner, decimals) = get_mint_owner_and_decimals(&bank, mint)?;
|
let (mint_owner, decimals) = get_mint_owner_and_decimals(&bank, mint)?;
|
||||||
if mint_owner != spl_token_id_v2_0() {
|
if mint_owner != spl_token_id() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token mint".to_string(),
|
"Invalid param: not a Token mint".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let mut token_balances: Vec<RpcTokenAccountBalance> = self
|
let mut token_balances: Vec<RpcTokenAccountBalance> = self
|
||||||
|
@ -1893,7 +1890,7 @@ impl JsonRpcRequestProcessor {
|
||||||
.get_filtered_indexed_accounts(
|
.get_filtered_indexed_accounts(
|
||||||
&IndexKey::SplTokenOwner(*owner_key),
|
&IndexKey::SplTokenOwner(*owner_key),
|
||||||
|account| {
|
|account| {
|
||||||
account.owner() == &spl_token_id_v2_0()
|
account.owner() == &spl_token_id()
|
||||||
&& filters.iter().all(|filter_type| match filter_type {
|
&& filters.iter().all(|filter_type| match filter_type {
|
||||||
RpcFilterType::DataSize(size) => {
|
RpcFilterType::DataSize(size) => {
|
||||||
account.data().len() as u64 == *size
|
account.data().len() as u64 == *size
|
||||||
|
@ -1910,7 +1907,7 @@ impl JsonRpcRequestProcessor {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})?)
|
})?)
|
||||||
} else {
|
} else {
|
||||||
self.get_filtered_program_accounts(bank, &spl_token_id_v2_0(), filters)
|
self.get_filtered_program_accounts(bank, &spl_token_id(), filters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,7 +1947,7 @@ impl JsonRpcRequestProcessor {
|
||||||
.get_filtered_indexed_accounts(
|
.get_filtered_indexed_accounts(
|
||||||
&IndexKey::SplTokenMint(*mint_key),
|
&IndexKey::SplTokenMint(*mint_key),
|
||||||
|account| {
|
|account| {
|
||||||
account.owner() == &spl_token_id_v2_0()
|
account.owner() == &spl_token_id()
|
||||||
&& filters.iter().all(|filter_type| match filter_type {
|
&& filters.iter().all(|filter_type| match filter_type {
|
||||||
RpcFilterType::DataSize(size) => {
|
RpcFilterType::DataSize(size) => {
|
||||||
account.data().len() as u64 == *size
|
account.data().len() as u64 == *size
|
||||||
|
@ -1967,7 +1964,7 @@ impl JsonRpcRequestProcessor {
|
||||||
message: e.to_string(),
|
message: e.to_string(),
|
||||||
})?)
|
})?)
|
||||||
} else {
|
} else {
|
||||||
self.get_filtered_program_accounts(bank, &spl_token_id_v2_0(), filters)
|
self.get_filtered_program_accounts(bank, &spl_token_id(), filters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2149,7 +2146,7 @@ fn get_encoded_account(
|
||||||
) -> Result<Option<UiAccount>> {
|
) -> Result<Option<UiAccount>> {
|
||||||
match bank.get_account(pubkey) {
|
match bank.get_account(pubkey) {
|
||||||
Some(account) => {
|
Some(account) => {
|
||||||
let response = if account.owner() == &spl_token_id_v2_0()
|
let response = if account.owner() == &spl_token_id()
|
||||||
&& encoding == UiAccountEncoding::JsonParsed
|
&& encoding == UiAccountEncoding::JsonParsed
|
||||||
{
|
{
|
||||||
get_parsed_token_account(bank.clone(), pubkey, account)
|
get_parsed_token_account(bank.clone(), pubkey, account)
|
||||||
|
@ -2189,7 +2186,7 @@ fn encode_account<T: ReadableAccount>(
|
||||||
/// NOTE: `optimize_filters()` should almost always be called before using this method because of
|
/// NOTE: `optimize_filters()` should almost always be called before using this method because of
|
||||||
/// the strict match on `MemcmpEncodedBytes::Bytes`.
|
/// the strict match on `MemcmpEncodedBytes::Bytes`.
|
||||||
fn get_spl_token_owner_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option<Pubkey> {
|
fn get_spl_token_owner_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option<Pubkey> {
|
||||||
if program_id != &spl_token_id_v2_0() {
|
if program_id != &spl_token_id() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut data_size_filter: Option<u64> = None;
|
let mut data_size_filter: Option<u64> = None;
|
||||||
|
@ -2231,7 +2228,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
|
/// NOTE: `optimize_filters()` should almost always be called before using this method because of
|
||||||
/// the strict match on `MemcmpEncodedBytes::Bytes`.
|
/// the strict match on `MemcmpEncodedBytes::Bytes`.
|
||||||
fn get_spl_token_mint_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option<Pubkey> {
|
fn get_spl_token_mint_filter(program_id: &Pubkey, filters: &[RpcFilterType]) -> Option<Pubkey> {
|
||||||
if program_id != &spl_token_id_v2_0() {
|
if program_id != &spl_token_id() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut data_size_filter: Option<u64> = None;
|
let mut data_size_filter: Option<u64> = None;
|
||||||
|
@ -2277,15 +2274,15 @@ fn get_token_program_id_and_mint(
|
||||||
match token_account_filter {
|
match token_account_filter {
|
||||||
TokenAccountsFilter::Mint(mint) => {
|
TokenAccountsFilter::Mint(mint) => {
|
||||||
let (mint_owner, _) = get_mint_owner_and_decimals(bank, &mint)?;
|
let (mint_owner, _) = get_mint_owner_and_decimals(bank, &mint)?;
|
||||||
if mint_owner != spl_token_id_v2_0() {
|
if mint_owner != spl_token_id() {
|
||||||
return Err(Error::invalid_params(
|
return Err(Error::invalid_params(
|
||||||
"Invalid param: not a v2.0 Token mint".to_string(),
|
"Invalid param: not a Token mint".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Ok((mint_owner, Some(mint)))
|
Ok((mint_owner, Some(mint)))
|
||||||
}
|
}
|
||||||
TokenAccountsFilter::ProgramId(program_id) => {
|
TokenAccountsFilter::ProgramId(program_id) => {
|
||||||
if program_id == spl_token_id_v2_0() {
|
if program_id == spl_token_id() {
|
||||||
Ok((program_id, None))
|
Ok((program_id, None))
|
||||||
} else {
|
} else {
|
||||||
Err(Error::invalid_params(
|
Err(Error::invalid_params(
|
||||||
|
@ -4337,7 +4334,7 @@ pub mod tests {
|
||||||
vote_instruction,
|
vote_instruction,
|
||||||
vote_state::{BlockTimestamp, Vote, VoteInit, VoteStateVersions, MAX_LOCKOUT_HISTORY},
|
vote_state::{BlockTimestamp, Vote, VoteInit, VoteStateVersions, MAX_LOCKOUT_HISTORY},
|
||||||
},
|
},
|
||||||
spl_token_v2_0::{
|
spl_token::{
|
||||||
solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey},
|
solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey},
|
||||||
state::AccountState as TokenAccountState,
|
state::AccountState as TokenAccountState,
|
||||||
state::Mint,
|
state::Mint,
|
||||||
|
@ -7232,7 +7229,7 @@ pub mod tests {
|
||||||
let token_account = AccountSharedData::from(Account {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
@ -7251,7 +7248,7 @@ pub mod tests {
|
||||||
let mint_account = AccountSharedData::from(Account {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||||
|
@ -7328,7 +7325,7 @@ pub mod tests {
|
||||||
let token_account = AccountSharedData::from(Account {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand();
|
let token_with_different_mint_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
@ -7343,7 +7340,7 @@ pub mod tests {
|
||||||
"params":["{}", {{"programId": "{}"}}]
|
"params":["{}", {{"programId": "{}"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
owner,
|
owner,
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7361,7 +7358,7 @@ pub mod tests {
|
||||||
"params":["{}", {{"programId": "{}"}}, {{"encoding": "jsonParsed"}}]
|
"params":["{}", {{"programId": "{}"}}, {{"encoding": "jsonParsed"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
owner,
|
owner,
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7378,7 +7375,7 @@ pub mod tests {
|
||||||
"method":"getProgramAccounts",
|
"method":"getProgramAccounts",
|
||||||
"params":["{}", {{"encoding": "jsonParsed"}}]
|
"params":["{}", {{"encoding": "jsonParsed"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7442,7 +7439,7 @@ pub mod tests {
|
||||||
"params":["{}", {{"programId": "{}"}}]
|
"params":["{}", {{"programId": "{}"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
solana_sdk::pubkey::new_rand(),
|
solana_sdk::pubkey::new_rand(),
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7460,7 +7457,7 @@ pub mod tests {
|
||||||
"params":["{}", {{"programId": "{}"}}]
|
"params":["{}", {{"programId": "{}"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
delegate,
|
delegate,
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7525,7 +7522,7 @@ pub mod tests {
|
||||||
"params":["{}", {{"programId": "{}"}}]
|
"params":["{}", {{"programId": "{}"}}]
|
||||||
}}"#,
|
}}"#,
|
||||||
solana_sdk::pubkey::new_rand(),
|
solana_sdk::pubkey::new_rand(),
|
||||||
spl_token_id_v2_0(),
|
spl_token_id(),
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
@ -7547,7 +7544,7 @@ pub mod tests {
|
||||||
let mint_account = AccountSharedData::from(Account {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
bank.store_account(
|
bank.store_account(
|
||||||
|
@ -7569,7 +7566,7 @@ pub mod tests {
|
||||||
let token_account = AccountSharedData::from(Account {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
let token_with_smaller_balance = solana_sdk::pubkey::new_rand();
|
let token_with_smaller_balance = solana_sdk::pubkey::new_rand();
|
||||||
|
@ -7633,7 +7630,7 @@ pub mod tests {
|
||||||
let token_account = AccountSharedData::from(Account {
|
let token_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: account_data.to_vec(),
|
data: account_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
let token_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
@ -7652,7 +7649,7 @@ pub mod tests {
|
||||||
let mint_account = AccountSharedData::from(Account {
|
let mint_account = AccountSharedData::from(Account {
|
||||||
lamports: 111,
|
lamports: 111,
|
||||||
data: mint_data.to_vec(),
|
data: mint_data.to_vec(),
|
||||||
owner: spl_token_id_v2_0(),
|
owner: spl_token_id(),
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
bank.store_account(&Pubkey::from_str(&mint.to_string()).unwrap(), &mint_account);
|
||||||
|
|
|
@ -14,7 +14,7 @@ use {
|
||||||
crossbeam_channel::{Receiver, RecvTimeoutError, SendError, Sender},
|
crossbeam_channel::{Receiver, RecvTimeoutError, SendError, Sender},
|
||||||
rayon::prelude::*,
|
rayon::prelude::*,
|
||||||
serde::Serialize,
|
serde::Serialize,
|
||||||
solana_account_decoder::{parse_token::spl_token_id_v2_0, UiAccount, UiAccountEncoding},
|
solana_account_decoder::{parse_token::spl_token_id, UiAccount, UiAccountEncoding},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
rpc_filter::RpcFilterType,
|
rpc_filter::RpcFilterType,
|
||||||
rpc_response::{
|
rpc_response::{
|
||||||
|
@ -301,9 +301,7 @@ fn filter_account_result(
|
||||||
// If last_modified_slot < last_notified_slot this means that we last notified for a fork
|
// 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.
|
// and should notify that the account state has been reverted.
|
||||||
let results: Box<dyn Iterator<Item = UiAccount>> = if last_modified_slot != last_notified_slot {
|
let results: Box<dyn Iterator<Item = UiAccount>> = if last_modified_slot != last_notified_slot {
|
||||||
if account.owner() == &spl_token_id_v2_0()
|
if account.owner() == &spl_token_id() && params.encoding == UiAccountEncoding::JsonParsed {
|
||||||
&& params.encoding == UiAccountEncoding::JsonParsed
|
|
||||||
{
|
|
||||||
Box::new(iter::once(get_parsed_token_account(
|
Box::new(iter::once(get_parsed_token_account(
|
||||||
bank,
|
bank,
|
||||||
¶ms.pubkey,
|
¶ms.pubkey,
|
||||||
|
@ -354,8 +352,7 @@ fn filter_program_results(
|
||||||
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
RpcFilterType::Memcmp(compare) => compare.bytes_match(account.data()),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
let accounts: Box<dyn Iterator<Item = RpcKeyedAccount>> = if params.pubkey
|
let accounts: Box<dyn Iterator<Item = RpcKeyedAccount>> = if params.pubkey == spl_token_id()
|
||||||
== spl_token_id_v2_0()
|
|
||||||
&& params.encoding == UiAccountEncoding::JsonParsed
|
&& params.encoding == UiAccountEncoding::JsonParsed
|
||||||
&& !accounts_is_empty
|
&& !accounts_is_empty
|
||||||
{
|
{
|
||||||
|
|
|
@ -7374,7 +7374,7 @@ pub mod tests {
|
||||||
accounts_index::RefCount,
|
accounts_index::RefCount,
|
||||||
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude},
|
accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude},
|
||||||
append_vec::{test_utils::TempFile, AccountMeta},
|
append_vec::{test_utils::TempFile, AccountMeta},
|
||||||
inline_spl_token_v2_0,
|
inline_spl_token,
|
||||||
};
|
};
|
||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
@ -8916,14 +8916,14 @@ pub mod tests {
|
||||||
// Set up account to be added to secondary index
|
// Set up account to be added to secondary index
|
||||||
let mint_key = Pubkey::new_unique();
|
let mint_key = Pubkey::new_unique();
|
||||||
let mut account_data_with_mint =
|
let mut account_data_with_mint =
|
||||||
vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()];
|
vec![0; inline_spl_token::state::Account::get_packed_len()];
|
||||||
account_data_with_mint[..PUBKEY_BYTES].clone_from_slice(&(mint_key.to_bytes()));
|
account_data_with_mint[..PUBKEY_BYTES].clone_from_slice(&(mint_key.to_bytes()));
|
||||||
|
|
||||||
let mut normal_account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
|
let mut normal_account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
|
||||||
normal_account.set_owner(inline_spl_token_v2_0::id());
|
normal_account.set_owner(inline_spl_token::id());
|
||||||
normal_account.set_data(account_data_with_mint.clone());
|
normal_account.set_data(account_data_with_mint.clone());
|
||||||
let mut zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
let mut zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
||||||
zero_account.set_owner(inline_spl_token_v2_0::id());
|
zero_account.set_owner(inline_spl_token::id());
|
||||||
zero_account.set_data(account_data_with_mint);
|
zero_account.set_data(account_data_with_mint);
|
||||||
|
|
||||||
//store an account
|
//store an account
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
bucket_map_holder::{Age, BucketMapHolder},
|
bucket_map_holder::{Age, BucketMapHolder},
|
||||||
contains::Contains,
|
contains::Contains,
|
||||||
in_mem_accounts_index::{InMemAccountsIndex, InsertNewEntryResults},
|
in_mem_accounts_index::{InMemAccountsIndex, InsertNewEntryResults},
|
||||||
inline_spl_token_v2_0::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
||||||
pubkey_bins::PubkeyBinCalculator24,
|
pubkey_bins::PubkeyBinCalculator24,
|
||||||
secondary_index::*,
|
secondary_index::*,
|
||||||
};
|
};
|
||||||
|
@ -1556,8 +1556,8 @@ impl<T: IndexValue> AccountsIndex<T> {
|
||||||
// 2) When the fetch from storage occurs, it will return AccountSharedData::Default
|
// 2) When the fetch from storage occurs, it will return AccountSharedData::Default
|
||||||
// (as persisted tombstone for snapshots). This will then ultimately be
|
// (as persisted tombstone for snapshots). This will then ultimately be
|
||||||
// filtered out by post-scan filters, like in `get_filtered_spl_token_accounts_by_owner()`.
|
// filtered out by post-scan filters, like in `get_filtered_spl_token_accounts_by_owner()`.
|
||||||
if *account_owner == inline_spl_token_v2_0::id()
|
if *account_owner == inline_spl_token::id()
|
||||||
&& account_data.len() == inline_spl_token_v2_0::state::Account::get_packed_len()
|
&& account_data.len() == inline_spl_token::state::Account::get_packed_len()
|
||||||
{
|
{
|
||||||
if account_indexes.contains(&AccountIndex::SplTokenOwner) {
|
if account_indexes.contains(&AccountIndex::SplTokenOwner) {
|
||||||
let owner_key = Pubkey::new(
|
let owner_key = Pubkey::new(
|
||||||
|
@ -3696,7 +3696,7 @@ pub mod tests {
|
||||||
let index_key = Pubkey::new_unique();
|
let index_key = Pubkey::new_unique();
|
||||||
let account_key = Pubkey::new_unique();
|
let account_key = Pubkey::new_unique();
|
||||||
|
|
||||||
let mut account_data = vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()];
|
let mut account_data = vec![0; inline_spl_token::state::Account::get_packed_len()];
|
||||||
account_data[key_start..key_end].clone_from_slice(&(index_key.to_bytes()));
|
account_data[key_start..key_end].clone_from_slice(&(index_key.to_bytes()));
|
||||||
|
|
||||||
// Insert slots into secondary index
|
// Insert slots into secondary index
|
||||||
|
@ -3705,7 +3705,7 @@ pub mod tests {
|
||||||
*slot,
|
*slot,
|
||||||
&account_key,
|
&account_key,
|
||||||
// Make sure these accounts are added to secondary index
|
// Make sure these accounts are added to secondary index
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data,
|
&account_data,
|
||||||
secondary_indexes,
|
secondary_indexes,
|
||||||
true,
|
true,
|
||||||
|
@ -3871,7 +3871,7 @@ pub mod tests {
|
||||||
let mut secondary_indexes = secondary_indexes.clone();
|
let mut secondary_indexes = secondary_indexes.clone();
|
||||||
let account_key = Pubkey::new_unique();
|
let account_key = Pubkey::new_unique();
|
||||||
let index_key = Pubkey::new_unique();
|
let index_key = Pubkey::new_unique();
|
||||||
let mut account_data = vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()];
|
let mut account_data = vec![0; inline_spl_token::state::Account::get_packed_len()];
|
||||||
account_data[key_start..key_end].clone_from_slice(&(index_key.to_bytes()));
|
account_data[key_start..key_end].clone_from_slice(&(index_key.to_bytes()));
|
||||||
|
|
||||||
// Wrong program id
|
// Wrong program id
|
||||||
|
@ -3892,7 +3892,7 @@ pub mod tests {
|
||||||
index.upsert(
|
index.upsert(
|
||||||
0,
|
0,
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data[1..],
|
&account_data[1..],
|
||||||
&secondary_indexes,
|
&secondary_indexes,
|
||||||
true,
|
true,
|
||||||
|
@ -3908,7 +3908,7 @@ pub mod tests {
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
index.update_secondary_indexes(
|
index.update_secondary_indexes(
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data,
|
&account_data,
|
||||||
&secondary_indexes,
|
&secondary_indexes,
|
||||||
);
|
);
|
||||||
|
@ -3927,7 +3927,7 @@ pub mod tests {
|
||||||
secondary_index.reverse_index.clear();
|
secondary_index.reverse_index.clear();
|
||||||
index.update_secondary_indexes(
|
index.update_secondary_indexes(
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data,
|
&account_data,
|
||||||
&secondary_indexes,
|
&secondary_indexes,
|
||||||
);
|
);
|
||||||
|
@ -3944,7 +3944,7 @@ pub mod tests {
|
||||||
secondary_index.reverse_index.clear();
|
secondary_index.reverse_index.clear();
|
||||||
index.update_secondary_indexes(
|
index.update_secondary_indexes(
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data,
|
&account_data,
|
||||||
&secondary_indexes,
|
&secondary_indexes,
|
||||||
);
|
);
|
||||||
|
@ -4001,10 +4001,10 @@ pub mod tests {
|
||||||
let secondary_key1 = Pubkey::new_unique();
|
let secondary_key1 = Pubkey::new_unique();
|
||||||
let secondary_key2 = Pubkey::new_unique();
|
let secondary_key2 = Pubkey::new_unique();
|
||||||
let slot = 1;
|
let slot = 1;
|
||||||
let mut account_data1 = vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()];
|
let mut account_data1 = vec![0; inline_spl_token::state::Account::get_packed_len()];
|
||||||
account_data1[index_key_start..index_key_end]
|
account_data1[index_key_start..index_key_end]
|
||||||
.clone_from_slice(&(secondary_key1.to_bytes()));
|
.clone_from_slice(&(secondary_key1.to_bytes()));
|
||||||
let mut account_data2 = vec![0; inline_spl_token_v2_0::state::Account::get_packed_len()];
|
let mut account_data2 = vec![0; inline_spl_token::state::Account::get_packed_len()];
|
||||||
account_data2[index_key_start..index_key_end]
|
account_data2[index_key_start..index_key_end]
|
||||||
.clone_from_slice(&(secondary_key2.to_bytes()));
|
.clone_from_slice(&(secondary_key2.to_bytes()));
|
||||||
|
|
||||||
|
@ -4012,7 +4012,7 @@ pub mod tests {
|
||||||
index.upsert(
|
index.upsert(
|
||||||
slot,
|
slot,
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data1,
|
&account_data1,
|
||||||
secondary_indexes,
|
secondary_indexes,
|
||||||
true,
|
true,
|
||||||
|
@ -4024,7 +4024,7 @@ pub mod tests {
|
||||||
index.upsert(
|
index.upsert(
|
||||||
slot,
|
slot,
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data2,
|
&account_data2,
|
||||||
secondary_indexes,
|
secondary_indexes,
|
||||||
true,
|
true,
|
||||||
|
@ -4044,7 +4044,7 @@ pub mod tests {
|
||||||
index.upsert(
|
index.upsert(
|
||||||
later_slot,
|
later_slot,
|
||||||
&account_key,
|
&account_key,
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&account_data1,
|
&account_data1,
|
||||||
secondary_indexes,
|
secondary_indexes,
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -46,7 +46,7 @@ use crate::{
|
||||||
builtins::{self, ActivationType, Builtin, Builtins},
|
builtins::{self, ActivationType, Builtin, Builtins},
|
||||||
cost_tracker::CostTracker,
|
cost_tracker::CostTracker,
|
||||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||||
inline_spl_token_v2_0,
|
inline_spl_token,
|
||||||
message_processor::MessageProcessor,
|
message_processor::MessageProcessor,
|
||||||
rent_collector::RentCollector,
|
rent_collector::RentCollector,
|
||||||
stake_weighted_timestamp::{
|
stake_weighted_timestamp::{
|
||||||
|
@ -6100,8 +6100,8 @@ impl Bank {
|
||||||
self.rent_collector.rent.burn_percent = 50; // 50% rent burn
|
self.rent_collector.rent.burn_percent = 50; // 50% rent burn
|
||||||
}
|
}
|
||||||
|
|
||||||
if new_feature_activations.contains(&feature_set::spl_token_v2_set_authority_fix::id()) {
|
if new_feature_activations.contains(&feature_set::spl_token_v3_3_0_release::id()) {
|
||||||
self.apply_spl_token_v2_set_authority_fix();
|
self.apply_spl_token_v3_3_0_release();
|
||||||
}
|
}
|
||||||
if new_feature_activations.contains(&feature_set::rent_for_sysvars::id()) {
|
if new_feature_activations.contains(&feature_set::rent_for_sysvars::id()) {
|
||||||
// when this feature is activated, immediately all of existing sysvars are susceptible
|
// when this feature is activated, immediately all of existing sysvars are susceptible
|
||||||
|
@ -6237,13 +6237,13 @@ impl Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_spl_token_v2_set_authority_fix(&mut self) {
|
fn apply_spl_token_v3_3_0_release(&mut self) {
|
||||||
if let Some(old_account) = self.get_account_with_fixed_root(&inline_spl_token_v2_0::id()) {
|
if let Some(old_account) = self.get_account_with_fixed_root(&inline_spl_token::id()) {
|
||||||
if let Some(new_account) =
|
if let Some(new_account) =
|
||||||
self.get_account_with_fixed_root(&inline_spl_token_v2_0::new_token_program::id())
|
self.get_account_with_fixed_root(&inline_spl_token::new_token_program::id())
|
||||||
{
|
{
|
||||||
datapoint_info!(
|
datapoint_info!(
|
||||||
"bank-apply_spl_token_v2_set_authority_fix",
|
"bank-apply_spl_token_v3_3_0_release",
|
||||||
("slot", self.slot, i64),
|
("slot", self.slot, i64),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6252,15 +6252,15 @@ impl Bank {
|
||||||
.fetch_sub(old_account.lamports(), Relaxed);
|
.fetch_sub(old_account.lamports(), Relaxed);
|
||||||
|
|
||||||
// Transfer new token account to old token account
|
// Transfer new token account to old token account
|
||||||
self.store_account(&inline_spl_token_v2_0::id(), &new_account);
|
self.store_account(&inline_spl_token::id(), &new_account);
|
||||||
|
|
||||||
// Clear new token account
|
// Clear new token account
|
||||||
self.store_account(
|
self.store_account(
|
||||||
&inline_spl_token_v2_0::new_token_program::id(),
|
&inline_spl_token::new_token_program::id(),
|
||||||
&AccountSharedData::default(),
|
&AccountSharedData::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.remove_executor(&inline_spl_token_v2_0::id());
|
self.remove_executor(&inline_spl_token::id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6274,8 +6274,8 @@ impl Bank {
|
||||||
|
|
||||||
if reconfigure_token2_native_mint {
|
if reconfigure_token2_native_mint {
|
||||||
let mut native_mint_account = solana_sdk::account::AccountSharedData::from(Account {
|
let mut native_mint_account = solana_sdk::account::AccountSharedData::from(Account {
|
||||||
owner: inline_spl_token_v2_0::id(),
|
owner: inline_spl_token::id(),
|
||||||
data: inline_spl_token_v2_0::native_mint::ACCOUNT_DATA.to_vec(),
|
data: inline_spl_token::native_mint::ACCOUNT_DATA.to_vec(),
|
||||||
lamports: sol_to_lamports(1.),
|
lamports: sol_to_lamports(1.),
|
||||||
executable: false,
|
executable: false,
|
||||||
rent_epoch: self.epoch() + 1,
|
rent_epoch: self.epoch() + 1,
|
||||||
|
@ -6285,7 +6285,7 @@ impl Bank {
|
||||||
// https://github.com/solana-labs/solana-program-library/issues/374, ensure that the
|
// https://github.com/solana-labs/solana-program-library/issues/374, ensure that the
|
||||||
// spl-token 2 native mint account is owned by the spl-token 2 program.
|
// spl-token 2 native mint account is owned by the spl-token 2 program.
|
||||||
let store = if let Some(existing_native_mint_account) =
|
let store = if let Some(existing_native_mint_account) =
|
||||||
self.get_account_with_fixed_root(&inline_spl_token_v2_0::native_mint::id())
|
self.get_account_with_fixed_root(&inline_spl_token::native_mint::id())
|
||||||
{
|
{
|
||||||
if existing_native_mint_account.owner() == &solana_sdk::system_program::id() {
|
if existing_native_mint_account.owner() == &solana_sdk::system_program::id() {
|
||||||
native_mint_account.set_lamports(existing_native_mint_account.lamports());
|
native_mint_account.set_lamports(existing_native_mint_account.lamports());
|
||||||
|
@ -6300,10 +6300,7 @@ impl Bank {
|
||||||
};
|
};
|
||||||
|
|
||||||
if store {
|
if store {
|
||||||
self.store_account(
|
self.store_account(&inline_spl_token::native_mint::id(), &native_mint_account);
|
||||||
&inline_spl_token_v2_0::native_mint::id(),
|
|
||||||
&native_mint_account,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12733,18 +12730,15 @@ pub(crate) mod tests {
|
||||||
assert_eq!(genesis_config.cluster_type, ClusterType::Development);
|
assert_eq!(genesis_config.cluster_type, ClusterType::Development);
|
||||||
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_balance(&inline_spl_token_v2_0::native_mint::id()),
|
bank.get_balance(&inline_spl_token::native_mint::id()),
|
||||||
1000000000
|
1000000000
|
||||||
);
|
);
|
||||||
|
|
||||||
// Testnet - Native mint blinks into existence at epoch 93
|
// Testnet - Native mint blinks into existence at epoch 93
|
||||||
genesis_config.cluster_type = ClusterType::Testnet;
|
genesis_config.cluster_type = ClusterType::Testnet;
|
||||||
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
||||||
assert_eq!(
|
assert_eq!(bank.get_balance(&inline_spl_token::native_mint::id()), 0);
|
||||||
bank.get_balance(&inline_spl_token_v2_0::native_mint::id()),
|
bank.deposit(&inline_spl_token::native_mint::id(), 4200000000)
|
||||||
0
|
|
||||||
);
|
|
||||||
bank.deposit(&inline_spl_token_v2_0::native_mint::id(), 4200000000)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let bank = Bank::new_from_parent(
|
let bank = Bank::new_from_parent(
|
||||||
|
@ -12754,23 +12748,20 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let native_mint_account = bank
|
let native_mint_account = bank
|
||||||
.get_account(&inline_spl_token_v2_0::native_mint::id())
|
.get_account(&inline_spl_token::native_mint::id())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(native_mint_account.data().len(), 82);
|
assert_eq!(native_mint_account.data().len(), 82);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_balance(&inline_spl_token_v2_0::native_mint::id()),
|
bank.get_balance(&inline_spl_token::native_mint::id()),
|
||||||
4200000000
|
4200000000
|
||||||
);
|
);
|
||||||
assert_eq!(native_mint_account.owner(), &inline_spl_token_v2_0::id());
|
assert_eq!(native_mint_account.owner(), &inline_spl_token::id());
|
||||||
|
|
||||||
// MainnetBeta - Native mint blinks into existence at epoch 75
|
// MainnetBeta - Native mint blinks into existence at epoch 75
|
||||||
genesis_config.cluster_type = ClusterType::MainnetBeta;
|
genesis_config.cluster_type = ClusterType::MainnetBeta;
|
||||||
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
let bank = Arc::new(Bank::new_for_tests(&genesis_config));
|
||||||
assert_eq!(
|
assert_eq!(bank.get_balance(&inline_spl_token::native_mint::id()), 0);
|
||||||
bank.get_balance(&inline_spl_token_v2_0::native_mint::id()),
|
bank.deposit(&inline_spl_token::native_mint::id(), 4200000000)
|
||||||
0
|
|
||||||
);
|
|
||||||
bank.deposit(&inline_spl_token_v2_0::native_mint::id(), 4200000000)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let bank = Bank::new_from_parent(
|
let bank = Bank::new_from_parent(
|
||||||
|
@ -12780,14 +12771,14 @@ pub(crate) mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let native_mint_account = bank
|
let native_mint_account = bank
|
||||||
.get_account(&inline_spl_token_v2_0::native_mint::id())
|
.get_account(&inline_spl_token::native_mint::id())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(native_mint_account.data().len(), 82);
|
assert_eq!(native_mint_account.data().len(), 82);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_balance(&inline_spl_token_v2_0::native_mint::id()),
|
bank.get_balance(&inline_spl_token::native_mint::id()),
|
||||||
4200000000
|
4200000000
|
||||||
);
|
);
|
||||||
assert_eq!(native_mint_account.owner(), &inline_spl_token_v2_0::id());
|
assert_eq!(native_mint_account.owner(), &inline_spl_token::id());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -13115,19 +13106,19 @@ pub(crate) mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spl_token_v2_replacement() {
|
fn test_spl_token_replacement() {
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(0);
|
let (genesis_config, _mint_keypair) = create_genesis_config(0);
|
||||||
let mut bank = Bank::new_for_tests(&genesis_config);
|
let mut bank = Bank::new_for_tests(&genesis_config);
|
||||||
|
|
||||||
// Setup original token account
|
// Setup original token account
|
||||||
bank.store_account_and_update_capitalization(
|
bank.store_account_and_update_capitalization(
|
||||||
&inline_spl_token_v2_0::id(),
|
&inline_spl_token::id(),
|
||||||
&AccountSharedData::from(Account {
|
&AccountSharedData::from(Account {
|
||||||
lamports: 100,
|
lamports: 100,
|
||||||
..Account::default()
|
..Account::default()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
assert_eq!(bank.get_balance(&inline_spl_token_v2_0::id()), 100);
|
assert_eq!(bank.get_balance(&inline_spl_token::id()), 100);
|
||||||
|
|
||||||
// Setup new token account
|
// Setup new token account
|
||||||
let new_token_account = AccountSharedData::from(Account {
|
let new_token_account = AccountSharedData::from(Account {
|
||||||
|
@ -13135,27 +13126,27 @@ pub(crate) mod tests {
|
||||||
..Account::default()
|
..Account::default()
|
||||||
});
|
});
|
||||||
bank.store_account_and_update_capitalization(
|
bank.store_account_and_update_capitalization(
|
||||||
&inline_spl_token_v2_0::new_token_program::id(),
|
&inline_spl_token::new_token_program::id(),
|
||||||
&new_token_account,
|
&new_token_account,
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_balance(&inline_spl_token_v2_0::new_token_program::id()),
|
bank.get_balance(&inline_spl_token::new_token_program::id()),
|
||||||
123
|
123
|
||||||
);
|
);
|
||||||
|
|
||||||
let original_capitalization = bank.capitalization();
|
let original_capitalization = bank.capitalization();
|
||||||
|
|
||||||
bank.apply_spl_token_v2_set_authority_fix();
|
bank.apply_spl_token_v3_3_0_release();
|
||||||
|
|
||||||
// New token account is now empty
|
// New token account is now empty
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_balance(&inline_spl_token_v2_0::new_token_program::id()),
|
bank.get_balance(&inline_spl_token::new_token_program::id()),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
// Old token account holds the new token account
|
// Old token account holds the new token account
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
bank.get_account(&inline_spl_token_v2_0::id()),
|
bank.get_account(&inline_spl_token::id()),
|
||||||
Some(new_token_account)
|
Some(new_token_account)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Partial SPL Token v2.0.x declarations inlined to avoid an external dependency on the spl-token crate
|
// Partial SPL Token declarations inlined to avoid an external dependency on the spl-token crate
|
||||||
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
||||||
|
|
||||||
pub(crate) mod new_token_program {
|
pub(crate) mod new_token_program {
|
||||||
solana_sdk::declare_id!("nTokHfnBtpt4V6xiEbBSduiGCrQ6wSF3rxC8WeWAQ9F");
|
solana_sdk::declare_id!("nTok2oJvx1CgbYA2SznfJLmnKLEL6sYdh2ypZms2nhm");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -31,7 +31,7 @@ pub mod execute_cost_table;
|
||||||
pub mod genesis_utils;
|
pub mod genesis_utils;
|
||||||
pub mod hardened_unpack;
|
pub mod hardened_unpack;
|
||||||
pub mod in_mem_accounts_index;
|
pub mod in_mem_accounts_index;
|
||||||
pub mod inline_spl_token_v2_0;
|
pub mod inline_spl_token;
|
||||||
pub mod loader_utils;
|
pub mod loader_utils;
|
||||||
pub mod message_processor;
|
pub mod message_processor;
|
||||||
pub mod non_circulating_supply;
|
pub mod non_circulating_supply;
|
||||||
|
|
|
@ -241,6 +241,10 @@ pub mod nonce_must_be_writable {
|
||||||
solana_sdk::declare_id!("BiCU7M5w8ZCMykVSyhZ7Q3m2SWoR2qrEQ86ERcDX77ME");
|
solana_sdk::declare_id!("BiCU7M5w8ZCMykVSyhZ7Q3m2SWoR2qrEQ86ERcDX77ME");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod spl_token_v3_3_0_release {
|
||||||
|
solana_sdk::declare_id!("Ftok2jhqAqxUWEiCVRrfRs9DPppWP8cgTB7NQNKL88mS");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Map of feature identifiers to user-visible description
|
/// Map of feature identifiers to user-visible description
|
||||||
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
|
||||||
|
@ -296,6 +300,7 @@ lazy_static! {
|
||||||
(add_compute_budget_program::id(), "Add compute_budget_program"),
|
(add_compute_budget_program::id(), "Add compute_budget_program"),
|
||||||
(reject_deployment_of_unresolved_syscalls::id(), "Reject deployment of programs with unresolved syscall symbols"),
|
(reject_deployment_of_unresolved_syscalls::id(), "Reject deployment of programs with unresolved syscall symbols"),
|
||||||
(nonce_must_be_writable::id(), "nonce must be writable"),
|
(nonce_must_be_writable::id(), "nonce must be writable"),
|
||||||
|
(spl_token_v3_3_0_release::id(), "spl-token v3.3.0 release"),
|
||||||
/*************** ADD NEW FEATURES HERE ***************/
|
/*************** ADD NEW FEATURES HERE ***************/
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -27,8 +27,8 @@ solana-remote-wallet = { path = "../remote-wallet", version = "=1.9.0" }
|
||||||
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
||||||
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
|
||||||
solana-version = { path = "../version", version = "=1.9.0" }
|
solana-version = { path = "../version", version = "=1.9.0" }
|
||||||
spl-associated-token-account-v1-0 = { package = "spl-associated-token-account", version = "=1.0.3" }
|
spl-associated-token-account = { version = "=1.0.3" }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] }
|
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use pickledb::PickleDb;
|
use pickledb::PickleDb;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_account_decoder::parse_token::{
|
use solana_account_decoder::parse_token::{
|
||||||
pubkey_from_spl_token_v2_0, real_number_string, spl_token_v2_0_pubkey,
|
pubkey_from_spl_token, real_number_string, spl_token_pubkey,
|
||||||
};
|
};
|
||||||
use solana_client::{
|
use solana_client::{
|
||||||
client_error::{ClientError, Result as ClientResult},
|
client_error::{ClientError, Result as ClientResult},
|
||||||
|
@ -35,8 +35,8 @@ use solana_sdk::{
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
use solana_transaction_status::TransactionStatus;
|
use solana_transaction_status::TransactionStatus;
|
||||||
use spl_associated_token_account_v1_0::get_associated_token_address;
|
use spl_associated_token_account::get_associated_token_address;
|
||||||
use spl_token_v2_0::solana_program::program_error::ProgramError;
|
use spl_token::solana_program::program_error::ProgramError;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self},
|
cmp::{self},
|
||||||
io,
|
io,
|
||||||
|
@ -309,12 +309,11 @@ fn build_messages(
|
||||||
let wallet_address = allocation.recipient.parse().unwrap();
|
let wallet_address = allocation.recipient.parse().unwrap();
|
||||||
let associated_token_address = get_associated_token_address(
|
let associated_token_address = get_associated_token_address(
|
||||||
&wallet_address,
|
&wallet_address,
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.mint),
|
&spl_token_pubkey(&spl_token_args.mint),
|
||||||
);
|
);
|
||||||
let do_create_associated_token_account = client
|
let do_create_associated_token_account = client
|
||||||
.get_multiple_accounts(&[pubkey_from_spl_token_v2_0(&associated_token_address)])?
|
.get_multiple_accounts(&[pubkey_from_spl_token(&associated_token_address)])?[0]
|
||||||
[0]
|
.is_none();
|
||||||
.is_none();
|
|
||||||
if do_create_associated_token_account {
|
if do_create_associated_token_account {
|
||||||
*created_accounts += 1;
|
*created_accounts += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,13 @@ use crate::{
|
||||||
};
|
};
|
||||||
use console::style;
|
use console::style;
|
||||||
use solana_account_decoder::parse_token::{
|
use solana_account_decoder::parse_token::{
|
||||||
pubkey_from_spl_token_v2_0, real_number_string, real_number_string_trimmed,
|
pubkey_from_spl_token, real_number_string, real_number_string_trimmed, spl_token_pubkey,
|
||||||
spl_token_v2_0_pubkey,
|
|
||||||
};
|
};
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
use solana_sdk::{instruction::Instruction, message::Message, native_token::lamports_to_sol};
|
use solana_sdk::{instruction::Instruction, message::Message, native_token::lamports_to_sol};
|
||||||
use solana_transaction_status::parse_token::spl_token_v2_0_instruction;
|
use solana_transaction_status::parse_token::spl_token_instruction;
|
||||||
use spl_associated_token_account_v1_0::{
|
use spl_associated_token_account::{create_associated_token_account, get_associated_token_address};
|
||||||
create_associated_token_account, get_associated_token_address,
|
use spl_token::{
|
||||||
};
|
|
||||||
use spl_token_v2_0::{
|
|
||||||
solana_program::program_pack::Pack,
|
solana_program::program_pack::Pack,
|
||||||
state::{Account as SplTokenAccount, Mint},
|
state::{Account as SplTokenAccount, Mint},
|
||||||
};
|
};
|
||||||
|
@ -24,7 +21,7 @@ pub fn update_token_args(client: &RpcClient, args: &mut Option<SplTokenArgs>) ->
|
||||||
.get_account(&spl_token_args.token_account_address)
|
.get_account(&spl_token_args.token_account_address)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mint_address =
|
let mint_address =
|
||||||
pubkey_from_spl_token_v2_0(&SplTokenAccount::unpack(&sender_account.data)?.mint);
|
pubkey_from_spl_token(&SplTokenAccount::unpack(&sender_account.data)?.mint);
|
||||||
spl_token_args.mint = mint_address;
|
spl_token_args.mint = mint_address;
|
||||||
update_decimals(client, args)?;
|
update_decimals(client, args)?;
|
||||||
}
|
}
|
||||||
|
@ -54,33 +51,31 @@ pub fn build_spl_token_instructions(
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("spl_token_args must be some");
|
.expect("spl_token_args must be some");
|
||||||
let wallet_address = allocation.recipient.parse().unwrap();
|
let wallet_address = allocation.recipient.parse().unwrap();
|
||||||
let associated_token_address = get_associated_token_address(
|
let associated_token_address =
|
||||||
&wallet_address,
|
get_associated_token_address(&wallet_address, &spl_token_pubkey(&spl_token_args.mint));
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.mint),
|
|
||||||
);
|
|
||||||
let mut instructions = vec![];
|
let mut instructions = vec![];
|
||||||
if do_create_associated_token_account {
|
if do_create_associated_token_account {
|
||||||
let create_associated_token_account_instruction = create_associated_token_account(
|
let create_associated_token_account_instruction = create_associated_token_account(
|
||||||
&spl_token_v2_0_pubkey(&args.fee_payer.pubkey()),
|
&spl_token_pubkey(&args.fee_payer.pubkey()),
|
||||||
&wallet_address,
|
&wallet_address,
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.mint),
|
&spl_token_pubkey(&spl_token_args.mint),
|
||||||
);
|
);
|
||||||
instructions.push(spl_token_v2_0_instruction(
|
instructions.push(spl_token_instruction(
|
||||||
create_associated_token_account_instruction,
|
create_associated_token_account_instruction,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let spl_instruction = spl_token_v2_0::instruction::transfer_checked(
|
let spl_instruction = spl_token::instruction::transfer_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.token_account_address),
|
&spl_token_pubkey(&spl_token_args.token_account_address),
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.mint),
|
&spl_token_pubkey(&spl_token_args.mint),
|
||||||
&associated_token_address,
|
&associated_token_address,
|
||||||
&spl_token_v2_0_pubkey(&args.sender_keypair.pubkey()),
|
&spl_token_pubkey(&args.sender_keypair.pubkey()),
|
||||||
&[],
|
&[],
|
||||||
allocation.amount,
|
allocation.amount,
|
||||||
spl_token_args.decimals,
|
spl_token_args.decimals,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
instructions.push(spl_token_v2_0_instruction(spl_instruction));
|
instructions.push(spl_token_instruction(spl_instruction));
|
||||||
instructions
|
instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +131,11 @@ pub fn print_token_balances(
|
||||||
let address = allocation.recipient.parse().unwrap();
|
let address = allocation.recipient.parse().unwrap();
|
||||||
let expected = allocation.amount;
|
let expected = allocation.amount;
|
||||||
let associated_token_address = get_associated_token_address(
|
let associated_token_address = get_associated_token_address(
|
||||||
&spl_token_v2_0_pubkey(&address),
|
&spl_token_pubkey(&address),
|
||||||
&spl_token_v2_0_pubkey(&spl_token_args.mint),
|
&spl_token_pubkey(&spl_token_args.mint),
|
||||||
);
|
);
|
||||||
let recipient_account = client
|
let recipient_account = client
|
||||||
.get_account(&pubkey_from_spl_token_v2_0(&associated_token_address))
|
.get_account(&pubkey_from_spl_token(&associated_token_address))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let (actual, difference) = if let Ok(recipient_token) =
|
let (actual, difference) = if let Ok(recipient_token) =
|
||||||
SplTokenAccount::unpack(&recipient_account.data)
|
SplTokenAccount::unpack(&recipient_account.data)
|
||||||
|
|
|
@ -25,9 +25,9 @@ solana-metrics = { path = "../metrics", version = "=1.9.0" }
|
||||||
solana-runtime = { path = "../runtime", version = "=1.9.0" }
|
solana-runtime = { path = "../runtime", version = "=1.9.0" }
|
||||||
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
||||||
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
solana-vote-program = { path = "../programs/vote", version = "=1.9.0" }
|
||||||
spl-associated-token-account-v1-0 = { package = "spl-associated-token-account", version = "=1.0.3", features = ["no-entrypoint"] }
|
spl-associated-token-account = { version = "=1.0.3", features = ["no-entrypoint"] }
|
||||||
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
|
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
|
||||||
spl-token-v2-0 = { package = "spl-token", version = "=3.2.0", features = ["no-entrypoint"] }
|
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
|
|
@ -6,10 +6,10 @@ use {
|
||||||
solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey},
|
solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey},
|
||||||
};
|
};
|
||||||
|
|
||||||
// A helper function to convert spl_associated_token_account_v1_0::id() as spl_sdk::pubkey::Pubkey
|
// A helper function to convert spl_associated_token_account::id() as spl_sdk::pubkey::Pubkey
|
||||||
// to solana_sdk::pubkey::Pubkey
|
// to solana_sdk::pubkey::Pubkey
|
||||||
pub fn spl_associated_token_id_v1_0() -> Pubkey {
|
pub fn spl_associated_token_id() -> Pubkey {
|
||||||
Pubkey::new_from_array(spl_associated_token_account_v1_0::id().to_bytes())
|
Pubkey::new_from_array(spl_associated_token_account::id().to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_associated_token(
|
pub fn parse_associated_token(
|
||||||
|
@ -51,7 +51,7 @@ fn check_num_associated_token_accounts(
|
||||||
mod test {
|
mod test {
|
||||||
use {
|
use {
|
||||||
super::*,
|
super::*,
|
||||||
spl_associated_token_account_v1_0::{
|
spl_associated_token_account::{
|
||||||
create_associated_token_account,
|
create_associated_token_account,
|
||||||
solana_program::{
|
solana_program::{
|
||||||
instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction,
|
instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
extract_memos::{spl_memo_id_v1, spl_memo_id_v3},
|
extract_memos::{spl_memo_id_v1, spl_memo_id_v3},
|
||||||
parse_associated_token::{parse_associated_token, spl_associated_token_id_v1_0},
|
parse_associated_token::{parse_associated_token, spl_associated_token_id},
|
||||||
parse_bpf_loader::{parse_bpf_loader, parse_bpf_upgradeable_loader},
|
parse_bpf_loader::{parse_bpf_loader, parse_bpf_upgradeable_loader},
|
||||||
parse_stake::parse_stake,
|
parse_stake::parse_stake,
|
||||||
parse_system::parse_system,
|
parse_system::parse_system,
|
||||||
|
@ -10,7 +10,7 @@ use {
|
||||||
},
|
},
|
||||||
inflector::Inflector,
|
inflector::Inflector,
|
||||||
serde_json::Value,
|
serde_json::Value,
|
||||||
solana_account_decoder::parse_token::spl_token_id_v2_0,
|
solana_account_decoder::parse_token::spl_token_id,
|
||||||
solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey, stake, system_program},
|
solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey, stake, system_program},
|
||||||
std::{
|
std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
@ -20,14 +20,14 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref ASSOCIATED_TOKEN_PROGRAM_ID: Pubkey = spl_associated_token_id_v1_0();
|
static ref ASSOCIATED_TOKEN_PROGRAM_ID: Pubkey = spl_associated_token_id();
|
||||||
static ref BPF_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader::id();
|
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 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_V1_PROGRAM_ID: Pubkey = spl_memo_id_v1();
|
||||||
static ref MEMO_V3_PROGRAM_ID: Pubkey = spl_memo_id_v3();
|
static ref MEMO_V3_PROGRAM_ID: Pubkey = spl_memo_id_v3();
|
||||||
static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id();
|
static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id();
|
||||||
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
|
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
|
||||||
static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id_v2_0();
|
static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id();
|
||||||
static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
|
static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
|
||||||
static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableProgram> = {
|
static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableProgram> = {
|
||||||
let mut m = HashMap::new();
|
let mut m = HashMap::new();
|
||||||
|
|
|
@ -3,12 +3,12 @@ use {
|
||||||
check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum,
|
check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum,
|
||||||
},
|
},
|
||||||
serde_json::{json, Map, Value},
|
serde_json::{json, Map, Value},
|
||||||
solana_account_decoder::parse_token::{pubkey_from_spl_token_v2_0, token_amount_to_ui_amount},
|
solana_account_decoder::parse_token::{pubkey_from_spl_token, token_amount_to_ui_amount},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
instruction::{AccountMeta, CompiledInstruction, Instruction},
|
instruction::{AccountMeta, CompiledInstruction, Instruction},
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
},
|
},
|
||||||
spl_token_v2_0::{
|
spl_token::{
|
||||||
instruction::{AuthorityType, TokenInstruction},
|
instruction::{AuthorityType, TokenInstruction},
|
||||||
solana_program::{
|
solana_program::{
|
||||||
instruction::Instruction as SplTokenInstruction, program_option::COption,
|
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)
|
check_num_accounts(accounts, num, ParsableProgram::SplToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spl_token_v2_0_instruction(instruction: SplTokenInstruction) -> Instruction {
|
pub fn spl_token_instruction(instruction: SplTokenInstruction) -> Instruction {
|
||||||
Instruction {
|
Instruction {
|
||||||
program_id: pubkey_from_spl_token_v2_0(&instruction.program_id),
|
program_id: pubkey_from_spl_token(&instruction.program_id),
|
||||||
accounts: instruction
|
accounts: instruction
|
||||||
.accounts
|
.accounts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|meta| AccountMeta {
|
.map(|meta| AccountMeta {
|
||||||
pubkey: pubkey_from_spl_token_v2_0(&meta.pubkey),
|
pubkey: pubkey_from_spl_token(&meta.pubkey),
|
||||||
is_signer: meta.is_signer,
|
is_signer: meta.is_signer,
|
||||||
is_writable: meta.is_writable,
|
is_writable: meta.is_writable,
|
||||||
})
|
})
|
||||||
|
@ -459,7 +459,7 @@ mod test {
|
||||||
use {
|
use {
|
||||||
super::*,
|
super::*,
|
||||||
solana_sdk::instruction::CompiledInstruction,
|
solana_sdk::instruction::CompiledInstruction,
|
||||||
spl_token_v2_0::{
|
spl_token::{
|
||||||
instruction::*,
|
instruction::*,
|
||||||
solana_program::{
|
solana_program::{
|
||||||
instruction::CompiledInstruction as SplTokenCompiledInstruction, message::Message,
|
instruction::CompiledInstruction as SplTokenCompiledInstruction, message::Message,
|
||||||
|
@ -493,7 +493,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeMint variations
|
// Test InitializeMint variations
|
||||||
let initialize_mint_ix = initialize_mint(
|
let initialize_mint_ix = initialize_mint(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
Some(&convert_pubkey(keys[3])),
|
Some(&convert_pubkey(keys[3])),
|
||||||
|
@ -517,7 +517,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let initialize_mint_ix = initialize_mint(
|
let initialize_mint_ix = initialize_mint(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
None,
|
None,
|
||||||
|
@ -541,7 +541,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeAccount
|
// Test InitializeAccount
|
||||||
let initialize_account_ix = initialize_account(
|
let initialize_account_ix = initialize_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
|
@ -564,7 +564,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeMultisig
|
// Test InitializeMultisig
|
||||||
let initialize_multisig_ix = initialize_multisig(
|
let initialize_multisig_ix = initialize_multisig(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&[
|
&[
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
|
@ -591,7 +591,7 @@ mod test {
|
||||||
|
|
||||||
// Test Transfer, incl multisig
|
// Test Transfer, incl multisig
|
||||||
let transfer_ix = transfer(
|
let transfer_ix = transfer(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -615,7 +615,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let transfer_ix = transfer(
|
let transfer_ix = transfer(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -641,7 +641,7 @@ mod test {
|
||||||
|
|
||||||
// Test Approve, incl multisig
|
// Test Approve, incl multisig
|
||||||
let approve_ix = approve(
|
let approve_ix = approve(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -665,7 +665,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let approve_ix = approve(
|
let approve_ix = approve(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -691,7 +691,7 @@ mod test {
|
||||||
|
|
||||||
// Test Revoke
|
// Test Revoke
|
||||||
let revoke_ix = revoke(
|
let revoke_ix = revoke(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&[],
|
&[],
|
||||||
|
@ -712,7 +712,7 @@ mod test {
|
||||||
|
|
||||||
// Test SetOwner
|
// Test SetOwner
|
||||||
let set_authority_ix = set_authority(
|
let set_authority_ix = set_authority(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
Some(&convert_pubkey(keys[2])),
|
Some(&convert_pubkey(keys[2])),
|
||||||
AuthorityType::FreezeAccount,
|
AuthorityType::FreezeAccount,
|
||||||
|
@ -736,7 +736,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let set_authority_ix = set_authority(
|
let set_authority_ix = set_authority(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
None,
|
None,
|
||||||
AuthorityType::CloseAccount,
|
AuthorityType::CloseAccount,
|
||||||
|
@ -762,7 +762,7 @@ mod test {
|
||||||
|
|
||||||
// Test MintTo
|
// Test MintTo
|
||||||
let mint_to_ix = mint_to(
|
let mint_to_ix = mint_to(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -787,7 +787,7 @@ mod test {
|
||||||
|
|
||||||
// Test Burn
|
// Test Burn
|
||||||
let burn_ix = burn(
|
let burn_ix = burn(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -812,7 +812,7 @@ mod test {
|
||||||
|
|
||||||
// Test CloseAccount
|
// Test CloseAccount
|
||||||
let close_account_ix = close_account(
|
let close_account_ix = close_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -835,7 +835,7 @@ mod test {
|
||||||
|
|
||||||
// Test FreezeAccount
|
// Test FreezeAccount
|
||||||
let freeze_account_ix = freeze_account(
|
let freeze_account_ix = freeze_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -858,7 +858,7 @@ mod test {
|
||||||
|
|
||||||
// Test ThawAccount
|
// Test ThawAccount
|
||||||
let thaw_account_ix = thaw_account(
|
let thaw_account_ix = thaw_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -881,7 +881,7 @@ mod test {
|
||||||
|
|
||||||
// Test TransferChecked, incl multisig
|
// Test TransferChecked, incl multisig
|
||||||
let transfer_ix = transfer_checked(
|
let transfer_ix = transfer_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
|
@ -913,7 +913,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let transfer_ix = transfer_checked(
|
let transfer_ix = transfer_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -947,7 +947,7 @@ mod test {
|
||||||
|
|
||||||
// Test ApproveChecked, incl multisig
|
// Test ApproveChecked, incl multisig
|
||||||
let approve_ix = approve_checked(
|
let approve_ix = approve_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
|
@ -979,7 +979,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let approve_ix = approve_checked(
|
let approve_ix = approve_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -1013,7 +1013,7 @@ mod test {
|
||||||
|
|
||||||
// Test MintToChecked
|
// Test MintToChecked
|
||||||
let mint_to_ix = mint_to_checked(
|
let mint_to_ix = mint_to_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1044,7 +1044,7 @@ mod test {
|
||||||
|
|
||||||
// Test BurnChecked
|
// Test BurnChecked
|
||||||
let burn_ix = burn_checked(
|
let burn_ix = burn_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1074,7 +1074,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test SyncNative
|
// Test SyncNative
|
||||||
let sync_native_ix = sync_native(&spl_token_v2_0::id(), &convert_pubkey(keys[0])).unwrap();
|
let sync_native_ix = sync_native(&spl_token::id(), &convert_pubkey(keys[0])).unwrap();
|
||||||
let message = Message::new(&[sync_native_ix], None);
|
let message = Message::new(&[sync_native_ix], None);
|
||||||
let compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
|
let compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1098,7 +1098,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeMint variations
|
// Test InitializeMint variations
|
||||||
let initialize_mint_ix = initialize_mint(
|
let initialize_mint_ix = initialize_mint(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
Some(&convert_pubkey(keys[2])),
|
Some(&convert_pubkey(keys[2])),
|
||||||
|
@ -1113,7 +1113,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
let initialize_mint_ix = initialize_mint(
|
let initialize_mint_ix = initialize_mint(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
None,
|
None,
|
||||||
|
@ -1129,7 +1129,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeAccount
|
// Test InitializeAccount
|
||||||
let initialize_account_ix = initialize_account(
|
let initialize_account_ix = initialize_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
|
@ -1144,7 +1144,7 @@ mod test {
|
||||||
|
|
||||||
// Test InitializeMultisig
|
// Test InitializeMultisig
|
||||||
let initialize_multisig_ix = initialize_multisig(
|
let initialize_multisig_ix = initialize_multisig(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&[
|
&[
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
|
@ -1163,7 +1163,7 @@ mod test {
|
||||||
|
|
||||||
// Test Transfer, incl multisig
|
// Test Transfer, incl multisig
|
||||||
let transfer_ix = transfer(
|
let transfer_ix = transfer(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1179,7 +1179,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
let transfer_ix = transfer(
|
let transfer_ix = transfer(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -1196,7 +1196,7 @@ mod test {
|
||||||
|
|
||||||
// Test Approve, incl multisig
|
// Test Approve, incl multisig
|
||||||
let approve_ix = approve(
|
let approve_ix = approve(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1212,7 +1212,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
let approve_ix = approve(
|
let approve_ix = approve(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -1229,7 +1229,7 @@ mod test {
|
||||||
|
|
||||||
// Test Revoke
|
// Test Revoke
|
||||||
let revoke_ix = revoke(
|
let revoke_ix = revoke(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
&[],
|
&[],
|
||||||
|
@ -1244,7 +1244,7 @@ mod test {
|
||||||
|
|
||||||
// Test SetAuthority
|
// Test SetAuthority
|
||||||
let set_authority_ix = set_authority(
|
let set_authority_ix = set_authority(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
Some(&convert_pubkey(keys[2])),
|
Some(&convert_pubkey(keys[2])),
|
||||||
AuthorityType::FreezeAccount,
|
AuthorityType::FreezeAccount,
|
||||||
|
@ -1261,7 +1261,7 @@ mod test {
|
||||||
|
|
||||||
// Test MintTo
|
// Test MintTo
|
||||||
let mint_to_ix = mint_to(
|
let mint_to_ix = mint_to(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1278,7 +1278,7 @@ mod test {
|
||||||
|
|
||||||
// Test Burn
|
// Test Burn
|
||||||
let burn_ix = burn(
|
let burn_ix = burn(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1295,7 +1295,7 @@ mod test {
|
||||||
|
|
||||||
// Test CloseAccount
|
// Test CloseAccount
|
||||||
let close_account_ix = close_account(
|
let close_account_ix = close_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1311,7 +1311,7 @@ mod test {
|
||||||
|
|
||||||
// Test FreezeAccount
|
// Test FreezeAccount
|
||||||
let freeze_account_ix = freeze_account(
|
let freeze_account_ix = freeze_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1327,7 +1327,7 @@ mod test {
|
||||||
|
|
||||||
// Test ThawAccount
|
// Test ThawAccount
|
||||||
let thaw_account_ix = thaw_account(
|
let thaw_account_ix = thaw_account(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1343,7 +1343,7 @@ mod test {
|
||||||
|
|
||||||
// Test TransferChecked, incl multisig
|
// Test TransferChecked, incl multisig
|
||||||
let transfer_ix = transfer_checked(
|
let transfer_ix = transfer_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
|
@ -1361,7 +1361,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
let transfer_ix = transfer_checked(
|
let transfer_ix = transfer_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -1380,7 +1380,7 @@ mod test {
|
||||||
|
|
||||||
// Test ApproveChecked, incl multisig
|
// Test ApproveChecked, incl multisig
|
||||||
let approve_ix = approve_checked(
|
let approve_ix = approve_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
|
@ -1398,7 +1398,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
let approve_ix = approve_checked(
|
let approve_ix = approve_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[3]),
|
&convert_pubkey(keys[3]),
|
||||||
&convert_pubkey(keys[4]),
|
&convert_pubkey(keys[4]),
|
||||||
|
@ -1417,7 +1417,7 @@ mod test {
|
||||||
|
|
||||||
// Test MintToChecked
|
// Test MintToChecked
|
||||||
let mint_to_ix = mint_to_checked(
|
let mint_to_ix = mint_to_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1435,7 +1435,7 @@ mod test {
|
||||||
|
|
||||||
// Test BurnChecked
|
// Test BurnChecked
|
||||||
let burn_ix = burn_checked(
|
let burn_ix = burn_checked(
|
||||||
&spl_token_v2_0::id(),
|
&spl_token::id(),
|
||||||
&convert_pubkey(keys[1]),
|
&convert_pubkey(keys[1]),
|
||||||
&convert_pubkey(keys[2]),
|
&convert_pubkey(keys[2]),
|
||||||
&convert_pubkey(keys[0]),
|
&convert_pubkey(keys[0]),
|
||||||
|
@ -1452,7 +1452,7 @@ mod test {
|
||||||
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
assert!(parse_token(&compiled_instruction, &keys).is_err());
|
||||||
|
|
||||||
// Test SyncNative
|
// Test SyncNative
|
||||||
let sync_native_ix = sync_native(&spl_token_v2_0::id(), &convert_pubkey(keys[0])).unwrap();
|
let sync_native_ix = sync_native(&spl_token::id(), &convert_pubkey(keys[0])).unwrap();
|
||||||
let message = Message::new(&[sync_native_ix], None);
|
let message = Message::new(&[sync_native_ix], None);
|
||||||
let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
|
let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
|
||||||
assert!(parse_token(&compiled_instruction, &[]).is_err());
|
assert!(parse_token(&compiled_instruction, &[]).is_err());
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use {
|
use {
|
||||||
crate::TransactionTokenBalance,
|
crate::TransactionTokenBalance,
|
||||||
solana_account_decoder::parse_token::{
|
solana_account_decoder::parse_token::{
|
||||||
pubkey_from_spl_token_v2_0, spl_token_id_v2_0, spl_token_v2_0_native_mint,
|
pubkey_from_spl_token, spl_token_id, spl_token_native_mint, token_amount_to_ui_amount,
|
||||||
token_amount_to_ui_amount, UiTokenAmount,
|
UiTokenAmount,
|
||||||
},
|
},
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_metrics::datapoint_debug,
|
solana_metrics::datapoint_debug,
|
||||||
solana_runtime::{bank::Bank, transaction_batch::TransactionBatch},
|
solana_runtime::{bank::Bank, transaction_batch::TransactionBatch},
|
||||||
solana_sdk::{account::ReadableAccount, pubkey::Pubkey},
|
solana_sdk::{account::ReadableAccount, pubkey::Pubkey},
|
||||||
spl_token_v2_0::{
|
spl_token::{
|
||||||
solana_program::program_pack::Pack,
|
solana_program::program_pack::Pack,
|
||||||
state::{Account as TokenAccount, Mint},
|
state::{Account as TokenAccount, Mint},
|
||||||
},
|
},
|
||||||
|
@ -36,12 +36,12 @@ impl TransactionTokenBalancesSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_token_program(program_id: &Pubkey) -> bool {
|
fn is_token_program(program_id: &Pubkey) -> bool {
|
||||||
program_id == &spl_token_id_v2_0()
|
program_id == &spl_token_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mint_decimals(bank: &Bank, mint: &Pubkey) -> Option<u8> {
|
fn get_mint_decimals(bank: &Bank, mint: &Pubkey) -> Option<u8> {
|
||||||
if mint == &spl_token_v2_0_native_mint() {
|
if mint == &spl_token_native_mint() {
|
||||||
Some(spl_token_v2_0::native_mint::DECIMALS)
|
Some(spl_token::native_mint::DECIMALS)
|
||||||
} else {
|
} else {
|
||||||
let mint_account = bank.get_account(mint)?;
|
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 account = bank.get_account(account_id)?;
|
||||||
|
|
||||||
let token_account = TokenAccount::unpack(account.data()).ok()?;
|
let token_account = TokenAccount::unpack(account.data()).ok()?;
|
||||||
let mint = pubkey_from_spl_token_v2_0(&token_account.mint);
|
let mint = pubkey_from_spl_token(&token_account.mint);
|
||||||
|
|
||||||
let decimals = mint_decimals.get(&mint).cloned().or_else(|| {
|
let decimals = mint_decimals.get(&mint).cloned().or_else(|| {
|
||||||
let decimals = get_mint_decimals(bank, &mint)?;
|
let decimals = get_mint_decimals(bank, &mint)?;
|
||||||
|
|
Loading…
Reference in New Issue