@@ -42,7 +42,7 @@ use solana_sdk::{
42
42
transaction:: Transaction ,
43
43
} ;
44
44
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,
46
46
} ;
47
47
use spl_token:: {
48
48
instruction:: * ,
@@ -404,8 +404,7 @@ fn command_create_account(
404
404
] ,
405
405
)
406
406
} 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) ;
409
408
println_display ( config, format ! ( "Creating account {}" , account) ) ;
410
409
(
411
410
account,
@@ -414,7 +413,6 @@ fn command_create_account(
414
413
& config. fee_payer,
415
414
& owner,
416
415
& token,
417
- & config. program_id,
418
416
) ] ,
419
417
)
420
418
} ;
@@ -540,11 +538,8 @@ fn command_authorize(
540
538
}
541
539
} else if let Ok ( token_account) = Account :: unpack ( & target_account. data ) {
542
540
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 ) ;
548
543
if account == maybe_associated_token_account
549
544
&& !force_authorize
550
545
&& Some ( authority) != new_authority
@@ -683,7 +678,7 @@ fn command_transfer(
683
678
let sender = if let Some ( sender) = sender {
684
679
sender
685
680
} else {
686
- get_associated_token_address_with_program_id ( & sender_owner, & token, & config . program_id )
681
+ get_associated_token_address ( & sender_owner, & token)
687
682
} ;
688
683
let ( mint_pubkey, decimals) = resolve_mint_info ( config, & sender, Some ( token) , mint_decimals) ?;
689
684
let maybe_transfer_balance =
@@ -769,11 +764,7 @@ fn command_transfer(
769
764
} ;
770
765
771
766
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) ;
777
768
println_display (
778
769
config,
779
770
format ! (
@@ -826,7 +817,6 @@ fn command_transfer(
826
817
& config. fee_payer ,
827
818
& recipient,
828
819
& mint_pubkey,
829
- & config. program_id ,
830
820
) ) ;
831
821
} else {
832
822
return Err (
@@ -1114,11 +1104,7 @@ fn command_wrap(
1114
1104
) ?,
1115
1105
]
1116
1106
} 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 ( ) ) ;
1122
1108
1123
1109
if !config. sign_only {
1124
1110
if let Some ( account_data) = config
@@ -1135,12 +1121,7 @@ fn command_wrap(
1135
1121
println_display ( config, format ! ( "Wrapping {} SOL into {}" , sol, account) ) ;
1136
1122
vec ! [
1137
1123
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( ) ) ,
1144
1125
]
1145
1126
} ;
1146
1127
if !config. sign_only {
@@ -1172,13 +1153,8 @@ fn command_unwrap(
1172
1153
bulk_signers : BulkSigners ,
1173
1154
) -> CommandResult {
1174
1155
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 ( ) ) ) ;
1182
1158
println_display ( config, format ! ( "Unwrapping {}" , address) ) ;
1183
1159
if !config. sign_only {
1184
1160
let lamports = config. rpc_client . get_balance ( & address) ?;
@@ -1469,8 +1445,7 @@ fn command_address(config: &Config, token: Option<Pubkey>, owner: Pubkey) -> Com
1469
1445
} ;
1470
1446
if let Some ( token) = token {
1471
1447
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) ;
1474
1449
cli_address. associated_token_address = Some ( associated_token_address. to_string ( ) ) ;
1475
1450
}
1476
1451
Ok ( config. output_format . formatted_string ( & cli_address) )
@@ -1484,8 +1459,7 @@ fn command_account_info(config: &Config, address: Pubkey) -> CommandResult {
1484
1459
. unwrap ( ) ;
1485
1460
let mint = Pubkey :: from_str ( & account. mint ) . unwrap ( ) ;
1486
1461
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;
1489
1463
let cli_token_account = CliTokenAccount {
1490
1464
address : address. to_string ( ) ,
1491
1465
is_associated,
@@ -1595,8 +1569,7 @@ fn command_gc(
1595
1569
1596
1570
for ( token, accounts) in accounts_by_token. into_iter ( ) {
1597
1571
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) ;
1600
1573
let total_balance: u64 = accounts. values ( ) . map ( |account| account. 0 ) . sum ( ) ;
1601
1574
1602
1575
if total_balance > 0 && !accounts. contains_key ( & associated_token_account) {
@@ -1605,7 +1578,6 @@ fn command_gc(
1605
1578
& config. fee_payer,
1606
1579
& owner,
1607
1580
& token,
1608
- & config. program_id,
1609
1581
) ] ) ;
1610
1582
lamports_needed += minimum_balance_for_rent_exemption;
1611
1583
}
@@ -3267,7 +3239,7 @@ mod tests {
3267
3239
fn create_associated_account ( config : & Config , payer : & Keypair , mint : Pubkey ) -> Pubkey {
3268
3240
let bulk_signers: Vec < Box < dyn Signer > > = vec ! [ Box :: new( clone_keypair( payer) ) ] ;
3269
3241
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)
3271
3243
}
3272
3244
3273
3245
fn mint_tokens (
@@ -3376,11 +3348,7 @@ mod tests {
3376
3348
] ,
3377
3349
) ;
3378
3350
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) ;
3384
3352
assert_eq ! ( value[ "address" ] , account. to_string( ) ) ;
3385
3353
assert_eq ! ( value[ "mint" ] , token. to_string( ) ) ;
3386
3354
assert_eq ! ( value[ "isAssociated" ] , true ) ;
@@ -3480,11 +3448,7 @@ mod tests {
3480
3448
& [ "spl-token" , CommandName :: Wrap . into ( ) , "0.5" ] ,
3481
3449
)
3482
3450
. 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 ( ) ) ;
3488
3452
let ui_account = config
3489
3453
. rpc_client
3490
3454
. get_token_account ( & account)
@@ -3500,11 +3464,7 @@ mod tests {
3500
3464
let config = test_config ( & test_validator, & payer, & spl_token:: id ( ) ) ;
3501
3465
let bulk_signers: Vec < Box < dyn Signer > > = vec ! [ Box :: new( clone_keypair( & payer) ) ] ;
3502
3466
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 ( ) ) ;
3508
3468
let result = process_test_command (
3509
3469
& config,
3510
3470
& payer,
@@ -3658,11 +3618,7 @@ mod tests {
3658
3618
let ui_amount = 10.0 ;
3659
3619
command_wrap ( & config, ui_amount, payer. pubkey ( ) , None , bulk_signers) . unwrap ( ) ;
3660
3620
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 ( ) ) ;
3666
3622
let _result = process_test_command (
3667
3623
& config,
3668
3624
& payer,
0 commit comments