You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The `admin` sets `MANAGER_ROLE` as the admin role for `GUARDIAN_ROLE` using `set_role_admin()`
78
+
2. The `admin` grants the `MANAGER_ROLE` role to the `manager` account
79
+
3. The `manager` can now grant/revoke the `GUARDIAN_ROLE` role to other accounts without requiring admin intervention
80
+
34
81
### Role Enumeration
35
82
36
83
The system tracks account-role pairs in storage with additional enumeration logic:
@@ -41,6 +88,78 @@ The system tracks account-role pairs in storage with additional enumeration logi
41
88
42
89
Roles exist only through their relationships with accounts, so a role with zero accounts is indistinguishable from a role that never existed.
43
90
91
+
## Procedural Macros
92
+
93
+
The module includes several procedural macros to simplify authorization checks in your contract functions. These macros are divided into two categories:
94
+
95
+
### Authorization-Enforcing Macros
96
+
97
+
These macros automatically call `require_auth()` on the specified account before executing the function:
98
+
99
+
#### @only_admin
100
+
101
+
Restricts access to the contract admin only:
102
+
103
+
```rust
104
+
#[only_admin]
105
+
pubfnadmin_function(e:&Env) {
106
+
// Only the admin can call this function
107
+
// require_auth() is automatically called
108
+
}
109
+
```
110
+
111
+
#### @only_role
112
+
113
+
Restricts access to accounts with a specific role:
0 commit comments