Skip to content

Commit

Permalink
Merge pull request #6 from brson/zero-allowance
Browse files Browse the repository at this point in the history
Fix 0 amount bug in spend_allowance
  • Loading branch information
spiraldevp authored Mar 28, 2024
2 parents 16da19d + 59e2715 commit 5f018b4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions contracts/src/c_pool/allowance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ pub fn spend_allowance(e: &Env, from: Address, spender: Address, amount: i128) {
if allowance.amount < amount {
panic_with_error!(&e, Error::ErrInsufficientAllowance);
}
write_allowance(
e,
from,
spender,
allowance.amount - amount,
allowance.expiration_ledger,
);
if amount > 0 {
write_allowance(
e,
from,
spender,
allowance.amount - amount,
allowance.expiration_ledger,
);
}
}

0 comments on commit 5f018b4

Please sign in to comment.