Skip to content

Commit

Permalink
Update docs and txtar(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed May 15, 2024
1 parent 69703d7 commit e71b88f
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 47 deletions.
3 changes: 3 additions & 0 deletions docs/assets/how-to-guides/simple-contract/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module gno.land/r/demo/counter

require gno.land/p/demo/ufmt v0.0.0-latest
3 changes: 3 additions & 0 deletions docs/assets/how-to-guides/simple-library/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module gno.land/p/demo/tapas

require gno.land/p/demo/rand v0.0.0-latest
5 changes: 1 addition & 4 deletions docs/gno-tooling/cli/gnokey.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ gnokey maketx addpkg \
-deposit="1ugnot" \
-gas-fee="1ugnot" \
-gas-wanted="5000000" \
-pkgpath={Registered Realm path} \
-pkgdir={Package folder path} \
{ADDRESS} \
> unsigned.tx
Expand All @@ -183,8 +182,7 @@ gnokey maketx addpkg \
#### **makeTx AddPackage Options**

| Name | Type | Description |
|-----------|--------|---------------------------------------|
| `pkgpath` | String | The package path (required). |
| --------- | ------ | ------------------------------------- |
| `pkgdir` | String | The path to package files (required). |
| `deposit` | String | The amount of coins to send. |

Expand All @@ -197,7 +195,6 @@ This subcommand lets you call a public function.
gnokey maketx call \
-gas-fee="1ugnot" \
-gas-wanted="5000000" \
-pkgpath="gno.land/r/demo/users" \
-send="200000000ugnot" \
-func="Register" \
-args="" \
Expand Down
2 changes: 0 additions & 2 deletions docs/how-to-guides/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ terminal at `counter-app/` and use the following `gnokey` command:

```bash
gnokey maketx addpkg \
--pkgpath "gno.land/r/demo/counter" \
--pkgdir "./r/counter" \
--gas-fee 10000000ugnot \
--gas-wanted 800000 \
Expand All @@ -99,7 +98,6 @@ MyKey
```

Let's analyze all of the flags in detail:
- `--pkgpath` - path where the package/realm will be placed on-chain
- `--pkgdir` - local path where the package/realm is located
- `--gas-wanted` - the upper limit for units of gas for the execution of the
transaction - similar to Solidity's gas limit
Expand Down
10 changes: 10 additions & 0 deletions docs/how-to-guides/simple-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ our tapas suggestion library logic:

```bash
cd tapas
gno mod init gno.land/p/demo/tapas
touch tapas.gno
```

Expand Down Expand Up @@ -137,6 +138,15 @@ func GetTapaSuggestion(userInput string) string {
}
```

And inside `gno.mod`, we will define dependencies:

[embedmd]:# (../assets/how-to-guides/simple-library/gno.mod go.mod)
```go.mod
module gno.land/p/demo/tapas
require gno.land/p/demo/rand v0.0.0-latest
```

There are a few things happening here, so let's dissect them:

- We defined the logic of our library into a package called `tapas`.
Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### - add pkg

./build/gnokey maketx addpkg -pkgdir "examples/gno.land/r/demo/groups" -deposit 100000000ugnot -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid dev -remote 0.0.0.0:26657 -pkgpath "gno.land/r/demo/groups" test1
./build/gnokey maketx addpkg -pkgdir "examples/gno.land/r/demo/groups" -deposit 100000000ugnot -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid dev -remote 0.0.0.0:26657 test1

### - create group

Expand Down
4 changes: 2 additions & 2 deletions examples/gno.land/r/demo/microblog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
(One-time) Add the microblog package:

```
gnokey maketx addpkg --pkgpath "gno.land/p/demo/microblog" --pkgdir "examples/gno.land/p/demo/microblog" \
gnokey maketx addpkg --pkgdir "examples/gno.land/p/demo/microblog" \
--deposit 100000000ugnot --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast --chainid dev --remote localhost:26657 <YOURKEY>
```

(One-time) Add the microblog realm:

```
gnokey maketx addpkg --pkgpath "gno.land/r/demo/microblog" --pkgdir "examples/gno.land/r/demo/microblog" \
gnokey maketx addpkg --pkgdir "examples/gno.land/r/demo/microblog" \
--deposit 100000000ugnot --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast --chainid dev --remote localhost:26657 <YOURKEY>
```

Expand Down
7 changes: 5 additions & 2 deletions gno.land/cmd/gnoland/testdata/addpkg.txtar
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# test for add package

# load hello.gno package located in $WORK directory as gno.land/r/hello
loadpkg gno.land/r/hello $WORK
# load `gno.land/r/hello` package located in $WORK directory
loadpkg $WORK

## start a new node
gnoland start
Expand All @@ -17,6 +17,9 @@ stdout 'GAS USED: \d+'
stdout 'HEIGHT: \d+'
stdout 'EVENTS: \[\]'

-- gno.mod --
module gno.land/r/hello

-- hello.gno --
package hello

Expand Down
5 changes: 4 additions & 1 deletion gno.land/cmd/gnoland/testdata/addpkg_invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
gnoland start

# add bar package located in $WORK directory as gno.land/r/foobar/bar
! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/foobar/bar -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
! gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

# check error message
! stdout .+
stderr 'as string value in return statement'
stderr '"std" imported and not used'

-- gno.mod --
module gno.land/r/foobar/bar

-- bar.gno --
package bar

Expand Down
7 changes: 6 additions & 1 deletion gno.land/cmd/gnoland/testdata/append.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ loadpkg gno.land/p/demo/ufmt
# start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/append -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# Call Append 1
Expand Down Expand Up @@ -69,6 +69,11 @@ gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot
stdout '("1-" string)'
stdout OK!

-- gno.mod --
module gno.land/r/append

require gno.land/p/demo/ufmt v0.0.0-latest

-- append.gno --
package append

Expand Down
6 changes: 4 additions & 2 deletions gno.land/cmd/gnoland/testdata/float_arg.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
## start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/float_realm -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

gnokey maketx call -pkgpath gno.land/r/demo/float_realm --func AddF32 -args 10.5 --args 20 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1
stdout '(30.5 float32)'

gnokey maketx call -pkgpath gno.land/r/demo/float_realm --func AddF64 -args 3.1 --args 2.2 --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1
stdout '(5.3[0-9]* float64)'

-- gno.mod --
module gno.land/r/demo/float_realm

-- float_realm.gno --
package float_realm

Expand All @@ -21,4 +24,3 @@ func AddF32(x, y float32) float32 {
func AddF64(x, y float64) float64 {
return x + y
}

14 changes: 10 additions & 4 deletions gno.land/cmd/gnoland/testdata/gnokey_simulate.txtar
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# test for gnokey maketx -simulate options, and how they return any errors

loadpkg gno.land/r/hello $WORK/hello
loadpkg $WORK/hello

# start a new node
gnoland start
Expand All @@ -12,15 +12,15 @@ stdout '"sequence": "0"'
# attempt adding the "test" package.
# the package has a syntax error; simulation should catch this ahead of time and prevent the tx.
# -simulate test
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate test test1
! gnokey maketx addpkg -pkgdir $WORK/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "0"'
# -simulate only
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only test1
! gnokey maketx addpkg -pkgdir $WORK/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "0"'
# -simulate skip
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate skip test1
! gnokey maketx addpkg -pkgdir $WORK/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
stdout '"sequence": "1"'

Expand Down Expand Up @@ -67,13 +67,19 @@ stdout '"sequence": "4"'
gnokey query vm/qeval --data "gno.land/r/hello\nHello()"
stdout 'Hello, George!'

-- test/gno.mod --
module gno.land/r/test

-- test/test.gno --
package test

func Render(path string) string {
return 89
}

-- hello/gno.mod --
module gno.land/r/hello

-- hello/hello.gno --
package hello

Expand Down
38 changes: 26 additions & 12 deletions gno.land/cmd/gnoland/testdata/grc20_registry.txtar
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# example for contract-contract interaction with ownership
# add registry
loadpkg gno.land/r/registry $WORK/registry
loadpkg $WORK/registry

## start a new node
gnoland start
Expand All @@ -10,13 +10,16 @@ gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo2
stdout 'not found'

# add foo20, and foo20wrapper
gnokey maketx addpkg -pkgdir $WORK/foo20 -pkgpath gno.land/r/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -pkgpath gno.land/r/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK/foo20 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK/foo20wrapper -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

# we call Transfer with foo20, after it's registered
gnokey maketx call -pkgpath gno.land/r/registry -func TransferByName -args 'foo20' -args 'g123456789' -args '42' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout 'same address, success!'

-- registry/gno.mod --
module gno.land/r/registry

-- registry/registry.gno --
package registry

Expand All @@ -42,15 +45,8 @@ func TransferByName(name string, to string, amount uint64) string {
return "not found"
}

-- foo20wrapper/foo20wrapper.gno --
package foo20wrapper

import "gno.land/r/registry"
import "gno.land/r/foo20"

func init() {
registry.Register("foo20", foo20.Transfer)
}
-- foo20/gno.mod --
module gno.land/r/foo20

-- foo20/foo20.gno --
package foo20
Expand All @@ -61,3 +57,21 @@ func Transfer(to std.Address, amount uint64) string {
println("transfer from=" + std.PrevRealm().Addr().String() + " to=" + to.String() + " some-amount")
return std.PrevRealm().Addr().String()
}

-- foo20wrapper/gno.mod --
module gno.land/r/foo20wrapper

require (
gno.land/r/registry v0.0.0-latest
gno.land/r/foo20 v0.0.0-latest
)

-- foo20wrapper/foo20wrapper.gno --
package foo20wrapper

import "gno.land/r/registry"
import "gno.land/r/foo20"

func init() {
registry.Register("foo20", foo20.Transfer)
}
2 changes: 1 addition & 1 deletion gno.land/cmd/gnoland/testdata/issue_1167.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ loadpkg gno.land/p/demo/avl
gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/xx -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# execute New
Expand Down
2 changes: 1 addition & 1 deletion gno.land/cmd/gnoland/testdata/issue_1588.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/xx -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

gnokey maketx call -pkgpath gno.land/r/demo/xx -func DefineFamily -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
Expand Down
3 changes: 1 addition & 2 deletions gno.land/cmd/gnoland/testdata/issue_1786.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ loadpkg gno.land/r/demo/wugnot
gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/proxywugnot -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# approve wugnot to `proxywugnot ≈ g1fndyg0we60rdfchyy5dwxzkfmhl5u34j932rg3`
Expand Down Expand Up @@ -38,7 +38,6 @@ stdout '9500 uint64'
-- gno.mod --
module gno.land/r/demo/proxywugnot


-- realm.gno --
package proxywugnot

Expand Down
5 changes: 4 additions & 1 deletion gno.land/cmd/gnoland/testdata/issue_gnochess_97.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/bug97 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'RealmCall1' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
stdout 'OK!'
Expand All @@ -13,6 +13,9 @@ stdout 'OK!'
gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'RealmCall1' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
stdout 'OK!'

-- gno.mod --
module gno.land/r/demo/bug97

-- bug97.gno --
package bug97

Expand Down
2 changes: 1 addition & 1 deletion gno.land/cmd/gnoland/testdata/map_delete.txtar
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/mapdelete -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# delete map
Expand Down
3 changes: 1 addition & 2 deletions gno.land/cmd/gnoland/testdata/map_storage.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gnoland start

# add contract
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/mapindex -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# call map
Expand All @@ -18,7 +18,6 @@ stdout '"three" string'
-- gno.mod --
module gno.land/r/demo/mapindex


-- realm.gno --
package mapindex

Expand Down
Loading

0 comments on commit e71b88f

Please sign in to comment.