prop3_filetest.gno

2.19 Kb ยท 120 lines
  1package main
  2
  3import (
  4	"std"
  5
  6	"gno.land/p/demo/dao"
  7	"gno.land/p/demo/membstore"
  8	govdao "gno.land/r/gov/dao/v2"
  9)
 10
 11func init() {
 12	memberFn := func() []membstore.Member {
 13		return []membstore.Member{
 14			{
 15				Address:     std.Address("g123"),
 16				VotingPower: 10,
 17			},
 18			{
 19				Address:     std.Address("g456"),
 20				VotingPower: 10,
 21			},
 22			{
 23				Address:     std.Address("g789"),
 24				VotingPower: 10,
 25			},
 26		}
 27	}
 28
 29	// Create a proposal
 30	description := "add new members to the govdao"
 31
 32	prop := dao.ProposalRequest{
 33		Description: description,
 34		Executor:    govdao.NewMemberPropExecutor(memberFn),
 35	}
 36
 37	govdao.Propose(prop)
 38}
 39
 40func main() {
 41	println("--")
 42	println(govdao.GetMembStore().Size())
 43	println("--")
 44	println(govdao.Render(""))
 45	println("--")
 46	println(govdao.Render("0"))
 47	println("--")
 48	govdao.VoteOnProposal(0, "YES")
 49	println("--")
 50	println(govdao.Render("0"))
 51	println("--")
 52	println(govdao.Render(""))
 53	println("--")
 54	govdao.ExecuteProposal(0)
 55	println("--")
 56	println(govdao.Render("0"))
 57	println("--")
 58	println(govdao.Render(""))
 59	println("--")
 60	println(govdao.GetMembStore().Size())
 61}
 62
 63// Output:
 64// --
 65// 1
 66// --
 67// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
 68//
 69// --
 70// # Prop #0
 71//
 72// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 73//
 74// add new members to the govdao
 75//
 76// Status: active
 77//
 78// Voting stats: YAY 0 (0%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 10 (100%)
 79//
 80// Threshold met: false
 81//
 82//
 83// --
 84// --
 85// # Prop #0
 86//
 87// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 88//
 89// add new members to the govdao
 90//
 91// Status: accepted
 92//
 93// Voting stats: YAY 10 (100%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 0 (0%)
 94//
 95// Threshold met: true
 96//
 97//
 98// --
 99// - [Proposal #0](/r/gov/dao/v2:0) - (**accepted**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
100//
101// --
102// --
103// # Prop #0
104//
105// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
106//
107// add new members to the govdao
108//
109// Status: execution successful
110//
111// Voting stats: YAY 10 (25%), NAY 0 (0%), ABSTAIN 0 (0%), HAVEN'T VOTED 30 (75%)
112//
113// Threshold met: false
114//
115//
116// --
117// - [Proposal #0](/r/gov/dao/v2:0) - (**execution successful**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm)
118//
119// --
120// 4