From 68b8f548fb78476f79f00b58003dfa7a4b03c13f Mon Sep 17 00:00:00 2001 From: Leon Hudak <33522493+leohhhn@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:20:30 +0200 Subject: [PATCH] docs(gnokey): add more info on `vm/qfile` (#2770) ## Description This PR adds more info for the `vm/qfile` query.
Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [x] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- .../cli/gnokey/querying-a-network.md | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/gno-tooling/cli/gnokey/querying-a-network.md b/docs/gno-tooling/cli/gnokey/querying-a-network.md index 97986237a21..1bb1bb8275f 100644 --- a/docs/gno-tooling/cli/gnokey/querying-a-network.md +++ b/docs/gno-tooling/cli/gnokey/querying-a-network.md @@ -23,7 +23,7 @@ Below is a list of queries a user can make with `gnokey`: - `auth/accounts/{ADDRESS}` - returns information about an account - `bank/balances/{ADDRESS}` - returns balances of an account - `vm/qfuncs` - returns the exported functions for a given pkgpath -- `vm/qfile` - returns the list of files for a given pkgpath +- `vm/qfile` - returns package contents for a given pkgpath - `vm/qeval` - evaluates an expression in read-only mode on and returns the results - `vm/qrender` - shorthand for evaluating `vm/qeval Render("")` for a given pkgpath @@ -124,14 +124,16 @@ data: [ ## `vm/qfile` -With the `vm/qfile` query, we can fetch files found on a specific package path. -To specify the path we want to query, we can use the `-data` flag: +With the `vm/qfile` query, we can fetch files and their content found on a +specific package path. To specify the path we want to query, we can use the +`-data` flag: ```bash gnokey query vm/qfile -data "gno.land/r/demo/wugnot" -remote https://rpc.gno.land:443 ``` -The output is a list of all files found within the `wugnot` realm: +If the `-data` field contains only the package path, the output is a list of all +files found within the `wugnot` realm: ```bash height: 0 @@ -140,6 +142,40 @@ wugnot.gno z0_filetest.gno ``` +If the `-data` field also specifies a file name after the path, the source code +of the file will be retrieved: + +```bash +gnokey query vm/qfile -data "gno.land/r/demo/wugnot/wugnot.gno" -remote https://rpc.gno.land:443 +``` + +Output: +```bash +height: 0 +data: package wugnot + +import ( + "std" + "strings" + + "gno.land/p/demo/grc/grc20" + "gno.land/p/demo/ufmt" + pusers "gno.land/p/demo/users" + "gno.land/r/demo/users" +) + +var ( + banker *grc20.Banker = grc20.NewBanker("wrapped GNOT", "wugnot", 0) + Token = banker.Token() +) + +const ( + ugnotMinDeposit uint64 = 1000 + wugnotMinDeposit uint64 = 1 +) +... +``` + ## `vm/qeval` `vm/qeval` allows us to evaluate a call to an exported function without using gas,