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: refactor govdao structure and examples (gnolang#2379)
- remove `gov/integration/` - remove `gov/proposals/` - move the integration test in `gov/dao/*test.gno` - add `r/sys/validators.Render()` Signed-off-by: moul <[email protected]>
- Loading branch information
Showing
7 changed files
with
98 additions
and
94 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,85 @@ | ||
// Please note that this package is intended for demonstration purposes only. | ||
// You could execute this code (the init part) by running a `maketx run` command | ||
// or by uploading a similar package to a personal namespace. | ||
// | ||
// For the specific case of validators, a `r/gnoland/valopers` will be used to | ||
// organize the lifecycle of validators (register, etc), and this more complex | ||
// contract will be responsible to generate proposals. | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
govdao "gno.land/r/gov/dao" | ||
"gno.land/r/sys/validators" | ||
) | ||
|
||
func init() { | ||
// Create the validators change proposal. | ||
changesFn := func() []validators.Change { | ||
return []validators.Change{ | ||
// add a new validator. | ||
{Address: std.Address("g12345678"), Power: 1}, | ||
// remove an existing validator. | ||
{Address: std.Address("g000000000"), Power: 0}, | ||
} | ||
} | ||
|
||
// Wraps changesFn to emit a certified event only if executed from a | ||
// complete governance proposal process. | ||
executor := validators.NewPropExecutor(changesFn) | ||
|
||
// Create a proposal. | ||
// XXX: payment | ||
comment := "manual valset changes proposal example" | ||
govdao.Propose(comment, executor) | ||
} | ||
|
||
func main() { | ||
println("--") | ||
println(govdao.Render("")) | ||
println("--") | ||
println(govdao.Render("1")) | ||
println("--") | ||
govdao.VoteOnProposal(1, "YES") | ||
println("--") | ||
println(govdao.Render("1")) | ||
println("--") | ||
println(validators.Render("")) | ||
println("--") | ||
govdao.ExecuteProposal(1) | ||
println("--") | ||
println(govdao.Render("1")) | ||
println("--") | ||
println(validators.Render("")) | ||
} | ||
|
||
// Output: | ||
// -- | ||
// - [/r/gov/dao:0](0) - manual valset changes proposal example (by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) | ||
// -- | ||
// # Prop#0 | ||
// | ||
// manual valset changes proposal example | ||
// Status: active | ||
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
// -- | ||
// -- | ||
// # Prop#0 | ||
// | ||
// manual valset changes proposal example | ||
// Status: accepted | ||
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
// -- | ||
// No valset changes to apply. | ||
// -- | ||
// -- | ||
// # Prop#0 | ||
// | ||
// manual valset changes proposal example | ||
// Status: success | ||
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
// -- | ||
// Valset changes to apply: | ||
// - g12345678 (1) | ||
// - g000000000 (0) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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