From 495b6d4af3cba58a4e6a249dd9c4102d0354247a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Molina?= Date: Fri, 8 Sep 2023 11:52:13 +0200 Subject: [PATCH 1/2] chore: set rust channel to stable --- rust-toolchain.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9e48ceeb..f3cac4cb 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2023-05-22" +channel = "stable" components = [ "rustfmt" ] targets = [ "wasm32-unknown-unknown" ] -profile = "minimal" \ No newline at end of file +profile = "minimal" From 45fe9c42c3f79c81b2c748dbf3877a8387a3a85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Molina?= Date: Fri, 8 Sep 2023 11:54:37 +0200 Subject: [PATCH 2/2] chore: format rust without nightly settings --- node/src/command.rs | 11 ++++++----- node/tests/common.rs | 2 +- pallets/asset-registry/src/lib.rs | 12 ++++++------ primitives/xcm/src/lib.rs | 10 +++++----- runtime/trappist/src/impls.rs | 16 ++++++++-------- runtime/trappist/src/weights/xcm/mod.rs | 5 +++-- rustfmt.toml | 10 ---------- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 89b6c708..6e453401 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -125,12 +125,12 @@ impl From<&str> for Runtime { fn from(value: &str) -> Self { #[cfg(feature = "trappist-runtime")] if value.starts_with("trappist") { - return Runtime::Trappist + return Runtime::Trappist; } #[cfg(feature = "stout-runtime")] if value.starts_with("stout") { - return Runtime::Stout + return Runtime::Stout; } let fallback = Runtime::default(); @@ -337,7 +337,7 @@ pub fn run() -> Result<()> { if !cfg!(feature = "runtime-benchmarks") { return Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." - .into()) + .into()); } dispatch_runtime!(config.chain_spec.runtime(), |runtime| { @@ -362,8 +362,9 @@ pub fn run() -> Result<()> { cmd.run(config, partial.client, db, storage) }) }, - BenchmarkCmd::Machine(cmd) => - cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), + BenchmarkCmd::Machine(cmd) => { + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()) + }, BenchmarkCmd::Overhead(cmd) => { construct_partial!(config, |partial| { let ext_builder = RemarkBuilder::new(partial.client.clone()); diff --git a/node/tests/common.rs b/node/tests/common.rs index eb330bd6..515009c6 100644 --- a/node/tests/common.rs +++ b/node/tests/common.rs @@ -44,7 +44,7 @@ pub fn wait_for(child: &mut Child, secs: u64) -> Result { let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5)) .map_err(|_| ())?; if let Some(exit_status) = result { - return Ok(exit_status) + return Ok(exit_status); } } eprintln!("Took too long to exit (> {} seconds). Killing...", secs); diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index f4c80721..de5e19dd 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -155,14 +155,14 @@ pub mod pallet { let check = matches!( last_junction, - Some(AccountId32 { .. }) | - Some(AccountKey20 { .. }) | - Some(PalletInstance(_)) | - Some(Parachain(_)) | None + Some(AccountId32 { .. }) + | Some(AccountKey20 { .. }) + | Some(PalletInstance(_)) + | Some(Parachain(_)) | None ); - check | - match last_junction { + check + | match last_junction { Some(GeneralIndex(_)) => { let penultimate = split_multilocation.last(); matches!(penultimate, Some(PalletInstance(_))) diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 8b3694f5..4b93bc9d 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -143,17 +143,17 @@ impl() >= - AssetsPallet::minimum_balance(asset_id) + amount.saturated_into::() + >= AssetsPallet::minimum_balance(asset_id) }, None => { weight.saturating_accrue(Weigher::native()); // only trap if native token and amount ≥ min_balance // do nothing otherwise (asset is lost) - *location == NATIVE_LOCATION && - amount.saturated_into::() >= - BalancesPallet::minimum_balance() + *location == NATIVE_LOCATION + && amount.saturated_into::() + >= BalancesPallet::minimum_balance() }, } } else { diff --git a/runtime/trappist/src/impls.rs b/runtime/trappist/src/impls.rs index 1e55b551..e8ce95f9 100644 --- a/runtime/trappist/src/impls.rs +++ b/runtime/trappist/src/impls.rs @@ -81,14 +81,14 @@ impl Contains for RuntimeBlackListedCalls { fn contains(call: &RuntimeCall) -> bool { !matches!( call, - RuntimeCall::Balances(_) | - RuntimeCall::Assets(_) | - RuntimeCall::Dex(_) | - RuntimeCall::PolkadotXcm(_) | - RuntimeCall::Treasury(_) | - RuntimeCall::Contracts(_) | - RuntimeCall::Uniques(_) | - RuntimeCall::AssetRegistry(_) + RuntimeCall::Balances(_) + | RuntimeCall::Assets(_) + | RuntimeCall::Dex(_) + | RuntimeCall::PolkadotXcm(_) + | RuntimeCall::Treasury(_) + | RuntimeCall::Contracts(_) + | RuntimeCall::Uniques(_) + | RuntimeCall::AssetRegistry(_) ) } } diff --git a/runtime/trappist/src/weights/xcm/mod.rs b/runtime/trappist/src/weights/xcm/mod.rs index f4209b70..2efc667d 100644 --- a/runtime/trappist/src/weights/xcm/mod.rs +++ b/runtime/trappist/src/weights/xcm/mod.rs @@ -40,8 +40,9 @@ impl WeighMultiAssets for MultiAssetFilter { WildFungibility::Fungible => weight, // Magic number 2 has to do with the fact that we could have up to 2 times // MaxAssetsIntoHolding in the worst-case scenario. - WildFungibility::NonFungible => - weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64), + WildFungibility::NonFungible => { + weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64) + }, }, AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)), AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)), diff --git a/rustfmt.toml b/rustfmt.toml index 441913f6..483a19e0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -3,21 +3,11 @@ hard_tabs = true max_width = 100 use_small_heuristics = "Max" # Imports -imports_granularity = "Crate" reorder_imports = true # Consistency newline_style = "Unix" -# Format comments -comment_width = 100 -wrap_comments = true # Misc chain_width = 80 -spaces_around_ranges = false -binop_separator = "Back" -reorder_impl_items = false match_arm_leading_pipes = "Preserve" -match_arm_blocks = false match_block_trailing_comma = true -trailing_comma = "Vertical" -trailing_semicolon = false use_field_init_shorthand = true