From 3913fb281e708f4aad8e54b0f2402f0eeef064e7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 2 Feb 2021 08:25:25 +0000 Subject: [PATCH] Parse SPL Memo v3 (bp #14979) (#14988) * Parse SPL Memo v3 (#14979) * Parse memo v3 too * tree (cherry picked from commit 34dfcc9c6f72738f08f80199823058bcdae35966) # Conflicts: # Cargo.lock * Fix version conflicts (inline v3 id) Co-authored-by: Tyera Eulberg Co-authored-by: Tyera Eulberg --- transaction-status/src/parse_instruction.rs | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/transaction-status/src/parse_instruction.rs b/transaction-status/src/parse_instruction.rs index 972b15b3db..850d15e39b 100644 --- a/transaction-status/src/parse_instruction.rs +++ b/transaction-status/src/parse_instruction.rs @@ -12,17 +12,25 @@ use std::{ }; use thiserror::Error; +// Inline to prevent version conflicts in v1.4 branch +mod spl_memo_v3_0 { + solana_sdk::declare_id!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"); +} + lazy_static! { static ref BPF_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader::id(); - static ref MEMO_PROGRAM_ID: Pubkey = + static ref MEMO_V1_PROGRAM_ID: Pubkey = Pubkey::from_str(&spl_memo_v1_0::id().to_string()).unwrap(); + static ref MEMO_V3_PROGRAM_ID: Pubkey = + Pubkey::from_str(&spl_memo_v3_0::id().to_string()).unwrap(); static ref STAKE_PROGRAM_ID: Pubkey = solana_stake_program::id(); static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id(); static ref TOKEN_PROGRAM_ID: Pubkey = spl_token_id_v2_0(); static ref VOTE_PROGRAM_ID: Pubkey = solana_vote_program::id(); static ref PARSABLE_PROGRAM_IDS: HashMap = { let mut m = HashMap::new(); - m.insert(*MEMO_PROGRAM_ID, ParsableProgram::SplMemo); + m.insert(*MEMO_V1_PROGRAM_ID, ParsableProgram::SplMemo); + m.insert(*MEMO_V3_PROGRAM_ID, ParsableProgram::SplMemo); m.insert(*TOKEN_PROGRAM_ID, ParsableProgram::SplToken); m.insert(*BPF_LOADER_PROGRAM_ID, ParsableProgram::BpfLoader); m.insert(*STAKE_PROGRAM_ID, ParsableProgram::Stake); @@ -131,10 +139,18 @@ mod test { data: vec![240, 159, 166, 150], }; assert_eq!( - parse(&MEMO_PROGRAM_ID, &memo_instruction, &[]).unwrap(), + parse(&MEMO_V1_PROGRAM_ID, &memo_instruction, &[]).unwrap(), ParsedInstruction { program: "spl-memo".to_string(), - program_id: MEMO_PROGRAM_ID.to_string(), + program_id: MEMO_V1_PROGRAM_ID.to_string(), + parsed: json!("🦖"), + } + ); + assert_eq!( + parse(&MEMO_V3_PROGRAM_ID, &memo_instruction, &[]).unwrap(), + ParsedInstruction { + program: "spl-memo".to_string(), + program_id: MEMO_V3_PROGRAM_ID.to_string(), parsed: json!("🦖"), } );