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

fix: reducible_balance to return liquid minus ED in case of Preserve preservation #987

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
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
Loading