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(keeper)!: use <pkgpath>.<expr> syntax for qeval; <pkgpath>:<path> for qrender #2382

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/gno-tooling/cli/gnokey.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ gnokey query {QUERY_PATH}
| `bank/balances/{ADDRESS}` | Returns balances of an account. | `gnokey query bank/balances/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5` |
| `vm/qfuncs` | Returns public facing function signatures as JSON. | `gnokey query vm/qfuncs --data "gno.land/r/demo/boards"` |
| `vm/qfile` | Returns the file bytes, or list of files if directory. | `gnokey query vm/qfile --data "gno.land/r/demo/boards"` |
| `vm/qrender` | Calls .Render(path) in readonly mode. | `gnokey query vm/qrender --data "gno.land/r/demo/boards"` |
| `vm/qeval` | Evaluates any expression in readonly mode and returns the results. | `gnokey query vm/qeval --data "gno.land/r/demo/boards GetBoardIDFromName("my_board")"` |
| `vm/qrender` | Calls .Render(path) in readonly mode. | `gnokey query vm/qrender --data "gno.land/r/demo/boards:"` |
| `vm/qeval` | Evaluates any expression in readonly mode and returns the results. | `gnokey query vm/qeval --data "gno.land/r/demo/boards.GetBoardIDFromName("my_board")"` |
| `vm/store` | (not yet supported) Fetches items from the store. | - |
| `vm/package` | (not yet supported) Fetches a package's files. | - |

Expand Down Expand Up @@ -205,16 +205,16 @@ gnokey maketx call \
> unsigned.tx
```

:::warning `call` is a state-changing message
:::warning `call` is a state-changing message

All exported functions, including `Render()`, can be called in two main ways:
`call` and [`query vm/qeval`](#query).

With `call`, any state change that happened in the function being called will be
applied and persisted in on the blockchain, and the gas used for this call will
be subtracted from the caller balance.
be subtracted from the caller balance.

As opposed to this, an ABCI query, such as `vm/qeval` will not persist state
As opposed to this, an ABCI query, such as `vm/qeval` will not persist state
changes and does not cost gas, only evaluating the expression in read-only mode.

:::
Expand Down
11 changes: 4 additions & 7 deletions examples/gno.land/r/demo/boards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ your `ACCOUNT_ADDR` and `KEYNAME`

Instead of editing `gno.land/genesis/genesis_balances.txt`, a more general solution (with more steps)
is to run a local "faucet" and use the web browser to add $GNOT. (This can be done at any time.)
See this page: https://github.com/gnolang/gno/blob/master/gno.land/cmd/gnofaucet/README.md
See this page: https://github.com/gnolang/gno/blob/master/gno.land/cmd/gnofaucet/README.md

### Start the `gnoland` node.

Expand Down Expand Up @@ -97,8 +97,7 @@ Interactive documentation: https://test3.gno.land/r/demo/boards?help&__func=Crea
Next, query for the permanent board ID by querying (you need this to create a new post):

```bash
./build/gnokey query "vm/qeval" -data "gno.land/r/demo/boards
GetBoardIDFromName(\"BOARDNAME\")" -remote localhost:26657
./build/gnokey query "vm/qeval" -data "gno.land/r/demo/boards.GetBoardIDFromName(\"BOARDNAME\")" -remote localhost:26657
thehowl marked this conversation as resolved.
Show resolved Hide resolved
```

### Create a post of a board with a smart contract call.
Expand All @@ -120,8 +119,7 @@ Interactive documentation: https://test3.gno.land/r/demo/boards?help&__func=Crea
Interactive documentation: https://test3.gno.land/r/demo/boards?help&__func=CreateReply

```bash
./build/gnokey query "vm/qrender" -data "gno.land/r/demo/boards
BOARDNAME/1" -remote localhost:26657
./build/gnokey query "vm/qrender" -data "gno.land/r/demo/boards:BOARDNAME/1" -remote localhost:26657
```

### Render page with optional path expression.
Expand All @@ -130,8 +128,7 @@ The contents of `https://gno.land/r/demo/boards:` and `https://gno.land/r/demo/b
the `Render(path string)` function like so:

```bash
./build/gnokey query "vm/qrender" -data "gno.land/r/demo/boards
gnolang"
./build/gnokey query "vm/qrender" -data "gno.land/r/demo/boards:gnolang"
```
## View the board in the browser.

Expand Down
12 changes: 6 additions & 6 deletions gno.land/cmd/gnoland/testdata/gnokey_simulate.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ stdout '"sequence": "1"'
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args John -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "2"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, John!'
# -simulate only
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args Paul -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "2"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, John!'
# -simulate skip
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args George -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "3"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'

# attempt calling hello.Grumpy (always panics).
Expand All @@ -52,19 +52,19 @@ stdout 'Hello, George!'
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "3"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
# -simulate only
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "3"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
# -simulate skip
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "4"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'

-- test/test.gno --
Expand Down
Loading
Loading