Search Apps Documentation Source Content File Folder Download Copy Actions Download

admin.gno

2.53 Kb · 86 lines
 1package memba_appstore_v2
 2
 3import "chain"
 4
 5// Admin surface — owner-gated. The owner is the samcrew multisig at launch and can
 6// be handed to the memba_dao executor via the 2-step TransferOwnership/AcceptOwnership
 7// (never a 1-step transfer to a mistyped/dead address).
 8
 9// SetRegistrationFee sets the flat listing fee in ugnot (0..MaxRegistrationFee).
10// Zero is allowed (a fee waiver). Owner only.
11func SetRegistrationFee(cur realm, fee int64) {
12	assertOwner()
13	if fee < 0 || fee > MaxRegistrationFee {
14		panic("fee out of range [0, MaxRegistrationFee]")
15	}
16	registrationFee = fee
17	chain.Emit("RegistrationFeeSet", "fee", itoa64(uint64(fee)))
18}
19
20// SetTreasury repoints the fee recipient. Must be non-empty (an empty treasury would
21// fail-close RegisterApp). Owner only. Keep this in sync with
22// memba_market_config.GetTreasury().
23func SetTreasury(cur realm, addr address) {
24	assertOwner()
25	if addr == "" {
26		panic("treasury must be non-empty")
27	}
28	treasury = addr
29	chain.Emit("TreasurySet", "treasury", addr.String())
30}
31
32// AddCurator grants the curate role (approve pending listings). Owner only.
33func AddCurator(cur realm, addr address) {
34	assertOwner()
35	if addr == "" {
36		panic("curator must be non-empty")
37	}
38	curators.Set(addr.String(), true)
39	chain.Emit("CuratorAdded", "curator", addr.String())
40}
41
42// RemoveCurator revokes the curate role. Owner only.
43func RemoveCurator(cur realm, addr address) {
44	assertOwner()
45	curators.Remove(addr.String())
46	chain.Emit("CuratorRemoved", "curator", addr.String())
47}
48
49// Pause is the kill switch: while paused, RegisterApp aborts (reads stay available).
50// Owner only.
51func Pause(cur realm, state bool) {
52	assertOwner()
53	paused = state
54	chain.Emit("PauseSet", "paused", boolStr(state))
55}
56
57// TransferOwnership stages a new owner; it takes effect only after AcceptOwnership
58// is called BY that address (2-step, so a typo can't brick admin).
59func TransferOwnership(cur realm, newOwner address) {
60	assertOwner()
61	if newOwner == "" {
62		panic("newOwner must be non-empty")
63	}
64	pendingOwner = newOwner
65	chain.Emit("OwnershipTransferStarted", "pending", newOwner.String())
66}
67
68// AcceptOwnership completes the handoff. Only the staged pendingOwner may call it.
69func AcceptOwnership(cur realm) {
70	if pendingOwner == "" {
71		panic("no pending ownership transfer")
72	}
73	if caller() != pendingOwner {
74		panic("unauthorized: only the pending owner may accept")
75	}
76	owner = pendingOwner
77	pendingOwner = ""
78	chain.Emit("OwnershipTransferAccepted", "owner", owner.String())
79}
80
81func boolStr(b bool) string {
82	if b {
83		return "true"
84	}
85	return "false"
86}