Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

protocol.gno

0.62 Kb · 43 lines
 1package admin
 2
 3import (
 4	"chain"
 5	"chain/runtime/unsafe"
 6
 7	"gno.land/p/akkadia/beta/accesscontrol"
 8)
 9
10const (
11	SetProtocolEvent = "SetProtocol"
12)
13
14var (
15	protocolAddr address
16)
17
18func init() {
19	caller := unsafe.OriginCaller()
20	protocolAddr = caller
21}
22
23func GetProtocol() address {
24	return protocolAddr
25}
26
27func SetProtocol(cur realm, addr address) {
28	accesscontrol.AssertIsAdmin(0, cur, IsAdmin)
29
30	assertValidAddress(addr)
31	oldAddr := protocolAddr
32	protocolAddr = addr
33
34	chain.Emit(
35		SetProtocolEvent,
36		"oldAddr", oldAddr.String(),
37		"newAddr", addr.String(),
38	)
39}
40
41func IsProtocol(address address) bool {
42	return address == protocolAddr
43}