Search Apps Documentation Source Content File Folder Download Copy Actions Download

protocol.gno

0.69 Kb · 44 lines
 1package admin
 2
 3import (
 4	"chain"
 5	"chain/runtime/unsafe"
 6
 7	"gno.land/p/g1nqnrt3aldzhu6zzeg75yw97wvavqy7wr77g56q/deploy-test/v2/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	assertNotFrozen()
29	accesscontrol.AssertIsAdmin(0, cur, IsAdmin)
30
31	assertValidAddress(addr)
32	oldAddr := protocolAddr
33	protocolAddr = addr
34
35	chain.Emit(
36		SetProtocolEvent,
37		"oldAddr", oldAddr.String(),
38		"newAddr", addr.String(),
39	)
40}
41
42func IsProtocol(address address) bool {
43	return address == protocolAddr
44}