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

feat(gnokey): add querying realm balances #2470

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

leohhhn
Copy link
Contributor

@leohhhn leohhhn commented Jun 30, 2024

Description

Closes: #2469

This PR adds code to the handler in gnokey that extends the bank/balances functionality to allow users to fetch the balance of a realm given its pkgpath, ie bank/balances/gno.land/r/demo/wugnot.

Initially I wanted to implement this functionality in the handler for tm2/sdk/bank, but in order to not introduce more tm2<>gno dependencies, I did it in the gnokey query handler. Then, I realized that that handler is also under tm2, in tm2/pkg/crypto/keys/client/query.go :/

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.

@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Jun 30, 2024
Copy link

codecov bot commented Jun 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.01%. Comparing base (95115c0) to head (1b17797).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2470      +/-   ##
==========================================
- Coverage   55.02%   55.01%   -0.01%     
==========================================
  Files         595      595              
  Lines       79662    79661       -1     
==========================================
- Hits        43832    43826       -6     
- Misses      32514    32517       +3     
- Partials     3316     3318       +2     
Flag Coverage Δ
contribs/gnodev 25.65% <ø> (-0.35%) ⬇️
contribs/gnofaucet 14.46% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 64.24% <ø> (ø)

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.

@leohhhn leohhhn marked this pull request as ready for review June 30, 2024 21:25
@leohhhn leohhhn requested review from jaekwon and a team as code owners June 30, 2024 21:25
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

good idea, but it should be implemented from sdk/vm.Handlers, not from keys/client.

@leohhhn
Copy link
Contributor Author

leohhhn commented Jul 2, 2024

@moul

The issue is the following; you can find only the VM queries in gno.land/pkg/sdk/vm:

QueryPackage = "package"
QueryStore   = "store"
QueryRender  = "qrender"
QueryFuncs   = "qfuncs"
QueryEval    = "qeval"
QueryFile    = "qfile"

On the other hand, bank/balances is querying the banker which lives separately, in tm2/sdk/bank.

I did this change in keys/client instead of in tm2/sdk/bank because I thought we wanted to keep tm2 & the banker agnostic to the VM they're communicating with. Let me know if I'm wrong on this.

With my implementation, gnokey would do the argument parsing locally and and the query would not change on the side of the chain.

@moul
Copy link
Member

moul commented Jul 4, 2024

The issue is the following; you can find only the VM queries in gno.land/pkg/sdk/vm:

Yes, that's exactly where I recommend implementing it: directly from this package, instead of from keys/client.

i := strings.Index(path, balancesQuery)
pkgPath := path[i+len(balancesQuery):]

pkgAddr := gnolang.DerivePkgAddr(pkgPath)
Copy link
Member

Choose a reason for hiding this comment

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

tm2 should not import gnovm/ or gno.land/.

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
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

[gnokey] Query balance of a realm
2 participants