-
Notifications
You must be signed in to change notification settings - Fork 409
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
Amino JSON representation of inner message in Msg{Instantiate,Migrate,Execute}Contract #642
Comments
I agree with this. Just a custom JSON encoder, right? I think allowing non-valid json and encoding as base64 is a nice touch. So if someone did want to use eg. protobuf messages, nothing in wasmd stops them. But we optimize UX when they are JSON |
Yes, we only need this for signature verification, i.e. protobuf encoding -> Go struct -> JSON -> sign bytes conversion.
I don't think we should allow this without adapting a whole lot of tooling. The readability of the signdoc is an important feature of Cosmos and we'd provide a way around it. It would require us to write extra code (if JSON validation fails fall back to base64). Not much, but still. This brings the risk that someone is tricks Go into considering something invalid JSON just to hide the content from the users. |
Fair enough |
@alpe I think this is the most important/breaking item between 0.20 and 1.0-beta |
I have looked into the issue and the changes in #520 were causing the issues. Nice find @webmaster128 One option is to revert to the I also looked a bit deeper at queries and contract responses and we have a mix of raw bytes and json.RawMessage now. A custom type with marshaler seems to be the cleanest and most extendable solution. I have implemented it in #658 to show the changes. |
The problem is that the type annotations are casts. At the protobuf level no JSON type exists and all bytes are perfectly valid. Now with the If we had a validating bytes ->
This still gives you instances of
Right, this is what we need. Raw bytes intended to hold JSON data but not guaranteed to be valid JSON. |
With the change in #520 we most likely changed the JSON representation of the
msg
field inMsgInstantiateContract
,MsgMigrateContract
andMsgExecuteContract
by accident. It is now a base64 encoded string of the JSON. The problem with this is that Ledger users cannot read the content of the smart contract interaction anymore. The same applies for other generic Amino JSON signers that do not have a dedicated UI for those message types.While most of the #520 makes sense, this diff in the autogenerated
x/wasm/types/tx.pb.go
is problematic:As you can see in https://play.golang.org/p/ois4zkjeRbr, the type defines the JSON serialization.
Seems like we should have a custom seralizer for those types that
[]byte
type for the inner messages because we have no clue what is in thereThe text was updated successfully, but these errors were encountered: