Add generators for which types are "entry points"
danfinlay opened this issue · comments
The EIP-712 signTypedData method requires a special form of type when a user is interacting with it. While this codegen generates MOST OF the code involved in complicated relationships of structs, it does not handle the entrypoint signature recovery. We should generate that too.
Sample code for recovering a delegation:
function verifyDelegationSignature (SignedDelegation memory signedDelegation) public view returns (address) {
Delegation memory delegation = signedDelegation.delegation;
bytes32 sigHash = getDelegationTypedDataHash(delegation);
address recoveredSignatureSigner = recover(sigHash, signedDelegation.signature);
return recoveredSignatureSigner;
}
function getDelegationTypedDataHash(Delegation memory delegation) public view returns (bytes32) {
bytes32 digest = keccak256(abi.encodePacked(
"\x19\x01",
domainHash,
GET_DELEGATION_PACKETHASH(delegation)
));
return digest;
}