Skip to content

Commit

Permalink
associated-token-account-client: Remove solana-program (#7443)
Browse files Browse the repository at this point in the history
#### Problem

The ATA client crate still uses solana-program, but it doesn't need it.

#### Summary of changes

Remove its usage, but it's still needed in dev-dependencies until the
system program client has been extracted.
  • Loading branch information
joncinque authored Nov 1, 2024
1 parent 4b2a3c3 commit 35750a3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
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"] }

[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");
}

0 comments on commit 35750a3

Please sign in to comment.