Skip to content

Commit

Permalink
fix bug with reducible balance when using preserve mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Apr 24, 2024
1 parent c1fbd5a commit 93e2967
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"xcm-support",
"xcm",
"xtokens",
"rate-limit",
]

resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion tokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "orml-tokens"
description = "Fungible tokens module that implements `MultiCurrency` trait."
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens"
license = "Apache-2.0"
version = "0.8.0"
version = "0.8.1"
authors = ["Laminar Developers <[email protected]>"]
edition = "2021"

Expand Down
4 changes: 3 additions & 1 deletion tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,9 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
let a = Self::accounts(who, asset_id);
// Liquid balance is what is neither reserved nor locked/frozen.
let liquid = a.free.saturating_sub(a.frozen);
if frame_system::Pallet::<T>::can_dec_provider(who) && !matches!(preservation, Preservation::Protect) {
if frame_system::Pallet::<T>::can_dec_provider(who)
&& !matches!(preservation, Preservation::Protect | Preservation::Preserve)
{
liquid
} else {
// `must_remain_to_exist` is the part of liquid balance which must remain to
Expand Down
9 changes: 9 additions & 0 deletions tokens/src/tests_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ fn fungibles_inspect_trait_should_work() {
),
98
);
assert_eq!(
<Tokens as fungibles::Inspect<_>>::reducible_balance(
DOT,
&ALICE,
Preservation::Preserve,
Fortitude::Polite
),
98
);
assert_ok!(
<Tokens as fungibles::Inspect<_>>::can_deposit(DOT, &ALICE, 1, Provenance::Extant).into_result()
);
Expand Down

0 comments on commit 93e2967

Please sign in to comment.