Skip to content

Commit

Permalink
Safety check that deposit amounts are positive
Browse files Browse the repository at this point in the history
Even without this, `deposit` should still fail on the `xfer_from`, so it
shouldn't be an issue.
  • Loading branch information
Paul Bellamy committed Jan 9, 2023
1 parent 47c382a commit c05fddf
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions contracts/crowdfund/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl Crowdfund {
}

pub fn deposit(e: Env, user: Identifier, amount: i128) {
assert!(amount > 0, "amount must be positive");
assert!(get_state(&e) == State::Running, "sale is not running");

let recipient = get_recipient(&e);
Expand Down

0 comments on commit c05fddf

Please sign in to comment.