config.gno
0.69 Kb ยท 40 lines
1package user
2
3import (
4 "chain"
5 "chain/runtime"
6
7 "gno.land/p/nt/ufmt"
8)
9
10const (
11 SetListLimitEvent = "SetListLimit"
12)
13
14var (
15 listLimit int = 100 // Max items per list query
16)
17
18// SetListLimit sets the max items per list query (admin only)
19func SetListLimit(cur realm, limit int) {
20 caller := runtime.PreviousRealm().Address()
21 assertIsAdmin(caller)
22 if limit < 1 {
23 panic("limit must be at least 1")
24 }
25
26 oldLimit := listLimit
27 listLimit = limit
28
29 chain.Emit(
30 SetListLimitEvent,
31 "caller", caller.String(),
32 "oldLimit", ufmt.Sprintf("%d", oldLimit),
33 "newLimit", ufmt.Sprintf("%d", limit),
34 )
35}
36
37// GetListLimit returns the max items per list query
38func GetListLimit() int {
39 return listLimit
40}