Search Apps Documentation Source Content File Folder Download Copy Actions Download

config.gno

1.47 Kb ยท 70 lines
 1package block
 2
 3import (
 4	"chain"
 5	"chain/runtime"
 6
 7	"gno.land/p/nt/ufmt"
 8)
 9
10const (
11	SetCreatorBPSEvent = "SetCreatorBPS"
12	SetListLimitEvent  = "SetListLimit"
13)
14
15var (
16	// creatorBPS is the basis points (1/10000) that goes to block creator on mint
17	// Default: 4000 = 40%
18	creatorBPS int = 4000
19	listLimit  int = 1000 // Max items per list query
20)
21
22// SetCreatorBPS sets the creator revenue share in basis points (admin only)
23// BPS must be between 0 and 10000 (0% to 100%)
24func SetCreatorBPS(cur realm, bps int) {
25	caller := runtime.PreviousRealm().Address()
26	assertIsAdmin(caller)
27
28	if bps < 0 || bps > 10000 {
29		panic("creator bps must be between 0 and 10000")
30	}
31
32	oldBPS := creatorBPS
33	creatorBPS = bps
34
35	chain.Emit(
36		SetCreatorBPSEvent,
37		"admin", caller.String(),
38		"oldBPS", ufmt.Sprintf("%d", oldBPS),
39		"newBPS", ufmt.Sprintf("%d", 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	caller := runtime.PreviousRealm().Address()
51	assertIsAdmin(caller)
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		"admin", caller.String(),
62		"oldLimit", ufmt.Sprintf("%d", oldLimit),
63		"newLimit", ufmt.Sprintf("%d", limit),
64	)
65}
66
67// GetListLimit returns the max items per list query
68func GetListLimit() int {
69	return listLimit
70}