feat: refactor trade API to return execution status with signature

- Bump version from 1.2.0 to 1.2.1
- Change trade methods return type from Signature to (bool, Signature)
- Improve parallel execution error handling and status tracking
- Update CLI examples to match new API interface
- Enhance transaction success/failure reporting capabilities

Breaking Change: Trade API now returns tuple (success_status, signature)
This commit is contained in:
ysq
2025-09-25 21:39:14 +08:00
parent ce5243702c
commit 3962a278b9
8 changed files with 61 additions and 45 deletions
+19 -19
View File
@@ -620,9 +620,9 @@ async fn handle_buy_pumpfun(
durable_nonce: None,
};
match client.buy(buy_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully bought tokens from PumpFun!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to buy tokens from PumpFun: {}", e);
@@ -669,9 +669,9 @@ async fn handle_buy_pumpswap(
durable_nonce: None,
};
match client.buy(buy_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully bought tokens from PumpSwap!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to buy tokens from PumpSwap: {}", e);
@@ -717,9 +717,9 @@ async fn handle_buy_bonk(
durable_nonce: None,
};
match client.buy(buy_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully bought tokens from Bonk!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to buy tokens from Bonk: {}", e);
@@ -769,9 +769,9 @@ async fn handle_buy_raydium_v4(
durable_nonce: None,
};
match client.buy(buy_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully bought tokens from Raydium V4!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to buy tokens from Raydium V4: {}", e);
@@ -821,9 +821,9 @@ async fn handle_buy_raydium_cpmm(
durable_nonce: None,
};
match client.buy(buy_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully bought tokens from Raydium CPMM!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to buy tokens from Raydium CPMM: {}", e);
@@ -984,9 +984,9 @@ async fn handle_sell_pumpfun(
};
match client.sell(sell_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully sold tokens from PumpFun!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to sell tokens from PumpFun: {}", e);
@@ -1035,7 +1035,7 @@ async fn handle_sell_pumpswap(
durable_nonce: None,
};
match client.sell(sell_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully sold tokens from PumpSwap!");
println!(" ✅ Transaction Signature: {}", signature);
}
@@ -1086,9 +1086,9 @@ async fn handle_sell_bonk(
durable_nonce: None,
};
match client.sell(sell_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully sold tokens from Bonk!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to sell tokens from Bonk: {}", e);
@@ -1140,9 +1140,9 @@ async fn handle_sell_raydium_v4(
durable_nonce: None,
};
match client.sell(sell_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully sold tokens from Raydium V4!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to sell tokens from Raydium V4: {}", e);
@@ -1194,9 +1194,9 @@ async fn handle_sell_raydium_cpmm(
durable_nonce: None,
};
match client.sell(sell_params).await {
Ok(signature) => {
Ok((_, signature)) => {
println!(" ✅ Successfully sold tokens from Raydium CPMM!");
println!(" ✅ Transaction Signature: {}", signature);
println!(" ✅ Transaction Signature: {:?}", signature);
}
Err(e) => {
println!(" ❌ Failed to sell tokens from Raydium CPMM: {}", e);