1package main
2
3import (
4 "std"
5 "time"
6
7 "gno.land/p/demo/context"
8 "gno.land/p/gov/proposal"
9 gnoblog "gno.land/r/gnoland/blog"
10 govdao "gno.land/r/gov/dao"
11)
12
13func init() {
14 membersFn := func() []std.Address {
15 return []std.Address{
16 std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"),
17 }
18 }
19
20 mExec := govdao.NewPropExecutor(membersFn)
21
22 comment := "adding someone to vote"
23
24 id := govdao.Propose(comment, mExec)
25
26 govdao.ExecuteProposal(id)
27
28 executor := proposal.NewCtxExecutor(func(ctx context.Context) error {
29 gnoblog.DaoAddPost(
30 ctx,
31 "hello-from-govdao", // slug
32 "Hello from GovDAO!", // title
33 "This post was published by a GovDAO proposal.", // body
34 time.Now().Format(time.RFC3339), // publidation date
35 "moul", // authors
36 "govdao,example", // tags
37 )
38 return nil
39 })
40
41 // Create a proposal.
42 // XXX: payment
43 comment = "post a new blogpost about govdao"
44 govdao.Propose(comment, executor)
45}
46
47func main() {
48 println("--")
49 println(govdao.Render(""))
50 println("--")
51 println(govdao.Render("1"))
52 println("--")
53 govdao.VoteOnProposal(1, "YES")
54 println("--")
55 println(govdao.Render("1"))
56 println("--")
57 println(gnoblog.Render(""))
58 println("--")
59 govdao.ExecuteProposal(1)
60 println("--")
61 println(govdao.Render("1"))
62 println("--")
63 println(gnoblog.Render(""))
64}
65
66// Output:
67// --
68// - [0](/r/gov/dao:0) - adding someone to vote (**succeeded**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
69// - [1](/r/gov/dao:1) - post a new blogpost about govdao (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
70//
71// --
72// # Prop #1
73//
74// post a new blogpost about govdao
75//
76// Status: active
77//
78// Voting status: YES: 0, NO: 0, percent: 0, members: 1
79//
80// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
81//
82//
83// --
84// --
85// # Prop #1
86//
87// post a new blogpost about govdao
88//
89// Status: accepted
90//
91// Voting status: YES: 1, NO: 0, percent: 100, members: 1
92//
93// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
94//
95//
96// --
97// # Gnoland's Blog
98//
99// No posts.
100// --
101// --
102// # Prop #1
103//
104// post a new blogpost about govdao
105//
106// Status: succeeded
107//
108// Voting status: YES: 1, NO: 0, percent: 100, members: 1
109//
110// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
111//
112//
113// --
114// # Gnoland's Blog
115//
116// <div class='columns-3'><div>
117//
118// ### [Hello from GovDAO!](/r/gnoland/blog:p/hello-from-govdao)
119// 13 Feb 2009
120// </div></div>
prop2_filetest.gno
2.40 Kb ยท 120 lines