Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add new asserts to set reason #268

Merged
Merged
Changes from all commits
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
17 changes: 12 additions & 5 deletions contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ pub mod Fund {
fn get_name(self: @ContractState) -> ByteArray {
return self.name.read();
}
fn set_reason(ref self: ContractState, reason: ByteArray) {
let caller = get_caller_address();
assert!(self.owner.read() == caller, "You are not the owner");
self.reason.write(reason);
fn set_reason(ref self: ContractState, reason: ByteArray) {
EmmanuelAR marked this conversation as resolved.
Show resolved Hide resolved
let caller = get_caller_address();
let valid_address_1 = contract_address_const::<FundManagerConstants::VALID_ADDRESS_1>();
let valid_address_2 = contract_address_const::<FundManagerConstants::VALID_ADDRESS_2>();

assert!(
self.owner.read() == caller || valid_address_1 == caller || valid_address_2 == caller,
"You must be an owner or admin to perform this action"
);

self.reason.write(reason);
}
fn get_reason(self: @ContractState) -> ByteArray {
return self.reason.read();
Expand Down Expand Up @@ -287,4 +294,4 @@ pub mod Fund {
}
}
}
}
}
Loading