Skip to content

Commit

Permalink
Add substrate's rustfmt config (ajuna-network#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb authored Mar 7, 2024
1 parent 7a18239 commit d83df55
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ jobs:
if: ${{ !startsWith(github.head_ref, 'release/') }}
name: Rustfmt
runs-on: ubuntu-latest
container:
# contains the nightly-toolchain
image: docker.io/paritytech/ci-unified:bullseye-1.75.0-2024-01-22-v20240109
continue-on-error: false
steps:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check
# some settings are only available in nightly.
- run: cargo +nightly fmt --all -- --check

lint:
if: ${{ !startsWith(github.head_ref, 'release/') }}
Expand Down
22 changes: 13 additions & 9 deletions runtime/ajuna/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use frame_support::pallet_prelude::ConstU32;
use frame_support::traits::fungible::HoldConsideration;
use frame_support::traits::tokens::{PayFromAccount, UnityAssetBalanceConversion};
use frame_support::traits::{Footprint, TransformOrigin};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
pallet_prelude::ConstU32,
parameter_types,
traits::{ConstBool, Contains, EitherOfDiverse},
traits::{
fungible::HoldConsideration,
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ConstBool, Contains, EitherOfDiverse, Footprint, TransformOrigin,
},
weights::{
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
Expand All @@ -72,10 +73,13 @@ use xcm_config::XcmOriginToTransactDispatchOrigin;
pub use sp_runtime::BuildStorage;

// Polkadot imports
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use parachains_common::{BlockNumber, Hash, Header};
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use parachains_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
BlockNumber, Hash, Header,
};
use polkadot_runtime_common::{
xcm_sender::NoPriceForMessageDelivery, BlockHashCount, SlowAdjustingFeeUpdate,
};
use sp_runtime::traits::{Convert, IdentifyAccount, IdentityLookup, Verify};

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
Expand Down
4 changes: 2 additions & 2 deletions runtime/ajuna/src/proxy_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. })
| RuntimeCall::Utility(..)
RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) |
RuntimeCall::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }))
Expand Down
9 changes: 4 additions & 5 deletions runtime/ajuna/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ use super::{
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
};
use core::{marker::PhantomData, ops::ControlFlow};
use frame_support::traits::Contains;
use frame_support::{
parameter_types,
traits::{ConstU32, Everything, Nothing, ProcessMessageError},
traits::{ConstU32, Contains, Everything, Nothing, ProcessMessageError},
weights::Weight,
};
use frame_system::EnsureRoot;
Expand Down Expand Up @@ -155,9 +154,9 @@ impl ShouldExecute for DenyReserveTransferToRelayChain {
InitiateReserveWithdraw {
reserve: Location { parents: 1, interior: Here },
..
}
| DepositReserveAsset { dest: Location { parents: 1, interior: Here }, .. }
| TransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. } => {
} |
DepositReserveAsset { dest: Location { parents: 1, interior: Here }, .. } |
TransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. } => {
Err(ProcessMessageError::Unsupported) // Deny
},
// An unexpected reserve transfer has arrived from the Relay Chain. Generally,
Expand Down
22 changes: 16 additions & 6 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Basic
hard_tabs = true
max_width = 100
edition = "2021"
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
reorder_modules = true
# Consistency
newline_style = "Unix"
# Misc
chain_width = 80
match_arm_leading_pipes = "Preserve"
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
use_field_init_shorthand = true
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
# Format comments
comment_width = 100
wrap_comments = true

0 comments on commit d83df55

Please sign in to comment.