In the course of implementing dynamic EIP-712 typed data signing on the alloy repo, I encountered an issue (see this comment) where bytes are being encoded as an array of numbers by TypedData::from_struct, causing an error when eip712_signing_hash() is called on the returned value: TypeMismatch { expected: "bytes", actual: "[102,105,122,122]" } .
@prestwich suggested the code (see comment) that is contained in this PR in order to resolve the issue.
Solution
add logic to the bytes() function used in DynSolType.coerce_json_simple() to handle case where the input value is an array of numbers instead of a string.
Motivation
In the course of implementing dynamic EIP-712 typed data signing on the alloy repo, I encountered an issue (see this comment) where
bytes
are being encoded as an array of numbers byTypedData::from_struct
, causing an error wheneip712_signing_hash()
is called on the returned value:TypeMismatch { expected: "bytes", actual: "[102,105,122,122]" }
.@prestwich suggested the code (see comment) that is contained in this PR in order to resolve the issue.
Solution
add logic to the
bytes()
function used inDynSolType.coerce_json_simple()
to handle case where theinput
value is an array of numbers instead of a string.PR Checklist