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

Commit 2742449

Browse files
spl: Bump token to v3.3.0 and ATA to v1.0.5 (backport #22649) (#24688)
* spl: Bump token to v3.3.0 and ATA to v1.0.5 (#22649) * Bump spl-token and ATA to v3.3.0 * Add parsers for new token instructions * Update parser for modified associated-token-account instruction * Update to use 1.0.5 once it's released * Update Cargo.lock in programs/bpf (cherry picked from commit c43afe2) # Conflicts: # account-decoder/Cargo.toml # accounts-cluster-bench/Cargo.toml # rpc/Cargo.toml # tokens/Cargo.toml # transaction-status/Cargo.toml * Fix merge conflicts * Re-add audit ignore to avoid bumping more crates Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
1 parent 46919a2 commit 2742449

16 files changed

+351
-50
lines changed

Cargo.lock

+13-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

account-decoder/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ serde_json = "1.0.79"
2222
solana-config-program = { path = "../programs/config", version = "=1.10.10" }
2323
solana-sdk = { path = "../sdk", version = "=1.10.10" }
2424
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
25-
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
26-
spl-token-2022 = { version = "=0.1.0", features = ["no-entrypoint"] }
25+
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
26+
spl-token-2022 = { version = "=0.2.0", features = ["no-entrypoint"] }
2727
thiserror = "1.0"
2828
zstd = "0.11.1"
2929

accounts-cluster-bench/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ solana-sdk = { path = "../sdk", version = "=1.10.10" }
2626
solana-streamer = { path = "../streamer", version = "=1.10.10" }
2727
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
2828
solana-version = { path = "../version", version = "=1.10.10" }
29-
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
29+
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
3030

3131
[dev-dependencies]
3232
solana-core = { path = "../core", version = "=1.10.10" }

fetch-spl.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ fetch_program() {
3838

3939
}
4040

41-
fetch_program token 3.2.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
41+
fetch_program token 3.3.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
4242
fetch_program memo 1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111
4343
fetch_program memo 3.0.0 MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111
44-
fetch_program associated-token-account 1.0.3 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
44+
fetch_program associated-token-account 1.0.5 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
4545
fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111
4646

4747
echo "${genesis_args[@]}" > spl-genesis-args.sh

program-test/src/programs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod spl_associated_token_account {
1818
}
1919

2020
static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[
21-
(spl_token::ID, include_bytes!("programs/spl_token-3.2.0.so")),
21+
(spl_token::ID, include_bytes!("programs/spl_token-3.3.0.so")),
2222
(
2323
spl_memo_1_0::ID,
2424
include_bytes!("programs/spl_memo-1.0.0.so"),
@@ -29,7 +29,7 @@ static SPL_PROGRAMS: &[(Pubkey, &[u8])] = &[
2929
),
3030
(
3131
spl_associated_token_account::ID,
32-
include_bytes!("programs/spl_associated-token-account-1.0.3.so"),
32+
include_bytes!("programs/spl_associated_token_account-1.0.5.so"),
3333
),
3434
];
3535

Binary file not shown.
Binary file not shown.
-153 KB
Binary file not shown.
134 KB
Binary file not shown.

programs/bpf/Cargo.lock

+13-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ solana-streamer = { path = "../streamer", version = "=1.10.10" }
4848
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
4949
solana-version = { path = "../version", version = "=1.10.10" }
5050
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
51-
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
51+
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
5252
stream-cancel = "0.8.1"
5353
thiserror = "1.0"
5454
tokio = { version = "1", features = ["full"] }

tokens/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ solana-remote-wallet = { path = "../remote-wallet", version = "=1.10.10" }
2727
solana-sdk = { path = "../sdk", version = "=1.10.10" }
2828
solana-transaction-status = { path = "../transaction-status", version = "=1.10.10" }
2929
solana-version = { path = "../version", version = "=1.10.10" }
30-
spl-associated-token-account = { version = "=1.0.3" }
31-
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
30+
spl-associated-token-account = { version = "=1.0.5" }
31+
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
3232
tempfile = "3.3.0"
3333
thiserror = "1.0"
3434

tokens/src/spl_token.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use {
1010
solana_client::rpc_client::RpcClient,
1111
solana_sdk::{instruction::Instruction, message::Message, native_token::lamports_to_sol},
1212
solana_transaction_status::parse_token::spl_token_instruction,
13-
spl_associated_token_account::{create_associated_token_account, get_associated_token_address},
13+
spl_associated_token_account::{
14+
get_associated_token_address, instruction::create_associated_token_account,
15+
},
1416
spl_token::{
1517
solana_program::program_pack::Pack,
1618
state::{Account as SplTokenAccount, Mint},

transaction-status/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ edition = "2021"
1313
Inflector = "0.11.4"
1414
base64 = "0.13.0"
1515
bincode = "1.3.3"
16+
borsh = "0.9.1"
1617
bs58 = "0.4.0"
1718
lazy_static = "1.4.0"
1819
log = "0.4.14"
@@ -25,10 +26,10 @@ solana-metrics = { path = "../metrics", version = "=1.10.10" }
2526
solana-runtime = { path = "../runtime", version = "=1.10.10" }
2627
solana-sdk = { path = "../sdk", version = "=1.10.10" }
2728
solana-vote-program = { path = "../programs/vote", version = "=1.10.10" }
28-
spl-associated-token-account = { version = "=1.0.3", features = ["no-entrypoint"] }
29+
spl-associated-token-account = { version = "=1.0.5", features = ["no-entrypoint"] }
2930
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
30-
spl-token = { version = "=3.2.0", features = ["no-entrypoint"] }
31-
spl-token-2022 = { version = "=0.1.0", features = ["no-entrypoint"] }
31+
spl-token = { version = "=3.3.0", features = ["no-entrypoint"] }
32+
spl-token-2022 = { version = "=0.2.0", features = ["no-entrypoint"] }
3233
thiserror = "1.0"
3334

3435
[package.metadata.docs.rs]

transaction-status/src/parse_associated_token.rs

+79-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ use {
22
crate::parse_instruction::{
33
check_num_accounts, ParsableProgram, ParseInstructionError, ParsedInstructionEnum,
44
},
5+
borsh::BorshDeserialize,
56
serde_json::json,
67
solana_sdk::{instruction::CompiledInstruction, message::AccountKeys, pubkey::Pubkey},
8+
spl_associated_token_account::instruction::AssociatedTokenAccountInstruction,
79
};
810

911
// A helper function to convert spl_associated_token_account::id() as spl_sdk::pubkey::Pubkey
@@ -25,19 +27,42 @@ pub fn parse_associated_token(
2527
));
2628
}
2729
}
28-
check_num_associated_token_accounts(&instruction.accounts, 7)?;
29-
Ok(ParsedInstructionEnum {
30-
instruction_type: "create".to_string(),
31-
info: json!({
32-
"source": account_keys[instruction.accounts[0] as usize].to_string(),
33-
"account": account_keys[instruction.accounts[1] as usize].to_string(),
34-
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
35-
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
36-
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
37-
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
38-
"rentSysvar": account_keys[instruction.accounts[6] as usize].to_string(),
39-
}),
40-
})
30+
if instruction.data.is_empty() {
31+
check_num_associated_token_accounts(&instruction.accounts, 7)?;
32+
Ok(ParsedInstructionEnum {
33+
instruction_type: "create".to_string(),
34+
info: json!({
35+
"source": account_keys[instruction.accounts[0] as usize].to_string(),
36+
"account": account_keys[instruction.accounts[1] as usize].to_string(),
37+
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
38+
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
39+
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
40+
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
41+
"rentSysvar": account_keys[instruction.accounts[6] as usize].to_string(),
42+
}),
43+
})
44+
} else {
45+
let ata_instruction = AssociatedTokenAccountInstruction::try_from_slice(&instruction.data)
46+
.map_err(|_| {
47+
ParseInstructionError::InstructionNotParsable(ParsableProgram::SplToken)
48+
})?;
49+
match ata_instruction {
50+
AssociatedTokenAccountInstruction::Create => {
51+
check_num_associated_token_accounts(&instruction.accounts, 6)?;
52+
Ok(ParsedInstructionEnum {
53+
instruction_type: "create".to_string(),
54+
info: json!({
55+
"source": account_keys[instruction.accounts[0] as usize].to_string(),
56+
"account": account_keys[instruction.accounts[1] as usize].to_string(),
57+
"wallet": account_keys[instruction.accounts[2] as usize].to_string(),
58+
"mint": account_keys[instruction.accounts[3] as usize].to_string(),
59+
"systemProgram": account_keys[instruction.accounts[4] as usize].to_string(),
60+
"tokenProgram": account_keys[instruction.accounts[5] as usize].to_string(),
61+
}),
62+
})
63+
}
64+
}
65+
}
4166
}
4267

4368
fn check_num_associated_token_accounts(
@@ -49,14 +74,17 @@ fn check_num_associated_token_accounts(
4974

5075
#[cfg(test)]
5176
mod test {
77+
#[allow(deprecated)]
78+
use spl_associated_token_account::create_associated_token_account as create_associated_token_account_deprecated;
5279
use {
5380
super::*,
5481
solana_account_decoder::parse_token::pubkey_from_spl_token,
5582
spl_associated_token_account::{
56-
create_associated_token_account, get_associated_token_address,
83+
get_associated_token_address,
84+
instruction::create_associated_token_account,
5785
solana_program::{
5886
instruction::CompiledInstruction as SplAssociatedTokenCompiledInstruction,
59-
message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey,
87+
message::Message, pubkey::Pubkey as SplAssociatedTokenPubkey, sysvar,
6088
},
6189
},
6290
};
@@ -84,14 +112,48 @@ mod test {
84112
}
85113

86114
#[test]
87-
fn test_parse_associated_token() {
115+
fn test_parse_associated_token_deprecated() {
88116
let funder = Pubkey::new_unique();
89117
let wallet_address = Pubkey::new_unique();
90118
let mint = Pubkey::new_unique();
91119
let associated_account_address =
92120
get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint));
93-
let rent_sysvar = solana_sdk::sysvar::rent::id();
121+
#[allow(deprecated)]
122+
let create_ix = create_associated_token_account_deprecated(
123+
&convert_pubkey(funder),
124+
&convert_pubkey(wallet_address),
125+
&convert_pubkey(mint),
126+
);
127+
let message = Message::new(&[create_ix], None);
128+
let compiled_instruction = convert_compiled_instruction(&message.instructions[0]);
129+
assert_eq!(
130+
parse_associated_token(
131+
&compiled_instruction,
132+
&AccountKeys::new(&convert_account_keys(&message), None)
133+
)
134+
.unwrap(),
135+
ParsedInstructionEnum {
136+
instruction_type: "create".to_string(),
137+
info: json!({
138+
"source": funder.to_string(),
139+
"account": associated_account_address.to_string(),
140+
"wallet": wallet_address.to_string(),
141+
"mint": mint.to_string(),
142+
"systemProgram": solana_sdk::system_program::id().to_string(),
143+
"tokenProgram": spl_token::id().to_string(),
144+
"rentSysvar": sysvar::rent::id().to_string(),
145+
})
146+
}
147+
);
148+
}
94149

150+
#[test]
151+
fn test_parse_associated_token() {
152+
let funder = Pubkey::new_unique();
153+
let wallet_address = Pubkey::new_unique();
154+
let mint = Pubkey::new_unique();
155+
let associated_account_address =
156+
get_associated_token_address(&convert_pubkey(wallet_address), &convert_pubkey(mint));
95157
let create_ix = create_associated_token_account(
96158
&convert_pubkey(funder),
97159
&convert_pubkey(wallet_address),
@@ -114,7 +176,6 @@ mod test {
114176
"mint": mint.to_string(),
115177
"systemProgram": solana_sdk::system_program::id().to_string(),
116178
"tokenProgram": spl_token::id().to_string(),
117-
"rentSysvar": rent_sysvar.to_string(),
118179
})
119180
}
120181
);

0 commit comments

Comments
 (0)