Search Apps Documentation Source Content File Folder Download Copy Actions Download

doc.gno

1.93 Kb ยท 59 lines
 1// Package accesscontrol implements a role-based access control (RBAC) system for Gno applications.
 2// It provides functionality to create, assign, revoke, and transfer roles.
 3//
 4// # Usage
 5//
 6// Import the `gno.land/p/demo/accesscontrol` package to manage roles within your Gno realm. You can create roles,
 7// assign them to users, revoke them, and transfer role ownership.
 8//
 9// Roles can be created by the contract owner using `CreateRole`. Each role is uniquely identified by its name.
10//
11//	CreateRole("editor")
12//
13// Use `GrantRole` to assign a role to a user, and `RevokeRole` to remove a role from a user.
14//
15//	GrantRole("editor", userAddress)
16//
17//	RevokeRole("editor", userAddress)
18//
19// Users can renounce their roles using `RenounceRole`, voluntarily removing themselves from a role.
20//
21//	RenounceRole("editor")
22//
23// You can look up a role by name with `FindRole`.
24//
25// FindRole("editor")
26//
27// Role ownership can be transferred using `SetRoleAdmin`.
28//
29// SetRoleAdmin(newAdminAddress)
30//
31// Key events
32// - `RoleCreatedEvent`: Triggered when a new role is created
33// Key includes:
34// `roleName` (name of the role)
35// `sender` (address of the sender)
36//
37// - `RoleGrantedEvent`: Triggered when a role is granted to an account
38// Key includes:
39// `roleName` (name of the role)
40// `account` (address of the account)
41// `sender` (address of the sender)
42//
43// - `RoleRevokedEvent`: Triggered when a role is revoked from an account
44// Key includes:
45// `roleName` (name of the role)
46// `account` (address of the account)
47// `sender` (address of the sender)
48//
49// - `RoleRenouncedEvent`: Triggered when a role is renounced by an account
50// Key includes:
51// `roleName` (name of the role)
52// `account` (address of the account)
53//
54// - `RoleSetEvent`: Triggered when a role's administrator is set or changed
55// Key includes:
56// `roleName` (name of the role)
57// `newAdmin` (address of the new administrator)
58// `sender` (address of the sender)
59package accesscontrol