Prepare RPC subsystem for multiple SPL Token program ids
This commit is contained in:
@@ -10,7 +10,7 @@ use {
|
||||
},
|
||||
inflector::Inflector,
|
||||
serde_json::Value,
|
||||
solana_account_decoder::parse_token::spl_token_id,
|
||||
solana_account_decoder::parse_token::spl_token_ids,
|
||||
solana_sdk::{
|
||||
instruction::CompiledInstruction, message::AccountKeys, pubkey::Pubkey, stake,
|
||||
system_program,
|
||||
@@ -30,7 +30,6 @@ lazy_static! {
|
||||
static ref MEMO_V3_PROGRAM_ID: Pubkey = spl_memo_id_v3();
|
||||
static ref STAKE_PROGRAM_ID: Pubkey = stake::program::id();
|
||||
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
|
||||
static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id();
|
||||
static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id();
|
||||
static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableProgram> = {
|
||||
let mut m = HashMap::new();
|
||||
@@ -40,7 +39,9 @@ lazy_static! {
|
||||
);
|
||||
m.insert(*MEMO_V1_PROGRAM_ID, ParsableProgram::SplMemo);
|
||||
m.insert(*MEMO_V3_PROGRAM_ID, ParsableProgram::SplMemo);
|
||||
m.insert(*TOKEN_PROGRAM_ID, ParsableProgram::SplToken);
|
||||
for spl_token_id in spl_token_ids() {
|
||||
m.insert(spl_token_id, ParsableProgram::SplToken);
|
||||
}
|
||||
m.insert(*BPF_LOADER_PROGRAM_ID, ParsableProgram::BpfLoader);
|
||||
m.insert(
|
||||
*BPF_UPGRADEABLE_LOADER_PROGRAM_ID,
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use {
|
||||
crate::TransactionTokenBalance,
|
||||
solana_account_decoder::parse_token::{
|
||||
pubkey_from_spl_token, spl_token_id, spl_token_native_mint, token_amount_to_ui_amount,
|
||||
UiTokenAmount,
|
||||
is_known_spl_token_id, pubkey_from_spl_token, spl_token_native_mint,
|
||||
token_amount_to_ui_amount, UiTokenAmount,
|
||||
},
|
||||
solana_measure::measure::Measure,
|
||||
solana_metrics::datapoint_debug,
|
||||
@@ -35,10 +35,6 @@ impl TransactionTokenBalancesSet {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_token_program(program_id: &Pubkey) -> bool {
|
||||
program_id == &spl_token_id()
|
||||
}
|
||||
|
||||
fn get_mint_decimals(bank: &Bank, mint: &Pubkey) -> Option<u8> {
|
||||
if mint == &spl_token_native_mint() {
|
||||
Some(spl_token::native_mint::DECIMALS)
|
||||
@@ -63,12 +59,12 @@ pub fn collect_token_balances(
|
||||
|
||||
for transaction in batch.sanitized_transactions() {
|
||||
let account_keys = transaction.message().account_keys();
|
||||
let has_token_program = account_keys.iter().any(is_token_program);
|
||||
let has_token_program = account_keys.iter().any(is_known_spl_token_id);
|
||||
|
||||
let mut transaction_balances: Vec<TransactionTokenBalance> = vec![];
|
||||
if has_token_program {
|
||||
for (index, account_id) in account_keys.iter().enumerate() {
|
||||
if transaction.message().is_invoked(index) || is_token_program(account_id) {
|
||||
if transaction.message().is_invoked(index) || is_known_spl_token_id(account_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user