Search Apps Documentation Source Content File Folder Download Copy Actions Download

dao.gno

1.25 Kb ยท 57 lines
 1package gnopendao6
 2
 3import (
 4	//"chain/banker"
 5	"chain/runtime"
 6	"gno.land/p/nt/commondao"
 7)
 8
 9var (
10	marketplaceDAO *commondao.CommonDAO
11	daoAdmin       address
12)
13
14const (
15	MIN_STAKE_UGNOT = 1_000_000 // 1 GNOT minimum to join DAO
16)
17
18func initDAO() {
19	daoAdmin = runtime.PreviousRealm().Address()
20
21	storage := commondao.NewMemberStorage()
22
23	marketplaceDAO = commondao.New(
24		commondao.WithID(1),
25		commondao.WithName("GnopenSea DAO"),
26		commondao.WithDescription("Decentralized governance for GnopenSea marketplace"),
27		commondao.WithMemberStorage(storage),
28	)
29}
30
31// JoinDAO - Join the marketplace DAO by staking GNOT
32func JoinDAO(_ realm) string {
33	caller := runtime.PreviousRealm().Address()
34	//sent := banker.OriginSend()
35
36	//amount := sent.AmountOf("ugnot")
37	//if amount < MIN_STAKE_UGNOT {
38	//	panic("minimum 1 GNOT required to join DAO")
39	//}
40
41	if marketplaceDAO.Members().Has(caller) {
42		panic("already a DAO member")
43	}
44
45	marketplaceDAO.Members().Add(caller)
46
47	return "Successfully joined GnopenSea DAO"
48}
49
50// IsDAOMember - Check if an address is a DAO member
51func IsDAOMember(addr address) bool {
52	return marketplaceDAO.Members().Has(addr)
53}
54
55// GetTotalMembers - Returns total number of DAO members
56func GetTotalMembers() int {
57	return marketplaceDAO.Members().Size()
58}