Skip to content

Commit

Permalink
fix: pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HansBhatia committed Jun 23, 2023
1 parent 0782ff7 commit 5f8ebc3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions listings/ch00-introduction/if_else/src/access_control.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@ mod SimpleAccessControl {
use starknet::{get_caller_address,ContractAddress};

struct Storage {
owner: ContractAddress,
_owner: ContractAddress,
}

#[event]
fn welcomeEvent(name: felt252) {}
fn WelcomeEvent(name: felt252) {}

#[constructor]
fn constructor(_address: ContractAddress) {
owner::write(_address);
fn constructor(address: ContractAddress) {
_owner::write(address);
}

#[internal]
fn only_owner() -> bool {
return get_caller_address() == owner::read();
return get_caller_address() == _owner::read();
}

#[external]
fn log_access() {
if(only_owner()) {
welcomeEvent('Welcome Admin!');
WelcomeEvent('Welcome Admin!');
} else {
welcomeEvent('Welcome User!');
WelcomeEvent('Welcome User!');
}
}
}

0 comments on commit 5f8ebc3

Please sign in to comment.