CoinAlpha / gateway-api

Apache License 2.0
47 stars 25 forks source link

Redesign how Gateway polls for ETH transactions #135

Closed fengtality closed 3 years ago

fengtality commented 3 years ago

Why

As @vic-en pointed out, the client currently does not handle polling for ETH transactions well. When it sends a tx, it sleeps instead of properly waiting for the next block before polling for status. We should redesign how it works so that it uses info from the RPC provider to determine when to poll.

What

As discussed in standup, change /eth/poll so that it handles the case where the hash isn't available. Check if we are calling the correct API in ethers (getTransactionReceipt), etc.

The result should be that we can call the poll function immediately after sending the transaction without having to add sleeps.

fengtality commented 3 years ago

I suggest looking at the other Transaction methods in the ethers docs: https://docs.ethers.io/v5/api/providers/provider/#Provider--transaction-methods

Especially:

To stall until the transaction has been mined, consider the waitForTransaction method below.