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

eip712_encode_hash encode string bytes and string uint256 #424

Closed
moisses89 opened this issue Jan 5, 2023 · 0 comments · Fixed by #427
Closed

eip712_encode_hash encode string bytes and string uint256 #424

moisses89 opened this issue Jan 5, 2023 · 0 comments · Fixed by #427
Assignees
Labels
enhancement New feature or request

Comments

@moisses89
Copy link
Member

moisses89 commented Jan 5, 2023

What is needed?

String bytes feature

I would like that eip712_encode_hash encode string bytes also like the following example:
"Message": [ {"name": "oneByte", "type": "bytes1"} ] "message": {"oneByte": "0x01"}

Currently this is not possible because eip712_encode_hash is using eth_abi that expects python bytes.

String uint256 feature

I would like that eip712_encode_hash encode string uint also like the following example:
"Message": [ {"name": "stringNum", "type": "uint256"} ] "message": {"stringNum": "1234"}

Possible solution

Check in _encode_field(name, typ, value) if is bytes type the value is an instance of str and in that case convert to bytes bytes.fromhex(string).
Similar solution for uint but converting it from string to python int.

Related issues

@moisses89 moisses89 added the enhancement New feature or request label Jan 5, 2023
@moisses89 moisses89 changed the title eip712_encode_hash encode string bytes eip712_encode_hash encode string bytes and string uint256 Jan 5, 2023
@moisses89 moisses89 self-assigned this Jan 9, 2023
@moisses89 moisses89 changed the title eip712_encode_hash encode string bytes and string uint256 Add EIP712 support for bytes and uint formatted as string Jan 10, 2023
@moisses89 moisses89 changed the title Add EIP712 support for bytes and uint formatted as string eip712_encode_hash encode string bytes and string uint256 Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant