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:
+13
-19
@@ -1,7 +1,7 @@
|
||||
use crate::common::SolanaRpcClient;
|
||||
use anyhow::anyhow;
|
||||
use fnv::FnvHasher;
|
||||
use solana_sdk::{instruction::Instruction, program_pack::Pack, pubkey::Pubkey};
|
||||
use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
|
||||
use solana_system_interface::instruction::create_account_with_seed;
|
||||
use std::hash::Hasher;
|
||||
use std::sync::Arc;
|
||||
@@ -34,15 +34,9 @@ pub fn start_rent_updater(client: Arc<SolanaRpcClient>) {
|
||||
|
||||
async fn fetch_rent_for_token_account(
|
||||
client: &SolanaRpcClient,
|
||||
is_2022_token: bool,
|
||||
_is_2022_token: bool,
|
||||
) -> Result<u64, anyhow::Error> {
|
||||
Ok(client
|
||||
.get_minimum_balance_for_rent_exemption(if is_2022_token {
|
||||
spl_token_2022::state::Account::LEN as usize
|
||||
} else {
|
||||
spl_token::state::Account::LEN as usize
|
||||
})
|
||||
.await?)
|
||||
Ok(client.get_minimum_balance_for_rent_exemption(165).await?)
|
||||
}
|
||||
|
||||
pub fn create_associated_token_account_use_seed(
|
||||
@@ -51,7 +45,7 @@ pub fn create_associated_token_account_use_seed(
|
||||
mint: &Pubkey,
|
||||
token_program: &Pubkey,
|
||||
) -> Result<Vec<Instruction>, anyhow::Error> {
|
||||
let is_2022_token = token_program == &spl_token_2022::id();
|
||||
let is_2022_token = token_program == &crate::constants::TOKEN_PROGRAM_2022;
|
||||
let rent =
|
||||
if is_2022_token { unsafe { SPL_TOKEN_2022_RENT } } else { unsafe { SPL_TOKEN_RENT } };
|
||||
if rent.is_none() {
|
||||
@@ -72,18 +66,14 @@ pub fn create_associated_token_account_use_seed(
|
||||
let seed = unsafe { std::str::from_utf8_unchecked(&buf) };
|
||||
let ata_like = Pubkey::create_with_seed(payer, seed, token_program)?;
|
||||
|
||||
let len = if is_2022_token {
|
||||
spl_token_2022::state::Account::LEN as u64
|
||||
} else {
|
||||
spl_token::state::Account::LEN as u64
|
||||
};
|
||||
let len = 165;
|
||||
let create_acc =
|
||||
create_account_with_seed(payer, &ata_like, owner, seed, rent.unwrap(), len, token_program);
|
||||
|
||||
let init_acc = if is_2022_token {
|
||||
spl_token_2022::instruction::initialize_account3(&token_program, &ata_like, mint, owner)?
|
||||
crate::common::spl_token_2022::initialize_account3(&token_program, &ata_like, mint, owner)?
|
||||
} else {
|
||||
spl_token::instruction::initialize_account3(&token_program, &ata_like, mint, owner)?
|
||||
crate::common::spl_token::initialize_account3(&token_program, &ata_like, mint, owner)?
|
||||
};
|
||||
|
||||
Ok(vec![create_acc, init_acc])
|
||||
@@ -106,9 +96,13 @@ pub fn get_associated_token_address_with_program_id_use_seed(
|
||||
_ => b'a' + (nibble - 10),
|
||||
};
|
||||
}
|
||||
let is_2022_token = token_program_id == &spl_token_2022::id();
|
||||
let is_2022_token = token_program_id == &crate::constants::TOKEN_PROGRAM_2022;
|
||||
let seed = unsafe { std::str::from_utf8_unchecked(&buf) };
|
||||
let token_program = if is_2022_token { &spl_token_2022::id() } else { &spl_token::id() };
|
||||
let token_program = if is_2022_token {
|
||||
&crate::constants::TOKEN_PROGRAM_2022
|
||||
} else {
|
||||
&crate::constants::TOKEN_PROGRAM
|
||||
};
|
||||
let ata_like = Pubkey::create_with_seed(wallet_address, seed, token_program)?;
|
||||
Ok(ata_like)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user