package admin import ( "chain" "chain/runtime" ) const ( SetProtocolEvent = "SetProtocol" ) var ( protocolAddr address ) func init() { caller := runtime.OriginCaller() protocolAddr = caller } func GetProtocol() address { return protocolAddr } func SetProtocol(cur realm, addr address) { caller := runtime.OriginCaller() if caller != admin { panic("admin access required to set protocol") } if !addr.IsValid() { panic("invalid address") } oldAddr := protocolAddr protocolAddr = addr chain.Emit( SetProtocolEvent, "admin", caller.String(), "oldAddr", oldAddr.String(), "newAddr", addr.String(), ) } func IsProtocol(address address) bool { return address == protocolAddr }