erc7730.lint.v2.lint_validate_eip712_keys module
V2 linter that validates EIP-712 display format keys are syntactically valid encodeType strings.
In v2, EIP-712 descriptors do not embed the message schema anymore: the display.formats keys are the schema.
Per the ERC-7730 specification, an EIP-712 format key MUST be the string returned by the encodeType function
defined in EIP-712, applied to the primary type of the message, so that the type hash computed by the wallet from
the message matches the one computed from the descriptor key:
keccak256(encodeType(typeOf(s))) == keccak256(TYPE_KEY)
Any deviation (stray whitespace, missing dependent type, wrong ordering, …) yields a different hash, meaning the descriptor would silently never apply. As the descriptor holds neither the domain nor the struct definitions, keys can only be checked syntactically – which is exactly what this linter does, purely locally.
Grammar validated here, from the EIP-712 specification (https://eips.ethereum.org/EIPS/eip-712):
encodeType := structDef+
structDef := identifier "(" [ member ("," member)* ] ")"
member := type " " identifier
type := (atomicType | dynamicType | identifier) ("[" [ number ] "]")*
with the referenced struct types collected, sorted by name, and appended to the primary type encoding.
- final class erc7730.lint.v2.lint_validate_eip712_keys.ValidateEIP712KeysLinter[source]View on GitHub
Bases:
ERC7730LinterValidates that EIP-712 display format keys are syntactically valid EIP-712
encodeTypestrings.Only applies to EIP-712 contexts: for contract contexts, format keys are function signatures or selectors.
- lint(input_descriptor: InputERC7730Descriptor, descriptor: ResolvedERC7730Descriptor, out: OutputAdder) None[source]View on GitHub
- erc7730.lint.v2.lint_validate_eip712_keys.validate_eip712_key(key: str, out: OutputAdder) None[source]View on GitHub
Validate an EIP-712 display format key is a syntactically valid
encodeTypestring.Emits an error for each of: * a key that does not match the
encodeTypegrammar (stray whitespace, unbalanced parenthesis, …), * a struct or member name defined twice, * a member type that is neither a valid EIP-712 atomic type nor a struct defined in the key, * a struct defined in the key but never referenced, * dependent struct types not sorted by name.- Parameters:
key – the
display.formatskey to validateout – output adder