forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tm2): add sdk/params module (gnolang#2920)
- [x] port x/params -> sdk/params b930513 - [x] inject in vmkeeper + add std.SetConfig 602245d - [x] implement in `gnoland` 783a044 - [x] appchain - [x] rpc query - [x] txtar - [x] implement or add comment where we should use it in the existing codebase - [x] namespace's realm target - [ ] questions - [x] do we want a `std.GetConfig` from the contract part? -> No, it allows unsafe, complex, and implicit patterns. If you want to get a value from another contract, you can either import it or use a registry pattern. This approach preserves type safety and other GNOVM protections. - [ ] do we want to restrict the realms able to call `SetConfig` (only `r/sys`), or maybe set an expensive gas price? - [x] after discussion with jae - [x] Rename Config -> Param for consistency - [x] Remove `interface{}` from the setters and use specific types, including in the tm2 implementation (string, uint64, int64, bool, bytes) - [x] Remove the `.<type>` suffix addition, but ensure that the type is explicitly defined by the user; and remove the table. - [x] Remove the types table from the tm2 implementation Related gnolang#1418 Related gnolang#1856 --------- Signed-off-by: moul <[email protected]>
- Loading branch information
Showing
21 changed files
with
901 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# test for https://github.com/gnolang/gno/pull/2920 | ||
|
||
gnoland start | ||
|
||
# query before adding the package | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: $' | ||
|
||
gnokey maketx addpkg -pkgdir $WORK/setter -pkgpath gno.land/r/sys/setter -gas-fee 1000000ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1 | ||
|
||
# query after adding the package, but before setting values | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: $' | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: $' | ||
|
||
|
||
# set foo (string) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetFoo -args foo1 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: "foo1"' | ||
|
||
# override foo | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetFoo -args foo2 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.foo.string | ||
stdout 'data: "foo2"' | ||
|
||
|
||
# set bar (bool) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBar -args true -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: true' | ||
|
||
# override bar | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBar -args false -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.bar.bool | ||
stdout 'data: false' | ||
|
||
|
||
# set baz (bool) | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBaz -args 1337 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: "1337"' | ||
|
||
# override baz | ||
gnokey maketx call -pkgpath gno.land/r/sys/setter -func SetBaz -args 31337 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1 | ||
gnokey query params/vm/gno.land/r/sys/setter.baz.int64 | ||
stdout 'data: "31337"' | ||
|
||
-- setter/setter.gno -- | ||
package setter | ||
|
||
import ( | ||
"std" | ||
) | ||
|
||
func SetFoo(newFoo string) { std.SetParamString("foo.string", newFoo) } | ||
func SetBar(newBar bool) { std.SetParamBool("bar.bool", newBar) } | ||
func SetBaz(newBaz int64) { std.SetParamInt64("baz.int64", newBaz) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.