feat: upgrade to v2.0.0 with major dependency updates

- Upgrade Solana dependencies from 2.3.x to 3.0.0 series
  - Upgrade solana-streamer-sdk from 0.4.13 to 0.5.0
  - Upgrade yellowstone-grpc from 8.0.0 to 9.0.0
  - Add new SPL token utility modules (spl_token.rs, spl_token_2022.rs,
  spl_associated_token_account.rs)
  - Remove deprecated gRPC protocol definitions (protos/ directory)
  - Remove event_subscription example and update all example dependencies
  - Update README documentation to reflect v2.0.0 changes
  - Refactor imports to use new dependency structure across examples

  BREAKING CHANGES:
  - Solana SDK upgraded to 3.0.0 with API changes
  - Removed gRPC protocol definitions
  - Updated import paths for SPL token operations
This commit is contained in:
ysq
2025-09-27 14:24:41 +08:00
parent e75b0c9480
commit a7f673b43d
70 changed files with 502 additions and 3001 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
use dashmap::DashMap;
use once_cell::sync::Lazy;
use smallvec::SmallVec;
use solana_sdk::{compute_budget::ComputeBudgetInstruction, instruction::Instruction};
use solana_sdk::instruction::Instruction;
use solana_compute_budget_interface::ComputeBudgetInstruction;
/// Cache key containing all parameters for compute budget instructions
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+14 -5
View File
@@ -1,9 +1,10 @@
use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction};
use solana_system_interface::instruction::transfer;
use spl_associated_token_account::get_associated_token_address;
use spl_token::instruction::close_account;
use crate::common::SolanaRpcClient;
use crate::common::{
fast_fn::get_associated_token_address_with_program_id_fast, spl_token::close_account,
SolanaRpcClient,
};
use anyhow::anyhow;
/// Get the balances of two tokens in the pool
@@ -35,7 +36,11 @@ pub async fn get_token_balance(
payer: &Pubkey,
mint: &Pubkey,
) -> Result<u64, anyhow::Error> {
let ata = get_associated_token_address(payer, mint);
let ata = crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
payer,
mint,
&crate::constants::TOKEN_PROGRAM,
);
let balance = rpc.get_token_account_balance(&ata).await?;
let balance_u64 =
balance.amount.parse::<u64>().map_err(|_| anyhow!("Failed to parse token balance"))?;
@@ -102,7 +107,11 @@ pub async fn close_token_account(
mint: &Pubkey,
) -> Result<(), anyhow::Error> {
// Get associated token account address
let ata = get_associated_token_address(&payer.pubkey(), mint);
let ata = get_associated_token_address_with_program_id_fast(
&payer.pubkey(),
mint,
&crate::constants::TOKEN_PROGRAM,
);
// Check if account exists
let account_exists = rpc.get_account(&ata).await.is_ok();
+10 -5
View File
@@ -1,8 +1,9 @@
use crate::common::fast_fn::create_associated_token_account_idempotent_fast;
use crate::common::{
fast_fn::create_associated_token_account_idempotent_fast, spl_token::close_account,
};
use smallvec::SmallVec;
use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
use solana_sdk::{instruction::Instruction, message::AccountMeta, pubkey::Pubkey};
use solana_system_interface::instruction::transfer;
use spl_token::instruction::close_account;
#[inline]
pub fn handle_wsol(payer: &Pubkey, amount_in: u64) -> SmallVec<[Instruction; 3]> {
@@ -22,8 +23,12 @@ pub fn handle_wsol(payer: &Pubkey, amount_in: u64) -> SmallVec<[Instruction; 3]>
));
insts.extend([
transfer(&payer, &wsol_token_account, amount_in),
spl_token::instruction::sync_native(&crate::constants::TOKEN_PROGRAM, &wsol_token_account)
.unwrap(),
// sync_native
Instruction {
program_id: crate::constants::TOKEN_PROGRAM,
accounts: vec![AccountMeta::new(wsol_token_account, false)],
data: vec![17],
},
]);
insts