difftreelog
fix cargo fmt
in: master
6 files changed
pallets/configuration/src/lib.rsdiffbeforeafterboth--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -43,7 +43,8 @@
use super::*;
use frame_support::{
traits::{Get, ReservableCurrency, Currency},
- pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType}, log,
+ pallet_prelude::{StorageValue, ValueQuery, DispatchResult, IsType},
+ log,
};
use frame_system::{pallet_prelude::OriginFor, ensure_root, Config as SystemConfig};
runtime/common/tests/mod.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::{BuildStorage, Storage};18use sp_core::{Public, Pair};19use sp_std::vec;20use up_common::types::AuraId;21use crate::{Runtime, GenesisConfig, ParachainInfoConfig, RuntimeEvent, System};2223pub use sp_runtime::AccountId32 as AccountId;24pub type Balance = u128;2526pub mod xcm;2728#[cfg(any(feature = "opal-runtime", feature = "quartz-runtime"))]29/// PARA_ID for Opal/Sapphire/Quartz30const PARA_ID: u32 = 2095;3132#[cfg(feature = "unique-runtime")]33/// PARA_ID for Unique34const PARA_ID: u32 = 2037;3536fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {37 TPublic::Pair::from_string(&format!("//{}", seed), None)38 .expect("static values are valid; qed")39 .public()40}4142fn last_events(n: usize) -> Vec<RuntimeEvent> {43 System::events().into_iter().map(|e| e.event).rev().take(n).rev().collect()44}4546fn new_test_ext(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities {47 let mut storage = make_basic_storage();4849 pallet_balances::GenesisConfig::<Runtime> { balances }50 .assimilate_storage(&mut storage)51 .unwrap();5253 let mut ext = sp_io::TestExternalities::new(storage);54 ext.execute_with(|| System::set_block_number(1));55 ext56}5758#[cfg(feature = "collator-selection")]59fn make_basic_storage() -> Storage {60 use sp_core::{sr25519};61 use sp_runtime::traits::{IdentifyAccount, Verify};62 use crate::{AccountId, Signature, SessionKeys, CollatorSelectionConfig, SessionConfig};6364 type AccountPublic = <Signature as Verify>::Signer;6566 fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId67 where68 AccountPublic: From<<TPublic::Pair as Pair>::Public>,69 {70 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()71 }7273 let accounts = vec!["Alice", "Bob"];74 let keys = accounts75 .iter()76 .map(|&acc| {77 let account_id = get_account_id_from_seed::<sr25519::Public>(acc);78 (79 account_id.clone(),80 account_id,81 SessionKeys {82 aura: get_from_seed::<AuraId>(acc),83 },84 )85 })86 .collect::<Vec<_>>();87 let invulnerables = accounts88 .iter()89 .map(|acc| get_account_id_from_seed::<sr25519::Public>(acc))90 .collect::<Vec<_>>();9192 let cfg = GenesisConfig {93 collator_selection: CollatorSelectionConfig { invulnerables },94 session: SessionConfig { keys },95 parachain_info: ParachainInfoConfig {96 parachain_id: PARA_ID.into(),97 },98 ..GenesisConfig::default()99 };100101 cfg.build_storage().unwrap().into()102}103104#[cfg(not(feature = "collator-selection"))]105fn make_basic_storage() -> Storage {106 use crate::AuraConfig;107108 let cfg = GenesisConfig {109 aura: AuraConfig {110 authorities: vec![111 get_from_seed::<AuraId>("Alice"),112 get_from_seed::<AuraId>("Bob"),113 ],114 },115 parachain_info: ParachainInfoConfig {116 parachain_id: PARA_ID.into(),117 },118 ..GenesisConfig::default()119 };120121 cfg.build_storage().unwrap().into()122}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use sp_runtime::{BuildStorage, Storage};18use sp_core::{Public, Pair};19use sp_std::vec;20use up_common::types::AuraId;21use crate::{Runtime, GenesisConfig, ParachainInfoConfig, RuntimeEvent, System};2223pub use sp_runtime::AccountId32 as AccountId;24pub type Balance = u128;2526pub mod xcm;2728#[cfg(any(feature = "opal-runtime", feature = "quartz-runtime"))]29/// PARA_ID for Opal/Sapphire/Quartz30const PARA_ID: u32 = 2095;3132#[cfg(feature = "unique-runtime")]33/// PARA_ID for Unique34const PARA_ID: u32 = 2037;3536fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {37 TPublic::Pair::from_string(&format!("//{}", seed), None)38 .expect("static values are valid; qed")39 .public()40}4142fn last_events(n: usize) -> Vec<RuntimeEvent> {43 System::events()44 .into_iter()45 .map(|e| e.event)46 .rev()47 .take(n)48 .rev()49 .collect()50}5152fn new_test_ext(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities {53 let mut storage = make_basic_storage();5455 pallet_balances::GenesisConfig::<Runtime> { balances }56 .assimilate_storage(&mut storage)57 .unwrap();5859 let mut ext = sp_io::TestExternalities::new(storage);60 ext.execute_with(|| System::set_block_number(1));61 ext62}6364#[cfg(feature = "collator-selection")]65fn make_basic_storage() -> Storage {66 use sp_core::{sr25519};67 use sp_runtime::traits::{IdentifyAccount, Verify};68 use crate::{AccountId, Signature, SessionKeys, CollatorSelectionConfig, SessionConfig};6970 type AccountPublic = <Signature as Verify>::Signer;7172 fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId73 where74 AccountPublic: From<<TPublic::Pair as Pair>::Public>,75 {76 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()77 }7879 let accounts = vec!["Alice", "Bob"];80 let keys = accounts81 .iter()82 .map(|&acc| {83 let account_id = get_account_id_from_seed::<sr25519::Public>(acc);84 (85 account_id.clone(),86 account_id,87 SessionKeys {88 aura: get_from_seed::<AuraId>(acc),89 },90 )91 })92 .collect::<Vec<_>>();93 let invulnerables = accounts94 .iter()95 .map(|acc| get_account_id_from_seed::<sr25519::Public>(acc))96 .collect::<Vec<_>>();9798 let cfg = GenesisConfig {99 collator_selection: CollatorSelectionConfig { invulnerables },100 session: SessionConfig { keys },101 parachain_info: ParachainInfoConfig {102 parachain_id: PARA_ID.into(),103 },104 ..GenesisConfig::default()105 };106107 cfg.build_storage().unwrap().into()108}109110#[cfg(not(feature = "collator-selection"))]111fn make_basic_storage() -> Storage {112 use crate::AuraConfig;113114 let cfg = GenesisConfig {115 aura: AuraConfig {116 authorities: vec![117 get_from_seed::<AuraId>("Alice"),118 get_from_seed::<AuraId>("Bob"),119 ],120 },121 parachain_info: ParachainInfoConfig {122 parachain_id: PARA_ID.into(),123 },124 ..GenesisConfig::default()125 };126127 cfg.build_storage().unwrap().into()128}runtime/common/tests/xcm.rsdiffbeforeafterboth--- a/runtime/common/tests/xcm.rs
+++ b/runtime/common/tests/xcm.rs
@@ -16,51 +16,48 @@
use xcm::{
VersionedXcm,
- latest::{prelude::*, Error}
+ latest::{prelude::*, Error},
};
use codec::Encode;
use crate::{Runtime, RuntimeCall, RuntimeOrigin, RuntimeEvent, PolkadotXcm};
use super::{new_test_ext, last_events, AccountId};
-use frame_support::{
- pallet_prelude::Weight,
-};
+use frame_support::{pallet_prelude::Weight};
const ALICE: AccountId = AccountId::new([0u8; 32]);
const BOB: AccountId = AccountId::new([1u8; 32]);
-const INITIAL_BALANCE: u128 = 1000000000000000000_0000; // 1000 UNQ
+const INITIAL_BALANCE: u128 = 1000000000000000000_0000; // 1000 UNQ
#[test]
pub fn xcm_transact_is_forbidden() {
new_test_ext(vec![(ALICE, INITIAL_BALANCE)]).execute_with(|| {
PolkadotXcm::execute(
RuntimeOrigin::signed(ALICE),
- Box::new(VersionedXcm::from(Xcm(vec![
- Transact {
- origin_kind: OriginKind::Native,
- require_weight_at_most: Weight::from_parts(1000, 1000),
- call: RuntimeCall::Balances(
- pallet_balances::Call::<Runtime>::transfer {
- dest: BOB.into(),
- value: INITIAL_BALANCE / 2,
- }
- ).encode().into(),
- }
- ]))),
+ Box::new(VersionedXcm::from(Xcm(vec![Transact {
+ origin_kind: OriginKind::Native,
+ require_weight_at_most: Weight::from_parts(1000, 1000),
+ call: RuntimeCall::Balances(pallet_balances::Call::<Runtime>::transfer {
+ dest: BOB.into(),
+ value: INITIAL_BALANCE / 2,
+ })
+ .encode()
+ .into(),
+ }]))),
Weight::from_parts(1001000, 2000),
- ).expect("XCM execute must succeed, the error should be in the `PolkadotXcm::Attempted` event");
+ )
+ .expect(
+ "XCM execute must succeed, the error should be in the `PolkadotXcm::Attempted` event",
+ );
let xcm_event = &last_events(1)[0];
match xcm_event {
- RuntimeEvent::PolkadotXcm(
- pallet_xcm::Event::<Runtime>::Attempted(
- Outcome::Incomplete(_weight, Error::NoPermission)
- )
- ) => { /* Pass */ },
+ RuntimeEvent::PolkadotXcm(pallet_xcm::Event::<Runtime>::Attempted(
+ Outcome::Incomplete(_weight, Error::NoPermission),
+ )) => { /* Pass */ }
_ => panic!(
"Expected PolkadotXcm.Attempted(Incomplete(_weight, NoPermission)),\
found: {xcm_event:#?}"
- )
+ ),
}
});
}
runtime/opal/src/xcm_barrier.rsdiffbeforeafterboth--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -17,7 +17,4 @@
use frame_support::traits::Everything;
use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};
-pub type Barrier = (
- TakeWeightCredit,
- AllowTopLevelPaidExecutionFrom<Everything>,
-);
+pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom<Everything>);
runtime/quartz/src/xcm_barrier.rsdiffbeforeafterboth--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -14,10 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-use frame_support::{
- match_types,
- traits::Everything,
-};
+use frame_support::{match_types, traits::Everything};
use xcm::latest::{Junctions::*, MultiLocation};
use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
runtime/unique/src/xcm_barrier.rsdiffbeforeafterboth--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -14,10 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-use frame_support::{
- match_types,
- traits::Everything,
-};
+use frame_support::{match_types, traits::Everything};
use xcm::latest::{Junctions::*, MultiLocation};
use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,