-
Notifications
You must be signed in to change notification settings - Fork 213
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
Ajust jsonToMetadata and jsonFromMetadata from cardano-api #2098
Milestone
Comments
I have a slight preference for a JSON representation which can perfectly map one-to-one with the on-chain metadata. It's not much more burden on API users. There are already several limitations on what metadata they can set. It's definitely not POJO. |
lgtm |
iohk-bors bot
added a commit
that referenced
this issue
Sep 21, 2020
2142: cardano-node: 1.19.1-patched -> 1.20.0 r=rvl a=rvl ### Issue Number ADP-307 / #2098 ### Overview Updates cardano-node to [1.20.0](https://github.com/input-output-hk/cardano-node/releases/tag/1.20.0) There are quite a few upstream API changes. Snapshot PR is input-output-hk/cardano-haskell#28. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
iohk-bors bot
added a commit
that referenced
this issue
Sep 21, 2020
2142: cardano-node: 1.19.1-patched -> 1.20.0 r=rvl a=rvl ### Issue Number ADP-307 / #2098 ### Overview Updates cardano-node to [1.20.0](https://github.com/input-output-hk/cardano-node/releases/tag/1.20.0) There are quite a few upstream API changes. Snapshot PR is input-output-hk/cardano-haskell#28. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
These functions are making several implicit conversion when dealing with JSON data which make them very unpractical to use.
Decision
a. Encode JSON as CBOR considering only the following "optimizations"
b. Hexadecimal sequences starting with 0x are encoded as CBOR bytestring.
c. JSON keys that are numbers are encoded as CBOR numbers.
d. CBOR is shown as JSON when possible, or as a string representing JSON-encoded data when not (i.e. when map keys aren't numbers or strings).
e. CBOR bytestrings are represented as hexadecimal strings prefixed with 0x
NOTE 1: Roundtripping would only work in one direction, when coming from a JSON value and that's totally fine.
NOTE 2: Complexe metadata using non-string keys in maps will render with funky keys in JSON, that's acceptable.
NOTE 3: Related Slack thread https://input-output-rnd.slack.com/archives/GR599HMFX/p1598966521093500
Acceptance Criteria
Development
QA
Metadata have been added to database property and state machine tests. Metadata are generated from JSON objects, as they would be in the API which guarantees that they roundtrip to JSON and from JSON back. Plus, any arbitrary metadata is guaranteed to be convertible to JSON by the type system. See generators here:
We use a patched version of cardano-node (patched on top of 1.19.1), which adds the fixed json conversions function. These functions are tested in cardano-api directly using a roundtrip property, and some golden tests to make sure we are in the end generating intended CBOR binary data:
The text was updated successfully, but these errors were encountered: