Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Returning a PendingTransaction after sending a tx #107

Merged
merged 7 commits into from
Dec 17, 2020
Merged

Conversation

gakonst
Copy link
Owner

@gakonst gakonst commented Dec 17, 2020

Improves the ergonomics of sending & waiting for a transaction to be mined. You can now do

// Before
let tx_hash = provider.send_transaction(...).await?
dbg!(tx_hash);
let receipt = provider.pending_transaction(tx_hash).await?;

// After:
let receipt = provider.send_transaction(...).await?.await?;

// or:
let pending_tx = provider.send_transaction(...).await?;
dbg!(*pending_tx);
let receipt = pending_tx.await?;

// you can still use the syntax for N confs like so:
let receipt = provider.send_transaction(...).await?.confirmations(6).await?;

THIS IS A BREAKING CHANGE

  • If you use previously used the tx_hash in the return values of a send_transaction call, you should deref it since PendingTransaction derefs to TxHash
  • Smart contract calls need to be split in the "create call" and "send call":
// Before:
let pending_tx = contract
            .method::<_, H256>("setValue", "hi".to_owned())
            .unwrap()
            .send()
            .await
            .unwrap();

// After:
let call = contract.method::<_, H256>("setValue", "hi".to_owned()).unwrap();
let pending_tx = call.send().await.unwrap();

@gakonst gakonst added the enhancement New feature or request label Dec 17, 2020
@gakonst
Copy link
Owner Author

gakonst commented Dec 17, 2020

Merging, CI failure is related to #105

@gakonst gakonst merged commit 3a2fd3e into master Dec 17, 2020
@gakonst gakonst deleted the auto-pending-tx branch December 17, 2020 11:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant