Validate types in `encode_structured_data()`
fselmo opened this issue · comments
What was wrong?
We currently don't seem to validate types when using encode_structured_data
(i.e. bytes32
, uint8
, uint256
sizes).
Relevant issues that sparked the creation of this issue: #90, #91
How can it be fixed?
- Investigate if this validation exists and if it is needed anywhere else in the code base.
Closing edit: Indeed it does exist, just not in the "validation" part of things. Validation seems to validate that the fields of the body are valid fields but value
validation happens during the actual hashing.
This was unlikely to begin with... it turns out we validate the values when hashing, not during the "validation" steps. Those seem stick to validating that supported types, as strings, are provided in the fields. However, errors stemming from passing in the wrong values for those types could be improved. The messaging seems to be good for when the base types between the provided type
differs from the actual value
but not when the base type is the same but exceeds the provided size.
e.g. If the type is uint8
and the value is 256
... the error will print out that we expected uint8
but got type int
. In reality, the value being an int
is fine, it just exceeds the size allowed for encoding a uint8
type.
This is a bit minor but would improve the user experience. However, it can be addressed in a separate issue. Closing this since we do validate fields appropriately.