From c309e10b8449607f2c96af68b343335dab63a90d Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 24 Jan 2022 14:13:38 -0800 Subject: [PATCH] Restore rent sysvar to create_associated_token_account --- Cargo.lock | 10 +++---- associated-token-account/program/Cargo.toml | 2 +- associated-token-account/program/src/lib.rs | 30 ++++++++++++++++----- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b368fb47b29..cc39db76312 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3524,7 +3524,7 @@ dependencies = [ [[package]] name = "spl-associated-token-account" -version = "1.0.4" +version = "1.0.5" dependencies = [ "borsh", "solana-program", @@ -3839,7 +3839,7 @@ dependencies = [ "solana-program", "solana-remote-wallet", "solana-sdk", - "spl-associated-token-account 1.0.4", + "spl-associated-token-account 1.0.5", "spl-stake-pool", "spl-token 3.3.0", ] @@ -3909,7 +3909,7 @@ dependencies = [ "solana-remote-wallet", "solana-sdk", "solana-transaction-status", - "spl-associated-token-account 1.0.4", + "spl-associated-token-account 1.0.5", "spl-memo 3.0.1", "spl-token 3.3.0", ] @@ -3922,7 +3922,7 @@ dependencies = [ "solana-client", "solana-program-test", "solana-sdk", - "spl-associated-token-account 1.0.4", + "spl-associated-token-account 1.0.5", "spl-token-2022", "thiserror", ] @@ -4010,7 +4010,7 @@ dependencies = [ "solana-program", "solana-program-test", "solana-sdk", - "spl-associated-token-account 1.0.4", + "spl-associated-token-account 1.0.5", "spl-token 3.3.0", "thiserror", ] diff --git a/associated-token-account/program/Cargo.toml b/associated-token-account/program/Cargo.toml index fc8a659aeb4..640f8e7c8ed 100644 --- a/associated-token-account/program/Cargo.toml +++ b/associated-token-account/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spl-associated-token-account" -version = "1.0.4" +version = "1.0.5" description = "Solana Program Library Associated Token Account" authors = ["Solana Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" diff --git a/associated-token-account/program/src/lib.rs b/associated-token-account/program/src/lib.rs index cfb6ecba9ff..6460b8a3ee1 100644 --- a/associated-token-account/program/src/lib.rs +++ b/associated-token-account/program/src/lib.rs @@ -9,7 +9,12 @@ pub mod tools; // Export current SDK types for downstream users building with a different SDK version pub use solana_program; -use solana_program::{instruction::Instruction, program_pack::Pack, pubkey::Pubkey}; +use solana_program::{ + instruction::{AccountMeta, Instruction}, + program_pack::Pack, + pubkey::Pubkey, + sysvar, +}; solana_program::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"); @@ -62,7 +67,7 @@ fn get_associated_token_address_and_bump_seed_internal( /// 5. `[]` SPL Token program /// #[deprecated( - since = "1.0.4", + since = "1.0.5", note = "please use `instruction::create_associated_token_account` instead" )] pub fn create_associated_token_account( @@ -70,9 +75,20 @@ pub fn create_associated_token_account( wallet_address: &Pubkey, spl_token_mint_address: &Pubkey, ) -> Instruction { - instruction::create_associated_token_account( - funding_address, - wallet_address, - spl_token_mint_address, - ) + let associated_account_address = + get_associated_token_address(wallet_address, spl_token_mint_address); + + Instruction { + program_id: id(), + accounts: vec![ + AccountMeta::new(*funding_address, true), + AccountMeta::new(associated_account_address, false), + AccountMeta::new_readonly(*wallet_address, false), + AccountMeta::new_readonly(*spl_token_mint_address, false), + AccountMeta::new_readonly(solana_program::system_program::id(), false), + AccountMeta::new_readonly(spl_token::id(), false), + AccountMeta::new_readonly(sysvar::rent::id(), false), + ], + data: vec![], + } }