Skip to content

Commit 12f0140

Browse files
committed
chore: fixup
Signed-off-by: moul <[email protected]>
1 parent b00abbe commit 12f0140

File tree

3 files changed

+122
-111
lines changed

3 files changed

+122
-111
lines changed

examples/gno.land/r/gov/dao/prop3_filetest.gno

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package main
2+
3+
import (
4+
"gno.land/p/demo/dao"
5+
"gno.land/r/gov/dao/bridge"
6+
govdaov2 "gno.land/r/gov/dao/v2"
7+
"gno.land/r/sys/params"
8+
)
9+
10+
func init() {
11+
/*{ // prop0
12+
membersFn := func() []std.Address {
13+
return []std.Address{
14+
std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"),
15+
}
16+
}
17+
mExec := bridge.GovDAO().NewMemberPropExecutor(membersFn)
18+
comment := "adding someone to vote"
19+
id := bridge.GovDAO().Propose(comment, mExec)
20+
bridge.GovDAO().ExecuteProposal(id)
21+
}*/
22+
23+
{ // prop0
24+
mExec := params.NewStringPropExecutor("prop1.string", "value1")
25+
comment := "setting prop1.string param"
26+
prop := dao.ProposalRequest{
27+
Description: comment,
28+
Executor: mExec,
29+
}
30+
id := bridge.GovDAO().Propose(prop)
31+
println("new prop", id)
32+
}
33+
34+
{ // prop1
35+
mExec := params.NewInt64PropExecutor("prop2.int64", 12345)
36+
comment := "setting prop2.int64 param"
37+
prop := dao.ProposalRequest{
38+
Description: comment,
39+
Executor: mExec,
40+
}
41+
id := bridge.GovDAO().Propose(prop)
42+
println("new prop", id)
43+
}
44+
}
45+
46+
func main() {
47+
println("--")
48+
println(govdaov2.Render(""))
49+
println("--")
50+
println(govdaov2.Render("1"))
51+
println("--")
52+
bridge.GovDAO().VoteOnProposal(1, "YES")
53+
println("--")
54+
println(govdaov2.Render("1"))
55+
println("--")
56+
bridge.GovDAO().ExecuteProposal(1)
57+
println("--")
58+
println(govdaov2.Render("1"))
59+
}
60+
61+
// Events:
62+
// [{"type":"ProposalAdded","attrs":[{"key":"proposal-id","value":"0"},{"key":"proposal-author","value":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"}],"pkg_path":"gno.land/r/gov/dao/v2","func":"EmitProposalAdded"},{"type":"ProposalAdded","attrs":[{"key":"proposal-id","value":"1"},{"key":"proposal-author","value":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"}],"pkg_path":"gno.land/r/gov/dao/v2","func":"EmitProposalAdded"},{"type":"VoteAdded","attrs":[{"key":"proposal-id","value":"1"},{"key":"author","value":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"},{"key":"option","value":"YES"}],"pkg_path":"gno.land/r/gov/dao/v2","func":"EmitVoteAdded"},{"type":"ProposalAccepted","attrs":[{"key":"proposal-id","value":"1"}],"pkg_path":"gno.land/r/gov/dao/v2","func":"EmitProposalAccepted"},{"type":"set","attrs":[{"key":"k","value":"prop2.int64"}],"pkg_path":"gno.land/r/sys/params","func":""},{"type":"ProposalExecuted","attrs":[{"key":"proposal-id","value":"1"},{"key":"exec-status","value":"accepted"}],"pkg_path":"gno.land/r/gov/dao/v2","func":"ExecuteProposal"}]
63+
64+
// Output:
65+
// new prop 0
66+
// new prop 1
67+
// --
68+
// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
69+
// - [Proposal #1](/r/gov/dao/v2:1) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
70+
//
71+
// --
72+
// # Prop #1
73+
//
74+
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
75+
//
76+
// setting prop2.int64 param
77+
//
78+
// Status: active
79+
//
80+
// Voting stats: YAY 0 (0%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 10 (100%)
81+
//
82+
// Threshold met: false
83+
//
84+
//
85+
// --
86+
// --
87+
// # Prop #1
88+
//
89+
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
90+
//
91+
// setting prop2.int64 param
92+
//
93+
// Status: accepted
94+
//
95+
// Voting stats: YAY 10 (100%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 0 (0%)
96+
//
97+
// Threshold met: true
98+
//
99+
//
100+
// --
101+
// --
102+
// # Prop #1
103+
//
104+
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
105+
//
106+
// setting prop2.int64 param
107+
//
108+
// Status: execution successful
109+
//
110+
// Voting stats: YAY 10 (100%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 0 (0%)
111+
//
112+
// Threshold met: true

examples/gno.land/r/sys/params/params.gno

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,35 @@ package params
33
import (
44
"std"
55

6-
"gno.land/p/gov/proposal"
6+
"gno.land/p/demo/dao"
7+
"gno.land/r/gov/dao/bridge"
78
)
89

9-
const daoPkgPath = "gno.land/r/gov/dao"
10-
11-
func NewStringPropExecutor(key string, value string) proposal.Executor {
10+
func NewStringPropExecutor(key string, value string) dao.Executor {
1211
return newPropExecutor(key, func() { std.SetParamString(key, value) })
1312
}
1413

15-
func NewInt64PropExecutor(key string, value int64) proposal.Executor {
14+
func NewInt64PropExecutor(key string, value int64) dao.Executor {
1615
return newPropExecutor(key, func() { std.SetParamInt64(key, value) })
1716
}
1817

19-
func NewUint64PropExecutor(key string, value uint64) proposal.Executor {
18+
func NewUint64PropExecutor(key string, value uint64) dao.Executor {
2019
return newPropExecutor(key, func() { std.SetParamUint64(key, value) })
2120
}
2221

23-
func NewBoolPropExecutor(key string, value bool) proposal.Executor {
22+
func NewBoolPropExecutor(key string, value bool) dao.Executor {
2423
return newPropExecutor(key, func() { std.SetParamBool(key, value) })
2524
}
2625

27-
func NewBytesPropExecutor(key string, value []byte) proposal.Executor {
26+
func NewBytesPropExecutor(key string, value []byte) dao.Executor {
2827
return newPropExecutor(key, func() { std.SetParamBytes(key, value) })
2928
}
3029

31-
func newPropExecutor(key string, fn func()) proposal.Executor {
30+
func newPropExecutor(key string, fn func()) dao.Executor {
3231
callback := func() error {
33-
if std.PrevRealm().PkgPath() != daoPkgPath {
34-
panic("should be executed from govdao")
35-
}
36-
std.Emit("set",
37-
"k", key,
38-
)
3932
fn()
33+
std.Emit("set", "k", key)
4034
return nil
4135
}
42-
return proposal.NewExecutor(callback)
36+
return bridge.GovDAO().NewGovDAOExecutor(callback)
4337
}

0 commit comments

Comments
 (0)