From f0d5f07a8632cdb12f18f0c6af0dbdc791645104 Mon Sep 17 00:00:00 2001 From: Andrei Silviu Dragnea Date: Wed, 14 Aug 2024 16:48:14 +0100 Subject: [PATCH] Fix create_associated_token_account for spl_token_2022::ID --- src/extensions/client/banks_client.rs | 3 ++- src/extensions/client/mod.rs | 2 +- src/extensions/client/rpc_client.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/extensions/client/banks_client.rs b/src/extensions/client/banks_client.rs index b1ba846..6756d69 100644 --- a/src/extensions/client/banks_client.rs +++ b/src/extensions/client/banks_client.rs @@ -168,7 +168,8 @@ impl ClientExtensions for BanksClient { token_program_id: &Pubkey, ) -> Result> { let latest_blockhash = self.get_latest_blockhash().await?; - let associated_token_account = get_associated_token_address(account, mint); + let associated_token_account = + get_associated_token_address_with_program_id(account, mint, token_program_id); let ix = create_associated_token_account_ix(&payer.pubkey(), account, mint, token_program_id); diff --git a/src/extensions/client/mod.rs b/src/extensions/client/mod.rs index 6cbfc1a..050b7b2 100644 --- a/src/extensions/client/mod.rs +++ b/src/extensions/client/mod.rs @@ -11,7 +11,7 @@ use solana_sdk::{ transaction::Transaction, }; use spl_associated_token_account::{ - get_associated_token_address, + get_associated_token_address_with_program_id, instruction::create_associated_token_account as create_associated_token_account_ix, }; diff --git a/src/extensions/client/rpc_client.rs b/src/extensions/client/rpc_client.rs index 49909a8..c1b6578 100644 --- a/src/extensions/client/rpc_client.rs +++ b/src/extensions/client/rpc_client.rs @@ -165,7 +165,8 @@ impl ClientExtensions for RpcClient { payer: &Keypair, token_program_id: &Pubkey, ) -> Result> { - let associated_token_account = get_associated_token_address(account, mint); + let associated_token_account = + get_associated_token_address_with_program_id(account, mint, token_program_id); let tx = self .transaction_from_instructions(