Prepare RPC subsystem for multiple SPL Token program ids
(cherry picked from commit 86d465c531
)
# Conflicts:
# rpc/src/rpc.rs
# transaction-status/src/parse_instruction.rs
# transaction-status/src/token_balances.rs
This commit is contained in:
@@ -10,8 +10,16 @@ use {
|
||||
},
|
||||
inflector::Inflector,
|
||||
serde_json::Value,
|
||||
<<<<<<< HEAD
|
||||
solana_account_decoder::parse_token::spl_token_id,
|
||||
solana_sdk::{instruction::CompiledInstruction, pubkey::Pubkey, stake, system_program},
|
||||
=======
|
||||
solana_account_decoder::parse_token::spl_token_ids,
|
||||
solana_sdk::{
|
||||
instruction::CompiledInstruction, message::AccountKeys, pubkey::Pubkey, stake,
|
||||
system_program,
|
||||
},
|
||||
>>>>>>> 86d465c53 (Prepare RPC subsystem for multiple SPL Token program ids)
|
||||
std::{
|
||||
collections::HashMap,
|
||||
str::{from_utf8, Utf8Error},
|
||||
@@ -27,7 +35,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();
|
||||
@@ -37,7 +44,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)
|
||||
@@ -62,6 +58,7 @@ pub fn collect_token_balances(
|
||||
let mut collect_time = Measure::start("collect_token_balances");
|
||||
|
||||
for transaction in batch.sanitized_transactions() {
|
||||
<<<<<<< HEAD
|
||||
let has_token_program = transaction
|
||||
.message()
|
||||
.account_keys_iter()
|
||||
@@ -71,6 +68,15 @@ pub fn collect_token_balances(
|
||||
if has_token_program {
|
||||
for (index, account_id) in transaction.message().account_keys_iter().enumerate() {
|
||||
if transaction.message().is_invoked(index) || is_token_program(account_id) {
|
||||
=======
|
||||
let account_keys = transaction.message().account_keys();
|
||||
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_known_spl_token_id(account_id) {
|
||||
>>>>>>> 86d465c53 (Prepare RPC subsystem for multiple SPL Token program ids)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user