ethers.js
ethers.js copied to clipboard
authorizationList structure compatibility with eth_estimateGas
Describe the Feature
Make it easier to pass authorizationList directly to RPC call without additional preparation.
Code Example
Heres example how authorization object look like after wallet.authorize().
{
address: '0x186dDEA073ebceCBF845D5AEabB742902316C777',
nonce: 6n,
chainId: 11155111n,
yParity: 1,
r: '0x686dba08151c21c076967366fadfda3a281c56b0adf8a310e4a367bd75583e97',
s: '0x48bf566e32cd6ff375e8667f893eb1676cfe52d94633064bb8c55751e17a8063'
}
This object can't be passed directly as authorizationList to call provider.send('eth_estimateGas') leading to an serialisation error:
TypeError: Do not know how to serialize a BigInt
Maybe theres a solutions to serialize it automatically on ethers side. Just an idea.
e.g.
const modifiedAuthorization = {
address: authorization.address,
nonce: toQuantity(authorization.nonce),
chainId: toQuantity(authorization.chainId),
r: authorization.signature.r,
s: authorization.signature.s,
yParity: toQuantity(authorization.signature.yParity),
};
There is a method on the JsonRpcProvider class, `getRpcTransaction' which will normalize all the values to be JSON-RPC compatible and take care of a lot of other idiosyncrasies for you. :)