Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

44 defi xcm use case no1 #78

Merged
merged 15 commits into from
Nov 13, 2022
Merged
Prev Previous commit
cargo fmt
  • Loading branch information
lana-shanghai committed Nov 13, 2022
commit 715562bd64c514c499ca6c0d34c2304141f8f808
15 changes: 6 additions & 9 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,14 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;
// Switch on the concrete benchmark sub-command-
match cmd {
BenchmarkCmd::Pallet(cmd) => {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, RuntimeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
}
},
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, RuntimeExecutor, _>(
&config,
Expand All @@ -226,14 +225,13 @@ pub fn run() -> Result<()> {
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => {
BenchmarkCmd::Storage(_) =>
return Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into())
},
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, RuntimeExecutor, _>(
Expand All @@ -245,9 +243,8 @@ pub fn run() -> Result<()> {

cmd.run(config, partials.client.clone(), db, storage)
}),
BenchmarkCmd::Machine(cmd) => {
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))
},
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
// NOTE: this allows the Client to leniently implement
// new benchmark commands without requiring a companion MR.
#[allow(unreachable_patterns)]
Expand Down
15 changes: 7 additions & 8 deletions runtime/base/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ parameter_types! {

//- From PR https://github.com/paritytech/cumulus/pull/936
fn matches_prefix(prefix: &MultiLocation, loc: &MultiLocation) -> bool {
prefix.parent_count() == loc.parent_count()
&& loc.len() >= prefix.len()
&& prefix
prefix.parent_count() == loc.parent_count() &&
loc.len() >= prefix.len() &&
prefix
.interior()
.iter()
.zip(loc.interior().iter())
Expand All @@ -234,11 +234,10 @@ impl<T: Get<MultiLocation>> FilterAssetLocation for ReserveAssetsFrom<T> {
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let prefix = T::get();
log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", prefix, origin);
&prefix == origin
&& match asset {
MultiAsset { id: xcm::latest::AssetId::Concrete(asset_loc), fun: Fungible(_a) } => {
matches_prefix(&prefix, asset_loc)
},
&prefix == origin &&
match asset {
MultiAsset { id: xcm::latest::AssetId::Concrete(asset_loc), fun: Fungible(_a) } =>
matches_prefix(&prefix, asset_loc),
_ => false,
}
}
Expand Down
15 changes: 7 additions & 8 deletions runtime/trappist/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ parameter_types! {

//- From PR https://github.com/paritytech/cumulus/pull/936
fn matches_prefix(prefix: &MultiLocation, loc: &MultiLocation) -> bool {
prefix.parent_count() == loc.parent_count()
&& loc.len() >= prefix.len()
&& prefix
prefix.parent_count() == loc.parent_count() &&
loc.len() >= prefix.len() &&
prefix
.interior()
.iter()
.zip(loc.interior().iter())
Expand All @@ -234,11 +234,10 @@ impl<T: Get<MultiLocation>> FilterAssetLocation for ReserveAssetsFrom<T> {
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
let prefix = T::get();
log::trace!(target: "xcm::AssetsFrom", "prefix: {:?}, origin: {:?}", prefix, origin);
&prefix == origin
&& match asset {
MultiAsset { id: xcm::latest::AssetId::Concrete(asset_loc), fun: Fungible(_a) } => {
matches_prefix(&prefix, asset_loc)
},
&prefix == origin &&
match asset {
MultiAsset { id: xcm::latest::AssetId::Concrete(asset_loc), fun: Fungible(_a) } =>
matches_prefix(&prefix, asset_loc),
_ => false,
}
}
Expand Down