Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

spl: Bump token to v3.3.0 and ATA to v1.0.5 (backport #22649) #24688

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions account-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ serde_json = "1.0.79"
solana-config-program = { path = "../programs/config", version = "=1.10.10" }
solana-sdk = { path = "../sdk", version = "=1.10.10" }
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.1.0", features = ["no-entrypoint"] }
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.2.0", features = ["no-entrypoint"] }
thiserror = "1.0"
zstd = "0.11.1"

Expand Down
2 changes: 1 addition & 1 deletion accounts-cluster-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ solana-sdk = { path = "../sdk", version = "=1.10.10" }
solana-streamer = { path = "../streamer", version = "=1.10.10" }
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
solana-version = { path = "../version", version = "=1.10.10" }
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }

[dev-dependencies]
solana-core = { path = "../core", version = "=1.10.10" }
Expand Down
4 changes: 2 additions & 2 deletions fetch-spl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ fetch_program() {

}

fetch_program token 3.2.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
fetch_program token 3.3.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
fetch_program memo 1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111
fetch_program memo 3.0.0 MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111
fetch_program associated-token-account 1.0.3 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program associated-token-account 1.0.5 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111

echo "${genesis_args[@]}" > spl-genesis-args.sh
Expand Down
4 changes: 2 additions & 2 deletions program-test/src/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod spl_associated_token_account {
}

static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[
(spl_token::ID, include_bytes!("programs/spl_token-3.2.0.so")),
(spl_token::ID, include_bytes!("programs/spl_token-3.3.0.so")),
(
spl_memo_1_0::ID,
include_bytes!("programs/spl_memo-1.0.0.so"),
Expand All @@ -29,7 +29,7 @@ static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[
),
(
spl_associated_token_account::ID,
include_bytes!("programs/spl_associated-token-account-1.0.3.so"),
include_bytes!("programs/spl_associated_token_account-1.0.5.so"),
),
];

Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed program-test/src/programs/spl_token-3.2.0.so
Binary file not shown.
Binary file added program-test/src/programs/spl_token-3.3.0.so
Binary file not shown.
22 changes: 13 additions & 9 deletions programs/bpf/Cargo.lock

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

2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ solana-streamer = { path = "../streamer", version = "=1.10.10" }
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
solana-version = { path = "../version", version = "=1.10.10" }
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
stream-cancel = "0.8.1"
thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
Expand Down
4 changes: 2 additions & 2 deletions tokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ solana-remote-wallet = { path = "../remote-wallet", version = "=1.10.10" }
solana-sdk = { path = "../sdk", version = "=1.10.10" }
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
solana-version = { path = "../version", version = "=1.10.10" }
spl-associated-token-account = { version = "=1.0.3" }
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "=1.0.5" }
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
tempfile = "3.3.0"
thiserror = "1.0"

Expand Down
4 changes: 3 additions & 1 deletion tokens/src/spl_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use {
solana_client::rpc_client::RpcClient,
solana_sdk::{instruction::Instruction, message::Message, native_token::lamports_to_sol},
solana_transaction_status::parse_token::spl_token_instruction,
spl_associated_token_account::{create_associated_token_account, get_associated_token_address},
spl_associated_token_account::{
get_associated_token_address, instruction::create_associated_token_account,
},
spl_token::{
solana_program::program_pack::Pack,
state::{Account as SplTokenAccount, Mint},
Expand Down
7 changes: 4 additions & 3 deletions transaction-status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ edition = "2021"
Inflector = "0.11.4"
base64 = "0.13.0"
bincode = "1.3.3"
borsh = "0.9.1"
bs58 = "0.4.0"
lazy_static = "1.4.0"
log = "0.4.14"
Expand All @@ -25,10 +26,10 @@ solana-metrics = { path = "../metrics", version = "=1.10.10" }
solana-runtime = { path = "../runtime", version = "=1.10.10" }
solana-sdk = { path = "../sdk", version = "=1.10.10" }
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
spl-associated-token-account = { version = "=1.0.3", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "=1.0.5", features = ["no-entrypoint"] }
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.1.0", features = ["no-entrypoint"] }
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.2.0", features = ["no-entrypoint"] }
thiserror = "1.0"

[package.metadata.docs.rs]
Expand Down
97 changes: 79 additions & 18 deletions transaction-status/src/parse_associated_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use {
crate::parse_instruction::{
check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum,
},
borsh::BorshDeserialize,
serde_json::json,
solana_sdk::{instruction::CompiledInstruction, message::AccountKeys, pubkey::Pubkey},
spl_associated_token_account::instruction::AssociatedTokenAccountInstruction,
};

// A helper function to convert spl_associated_token_account::id() as spl_sdk::pubkey::Pubkey
Expand All @@ -25,19 +27,42 @@ pub fn parse_associated_token(
));
}
}
check_num_associated_token_accounts(&instruction.accounts, 7)?;
Ok(ParsedInstructionEnum {
instruction_type: "create".to_string(),
info: json!({
"source": account_keys[instruction.accounts[0] as usize].to_string(),
"account": account_keys[instruction.accounts[1] as usize].to_string(),
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
"rentSysvar": account_keys[instruction.accounts[6] as usize].to_string(),
}),
})
if instruction.data.is_empty() {
check_num_associated_token_accounts(&instruction.accounts, 7)?;
Ok(ParsedInstructionEnum {
instruction_type: "create".to_string(),
info: json!({
"source": account_keys[instruction.accounts[0] as usize].to_string(),
"account": account_keys[instruction.accounts[1] as usize].to_string(),
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
"rentSysvar": account_keys[instruction.accounts[6] as usize].to_string(),
}),
})
} else {
let ata_instruction = AssociatedTokenAccountInstruction::try_from_slice(&instruction.data)
.map_err(|_| {
ParseInstructionError::InstructionNotParsable(ParsableProgram::SplToken)
})?;
match ata_instruction {
AssociatedTokenAccountInstruction::Create => {
check_num_associated_token_accounts(&instruction.accounts, 6)?;
Ok(ParsedInstructionEnum {
instruction_type: "create".to_string(),
info: json!({
"source": account_keys[instruction.accounts[0] as usize].to_string(),
"account": account_keys[instruction.accounts[1] as usize].to_string(),
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
}),
})
}
}
}
}

fn check_num_associated_token_accounts(
Expand All @@ -49,14 +74,17 @@ fn check_num_associated_token_accounts(

#[cfg(test)]
mod test {
#[allow(deprecated)]
use spl_associated_token_account::create_associated_token_account as create_associated_token_account_deprecated;
use {
super::*,
solana_account_decoder::parse_token::pubkey_from_spl_token,
spl_associated_token_account::{
create_associated_token_account, get_associated_token_address,
get_associated_token_address,
instruction::create_associated_token_account,
solana_program::{
instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction,
message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey,
message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, sysvar,
},
},
};
Expand Down Expand Up @@ -84,14 +112,48 @@ mod test {
}

#[test]
fn test_parse_associated_token() {
fn test_parse_associated_token_deprecated() {
let funder = Pubkey::new_unique();
let wallet_address = Pubkey::new_unique();
let mint = Pubkey::new_unique();
let associated_account_address =
get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint));
let rent_sysvar = solana_sdk::sysvar::rent::id();
#[allow(deprecated)]
let create_ix = create_associated_token_account_deprecated(
&convert_pubkey(funder),
&convert_pubkey(wallet_address),
&convert_pubkey(mint),
);
let message = Message::new(&[create_ix], None);
let compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
assert_eq!(
parse_associated_token(
&compiled_instruction,
&AccountKeys::new(&convert_account_keys(&message), None)
)
.unwrap(),
ParsedInstructionEnum {
instruction_type: "create".to_string(),
info: json!({
"source": funder.to_string(),
"account": associated_account_address.to_string(),
"wallet": wallet_address.to_string(),
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"tokenProgram": spl_token::id().to_string(),
"rentSysvar": sysvar::rent::id().to_string(),
})
}
);
}

#[test]
fn test_parse_associated_token() {
let funder = Pubkey::new_unique();
let wallet_address = Pubkey::new_unique();
let mint = Pubkey::new_unique();
let associated_account_address =
get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint));
let create_ix = create_associated_token_account(
&convert_pubkey(funder),
&convert_pubkey(wallet_address),
Expand All @@ -114,7 +176,6 @@ mod test {
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"tokenProgram": spl_token::id().to_string(),
"rentSysvar": rent_sysvar.to_string(),
})
}
);
Expand Down
Loading