Skip to content

Commit

Permalink
fix: do not wait for success event on tx
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj committed Nov 23, 2023
1 parent 81528f6 commit 6750b0b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/txes/processor.rs
Original file line number Diff line number Diff line change
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 6750b0b

Please sign in to comment.