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(keeper): implement json primitive return #2949

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

Conversation

gfanton
Copy link
Member

@gfanton gfanton commented Oct 14, 2024

Yet another JSON PR 🎉

This is a simpler implementation of the JSON keeper result that introduces JSON primitive results in keeper MsgCall and MsgQuery result. To maintain backward compatibility, it's not enabled by default, and you have to specify the format in the request.

The result will be returned in the form of a parsable JSON array.

Currently, it will resolve types as follows:

  • PrimitiveKind -> raw value
  • Error/Stringer -> execute and return result
  • Object -> <oid:type> as string
  • Other -> <type> as string

TODOs

  • Probably more tests
  • Need approval on how we represent object
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
Signed-off-by: gfanton <[email protected]>
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 14, 2024
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.89%. Comparing base (5503cca) to head (aca85fb).
Report is 42 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2949      +/-   ##
==========================================
+ Coverage   60.83%   60.89%   +0.06%     
==========================================
  Files         563      563              
  Lines       75193    75211      +18     
==========================================
+ Hits        45743    45803      +60     
+ Misses      26076    26046      -30     
+ Partials     3374     3362      -12     
Flag Coverage Δ
contribs/gnofaucet 15.31% <ø> (+0.85%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 20.23% <ø> (ø)
tm2 62.06% <100.00%> (+0.17%) ⬆️

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.

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall approach LGTM, let's roll with only supporting primitive types for now


rtvs := m.Eval(xn)
stringifyResultValues(m, msg.Format, rtvs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused


const (
FormatMachine = "machine" // Default machine representation
FormatJSON = "json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's add a comment like // XXX: EXPERIMENTAL, only supports primitive types for now

gnovm/pkg/gnolang/values.go Show resolved Hide resolved
tm2/pkg/bft/abci/types/types.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants