config.gno
0.69 Kb · 40 lines
1package user
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 SetListLimitEvent = "SetListLimit"
13)
14
15var (
16 listLimit int = 100 // Max items per list query
17)
18
19// SetListLimit sets the max items per list query (admin only)
20func SetListLimit(cur realm, limit int) {
21 assertNotFrozen()
22 accesscontrol.AssertIsAdmin(0, cur, admin.IsAdmin)
23 if limit < 1 {
24 panic("limit must be at least 1")
25 }
26
27 oldLimit := listLimit
28 listLimit = limit
29
30 chain.Emit(
31 SetListLimitEvent,
32 "oldLimit", strconv.Itoa(oldLimit),
33 "newLimit", strconv.Itoa(limit),
34 )
35}
36
37// GetListLimit returns the max items per list query
38func GetListLimit() int {
39 return listLimit
40}