Better Gas estimation for on-chain calls #617
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This PR adds better gas estimation for any on-chain calls in the browser. It primarily uses etherscan's estimation api (this is wrapped behind a simple AWS gateway), but has a fallback function that uses the local node to do so.
The advantage of the etherscan api is that it has a richer estimation algorithm (with low, med and high - we use medium for this application) while the fallback relies on the average gas cost of the last n blocks.
The url endpoint is hardcoded, it will be used for all deployments of the wallet (i.e.
testnet
,mainnet
) since etherscan only provides an estimation formainnet
. This isn't a problem as it means we get a good idea of the gas costs involved on mainnet even while testing usingGoerli
.Placing the api behind an AWS endpoint means we can monitor and add throttling or restrictions if we find that they are being over-used.
Note: There is some eslint issues fixed here too