Skip to content

Commit

Permalink
add caller check is depositor on fund
Browse files Browse the repository at this point in the history
  • Loading branch information
alyn509 committed Sep 12, 2023
1 parent ae01fc4 commit 617d153
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/examples/digital-cash/src/digital_cash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ pub trait DigitalCash {
fn fund(&self, address: ManagedAddress, valability: u64) {
let deposit_mapper = self.deposit(&address);
require!(!deposit_mapper.is_empty(), FEES_NOT_COVERED_ERR_MSG);
let depositor = deposit_mapper.get().depositor_address;
require!(
self.blockchain().get_caller() == depositor,
"invalid depositor"
);

let egld_payment = self.call_value().egld_value().clone_value();
let esdt_payment = self.call_value().all_esdt_transfers().clone_value();
Expand Down

0 comments on commit 617d153

Please sign in to comment.