Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_commondao_execute_2_filetest.gno

1.04 Kb ยท 43 lines
 1// PKGPATH: gno.land/r/test
 2package test
 3
 4import (
 5	"time"
 6
 7	"gno.land/p/nt/commondao"
 8)
 9
10const member address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
11
12var (
13	dao      *commondao.CommonDAO
14	proposal *commondao.Proposal
15)
16
17type testPropDef struct{}
18
19func (testPropDef) Title() string                               { return "" }
20func (testPropDef) Body() string                                { return "" }
21func (testPropDef) VotingPeriod() time.Duration                 { return time.Hour } // Voting ends in 1 hour
22func (testPropDef) Execute(cur realm) error                     { return nil }
23func (testPropDef) Tally(commondao.VotingContext) (bool, error) { return true, nil }
24
25func init() {
26	dao = commondao.New(
27		commondao.WithMember(member),
28		commondao.DisableVotingDeadlineCheck(), // Disable to be able to execute before voting deadline
29	)
30	proposal = dao.MustPropose(member, testPropDef{})
31}
32
33func main() {
34	err := dao.Execute(proposal.ID())
35	if err != nil {
36		panic(err)
37	}
38
39	println(string(proposal.Status()))
40}
41
42// Output:
43// executed