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

Commit 78e7a95

Browse files
authored
associated-token-account: Bump dependent token version to 3.3 (#2766)
* associated-token-account: Bump dependent token version to 3.3 * Fix uses of deprecated instruction
1 parent f5a6dc6 commit 78e7a95

File tree

11 files changed

+39
-69
lines changed

11 files changed

+39
-69
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

associated-token-account/program/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test-bpf = []
1414
[dependencies]
1515
borsh = "0.9.1"
1616
solana-program = "1.9.2"
17-
spl-token = { version = "0.1", path = "../../token/program-2022", features = ["no-entrypoint"], package = "spl-token-2022" }
17+
spl-token = { version = "3.3", path = "../../token/program", features = ["no-entrypoint"] }
1818

1919
[dev-dependencies]
2020
solana-program-test = "1.9.2"

associated-token-account/program/src/lib.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ pub mod tools;
99

1010
// Export current SDK types for downstream users building with a different SDK version
1111
pub use solana_program;
12-
use solana_program::{
13-
instruction::{AccountMeta, Instruction},
14-
program_pack::Pack,
15-
pubkey::Pubkey,
16-
sysvar,
17-
};
12+
use solana_program::{instruction::Instruction, program_pack::Pack, pubkey::Pubkey};
1813

1914
solana_program::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
2015

@@ -65,28 +60,19 @@ fn get_associated_token_address_and_bump_seed_internal(
6560
/// 3. `[]` The token mint for the new associated token account
6661
/// 4. `[]` System program
6762
/// 5. `[]` SPL Token program
68-
/// 6. `[]` Rent sysvar
6963
///
70-
// TODO: Uncomment after 1.0.4 is released
71-
// #[deprecated(
72-
// since = "1.0.4",
73-
// note = "please use `instruction::create_associated_token_account` instead"
74-
// )]
64+
#[deprecated(
65+
since = "1.0.4",
66+
note = "please use `instruction::create_associated_token_account` instead"
67+
)]
7568
pub fn create_associated_token_account(
7669
funding_address: &Pubkey,
7770
wallet_address: &Pubkey,
7871
spl_token_mint_address: &Pubkey,
7972
) -> Instruction {
80-
let mut instruction = instruction::create_associated_token_account(
73+
instruction::create_associated_token_account(
8174
funding_address,
8275
wallet_address,
8376
spl_token_mint_address,
84-
);
85-
86-
// TODO: Remove after ATA 1.0.4 and Token >3.2.0 are released (Token::InitializeAccount3 is required if rent account is not provided)
87-
instruction
88-
.accounts
89-
.push(AccountMeta::new_readonly(sysvar::rent::id(), false));
90-
91-
instruction
77+
)
9278
}

associated-token-account/program/src/processor.rs

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ pub fn process_create_associated_token_account(
5151
let spl_token_program_info = next_account_info(account_info_iter)?;
5252
let spl_token_program_id = spl_token_program_info.key;
5353

54-
// TODO: Remove after ATA 1.0.4 and Token >3.2.0 are released and just use Rent::get()
55-
let (rent_sysvar_info, rent) = next_account_info(account_info_iter)
56-
.map(|info| (Some(info), Rent::from_account_info(info).unwrap()))
57-
.unwrap_or((None, Rent::get().unwrap()));
54+
let rent = Rent::get()?;
5855

5956
let (associated_token_address, bump_seed) = get_associated_token_address_and_bump_seed_internal(
6057
wallet_account_info.key,
@@ -85,38 +82,18 @@ pub fn process_create_associated_token_account(
8582
)?;
8683

8784
msg!("Initialize the associated token account");
88-
89-
if let Some(rent_sysvar_info) = rent_sysvar_info {
90-
invoke(
91-
&spl_token::instruction::initialize_account(
92-
spl_token_program_id,
93-
associated_token_account_info.key,
94-
spl_token_mint_info.key,
95-
wallet_account_info.key,
96-
)?,
97-
&[
98-
associated_token_account_info.clone(),
99-
spl_token_mint_info.clone(),
100-
wallet_account_info.clone(),
101-
rent_sysvar_info.clone(),
102-
spl_token_program_info.clone(),
103-
],
104-
)
105-
} else {
106-
// Use InitializeAccount3 when Rent account is not provided
107-
invoke(
108-
&spl_token::instruction::initialize_account3(
109-
spl_token_program_id,
110-
associated_token_account_info.key,
111-
spl_token_mint_info.key,
112-
wallet_account_info.key,
113-
)?,
114-
&[
115-
associated_token_account_info.clone(),
116-
spl_token_mint_info.clone(),
117-
wallet_account_info.clone(),
118-
spl_token_program_info.clone(),
119-
],
120-
)
121-
}
85+
invoke(
86+
&spl_token::instruction::initialize_account3(
87+
spl_token_program_id,
88+
associated_token_account_info.key,
89+
spl_token_mint_info.key,
90+
wallet_account_info.key,
91+
)?,
92+
&[
93+
associated_token_account_info.clone(),
94+
spl_token_mint_info.clone(),
95+
wallet_account_info.clone(),
96+
spl_token_program_info.clone(),
97+
],
98+
)
12299
}

associated-token-account/program/tests/process_create_associated_token_account.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ async fn test_create_associated_token_account_using_deprecated_instruction_creat
300300
);
301301

302302
// Use legacy instruction creator
303+
#[allow(deprecated)]
303304
let create_associated_token_account_ix = deprecated_create_associated_token_account(
304305
&payer.pubkey(),
305306
&wallet_address,

associated-token-account/program/tests/program_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn program_test(token_mint_address: Pubkey, use_latest_spl_token: bool) -> P
1212
);
1313

1414
if use_latest_spl_token {
15-
// TODO: Remove after Token >3.2.0 is released
15+
// TODO: Remove after Token >3.2.0 is available by default in program-test
1616
pc.add_program(
1717
"spl_token",
1818
spl_token::id(),

stake-pool/cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ use {
3737
system_instruction,
3838
transaction::Transaction,
3939
},
40-
spl_associated_token_account::{create_associated_token_account, get_associated_token_address},
40+
spl_associated_token_account::{
41+
get_associated_token_address, instruction::create_associated_token_account,
42+
},
4143
spl_stake_pool::state::ValidatorStakeInfo,
4244
spl_stake_pool::{
4345
self, find_stake_program_address, find_transient_stake_program_address,

stateless-asks/program/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test-bpf = []
1414
borsh = "0.9.1"
1515
solana-program = "1.9.2"
1616
spl-token = { version = "3.3", path = "../../token/program", features = ["no-entrypoint"] }
17-
spl-associated-token-account = {version = "1.0.3", features = ["no-entrypoint"]}
17+
spl-associated-token-account = {version = "1.0", path = "../../associated-token-account/program", features = ["no-entrypoint"]}
1818
metaplex-token-metadata = { version = "0.0.1", features = ["no-entrypoint"] }
1919
thiserror = "1.0"
2020

token/cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ use solana_sdk::{
4141
system_instruction, system_program,
4242
transaction::Transaction,
4343
};
44-
use spl_associated_token_account::*;
44+
use spl_associated_token_account::{
45+
get_associated_token_address, instruction::create_associated_token_account,
46+
};
4547
use spl_token::{
4648
self,
4749
instruction::*,

token/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ async-trait = "0.1"
1717
solana-client = "=1.9.2"
1818
solana-program-test = "=1.9.2"
1919
solana-sdk = "=1.9.2"
20-
spl-associated-token-account = { version = "1.0", features = ["no-entrypoint"] }
20+
spl-associated-token-account = { version = "1.0", path = "../../associated-token-account/program", features = ["no-entrypoint"] }
2121
spl-token-2022 = { version = "0.1", path="../program-2022" }
2222
thiserror = "1.0"

token/rust/src/token.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use solana_sdk::{
1010
system_instruction,
1111
transaction::Transaction,
1212
};
13-
use spl_associated_token_account::{create_associated_token_account, get_associated_token_address};
13+
use spl_associated_token_account::{
14+
get_associated_token_address, instruction::create_associated_token_account,
15+
};
1416
use spl_token_2022::{
1517
extension::{transfer_fee, ExtensionType, StateWithExtensionsOwned},
1618
id, instruction,

0 commit comments

Comments
 (0)