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

associated-token-account-client: Remove solana-program #7443

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions associated-token-account/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ license = "Apache-2.0"
edition = "2021"

[dependencies]
solana-instruction = { version = "2.1.0", features = ["std"] }
solana-pubkey = { version = "2.1.0", features = ["curve25519"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


[dev-dependencies]
solana-program = "2.1.0"

[package.metadata.docs.rs]
Expand Down
4 changes: 2 additions & 2 deletions associated-token-account/client/src/address.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Address derivation functions

use solana_program::pubkey::Pubkey;
use solana_pubkey::Pubkey;

/// Derives the associated token account address and bump seed
/// for the given wallet address, token mint and token program id
Expand All @@ -19,7 +19,7 @@ pub fn get_associated_token_address_and_bump_seed(
}

mod inline_spl_token {
solana_program::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
solana_pubkey::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
}

/// Derives the associated token account address for the given wallet address
Expand Down
21 changes: 15 additions & 6 deletions associated-token-account/client/src/instruction.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! Instruction creators for the program
use {
crate::{address::get_associated_token_address_with_program_id, program::id},
solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
system_program,
},
solana_instruction::{AccountMeta, Instruction},
solana_pubkey::Pubkey,
};

const SYSTEM_PROGRAM_ID: Pubkey = Pubkey::from_str_const("11111111111111111111111111111111");

fn build_associated_token_account_instruction(
funding_address: &Pubkey,
wallet_address: &Pubkey,
Expand All @@ -29,7 +28,7 @@ fn build_associated_token_account_instruction(
AccountMeta::new(associated_account_address, false),
AccountMeta::new_readonly(*wallet_address, false),
AccountMeta::new_readonly(*token_mint_address, false),
AccountMeta::new_readonly(system_program::id(), false),
AccountMeta::new_readonly(SYSTEM_PROGRAM_ID, false),
AccountMeta::new_readonly(*token_program_id, false),
],
data: vec![instruction],
Expand Down Expand Up @@ -105,3 +104,13 @@ pub fn recover_nested(
data: vec![2], // AssociatedTokenAccountInstruction::RecoverNested
}
}

#[cfg(test)]
mod tests {
use {super::*, solana_program::system_program};

#[test]
fn system_program_id() {
assert_eq!(system_program::id(), SYSTEM_PROGRAM_ID);
}
}
2 changes: 1 addition & 1 deletion associated-token-account/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pub mod instruction;

/// Module defining the program id
pub mod program {
solana_program::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
solana_pubkey::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
}