Has anyone used the latest signTypedData https://docs.ethers.org/v6/api/providers/#Signer-signTypedData
Not sure if it's a bug, but this is the method:
async signTypedData(domain: TypedDataDomain, types: Record>, _value: Record): Promise {
const value = deepCopy(_value);
// Populate any ENS names (in-place)
const populated = await TypedDataEncoder.resolveNames(domain, types, value, async (value: string) => {
const address = await resolveAddress(value);
assertArgument(address != null, "TypedData does not support null address", "value", value);
return address;
});
return await this.provider.send("eth_signTypedData_v4", [
this.address.toLowerCase(),
JSON.stringify(TypedDataEncoder.getPayload(populated.domain, types, populated.value))
]);
}
The stringify method is failing because TypedDataDomain has chainId property which is defined as BigNumberish and stringify is not able to serialize it: TypeError: Do not know how to serialize a BigInt
const value = deepCopy(_value);
// Populate any ENS names (in-place)
const populated = await TypedDataEncoder.resolveNames(domain, types, value, async (value: string) => {
const address = await resolveAddress(value);
assertArgument(address != null, "TypedData does not support null address", "value", value);
return address;
});
return await this.provider.send("eth_signTypedData_v4", [
this.address.toLowerCase(),
JSON.stringify(TypedDataEncoder.getPayload(populated.domain, types, populated.value))
]);
}
The stringify method is failing because TypedDataDomain has chainId property which is defined as BigNumberish and stringify is not able to serialize it: TypeError: Do not know how to serialize a BigInt
Mar 9, 2023, 1:22 PM