ethermint icon indicating copy to clipboard operation
ethermint copied to clipboard

Add command to generate eip712 type data for msg

Open yihuang opened this issue 3 years ago • 4 comments

Description

This PR implements an command eip-712 data-type to output the EIP-712 type schema for any message. The client library may use this instead of hard code the json.

$ ethermintd eip-712 data-type "/cosmos.bank.v1beta1.MsgSend"

For contributor use:

  • [ ] Targeted PR against correct branch (see CONTRIBUTING.md)
  • [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • [ ] Code follows the module structure standards.
  • [ ] Wrote unit and integration tests
  • [ ] Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • [ ] Added relevant godoc comments.
  • [ ] Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • [ ] Re-reviewed Files changed in the Github PR explorer

For admin use:

  • [ ] Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • [ ] Reviewers assigned
  • [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

yihuang avatar Aug 24 '22 04:08 yihuang

There's one issue that the result of ./build/ethermintd gen-eip712-data-type "/cosmos.bank.v1beta1.MsgSend" | jq don't contain the amount field in the bank send msg, maybe because it's a sdk.Coins rather than sdk.Coin.

yihuang avatar Aug 24 '22 09:08 yihuang

There's one issue that the result of ./build/ethermintd gen-eip712-data-type "/cosmos.bank.v1beta1.MsgSend" | jq don't contain the amount field in the bank send msg, maybe because it's a sdk.Coins rather than sdk.Coin.

this one is fixed.

yihuang avatar Aug 26 '22 08:08 yihuang

@yihuang can you add a PR description about what users can do with this?

done. sorry I didn't follow up closely on this PR, because we didn't start to use eip-712 yet, and frankly I'm not very familiar with all the details about eip-712 yet, feel free to take over if it interests you.

yihuang avatar Sep 15 '22 14:09 yihuang

@yihuang can you add a PR description about what users can do with this?

done. sorry I didn't follow up closely on this PR, because we didn't start to use eip-712 yet, and frankly I'm not very familiar with all the details about eip-712 yet, feel free to take over if it interests you.

@yihuang If you're not planning to finish the PR, I'm converting this into draft. I don't a specific need for this at the moment. @hanchon @ramacarlucho Are you interested in this functionality?

danburck avatar Sep 29 '22 20:09 danburck

Right now when I'm adding a new message to evmosjs I need to debug the Ethermint code, having this cmd function will simplify the eip712 generation

hanchon avatar Oct 27 '22 11:10 hanchon

╰─❯ ./build/ethermintd eip-712 data-type "/cosmos.gov.v1beta1.MsgSubmitProposal"
Error: fail to extract msg types: panicked with error: runtime error: invalid memory address or nil pointer dereference
Usage:
  ethermintd eip-712 data-type <msg-url> [flags]

I'm getting nil pointer on MsgSubmitProposal

For MsgVote is working fine:

{"Coin":[{"name":"denom","type":"string"},{"name":"amount","type":"string"}],"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"string"},{"name":"salt","type":"string"}],"Fee":[{"name":"amount","type":"Coin[]"},{"name":"gas","type":"string"}],"Msg":[{"name":"type","type":"string"},{"name":"value","type":"MsgValue"}],"MsgValue":[{"name":"proposal_id","type":"uint64"},{"name":"voter","type":"string"},{"name":"option","type":"int32"}],"Tx":[{"name":"account_number","type":"string"},{"name":"chain_id","type":"string"},{"name":"fee","type":"Fee"},{"name":"memo","type":"string"},{"name":"msgs","type":"Msg[]"},{"name":"sequence","type":"string"}]}

This is probably related to the issue that @ramacarlucho was talking about, with the messages containing proto.Any I don't know if having the cosmos sdk 0.46 will solve this problem or if it's not related

hanchon avatar Oct 27 '22 11:10 hanchon

closing this

fedekunze avatar Dec 06 '22 22:12 fedekunze