Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Prefer matches
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez committed May 4, 2023
1 parent 054c41d commit 8c06096
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 39 deletions.
14 changes: 4 additions & 10 deletions parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ impl<Network: Get<NetworkId>> Contains<MultiLocation>
for StartsWithExplicitGlobalConsensus<Network>
{
fn contains(t: &MultiLocation) -> bool {
match t.interior.global_consensus() {
Ok(requested_network) if requested_network.eq(&Network::get()) => true,
_ => false,
}
matches!(t.interior.global_consensus(), Ok(requested_network) if requested_network.eq(&Network::get()))
}
}

Expand Down Expand Up @@ -79,12 +76,9 @@ impl<SelfParaId: Get<ParaId>> ContainsPair<MultiLocation, MultiLocation>

// here we check if sibling
match a {
MultiLocation { parents: 1, interior } => match interior.first() {
Some(Parachain(sibling_para_id))
if sibling_para_id.ne(&u32::from(SelfParaId::get())) =>
true,
_ => false,
},
MultiLocation { parents: 1, interior } =>
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get())))
,
_ => false,
}
}
Expand Down
9 changes: 4 additions & 5 deletions parachains/runtimes/assets/statemine/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand Down Expand Up @@ -338,10 +338,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_uniques::Call::set_accept_ownership { .. } |
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. },
) => true,
_ => false,
}
pallet_uniques::Call::buy_item { .. }
)
)
}
}

Expand Down
7 changes: 3 additions & 4 deletions parachains/runtimes/assets/statemint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand Down Expand Up @@ -242,9 +242,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. },
) => true,
_ => false,
}
)
)
}
}

Expand Down
7 changes: 3 additions & 4 deletions parachains/runtimes/assets/westmint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand Down Expand Up @@ -337,9 +337,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. },
) => true,
_ => false,
}
)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand All @@ -149,9 +149,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::DmpQueue(..) |
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
_ => false,
}
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. })
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand All @@ -152,9 +152,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::DmpQueue(..) |
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
_ => false,
}
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. })
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
Expand Down Expand Up @@ -184,9 +184,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
BridgeGrandpaWococoInstance,
>::initialize {
..
}) => true,
_ => false,
}
})
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

match call {
matches!(call,
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
Expand Down Expand Up @@ -186,9 +186,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_ranked_collective::Call::promote_member { .. } |
pallet_ranked_collective::Call::demote_member { .. } |
pallet_ranked_collective::Call::remove_member { .. },
) => true,
_ => false,
}
)
)
}
}

Expand Down

0 comments on commit 8c06096

Please sign in to comment.