Skip to content

Commit

Permalink
Merge pull request #30 from webb-tools/fix/do-not-wait-event
Browse files Browse the repository at this point in the history
fix: do not wait for success event on tx
  • Loading branch information
1xstj authored Nov 23, 2023
2 parents 81528f6 + ea69613 commit 3f3a785
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/txes/processor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ops::Div;

use std::sync::Arc;

use crate::subxt::utils::H256;
Expand Down Expand Up @@ -246,28 +246,30 @@ async fn handle_substrate_native_tx(

let tx_hash = tx_result.extrinsic_hash();

let events = tx_result
.wait_for_finalized_success()
.await
.map_err(|e| Error::Custom(e.to_string()))?;
let block_hash = events.block_hash();
println!("Tranasction sent with TxHash: {:?}", tx_hash);

// Find a Transfer event and print it.
let transfer_event = events
.find_first::<RuntimeApi::balances::events::Transfer>()
.map_err(|e| Error::Custom(e.to_string()))?;
if let Some(event) = transfer_event {
let from = event.from;
let to = event.to;
let amount = event.amount.div(10u128.pow(18));
println!("Transfered {amount} tokens {from} -> {to}");
}
// let events = tx_result
// .wait_for_finalized_success()
// .await
// .map_err(|e| Error::Custom(e.to_string()))?;
// let block_hash = events.block_hash();

// // Find a Transfer event and print it.
// let transfer_event = events
// .find_first::<RuntimeApi::balances::events::Transfer>()
// .map_err(|e| Error::Custom(e.to_string()))?;
// if let Some(event) = transfer_event {
// let from = event.from;
// let to = event.to;
// let amount = event.amount.div(10u128.pow(18));
// println!("Transfered {amount} tokens {from} -> {to}");
// }

// Return the transaction hash.
result_sender
.send(Ok(TxResult::Substrate {
tx_hash,
block_hash,
block_hash: tx_hash,
}))
.map_err(|e| {
Error::Custom(format!("Failed to send tx_hash: {:?}", e))
Expand Down

0 comments on commit 3f3a785

Please sign in to comment.