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

Commit 725430d

Browse files
authored
Revert "token-cli: Downgrade to crates.io versions for release (#3371)" (#3372)
This reverts commit 1c9e2a5.
1 parent 1c9e2a5 commit 725430d

File tree

6 files changed

+77
-31
lines changed

6 files changed

+77
-31
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", 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"] }
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"] }
3333
strum = "0.24"
3434
strum_macros = "0.24"
3535

token/cli/src/bench.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ 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(|| get_associated_token_address(&owner, &token));
206+
.unwrap_or_else(|| {
207+
get_associated_token_address_with_program_id(&owner, &token, &config.program_id)
208+
});
207209

208210
command_deposit_into_or_withdraw_from(
209211
config, signers, &token, n, &owner, ui_amount, &from, true,
@@ -220,7 +222,9 @@ pub(crate) fn bench_process_command(
220222
signers.push(owner_signer);
221223
let to = pubkey_of_signer(arg_matches, "to", wallet_manager)
222224
.unwrap()
223-
.unwrap_or_else(|| get_associated_token_address(&owner, &token));
225+
.unwrap_or_else(|| {
226+
get_associated_token_address_with_program_id(&owner, &token, &config.program_id)
227+
});
224228

225229
command_deposit_into_or_withdraw_from(
226230
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(&owner, &token)
78+
get_associated_token_address_with_program_id(&owner, &token, &self.program_id)
7979
}
8080

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

token/cli/src/main.rs

Lines changed: 62 additions & 18 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, instruction::create_associated_token_account,
45+
get_associated_token_address_with_program_id, instruction::create_associated_token_account,
4646
};
4747
use spl_token::{
4848
instruction::*,
@@ -404,7 +404,8 @@ fn command_create_account(
404404
],
405405
)
406406
} else {
407-
let account = get_associated_token_address(&owner, &token);
407+
let account =
408+
get_associated_token_address_with_program_id(&owner, &token, &config.program_id);
408409
println_display(config, format!("Creating account {}", account));
409410
(
410411
account,
@@ -413,6 +414,7 @@ fn command_create_account(
413414
&config.fee_payer,
414415
&owner,
415416
&token,
417+
&config.program_id,
416418
)],
417419
)
418420
};
@@ -538,8 +540,11 @@ fn command_authorize(
538540
}
539541
} else if let Ok(token_account) = Account::unpack(&target_account.data) {
540542
let check_associated_token_account = || -> Result<(), Error> {
541-
let maybe_associated_token_account =
542-
get_associated_token_address(&token_account.owner, &token_account.mint);
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+
);
543548
if account == maybe_associated_token_account
544549
&& !force_authorize
545550
&& Some(authority) != new_authority
@@ -678,7 +683,7 @@ fn command_transfer(
678683
let sender = if let Some(sender) = sender {
679684
sender
680685
} else {
681-
get_associated_token_address(&sender_owner, &token)
686+
get_associated_token_address_with_program_id(&sender_owner, &token, &config.program_id)
682687
};
683688
let (mint_pubkey, decimals) = resolve_mint_info(config, &sender, Some(token), mint_decimals)?;
684689
let maybe_transfer_balance =
@@ -764,7 +769,11 @@ fn command_transfer(
764769
};
765770

766771
if !recipient_is_token_account {
767-
recipient_token_account = get_associated_token_address(&recipient, &mint_pubkey);
772+
recipient_token_account = get_associated_token_address_with_program_id(
773+
&recipient,
774+
&mint_pubkey,
775+
&config.program_id,
776+
);
768777
println_display(
769778
config,
770779
format!(
@@ -817,6 +826,7 @@ fn command_transfer(
817826
&config.fee_payer,
818827
&recipient,
819828
&mint_pubkey,
829+
&config.program_id,
820830
));
821831
} else {
822832
return Err(
@@ -1104,7 +1114,11 @@ fn command_wrap(
11041114
)?,
11051115
]
11061116
} else {
1107-
let account = get_associated_token_address(&wallet_address, &native_mint::id());
1117+
let account = get_associated_token_address_with_program_id(
1118+
&wallet_address,
1119+
&native_mint::id(),
1120+
&config.program_id,
1121+
);
11081122

11091123
if !config.sign_only {
11101124
if let Some(account_data) = config
@@ -1121,7 +1135,12 @@ fn command_wrap(
11211135
println_display(config, format!("Wrapping {} SOL into {}", sol, account));
11221136
vec![
11231137
system_instruction::transfer(&wallet_address, &account, lamports),
1124-
create_associated_token_account(&config.fee_payer, &wallet_address, &native_mint::id()),
1138+
create_associated_token_account(
1139+
&config.fee_payer,
1140+
&wallet_address,
1141+
&native_mint::id(),
1142+
&config.program_id,
1143+
),
11251144
]
11261145
};
11271146
if !config.sign_only {
@@ -1153,8 +1172,13 @@ fn command_unwrap(
11531172
bulk_signers: BulkSigners,
11541173
) -> CommandResult {
11551174
let use_associated_account = address.is_none();
1156-
let address = address
1157-
.unwrap_or_else(|| get_associated_token_address(&wallet_address, &native_mint::id()));
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+
});
11581182
println_display(config, format!("Unwrapping {}", address));
11591183
if !config.sign_only {
11601184
let lamports = config.rpc_client.get_balance(&address)?;
@@ -1445,7 +1469,8 @@ fn command_address(config: &Config, token: Option<Pubkey>, owner: Pubkey) -> Com
14451469
};
14461470
if let Some(token) = token {
14471471
validate_mint(config, token)?;
1448-
let associated_token_address = get_associated_token_address(&owner, &token);
1472+
let associated_token_address =
1473+
get_associated_token_address_with_program_id(&owner, &token, &config.program_id);
14491474
cli_address.associated_token_address = Some(associated_token_address.to_string());
14501475
}
14511476
Ok(config.output_format.formatted_string(&cli_address))
@@ -1459,7 +1484,8 @@ fn command_account_info(config: &Config, address: Pubkey) -> CommandResult {
14591484
.unwrap();
14601485
let mint = Pubkey::from_str(&account.mint).unwrap();
14611486
let owner = Pubkey::from_str(&account.owner).unwrap();
1462-
let is_associated = get_associated_token_address(&owner, &mint) == address;
1487+
let is_associated =
1488+
get_associated_token_address_with_program_id(&owner, &mint, &config.program_id) == address;
14631489
let cli_token_account = CliTokenAccount {
14641490
address: address.to_string(),
14651491
is_associated,
@@ -1569,7 +1595,8 @@ fn command_gc(
15691595

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

15751602
if total_balance > 0 && !accounts.contains_key(&associated_token_account) {
@@ -1578,6 +1605,7 @@ fn command_gc(
15781605
&config.fee_payer,
15791606
&owner,
15801607
&token,
1608+
&config.program_id,
15811609
)]);
15821610
lamports_needed += minimum_balance_for_rent_exemption;
15831611
}
@@ -3239,7 +3267,7 @@ mod tests {
32393267
fn create_associated_account(config: &Config, payer: &Keypair, mint: Pubkey) -> Pubkey {
32403268
let bulk_signers: Vec<Box<dyn Signer>> = vec![Box::new(clone_keypair(payer))];
32413269
command_create_account(config, mint, payer.pubkey(), None, bulk_signers).unwrap();
3242-
get_associated_token_address(&payer.pubkey(), &mint)
3270+
get_associated_token_address_with_program_id(&payer.pubkey(), &mint, &config.program_id)
32433271
}
32443272

32453273
fn mint_tokens(
@@ -3348,7 +3376,11 @@ mod tests {
33483376
],
33493377
);
33503378
let value: serde_json::Value = serde_json::from_str(&result.unwrap()).unwrap();
3351-
let account = get_associated_token_address(&payer.pubkey(), &token);
3379+
let account = get_associated_token_address_with_program_id(
3380+
&payer.pubkey(),
3381+
&token,
3382+
&config.program_id,
3383+
);
33523384
assert_eq!(value["address"], account.to_string());
33533385
assert_eq!(value["mint"], token.to_string());
33543386
assert_eq!(value["isAssociated"], true);
@@ -3448,7 +3480,11 @@ mod tests {
34483480
&["spl-token", CommandName::Wrap.into(), "0.5"],
34493481
)
34503482
.unwrap();
3451-
let account = get_associated_token_address(&payer.pubkey(), &native_mint::id());
3483+
let account = get_associated_token_address_with_program_id(
3484+
&payer.pubkey(),
3485+
&native_mint::id(),
3486+
&config.program_id,
3487+
);
34523488
let ui_account = config
34533489
.rpc_client
34543490
.get_token_account(&account)
@@ -3464,7 +3500,11 @@ mod tests {
34643500
let config = test_config(&test_validator, &payer, &spl_token::id());
34653501
let bulk_signers: Vec<Box<dyn Signer>> = vec![Box::new(clone_keypair(&payer))];
34663502
command_wrap(&config, 0.5, payer.pubkey(), None, bulk_signers).unwrap();
3467-
let account = get_associated_token_address(&payer.pubkey(), &native_mint::id());
3503+
let account = get_associated_token_address_with_program_id(
3504+
&payer.pubkey(),
3505+
&native_mint::id(),
3506+
&config.program_id,
3507+
);
34683508
let result = process_test_command(
34693509
&config,
34703510
&payer,
@@ -3618,7 +3658,11 @@ mod tests {
36183658
let ui_amount = 10.0;
36193659
command_wrap(&config, ui_amount, payer.pubkey(), None, bulk_signers).unwrap();
36203660

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

token/cli/src/sort.rs

Lines changed: 2 additions & 4 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,9 +39,7 @@ 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(owner, &mint)
43-
.to_string()
44-
== address
42+
spl_associated_token_account::get_associated_token_address_with_program_id(owner, &mint, program_id).to_string() == address
4543
} else {
4644
includes_aux = true;
4745
false

0 commit comments

Comments
 (0)