eip712-codegen
eip712-codegen copied to clipboard
Encode `name` and `version` in EIP712Domain packet hash
In the generated GET_EIP712DOMAIN_PACKETHASH function, name and version of EIP712Domain struct are of dynamic type (string), should they be encoded as the hash of their contents ?
function GET_EIP712DOMAIN_PACKETHASH (EIP712Domain memory _input) public pure returns (bytes32) {
bytes memory encoded = abi.encode(
EIP712DOMAIN_TYPEHASH,
_input.name,
_input.version,
_input.chainId,
_input.verifyingContract
);
return keccak256(encoded);
}
Expected:
function GET_EIP712DOMAIN_PACKETHASH (EIP712Domain memory _input) public pure returns (bytes32) {
bytes memory encoded = abi.encode(
EIP712DOMAIN_TYPEHASH,
keccak256(bytes(_input.name)),
keccak256(byes(_input.version)),
_input.chainId,
_input.verifyingContract
);
return keccak256(encoded);
}
Oh wow, that's an interesting catch! I'm actually very surprised that all the tests passed considering this variance. I'm going to need to do some extra investigation here. Thanks for reporting.
Oh, it was just a commented suggested code. So we had generated some bad docs but not bad code. Relieving. I'm hoping to add a proper entry-point generator also on a per-type basis, and I'll make sure that works properly.