@@ -42,7 +42,7 @@ use solana_sdk::{
4242 transaction:: Transaction ,
4343} ;
4444use 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} ;
4747use 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,
0 commit comments