Skip to content

Commit

Permalink
fix bug of reducible_balance so we return the balance minus ED in cas…
Browse files Browse the repository at this point in the history
…e of Preserve preservation (#987)
  • Loading branch information
dmoka authored Apr 6, 2024
1 parent 2dbcd1d commit b8293cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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 b8293cb

Please sign in to comment.