1// Package safe is inspired by Gnosis Safe2package safe34import (5 "chain/runtime/unsafe"6)78// Gnosis safe style using this with threshold9// : affMember + update threshold at the same time1011type Safe interface {12 Name() string13 Members() []address14 Threshold() uint15 Size() uint16 NextProposal() Proposal17 UpcomingProposals(page uint) (props []Proposal, total uint)18 PreviousProposals(page uint) (props []Proposal, total uint)19 // balances (native, grc20, grc721)2021 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()2829 GetProposal(id uint) Proposal30 ApproveProposal(p Proposal) error31 ExecuteProposal(p Proposal) error32 CancelProposal(p Proposal) error // XXX: should be ProposeToCancel?3334 Render(path string) string35}3637type Proposal interface {38 ID() uint39 Active() bool40 Executed() bool41 Voters() []address42}4344func 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}5354type safe struct {55 name string56 members []address // member addresses57 threshold uint58 prevProps []Proposal // executed/cancelled proposals59 nextProps []Proposal // upcoming proposals60}6162func (s safe) String() string { panic("not implemented") }6364func (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") }6970func (s safe) UpcomingProposals(page uint) (props []Proposal, total uint) {71 panic("not implemented")72}7374func (s safe) PreviousProposals(page uint) (props []Proposal, total uint) {75 panic("not implemented")76}7778func (s safe) ProposeAddingMember(addr address, newThreshold uint) (prop Proposal, err error) {79 panic("not implemented")80}8182func (s safe) ProposeRemovingMember(addr address, newThreshold uint) (prop Proposal, err error) {83 panic("not implemented")84}8586func (s safe) ProposeUpdatingThreshold(newThreshold uint) (prop Proposal, err error) {87 panic("not implemented")88}8990func (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") }9596type proposal struct{}9798func (p proposal) String() string { panic("not implemented") }99Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.