Skip to content

Commit

Permalink
remove almost all solana-sdk usage from transaction-status
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Jan 10, 2025
1 parent 74673b8 commit a06e0ae
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 79 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions svm/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions transaction-status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
solana-account-decoder = { workspace = true }
solana-clock = { workspace = true }
solana-hash = { workspace = true }
solana-instruction = { workspace = true }
solana-message = { workspace = true }
solana-program = { workspace = true }
solana-pubkey = { workspace = true }
solana-reserved-account-keys = { workspace = true }
solana-reward-info = { workspace = true }
solana-sdk = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-signature = { workspace = true }
solana-system-interface = { workspace = true }
solana-transaction = { workspace = true }
solana-transaction-error = { workspace = true }
solana-transaction-status-client-types = { workspace = true }
spl-associated-token-account = { workspace = true, features = ["no-entrypoint"] }
spl-memo = { workspace = true, features = ["no-entrypoint"] }
Expand All @@ -35,6 +46,7 @@ thiserror = { workspace = true }

[dev-dependencies]
bytemuck = { workspace = true }
solana-pubkey = { workspace = true, features = ["rand"] }
spl-token-confidential-transfer-proof-extraction = { workspace = true }

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion transaction-status/benches/extract_memos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extern crate test;

use {
solana_message::{compiled_instruction::CompiledInstruction, Message},
solana_sdk::pubkey::Pubkey,
solana_pubkey::Pubkey,
solana_transaction_status::extract_memos::{spl_memo_id_v1, spl_memo_id_v3, ExtractMemos},
test::Bencher,
};
Expand Down
2 changes: 1 addition & 1 deletion transaction-status/src/extract_memos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
solana_message::{
compiled_instruction::CompiledInstruction, AccountKeys, Message, SanitizedMessage,
},
solana_sdk::pubkey::Pubkey,
solana_pubkey::Pubkey,
};

// A helper function to convert spl_memo::v1::id() as spl_sdk::pubkey::Pubkey to
Expand Down
18 changes: 10 additions & 8 deletions transaction-status/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub use {
crate::extract_memos::extract_and_fmt_memos,
solana_sdk::reward_type::RewardType,
solana_reward_info::RewardType,
solana_transaction_status_client_types::{
option_serializer, ConfirmedTransactionStatusWithSignature, EncodeError,
EncodedConfirmedBlock, EncodedConfirmedTransactionWithStatusMeta, EncodedTransaction,
Expand All @@ -23,19 +23,21 @@ use {
parse_instruction::parse,
},
base64::{prelude::BASE64_STANDARD, Engine},
solana_clock::{Slot, UnixTimestamp},
solana_hash::Hash,
solana_message::{
compiled_instruction::CompiledInstruction,
v0::{self, LoadedAddresses, LoadedMessage},
AccountKeys, Message, VersionedMessage,
},
solana_sdk::{
clock::{Slot, UnixTimestamp},
hash::Hash,
pubkey::Pubkey,
reserved_account_keys::ReservedAccountKeys,
signature::Signature,
transaction::{Transaction, TransactionError, TransactionVersion, VersionedTransaction},
solana_pubkey::Pubkey,
solana_reserved_account_keys::ReservedAccountKeys,
solana_signature::Signature,
solana_transaction::{
versioned::{TransactionVersion, VersionedTransaction},
Transaction,
},
solana_transaction_error::TransactionError,
std::collections::HashSet,
thiserror::Error,
};
Expand Down
5 changes: 3 additions & 2 deletions transaction-status/src/parse_accounts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use solana_transaction_status_client_types::{ParsedAccount, ParsedAccountSource};
use {
solana_message::{v0::LoadedMessage, Message},
solana_sdk::reserved_account_keys::ReservedAccountKeys,
solana_reserved_account_keys::ReservedAccountKeys,
};

pub fn parse_legacy_message_accounts(message: &Message) -> Vec<ParsedAccount> {
Expand Down Expand Up @@ -41,7 +41,8 @@ mod test {
use {
super::*,
solana_message::{v0, v0::LoadedAddresses, MessageHeader},
solana_sdk::{pubkey::Pubkey, reserved_account_keys::ReservedAccountKeys},
solana_pubkey::Pubkey,
solana_reserved_account_keys::ReservedAccountKeys,
};

#[test]
Expand Down
8 changes: 3 additions & 5 deletions transaction-status/src/parse_address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
bincode::deserialize,
serde_json::json,
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::address_lookup_table::instruction::ProgramInstruction,
solana_program::address_lookup_table::instruction::ProgramInstruction,
};

pub fn parse_address_lookup_table(
Expand Down Expand Up @@ -114,10 +114,8 @@ fn check_num_address_lookup_table_accounts(
#[cfg(test)]
mod test {
use {
super::*,
solana_message::Message,
solana_sdk::{address_lookup_table::instruction, pubkey::Pubkey, system_program},
std::str::FromStr,
super::*, solana_message::Message, solana_program::address_lookup_table::instruction,
solana_pubkey::Pubkey, solana_sdk_ids::system_program, std::str::FromStr,
};

#[test]
Expand Down
10 changes: 5 additions & 5 deletions transaction-status/src/parse_associated_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
borsh::BorshDeserialize,
serde_json::json,
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::pubkey::Pubkey,
solana_pubkey::Pubkey,
spl_associated_token_account::instruction::AssociatedTokenAccountInstruction,
};

Expand Down Expand Up @@ -96,7 +96,7 @@ mod test {
use {
super::*,
solana_message::Message,
solana_sdk::sysvar,
solana_sdk_ids::sysvar,
spl_associated_token_account::{
get_associated_token_address, get_associated_token_address_with_program_id,
instruction::{
Expand All @@ -123,7 +123,7 @@ mod test {
"account": associated_account_address.to_string(),
"wallet": wallet_address.to_string(),
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"systemProgram": solana_sdk_ids::system_program::id().to_string(),
"tokenProgram": spl_token::id().to_string(),
}),
};
Expand Down Expand Up @@ -186,7 +186,7 @@ mod test {
"account": associated_account_address.to_string(),
"wallet": wallet_address.to_string(),
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"systemProgram": solana_sdk_ids::system_program::id().to_string(),
"tokenProgram": token_program_id.to_string(),
})
}
Expand Down Expand Up @@ -228,7 +228,7 @@ mod test {
"account": associated_account_address.to_string(),
"wallet": wallet_address.to_string(),
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"systemProgram": solana_sdk_ids::system_program::id().to_string(),
"tokenProgram": token_program_id.to_string(),
})
}
Expand Down
15 changes: 7 additions & 8 deletions transaction-status/src/parse_bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
bincode::deserialize,
serde_json::json,
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::{
solana_program::{
loader_instruction::LoaderInstruction,
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
},
Expand Down Expand Up @@ -209,11 +209,9 @@ mod test {
super::*,
serde_json::Value,
solana_message::Message,
solana_sdk::{
bpf_loader_upgradeable,
pubkey::{self, Pubkey},
system_program, sysvar,
},
solana_program::bpf_loader_upgradeable,
solana_pubkey::{self as pubkey, Pubkey},
solana_sdk_ids::{system_program, sysvar},
};

#[test]
Expand All @@ -226,7 +224,7 @@ mod test {
let account_keys = vec![fee_payer, account_pubkey];
let missing_account_keys = vec![account_pubkey];

let instruction = solana_sdk::loader_instruction::write(
let instruction = solana_program::loader_instruction::write(
&account_pubkey,
&program_id,
offset,
Expand Down Expand Up @@ -260,7 +258,8 @@ mod test {
)
.is_err());

let instruction = solana_sdk::loader_instruction::finalize(&account_pubkey, &program_id);
let instruction =
solana_program::loader_instruction::finalize(&account_pubkey, &program_id);
let mut message = Message::new(&[instruction], Some(&fee_payer));
assert_eq!(
parse_bpf_loader(
Expand Down
14 changes: 8 additions & 6 deletions transaction-status/src/parse_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use {
serde_json::Value,
solana_account_decoder::parse_token::spl_token_ids,
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::{address_lookup_table, pubkey::Pubkey, stake, system_program, vote},
solana_pubkey::Pubkey,
solana_sdk_ids::{address_lookup_table, stake, system_program, vote},
std::{
collections::HashMap,
str::{from_utf8, Utf8Error},
Expand All @@ -23,15 +24,16 @@ use {
};

lazy_static! {
static ref ADDRESS_LOOKUP_PROGRAM_ID: Pubkey = address_lookup_table::program::id();
static ref ADDRESS_LOOKUP_PROGRAM_ID: Pubkey = address_lookup_table::id();
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_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id();
static ref BPF_LOADER_PROGRAM_ID: Pubkey = solana_sdk_ids::bpf_loader::id();
static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey =
solana_sdk_ids::bpf_loader_upgradeable::id();
static ref MEMO_V1_PROGRAM_ID: Pubkey = spl_memo_id_v1();
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::id();
static ref SYSTEM_PROGRAM_ID: Pubkey = system_program::id();
static ref VOTE_PROGRAM_ID: Pubkey = vote::program::id();
static ref VOTE_PROGRAM_ID: Pubkey = vote::id();
static ref PARSABLE_PROGRAM_IDS: HashMap<Pubkey, ParsableProgram> = {
let mut m = HashMap::new();
m.insert(
Expand Down
18 changes: 8 additions & 10 deletions transaction-status/src/parse_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
bincode::deserialize,
serde_json::{json, Map, Value},
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::stake::instruction::StakeInstruction,
solana_program::stake::instruction::StakeInstruction,
};

pub fn parse_stake(
Expand Down Expand Up @@ -331,17 +331,15 @@ fn check_num_stake_accounts(accounts: &[u8], num: usize) -> Result<(), ParseInst
mod test {
use {
super::*,
solana_instruction::Instruction,
solana_message::Message,
solana_sdk::{
instruction::Instruction,
pubkey::Pubkey,
stake::{
config,
instruction::{self, LockupArgs},
state::{Authorized, Lockup, StakeAuthorize},
},
sysvar,
solana_program::stake::{
config,
instruction::{self, LockupArgs},
state::{Authorized, Lockup, StakeAuthorize},
},
solana_pubkey::Pubkey,
solana_sdk_ids::sysvar,
std::iter::repeat_with,
};

Expand Down
7 changes: 3 additions & 4 deletions transaction-status/src/parse_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
bincode::deserialize,
serde_json::json,
solana_message::{compiled_instruction::CompiledInstruction, AccountKeys},
solana_sdk::system_instruction::SystemInstruction,
solana_system_interface::instruction::SystemInstruction,
};

pub fn parse_system(
Expand Down Expand Up @@ -208,9 +208,8 @@ fn check_num_system_accounts(accounts: &[u8], num: usize) -> Result<(), ParseIns
#[cfg(test)]
mod test {
use {
super::*,
solana_message::Message,
solana_sdk::{pubkey::Pubkey, system_instruction, sysvar},
super::*, solana_message::Message, solana_pubkey::Pubkey, solana_sdk_ids::sysvar,
solana_system_interface::instruction as system_instruction,
};

#[test]
Expand Down
8 changes: 4 additions & 4 deletions transaction-status/src/parse_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,15 +863,15 @@ fn map_coption_pubkey(pubkey: COption<Pubkey>) -> Option<String> {
#[cfg(test)]
mod test {
use {
super::*, solana_message::Message, solana_sdk::pubkey::Pubkey,
spl_token_2022::instruction::*, std::iter::repeat_with,
super::*, solana_message::Message, solana_pubkey::Pubkey, spl_token_2022::instruction::*,
std::iter::repeat_with,
};

fn test_parse_token(program_id: &Pubkey) {
let mint_pubkey = Pubkey::new_unique();
let mint_authority = Pubkey::new_unique();
let freeze_authority = Pubkey::new_unique();
let rent_sysvar = solana_sdk::sysvar::rent::id();
let rent_sysvar = solana_sdk_ids::sysvar::rent::id();

// Test InitializeMint variations
let initialize_mint_ix = initialize_mint(
Expand Down Expand Up @@ -1773,7 +1773,7 @@ mod test {
info: json!({
"payer": payer.to_string(),
"nativeMint": spl_token_2022::native_mint::id().to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"systemProgram": solana_sdk_ids::system_program::id().to_string(),
})
}
);
Expand Down
Loading

0 comments on commit a06e0ae

Please sign in to comment.