config.gno
1.44 Kb · 69 lines
1package block
2
3import (
4 "chain"
5 "strconv"
6
7 "gno.land/p/akkadia/v0/accesscontrol"
8 "gno.land/r/akkadia/v0/admin"
9)
10
11const (
12 SetCreatorBPSEvent = "SetCreatorBPS"
13 SetListLimitEvent = "SetListLimit"
14)
15
16var (
17 // creatorBPS is the basis points (1/10000) that goes to block creator on mint
18 // Default: 4000 = 40%
19 creatorBPS int = 4000
20 listLimit int = 100 // Max items per list query
21)
22
23// SetCreatorBPS sets the creator revenue share in basis points (admin only)
24// BPS must be between 0 and 10000 (0% to 100%)
25func SetCreatorBPS(cur realm, bps int) {
26 assertNotFrozen()
27 accesscontrol.AssertIsAdmin(0, cur, admin.IsAdmin)
28
29 if bps < 0 || bps > 10000 {
30 panic("creator bps must be between 0 and 10000")
31 }
32
33 oldBPS := creatorBPS
34 creatorBPS = bps
35
36 chain.Emit(
37 SetCreatorBPSEvent,
38 "oldBPS", strconv.Itoa(oldBPS),
39 "newBPS", strconv.Itoa(bps),
40 )
41}
42
43// GetCreatorBPS returns the current creator revenue share in basis points
44func GetCreatorBPS() int {
45 return creatorBPS
46}
47
48// SetListLimit sets the max items per list query (admin only)
49func SetListLimit(cur realm, limit int) {
50 assertNotFrozen()
51 accesscontrol.AssertIsAdmin(0, cur, admin.IsAdmin)
52 if limit < 1 {
53 panic("limit must be at least 1")
54 }
55
56 oldLimit := listLimit
57 listLimit = limit
58
59 chain.Emit(
60 SetListLimitEvent,
61 "oldLimit", strconv.Itoa(oldLimit),
62 "newLimit", strconv.Itoa(limit),
63 )
64}
65
66// GetListLimit returns the max items per list query
67func GetListLimit() int {
68 return listLimit
69}