Skip to content

Commit

Permalink
spl: Bump token to 3.5.0 and ata to 1.1.0 (backport #26921) (#26952)
Browse files Browse the repository at this point in the history
* spl: Bump token to 3.5.0 and ata to 1.1.0 (#26921)

(cherry picked from commit b725b86)

* Bump spl-token dependency in solana-ledger

Co-authored-by: Jon Cinque <[email protected]>
  • Loading branch information
mergify[bot] and joncinque authored Aug 5, 2022
1 parent 0d19c31 commit 2fa2d5c
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 27 deletions.
13 changes: 9 additions & 4 deletions 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 account-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde_json = "1.0.81"
solana-config-program = { path = "../programs/config", version = "=1.11.6" }
solana-sdk = { path = "../sdk", version = "=1.11.6" }
solana-vote-program = { path = "../programs/vote", version = "=1.11.6" }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] }
thiserror = "1.0"
zstd = "0.11.2"
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.11.6" }
solana-streamer = { path = "../streamer", version = "=1.11.6" }
solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" }
solana-version = { path = "../version", version = "=1.11.6" }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }

[dev-dependencies]
solana-core = { path = "../core", version = "=1.11.6" }
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.3.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
fetch_program token 3.5.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.5 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program associated-token-account 1.1.1 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111

echo "${genesis_args[@]}" > spl-genesis-args.sh
Expand Down
2 changes: 1 addition & 1 deletion ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ solana-storage-bigtable = { path = "../storage-bigtable", version = "=1.11.6" }
solana-storage-proto = { path = "../storage-proto", version = "=1.11.6" }
solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" }
solana-vote-program = { path = "../programs/vote", version = "=1.11.6" }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] }
static_assertions = "1.1.0"
tempfile = "3.3.0"
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.3.0.so")),
(spl_token::ID, include_bytes!("programs/spl_token-3.5.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.5.so"),
include_bytes!("programs/spl_associated_token_account-1.1.1.so"),
),
];

Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed program-test/src/programs/spl_token-3.3.0.so
Binary file not shown.
Binary file added program-test/src/programs/spl_token-3.5.0.so
Binary file not shown.
13 changes: 9 additions & 4 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 @@ -49,7 +49,7 @@ solana-streamer = { path = "../streamer", version = "=1.11.6" }
solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" }
solana-version = { path = "../version", version = "=1.11.6" }
solana-vote-program = { path = "../programs/vote", version = "=1.11.6" }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] }
stream-cancel = "0.8.1"
thiserror = "1.0"
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.11.6" }
solana-sdk = { path = "../sdk", version = "=1.11.6" }
solana-transaction-status = { path = "../transaction-status", version = "=1.11.6" }
solana-version = { path = "../version", version = "=1.11.6" }
spl-associated-token-account = { version = "=1.0.5" }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "=1.1.1" }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }
tempfile = "3.3.0"
thiserror = "1.0"

Expand Down
1 change: 1 addition & 0 deletions tokens/src/spl_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn build_spl_token_instructions(
&spl_token_pubkey(&args.fee_payer.pubkey()),
&wallet_address,
&spl_token_pubkey(&spl_token_args.mint),
&spl_token::id(),
);
instructions.push(spl_token_instruction(
create_associated_token_account_instruction,
Expand Down
4 changes: 2 additions & 2 deletions transaction-status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ solana-measure = { path = "../measure", version = "=1.11.6" }
solana-metrics = { path = "../metrics", version = "=1.11.6" }
solana-sdk = { path = "../sdk", version = "=1.11.6" }
solana-vote-program = { path = "../programs/vote", version = "=1.11.6" }
spl-associated-token-account = { version = "=1.0.5", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "=1.1.1", features = ["no-entrypoint"] }
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.3.1", features = ["no-entrypoint"] }
spl-token = { version = "=3.5.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = "=0.4.2", features = ["no-entrypoint"] }
thiserror = "1.0"

Expand Down
152 changes: 145 additions & 7 deletions transaction-status/src/parse_associated_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@ pub fn parse_associated_token(
}),
})
}
AssociatedTokenAccountInstruction::CreateIdempotent => {
check_num_associated_token_accounts(&instruction.accounts, 6)?;
Ok(ParsedInstructionEnum {
instruction_type: "createIdempotent".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(),
}),
})
}
AssociatedTokenAccountInstruction::RecoverNested => {
check_num_associated_token_accounts(&instruction.accounts, 7)?;
Ok(ParsedInstructionEnum {
instruction_type: "recoverNested".to_string(),
info: json!({
"nestedSource": account_keys[instruction.accounts[0] as usize].to_string(),
"nestedMint": account_keys[instruction.accounts[1] as usize].to_string(),
"destination": account_keys[instruction.accounts[2] as usize].to_string(),
"nestedOwner": account_keys[instruction.accounts[3] as usize].to_string(),
"ownerMint": account_keys[instruction.accounts[4] as usize].to_string(),
"wallet": account_keys[instruction.accounts[5] as usize].to_string(),
"tokenProgram": account_keys[instruction.accounts[6] as usize].to_string(),
}),
})
}
}
}
}
Expand All @@ -80,8 +109,11 @@ mod test {
super::*,
solana_account_decoder::parse_token::pubkey_from_spl_token,
spl_associated_token_account::{
get_associated_token_address,
instruction::create_associated_token_account,
get_associated_token_address, get_associated_token_address_with_program_id,
instruction::{
create_associated_token_account, create_associated_token_account_idempotent,
recover_nested,
},
solana_program::{
instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction,
message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, sysvar,
Expand Down Expand Up @@ -112,7 +144,7 @@ mod test {
}

#[test]
fn test_parse_associated_token_deprecated() {
fn test_parse_create_deprecated() {
let funder = Pubkey::new_unique();
let wallet_address = Pubkey::new_unique();
let mint = Pubkey::new_unique();
Expand Down Expand Up @@ -154,16 +186,21 @@ mod test {
}

#[test]
fn test_parse_associated_token() {
fn test_parse_create() {
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 token_program_id = Pubkey::new_unique();
let associated_account_address = get_associated_token_address_with_program_id(
&convert_pubkey(wallet_address),
&convert_pubkey(mint),
&convert_pubkey(token_program_id),
);
let create_ix = create_associated_token_account(
&convert_pubkey(funder),
&convert_pubkey(wallet_address),
&convert_pubkey(mint),
&convert_pubkey(token_program_id),
);
let message = Message::new(&[create_ix], None);
let mut compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
Expand All @@ -181,7 +218,108 @@ mod test {
"wallet": wallet_address.to_string(),
"mint": mint.to_string(),
"systemProgram": solana_sdk::system_program::id().to_string(),
"tokenProgram": spl_token::id().to_string(),
"tokenProgram": token_program_id.to_string(),
})
}
);
compiled_instruction.accounts.pop();
assert!(parse_associated_token(
&compiled_instruction,
&AccountKeys::new(&convert_account_keys(&message), None)
)
.is_err());
}

#[test]
fn test_parse_create_idempotent() {
let funder = Pubkey::new_unique();
let wallet_address = Pubkey::new_unique();
let mint = Pubkey::new_unique();
let token_program_id = Pubkey::new_unique();
let associated_account_address = get_associated_token_address_with_program_id(
&convert_pubkey(wallet_address),
&convert_pubkey(mint),
&convert_pubkey(token_program_id),
);
let create_ix = create_associated_token_account_idempotent(
&convert_pubkey(funder),
&convert_pubkey(wallet_address),
&convert_pubkey(mint),
&convert_pubkey(token_program_id),
);
let message = Message::new(&[create_ix], None);
let mut 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: "createIdempotent".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": token_program_id.to_string(),
})
}
);
compiled_instruction.accounts.pop();
assert!(parse_associated_token(
&compiled_instruction,
&AccountKeys::new(&convert_account_keys(&message), None)
)
.is_err());
}

#[test]
fn test_parse_recover_nested() {
let wallet_address = Pubkey::new_unique();
let owner_mint = Pubkey::new_unique();
let nested_mint = Pubkey::new_unique();
let token_program_id = Pubkey::new_unique();
let owner_associated_account_address = get_associated_token_address_with_program_id(
&convert_pubkey(wallet_address),
&convert_pubkey(owner_mint),
&convert_pubkey(token_program_id),
);
let nested_associated_account_address = get_associated_token_address_with_program_id(
&owner_associated_account_address,
&convert_pubkey(nested_mint),
&convert_pubkey(token_program_id),
);
let destination_associated_account_address = get_associated_token_address_with_program_id(
&convert_pubkey(wallet_address),
&convert_pubkey(nested_mint),
&convert_pubkey(token_program_id),
);
let recover_ix = recover_nested(
&convert_pubkey(wallet_address),
&convert_pubkey(owner_mint),
&convert_pubkey(nested_mint),
&convert_pubkey(token_program_id),
);
let message = Message::new(&[recover_ix], None);
let mut 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: "recoverNested".to_string(),
info: json!({
"nestedSource": nested_associated_account_address.to_string(),
"nestedMint": nested_mint.to_string(),
"destination": destination_associated_account_address.to_string(),
"nestedOwner": owner_associated_account_address.to_string(),
"ownerMint": owner_mint.to_string(),
"wallet": wallet_address.to_string(),
"tokenProgram": token_program_id.to_string(),
})
}
);
Expand Down

0 comments on commit 2fa2d5c

Please sign in to comment.