diff --git a/Cargo.dev.toml b/Cargo.dev.toml index a015b096b..a38c164db 100644 --- a/Cargo.dev.toml +++ b/Cargo.dev.toml @@ -14,25 +14,27 @@ members = [ "vesting", "rewards", "nft", + "xtokens", + "xcm-support", ] resolver = "2" [patch.crates-io] -frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -frame-support = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -frame-system = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -pallet-balances = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -pallet-treasury = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-io = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-std = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-trie = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } -sp-version = { git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +pallet-treasury = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } +sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "rococo-v1" } diff --git a/auction/Cargo.toml b/auction/Cargo.toml index 0e767e2e0..5c568933b 100644 --- a/auction/Cargo.toml +++ b/auction/Cargo.toml @@ -10,17 +10,18 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" -sp-io = "3.0.0" +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/authority/Cargo.toml b/authority/Cargo.toml index 31fc4ac45..5d7a393f4 100644 --- a/authority/Cargo.toml +++ b/authority/Cargo.toml @@ -10,18 +10,21 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" -sp-io = "3.0.0" -pallet-scheduler = "3.0.0" +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/benchmarking/Cargo.toml b/benchmarking/Cargo.toml index 12110bd2d..e2ae5e252 100644 --- a/benchmarking/Cargo.toml +++ b/benchmarking/Cargo.toml @@ -11,14 +11,14 @@ edition = "2018" serde = { version = "1.0.111", optional = true } paste = "0.1.16" codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-api = { version = "3.0.0", default-features = false } -sp-runtime-interface = { version = "3.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } -frame-benchmarking = { version = "3.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", rev = "e03ca38d45f438932ec92bf69a40b6b16b6ec643" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 diff --git a/benchmarking/src/lib.rs b/benchmarking/src/lib.rs index d6bcbda56..71c6af4e7 100644 --- a/benchmarking/src/lib.rs +++ b/benchmarking/src/lib.rs @@ -859,7 +859,7 @@ macro_rules! impl_benchmark { closure_to_benchmark()?; } else { // Time the extrinsic logic. - frame_support::debug::trace!( + frame_support::log::trace!( target: "benchmark", "Start Benchmark: {:?}", c ); @@ -872,12 +872,12 @@ macro_rules! impl_benchmark { let elapsed_extrinsic = finish_extrinsic - start_extrinsic; // Commit the changes to get proper write count $crate::benchmarking::commit_db(); - frame_support::debug::trace!( + frame_support::log::trace!( target: "benchmark", "End Benchmark: {} ns", elapsed_extrinsic ); let read_write_count = $crate::benchmarking::read_write_count(); - frame_support::debug::trace!( + frame_support::log::trace!( target: "benchmark", "Read/Write Count {:?}", read_write_count ); diff --git a/currencies/Cargo.toml b/currencies/Cargo.toml index 7708e5636..a7029ed79 100644 --- a/currencies/Cargo.toml +++ b/currencies/Cargo.toml @@ -10,12 +10,12 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } @@ -23,8 +23,8 @@ orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-feature funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" -pallet-balances = "3.0.0" +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.4.1-dev" } [features] diff --git a/gradually-update/Cargo.toml b/gradually-update/Cargo.toml index 18f3750fb..6df11cae4 100644 --- a/gradually-update/Cargo.toml +++ b/gradually-update/Cargo.toml @@ -10,12 +10,12 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -sp-core = { version = "3.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 diff --git a/nft/Cargo.toml b/nft/Cargo.toml index e1bd81f11..1870aa65e 100644 --- a/nft/Cargo.toml +++ b/nft/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } - -funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } [dev-dependencies] -sp-io = "3.0.0" -sp-core = "3.0.0" +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } + +funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [features] default = ["std"] diff --git a/oracle/Cargo.toml b/oracle/Cargo.toml index 36da0de22..8bd2e9df9 100644 --- a/oracle/Cargo.toml +++ b/oracle/Cargo.toml @@ -10,14 +10,13 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } -sp-application-crypto = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } - -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } @@ -25,7 +24,7 @@ orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-feature funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } [features] default = ["std"] diff --git a/oracle/rpc/Cargo.toml b/oracle/rpc/Cargo.toml index 131f21403..9ab71dbee 100644 --- a/oracle/rpc/Cargo.toml +++ b/oracle/rpc/Cargo.toml @@ -9,9 +9,10 @@ codec = { package = "parity-scale-codec", version = "2.0.0" } jsonrpc-core = "15.0.0" jsonrpc-core-client = "15.0.0" jsonrpc-derive = "15.0.0" -sp-runtime = { version = "3.0.0" } -sp-api = { version = "3.0.0" } -sp-blockchain = { version = "3.0.0" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } + orml-oracle-rpc-runtime-api = { path = "runtime-api" } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 diff --git a/oracle/rpc/runtime-api/Cargo.toml b/oracle/rpc/runtime-api/Cargo.toml index eb6a0afed..3003f32f8 100644 --- a/oracle/rpc/runtime-api/Cargo.toml +++ b/oracle/rpc/runtime-api/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } -sp-api = { default-features = false, version = "3.0.0" } -sp-std = { default-features = false, version = "3.0.0" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 diff --git a/rewards/Cargo.toml b/rewards/Cargo.toml index 5d2cce022..fb7c747f6 100644 --- a/rewards/Cargo.toml +++ b/rewards/Cargo.toml @@ -10,17 +10,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index 8d59ce706..641eb41b2 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -10,19 +10,19 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" -sp-io = "3.0.0" -pallet-treasury = "3.0.0" -pallet-elections-phragmen = "3.0.0" +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index c993cf95e..717698ff4 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -40,7 +40,7 @@ pub use crate::imbalances::{NegativeImbalance, PositiveImbalance}; use frame_support::{ - ensure, + ensure, log, pallet_prelude::*, traits::{ BalanceStatus as Status, Currency as PalletCurrency, ExistenceRequirement, Get, Imbalance, @@ -456,7 +456,7 @@ impl Pallet { // No providers for the locks. This is impossible under normal circumstances // since the funds that are under the lock will themselves be stored in the // account and therefore will need a reference. - frame_support::debug::warn!( + log::warn!( "Warning: Attempt to introduce lock consumer reference, yet no providers. \ This is unexpected but should be safe." ); diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 349fa925e..e99c0d48b 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -10,12 +10,12 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -num-traits = { version = "0.2.11", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +num-traits = { version = "0.2.14", default-features = false } impl-trait-for-tuples = "0.1.3" -frame-support = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } orml-utilities = { path = "../utilities", version = "0.4.1-dev", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index 0b484d3d0..955ebc0ec 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -10,16 +10,16 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] serde_json = "1.0.53" -frame-system = "3.0.0" +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index f08a0d924..bb4cdc717 100644 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -10,18 +10,18 @@ edition = "2018" [dependencies] serde = { version = "1.0.111", optional = true } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } -sp-runtime = { version = "3.0.0", default-features = false } -sp-io = { version = "3.0.0", default-features = false } -sp-std = { version = "3.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } -frame-support = { version = "3.0.0", default-features = false } -frame-system = { version = "3.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } funty = { version = "=1.1.0", default-features = false } # https://github.com/bitvecto-rs/bitvec/issues/105 [dev-dependencies] -sp-core = "3.0.0" -pallet-balances = "3.0.0" +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } [features] default = ["std"] diff --git a/xcm-support/Cargo.toml b/xcm-support/Cargo.toml new file mode 100644 index 000000000..045d9898c --- /dev/null +++ b/xcm-support/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "orml-xcm-support" +description = "Crosschain token transfer" +repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/xcm-support" +license = "Apache-2.0" +version = "0.4.1-dev" +authors = ["Acala Developers"] +edition = "2018" + +[dependencies] +codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } + +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +xcm = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", default-features = false } +xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", default-features = false } + +orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false } + +[features] +default = ["std"] +std = [ + "sp-std/std", + "sp-runtime/std", + "frame-support/std", + "xcm/std", + "xcm-executor/std", + "orml-traits/std", +] diff --git a/xcm-support/src/lib.rs b/xcm-support/src/lib.rs new file mode 100644 index 000000000..a5d55ed10 --- /dev/null +++ b/xcm-support/src/lib.rs @@ -0,0 +1,142 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::FullCodec; +use sp_runtime::traits::{CheckedConversion, Convert, MaybeSerializeDeserialize, SaturatedConversion}; +use sp_std::{ + cmp::{Eq, PartialEq}, + collections::btree_set::BTreeSet, + convert::{TryFrom, TryInto}, + fmt::Debug, + marker::PhantomData, + prelude::*, + result, +}; + +use xcm::v0::{Error, Junction, MultiAsset, MultiLocation, Result}; +use xcm_executor::traits::{FilterAssetLocation, LocationConversion, MatchesFungible, NativeAsset, TransactAsset}; + +use frame_support::{log, traits::Get}; + +pub trait CurrencyIdConversion { + fn from_asset(asset: &MultiAsset) -> Option; +} + +pub struct MultiCurrencyAdapter( + PhantomData<( + MultiCurrency, + Matcher, + AccountIdConverter, + AccountId, + CurrencyIdConverter, + CurrencyId, + )>, +); + +impl< + MultiCurrency: orml_traits::MultiCurrency, + Matcher: MatchesFungible, + AccountIdConverter: LocationConversion, + AccountId: sp_std::fmt::Debug, + CurrencyIdConverter: CurrencyIdConversion, + CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug, + > TransactAsset + for MultiCurrencyAdapter +{ + fn deposit_asset(asset: &MultiAsset, location: &MultiLocation) -> Result { + log::info!("------------------------------------------------"); + log::info!(">>> trying deposit. asset: {:?}, location: {:?}", asset, location); + let who = AccountIdConverter::from_location(location).ok_or(())?; + log::info!("who: {:?}", who); + let currency_id = CurrencyIdConverter::from_asset(asset).ok_or(())?; + log::info!("currency_id: {:?}", currency_id); + let amount: MultiCurrency::Balance = Matcher::matches_fungible(&asset).ok_or(())?.saturated_into(); + log::info!("amount: {:?}", amount); + MultiCurrency::deposit(currency_id, &who, amount).map_err(|_| ())?; + log::info!(">>> success deposit."); + log::info!("------------------------------------------------"); + Ok(()) + } + + fn withdraw_asset(asset: &MultiAsset, location: &MultiLocation) -> result::Result { + log::info!("------------------------------------------------"); + log::info!(">>> trying withdraw. asset: {:?}, location: {:?}", asset, location); + let who = AccountIdConverter::from_location(location).ok_or(())?; + log::info!("who: {:?}", who); + let currency_id = CurrencyIdConverter::from_asset(asset).ok_or(())?; + log::info!("currency_id: {:?}", currency_id); + let amount: MultiCurrency::Balance = Matcher::matches_fungible(&asset).ok_or(())?.saturated_into(); + log::info!("amount: {:?}", amount); + MultiCurrency::withdraw(currency_id, &who, amount).map_err(|_| ())?; + log::info!(">>> success withdraw."); + log::info!("------------------------------------------------"); + Ok(asset.clone()) + } +} + +pub struct IsConcreteWithGeneralKey( + PhantomData<(CurrencyId, FromRelayChainBalance)>, +); +impl MatchesFungible + for IsConcreteWithGeneralKey +where + CurrencyId: TryFrom>, + B: TryFrom, + FromRelayChainBalance: Convert, +{ + fn matches_fungible(a: &MultiAsset) -> Option { + if let MultiAsset::ConcreteFungible { id, amount } = a { + if id == &MultiLocation::X1(Junction::Parent) { + // Convert relay chain decimals to local chain + let local_amount = FromRelayChainBalance::convert(*amount); + return CheckedConversion::checked_from(local_amount); + } + if let Some(Junction::GeneralKey(key)) = id.last() { + if TryInto::::try_into(key.clone()).is_ok() { + return CheckedConversion::checked_from(*amount); + } + } + } + None + } +} + +pub struct NativePalletAssetOr(PhantomData); +impl, MultiLocation)>>> FilterAssetLocation for NativePalletAssetOr { + fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool { + if NativeAsset::filter_asset_location(asset, origin) { + return true; + } + + // native orml-tokens with a general key + if let MultiAsset::ConcreteFungible { ref id, .. } = asset { + if let Some(Junction::GeneralKey(key)) = id.last() { + return Pairs::get().contains(&(key.clone(), origin.clone())); + } + } + + false + } +} + +pub struct CurrencyIdConverter( + PhantomData, + PhantomData, +); +impl CurrencyIdConversion + for CurrencyIdConverter +where + CurrencyId: TryFrom>, + RelayChainCurrencyId: Get, +{ + fn from_asset(asset: &MultiAsset) -> Option { + if let MultiAsset::ConcreteFungible { id: location, .. } = asset { + if location == &MultiLocation::X1(Junction::Parent) { + return Some(RelayChainCurrencyId::get()); + } + if let Some(Junction::GeneralKey(key)) = location.last() { + return CurrencyId::try_from(key.clone()).ok(); + } + } + None + } +} diff --git a/xtokens/Cargo.toml b/xtokens/Cargo.toml new file mode 100644 index 000000000..5124431b1 --- /dev/null +++ b/xtokens/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "orml-xtokens" +description = "Crosschain token transfer" +repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/tokens" +license = "Apache-2.0" +version = "0.4.1-dev" +authors = ["Acala Developers"] +edition = "2018" + +[dependencies] +serde = { version = "1.0.111", optional = true } +codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false } + +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", default-features = false } + +xcm = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", default-features = false } +xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", default-features = false } + +[dev-dependencies] +sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } +polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } +orml-tokens = { path = "../tokens", version = "0.4.1-dev" } + +[features] +default = ["std"] +std = [ + "serde", + "codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "cumulus-primitives-core/std", + "xcm/std", +] diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs new file mode 100644 index 000000000..e045c3529 --- /dev/null +++ b/xtokens/src/lib.rs @@ -0,0 +1,338 @@ +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::from_over_into)] +#![allow(clippy::unused_unit)] + +pub use module::*; + +#[frame_support::pallet] +pub mod module { + use codec::{Decode, Encode}; + use frame_support::{pallet_prelude::*, traits::Get, transactional, Parameter}; + use frame_system::{ensure_signed, pallet_prelude::*}; + use sp_runtime::{ + traits::{AtLeast32BitUnsigned, Convert, MaybeSerializeDeserialize, Member}, + RuntimeDebug, + }; + use sp_std::prelude::*; + + use cumulus_primitives_core::{relay_chain::Balance as RelayChainBalance, ParaId}; + use xcm::v0::{Error as XcmError, ExecuteXcm, Junction, MultiAsset, MultiLocation, NetworkId, Order, Xcm}; + use xcm_executor::traits::LocationConversion; + + #[derive(Encode, Decode, Eq, PartialEq, Clone, Copy, RuntimeDebug)] + /// Identity of chain. + pub enum ChainId { + /// The relay chain. + RelayChain, + /// A parachain. + ParaChain(ParaId), + } + + #[derive(Encode, Decode, Eq, PartialEq, Clone, RuntimeDebug)] + /// Identity of cross chain currency. + pub struct XCurrencyId { + /// The reserve chain of the currency. For instance, the reserve chain + /// of DOT is Polkadot. + pub chain_id: ChainId, + /// The identity of the currency. + pub currency_id: Vec, + } + + #[cfg(test)] + impl XCurrencyId { + pub fn new(chain_id: ChainId, currency_id: Vec) -> Self { + XCurrencyId { chain_id, currency_id } + } + } + + impl Into for XCurrencyId { + fn into(self) -> MultiLocation { + MultiLocation::X1(Junction::GeneralKey(self.currency_id)) + } + } + + #[pallet::config] + pub trait Config: frame_system::Config { + type Event: From> + IsType<::Event>; + + type Balance: Parameter + + Member + + AtLeast32BitUnsigned + + Default + + Copy + + MaybeSerializeDeserialize + + Into; + + /// Convertor `Balance` to `RelayChainBalance`. + type ToRelayChainBalance: Convert; + + type AccountId32Convert: Convert; + + type RelayChainNetworkId: Get; + + /// Parachain ID. + type ParaId: Get; + + type AccountIdConverter: LocationConversion; + + type XcmExecutor: ExecuteXcm; + } + + #[pallet::event] + #[pallet::generate_deposit(fn deposit_event)] + pub enum Event { + /// Transferred to relay chain. \[src, dest, amount\] + TransferredToRelayChain(T::AccountId, T::AccountId, T::Balance), + + /// Transfer to relay chain failed. \[src, dest, amount, error\] + TransferToRelayChainFailed(T::AccountId, T::AccountId, T::Balance, XcmError), + + /// Transferred to parachain. \[x_currency_id, src, para_id, dest, + /// dest_network, amount\] + TransferredToParachain(XCurrencyId, T::AccountId, ParaId, T::AccountId, NetworkId, T::Balance), + + /// Transfer to parachain failed. \[x_currency_id, src, para_id, dest, + /// dest_network, amount, error\] + TransferToParachainFailed( + XCurrencyId, + T::AccountId, + ParaId, + T::AccountId, + NetworkId, + T::Balance, + XcmError, + ), + } + + #[pallet::error] + pub enum Error { + /// Bad location. + BadLocation, + } + + #[pallet::hooks] + impl Hooks for Pallet {} + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::call] + impl Pallet { + /// Transfer relay chain tokens to relay chain. + #[pallet::weight(10)] + #[transactional] + pub fn transfer_to_relay_chain( + origin: OriginFor, + dest: T::AccountId, + amount: T::Balance, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + + let xcm = Xcm::WithdrawAsset { + assets: vec![MultiAsset::ConcreteFungible { + id: MultiLocation::X1(Junction::Parent), + amount: T::ToRelayChainBalance::convert(amount), + }], + effects: vec![Order::InitiateReserveWithdraw { + assets: vec![MultiAsset::All], + reserve: MultiLocation::X1(Junction::Parent), + effects: vec![Order::DepositAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X1(Junction::AccountId32 { + network: T::RelayChainNetworkId::get(), + id: T::AccountId32Convert::convert(dest.clone()), + }), + }], + }], + }; + + let xcm_origin = + T::AccountIdConverter::try_into_location(who.clone()).map_err(|_| Error::::BadLocation)?; + // TODO: revert state on xcm execution failure. + match T::XcmExecutor::execute_xcm(xcm_origin, xcm) { + Ok(_) => Self::deposit_event(Event::::TransferredToRelayChain(who, dest, amount)), + Err(err) => Self::deposit_event(Event::::TransferToRelayChainFailed(who, dest, amount, err)), + } + + Ok(().into()) + } + + /// Transfer tokens to parachain. + #[pallet::weight(10)] + #[transactional] + pub fn transfer_to_parachain( + origin: OriginFor, + x_currency_id: XCurrencyId, + para_id: ParaId, + dest: T::AccountId, + dest_network: NetworkId, + amount: T::Balance, + ) -> DispatchResultWithPostInfo { + let who = ensure_signed(origin)?; + + if para_id == T::ParaId::get() { + return Ok(().into()); + } + + let xcm = match x_currency_id.chain_id { + ChainId::RelayChain => { + Self::transfer_relay_chain_tokens_to_parachain(para_id, &dest, dest_network.clone(), amount) + } + ChainId::ParaChain(reserve_chain) => { + if T::ParaId::get() == reserve_chain { + Self::transfer_owned_tokens_to_parachain( + x_currency_id.clone(), + para_id, + &dest, + dest_network.clone(), + amount, + ) + } else { + Self::transfer_non_owned_tokens_to_parachain( + reserve_chain, + x_currency_id.clone(), + para_id, + &dest, + dest_network.clone(), + amount, + ) + } + } + }; + + let xcm_origin = + T::AccountIdConverter::try_into_location(who.clone()).map_err(|_| Error::::BadLocation)?; + // TODO: revert state on xcm execution failure. + match T::XcmExecutor::execute_xcm(xcm_origin, xcm) { + Ok(_) => Self::deposit_event(Event::::TransferredToParachain( + x_currency_id, + who, + para_id, + dest, + dest_network, + amount, + )), + Err(err) => Self::deposit_event(Event::::TransferToParachainFailed( + x_currency_id, + who, + para_id, + dest, + dest_network, + amount, + err, + )), + } + + Ok(().into()) + } + } + + impl Pallet { + fn transfer_relay_chain_tokens_to_parachain( + para_id: ParaId, + dest: &T::AccountId, + dest_network: NetworkId, + amount: T::Balance, + ) -> Xcm { + Xcm::WithdrawAsset { + assets: vec![MultiAsset::ConcreteFungible { + id: MultiLocation::X1(Junction::Parent), + amount: T::ToRelayChainBalance::convert(amount), + }], + effects: vec![Order::InitiateReserveWithdraw { + assets: vec![MultiAsset::All], + reserve: MultiLocation::X1(Junction::Parent), + effects: vec![Order::DepositReserveAsset { + assets: vec![MultiAsset::All], + // `dest` is children parachain(of parent). + dest: MultiLocation::X1(Junction::Parachain { id: para_id.into() }), + effects: vec![Order::DepositAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X1(Junction::AccountId32 { + network: dest_network, + id: T::AccountId32Convert::convert(dest.clone()), + }), + }], + }], + }], + } + } + + /// Transfer parachain tokens "owned" by self parachain to another + /// parachain. + /// + /// NOTE - `para_id` must not be self parachain. + fn transfer_owned_tokens_to_parachain( + x_currency_id: XCurrencyId, + para_id: ParaId, + dest: &T::AccountId, + dest_network: NetworkId, + amount: T::Balance, + ) -> Xcm { + Xcm::WithdrawAsset { + assets: vec![MultiAsset::ConcreteFungible { + id: x_currency_id.into(), + amount: amount.into(), + }], + effects: vec![Order::DepositReserveAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X2(Junction::Parent, Junction::Parachain { id: para_id.into() }), + effects: vec![Order::DepositAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X1(Junction::AccountId32 { + network: dest_network, + id: T::AccountId32Convert::convert(dest.clone()), + }), + }], + }], + } + } + + /// Transfer parachain tokens not "owned" by self chain to another + /// parachain. + fn transfer_non_owned_tokens_to_parachain( + reserve_chain: ParaId, + x_currency_id: XCurrencyId, + para_id: ParaId, + dest: &T::AccountId, + dest_network: NetworkId, + amount: T::Balance, + ) -> Xcm { + let deposit_to_dest = Order::DepositAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X1(Junction::AccountId32 { + network: dest_network, + id: T::AccountId32Convert::convert(dest.clone()), + }), + }; + // If transfer to reserve chain, deposit to `dest` on reserve chain, + // else deposit reserve asset. + let reserve_chain_order = if para_id == reserve_chain { + deposit_to_dest + } else { + Order::DepositReserveAsset { + assets: vec![MultiAsset::All], + dest: MultiLocation::X2(Junction::Parent, Junction::Parachain { id: para_id.into() }), + effects: vec![deposit_to_dest], + } + }; + + Xcm::WithdrawAsset { + assets: vec![MultiAsset::ConcreteFungible { + id: x_currency_id.into(), + amount: amount.into(), + }], + effects: vec![Order::InitiateReserveWithdraw { + assets: vec![MultiAsset::All], + reserve: MultiLocation::X2( + Junction::Parent, + Junction::Parachain { + id: reserve_chain.into(), + }, + ), + effects: vec![reserve_chain_order], + }], + } + } + } +}