decentraland / decentraland-eth

DEPRECATED - Ethereum common helpers for Decentraland
https://decentraland.github.io/decentraland-eth/
Apache License 2.0
15 stars 9 forks source link

fix: wrong replaced tx #35

Closed cazala closed 5 years ago

cazala commented 5 years ago

This PR changes the order on that we fetch the tx status and the account nonce to solve a race condition on which the status would return as pending (non null but with null blockNumber) and it will get mined before the await eth.getCurrentNonce() is resolved, resulting in a replaced tx.

By fetching the account nonce first, if the tx gets mined in between the calls to fetch the nonce and the tx status, the transaction will come back with a non null block number and it will be returned as confirmed (or reverted).