Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not wait for success event on tx #30

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading