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

admin.gno

2.73 Kb · 81 lines
 1package bubble
 2
 3// The settings, and who may change them.
 4//
 5// admin is whoever deployed the realm (Jae's hotkey signs the addpkg) and is handed to the box's keeper key in the
 6// same minute ("a token that you control, but admin can be transferred and even destroyed"). An empty admin is
 7// nobody, permanently: RenounceAdmin is the "destroyed" Jae asked for. After it, every one of these settings moves
 8// only by a holders' vote (kinds.gno), and the mint goes on under the minter until the holders stop it.
 9var (
10	// admin is Jae's cold key (jarvis room 201, 2026-09-25: "(b) g1ecsu … make sure that even if the hotkey is
11	// hacked the g1ecsu can restore"), named here rather than read from OriginCaller at init: the deployer is the
12	// hotkey, which holds no power once the realm is up, and a test package or a filetest loads with no deployer
13	// at all. The box holds the minter, whose damage the day cap bounds; if the box or the hotkey is ever taken,
14	// this key pauses, names another minter, and goes on.
15	admin = address("g1ecsuj0q572jr0dhu29q9njtnmw03hyu7tyyvv6")
16	// minter is the box's keeper key, the only address that mints referrals; "" is nobody.
17	minter = address("g18dd5mstjqlcg9ngqpg26azeya6wqg7upd9t8xa")
18	paused bool // the admin's brake: stops Mint and MintMany, nothing else
19	dayCap = 250_000 * one
20)
21
22func init() {
23	ledger.SetID(tokenID)
24	ledger.Mint(premineTo, premine)
25	premined = premine
26}
27
28func Admin() address  { return admin }
29func Minter() address { return minter }
30func Paused() bool    { return paused }
31func DayCap() int64   { return dayCap }
32
33func mustBeAdmin(cur realm) {
34	who := caller(cur)
35	if admin == "" {
36		panic("bubble: the admin was given up; the holders decide now")
37	}
38	if who != admin {
39		panic("bubble: only the admin")
40	}
41}
42
43// SetAdmin hands the settings to another address.
44func SetAdmin(cur realm, to address) {
45	mustBeAdmin(cur)
46	if !to.IsValid() {
47		panic("bubble: not an address")
48	}
49	admin = to
50}
51
52// RenounceAdmin gives the settings up for good: from here they move only by vote.
53func RenounceAdmin(cur realm) {
54	mustBeAdmin(cur)
55	admin = ""
56}
57
58// SetMinter names who mints; "" is nobody (the referral mint stops until a vote names one).
59func SetMinter(cur realm, to address) {
60	mustBeAdmin(cur)
61	if to != "" && !to.IsValid() {
62		panic("bubble: not an address")
63	}
64	minter = to
65}
66
67// SetPaused stops the mint, or lets it go on.
68func SetPaused(cur realm, on bool) {
69	mustBeAdmin(cur)
70	paused = on
71}
72
73// SetDayCap lowers the daily ceiling. Raising it is the holders' (govern:daycap): the cap is what bounds a stolen
74// key, so the key it bounds may not raise it.
75func SetDayCap(cur realm, n int64) {
76	mustBeAdmin(cur)
77	if n < 0 || n > dayCap {
78		panic("bubble: the admin can only lower the day cap; raising it is a vote")
79	}
80	dayCap = n
81}