Parse upgradeable loader instructions and accounts (#15195)

* Parse upgradeable-loader instructions

* Parse upgradeable-loader accounts
This commit is contained in:
Tyera Eulberg
2021-02-08 17:18:10 -07:00
committed by GitHub
parent c51e49a746
commit c0a6272afd
5 changed files with 465 additions and 4 deletions

View File

@@ -1,6 +1,9 @@
use crate::{
parse_bpf_loader::parse_bpf_loader, parse_stake::parse_stake, parse_system::parse_system,
parse_token::parse_token, parse_vote::parse_vote,
parse_bpf_loader::{parse_bpf_loader, parse_bpf_upgradeable_loader},
parse_stake::parse_stake,
parse_system::parse_system,
parse_token::parse_token,
parse_vote::parse_vote,
};
use inflector::Inflector;
use serde_json::Value;
@@ -14,6 +17,7 @@ use thiserror::Error;
lazy_static! {
static ref BPF_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader::id();
static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id();
static ref MEMO_V1_PROGRAM_ID: Pubkey =
Pubkey::from_str(&spl_memo_v1_0::id().to_string()).unwrap();
static ref MEMO_V3_PROGRAM_ID: Pubkey =
@@ -28,6 +32,10 @@ lazy_static! {
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(
*BPF_UPGRADEABLE_LOADER_PROGRAM_ID,
ParsableProgram::BpfUpgradeableLoader,
);
m.insert(*STAKE_PROGRAM_ID, ParsableProgram::Stake);
m.insert(*SYSTEM_PROGRAM_ID, ParsableProgram::System);
m.insert(*VOTE_PROGRAM_ID, ParsableProgram::Vote);
@@ -73,6 +81,7 @@ pub enum ParsableProgram {
SplMemo,
SplToken,
BpfLoader,
BpfUpgradeableLoader,
Stake,
System,
Vote,
@@ -92,6 +101,9 @@ pub fn parse(
ParsableProgram::BpfLoader => {
serde_json::to_value(parse_bpf_loader(instruction, account_keys)?)?
}
ParsableProgram::BpfUpgradeableLoader => {
serde_json::to_value(parse_bpf_upgradeable_loader(instruction, account_keys)?)?
}
ParsableProgram::Stake => serde_json::to_value(parse_stake(instruction, account_keys)?)?,
ParsableProgram::System => serde_json::to_value(parse_system(instruction, account_keys)?)?,
ParsableProgram::Vote => serde_json::to_value(parse_vote(instruction, account_keys)?)?,