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

types.gno

1.71 Kb · 56 lines
 1package rbac
 2
 3// SystemRole represents a predefined system role that cannot be removed.
 4type SystemRole string
 5
 6const (
 7	ROLE_ADMIN          SystemRole = "admin"
 8	ROLE_DEVOPS         SystemRole = "devops"
 9	ROLE_COMMUNITY_POOL SystemRole = "community_pool"
10	ROLE_GOVERNANCE     SystemRole = "governance"
11	ROLE_GOV_STAKER     SystemRole = "gov_staker"
12	ROLE_XGNS           SystemRole = "xgns"
13	ROLE_POOL           SystemRole = "pool"
14	ROLE_POSITION       SystemRole = "position"
15	ROLE_ROUTER         SystemRole = "router"
16	ROLE_STAKER         SystemRole = "staker"
17	ROLE_EMISSION       SystemRole = "emission"
18	ROLE_LAUNCHPAD      SystemRole = "launchpad"
19	ROLE_PROTOCOL_FEE   SystemRole = "protocol_fee"
20)
21
22// MUST BE IMMUTABLE, DO NOT MODIFY.
23// _systemRoleNames is a map of system role names to SystemRole values by performance.
24var _systemRoleNames = map[string]SystemRole{
25	"admin":          ROLE_ADMIN,
26	"devops":         ROLE_DEVOPS,
27	"community_pool": ROLE_COMMUNITY_POOL,
28	"governance":     ROLE_GOVERNANCE,
29	"gov_staker":     ROLE_GOV_STAKER,
30	"xgns":           ROLE_XGNS,
31	"pool":           ROLE_POOL,
32	"position":       ROLE_POSITION,
33	"router":         ROLE_ROUTER,
34	"staker":         ROLE_STAKER,
35	"emission":       ROLE_EMISSION,
36	"launchpad":      ROLE_LAUNCHPAD,
37	"protocol_fee":   ROLE_PROTOCOL_FEE,
38}
39
40// String returns the string representation of the SystemRole.
41// Returns "Unknown" if the role is not a valid system role.
42func (r SystemRole) String() string {
43	roleName := string(r)
44	if _, ok := _systemRoleNames[roleName]; !ok {
45		return "Unknown"
46	}
47
48	return roleName
49}
50
51// IsSystemRole returns true if roleName is a system role.
52func IsSystemRole(roleName string) bool {
53	_, ok := _systemRoleNames[roleName]
54
55	return ok
56}