Wallet signer doesn't accept a BigNumber
for nonce.
#301
Labels
enhancement
New feature or improvement.
BigNumber
for nonce.
#301
The Ethereum protocol doesn't have a concept of small numbers vs big numbers, in its eyes everything is a big number, even if there is no reasonable expectation for a number to grow past 2^52. An example of this is the
nonce
, which is derived from https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactioncount which returns aQUANTITY
.While I think this is stupid, ethers currently is mostly consistent about accepting
BigNumber
for any numeric parameter. The one exception I have found is inTransactionRequest
when it asks for anonce
https://github.com/ethers-io/ethers.js/blob/master/src.ts/providers/abstract-provider.ts#L81.For consistency, I recommend making this accept a
BigNumber
.Alternatively, I could see value in doing a large scale refactoring of ethers that does ab etter job than the wire protocol at differentiating between different types, including small numbers, big numbers, addresses, hashes, byte arrays, etc. I have tackled this previously and it is a lot of work but I personally found it really paid off in making my code easier to maintain by giving me much more robust type checking (no longer accidentally passing an address to something that wanted a hash, or passing a hash to something that wanted a big number, or passing a big number to something that wanted a small number). This would be a very large undertaking, so for now I would be fine with the library simply being consistent and accepting
BigNumber
everywhere.The text was updated successfully, but these errors were encountered: