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

Commit 35750a3

Browse files
authored
associated-token-account-client: Remove solana-program (#7443)
#### 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.
1 parent 4b2a3c3 commit 35750a3

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

associated-token-account/client/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ license = "Apache-2.0"
88
edition = "2021"
99

1010
[dependencies]
11+
solana-instruction = { version = "2.1.0", features = ["std"] }
12+
solana-pubkey = { version = "2.1.0", features = ["curve25519"] }
13+
14+
[dev-dependencies]
1115
solana-program = "2.1.0"
1216

1317
[package.metadata.docs.rs]

associated-token-account/client/src/address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Address derivation functions
22
3-
use solana_program::pubkey::Pubkey;
3+
use solana_pubkey::Pubkey;
44

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

2121
mod inline_spl_token {
22-
solana_program::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
22+
solana_pubkey::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
2323
}
2424

2525
/// Derives the associated token account address for the given wallet address

associated-token-account/client/src/instruction.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//! Instruction creators for the program
22
use {
33
crate::{address::get_associated_token_address_with_program_id, program::id},
4-
solana_program::{
5-
instruction::{AccountMeta, Instruction},
6-
pubkey::Pubkey,
7-
system_program,
8-
},
4+
solana_instruction::{AccountMeta, Instruction},
5+
solana_pubkey::Pubkey,
96
};
107

8+
const SYSTEM_PROGRAM_ID: Pubkey = Pubkey::from_str_const("11111111111111111111111111111111");
9+
1110
fn build_associated_token_account_instruction(
1211
funding_address: &Pubkey,
1312
wallet_address: &Pubkey,
@@ -29,7 +28,7 @@ fn build_associated_token_account_instruction(
2928
AccountMeta::new(associated_account_address, false),
3029
AccountMeta::new_readonly(*wallet_address, false),
3130
AccountMeta::new_readonly(*token_mint_address, false),
32-
AccountMeta::new_readonly(system_program::id(), false),
31+
AccountMeta::new_readonly(SYSTEM_PROGRAM_ID, false),
3332
AccountMeta::new_readonly(*token_program_id, false),
3433
],
3534
data: vec![instruction],
@@ -105,3 +104,13 @@ pub fn recover_nested(
105104
data: vec![2], // AssociatedTokenAccountInstruction::RecoverNested
106105
}
107106
}
107+
108+
#[cfg(test)]
109+
mod tests {
110+
use {super::*, solana_program::system_program};
111+
112+
#[test]
113+
fn system_program_id() {
114+
assert_eq!(system_program::id(), SYSTEM_PROGRAM_ID);
115+
}
116+
}

associated-token-account/client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ pub mod instruction;
77

88
/// Module defining the program id
99
pub mod program {
10-
solana_program::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
10+
solana_pubkey::declare_id!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
1111
}

0 commit comments

Comments
 (0)