Skip to content

Commit

Permalink
safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
mustermeiszer committed Sep 11, 2024
1 parent 5d03380 commit 2c2b84c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pallets/token-mux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,22 @@ pub mod pallet {
}

pub(crate) fn prepare_and(
currency_a: &T::CurrencyId,
currency_b: &T::CurrencyId,
currency_from: &T::CurrencyId,
currency_to: &T::CurrencyId,
amount: T::Balance,
and: FnOnce(T::Balance) -> DispatchResult,
) -> DispatchResult {
if currency_a.is_local_representation_of(&currency_b) {
and(Self::adjust_amount(currency_a, currency_b, amount)?)?;
match (
currency_a.is_local_representation_of(&currency_b),
currency_b.is_local_representation_of(&currency_a),
) {
(true, false) => {
mint()
and(amount)
},
(false, true) => and(Self::adjust_amount(currency_a, currency_b, amount)?)?,
(_, _) => Err(Error::<T>::NoLocalRepresentation.into()),
}

if currency_b.is_local_representation_of(&currency_a) {}

Err(Error::<T>::NoLocalRepresentation.into())
}
}
}

0 comments on commit 2c2b84c

Please sign in to comment.