transaction is sent to blockchain however bot doesn't buy the token
This commit is contained in:
@@ -64,11 +64,12 @@ async fn main() -> Result<()> {
|
||||
let (_plan, prepared) = prepare_and_build(txu, &adapters, &kp_pub)?;
|
||||
|
||||
// 2) Blockhash fresco + slot
|
||||
let (new_bh, ctx_slot) = rpc.get_latest_blockhash().await?;
|
||||
let (latest_blockhash, ctx_slot) = rpc.get_latest_blockhash().await?;
|
||||
println!("latest_blockhash: {latest_blockhash}"); //si borro esto parece q no refresba bien latest_blockhash
|
||||
println!("Latest slot solana: {ctx_slot}");
|
||||
|
||||
// 3) Actualiza blockhash del mensaje
|
||||
let vm = set_recent_blockhash(prepared.message, new_bh);
|
||||
let vm = set_recent_blockhash(prepared.message, latest_blockhash);
|
||||
|
||||
// 4) Firma con tu keypair
|
||||
let vtx = sign_versioned_tx(vm, &[&kp])?;
|
||||
@@ -81,7 +82,7 @@ async fn main() -> Result<()> {
|
||||
|
||||
|
||||
// 6) Enviar
|
||||
let sig = rpc.send_transaction(&vtx, Some(ctx_slot)).await?;
|
||||
let sig = rpc.send_transaction(&vtx, None).await?;
|
||||
println!("🚀 Enviada: {}", sig);
|
||||
|
||||
|
||||
|
||||
19
src/rpc.rs
19
src/rpc.rs
@@ -93,13 +93,11 @@ struct GetLatestBlockhashValue {
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct SimSendConfig<'a> {
|
||||
encoding: &'a str, // "base64"
|
||||
#[serde(rename = "sigVerify")]
|
||||
sig_verify: bool, // false
|
||||
#[serde(rename = "replaceRecentBlockhash")]
|
||||
replace_recent_blockhash: bool, // true/false
|
||||
#[serde(rename = "commitment")]
|
||||
sig_verify: bool,
|
||||
replace_recent_blockhash: bool, // false
|
||||
commitment: &'a str,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -107,7 +105,7 @@ struct SimSendConfig<'a> {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
skip_preflight: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "minContextSlot")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
min_context_slot: Option<u64>,
|
||||
}
|
||||
|
||||
@@ -158,7 +156,7 @@ impl Rpc for HttpRpc {
|
||||
replace_recent_blockhash: false, // usa el mismo blockhash que envías
|
||||
commitment: &self.commitment,
|
||||
preflight_commitment: Some(&self.commitment),
|
||||
skip_preflight: None,
|
||||
skip_preflight: Some(true),
|
||||
min_context_slot,
|
||||
};
|
||||
|
||||
@@ -169,6 +167,7 @@ impl Rpc for HttpRpc {
|
||||
params: Some(vec![serde_json::json!(tx_b64), serde_json::to_value(cfg)?]),
|
||||
};
|
||||
|
||||
|
||||
let resp: RpcResponse<serde_json::Value> = self
|
||||
.client
|
||||
.post(&self.url)
|
||||
@@ -193,9 +192,9 @@ impl Rpc for HttpRpc {
|
||||
sig_verify: false,
|
||||
replace_recent_blockhash: false,
|
||||
commitment: &self.commitment,
|
||||
preflight_commitment: Some(&self.commitment),
|
||||
skip_preflight: Some(false),
|
||||
min_context_slot, // 👈 importante
|
||||
preflight_commitment: None,
|
||||
skip_preflight: Some(true),
|
||||
min_context_slot: None
|
||||
};
|
||||
|
||||
let req = RpcRequest {
|
||||
|
||||
Reference in New Issue
Block a user