package admin import ( "chain" "chain/runtime" ) const ( TransferAdminEvent = "TransferAdmin" SetExplorerURLEvent = "SetExplorerURL" ) var ( admin address explorerURL string = "https://app.alpha.akkadia.land" ) func init() { caller := runtime.OriginCaller() admin = caller } func GetAdmin() address { return admin } func TransferAdmin(cur realm, address address) { caller := runtime.OriginCaller() if caller != admin { panic("admin access required to transfer admin") } if !address.IsValid() { panic("invalid address") } prevAdmin := admin chain.Emit( TransferAdminEvent, "from", prevAdmin.String(), "to", address.String(), ) admin = address } func IsAdmin(address address) bool { return address == admin } // SetExplorerURL sets the explorer base URL (admin only) func SetExplorerURL(cur realm, url string) { caller := runtime.OriginCaller() if caller != admin { panic("admin access required to set explorer URL") } oldURL := explorerURL explorerURL = url chain.Emit( SetExplorerURLEvent, "admin", caller.String(), "oldURL", oldURL, "newURL", url, ) } // GetExplorerURL returns the explorer base URL func GetExplorerURL() string { return explorerURL }