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 bug - reducable balance deduct ED when mode is Preserve #3

Open
wants to merge 10 commits into
base: polkadot-v1.1.0
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2023-04-15
toolchain: nightly-x86_64-unknown-linux-gnu
components: rustfmt
target: wasm32-unknown-unknown
- name: Install Wasm toolchain
Expand All @@ -39,8 +39,6 @@ jobs:
run: rustup component add clippy
- name: Update
run: cargo update
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Check for Wasm
run: make dev-check
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use frame_system::{ensure_signed, pallet_prelude::*};
use orml_traits::{Auction, AuctionHandler, AuctionInfo, Change};
use sp_runtime::{
traits::{AtLeast32BitUnsigned, Bounded, CheckedAdd, MaybeSerializeDeserialize, Member, One, Zero},
DispatchError, DispatchResult,
DispatchResult,
};

mod mock;
Expand Down
5 changes: 2 additions & 3 deletions authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
#![allow(clippy::borrowed_box)]
#![allow(clippy::unused_unit)]

use codec::MaxEncodedLen;
use frame_support::{
dispatch::PostDispatchInfo,
dispatch::{DispatchClass, GetDispatchInfo, Pays},
pallet_prelude::*,
traits::{
schedule::{v1::Named as ScheduleNamed, DispatchTime, Priority},
EitherOfDiverse, EnsureOrigin, Get, IsType, OriginTrait,
EitherOfDiverse, IsType, OriginTrait,
},
};
use frame_system::{pallet_prelude::*, EnsureRoot, EnsureSigned};
Expand Down Expand Up @@ -72,7 +71,7 @@ mod helper {
use std::cell::RefCell;

thread_local! {
static NESTED_MAX_ENCODED_LEN: RefCell<bool> = RefCell::new(false);
static NESTED_MAX_ENCODED_LEN: RefCell<bool> = const { RefCell::new(false) };
}

pub fn set_nested_max_encoded_len(val: bool) {
Expand Down
2 changes: 1 addition & 1 deletion currencies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-feature
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }

orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.4.1-dev" }
orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.4.2-dev" }

[features]
default = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions currencies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ use orml_traits::{
};
use orml_utilities::with_transaction_result;
use sp_runtime::{
traits::{CheckedSub, MaybeSerializeDeserialize, StaticLookup, Zero},
DispatchError, DispatchResult,
traits::{CheckedSub, StaticLookup, Zero},
DispatchResult,
};
use sp_std::{fmt::Debug, marker, result};

Expand Down
2 changes: 1 addition & 1 deletion nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_system::pallet_prelude::*;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Zero},
ArithmeticError, DispatchError, DispatchResult, RuntimeDebug,
ArithmeticError, DispatchResult, RuntimeDebug,
};
use sp_std::vec::Vec;

Expand Down
2 changes: 1 addition & 1 deletion payments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ serde = "1.0.136"
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false , branch = "release-polkadot-v1.1.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false , branch = "release-polkadot-v1.1.0" }

orml-tokens = { path = "../tokens", version = "0.4.1-dev", default-features = false }
orml-tokens = { path = "../tokens", version = "0.4.2-dev", default-features = false }

[features]
default = ['std']
Expand Down
2 changes: 1 addition & 1 deletion rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_runtime::{
traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize, Member, Saturating, UniqueSaturatedInto, Zero},
FixedPointOperand, RuntimeDebug, SaturatedConversion,
};
use sp_std::{borrow::ToOwned, collections::btree_map::BTreeMap, fmt::Debug, prelude::*};
use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, prelude::*};

/// The Reward Pool Info.
#[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
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.4.1-dev"
version = "0.4.2-dev"
authors = ["Laminar Developers <[email protected]>"]
edition = "2021"

Expand Down
6 changes: 4 additions & 2 deletions tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use sp_runtime::{
AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, Saturating,
StaticLookup, Zero,
},
ArithmeticError, DispatchError, DispatchResult, FixedPointOperand, RuntimeDebug, TokenError,
ArithmeticError, DispatchResult, FixedPointOperand, RuntimeDebug, TokenError,
};
use sp_std::{cmp, convert::Infallible, marker, prelude::*, vec::Vec};

Expand Down Expand Up @@ -1806,7 +1806,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
5 changes: 1 addition & 4 deletions traits/src/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pub use num_traits::{
Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedShl, CheckedShr, CheckedSub, One, Signed, Zero,
};
use sp_std::{
self,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign},
};
use sp_std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Shl, Shr, Sub, SubAssign};

/// A meta trait for arithmetic.
///
Expand Down
6 changes: 1 addition & 5 deletions traits/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ use sp_runtime::{
traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize},
DispatchError, DispatchResult,
};
use sp_std::{
cmp::{Eq, Ordering, PartialEq},
fmt::Debug,
result,
};
use sp_std::{cmp::Ordering, fmt::Debug, result};

/// Abstraction over a fungible multi-currency system.
pub trait MultiCurrency<AccountId> {
Expand Down
5 changes: 1 addition & 4 deletions traits/src/xcm_transfer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
use xcm::{
v3::{prelude::*, Weight},
VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation,
};
use xcm::{v3::prelude::*, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation};
pub struct Transferred<AccountId> {
pub sender: AccountId,
pub assets: MultiAssets,
Expand Down
1 change: 0 additions & 1 deletion utilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use frame_support::storage::{with_transaction, TransactionOutcome};
use sp_runtime::DispatchError;
use sp_std::result::Result;

pub mod offchain_worker;
pub mod ordered_set;
Expand Down
10 changes: 2 additions & 8 deletions xcm-support/src/currency_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ use sp_runtime::{
traits::{Convert, MaybeSerializeDeserialize, SaturatedConversion},
DispatchError,
};
use sp_std::{
cmp::{Eq, PartialEq},
fmt::Debug,
marker::PhantomData,
prelude::*,
result,
};
use sp_std::{fmt::Debug, marker::PhantomData, prelude::*, result};

use xcm::v3::{prelude::*, Error as XcmError, MultiAsset, MultiLocation, Result};
use xcm::v3::{prelude::*, Error as XcmError, Result};
use xcm_executor::{
traits::{ConvertLocation, MatchesFungible, TransactAsset},
Assets,
Expand Down
Loading