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
+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();