git.delta.rocks / unique-network / refs/commits / 7168c554956e

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2021-07-27parent: #0e47fc5.patch.diff
in: master

7 files changed

modifiedcrates/evm-coder-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder-macros/src/lib.rs
+++ b/crates/evm-coder-macros/src/lib.rs
@@ -5,7 +5,10 @@
 use proc_macro::TokenStream;
 use quote::quote;
 use sha3::{Digest, Keccak256};
-use syn::{AttributeArgs, DeriveInput, GenericArgument, Ident, ItemImpl, Pat, Path, PathArguments, PathSegment, Type, parse_macro_input, spanned::Spanned};
+use syn::{
+	AttributeArgs, DeriveInput, GenericArgument, Ident, ItemImpl, Pat, Path, PathArguments,
+	PathSegment, Type, parse_macro_input, spanned::Spanned,
+};
 
 mod solidity_interface;
 mod to_log;
@@ -196,11 +199,12 @@
 		Err(e) => e.to_compile_error(),
 	};
 
-    (quote! {
-        #input
+	(quote! {
+		#input
 
-        #expanded
-    }).into()
+		#expanded
+	})
+	.into()
 }
 
 #[proc_macro_attribute]
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -54,11 +54,11 @@
 }
 
 pub trait Call: Sized {
-    fn parse(selector: u32, input: &mut AbiReader) -> execution::Result<Option<Self>>;
+	fn parse(selector: u32, input: &mut AbiReader) -> execution::Result<Option<Self>>;
 }
 
 pub trait Callable<C: Call> {
-    fn call(&mut self, call: types::Msg<C>) -> execution::Result<AbiWriter>;
+	fn call(&mut self, call: types::Msg<C>) -> execution::Result<AbiWriter>;
 }
 
 #[cfg(test)]
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
before · crates/evm-coder/src/solidity.rs
1#[cfg(not(feature = "std"))]2use alloc::{string::String};3use core::{fmt, marker::PhantomData};4use impl_trait_for_tuples::impl_for_tuples;5use crate::types::*;67pub trait SolidityTypeName: 'static {8	fn solidity_name(writer: &mut impl fmt::Write) -> fmt::Result;9	fn is_void() -> bool {10		false11	}12}1314macro_rules! solidity_type_name {15    ($($ty:ident => $name:expr),* $(,)?) => {16        $(17            impl SolidityTypeName for $ty {18                fn solidity_name(writer: &mut impl core::fmt::Write) -> core::fmt::Result {19                    write!(writer, $name)20                }21            }22        )*23    };24}2526solidity_type_name! {27	uint8 => "uint8",28	uint32 => "uint32",29	uint128 => "uint128",30	uint256 => "uint256",31	address => "address",32	string => "memory string",33	bytes => "memory bytes",34	bool => "bool",35}36impl SolidityTypeName for void {37	fn solidity_name(_writer: &mut impl fmt::Write) -> fmt::Result {38		Ok(())39	}40	fn is_void() -> bool {41		true42	}43}4445pub trait SolidityArguments {46	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result;47	fn is_empty(&self) -> bool {48		self.len() == 049	}50	fn len(&self) -> usize;51}5253#[derive(Default)]54pub struct UnnamedArgument<T>(PhantomData<*const T>);5556impl<T: SolidityTypeName> SolidityArguments for UnnamedArgument<T> {57	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {58		if !T::is_void() {59			T::solidity_name(writer)60		} else {61			Ok(())62		}63	}64	fn len(&self) -> usize {65		if T::is_void() {66			067		} else {68			169		}70	}71}7273pub struct NamedArgument<T>(&'static str, PhantomData<*const T>);7475impl<T> NamedArgument<T> {76	pub fn new(name: &'static str) -> Self {77		Self(name, Default::default())78	}79}8081impl<T: SolidityTypeName> SolidityArguments for NamedArgument<T> {82	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {83		if !T::is_void() {84			T::solidity_name(writer)?;85			write!(writer, " {}", self.0)86		} else {87			Ok(())88		}89	}90	fn len(&self) -> usize {91		if T::is_void() {92			093		} else {94			195		}96	}97}9899impl SolidityArguments for () {100	fn solidity_name(&self, _writer: &mut impl fmt::Write) -> fmt::Result {101		Ok(())102	}103	fn len(&self) -> usize {104		0105	}106}107108#[impl_for_tuples(1, 5)]109impl SolidityArguments for Tuple {110	for_tuples!( where #( Tuple: SolidityArguments ),* );111112	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {113		let mut first = true;114		for_tuples!( #(115            if !Tuple.is_empty() {116                if !first {117                    write!(writer, ", ")?;118                }119                first = false;120                Tuple.solidity_name(writer)?;121            }122        )* );123		Ok(())124	}125	fn len(&self) -> usize {126		for_tuples!( #( Tuple.len() )+* )127	}128}129130pub trait SolidityFunctions {131	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result;132}133134pub enum SolidityMutability {135	Pure,136	View,137	Mutable,138}139pub struct SolidityFunction<A, R> {140	pub name: &'static str,141	pub args: A,142	pub result: R,143	pub mutability: SolidityMutability,144}145impl<A: SolidityArguments, R: SolidityArguments> SolidityFunctions for SolidityFunction<A, R> {146	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {147		write!(writer, "function {}(", self.name)?;148		self.args.solidity_name(writer)?;149		write!(writer, ") external")?;150		match &self.mutability {151			SolidityMutability::Pure => write!(writer, " pure")?,152			SolidityMutability::View => write!(writer, " view")?,153			SolidityMutability::Mutable => {}154		}155		if !self.result.is_empty() {156			write!(writer, " returns (")?;157			self.result.solidity_name(writer)?;158			write!(writer, ")")?;159		}160		writeln!(writer, ";")161	}162}163164#[impl_for_tuples(0, 12)]165impl SolidityFunctions for Tuple {166	for_tuples!( where #( Tuple: SolidityFunctions ),* );167168	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {169		let mut first = false;170		for_tuples!( #(171            Tuple.solidity_name(writer)?;172        )* );173		Ok(())174	}175}176177pub struct SolidityInterface<F: SolidityFunctions> {178	pub name: &'static str,179	pub functions: F,180}181182impl<F: SolidityFunctions> SolidityInterface<F> {183	pub fn format(&self, out: &mut impl fmt::Write) -> fmt::Result {184		writeln!(out, "interface {} {{", self.name)?;185		self.functions.solidity_name(out)?;186		writeln!(out, "}}")?;187		Ok(())188	}189}
after · crates/evm-coder/src/solidity.rs
1#[cfg(not(feature = "std"))]2use alloc::{string::String};3use core::{fmt, marker::PhantomData};4use impl_trait_for_tuples::impl_for_tuples;5use crate::types::*;67pub trait SolidityTypeName: 'static {8	fn solidity_name(writer: &mut impl fmt::Write) -> fmt::Result;9	fn is_void() -> bool {10		false11	}12}1314macro_rules! solidity_type_name {15    ($($ty:ident => $name:expr),* $(,)?) => {16        $(17            impl SolidityTypeName for $ty {18                fn solidity_name(writer: &mut impl core::fmt::Write) -> core::fmt::Result {19                    write!(writer, $name)20                }21            }22        )*23    };24}2526solidity_type_name! {27	uint8 => "uint8",28	uint32 => "uint32",29	uint128 => "uint128",30	uint256 => "uint256",31	address => "address",32	string => "memory string",33	bytes => "memory bytes",34	bool => "bool",35}36impl SolidityTypeName for void {37	fn solidity_name(_writer: &mut impl fmt::Write) -> fmt::Result {38		Ok(())39	}40	fn is_void() -> bool {41		true42	}43}4445pub trait SolidityArguments {46	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result;47	fn is_empty(&self) -> bool {48		self.len() == 049	}50	fn len(&self) -> usize;51}5253#[derive(Default)]54pub struct UnnamedArgument<T>(PhantomData<*const T>);5556impl<T: SolidityTypeName> SolidityArguments for UnnamedArgument<T> {57	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {58		if !T::is_void() {59			T::solidity_name(writer)60		} else {61			Ok(())62		}63	}64	fn len(&self) -> usize {65		if T::is_void() {66			067		} else {68			169		}70	}71}7273pub struct NamedArgument<T>(&'static str, PhantomData<*const T>);7475impl<T> NamedArgument<T> {76	pub fn new(name: &'static str) -> Self {77		Self(name, Default::default())78	}79}8081impl<T: SolidityTypeName> SolidityArguments for NamedArgument<T> {82	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {83		if !T::is_void() {84			T::solidity_name(writer)?;85			write!(writer, " {}", self.0)86		} else {87			Ok(())88		}89	}90	fn len(&self) -> usize {91		if T::is_void() {92			093		} else {94			195		}96	}97}9899impl SolidityArguments for () {100	fn solidity_name(&self, _writer: &mut impl fmt::Write) -> fmt::Result {101		Ok(())102	}103	fn len(&self) -> usize {104		0105	}106}107108#[impl_for_tuples(1, 5)]109impl SolidityArguments for Tuple {110	for_tuples!( where #( Tuple: SolidityArguments ),* );111112	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {113		let mut first = true;114		for_tuples!( #(115            if !Tuple.is_empty() {116                if !first {117                    write!(writer, ", ")?;118                }119                first = false;120                Tuple.solidity_name(writer)?;121            }122        )* );123		Ok(())124	}125	fn len(&self) -> usize {126		for_tuples!( #( Tuple.len() )+* )127	}128}129130pub trait SolidityFunctions {131	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result;132}133134pub enum SolidityMutability {135	Pure,136	View,137	Mutable,138}139pub struct SolidityFunction<A, R> {140	pub name: &'static str,141	pub args: A,142	pub result: R,143	pub mutability: SolidityMutability,144}145impl<A: SolidityArguments, R: SolidityArguments> SolidityFunctions for SolidityFunction<A, R> {146	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {147		write!(writer, "function {}(", self.name)?;148		self.args.solidity_name(writer)?;149		write!(writer, ") external")?;150		match &self.mutability {151			SolidityMutability::Pure => write!(writer, " pure")?,152			SolidityMutability::View => write!(writer, " view")?,153			SolidityMutability::Mutable => {}154		}155		if !self.result.is_empty() {156			write!(writer, " returns (")?;157			self.result.solidity_name(writer)?;158			write!(writer, ")")?;159		}160		writeln!(writer, ";")161	}162}163164#[impl_for_tuples(0, 12)]165impl SolidityFunctions for Tuple {166	for_tuples!( where #( Tuple: SolidityFunctions ),* );167168	fn solidity_name(&self, writer: &mut impl fmt::Write) -> fmt::Result {169		let mut first = false;170		for_tuples!( #(171            Tuple.solidity_name(writer)?;172        )* );173		Ok(())174	}175}176177pub struct SolidityInterface<F: SolidityFunctions> {178	pub name: &'static str,179	pub functions: F,180}181182impl<F: SolidityFunctions> SolidityInterface<F> {183	pub fn format(&self, out: &mut impl fmt::Write) -> fmt::Result {184		writeln!(out, "interface {} {{", self.name)?;185		self.functions.solidity_name(out)?;186		writeln!(out, "}}")?;187		Ok(())188	}189}
modifiedcrates/evm-coder/tests/a.rsdiffbeforeafterboth
--- a/crates/evm-coder/tests/a.rs
+++ b/crates/evm-coder/tests/a.rs
@@ -8,33 +8,38 @@
 #[solidity_interface(name = "OurInterface")]
 impl Impls {
 	fn fn_a(&self, input: uint256) -> Result<bool> {
-        todo!()
-    }
+		todo!()
+	}
 }
 
 #[solidity_interface(name = "OurInterface1")]
 impl Impls {
 	fn fn_b(&self, input: uint128) -> Result<uint32> {
-        todo!()
-    }
+		todo!()
+	}
 }
 
-#[solidity_interface(name = "OurInterface2", is(OurInterface), inline_is(OurInterface1), events(ERC721Log))]
+#[solidity_interface(
+	name = "OurInterface2",
+	is(OurInterface),
+	inline_is(OurInterface1),
+	events(ERC721Log)
+)]
 impl Impls {
 	#[solidity(rename_selector = "fnK")]
 	fn fn_c(&self, input: uint32) -> Result<uint8> {
-        todo!()
-    }
+		todo!()
+	}
 	fn fn_d(&self, value: uint32) -> Result<uint32> {
-        todo!()
-    }
+		todo!()
+	}
 
 	fn caller_sensitive(&self, caller: caller) -> Result<uint8> {
-        todo!()
-    }
+		todo!()
+	}
 	fn payable(&mut self, value: value) -> Result<uint8> {
-        todo!()
-    }
+		todo!()
+	}
 }
 
 #[derive(ToLog)]
@@ -58,14 +63,14 @@
 #[solidity_interface(name = "ERC20")]
 impl ERC20 {
 	fn decimals(&self) -> Result<uint8> {
-        todo!()
-    }
+		todo!()
+	}
 	fn balance_of(&self, owner: address) -> Result<uint256> {
-        todo!()
-    }
+		todo!()
+	}
 	fn transfer(&mut self, caller: caller, to: address, value: uint256) -> Result<bool> {
-        todo!()
-    }
+		todo!()
+	}
 	fn transfer_from(
 		&mut self,
 		caller: caller,
@@ -73,12 +78,13 @@
 		to: address,
 		value: uint256,
 	) -> Result<bool> {
-        todo!()
-    }
+		todo!()
+	}
 	fn approve(&mut self, caller: caller, spender: address, value: uint256) -> Result<bool> {
-        todo!()
-    }
+		todo!()
+	}
 	fn allowance(&self, owner: address, spender: address) -> Result<uint256> {
-        todo!()
-    }
+		todo!()
+	}
 }
+
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -304,7 +304,7 @@
 
 		nft_rpc::create_full::<_, _, _, RuntimeApi, _>(full_deps, subscription_executor.clone())
 	});
-	
+
 	task_manager.spawn_essential_handle().spawn(
 		"frontier-mapping-sync-worker",
 		MappingSyncWorker::new(
@@ -313,7 +313,8 @@
 			client.clone(),
 			backend.clone(),
 			frontier_backend.clone(),
-		).for_each(|()| futures::future::ready(()))
+		)
+		.for_each(|()| futures::future::ready(())),
 	);
 
 	sc_service::spawn_tasks(sc_service::SpawnTasksParams {
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -136,7 +136,7 @@
 			let limit = <SponsoringRateLimit<T>>::get(&call.0);
 			if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {
 				<SponsorBasket<T>>::insert(&call.0, who, block_number);
-				let limit_time = last_tx_block + limit.into();
+				let limit_time = last_tx_block + limit;
 				if block_number > limit_time {
 					return Some(call.0);
 				}
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -281,7 +281,7 @@
 impl pallet_ethereum::Config for Runtime {
 	type Event = Event;
 	type StateRoot = pallet_ethereum::IntermediateStateRoot;
-	type EvmSubmitLog = pallet_evm::Pallet<Runtime>;
+	type EvmSubmitLog = pallet_evm::Pallet<Self>;
 }
 
 impl pallet_randomness_collective_flip::Config for Runtime {}
@@ -329,7 +329,7 @@
 	/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
 	type SS58Prefix = SS58Prefix;
 	/// Weight information for the extrinsics of this pallet.
-	type SystemWeightInfo = system::weights::SubstrateWeight<Runtime>;
+	type SystemWeightInfo = system::weights::SubstrateWeight<Self>;
 	/// Version of the runtime.
 	type Version = Version;
 }
@@ -363,7 +363,7 @@
 	type DustRemoval = Treasury;
 	type ExistentialDeposit = ExistentialDeposit;
 	type AccountStore = System;
-	type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
+	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
 }
 
 pub const MICROUNIQUE: Balance = 1_000_000_000;
@@ -487,7 +487,7 @@
 	type Burn = Burn;
 	type BurnDestination = ();
 	type SpendFunds = ();
-	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
+	type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;
 	type MaxApprovals = MaxApprovals;
 }
 
@@ -516,7 +516,7 @@
 impl cumulus_pallet_parachain_system::Config for Runtime {
 	type Event = Event;
 	type OnValidationData = ();
-	type SelfParaId = parachain_info::Pallet<Runtime>;
+	type SelfParaId = parachain_info::Pallet<Self>;
 	// type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
 	// 	MaxDownwardMessageWeight,
 	// 	XcmExecutor<XcmConfig>,