Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

admin.gno

1.28 Kb · 59 lines
 1package memba_notes_v1
 2
 3import (
 4	"chain"
 5	keys "gno.land/r/samcrew/enckeys_v1"
 6)
 7
 8func administrator(who address) {
 9	if who != admin {
10		panic("notes: admin required")
11	}
12}
13func SetCreateFee(cur realm, fee int64) {
14	who := enter(cur, false)
15	defer leave()
16	administrator(who)
17	if fee < 0 || fee > 1000000 {
18		panic("notes: fee out of range")
19	}
20	createFee = fee
21}
22func SetTreasury(cur realm, to address) {
23	who := enter(cur, false)
24	defer leave()
25	administrator(who)
26	to = keys.CanonicalAddress(to)
27	if to == cur.Address() || to == chain.DeriveStorageDepositAddr(RealmPath) {
28		panic("notes: locked treasury")
29	}
30	treasury = to
31}
32func Pause(cur realm, on bool) {
33	who := enter(cur, false)
34	defer leave()
35	administrator(who)
36	paused = on
37}
38func TransferAdmin(cur realm, to address) {
39	who := enter(cur, false)
40	defer leave()
41	administrator(who)
42	to = keys.CanonicalAddress(to)
43	if to == govAddress {
44		panic("notes: governance cannot accept realm administration")
45	}
46	pendingAdmin = to
47}
48func AcceptAdmin(cur realm) {
49	who := enter(cur, false)
50	defer leave()
51	if who != pendingAdmin || pendingAdmin == "" {
52		panic("notes: pending admin required")
53	}
54	admin = who
55	pendingAdmin = ""
56}
57
58// GetAdmin supplies the closed authority readback used by deployment rehearsal.
59func GetAdmin() address { return admin }