types.gno
1.58 Kb ยท 54 lines
1package rbac
2
3// SystemRole represents a predefined system role that cannot be removed.
4type SystemRole string
5
6var (
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
22var systemRoleNames = map[string]SystemRole{
23 "admin": ROLE_ADMIN,
24 "devops": ROLE_DEVOPS,
25 "community_pool": ROLE_COMMUNITY_POOL,
26 "governance": ROLE_GOVERNANCE,
27 "gov_staker": ROLE_GOV_STAKER,
28 "xgns": ROLE_XGNS,
29 "pool": ROLE_POOL,
30 "position": ROLE_POSITION,
31 "router": ROLE_ROUTER,
32 "staker": ROLE_STAKER,
33 "emission": ROLE_EMISSION,
34 "launchpad": ROLE_LAUNCHPAD,
35 "protocol_fee": ROLE_PROTOCOL_FEE,
36}
37
38// String returns the string representation of the SystemRole.
39// Returns "Unknown" if the role is not a valid system role.
40func (r SystemRole) String() string {
41 roleName := string(r)
42 if _, ok := systemRoleNames[roleName]; !ok {
43 return "Unknown"
44 }
45
46 return roleName
47}
48
49// IsSystemRole returns true if roleName is a system role.
50func IsSystemRole(roleName string) bool {
51 _, ok := systemRoleNames[roleName]
52
53 return ok
54}