-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gasLimit
should be gas
#299
Comments
This is intentional and was part of the original library. The term gas has led to confusion and “back in the day” I had many discussion with many developers about this, and the consensus was gasLimit was more obvious what it does. If you look at the JSON-RPC code, you will see it does the conversion and contracts will through if invalid fields are given in the overrides. |
I agree that If the intent is to support both (standard way and better way), then this may just be a bug in |
There is no intention of supporting both in ethers.js, since that just adds more confusion to people that are not using both Web3 and ethers.js. There is the ethers-web3-bridge, which I'm half done updating for v4 along with TypeScript, which allows a Web3 instance to use a ethers.js provider, which manages these conversions for you. This is mainly intended for migration between ethers.js and Web3 (either direction of migration is supported). :) I should ensure that any un-recognized parameters passed into |
Version |
This is a pretty major change, at the least it should be considered a breaking change IMO (major version bump). Code that reasonably worked before will no longer work as of this change, so I think patch version is incorrect. Also, I'm pretty strongly against this change for a couple reasons:
This change assumes that the transaction being passed in is an It is also possible that the system integrating with ethers is dropping additional variables onto the transaction object for its own internal tracking, like correlation ids, supplamental details, client-specific details, or even details that are incredibly common yet not part of signing like I just want to emphasize, if I am reading this change correctly, this code will throw if your |
Any code that used to work was heavily relying on a bug in the library. The The documentation has also indicated the correct usage since it was created (probably around version 0.9 or v1.0). Cross-platform transactions already require tweaking, as there are various BigNumber libraries, ethers supports Uint8Arrays for many properties, and so on. Also, ethers works with Checksum addresses and verifies all address, some platforms require addresses to be in lowercase format (which ethers performs on the to address in JSON-RPC calls). It probably is not safe to be using most transactions across multiple libraries. Allowing two different keys that do the same thing can also lead to many issues, and more complex code logic, for example if both are specified; if they match, then it is ok to collapse them, if not then what? If you need to use a transaction across a Web3 and an Ethers system, you can use:
Allowing additional properties can also lead to bugs, typos are not caught and in general TypeScript would not work. With a functional language like JavaScript, there are far easier ways to include correlation ID's, by storing them in the dictionary above the transaction object. There are already quite a few differenced between ethers.js and Web3, many of which are because I am trying to escape legacy decisions made early in the eco-system. For the most part I've made attempts to provide migration easy, but some things are and will be difficult to reconcile. |
ethers.js/src.ts/utils/transaction.ts
Line 71 in 9b118af
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction
https://wiki.parity.io/JSONRPC-eth-module#eth_sendtransaction
https://wiki.parity.io/JSONRPC-eth-module#eth_signtransaction
Notice that both Geth and Parity documentation call the parameter
gas
, but Ethers calls itgasLimit
. This means if I construct a transaction such that Geth or Parity will accept it, I cannot use Ethers wallet to sign it. Inversely, if I construct a transaction such that Ethers can sign it, Geth/Parity will not accept it as valid (I believe, I haven't tested giving themgasLimit
instead ofgas
).I believe MetaMask also expects
gas
for signing, but I have not confirmed this.The text was updated successfully, but these errors were encountered: