Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dyn-abi): enable DynSolType.coerce_json to convert array of numbers to bytes #541

Conversation

evchip
Copy link
Contributor

@evchip evchip commented Feb 27, 2024

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 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.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

…ce_json_simple()to handle case where input value is an array of numbers instead of a string
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DaniPopes DaniPopes merged commit 134236b into alloy-rs:main Feb 27, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants