Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
typo
  • Loading branch information
fbielejec committed Aug 16, 2022
commit d83561ec895189fb564bcb98ce7ccae5a314e40c
16 changes: 8 additions & 8 deletions contracts/access_control/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod access_control {
#[derive(SpreadAllocate)]
pub struct AccessControl {
/// Stores a de-facto hashset of user accounts and their roles
pub priviledges: Mapping<(AccountId, Role), ()>,
pub privileges: Mapping<(AccountId, Role), ()>,
}

#[ink(event)]
Expand Down Expand Up @@ -87,12 +87,12 @@ mod access_control {

/// Initializes the contract.
///
/// caller is granted admin and owner priviledges
/// caller is granted admin and owner privileges
fn new_init(&mut self) {
let caller = Self::env().caller();
let this = Self::env().account_id();
self.priviledges.insert((caller, Role::Admin(this)), &());
self.priviledges.insert((caller, Role::Owner(this)), &());
self.privileges.insert((caller, Role::Admin(this)), &());
self.privileges.insert((caller, Role::Owner(this)), &());
}

/// Gives a role to an account
Expand All @@ -101,11 +101,11 @@ mod access_control {
#[ink(message, selector = 1)]
pub fn grant_role(&mut self, account: AccountId, role: Role) -> Result<()> {
let key = (account, role);
if !self.priviledges.contains(key) {
if !self.privileges.contains(key) {
let caller = self.env().caller();
let this = self.env().account_id();
self.check_role(caller, Role::Admin(this))?;
self.priviledges.insert(key, &());
self.privileges.insert(key, &());

let event = Event::RoleGranted(RoleGranted {
by: caller,
Expand All @@ -126,7 +126,7 @@ mod access_control {
let caller = self.env().caller();
let this = self.env().account_id();
self.check_role(caller, Role::Admin(this))?;
self.priviledges.remove((account, role));
self.privileges.remove((account, role));

let event = Event::RoleRevoked(RoleRevoked {
by: caller,
Expand All @@ -141,7 +141,7 @@ mod access_control {
/// Returns true if account has a role
#[ink(message, selector = 3)]
pub fn has_role(&self, account: AccountId, role: Role) -> bool {
self.priviledges.contains((account, role))
self.privileges.contains((account, role))
}

/// Terminates the contract.
Expand Down
2 changes: 2 additions & 0 deletions contracts/back_to_the_future/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contracts/back_to_the_future/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ crate-type = [
[features]
default = ["std"]
std = [
"access_control/std",
"button/std",
"ink_env/std",
"ink_lang/std",
"ink_lang_codegen/std",
"ink_metadata/std",
"ink_prelude/std",
Expand Down
2 changes: 1 addition & 1 deletion contracts/button/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum GameError {
BeforeDeadline,
/// Returned if button is pressed after the deadline
AfterDeadline,
/// Returned if a call is made from an account with missing access control priviledges
/// Returned if a call is made from an account with missing access control privileges
MissingRole(String),
/// Returned if a call to another contract has failed
ContractCall(String),
Expand Down