1package config23import (4 "errors"56 "gno.land/p/moul/authz/v0"7)89var Authorizer *authz.Authorizer1011func init(cur realm) {12 if !cur.Previous().IsUserCall() {13 panic("r/moul/config must be initialized by an EOA")14 }15 Authorizer = authz.NewWithMembers(cur.Previous().Address())16}1718// AddManager adds a new address to the list of authorized managers.19// This only works if the current authority is a MemberAuthority.20// The caller must be authorized by the current authority.21func AddManager(cur realm, addr address) error {22 memberAuth, ok := Authorizer.Authority().(*authz.MemberAuthority)23 if !ok {24 return errors.New("current authority is not a MemberAuthority, cannot add manager directly")25 }26 return memberAuth.AddMember(0, cur, addr)27}2829// RemoveManager removes an address from the list of authorized managers.30// This only works if the current authority is a MemberAuthority.31// The caller must be authorized by the current authority.32func RemoveManager(cur realm, addr address) error {33 memberAuth, ok := Authorizer.Authority().(*authz.MemberAuthority)34 if !ok {35 return errors.New("current authority is not a MemberAuthority, cannot remove manager directly")36 }37 return memberAuth.RemoveMember(0, cur, addr)38}3940// TransferManagement transfers the authority to manage keys to a new authority.41// The caller must be authorized by the current authority.42func TransferManagement(cur realm, newAuthority authz.Authority) error {43 if newAuthority == nil {44 return errors.New("new authority cannot be nil")45 }46 return Authorizer.Transfer(0, cur, newAuthority)47}4849// ListManagers returns a slice of all managed keys.50func ListManagers(cur realm) []address {51 var keyList []address52 memberAuth, ok := Authorizer.Authority().(*authz.MemberAuthority)53 if !ok {54 return keyList55 }56 tree := memberAuth.Tree()57 if !ok || tree == nil {58 return keyList // Return empty list if tree is not as expected or nil59 }60 tree.Iterate("", "", func(key string, _ any) bool {61 keyList = append(keyList, address(key))62 return false63 })64 return keyList65}6667func HasManager(cur realm, addr address) bool {68 memberAuth, ok := Authorizer.Authority().(*authz.MemberAuthority)69 if !ok {70 return false // Return false if not a MemberAuthority or doesn't exist71 }72 // Use the MemberAuthority's specific RemoveMember method,73 // which internally performs the authorization check.74 return memberAuth.Has(addr)75}76AddManager(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, addr string) interface {Error func() string}
HasManager(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, addr string) bool
ListManagers(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}) [].uverse.address
RemoveManager(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, addr string) interface {Error func() string}
TransferManagement(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, newAuthority interface {Authorize func(.uverse.address, string, gno.land/p/moul/authz/v0.PrivilegedAction, ...interface {}) .uverse.error; String func() string}) interface {Error func() string}
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.