testblog.gno
0.80 Kb · 32 lines
1package testblog1780751539
2
3import "gno.land/p/nt/bptree/v0"
4
5var moderatorList = bptree.NewBPTree32()
6
7// AddModerator marque addr comme modérateur.
8func AddModerator(_ realm, addr string) {
9 moderatorList.Set(addr, true)
10}
11
12// RemoveModerator reproduit le bug du blog : Set(false) au lieu de Remove.
13func RemoveModerator(_ realm, addr string) {
14 moderatorList.Set(addr, false)
15}
16
17// isModerator reproduit le bug : teste only 'found', pas la valeur.
18func isModerator(addr string) bool {
19 _, found := moderatorList.Get(addr)
20 return found
21}
22
23// ModOnlyAction panique si l'appelant n'est pas modérateur.
24func ModOnlyAction(cur realm) string {
25 caller := cur.Previous().Address()
26 if !isModerator(caller.String()) {
27 panic("not moderator")
28 }
29 return "executed"
30}
31
32func Render(_ string) string { return "testblog" }