Skip to content

Commit def0e43

Browse files
authored
chore: Update dependencies and refactor token interfaces (update to v… (#242)
* chore: Update dependencies and refactor token interfaces (update to v3 for sdks) - Upgraded `agave-feature-set` and `agave-reserved-account-keys` to version 3.0.8 in `Cargo.lock`. - Updated various Solana SDK dependencies to version 3.0.x for improved compatibility and features. - Refactored token-related imports to use the new `spl_token_interface` and `spl_token_2022_interface` for better modularity. - Removed outdated dependencies and adjusted related code to ensure consistency across the codebase. - Enhanced test cases to reflect changes in token interface usage and ensure proper functionality.
1 parent 3806a88 commit def0e43

35 files changed

+1242
-2237
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ jsonrpsee = { version = "0.16.2", features = [
3535
"http-client",
3636
"client",
3737
] }
38-
solana-sdk = "2.1.9"
39-
solana-commitment-config = "2.1.9"
40-
solana-message = "2.1.9"
41-
solana-system-interface = "1.0.0"
42-
solana-transaction-status-client-types = "2.1.9"
43-
solana-transaction-status = "2.1.9"
44-
solana-address-lookup-table-interface = "2.2.2"
45-
solana-program = "2.1.9"
46-
solana-client = "2.1.9"
38+
solana-sdk = "3.0.0"
39+
solana-commitment-config = "3.0.0"
40+
solana-message = "3.0.1"
41+
solana-system-interface = "2.0.0"
42+
solana-transaction-status-client-types = "3.0.8"
43+
solana-transaction-status = "3.0.8"
44+
solana-address-lookup-table-interface = "3.0.0"
45+
solana-program = "3.0.0"
46+
solana-program-pack = "3.0.0"
47+
solana-compute-budget-interface = "3.0.0"
48+
solana-client = "3.0.8"
4749
bs58 = "0.5.1"
4850
bincode = "1.3.3"
4951
borsh = "1.5.3"
@@ -67,11 +69,9 @@ futures-util = "0.3.31"
6769
hyper = "1.5.1"
6870
http = "0.2"
6971
toml = "0.8.19"
70-
spl-token = { version = "7.0.0", features = ["no-entrypoint"] }
71-
spl-token-2022 = { version = "8.0.0", features = ["no-entrypoint"] }
72-
spl-associated-token-account = { version = "6.0.0", features = [
73-
"no-entrypoint",
74-
] }
72+
spl-token-interface = { version = "2.0.0" }
73+
spl-token-2022-interface = { version = "2.0.0" }
74+
spl-associated-token-account-interface = { version = "2.0.0" }
7575
chrono = "0.4.39"
7676
hex = "0.4.3"
7777
p256 = "0.13.3"

crates/lib/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ solana-commitment-config = { workspace = true }
2626
solana-message = { workspace = true }
2727
solana-system-interface = { workspace = true }
2828
solana-program = { workspace = true }
29+
solana-program-pack = { workspace = true }
30+
solana-compute-budget-interface = { workspace = true }
2931
solana-transaction-status-client-types = { workspace = true }
3032
solana-transaction-status = { workspace = true }
3133
solana-address-lookup-table-interface = { workspace = true }
@@ -37,11 +39,12 @@ base64 = { workspace = true }
3739
tokio = { workspace = true }
3840
async-trait = { workspace = true }
3941
reqwest = { workspace = true }
40-
spl-token = { workspace = true }
41-
spl-token-2022 = { workspace = true }
42-
spl-associated-token-account = { workspace = true }
43-
solana-signers = { git = "https://github.com/solana-foundation/solana-signers", features = [
42+
spl-token-interface = { workspace = true }
43+
spl-token-2022-interface = { workspace = true }
44+
spl-associated-token-account-interface = { workspace = true }
45+
solana-signers = { git = "https://github.com/solana-foundation/solana-signers", default-features = false, features = [
4446
"all",
47+
"sdk-v3",
4548
] }
4649
vaultrs = { workspace = true }
4750
deadpool-redis = { workspace = true }
@@ -56,7 +59,7 @@ rand = "0.9.2"
5659
utoipa = { workspace = true }
5760
dirs = "6.0.0"
5861
mockall = "0.13.1"
59-
spl-pod = "0.5.0"
62+
spl-pod = "0.7.1"
6063
p256 = { version = "0.13", features = ["ecdsa"] }
6164
chrono = { workspace = true }
6265
hex = { workspace = true }

crates/lib/src/admin/token_util.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ use crate::{
55
transaction::TransactionUtil,
66
};
77
use solana_client::nonblocking::rpc_client::RpcClient;
8+
use solana_compute_budget_interface::ComputeBudgetInstruction;
89
use solana_message::{Message, VersionedMessage};
9-
use solana_sdk::{
10-
compute_budget::ComputeBudgetInstruction, instruction::Instruction, pubkey::Pubkey,
11-
};
10+
use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
1211
use solana_signers::SolanaSigner;
1312

14-
use spl_associated_token_account::{
15-
get_associated_token_address, instruction::create_associated_token_account,
13+
use spl_associated_token_account_interface::{
14+
address::get_associated_token_address, instruction::create_associated_token_account,
1615
};
1716
use std::{fmt::Display, str::FromStr, sync::Arc};
1817

@@ -389,13 +388,17 @@ mod tests {
389388
let atas_to_create = vec![
390389
ATAToCreate {
391390
mint: mint1,
392-
ata: spl_associated_token_account::get_associated_token_address(&address, &mint1),
393-
token_program: spl_token::id(),
391+
ata: spl_associated_token_account_interface::address::get_associated_token_address(
392+
&address, &mint1,
393+
),
394+
token_program: spl_token_interface::id(),
394395
},
395396
ATAToCreate {
396397
mint: mint2,
397-
ata: spl_associated_token_account::get_associated_token_address(&address, &mint2),
398-
token_program: spl_token::id(),
398+
ata: spl_associated_token_account_interface::address::get_associated_token_address(
399+
&address, &mint2,
400+
),
401+
token_program: spl_token_interface::id(),
399402
},
400403
];
401404

crates/lib/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22
use solana_sdk::pubkey::Pubkey;
3-
use spl_token_2022::extension::ExtensionType;
3+
use spl_token_2022_interface::extension::ExtensionType;
44
use std::{fs, path::Path, str::FromStr};
55
use toml;
66
use utoipa::ToSchema;

crates/lib/src/fee/fee.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ mod tests {
491491
config_mock::ConfigMockBuilder,
492492
rpc_mock::RpcMockBuilder,
493493
},
494-
token::{interface::TokenInterface, TokenProgram},
494+
token::{interface::TokenInterface, spl_token::TokenProgram},
495495
transaction::TransactionUtil,
496496
};
497497
use solana_message::{v0, Message, VersionedMessage};
@@ -509,7 +509,7 @@ mod tests {
509509
},
510510
program::ID as SYSTEM_PROGRAM_ID,
511511
};
512-
use spl_associated_token_account::get_associated_token_address;
512+
use spl_associated_token_account_interface::address::get_associated_token_address;
513513

514514
#[test]
515515
fn test_is_fee_payer_in_signers_legacy_fee_payer_is_signer() {

crates/lib/src/rpc_server/method/transfer_transaction.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ mod tests {
164164
#[tokio::test]
165165
async fn test_transfer_transaction_invalid_source() {
166166
let config = ConfigMockBuilder::new().build();
167-
let _ = update_config(config);
167+
update_config(config).unwrap();
168168
let _ = setup_or_get_test_signer();
169169

170170
let rpc_client = Arc::new(RpcMockBuilder::new().with_mint_account(6).build());
@@ -192,7 +192,8 @@ mod tests {
192192

193193
#[tokio::test]
194194
async fn test_transfer_transaction_invalid_destination() {
195-
let _m = ConfigMockBuilder::new().build_and_setup();
195+
let config = ConfigMockBuilder::new().build();
196+
update_config(config).unwrap();
196197
let _ = setup_or_get_test_signer();
197198

198199
let rpc_client = Arc::new(RpcMockBuilder::new().with_mint_account(6).build());
@@ -219,7 +220,8 @@ mod tests {
219220

220221
#[tokio::test]
221222
async fn test_transfer_transaction_invalid_token() {
222-
let _m = ConfigMockBuilder::new().build_and_setup();
223+
let config = ConfigMockBuilder::new().build();
224+
update_config(config).unwrap();
223225
let _ = setup_or_get_test_signer();
224226

225227
let rpc_client = Arc::new(RpcMockBuilder::new().with_mint_account(6).build());

crates/lib/src/tests/account_mock.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use spl_pod::{
66
optional_keys::OptionalNonZeroPubkey,
77
primitives::{PodU16, PodU64},
88
};
9-
use spl_token::state::{Account as TokenAccount, AccountState as SplAccountState, Mint};
10-
use spl_token_2022::{
9+
use spl_token_2022_interface::{
1110
extension::{
1211
self,
1312
transfer_fee::{TransferFee, TransferFeeConfig},
@@ -18,9 +17,11 @@ use spl_token_2022::{
1817
Account as Token2022AccountState, AccountState as Token2022AccountState_, Mint as Mint2022,
1918
},
2019
};
20+
use spl_token_interface::state::{Account as TokenAccount, AccountState as SplAccountState, Mint};
2121

2222
use crate::token::{
23-
spl_token_2022::Token2022Mint, spl_token_2022_util::ParsedExtension, Token2022Account,
23+
spl_token_2022::{Token2022Account, Token2022Mint},
24+
spl_token_2022_util::ParsedExtension,
2425
};
2526

2627
// Common default values used across mock builders
@@ -242,7 +243,7 @@ impl TokenAccountMockBuilder {
242243
Account {
243244
lamports: self.lamports,
244245
data,
245-
owner: spl_token::id(),
246+
owner: spl_token_interface::id(),
246247
executable: false,
247248
rent_epoch: self.rent_epoch,
248249
}
@@ -267,7 +268,7 @@ impl TokenAccountMockBuilder {
267268
Account {
268269
lamports: self.lamports,
269270
data,
270-
owner: spl_token_2022::id(),
271+
owner: spl_token_2022_interface::id(),
271272
executable: false,
272273
rent_epoch: self.rent_epoch,
273274
}
@@ -397,7 +398,7 @@ impl MintAccountMockBuilder {
397398
Account {
398399
lamports: self.lamports,
399400
data,
400-
owner: spl_token::id(),
401+
owner: spl_token_interface::id(),
401402
executable: false,
402403
rent_epoch: self.rent_epoch,
403404
}
@@ -421,7 +422,7 @@ impl MintAccountMockBuilder {
421422
Account {
422423
lamports: self.lamports,
423424
data,
424-
owner: spl_token_2022::id(),
425+
owner: spl_token_2022_interface::id(),
425426
executable: false,
426427
rent_epoch: self.rent_epoch,
427428
}
@@ -484,7 +485,7 @@ impl MintAccountMockBuilder {
484485
Ok(Account {
485486
lamports: self.lamports,
486487
data,
487-
owner: spl_token_2022::id(),
488+
owner: spl_token_2022_interface::id(),
488489
executable: false,
489490
rent_epoch: self.rent_epoch,
490491
})
@@ -588,10 +589,14 @@ pub fn create_mock_token2022_mint_with_extensions(
588589
/// Helper to create Transfer Fee Config for testing
589590
pub fn create_transfer_fee_config(basis_points: u16, max_fee: u64) -> TransferFeeConfig {
590591
TransferFeeConfig {
591-
transfer_fee_config_authority: OptionalNonZeroPubkey::try_from(Some(Pubkey::new_unique()))
592-
.unwrap(),
593-
withdraw_withheld_authority: OptionalNonZeroPubkey::try_from(Some(Pubkey::new_unique()))
594-
.unwrap(),
592+
transfer_fee_config_authority: OptionalNonZeroPubkey::try_from(Some(
593+
spl_pod::solana_pubkey::Pubkey::new_unique(),
594+
))
595+
.unwrap(),
596+
withdraw_withheld_authority: OptionalNonZeroPubkey::try_from(Some(
597+
spl_pod::solana_pubkey::Pubkey::new_unique(),
598+
))
599+
.unwrap(),
595600
withheld_amount: PodU64::from(0),
596601
newer_transfer_fee: TransferFee {
597602
epoch: PodU64::from(0),

crates/lib/src/tests/transaction_mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use solana_sdk::{
33
pubkey::Pubkey,
44
signature::Keypair,
55
signer::Signer,
6-
system_instruction::transfer,
76
transaction::{Transaction, VersionedTransaction},
87
};
8+
use solana_system_interface::instruction::transfer;
99

1010
use crate::transaction::TransactionUtil;
1111

crates/lib/src/token/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ pub mod spl_token_2022_util;
55
pub mod token;
66

77
pub use interface::{TokenInterface, TokenState};
8-
pub use spl_token::{TokenAccount, TokenProgram};
9-
pub use spl_token_2022::{Token2022Account, Token2022Program};

0 commit comments

Comments
 (0)