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

wip: implement (Un)MarshalJSON(Amino) TypedValue #2652

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

gfanton
Copy link
Member

@gfanton gfanton commented Aug 1, 2024

Work in Progress

This pull request aims to implement JSON marshaling on TypedValue. It includes:

  • A lower-level encoding API for writing/reading JSON. The code is mostly taken from protojson, which provides a generic enough API, is well-tested, and does not rely on reflection or other libraries. I have made slight updates to the code to avoid unnecessary randomness or depends on protobufs.
    • If needed, we can update this part later with a more optimised encoder for Gno or adapt this one to use reader/writer instead of raw []byte data, for example.
  • (Un)MarshalJSON(Amino) methods on TypedValue
  • (Un)MarshalOptions that allow passing additional options like Store and Allocator (optional)

Current State:

  • Support scalar types (bool, number, string)
  • Support Array
  • Support object (struct)
  • Partially support Interface
  • Handle circular reference with objectid

Note: Don't be scared by the number of lines added. The most important parts of the code are located in value_json.go and value_json_test.go, as encoding/json/* is mostly taken from protojson.

TODO:

  • RefValue support
  • Fully support Amino format
  • More tests
  • Documentation & Comments
  • ... (Possibly other tasks, I will add them later as I discover them)
Contributors' checklist...
  • Added new tests, if necessary or feasible
  • Provided an example (e.g. screenshot) to assist in the review or ensured the PR is self-explanatory
  • Updated the official documentation, if required
  • No breaking changes were introduced, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided useful hints for running manual tests
  • Added new benchmarks to generated graphs, if applicable. More information here.

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
@gfanton gfanton changed the title wip: implment (Un)MarshalJSON(Amino) TypedValue wip: implement (Un)MarshalJSON(Amino) TypedValue Aug 1, 2024
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Aug 1, 2024
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.11%. Comparing base (e844fc1) to head (5921ac2).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2652      +/-   ##
==========================================
- Coverage   60.12%   60.11%   -0.01%     
==========================================
  Files         560      560              
  Lines       74690    74690              
==========================================
- Hits        44905    44900       -5     
+ Misses      26397    26396       -1     
- Partials     3388     3394       +6     
Flag Coverage Δ
contribs/gnodev 61.40% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (-0.86%) ⬇️
gno.land 64.15% <ø> (ø)
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (ø)
tm2 62.03% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

1 participant