difftreelog
fix cargo fmt
in: master
7 files changed
crates/evm-coder/src/execution.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/>.1617//! Contract execution related types1819#[cfg(not(feature = "std"))]20use alloc::string::{String, ToString};21use evm_core::{ExitError, ExitFatal};22#[cfg(feature = "std")]23use std::string::{String, ToString};2425use crate::Weight;2627/// Execution error, should be convertible between EVM and Substrate.28#[derive(Debug, Clone)]29pub enum Error {30 /// Non-fatal contract error occured31 Revert(String),32 /// EVM fatal error33 Fatal(ExitFatal),34 /// EVM normal error35 Error(ExitError),36}3738impl<E> From<E> for Error39where40 E: ToString,41{42 fn from(e: E) -> Self {43 Self::Revert(e.to_string())44 }45}4647/// To be used in [`crate::solidity_interface`] implementation.48pub type Result<T> = core::result::Result<T, Error>;4950/// Static information collected from [`crate::weight`].51pub struct DispatchInfo {52 /// Statically predicted call weight53 pub weight: Weight,54}5556impl From<Weight> for DispatchInfo {57 fn from(weight: Weight) -> Self {58 Self { weight }59 }60}61impl From<u64> for DispatchInfo {62 fn from(weight: u64) -> Self {63 Self { weight: Weight::from_ref_time(weight) }64 }65}66impl From<()> for DispatchInfo {67 fn from(_: ()) -> Self {68 Self { weight: Weight::zero() }69 }70}7172/// Weight information that is only available post dispatch.73/// Note: This can only be used to reduce the weight or fee, not increase it.74#[derive(Default, Clone)]75pub struct PostDispatchInfo {76 /// Actual weight consumed by call77 actual_weight: Option<Weight>,78}7980impl PostDispatchInfo {81 /// Calculate amount to be returned back to user82 pub fn calc_unspent(&self, info: &DispatchInfo) -> Weight {83 info.weight - self.calc_actual_weight(info)84 }8586 /// Calculate actual consumed weight, saturating to weight reported87 /// pre-dispatch88 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {89 if let Some(actual_weight) = self.actual_weight {90 actual_weight.min(info.weight)91 } else {92 info.weight93 }94 }95}9697/// Wrapper for PostDispatchInfo and any user-provided data98#[derive(Clone)]99pub struct WithPostDispatchInfo<T> {100 /// User provided data101 pub data: T,102 /// Info known after dispatch103 pub post_info: PostDispatchInfo,104}105106impl<T> From<T> for WithPostDispatchInfo<T> {107 fn from(data: T) -> Self {108 Self {109 data,110 post_info: Default::default(),111 }112 }113}114115/// Return type of items in [`crate::solidity_interface`] definition116pub type ResultWithPostInfo<T> =117 core::result::Result<WithPostDispatchInfo<T>, WithPostDispatchInfo<Error>>;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/>.1617//! Contract execution related types1819#[cfg(not(feature = "std"))]20use alloc::string::{String, ToString};21use evm_core::{ExitError, ExitFatal};22#[cfg(feature = "std")]23use std::string::{String, ToString};2425use crate::Weight;2627/// Execution error, should be convertible between EVM and Substrate.28#[derive(Debug, Clone)]29pub enum Error {30 /// Non-fatal contract error occured31 Revert(String),32 /// EVM fatal error33 Fatal(ExitFatal),34 /// EVM normal error35 Error(ExitError),36}3738impl<E> From<E> for Error39where40 E: ToString,41{42 fn from(e: E) -> Self {43 Self::Revert(e.to_string())44 }45}4647/// To be used in [`crate::solidity_interface`] implementation.48pub type Result<T> = core::result::Result<T, Error>;4950/// Static information collected from [`crate::weight`].51pub struct DispatchInfo {52 /// Statically predicted call weight53 pub weight: Weight,54}5556impl From<Weight> for DispatchInfo {57 fn from(weight: Weight) -> Self {58 Self { weight }59 }60}61impl From<u64> for DispatchInfo {62 fn from(weight: u64) -> Self {63 Self {64 weight: Weight::from_ref_time(weight),65 }66 }67}68impl From<()> for DispatchInfo {69 fn from(_: ()) -> Self {70 Self {71 weight: Weight::zero(),72 }73 }74}7576/// Weight information that is only available post dispatch.77/// Note: This can only be used to reduce the weight or fee, not increase it.78#[derive(Default, Clone)]79pub struct PostDispatchInfo {80 /// Actual weight consumed by call81 actual_weight: Option<Weight>,82}8384impl PostDispatchInfo {85 /// Calculate amount to be returned back to user86 pub fn calc_unspent(&self, info: &DispatchInfo) -> Weight {87 info.weight - self.calc_actual_weight(info)88 }8990 /// Calculate actual consumed weight, saturating to weight reported91 /// pre-dispatch92 pub fn calc_actual_weight(&self, info: &DispatchInfo) -> Weight {93 if let Some(actual_weight) = self.actual_weight {94 actual_weight.min(info.weight)95 } else {96 info.weight97 }98 }99}100101/// Wrapper for PostDispatchInfo and any user-provided data102#[derive(Clone)]103pub struct WithPostDispatchInfo<T> {104 /// User provided data105 pub data: T,106 /// Info known after dispatch107 pub post_info: PostDispatchInfo,108}109110impl<T> From<T> for WithPostDispatchInfo<T> {111 fn from(data: T) -> Self {112 Self {113 data,114 post_info: Default::default(),115 }116 }117}118119/// Return type of items in [`crate::solidity_interface`] definition120pub type ResultWithPostInfo<T> =121 core::result::Result<WithPostDispatchInfo<T>, WithPostDispatchInfo<Error>>;node/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,
pallets/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.
pallets/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;
runtime/common/config/xcm/nativeassets.rsdiffbeforeafterboth--- a/runtime/common/config/xcm/nativeassets.rs
+++ b/runtime/common/config/xcm/nativeassets.rs
@@ -23,8 +23,7 @@
use xcm::latest::{
AssetId::{Concrete},
Fungibility::Fungible as XcmFungible,
- MultiAsset, Error as XcmError,
- Weight,
+ MultiAsset, Error as XcmError, Weight,
};
use xcm_builder::{CurrencyAdapter, NativeAsset};
use xcm_executor::{
runtime/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;
runtime/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;