git.delta.rocks / unique-network / refs/commits / b88274c6db1b

difftreelog

fix cargo fmt

Daniel Shiposha2022-09-28parent: #3deec63.patch.diff
in: master

7 files changed

modifiedcrates/evm-coder/src/execution.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/execution.rs
+++ b/crates/evm-coder/src/execution.rs
@@ -60,12 +60,16 @@
 }
 impl From<u64> for DispatchInfo {
 	fn from(weight: u64) -> Self {
-		Self { weight: Weight::from_ref_time(weight) }
+		Self {
+			weight: Weight::from_ref_time(weight),
+		}
 	}
 }
 impl From<()> for DispatchInfo {
 	fn from(_: ()) -> Self {
-		Self { weight: Weight::zero() }
+		Self {
+			weight: Weight::zero(),
+		}
 	}
 }
 
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -327,7 +327,7 @@
 				Arc::new(RelayChainRpcInterface::new(rpc_client)) as Arc<_>,
 				None,
 			))
-		},
+		}
 		None => build_inprocess_relay_chain(
 			polkadot_config,
 			parachain_config,
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -185,25 +185,21 @@
 	/// Consume gas for reading.
 	pub fn consume_store_reads(&self, reads: u64) -> evm_coder::execution::Result<()> {
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(
-				Weight::from_ref_time(
-					<T as frame_system::Config>::DbWeight::get()
-						.read
-						.saturating_mul(reads)
-				),
-			))
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+				<T as frame_system::Config>::DbWeight::get()
+					.read
+					.saturating_mul(reads),
+			)))
 	}
 
 	/// Consume gas for writing.
 	pub fn consume_store_writes(&self, writes: u64) -> evm_coder::execution::Result<()> {
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(
-				Weight::from_ref_time(
-					<T as frame_system::Config>::DbWeight::get()
-						.write
-						.saturating_mul(writes)
-				),
-			))
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+				<T as frame_system::Config>::DbWeight::get()
+					.write
+					.saturating_mul(writes),
+			)))
 	}
 
 	/// Consume gas for reading and writing.
@@ -216,9 +212,9 @@
 		let reads = weight.read.saturating_mul(reads);
 		let writes = weight.read.saturating_mul(writes);
 		self.recorder
-			.consume_gas(T::GasWeightMapping::weight_to_gas(
-				Weight::from_ref_time(reads.saturating_add(writes)),
-			))
+			.consume_gas(T::GasWeightMapping::weight_to_gas(Weight::from_ref_time(
+				reads.saturating_add(writes),
+			)))
 	}
 
 	/// Save collection to storage.
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -99,9 +99,7 @@
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_evm_coder_substrate::WithRecorder;
 use pallet_common::{
-	CommonCollectionOperations,
-	Error as CommonError,
-	eth::collection_id_to_address,
+	CommonCollectionOperations, Error as CommonError, eth::collection_id_to_address,
 	Event as CommonEvent, Pallet as PalletCommon,
 };
 use pallet_structure::Pallet as PalletStructure;
@@ -110,10 +108,10 @@
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
 use up_data_structs::{
-	AccessMode, budget::Budget, CollectionId, CollectionFlags,
-	CollectionPropertiesVec, CreateCollectionData, CustomDataLimit, mapping::TokenAddressMapping,
-	MAX_ITEMS_PER_BATCH, MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission,
-	PropertyPermission, PropertyScope, PropertyValue, TokenId, TrySetProperty,
+	AccessMode, budget::Budget, CollectionId, CollectionFlags, CollectionPropertiesVec,
+	CreateCollectionData, CustomDataLimit, mapping::TokenAddressMapping, MAX_ITEMS_PER_BATCH,
+	MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,
+	PropertyScope, PropertyValue, TokenId, TrySetProperty,
 };
 use frame_support::BoundedBTreeMap;
 use derivative::Derivative;
modifiedruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth
before · runtime/common/config/xcm/nativeassets.rs
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 frame_support::{18	traits::{tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get},19	weights::WeightToFeePolynomial,20};21use sp_runtime::traits::{CheckedConversion, Zero, Convert};22use xcm::v1::{Junction::*, MultiLocation, Junctions::*};23use xcm::latest::{24	AssetId::{Concrete},25	Fungibility::Fungible as XcmFungible,26	MultiAsset, Error as XcmError,27	Weight,28};29use xcm_builder::{CurrencyAdapter, NativeAsset};30use xcm_executor::{31	Assets,32	traits::{MatchesFungible, WeightTrader},33};34use pallet_foreign_assets::{AssetIds, NativeCurrency};35use sp_std::marker::PhantomData;36use crate::{Balances, ParachainInfo};37use super::{LocationToAccountId, RelayLocation};3839use up_common::types::{AccountId, Balance};4041pub struct OnlySelfCurrency;42impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {43	fn matches_fungible(a: &MultiAsset) -> Option<B> {44		let paraid = Parachain(ParachainInfo::parachain_id().into());45		match (&a.id, &a.fun) {46			(47				Concrete(MultiLocation {48					parents: 1,49					interior: X1(loc),50				}),51				XcmFungible(ref amount),52			) if paraid == *loc => CheckedConversion::checked_from(*amount),53			(54				Concrete(MultiLocation {55					parents: 0,56					interior: Here,57				}),58				XcmFungible(ref amount),59			) => CheckedConversion::checked_from(*amount),60			_ => None,61		}62	}63}6465/// Means for transacting assets on this chain.66pub type LocalAssetTransactor = CurrencyAdapter<67	// Use this currency:68	Balances,69	// Use this currency when it is a fungible asset matching the given location or name:70	OnlySelfCurrency,71	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:72	LocationToAccountId,73	// Our chain's account ID type (we can't get away without mentioning it explicitly):74	AccountId,75	// We don't track any teleports.76	(),77>;7879pub type AssetTransactors = LocalAssetTransactor;8081pub type IsReserve = NativeAsset;8283pub struct UsingOnlySelfCurrencyComponents<84	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,85	AssetId: Get<MultiLocation>,86	AccountId,87	Currency: CurrencyT<AccountId>,88	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,89>(90	Weight,91	Currency::Balance,92	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,93);94impl<95		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,96		AssetId: Get<MultiLocation>,97		AccountId,98		Currency: CurrencyT<AccountId>,99		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,100	> WeightTrader101	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>102{103	fn new() -> Self {104		Self(0, Zero::zero(), PhantomData)105	}106107	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {108		Ok(payment)109	}110}111impl<112		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,113		AssetId: Get<MultiLocation>,114		AccountId,115		Currency: CurrencyT<AccountId>,116		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,117	> Drop118	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>119{120	fn drop(&mut self) {121		OnUnbalanced::on_unbalanced(Currency::issue(self.1));122	}123}124125pub type Trader<T> = UsingOnlySelfCurrencyComponents<126	pallet_configuration::WeightToFee<T, Balance>,127	RelayLocation,128	AccountId,129	Balances,130	(),131>;132133pub struct CurrencyIdConvert;134impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {135	fn convert(id: AssetIds) -> Option<MultiLocation> {136		match id {137			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(138				1,139				X1(Parachain(ParachainInfo::get().into())),140			)),141			_ => None,142		}143	}144}
after · runtime/common/config/xcm/nativeassets.rs
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 frame_support::{18	traits::{tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get},19	weights::WeightToFeePolynomial,20};21use sp_runtime::traits::{CheckedConversion, Zero, Convert};22use xcm::v1::{Junction::*, MultiLocation, Junctions::*};23use xcm::latest::{24	AssetId::{Concrete},25	Fungibility::Fungible as XcmFungible,26	MultiAsset, Error as XcmError, Weight,27};28use xcm_builder::{CurrencyAdapter, NativeAsset};29use xcm_executor::{30	Assets,31	traits::{MatchesFungible, WeightTrader},32};33use pallet_foreign_assets::{AssetIds, NativeCurrency};34use sp_std::marker::PhantomData;35use crate::{Balances, ParachainInfo};36use super::{LocationToAccountId, RelayLocation};3738use up_common::types::{AccountId, Balance};3940pub struct OnlySelfCurrency;41impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {42	fn matches_fungible(a: &MultiAsset) -> Option<B> {43		let paraid = Parachain(ParachainInfo::parachain_id().into());44		match (&a.id, &a.fun) {45			(46				Concrete(MultiLocation {47					parents: 1,48					interior: X1(loc),49				}),50				XcmFungible(ref amount),51			) if paraid == *loc => CheckedConversion::checked_from(*amount),52			(53				Concrete(MultiLocation {54					parents: 0,55					interior: Here,56				}),57				XcmFungible(ref amount),58			) => CheckedConversion::checked_from(*amount),59			_ => None,60		}61	}62}6364/// Means for transacting assets on this chain.65pub type LocalAssetTransactor = CurrencyAdapter<66	// Use this currency:67	Balances,68	// Use this currency when it is a fungible asset matching the given location or name:69	OnlySelfCurrency,70	// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:71	LocationToAccountId,72	// Our chain's account ID type (we can't get away without mentioning it explicitly):73	AccountId,74	// We don't track any teleports.75	(),76>;7778pub type AssetTransactors = LocalAssetTransactor;7980pub type IsReserve = NativeAsset;8182pub struct UsingOnlySelfCurrencyComponents<83	WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,84	AssetId: Get<MultiLocation>,85	AccountId,86	Currency: CurrencyT<AccountId>,87	OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,88>(89	Weight,90	Currency::Balance,91	PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,92);93impl<94		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,95		AssetId: Get<MultiLocation>,96		AccountId,97		Currency: CurrencyT<AccountId>,98		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,99	> WeightTrader100	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>101{102	fn new() -> Self {103		Self(0, Zero::zero(), PhantomData)104	}105106	fn buy_weight(&mut self, _weight: Weight, payment: Assets) -> Result<Assets, XcmError> {107		Ok(payment)108	}109}110impl<111		WeightToFee: WeightToFeePolynomial<Balance = Currency::Balance>,112		AssetId: Get<MultiLocation>,113		AccountId,114		Currency: CurrencyT<AccountId>,115		OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,116	> Drop117	for UsingOnlySelfCurrencyComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>118{119	fn drop(&mut self) {120		OnUnbalanced::on_unbalanced(Currency::issue(self.1));121	}122}123124pub type Trader<T> = UsingOnlySelfCurrencyComponents<125	pallet_configuration::WeightToFee<T, Balance>,126	RelayLocation,127	AccountId,128	Balances,129	(),130>;131132pub struct CurrencyIdConvert;133impl Convert<AssetIds, Option<MultiLocation>> for CurrencyIdConvert {134	fn convert(id: AssetIds) -> Option<MultiLocation> {135		match id {136			AssetIds::NativeAssetId(NativeCurrency::Here) => Some(MultiLocation::new(137				1,138				X1(Parachain(ParachainInfo::get().into())),139			)),140			_ => None,141		}142	}143}
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -39,10 +39,7 @@
 #[cfg(feature = "std")]
 use sp_version::NativeVersion;
 
-use crate::{
-	Runtime, Call, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,
-	InherentDataExt,
-};
+use crate::{Runtime, Call, Balances, Treasury, Aura, Signature, AllPalletsWithSystem, InherentDataExt};
 use up_common::types::{AccountId, BlockNumber};
 
 #[macro_export]
@@ -105,7 +102,7 @@
 	Block,
 	frame_system::ChainContext<Runtime>,
 	Runtime,
-	AllPalletsWithSystem
+	AllPalletsWithSystem,
 >;
 
 type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -15,7 +15,10 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::traits::Everything;
-use xcm::{latest::{Xcm, Weight}, v1::MultiLocation};
+use xcm::{
+	latest::{Xcm, Weight},
+	v1::MultiLocation,
+};
 use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit};
 use xcm_executor::traits::ShouldExecute;