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

265 audit pdm 003 test coverage #316

Merged
merged 5 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions pallets/orml-currencies-allowance-extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<T: Config> Pallet<T> {
Approvals::<T>::try_mutate_exists(
(id, &owner, delegate),
|maybe_approved| -> DispatchResult {
let mut approved = maybe_approved.take().ok_or(Error::<T>::Unapproved)?;
let approved = maybe_approved.take().ok_or(Error::<T>::Unapproved)?;
let remaining = approved.checked_sub(&amount).ok_or(Error::<T>::Unapproved)?;

<orml_currencies::Pallet<T> as MultiCurrency<T::AccountId>>::transfer(
Expand All @@ -308,14 +308,13 @@ impl<T: Config> Pallet<T> {
amount,
)?;

if remaining.is_zero() {
// Don't decrement allowance if it is set to the max value (which acts as infinite allowance)
if approved == BalanceOf::<T>::max_value() {
*maybe_approved = Some(approved);
} else if remaining.is_zero() {
*maybe_approved = None;
} else {
//decrement allowance only if it isn't max value (which acts as infinite allowance)
if approved != BalanceOf::<T>::max_value() {
approved = remaining;
}
*maybe_approved = Some(approved);
*maybe_approved = Some(remaining);
}
Ok(())
},
Expand Down
Loading
Loading