We are using OpenZeppelin's ERC20 and especiall ERC20Votes.
There, we are trying to use the delegateBySig function. Unfortunately, we are seeing some mismatch between the front-end signature and the ERC20 contract.
Using the following elements:
const domain = {
"name": "Unlock Discount Token",
"version": "1",
"chainId": 1,
"verifyingContract": "0x90DE74265a416e1393A450752175AED98fe11517"
}
const types = {
'Delegation': [
{ name: 'delegatee', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'expiry', type: 'uint256' },
]
}
const message = {
"delegatee": "0x9dED35Aef86F3c826Ff8fe9240f9e7a9Fb2094e5",
"nonce": 0,
"expiry": ethers.BigNumber.from("1634160375")
}
We prompted a user to sign and they signature we got is this one:
const v = 28;
const r = "0x2d89602ddbb9baaf2f8cf7d839880ff3df556ebc1730adcc0cb7882a82b003f4";
const s = "0x5c20eda96bdada01f35af58d682bfec930c0f44628560be92cd770938efcf3e7";
When using ethers verifyTypedData
we get the address of the signer (0x245DC69FD58dd92C0B3298b71fA58CC299E79042
)
ethers.utils.verifyTypedData( domain , types , message , {v,r,s} )
However, when the transaction is submitted, for a reason that we do not understand the contract recovers a completely different one: 0xc9f0970a72dc8a5832b48d2a0fb9c75043cdb474
.
You can see the transaction there: https://etherscan.io/tx/0x6dc37b39c9ef967b85d25d47d3c2e21926f831e85e647ea2df91a60bf7fff99d#eventlog (check the logs for the DelegateChanged
event).
Any help would be greatly appreciated.