I am using "ethers": "^5.6.2" and this is running through a browser. I am also using "eth-permit": "^0.2.1". As to the documentation for eth-permit, I can send a Wallet object as the provider for signDaiPermit(provider, token|Domain, holderAddress, spenderAddress).
Looking in the code for eth-permit, if the Wallet has signTypedData or _signTypedData as a function (which should be provided by ethers according to their documentation) then it will use that function. When I look at the Wallet in the browser inspector I don't see either of those functions.
I am specifically looking to not connect to an ethereum network to sign this data with ethers. This is how I am setting up Wallet:
let domain = {
"name": "Dai Stablecoin",
"version": "1",
"chainId": 1,
"verifyingContract": daiAddress
}
let mainWallet = new ethers.Wallet("0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e", ethers.getDefaultProvider());
let result = await signDaiPermit(mainWallet, domain, myAddress, crowdSaleAddress);
The private key is one of the default keys for the hardhat test environment.
I would assume that this would set up the Wallet as a signer but, as I said before, no signTypedData as a function.
Can anyone tell me what I am doing wrong or what I need to create a Wallet that has signTypedData as a function?
As you can see I am attempting to create data for a "permit" in DAI. I running hardhat as a fork from mainnet and I am using the mainnet deploy of DAI. If I attempt to generate the signature from Metamask while testing it is using chainId 31337 and the DOMAIN_SEPARATOR for the mainnet deploy contract needs chainId to be 1. Metamask will refuse to sign this. I am trying to generate a signature with chainId=1 using ethers only but the transaction will be sent to the hardhat test network on its chainId.