-
Notifications
You must be signed in to change notification settings - Fork 720
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
Serialize AssetName to JSON as hex string #3211
Conversation
Just as a note: It should also be than |
5509371
to
c3f1ed3
Compare
Removed textual AssetName everywhere, hex only |
c3f1ed3
to
52081dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, a few comments
@cblp any updates here from your side? would be nice to see this in 1.31.0 😄 |
caf2e3f
to
a8660e2
Compare
how does the output of "Friendly output multi-asset with ASCII version where possible" look like? i would leave it up to the software behind the CLI to decide to show it as readable or as hex/binary. makes it more complicated to post-process if the output is not hex all the time. |
Here is an example: mint:
policy 52dc3d43b6d2465e96109ce75ab61abe5e9c1d8a3c9ce6ff8a3af528:
asset 736b79 (sky): 142
API version of cardano-cli is to be built in #3213 |
ah, so the normal |
@gitmachtl |
thats perfect, so hex output in the normal |
@dcoutts should I fix docs (couttscoins etc.) in this PR? |
ping 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments
ttoken = proxyToAsType (Proxy :: Proxy a) | ||
tname = (tyConName . typeRepTyCon . typeRep) (Proxy :: Proxy a) | ||
|
||
instance SerialiseAsRawBytes a => ToJSONKey (UsingRawBytesHex a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you make this explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default ToJSONKey implementation is the Value-based encoding; we need the Text-based here.
Aeson.FromJSONKeyTextParser $ | ||
either fail pure . deserialiseFromRawBytesBase16 . Text.encodeUtf8 | ||
|
||
deserialiseFromRawBytesBase16 :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have two implementations of essentially the same thing deserialiseFromRawBytesHex
and deserialiseFromRawBytesBase16
. Not to mention we Base16 decode the input ByteString
twice in order to get an error message in deserialiseFromRawBytesBase16
. The proper solution here is to update deserialiseFromRawBytesHex
to return an Either
. This refactor would be better as a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many places expect Maybe from deserialiseFromRawBytesHex. Should it be a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, please raise a follow up PR to correct this. Leave a TODO in the code explaining this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is #3304
5576208
to
d24e226
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Cool! 👍 |
Looking forward to see this PR within the next release. |
@JaredCorduan @newhoggy maybe someone of you is having the time to review it also? |
can we expect to see this in the next cardano-cli release? |
@nc6 do we have a chance to get this into the 1.31.0 release? |
…sible As desktop client does
bors merge |
Build succeeded: |
wohoo! :-) |
Fix (second attempt) of incorrect UTF-8 decoding of non-textual (non-UTF-8) asset names.
I also changed tx-view to test JSON repr.
BEFORE:
AFTER:
This is how it already looks like in UI (Cardano Explorer):
Future Daedalus: