feat: upgrade to v3.2.1

This commit is contained in:
ysq
2025-11-07 17:04:36 +08:00
parent c5a55b1c14
commit 4f315187f3
4 changed files with 43 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "sol-trade-sdk"
version = "3.2.0"
version = "3.2.1"
edition = "2021"
authors = [
"William <byteblock6@gmail.com>",
+2 -2
View File
@@ -87,14 +87,14 @@ Add the dependency to your `Cargo.toml`:
```toml
# Add to your Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.0" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.1" }
```
### Use crates.io
```toml
# Add to your Cargo.toml
sol-trade-sdk = "3.2.0"
sol-trade-sdk = "3.2.1"
```
## 🛠️ Usage Examples
+2 -2
View File
@@ -87,14 +87,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.0" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.1" }
```
### 使用 crates.io
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = "3.2.0"
sol-trade-sdk = "3.2.1"
```
## 🛠️ 使用示例
+38
View File
@@ -619,4 +619,42 @@ impl SolanaTrade {
let signature = self.rpc.send_and_confirm_transaction(&transaction).await?;
Ok(signature.to_string())
}
/// Creates a wSOL associated token account (ATA) without wrapping any SOL
///
/// This function only creates the wSOL associated token account for the payer
/// without transferring any SOL into it. This is useful when you want to set up
/// the account infrastructure in advance without committing funds yet.
///
/// # Returns
/// * `Ok(String)` - Transaction signature if successful
/// * `Err(anyhow::Error)` - If the transaction fails to execute
///
/// # Errors
///
/// This function will return an error if:
/// - wSOL ATA account already exists (idempotent, will succeed silently)
/// - Transaction fails to execute or confirm
/// - Network or RPC errors occur
/// - Insufficient SOL for transaction fees
pub async fn create_wsol_ata(&self) -> Result<String, anyhow::Error> {
use crate::trading::common::wsol_manager::create_wsol_ata;
use solana_sdk::transaction::Transaction;
let recent_blockhash = self.rpc.get_latest_blockhash().await?;
let instructions = create_wsol_ata(&self.payer.pubkey());
// If instructions are empty, ATA already exists
if instructions.is_empty() {
return Err(anyhow::anyhow!(
"wSOL ATA already exists or no instructions needed"
));
}
let mut transaction =
Transaction::new_with_payer(&instructions, Some(&self.payer.pubkey()));
transaction.sign(&[&*self.payer], recent_blockhash);
let signature = self.rpc.send_and_confirm_transaction(&transaction).await?;
Ok(signature.to_string())
}
}