safe.gno
2.85 Kb · 98 lines
1// Package safe is inspired by Gnosis Safe
2package safe
3
4import (
5 "chain/runtime/unsafe"
6)
7
8// Gnosis safe style using this with threshold
9// : affMember + update threshold at the same time
10
11type Safe interface {
12 Name() string
13 Members() []address
14 Threshold() uint
15 Size() uint
16 NextProposal() Proposal
17 UpcomingProposals(page uint) (props []Proposal, total uint)
18 PreviousProposals(page uint) (props []Proposal, total uint)
19 // balances (native, grc20, grc721)
20
21 ProposeAddingMember(addr address, newThreshold uint) (prop Proposal, err error)
22 ProposeRemovingMember(addr address, newThreshold uint) (prop Proposal, err error)
23 ProposeUpdatingThreshold(newThreshold uint) (prop Proposal, err error)
24 // ProposeClosure(cl func()) (prop Proposal, err error)
25 // ProposeBankXXX()
26 // ProposeGRC20XXX()
27 // ProposeGRC721XXX()
28
29 GetProposal(id uint) Proposal
30 ApproveProposal(p Proposal) error
31 ExecuteProposal(p Proposal) error
32 CancelProposal(p Proposal) error // XXX: should be ProposeToCancel?
33
34 Render(path string) string
35}
36
37type Proposal interface {
38 ID() uint
39 Active() bool
40 Executed() bool
41 Voters() []address
42}
43
44func NewSafe() Safe {
45 caller := unsafe.PreviousRealm().Address()
46 return safe{
47 members: []address{caller},
48 threshold: 1,
49 prevProps: []Proposal{},
50 nextProps: []Proposal{},
51 }
52}
53
54type safe struct {
55 name string
56 members []address // member addresses
57 threshold uint
58 prevProps []Proposal // executed/cancelled proposals
59 nextProps []Proposal // upcoming proposals
60}
61
62func (s safe) String() string { panic("not implemented") }
63
64func (s safe) Name() string { return s.name }
65func (s safe) Members() []address { return s.members }
66func (s safe) Threshold() uint { return s.threshold }
67func (s safe) Size() uint { return uint(len(s.members)) }
68func (s safe) NextProposal() Proposal { panic("not implemented") }
69
70func (s safe) UpcomingProposals(page uint) (props []Proposal, total uint) {
71 panic("not implemented")
72}
73
74func (s safe) PreviousProposals(page uint) (props []Proposal, total uint) {
75 panic("not implemented")
76}
77
78func (s safe) ProposeAddingMember(addr address, newThreshold uint) (prop Proposal, err error) {
79 panic("not implemented")
80}
81
82func (s safe) ProposeRemovingMember(addr address, newThreshold uint) (prop Proposal, err error) {
83 panic("not implemented")
84}
85
86func (s safe) ProposeUpdatingThreshold(newThreshold uint) (prop Proposal, err error) {
87 panic("not implemented")
88}
89
90func (s safe) GetProposal(id uint) Proposal { panic("not implemented") }
91func (s safe) ApproveProposal(p Proposal) error { panic("not implemented") }
92func (s safe) ExecuteProposal(p Proposal) error { panic("not implemented") }
93func (s safe) CancelProposal(p Proposal) error { panic("not implemented") }
94func (s safe) Render(path string) string { panic("not implemented") }
95
96type proposal struct{}
97
98func (p proposal) String() string { panic("not implemented") }