Skip to content

Commit c57c1ee

Browse files
authored
Merge pull request #84 from OpenZeppelin/stellar-consistency
caller parameter order
2 parents 966f070 + 90511fa commit c57c1ee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

content/stellar-contracts/access/access-control.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl MyContract {
5050
pub fn __constructor(e: &Env, admin: Address, manager: Address) {
5151
// Set the contract admin
5252
access_control::set_admin(e, &admin);
53-
53+
5454
// 1. Set MANAGER_ROLE as the admin role for GUARDIAN_ROLE:
5555
// accounts with MANAGER_ROLE can manage accounts with GUARDIAN_ROLE
5656
access_control::set_role_admin_no_auth(e, &admin, &GUARDIAN_ROLE, &MANAGER_ROLE);
@@ -62,11 +62,11 @@ impl MyContract {
6262
pub fn manage_guardians(e: &Env, manager: Address, guardian1: Address, guardian2: Address) {
6363
// Manager must be authorized
6464
manager.require_auth();
65-
65+
6666
// 3. Now the manager can grant GUARDIAN_ROLE to other accounts
6767
access_control::grant_role_no_auth(e, &manager, &guardian1, &GUARDIAN_ROLE);
6868
access_control::grant_role_no_auth(e, &manager, &guardian2, &GUARDIAN_ROLE);
69-
69+
7070
// Manager can also revoke GUARDIAN_ROLE
7171
access_control::revoke_role_no_auth(e, &manager, &guardian1, &GUARDIAN_ROLE);
7272
}
@@ -114,7 +114,7 @@ Restricts access to accounts with a specific role:
114114

115115
```rust
116116
#[only_role(caller, "minter")]
117-
pub fn mint(e: &Env, caller: Address, to: Address, token_id: u32) {
117+
pub fn mint(e: &Env, to: Address, token_id: u32, caller: Address) {
118118
// Only accounts with the "minter" role can call this
119119
// require_auth() is automatically called on caller
120120
}
@@ -142,7 +142,7 @@ Checks if an account has a specific role:
142142

143143
```rust
144144
#[has_role(caller, "minter")]
145-
pub fn conditional_mint(e: &Env, caller: Address, to: Address, token_id: u32) {
145+
pub fn conditional_mint(e: &Env, to: Address, token_id: u32, caller: Address) {
146146
// Checks if caller has "minter" role, but doesn't call require_auth()
147147
caller.require_auth(); // Must manually authorize if needed
148148
}
@@ -192,7 +192,7 @@ impl MyContract {
192192
// we want `require_auth()` provided by the macro, since there is no
193193
// `require_auth()` in `Base::mint`.
194194
#[only_role(caller, "minter")]
195-
pub fn mint(e: &Env, caller: Address, to: Address, token_id: u32) {
195+
pub fn mint(e: &Env, to: Address, token_id: u32, caller: Address) {
196196
Base::mint(e, &to, token_id)
197197

198198
}

0 commit comments

Comments
 (0)