tablelandnetwork / studio

Discover, design, deploy, and manage data driven web3 apps on Tableland.
https://studio.tableland.xyz
4 stars 1 forks source link

Add a gas estimation message to command confirmation prompts #173

Closed joewagner closed 9 months ago

joewagner commented 9 months ago

NOTE: this requires the release of a new SDK that exports the getContractAndOverrides method. PR in review.

Overview

The import-data, deployment create, and query commands all potentially submit a transaction to the block chain using the user provided wallet. In order to give the user better control over what is done with their funds, this PR adds a message explaining what the estimated amount of gas that would be used for the transaction.

Details

The main addition included here is a helper function that wraps the ethers.js contract.estimateGas method. This helper allows the caller to specify a method and arguments for the tableland registry contract. Given that info, we can get an estimate of the amount of gas needed. In manual testing, the accuracy of the estimate is within reasonable limits. Specifically, It's always been less than 10% off in my tests. FYI: all of my tests were on the mumbai network.

railway-app[bot] commented 9 months ago

This PR was not deployed automatically as @joewagner does not have access to the Railway project.

In order to get automatic PR deploys, please add @joewagner to your team on Railway.

joewagner commented 9 months ago

@asutula I made the change to showing an estimated cost instead of gas. I was able to do it using the provider, which we already have a paid account for. You'll need to review https://github.com/tablelandnetwork/tableland-js/pull/111 before this will pass CI Also, take a look at how I'm getting the currency symbol. We can potentially move that logic to @tableland/evm or @tableland/sdk if the I'm doing it makes sense to you.

joewagner commented 9 months ago

This looks good to me. It's still in draft, so let me know if you do anything more and need another review.

I added some linting fixes, but otherwise I just published the SDK. Looks like I can still merge.