Code to reproduce
I'm creating a signature with _signTypedData
my node js code:
const { ethers } = require("ethers");
exports.cashmereBridge = async (contract,signer,provider) => {
const currentDate = new Date()
console.log(currentDate.toLocaleString())
const gasPrice = await provider.getGasPrice()
const gasLimit = ethers.BigNumber.from(4000000)
const srcToken = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
const srcAmount = ethers.utils.parseEther('0.1')
const lwsPoolId = 1
const hgsPoolId = 1
const dstToken = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
const dstChain = 10160
const dstAggregatorAddress = '0x9b9f55494cf915c728dc65ee113c7309ee16ca18'
const minHgsAmount = '76026680535845117664'
const domainSeparator = {
name: "Parameters",
version: "1",
chainId: "59140",
verifyingContract: "0x76303b0C86Ec887867e22E44a681bDbCaE85Ccdf",
}
const types = {
Parameters: [
{ name: "receiver", type: "address" },
{ name: "lwsPoolId", type: "uint16" },
{ name: "hgsPoolId", type: "uint16" },
{ name: "dstToken", type: "address" },
{ name: "minHgsAmount", type: "uint256" },
],
}
const message = {
receiver: signer.address,
lwsPoolId: lwsPoolId,
hgsPoolId: hgsPoolId,
dstToken: dstToken,
minHgsAmount: minHgsAmount,
}
const signature = await signer._signTypedData(domainSeparator, types, message);
const params = [
srcToken,
srcAmount,
lwsPoolId,
hgsPoolId,
dstToken,
dstChain,
dstAggregatorAddress,
minHgsAmount,
signature
]
console.log(params)
const overrides = {
gasPrice: gasPrice,
gasLimit: gasLimit,
from: signer.address,
value: ethers.utils.parseEther('0.13'),
}
try {
const tx = await contract.startSwap(
params,
overrides,
)
const receipt = await tx.wait()
console.log(signer.address,'cashmere transaction confirmed:',receipt.transactionHash)
} catch (error) {
console.log(signer.address,'error sending cashmere transaction:',error)
}
}
however, getting into this contract (0xFe1D2647be6e9542e96528EBb3B44E5bE035c85C), it is rejected
require(
_hashTypedDataV4(
keccak256(
abi.encode(
keccak256(
"Parameters(address receiver,uint16 lwsPoolId,uint16 hgsPoolId,address dstToken,uint256 minHgsAmount)"
),
msg.sender,
params.lwsPoolId,
params.hgsPoolId,
params.dstToken,
params.minHgsAmount
)
),
block.chainid,
address(this)
).recover(params.signature) == msg.sender,
"!signature"
);
I will be glad of any help
Environment
node js