๐ `InvalidArgumentsError` With `signTypedData`
charlie-kim opened this issue ยท 6 comments
Describe the issue:
I have a hardhat test with signTypedData
that starts to fail when I install xdeployer.
Code example to reproduce the issue:
import { ethers } from "hardhat";
const [signer] = await ethers.getSigners();
const domain = {
name: 'Collateral',
version: '2',
chainId: 31337, // hardhat
verifyingContract: '0xb0279Db6a2F1E01fbC8483FCCef0Be2bC6299cC3',
salt: new Uint8Array([
189, 181, 85, 137, 189, 110, 138, 202,
85, 30, 222, 158, 181, 116, 29, 49,
117, 28, 64, 185, 106, 101, 110, 218,
99, 63, 69, 230, 136, 254, 92, 224
])
};
const type = {
UpdateAdminThreshold: [
{ name: 'threshold', type: 'uint8' },
{ name: 'nonce', type: 'uint256' }
]
} ;
const data = { threshold: 1, nonce: 0n };
await signer.signTypedData(domain, type, data);
Version:
3.0.4.
Here are the rest
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"ethers": "^6.8.1",
"hardhat": "^2.19.1",
"typescript": "^5.2.2",
"xdeployer": "^3.0.4"
Relevant log output:
InvalidArgumentsError: The message parameter is an invalid JSON. at line 1 column 776
at EdrProviderWrapper.request (/Users/charlie/Code/rain-contract-v2/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:423:10)
response.error looks like this.
{
code: -32602,
message: 'The message parameter is an invalid JSON. at line 1 column 776',
data: {
method: 'eth_signTypedData_v4',
params: [
'0x976ea74026e726554db657fa54763abd0c3a0aa9',
'{"types":{"UpdateAdminThreshold":[{"name":"threshold","type":"uint8"},{"name":"nonce","type":"uint256"}],"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"},{"name":"salt","type":"bytes32"}]},"domain":{"name":"Collateral","version":"2","chainId":"0x7a69","verifyingContract":"0xb0279db6a2f1e01fbc8483fccef0be2bc6299cc3","salt":"0x54c6b2b3ad37d2ee0bf85cf73d4c147b0a1c333627a2cbf9a1bb9ecc1543fc7a"},"primaryType":"UpdateAdminThreshold","message":{"threshold":"1","nonce":"0"}}'
]
}
}
Hmm, I have never seen such an issue. It's very hard to reproduce whether it's related to xdeployer
. Can you push a repository with the code that is failing for me to reproduce it (including package.json
and the lock file)?
Also, can you ensure your dependencies are on the latest version:
npm update
Oh I think I know what's the issue: Hardhat introduced a new development runtime "Ethereum Development Runtime" (EDR) in version v2.21.0
, and that wrapper raises:
EdrProviderWrapper.request (/Users/charlie/Code/rain-contract-v2/node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:423:10)
Since I pin to the latest Hardhat version on the latest xdeployer
version, when you install xdeployer
it also updates Hardhat. Can you please open an issue here, and link to this issue.
Cc: @fvictorio
One temporary solution is that you downgrade xdeployer
to version 3.0.1
which doesn't use a Hardhat version that supports EDR.
@pcaversaccio yes, that was it. Using xdeployer 3.0.1
and hardhat 2.19.5
solved the issue. I guess the EDR new version has a bug.
I created an issue in hardhat repo: NomicFoundation/edr#346
@pcaversaccio yes, that was it. Using
xdeployer 3.0.1
andhardhat 2.19.5
solved the issue. I guess the EDR new version has a bug.I created an issue in hardhat repo: NomicFoundation/edr#346
Great! I will close this issue accordingly.