JoinColony / purser

Interact with Ethereum wallets easily
https://joincolony.github.io/purser
MIT License
84 stars 21 forks source link

Add MetaMask/Infura workaround for pending transactions #265

Closed JamesLefrere closed 5 years ago

JamesLefrere commented 5 years ago

This PR adds a workaround for an Infura issue (that becomes a problem with our MetaMask implementation) as documented here and more specifically here.

The crux of our issue is that purser-metamask's signTransaction method attempts to get the transaction that MetaMask sent in the callback of sendTransaction, when it is pending. With most providers, the getTransaction method will respond with the transaction when it is pending, but Infura recently started returning an empty response.

The workaround involves attempting to get the transaction immediately, and if that fails, using a web3 0.20.x-compatible package (await-transaction-mined) to wait for the transaction to be confirmed before getting the transaction.

This PR also makes some improvements to various defaults as suggested in #261 .