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

Commit 1c9e2a5

Browse files
authored
token-cli: Downgrade to crates.io versions for release (#3371)
1 parent 8169e52 commit 1c9e2a5

File tree

6 files changed

+31
-77
lines changed

6 files changed

+31
-77
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.

token/cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ solana-logger = "=1.10.29"
2727
solana-remote-wallet = "=1.10.29"
2828
solana-sdk = "=1.10.29"
2929
solana-transaction-status = "=1.10.29"
30-
spl-token = { version = "3.3", path="../program", features = [ "no-entrypoint" ] }
31-
spl-associated-token-account = { version = "1.0.5", path="../../associated-token-account/program", features = [ "no-entrypoint" ] }
32-
spl-memo = { version = "3.0.1", path="../../memo/program", features = ["no-entrypoint"] }
30+
spl-token = { version = "3.3", features = [ "no-entrypoint" ] }
31+
spl-associated-token-account = { version = "1.0.5", features = [ "no-entrypoint" ] }
32+
spl-memo = { version = "3.0.1", features = ["no-entrypoint"] }
3333
strum = "0.24"
3434
strum_macros = "0.24"
3535

token/cli/src/bench.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ pub(crate) fn bench_process_command(
203203
signers.push(owner_signer);
204204
let from = pubkey_of_signer(arg_matches, "from", wallet_manager)
205205
.unwrap()
206-
.unwrap_or_else(|| {
207-
get_associated_token_address_with_program_id(&owner, &token, &config.program_id)
208-
});
206+
.unwrap_or_else(|| get_associated_token_address(&owner, &token));
209207

210208
command_deposit_into_or_withdraw_from(
211209
config, signers, &token, n, &owner, ui_amount, &from, true,
@@ -222,9 +220,7 @@ pub(crate) fn bench_process_command(
222220
signers.push(owner_signer);
223221
let to = pubkey_of_signer(arg_matches, "to", wallet_manager)
224222
.unwrap()
225-
.unwrap_or_else(|| {
226-
get_associated_token_address_with_program_id(&owner, &token, &config.program_id)
227-
});
223+
.unwrap_or_else(|| get_associated_token_address(&owner, &token));
228224

229225
command_deposit_into_or_withdraw_from(
230226
config, signers, &token, n, &owner, ui_amount, &to, false,

token/cli/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> Config<'a> {
7575
eprintln!("error: {}", e);
7676
exit(1);
7777
});
78-
get_associated_token_address_with_program_id(&owner, &token, &self.program_id)
78+
get_associated_token_address(&owner, &token)
7979
}
8080

8181
// Checks if an explicit address was provided, otherwise return the default address.

token/cli/src/main.rs

Lines changed: 18 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use solana_sdk::{
4242
transaction::Transaction,
4343
};
4444
use spl_associated_token_account::{
45-
get_associated_token_address_with_program_id, instruction::create_associated_token_account,
45+
get_associated_token_address, instruction::create_associated_token_account,
4646
};
4747
use spl_token::{
4848
instruction::*,
@@ -404,8 +404,7 @@ fn command_create_account(
404404
],
405405
)
406406
} else {
407-
let account =
408-
get_associated_token_address_with_program_id(&owner, &token, &config.program_id);
407+
let account = get_associated_token_address(&owner, &token);
409408
println_display(config, format!("Creating account {}", account));
410409
(
411410
account,
@@ -414,7 +413,6 @@ fn command_create_account(
414413
&config.fee_payer,
415414
&owner,
416415
&token,
417-
&config.program_id,
418416
)],
419417
)
420418
};
@@ -540,11 +538,8 @@ fn command_authorize(
540538
}
541539
} else if let Ok(token_account) = Account::unpack(&target_account.data) {
542540
let check_associated_token_account = || -> Result<(), Error> {
543-
let maybe_associated_token_account = get_associated_token_address_with_program_id(
544-
&token_account.owner,
545-
&token_account.mint,
546-
&config.program_id,
547-
);
541+
let maybe_associated_token_account =
542+
get_associated_token_address(&token_account.owner, &token_account.mint);
548543
if account == maybe_associated_token_account
549544
&& !force_authorize
550545
&& Some(authority) != new_authority
@@ -683,7 +678,7 @@ fn command_transfer(
683678
let sender = if let Some(sender) = sender {
684679
sender
685680
} else {
686-
get_associated_token_address_with_program_id(&sender_owner, &token, &config.program_id)
681+
get_associated_token_address(&sender_owner, &token)
687682
};
688683
let (mint_pubkey, decimals) = resolve_mint_info(config, &sender, Some(token), mint_decimals)?;
689684
let maybe_transfer_balance =
@@ -769,11 +764,7 @@ fn command_transfer(
769764
};
770765

771766
if !recipient_is_token_account {
772-
recipient_token_account = get_associated_token_address_with_program_id(
773-
&recipient,
774-
&mint_pubkey,
775-
&config.program_id,
776-
);
767+
recipient_token_account = get_associated_token_address(&recipient, &mint_pubkey);
777768
println_display(
778769
config,
779770
format!(
@@ -826,7 +817,6 @@ fn command_transfer(
826817
&config.fee_payer,
827818
&recipient,
828819
&mint_pubkey,
829-
&config.program_id,
830820
));
831821
} else {
832822
return Err(
@@ -1114,11 +1104,7 @@ fn command_wrap(
11141104
)?,
11151105
]
11161106
} else {
1117-
let account = get_associated_token_address_with_program_id(
1118-
&wallet_address,
1119-
&native_mint::id(),
1120-
&config.program_id,
1121-
);
1107+
let account = get_associated_token_address(&wallet_address, &native_mint::id());
11221108

11231109
if !config.sign_only {
11241110
if let Some(account_data) = config
@@ -1135,12 +1121,7 @@ fn command_wrap(
11351121
println_display(config, format!("Wrapping {} SOL into {}", sol, account));
11361122
vec![
11371123
system_instruction::transfer(&wallet_address, &account, lamports),
1138-
create_associated_token_account(
1139-
&config.fee_payer,
1140-
&wallet_address,
1141-
&native_mint::id(),
1142-
&config.program_id,
1143-
),
1124+
create_associated_token_account(&config.fee_payer, &wallet_address, &native_mint::id()),
11441125
]
11451126
};
11461127
if !config.sign_only {
@@ -1172,13 +1153,8 @@ fn command_unwrap(
11721153
bulk_signers: BulkSigners,
11731154
) -> CommandResult {
11741155
let use_associated_account = address.is_none();
1175-
let address = address.unwrap_or_else(|| {
1176-
get_associated_token_address_with_program_id(
1177-
&wallet_address,
1178-
&native_mint::id(),
1179-
&config.program_id,
1180-
)
1181-
});
1156+
let address = address
1157+
.unwrap_or_else(|| get_associated_token_address(&wallet_address, &native_mint::id()));
11821158
println_display(config, format!("Unwrapping {}", address));
11831159
if !config.sign_only {
11841160
let lamports = config.rpc_client.get_balance(&address)?;
@@ -1469,8 +1445,7 @@ fn command_address(config: &Config, token: Option<Pubkey>, owner: Pubkey) -> Com
14691445
};
14701446
if let Some(token) = token {
14711447
validate_mint(config, token)?;
1472-
let associated_token_address =
1473-
get_associated_token_address_with_program_id(&owner, &token, &config.program_id);
1448+
let associated_token_address = get_associated_token_address(&owner, &token);
14741449
cli_address.associated_token_address = Some(associated_token_address.to_string());
14751450
}
14761451
Ok(config.output_format.formatted_string(&cli_address))
@@ -1484,8 +1459,7 @@ fn command_account_info(config: &Config, address: Pubkey) -> CommandResult {
14841459
.unwrap();
14851460
let mint = Pubkey::from_str(&account.mint).unwrap();
14861461
let owner = Pubkey::from_str(&account.owner).unwrap();
1487-
let is_associated =
1488-
get_associated_token_address_with_program_id(&owner, &mint, &config.program_id) == address;
1462+
let is_associated = get_associated_token_address(&owner, &mint) == address;
14891463
let cli_token_account = CliTokenAccount {
14901464
address: address.to_string(),
14911465
is_associated,
@@ -1595,8 +1569,7 @@ fn command_gc(
15951569

15961570
for (token, accounts) in accounts_by_token.into_iter() {
15971571
println_display(config, format!("Processing token: {}", token));
1598-
let associated_token_account =
1599-
get_associated_token_address_with_program_id(&owner, &token, &config.program_id);
1572+
let associated_token_account = get_associated_token_address(&owner, &token);
16001573
let total_balance: u64 = accounts.values().map(|account| account.0).sum();
16011574

16021575
if total_balance > 0 && !accounts.contains_key(&associated_token_account) {
@@ -1605,7 +1578,6 @@ fn command_gc(
16051578
&config.fee_payer,
16061579
&owner,
16071580
&token,
1608-
&config.program_id,
16091581
)]);
16101582
lamports_needed += minimum_balance_for_rent_exemption;
16111583
}
@@ -3267,7 +3239,7 @@ mod tests {
32673239
fn create_associated_account(config: &Config, payer: &Keypair, mint: Pubkey) -> Pubkey {
32683240
let bulk_signers: Vec<Box<dyn Signer>> = vec![Box::new(clone_keypair(payer))];
32693241
command_create_account(config, mint, payer.pubkey(), None, bulk_signers).unwrap();
3270-
get_associated_token_address_with_program_id(&payer.pubkey(), &mint, &config.program_id)
3242+
get_associated_token_address(&payer.pubkey(), &mint)
32713243
}
32723244

32733245
fn mint_tokens(
@@ -3376,11 +3348,7 @@ mod tests {
33763348
],
33773349
);
33783350
let value: serde_json::Value = serde_json::from_str(&result.unwrap()).unwrap();
3379-
let account = get_associated_token_address_with_program_id(
3380-
&payer.pubkey(),
3381-
&token,
3382-
&config.program_id,
3383-
);
3351+
let account = get_associated_token_address(&payer.pubkey(), &token);
33843352
assert_eq!(value["address"], account.to_string());
33853353
assert_eq!(value["mint"], token.to_string());
33863354
assert_eq!(value["isAssociated"], true);
@@ -3480,11 +3448,7 @@ mod tests {
34803448
&["spl-token", CommandName::Wrap.into(), "0.5"],
34813449
)
34823450
.unwrap();
3483-
let account = get_associated_token_address_with_program_id(
3484-
&payer.pubkey(),
3485-
&native_mint::id(),
3486-
&config.program_id,
3487-
);
3451+
let account = get_associated_token_address(&payer.pubkey(), &native_mint::id());
34883452
let ui_account = config
34893453
.rpc_client
34903454
.get_token_account(&account)
@@ -3500,11 +3464,7 @@ mod tests {
35003464
let config = test_config(&test_validator, &payer, &spl_token::id());
35013465
let bulk_signers: Vec<Box<dyn Signer>> = vec![Box::new(clone_keypair(&payer))];
35023466
command_wrap(&config, 0.5, payer.pubkey(), None, bulk_signers).unwrap();
3503-
let account = get_associated_token_address_with_program_id(
3504-
&payer.pubkey(),
3505-
&native_mint::id(),
3506-
&config.program_id,
3507-
);
3467+
let account = get_associated_token_address(&payer.pubkey(), &native_mint::id());
35083468
let result = process_test_command(
35093469
&config,
35103470
&payer,
@@ -3658,11 +3618,7 @@ mod tests {
36583618
let ui_amount = 10.0;
36593619
command_wrap(&config, ui_amount, payer.pubkey(), None, bulk_signers).unwrap();
36603620

3661-
let recipient = get_associated_token_address_with_program_id(
3662-
&payer.pubkey(),
3663-
&native_mint::id(),
3664-
&config.program_id,
3665-
);
3621+
let recipient = get_associated_token_address(&payer.pubkey(), &native_mint::id());
36663622
let _result = process_test_command(
36673623
&config,
36683624
&payer,

token/cli/src/sort.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) struct UnsupportedAccount {
1919
pub(crate) fn sort_and_parse_token_accounts(
2020
owner: &Pubkey,
2121
accounts: Vec<RpcKeyedAccount>,
22-
program_id: &Pubkey,
22+
_program_id: &Pubkey,
2323
) -> (MintAccounts, Vec<UnsupportedAccount>, usize, bool) {
2424
let mut mint_accounts: MintAccounts = BTreeMap::new();
2525
let mut unsupported_accounts = vec![];
@@ -39,7 +39,9 @@ pub(crate) fn sort_and_parse_token_accounts(
3939
Ok(TokenAccountType::Account(ui_token_account)) => {
4040
let mint = ui_token_account.mint.clone();
4141
let is_associated = if let Ok(mint) = Pubkey::from_str(&mint) {
42-
spl_associated_token_account::get_associated_token_address_with_program_id(owner, &mint, program_id).to_string() == address
42+
spl_associated_token_account::get_associated_token_address(owner, &mint)
43+
.to_string()
44+
== address
4345
} else {
4446
includes_aux = true;
4547
false

0 commit comments

Comments
 (0)