admin.gno
1.63 Kb · 58 lines
1package memba_nft_market_v2
2
3// Admin operations — multisig-gated controls.
4//
5// assertAdmin() is the single authorization gate; caller = unsafe.PreviousRealm().Address().
6// AdminDelist is pause-exempt (moderation can always remove content).
7// SetFeeRecipient changes where platform fees flow (default = AdminAddress).
8
9import (
10 "chain"
11 "chain/runtime/unsafe"
12
13 "gno.land/p/samcrew/grc721"
14)
15
16func assertAdmin() {
17 if unsafe.PreviousRealm().Address() != address(AdminAddress) {
18 panic("admin only")
19 }
20}
21
22// Pause halts new trade operations (ListNFT, BuyNFT, MakeOffer, AcceptOffer).
23// Value-exit paths (DelistNFT, CancelOffer, ClaimExpiredOffer) remain available.
24func Pause(cur realm) {
25 assertAdmin()
26 paused = true
27 chain.Emit("MarketPaused", "by", unsafe.PreviousRealm().Address().String())
28}
29
30// Unpause resumes normal operations.
31func Unpause(cur realm) {
32 assertAdmin()
33 paused = false
34 chain.Emit("MarketUnpaused", "by", unsafe.PreviousRealm().Address().String())
35}
36
37// AdminDelist force-removes any listing. Pause-exempt (moderation).
38func AdminDelist(cur realm, collectionID string, tid grc721.TokenID) {
39 assertAdmin()
40 key := listingKey(collectionID, string(tid))
41 if _, exists := listings.Get(key); !exists {
42 panic("not listed: " + key)
43 }
44 listings.Remove(key)
45 removeFromOrder(key)
46 chain.Emit("AdminDelisted",
47 "collection", collectionID,
48 "tokenId", string(tid),
49 "admin", unsafe.PreviousRealm().Address().String(),
50 )
51}
52
53// SetFeeRecipient updates the address that receives platform fees.
54func SetFeeRecipient(cur realm, addr address) {
55 assertAdmin()
56 feeRecipient = addr
57 chain.Emit("FeeRecipientChanged", "newRecipient", addr.String())
58}