feat: harden trading SDK examples
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Instruction Middleware
|
||||
|
||||
[中文](README_CN.md)
|
||||
|
||||
Demonstrates implementing `InstructionMiddleware`, installing it in a `MiddlewareManager`, and observing or modifying instructions before submission.
|
||||
|
||||
> The example loads `PRIVATE_KEY` and calls `client.buy`. After configuration it can submit a real PumpSwap mainnet transaction.
|
||||
|
||||
```bash
|
||||
cargo run --package middleware_system
|
||||
```
|
||||
|
||||
Middleware must preserve signer, account-order, compute-budget, tip, nonce, and transaction-size semantics. Keep latency-sensitive middleware deterministic and free of blocking I/O.
|
||||
@@ -0,0 +1,13 @@
|
||||
# 指令中间件
|
||||
|
||||
[English](README.md)
|
||||
|
||||
展示如何实现 `InstructionMiddleware`、安装到 `MiddlewareManager`,并在提交前观察或修改指令。
|
||||
|
||||
> 示例从 `PRIVATE_KEY` 加载钱包并调用 `client.buy`;配置完成后可能提交真实 PumpSwap 主网交易。
|
||||
|
||||
```bash
|
||||
cargo run --package middleware_system
|
||||
```
|
||||
|
||||
中间件必须保持 signer、账户顺序、compute budget、tip、nonce 和交易体积语义。低延迟中间件应确定性执行,不能包含阻塞 I/O。
|
||||
@@ -10,7 +10,7 @@ use sol_trade_sdk::{
|
||||
SolanaTrade, TradeTokenType,
|
||||
};
|
||||
use solana_commitment_config::CommitmentConfig;
|
||||
use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signature::Keypair};
|
||||
use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -59,7 +59,7 @@ impl InstructionMiddleware for CustomMiddleware {
|
||||
/// Initializes a new SolanaTrade client with configuration
|
||||
async fn create_solana_trade_client() -> AnyResult<SolanaTrade> {
|
||||
println!("🚀 Initializing SolanaTrade client...");
|
||||
let payer = Keypair::from_base58_string("use_your_payer_keypair_here");
|
||||
let payer = sol_trade_sdk::common::keypair::load_keypair_from_env("PRIVATE_KEY")?;
|
||||
let rpc_url = "https://api.mainnet-beta.solana.com".to_string();
|
||||
let commitment = CommitmentConfig::confirmed();
|
||||
let swqos_configs: Vec<SwqosConfig> = vec![SwqosConfig::Default(rpc_url.clone())];
|
||||
|
||||
Reference in New Issue
Block a user