diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3c0f5916d..b4afe49cf 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -37,7 +37,6 @@ jobs: tar -zxvf cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz -C $HOME/.cargo/bin make Cargo.toml cargo update - cargo update -p frame-support-procedural --precise 30.0.2 cargo tarpaulin --verbose --no-fail-fast --workspace --timeout 300 --out Xml - name: Upload to codecov.io uses: codecov/codecov-action@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b07dc772..dfe572303 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,9 +34,7 @@ jobs: - name: Install clippy run: rustup component add clippy - name: Update - run: | - cargo update - cargo update -p frame-support-procedural --precise 30.0.2 + run: cargo update - name: Run clippy run: cargo clippy -- -D warnings - name: Check for Wasm diff --git a/.github/workflows/zepter.yml b/.github/workflows/zepter.yml index 1fccac7b0..e2cbd94d6 100644 --- a/.github/workflows/zepter.yml +++ b/.github/workflows/zepter.yml @@ -28,8 +28,6 @@ jobs: - name: Install Zepter run: cargo install zepter --version 0.15.0 --locked -q -f --no-default-features && zepter --version - run: make Cargo.toml - - run: | - cargo update - cargo update -p frame-support-procedural --precise 30.0.2 + - run: cargo update - name: Check Rust features run: make dev-features-check diff --git a/Cargo.dev.toml b/Cargo.dev.toml index 3111011e6..0c7e48623 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -37,35 +37,35 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive serde = { version = "1.0.189" } parity-scale-codec = { version = "3.6.5", default-features = false, features = ["max-encoded-len"] } -cumulus-pallet-xcm = { version = "0.16.0", default-features = false } -cumulus-primitives-core = { version = "0.15.0", default-features = false } -frame-benchmarking = { version = "37.0.0", default-features = false } -frame-support = { version = "37.0.0", default-features = false } -frame-system = { version = "37.0.0", default-features = false } -pallet-balances = { version = "38.0.0", default-features = false } -pallet-elections-phragmen = { version = "38.0.0", default-features = false } -pallet-message-queue = { version = "40.0.0", default-features = false } -pallet-preimage = { version = "37.0.0", default-features = false } -pallet-root-testing = { version = "13.0.0", default-features = false } -pallet-scheduler = { version = "38.0.0", default-features = false } -pallet-timestamp = { version = "36.0.0", default-features = false } -pallet-treasury = { version = "36.0.0", default-features = false } -pallet-xcm = { version = "16.0.0", default-features = false } +cumulus-pallet-xcm = { version = "0.17.0", default-features = false } +cumulus-primitives-core = { version = "0.16.0", default-features = false } +frame-benchmarking = { version = "38.0.0", default-features = false } +frame-support = { version = "38.0.0", default-features = false } +frame-system = { version = "38.0.0", default-features = false } +pallet-balances = { version = "39.0.0", default-features = false } +pallet-elections-phragmen = { version = "39.0.0", default-features = false } +pallet-message-queue = { version = "41.0.1", default-features = false } +pallet-preimage = { version = "38.0.0", default-features = false } +pallet-root-testing = { version = "14.0.0", default-features = false } +pallet-scheduler = { version = "39.0.0", default-features = false } +pallet-timestamp = { version = "37.0.0", default-features = false } +pallet-treasury = { version = "37.0.0", default-features = false } +pallet-xcm = { version = "17.0.0", default-features = false } polkadot-parachain-primitives = { version = "14.0.0", default-features = false } -polkadot-runtime-common = { version = "16.0.0", default-features = false } -polkadot-runtime-parachains = { version = "16.0.0", default-features = false } +polkadot-runtime-common = { version = "17.0.0", default-features = false } +polkadot-runtime-parachains = { version = "17.0.1", default-features = false } sp-api = { version = "34.0.0", default-features = false } sp-application-crypto = { version = "38.0.0", default-features = false } sp-arithmetic = { version = "26.0.0", default-features = false } sp-core = { version = "34.0.0", default-features = false } sp-io = { version = "38.0.0", default-features = false } -sp-runtime = { version = "39.0.0", default-features = false } +sp-runtime = { version = "39.0.1", default-features = false } sp-runtime-interface = { version = "28.0.0", default-features = false } -sp-staking = { version = "34.0.0", default-features = false } +sp-staking = { version = "36.0.0", default-features = false } sp-std = { version = "14.0.0", default-features = false } sp-storage = { version = "21.0.0", default-features = false } -xcm = { version = "14.1.0", package = "staging-xcm", default-features = false } -xcm-builder = { version = "16.0.0", package = "staging-xcm-builder", default-features = false } -xcm-executor = { version = "16.0.0", package = "staging-xcm-executor", default-features = false } +xcm = { version = "14.2.0", package = "staging-xcm", default-features = false } +xcm-builder = { version = "17.0.1", package = "staging-xcm-builder", default-features = false } +xcm-executor = { version = "17.0.0", package = "staging-xcm-executor", default-features = false } -xcm-simulator = { version = "16.0.0" } +xcm-simulator = { version = "17.0.0" } diff --git a/asset-registry/Cargo.toml b/asset-registry/Cargo.toml index 4d39bd07e..11a50e1a2 100644 --- a/asset-registry/Cargo.toml +++ b/asset-registry/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-asset-registry" description = "Registry for (foreign) assets" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/asset-registry" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Interlay Ltd, etc"] edition = "2021" @@ -27,7 +27,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } # for runtime-benchmarks polkadot-runtime-common = { workspace = true, optional = true } diff --git a/auction/Cargo.toml b/auction/Cargo.toml index 6135e6b75..156ad892d 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-auction" description = "Auction module that implements `Auction` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 56a2e7c99..8327255f0 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-authority" description = "Utility pallet to perform ROOT calls in a PoA network" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/auction" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index 325f8f4c5..fab80323d 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-benchmarking" description = "Provide macro to benchmark Substrate runtime." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/benchmarking" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/build-script-utils/Cargo.toml b/build-script-utils/Cargo.toml index 101f3a6aa..e87d66c70 100644 --- a/build-script-utils/Cargo.toml +++ b/build-script-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-build-script-utils" description = "Crate with utility functions for `build.rs` scripts." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/build-script-utils" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Parity Technologies ", "Laminar Developers "] edition = "2021" diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index 19b672231..5b711c1f9 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-currencies" description = "Provide `MultiCurrency` implementation using `pallet-balances` and `orml-tokens` module." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/currencies" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" @@ -18,8 +18,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } -orml-utilities = { path = "../utilities", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } +orml-utilities = { path = "../utilities", version = "1.1.0", default-features = false } [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index 8649c34fb..29a85012b 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-gradually-update" description = "Provides way to adjust numeric parameter gradually over a period of time." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/gradually-update" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/nft/Cargo.toml b/nft/Cargo.toml index 7f44ccf0c..9e3af75b4 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-nft" description = "Non-fungible token pallet provides basic functions to create and manager NFT" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/nft" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 729ab5f11..d5f45ac8a 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-oracle" description = "Oracle module that makes off-chain data available on-chain." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/oracle" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" @@ -20,8 +20,8 @@ sp-runtime = { workspace = true } sp-std = { workspace = true } frame-benchmarking = { workspace = true, optional = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } -orml-utilities = { path = "../utilities", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } +orml-utilities = { path = "../utilities", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true } diff --git a/oracle/runtime-api/Cargo.toml b/oracle/runtime-api/Cargo.toml index 1bd7f6e44..db12b5d4e 100644 --- a/oracle/runtime-api/Cargo.toml +++ b/oracle/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-oracle-runtime-api" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/parameters/Cargo.toml b/parameters/Cargo.toml index 4cebb99ce..1715f98a2 100644 --- a/parameters/Cargo.toml +++ b/parameters/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-parameters" description = "Offer a centra place to store and configure parameters." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/parameters" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-runtime = { workspace = true } sp-core = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/payments/Cargo.toml b/payments/Cargo.toml index fefcdf068..c4c2fc8e6 100644 --- a/payments/Cargo.toml +++ b/payments/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Virto Network "] edition = '2021' name = "orml-payments" -version = "1.0.0" +version = "1.1.0" license = "Apache-2.0" homepage = "https://github.com/virto-network/virto-node" repository = "https://github.com/virto-network/virto-node" @@ -20,7 +20,7 @@ frame-system = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = {path = "../traits", version = "1.0.0", default-features = false } +orml-traits = {path = "../traits", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true } diff --git a/rate-limit/Cargo.toml b/rate-limit/Cargo.toml index 21943c068..b046b68cf 100644 --- a/rate-limit/Cargo.toml +++ b/rate-limit/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rate-limit" description = "Provides way to config rate limiter for limit some operation." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,8 +19,8 @@ sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } -orml-utilities = { path = "../utilities", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } +orml-utilities = { path = "../utilities", version = "1.1.0", default-features = false } [dev-dependencies] pallet-timestamp = { workspace = true, features = ["std"] } diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index b7cae2ad1..622ec1971 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-rewards" description = "Store and manage shares and rewards" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rewards" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -19,7 +19,7 @@ sp-io = { workspace = true } sp-runtime = { workspace = true, features = ["serde"] } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index ce86d4e66..aae56b0f6 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -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 = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" @@ -19,7 +19,7 @@ sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } [dev-dependencies] pallet-elections-phragmen = { workspace = true, features = ["std"] } diff --git a/tokens/runtime-api/Cargo.toml b/tokens/runtime-api/Cargo.toml index b2f733dc6..574af4462 100644 --- a/tokens/runtime-api/Cargo.toml +++ b/tokens/runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orml-tokens-runtime-api" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" license = "Apache-2.0" diff --git a/tokens/src/imbalances.rs b/tokens/src/imbalances.rs index 7463d8c72..858641130 100644 --- a/tokens/src/imbalances.rs +++ b/tokens/src/imbalances.rs @@ -1,7 +1,7 @@ // wrapping these imbalances in a private module is necessary to ensure absolute // privacy of the inner member. use crate::{Config, TotalIssuance}; -use frame_support::traits::{Get, Imbalance, SameOrOther, TryDrop}; +use frame_support::traits::{tokens::imbalance::TryMerge, Get, Imbalance, SameOrOther, TryDrop}; use sp_runtime::traits::{Saturating, Zero}; use sp_std::{marker, mem, result}; @@ -184,3 +184,14 @@ impl> Drop for NegativeImbalance::mutate(GetCurrencyId::get(), |v| *v = v.saturating_sub(self.0)); } } + +impl> TryMerge for PositiveImbalance { + fn try_merge(self, other: Self) -> Result { + Ok(self.merge(other)) + } +} +impl> TryMerge for NegativeImbalance { + fn try_merge(self, other: Self) -> Result { + Ok(self.merge(other)) + } +} diff --git a/tokens/src/mock.rs b/tokens/src/mock.rs index ad9afb909..56ee19b78 100644 --- a/tokens/src/mock.rs +++ b/tokens/src/mock.rs @@ -56,30 +56,6 @@ thread_local! { ]); } -pub struct TenToFourteen; -impl SortedMembers for TenToFourteen { - fn sorted_members() -> Vec { - TEN_TO_FOURTEEN.with(|v| v.borrow().clone()) - } - #[cfg(feature = "runtime-benchmarks")] - fn add(new: &AccountId) { - TEN_TO_FOURTEEN.with(|v| { - let mut members = v.borrow_mut(); - members.push(new.clone()); - members.sort(); - }) - } -} - -impl ContainsLengthBound for TenToFourteen { - fn max_len() -> usize { - TEN_TO_FOURTEEN.with(|v| v.borrow().len()) - } - fn min_len() -> usize { - 0 - } -} - parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const Burn: Permill = Permill::from_percent(50); diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 4008a3e6c..5a2995fae 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-traits" description = "Shared traits including `BasicCurrency`, `MultiCurrency`, `Auction` and more." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/traits" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" @@ -23,7 +23,7 @@ frame-support = { workspace = true } xcm = { workspace = true } -orml-utilities = { path = "../utilities", version = "1.0.0", default-features = false } +orml-utilities = { path = "../utilities", version = "1.1.0", default-features = false } [features] default = [ "std" ] diff --git a/unknown-tokens/Cargo.toml b/unknown-tokens/Cargo.toml index 06b1aa8ad..eb2720b94 100644 --- a/unknown-tokens/Cargo.toml +++ b/unknown-tokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-unknown-tokens" description = "Unknown tokens module that implements `UnknownAsset` trait." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/unknown-tokens" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -18,7 +18,7 @@ sp-std = { workspace = true } xcm = { workspace = true } -orml-xcm-support = { path = "../xcm-support", version = "1.0.0", default-features = false } +orml-xcm-support = { path = "../xcm-support", version = "1.1.0", default-features = false } [dev-dependencies] sp-core = { workspace = true, features = ["std"] } diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index fd4f7ca0e..3a869043e 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-utilities" description = "Various utilities including `FixedU128` and `LinkedList`." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/utilities" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 21aeea635..83e8e828f 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-vesting" description = "Provides scheduled balance locking mechanism, in a *graded vesting* way." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/vesting" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Laminar Developers "] edition = "2021" diff --git a/xcm-mock-message-queue/Cargo.toml b/xcm-mock-message-queue/Cargo.toml index f43825d55..1fed7061d 100644 --- a/xcm-mock-message-queue/Cargo.toml +++ b/xcm-mock-message-queue/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-mock-message-queue" description = "XCM Mock Message Qeueu for XCM Simulator tests" repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-mock-message-queue" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml index 4057c14c0..9a3d4cc3f 100644 --- a/xcm-support/Cargo.toml +++ b/xcm-support/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm-support" description = "Supporting module for XCM integration." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-support" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -17,7 +17,7 @@ sp-std = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } -orml-traits = { path = "../traits", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false } [features] default = [ "std" ] diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 5eb830c6b..572238352 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xcm" description = "XCM message helpers." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml index 0c56c663d..f42ba1b71 100644 --- a/xtokens/Cargo.toml +++ b/xtokens/Cargo.toml @@ -3,7 +3,7 @@ name = "orml-xtokens" description = "Cross-chain token transfer." repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xtokens" license = "Apache-2.0" -version = "1.0.0" +version = "1.1.0" authors = ["Acala Developers"] edition = "2021" @@ -26,8 +26,8 @@ xcm = { workspace = true } xcm-executor = { workspace = true } # orml -orml-traits = { path = "../traits", version = "1.0.0", default-features = false} -orml-xcm-support = { path = "../xcm-support", version = "1.0.0", default-features = false } +orml-traits = { path = "../traits", version = "1.1.0", default-features = false} +orml-xcm-support = { path = "../xcm-support", version = "1.1.0", default-features = false } [dev-dependencies] # substrate diff --git a/xtokens/src/mock/para.rs b/xtokens/src/mock/para.rs index b879e539c..2df1f7b83 100644 --- a/xtokens/src/mock/para.rs +++ b/xtokens/src/mock/para.rs @@ -6,7 +6,7 @@ use crate as orml_xtokens; use frame_support::{ construct_runtime, derive_impl, ensure, parameter_types, - traits::{ConstU128, ConstU32, Contains, Everything, Get, Nothing}, + traits::{ConstU128, ConstU32, Contains, ContainsPair, Everything, Get, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; @@ -16,7 +16,7 @@ use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, }; -use sp_std::cell::RefCell; +use sp_std::{cell::RefCell, marker::PhantomData}; use xcm::v4::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, NativeAsset, ParentIsPreset, RelayChainAsNative, @@ -26,8 +26,11 @@ use xcm_builder::{ use xcm_executor::{Config, XcmExecutor}; use crate::mock::AllTokensAreCreatedEqualToWeight; -use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key, RateLimiterError}; -use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; +use orml_traits::{ + location::{AbsoluteReserveProvider, Reserve}, + parameter_type_with_key, RateLimiterError, +}; +use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter}; pub type AccountId = AccountId32; @@ -117,6 +120,25 @@ parameter_types! { pub const MaxAssetsIntoHolding: u32 = 64; } +pub struct MultiNativeAsset(PhantomData); +impl ContainsPair for MultiNativeAsset +where + ReserveProvider: Reserve, +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + if let Some(ref reserve) = ReserveProvider::reserve(asset) { + if reserve == origin { + return true; + } + } + // allow parachain to be reserved of relay to bypass https://github.com/paritytech/polkadot-sdk/pull/5660 + if asset.id.0 == Location::parent() { + return true; + } + false + } +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall; diff --git a/xtokens/src/mock/para_relative_view.rs b/xtokens/src/mock/para_relative_view.rs index f912eaf58..edc7f0bac 100644 --- a/xtokens/src/mock/para_relative_view.rs +++ b/xtokens/src/mock/para_relative_view.rs @@ -3,7 +3,7 @@ use crate as orml_xtokens; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{ConstU128, ConstU32, Contains, Everything, Get, Nothing}, + traits::{ConstU128, ConstU32, Contains, ContainsPair, Everything, Get, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; @@ -12,6 +12,7 @@ use sp_runtime::{ traits::{Convert, IdentityLookup}, AccountId32, BoundedVec, }; +use sp_std::marker::PhantomData; use xcm::v4::{prelude::*, Weight}; use xcm_builder::{ AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, @@ -22,10 +23,10 @@ use xcm_executor::{Config, XcmExecutor}; use crate::mock::AllTokensAreCreatedEqualToWeight; use orml_traits::{ - location::{AbsoluteReserveProvider, RelativeReserveProvider}, + location::{AbsoluteReserveProvider, RelativeReserveProvider, Reserve}, parameter_type_with_key, }; -use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; +use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter}; pub type AccountId = AccountId32; @@ -115,6 +116,25 @@ parameter_types! { pub const MaxAssetsIntoHolding: u32 = 64; } +pub struct MultiNativeAsset(PhantomData); +impl ContainsPair for MultiNativeAsset +where + ReserveProvider: Reserve, +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + if let Some(ref reserve) = ReserveProvider::reserve(asset) { + if reserve == origin { + return true; + } + } + // allow parachain to be reserved of relay to bypass https://github.com/paritytech/polkadot-sdk/pull/5660 + if asset.id.0 == Location::parent() { + return true; + } + false + } +} + pub struct XcmConfig; impl Config for XcmConfig { type RuntimeCall = RuntimeCall;