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

difftreelog

feat Add custum signature with unlimited nesting.

Trubnikov Sergey2022-10-19parent: #01896ba.patch.diff
in: master

17 files changed

modifiedcrates/evm-coder/procedural/src/solidity_interface.rsdiffbeforeafterboth
--- a/crates/evm-coder/procedural/src/solidity_interface.rs
+++ b/crates/evm-coder/procedural/src/solidity_interface.rs
@@ -21,7 +21,7 @@
 // https://doc.rust-lang.org/reference/procedural-macros.html
 
 use proc_macro2::{TokenStream, Group};
-use quote::{quote, ToTokens};
+use quote::{quote, ToTokens, format_ident};
 use inflector::cases;
 use std::fmt::Write;
 use syn::{
@@ -725,25 +725,20 @@
 		}
 	}
 
-	fn expand_selector(&self) -> proc_macro2::TokenStream {
-		let custom_signature = self.expand_custom_signature();
-		quote! {
-			 {
-				let a = ::evm_coder::sha3_const::Keccak256::new()
-					.update(#custom_signature.as_bytes())
-					.finalize();
-				[a[0], a[1], a[2], a[3]]
-			}
-		}
-	}
-
 	fn expand_const(&self) -> proc_macro2::TokenStream {
 		let screaming_name = &self.screaming_name;
+		let screaming_name_signature = format_ident!("{}_SIGNATURE", &self.screaming_name);
 		let selector_str = &self.selector_str;
-		let selector = &self.expand_selector();
+		let custom_signature = self.expand_custom_signature();
 		quote! {
+			const #screaming_name_signature: ::evm_coder::custom_signature::FunctionSignature = #custom_signature;
 			#[doc = #selector_str]
-			const #screaming_name: ::evm_coder::types::bytes4 = #selector;
+			const #screaming_name: ::evm_coder::types::bytes4 = {
+				let a = ::evm_coder::sha3_const::Keccak256::new()
+				.update_with_size(&Self::#screaming_name_signature.signature, Self::#screaming_name_signature.signature_len)
+				.finalize();
+				[a[0], a[1], a[2], a[3]]
+			};
 		}
 	}
 
@@ -847,9 +842,8 @@
 	}
 
 	fn expand_custom_signature(&self) -> proc_macro2::TokenStream {
-		let mut first_comma = true;
 		let mut custom_signature = TokenStream::new();
-		let mut template = self.camel_name.clone() + "(";
+
 		self.args
 			.iter()
 			.filter_map(|a| {
@@ -863,39 +857,18 @@
 				}
 			})
 			.for_each(|ident| {
-				if !first_comma {
-					custom_signature.extend(quote!(,));
-					template.push(',');
-				} else {
-					first_comma = false;
-				};
-				template.push_str("{}");
-				let ident_str = ident.to_string();
-				match ident_str.as_str() {
-					"address" | "uint8" | "uint16" | "uint32" | "uint64" | "uint128"
-					| "uint256" | "bytes4" | "topic" | "string" | "bytes" | "void" | "caller"
-					| "bool" | "" => {
-						custom_signature.extend(quote!(#ident_str));
-					}
-					_ => {
-						custom_signature.extend(quote! {
-							#ident::SIGNATURE_STRING
-						});
-					}
-				}
+				custom_signature.extend(quote! {
+					(<#ident>::SIGNATURE, <#ident>::SIGNATURE_LEN)
+				});
 			});
 
-		template.push(')');
-		let mut template = quote!(#template);
-		template.extend(quote!(,));
-		template.extend(custom_signature);
-		let custom_signature_group = Group::new(proc_macro2::Delimiter::Parenthesis, template);
-		let mut custom_signature = quote! {
-			::evm_coder::const_format::formatcp!
-		};
-		custom_signature.extend(custom_signature_group.to_token_stream());
+		let func_name = self.camel_name.clone();
+		let func_name = quote!(FunctionName::new(#func_name));
+		custom_signature =
+			quote!({ ::evm_coder::make_signature!(new fn(& #func_name),#custom_signature) });
+
+		// println!("!!!!! {}", custom_signature);
 
-		println!("!!!!! {}", custom_signature);
 		custom_signature
 	}
 
@@ -915,16 +888,23 @@
 			.map(MethodArg::expand_solidity_argument);
 		let docs = &self.docs;
 		let selector_str = &self.selector_str;
-		let selector = &self.expand_selector();
+		let screaming_name = &self.screaming_name;
 		let hide = self.hide;
 		let custom_signature = self.expand_custom_signature();
+		let custom_signature = quote!(
+			{
+				const cs: FunctionSignature = #custom_signature;
+				cs
+			}
+		);
+		// println!("!!!!! {}", custom_signature);
 		let is_payable = self.has_value_args;
-		quote! {
+		let out = quote! {
 			SolidityFunction {
 				docs: &[#(#docs),*],
 				selector_str: #selector_str,
 				hide: #hide,
-				selector: u32::from_be_bytes(#selector),
+				selector: u32::from_be_bytes(Self::#screaming_name),
 				custom_signature: #custom_signature,
 				name: #camel_name,
 				mutability: #mutability,
@@ -936,7 +916,9 @@
 				),
 				result: <UnnamedArgument<#result>>::default(),
 			}
-		}
+		};
+		// println!("@@@ {}", out);
+		out
 	}
 }
 
addedcrates/evm-coder/src/custom_signature.rsdiffbeforeafterboth
--- /dev/null
+++ b/crates/evm-coder/src/custom_signature.rs
@@ -0,0 +1,336 @@
+use core::str::from_utf8;
+
+pub const SIGNATURE_SIZE_LIMIT: usize = 256;
+
+pub trait Name {
+	const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];
+	const SIGNATURE_LEN: usize;
+
+	fn name() -> &'static str {
+		from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")
+	}
+}
+
+#[derive(Debug)]
+pub struct FunctionSignature {
+	pub signature: [u8; SIGNATURE_SIZE_LIMIT],
+	pub signature_len: usize,
+}
+
+impl FunctionSignature {
+	pub const fn new(name: &'static FunctionName) -> FunctionSignature {
+		let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];
+		let name_len = name.signature_len;
+		let name = name.signature;
+		let mut dst_offset = 0;
+		let bracket_open = {
+			let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+			b[0] = b"("[0];
+			b
+		};
+		crate::make_signature!(@copy(name, signature, name_len, dst_offset));
+		crate::make_signature!(@copy(bracket_open, signature, 1, dst_offset));
+		FunctionSignature {
+			signature,
+			signature_len: dst_offset,
+		}
+	}
+
+	pub const fn add_param(
+		signature: FunctionSignature,
+		param: ([u8; SIGNATURE_SIZE_LIMIT], usize),
+	) -> FunctionSignature {
+		let mut dst = signature.signature;
+		let mut dst_offset = signature.signature_len;
+		let (param_name, param_len) = param;
+		let comma = {
+			let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+			b[0] = b","[0];
+			b
+		};
+		FunctionSignature {
+			signature: {
+				crate::make_signature!(@copy(param_name, dst, param_len, dst_offset));
+				crate::make_signature!(@copy(comma, dst, 1, dst_offset));
+				dst
+			},
+			signature_len: dst_offset,
+		}
+	}
+
+	pub const fn done(signature: FunctionSignature, owerride: bool) -> FunctionSignature {
+		let mut dst = signature.signature;
+		let mut dst_offset = signature.signature_len - if owerride { 1 } else { 0 };
+		let bracket_close = {
+			let mut b = [0_u8; SIGNATURE_SIZE_LIMIT];
+			b[0] = b")"[0];
+			b
+		};
+		FunctionSignature {
+			signature: {
+				crate::make_signature!(@copy(bracket_close, dst, 1, dst_offset));
+				dst
+			},
+			signature_len: dst_offset,
+		}
+	}
+
+	// fn as_str(&self) -> &'static str {
+	// 	from_utf8(&self.signature[..self.signature_len]).expect("bad utf-8")
+	// }
+}
+
+#[derive(Debug)]
+pub struct FunctionName {
+	signature: [u8; SIGNATURE_SIZE_LIMIT],
+	signature_len: usize,
+}
+
+impl FunctionName {
+	pub const fn new(name: &'static str) -> FunctionName {
+		let mut signature = [0_u8; SIGNATURE_SIZE_LIMIT];
+		let name = name.as_bytes();
+		let name_len = name.len();
+		let mut dst_offset = 0;
+		crate::make_signature!(@copy(name, signature, name_len, dst_offset));
+		FunctionName {
+			signature,
+			signature_len: name_len,
+		}
+	}
+}
+
+#[macro_export]
+#[allow(missing_docs)]
+macro_rules! make_signature { // May be "define_signature"?
+	(new fn($func:expr)$(,)+) => {
+		{
+			let fs = FunctionSignature::new(& $func);
+			let fs = FunctionSignature::done(fs, false);
+			fs
+		}
+	};
+	(new fn($func:expr), $($tt:tt)*) => {
+		{
+			let fs = FunctionSignature::new(& $func);
+			let fs = make_signature!(@param; fs, $($tt),*);
+			fs
+		}
+	};
+
+	(@param; $func:expr) => {
+		FunctionSignature::done($func, true)
+	};
+	(@param; $func:expr, $param:expr) => {
+		make_signature!(@param; FunctionSignature::add_param($func, $param))
+	};
+	(@param; $func:expr, $param:expr, $($tt:tt),*) => {
+		make_signature!(@param; FunctionSignature::add_param($func, $param), $($tt),*)
+	};
+
+    (new $($tt:tt)*) => {
+        const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = {
+            let mut out = [0u8; SIGNATURE_SIZE_LIMIT];
+            let mut dst_offset = 0;
+            make_signature!(@data(out, dst_offset); $($tt)*);
+            out
+        };
+        const SIGNATURE_LEN: usize = 0 + make_signature!(@size; $($tt)*);
+    };
+
+	// (@bytes)
+
+    (@size;) => {
+        0
+    };
+    (@size; fixed($expr:expr) $($tt:tt)*) => {
+        $expr.len() + make_signature!(@size; $($tt)*)
+    };
+    (@size; nameof($expr:ty) $($tt:tt)*) => {
+        <$expr>::SIGNATURE_LEN + make_signature!(@size; $($tt)*)
+    };
+
+    (@data($dst:ident, $dst_offset:ident);) => {};
+    (@data($dst:ident, $dst_offset:ident); fixed($expr:expr) $($tt:tt)*) => {
+        {
+            let data = $expr.as_bytes();
+			let data_len = data.len();
+			make_signature!(@copy(data, $dst, data_len, $dst_offset));
+        }
+        make_signature!(@data($dst, $dst_offset); $($tt)*)
+    };
+    (@data($dst:ident, $dst_offset:ident); nameof($expr:ty) $($tt:tt)*) => {
+        {
+			let data = &<$expr>::SIGNATURE;
+			let data_len = <$expr>::SIGNATURE_LEN;
+            make_signature!(@copy(data, $dst, data_len, $dst_offset));
+        }
+        make_signature!(@data($dst, $dst_offset); $($tt)*)
+    };
+
+	(@copy($src:ident, $dst:ident, $src_len:expr, $dst_offset:ident)) => {
+		{
+			let mut src_offset = 0;
+			let src_len: usize = $src_len;
+			while src_offset < src_len {
+				$dst[$dst_offset] = $src[src_offset];
+				$dst_offset += 1;
+				src_offset += 1;
+			}
+		}
+	}
+}
+
+#[cfg(test)]
+mod test {
+	use core::str::from_utf8;
+
+	use frame_support::sp_runtime::app_crypto::sp_core::hexdisplay::AsBytesRef;
+
+	use super::{Name, SIGNATURE_SIZE_LIMIT, FunctionName, FunctionSignature};
+
+	impl Name for u8 {
+		make_signature!(new fixed("uint8"));
+	}
+	impl Name for u32 {
+		make_signature!(new fixed("uint32"));
+	}
+	impl<T: Name> Name for Vec<T> {
+		make_signature!(new nameof(T) fixed("[]"));
+	}
+	impl<A: Name, B: Name> Name for (A, B) {
+		make_signature!(new fixed("(") nameof(A) fixed(",") nameof(B) fixed(")"));
+	}
+
+	struct MaxSize();
+	impl Name for MaxSize {
+		const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT] = [b'!'; SIGNATURE_SIZE_LIMIT];
+		const SIGNATURE_LEN: usize = SIGNATURE_SIZE_LIMIT;
+	}
+
+	#[test]
+	fn simple() {
+		assert_eq!(u8::name(), "uint8");
+		assert_eq!(u32::name(), "uint32");
+	}
+
+	#[test]
+	fn vector_of_simple() {
+		assert_eq!(<Vec<u8>>::name(), "uint8[]");
+		assert_eq!(<Vec<u32>>::name(), "uint32[]");
+	}
+
+	#[test]
+	fn vector_of_vector() {
+		assert_eq!(<Vec<Vec<u8>>>::name(), "uint8[][]");
+	}
+
+	#[test]
+	fn tuple_of_simple() {
+		assert_eq!(<(u32, u8)>::name(), "(uint32,uint8)");
+	}
+
+	#[test]
+	fn tuple_of_tuple() {
+		assert_eq!(
+			<((u32, u8), (u8, u32))>::name(),
+			"((uint32,uint8),(uint8,uint32))"
+		);
+	}
+
+	#[test]
+	fn vector_of_tuple() {
+		assert_eq!(<Vec<(u32, u8)>>::name(), "(uint32,uint8)[]");
+	}
+
+	#[test]
+	fn tuple_of_vector() {
+		assert_eq!(<(Vec<u32>, u8)>::name(), "(uint32[],uint8)");
+	}
+
+	#[test]
+	fn complex() {
+		assert_eq!(
+			<(Vec<u32>, (u32, Vec<u8>))>::name(),
+			"(uint32[],(uint32,uint8[]))"
+		);
+	}
+
+	#[test]
+	fn max_size() {
+		assert_eq!(<MaxSize>::name(), "!".repeat(SIGNATURE_SIZE_LIMIT));
+	}
+
+	// This test must NOT compile!
+	// #[test]
+	// fn over_max_size() {
+	// 	assert_eq!(<Vec<MaxSize>>::name(), "!".repeat(SIZE_LIMIT) + "[]");
+	// }
+
+	#[test]
+	fn make_func_without_args() {
+		const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+		const SIG: FunctionSignature = make_signature!(
+			new fn(&SOME_FUNK_NAME),
+		);
+		let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+		assert_eq!(name, "some_funk()");
+	}
+
+	#[test]
+	fn make_func_with_1_args() {
+		const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+		const SIG: FunctionSignature = make_signature!(
+			new fn(&SOME_FUNK_NAME),
+			(u8::SIGNATURE, u8::SIGNATURE_LEN)
+		);
+		let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+		assert_eq!(name, "some_funk(uint8)");
+	}
+
+	#[test]
+	fn make_func_with_2_args() {
+		const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+		const SIG: FunctionSignature = make_signature!(
+			new fn(&SOME_FUNK_NAME),
+			(u8::SIGNATURE, u8::SIGNATURE_LEN)
+			(<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+		);
+		let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+		assert_eq!(name, "some_funk(uint8,uint32[])");
+	}
+
+	#[test]
+	fn make_func_with_3_args() {
+		const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+		const SIG: FunctionSignature = make_signature!(
+			new fn(&SOME_FUNK_NAME),
+			(u8::SIGNATURE, u8::SIGNATURE_LEN)
+			(u32::SIGNATURE, u32::SIGNATURE_LEN)
+			(<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+		);
+		let name = from_utf8(&SIG.signature[..SIG.signature_len]).unwrap();
+		assert_eq!(name, "some_funk(uint8,uint32,uint32[])");
+	}
+
+	#[test]
+	fn make_slice_from_signature() {
+		const SOME_FUNK_NAME: FunctionName = FunctionName::new("some_funk");
+		const SIG: FunctionSignature = make_signature!(
+			new fn(&SOME_FUNK_NAME),
+			(u8::SIGNATURE, u8::SIGNATURE_LEN)
+			(u32::SIGNATURE, u32::SIGNATURE_LEN)
+			(<Vec<u32>>::SIGNATURE, <Vec<u32>>::SIGNATURE_LEN)
+		);
+		const NAME: [u8; SIG.signature_len] = {
+			let mut name: [u8; SIG.signature_len] = [0; SIG.signature_len];
+			let mut i = 0;
+			while i < SIG.signature_len {
+				name[i] = SIG.signature[i];
+				i += 1;
+			}
+			name
+		};
+		assert_eq!(&NAME, b"some_funk(uint8,uint32,uint32[])");
+	}
+}
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -15,7 +15,9 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 #![doc = include_str!("../README.md")]
-#![deny(missing_docs)]
+// #![deny(missing_docs)]
+#![warn(missing_docs)]
+#![macro_use]
 #![cfg_attr(not(feature = "std"), no_std)]
 #[cfg(not(feature = "std"))]
 extern crate alloc;
@@ -26,6 +28,8 @@
 pub use events::{ToLog, ToTopic};
 use execution::DispatchInfo;
 pub mod execution;
+#[macro_use]
+pub mod custom_signature;
 
 /// Derives call enum implementing [`crate::Callable`], [`crate::Weighted`]
 /// and [`crate::Call`] from impl block.
@@ -118,27 +122,54 @@
 	use alloc::{vec::Vec};
 	use pallet_evm::account::CrossAccountId;
 	use primitive_types::{U256, H160, H256};
+	use core::str::from_utf8;
 
-	pub type address = H160;
+	use crate::custom_signature::SIGNATURE_SIZE_LIMIT;
 
-	pub type uint8 = u8;
-	pub type uint16 = u16;
-	pub type uint32 = u32;
-	pub type uint64 = u64;
-	pub type uint128 = u128;
-	pub type uint256 = U256;
+	pub trait Signature {
+		const SIGNATURE: [u8; SIGNATURE_SIZE_LIMIT];
+		const SIGNATURE_LEN: usize;
 
-	pub type bytes4 = [u8; 4];
+		fn as_str() -> &'static str {
+			from_utf8(&Self::SIGNATURE[..Self::SIGNATURE_LEN]).expect("bad utf-8")
+		}
+	}
 
-	pub type topic = H256;
+	impl Signature for bool {
+		make_signature!(new fixed("bool"));
+	}
 
+	macro_rules! define_simple_type {
+		(type $ident:ident = $ty:ty) => {
+			pub type $ident = $ty;
+			impl Signature for $ty {
+				make_signature!(new fixed(stringify!($ident)));
+			}
+		};
+	}
+
+	define_simple_type!(type address = H160);
+
+	define_simple_type!(type uint8 = u8);
+	define_simple_type!(type uint16 = u16);
+	define_simple_type!(type uint32 = u32);
+	define_simple_type!(type uint64 = u64);
+	define_simple_type!(type uint128 = u128);
+	define_simple_type!(type uint256 = U256);
+	define_simple_type!(type bytes4 = [u8; 4]);
+
+	define_simple_type!(type topic = H256);
+
 	#[cfg(not(feature = "std"))]
-	pub type string = ::alloc::string::String;
+	define_simple_type!(type string = ::alloc::string::String);
 	#[cfg(feature = "std")]
-	pub type string = ::std::string::String;
+	define_simple_type!(type string = ::std::string::String);
 
 	#[derive(Default, Debug)]
 	pub struct bytes(pub Vec<u8>);
+	impl Signature for bytes {
+		make_signature!(new fixed("bytes"));
+	}
 
 	/// Solidity doesn't have `void` type, however we have special implementation
 	/// for empty tuple return type
@@ -230,12 +261,8 @@
 		}
 	}
 
-	impl SignatureString for EthCrossAccount {
-		const SIGNATURE_STRING: &'static str = "(address,uint256)";
-	}
-
-	pub trait SignatureString {
-		const SIGNATURE_STRING: &'static str;
+	impl Signature for EthCrossAccount {
+		make_signature!(new fixed("(address,uint256)"));
 	}
 
 	/// Convert `CrossAccountId` to `uint256`.
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -30,9 +30,10 @@
 	marker::PhantomData,
 	cell::{Cell, RefCell},
 	cmp::Reverse,
+	str::from_utf8,
 };
 use impl_trait_for_tuples::impl_for_tuples;
-use crate::types::*;
+use crate::{types::*, custom_signature::FunctionSignature};
 
 #[derive(Default)]
 pub struct TypeCollector {
@@ -487,7 +488,7 @@
 	pub selector_str: &'static str,
 	pub selector: u32,
 	pub hide: bool,
-	pub custom_signature: &'static str,
+	pub custom_signature: FunctionSignature,
 	pub name: &'static str,
 	pub args: A,
 	pub result: R,
@@ -513,7 +514,8 @@
 		writeln!(
 			writer,
 			"\t{hide_comment}///  or in textual repr: {}",
-			self.custom_signature
+			// from_utf8(self.custom_signature.as_str()).expect("bad utf8")
+			self.selector_str
 		)?;
 		write!(writer, "\t{hide_comment}function {}(", self.name)?;
 		self.args.solidity_name(writer, tc)?;
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -21,6 +21,8 @@
 	types::*,
 	execution::{Result, Error},
 	weight,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
 };
 pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};
 use pallet_evm_coder_substrate::dispatch_to_evm;
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
before · pallets/evm-contract-helpers/src/eth.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/>.1617//! Implementation of magic contract1819extern crate alloc;20use alloc::{format, string::ToString};21use core::marker::PhantomData;22use evm_coder::{23	abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,24};25use pallet_evm::{26	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,27	account::CrossAccountId,28};29use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};30use pallet_evm_transaction_payment::CallContext;31use sp_core::{H160, U256};32use up_data_structs::SponsorshipState;33use crate::{34	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,35	SponsoringRateLimit, SponsoringModeT, Sponsoring,36};37use frame_support::traits::Get;38use up_sponsorship::SponsorshipHandler;39use sp_std::vec::Vec;4041/// Pallet events.42#[derive(ToLog)]43pub enum ContractHelpersEvents {44	/// Contract sponsor was set.45	ContractSponsorSet {46		/// Contract address of the affected collection.47		#[indexed]48		contract_address: address,49		/// New sponsor address.50		sponsor: address,51	},5253	/// New sponsor was confirm.54	ContractSponsorshipConfirmed {55		/// Contract address of the affected collection.56		#[indexed]57		contract_address: address,58		/// New sponsor address.59		sponsor: address,60	},6162	/// Collection sponsor was removed.63	ContractSponsorRemoved {64		/// Contract address of the affected collection.65		#[indexed]66		contract_address: address,67	},68}6970/// See [`ContractHelpersCall`]71pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);72impl<T: Config> WithRecorder<T> for ContractHelpers<T> {73	fn recorder(&self) -> &SubstrateRecorder<T> {74		&self.075	}7677	fn into_recorder(self) -> SubstrateRecorder<T> {78		self.079	}80}8182/// @title Magic contract, which allows users to reconfigure other contracts83#[solidity_interface(name = ContractHelpers, events(ContractHelpersEvents))]84impl<T: Config> ContractHelpers<T>85where86	T::AccountId: AsRef<[u8; 32]>,87{88	/// Get user, which deployed specified contract89	/// @dev May return zero address in case if contract is deployed90	///  using uniquenetwork evm-migration pallet, or using other terms not91	///  intended by pallet-evm92	/// @dev Returns zero address if contract does not exists93	/// @param contractAddress Contract to get owner of94	/// @return address Owner of contract95	fn contract_owner(&self, contract_address: address) -> Result<address> {96		Ok(<Owner<T>>::get(contract_address))97	}9899	/// Set sponsor.100	/// @param contractAddress Contract for which a sponsor is being established.101	/// @param sponsor User address who set as pending sponsor.102	fn set_sponsor(103		&mut self,104		caller: caller,105		contract_address: address,106		sponsor: address,107	) -> Result<void> {108		self.recorder().consume_sload()?;109		self.recorder().consume_sstore()?;110111		Pallet::<T>::set_sponsor(112			&T::CrossAccountId::from_eth(caller),113			contract_address,114			&T::CrossAccountId::from_eth(sponsor),115		)116		.map_err(dispatch_to_evm::<T>)?;117118		Ok(())119	}120121	/// Set contract as self sponsored.122	///123	/// @param contractAddress Contract for which a self sponsoring is being enabled.124	fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {125		self.recorder().consume_sload()?;126		self.recorder().consume_sstore()?;127128		let caller = T::CrossAccountId::from_eth(caller);129130		Pallet::<T>::ensure_owner(contract_address, *caller.as_eth())131			.map_err(dispatch_to_evm::<T>)?;132133		Pallet::<T>::force_set_sponsor(134			contract_address,135			&T::CrossAccountId::from_eth(contract_address),136		)137		.map_err(dispatch_to_evm::<T>)?;138139		Ok(())140	}141142	/// Remove sponsor.143	///144	/// @param contractAddress Contract for which a sponsorship is being removed.145	fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {146		self.recorder().consume_sload()?;147		self.recorder().consume_sstore()?;148149		Pallet::<T>::remove_sponsor(&T::CrossAccountId::from_eth(caller), contract_address)150			.map_err(dispatch_to_evm::<T>)?;151152		Ok(())153	}154155	/// Confirm sponsorship.156	///157	/// @dev Caller must be same that set via [`setSponsor`].158	///159	/// @param contractAddress Сontract for which need to confirm sponsorship.160	fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {161		self.recorder().consume_sload()?;162		self.recorder().consume_sstore()?;163164		Pallet::<T>::confirm_sponsorship(&T::CrossAccountId::from_eth(caller), contract_address)165			.map_err(dispatch_to_evm::<T>)?;166167		Ok(())168	}169170	/// Get current sponsor.171	///172	/// @param contractAddress The contract for which a sponsor is requested.173	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.174	fn sponsor(&self, contract_address: address) -> Result<(address, uint256)> {175		let sponsor =176			Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;177		Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(178			&sponsor,179		))180	}181182	/// Check tat contract has confirmed sponsor.183	///184	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.185	/// @return **true** if contract has confirmed sponsor.186	fn has_sponsor(&self, contract_address: address) -> Result<bool> {187		Ok(Pallet::<T>::get_sponsor(contract_address).is_some())188	}189190	/// Check tat contract has pending sponsor.191	///192	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.193	/// @return **true** if contract has pending sponsor.194	fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {195		Ok(match Sponsoring::<T>::get(contract_address) {196			SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,197			SponsorshipState::Unconfirmed(_) => true,198		})199	}200201	fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {202		Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)203	}204205	fn set_sponsoring_mode(206		&mut self,207		caller: caller,208		contract_address: address,209		// TODO: implement support for enums in evm-coder210		mode: uint8,211	) -> Result<void> {212		self.recorder().consume_sload()?;213		self.recorder().consume_sstore()?;214215		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;216		let mode = SponsoringModeT::from_eth(mode).ok_or("unknown mode")?;217		<Pallet<T>>::set_sponsoring_mode(contract_address, mode);218219		Ok(())220	}221222	/// Get current contract sponsoring rate limit223	/// @param contractAddress Contract to get sponsoring rate limit of224	/// @return uint32 Amount of blocks between two sponsored transactions225	fn sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {226		self.recorder().consume_sload()?;227228		Ok(<SponsoringRateLimit<T>>::get(contract_address)229			.try_into()230			.map_err(|_| "rate limit > u32::MAX")?)231	}232233	/// Set contract sponsoring rate limit234	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should235	///  pass between two sponsored transactions236	/// @param contractAddress Contract to change sponsoring rate limit of237	/// @param rateLimit Target rate limit238	/// @dev Only contract owner can change this setting239	fn set_sponsoring_rate_limit(240		&mut self,241		caller: caller,242		contract_address: address,243		rate_limit: uint32,244	) -> Result<void> {245		self.recorder().consume_sload()?;246		self.recorder().consume_sstore()?;247248		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;249		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());250		Ok(())251	}252253	/// Set contract sponsoring fee limit254	/// @dev Sponsoring fee limit - is maximum fee that could be spent by255	///  single transaction256	/// @param contractAddress Contract to change sponsoring fee limit of257	/// @param feeLimit Fee limit258	/// @dev Only contract owner can change this setting259	fn set_sponsoring_fee_limit(260		&mut self,261		caller: caller,262		contract_address: address,263		fee_limit: uint256,264	) -> Result<void> {265		self.recorder().consume_sload()?;266		self.recorder().consume_sstore()?;267268		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;269		<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into())270			.map_err(dispatch_to_evm::<T>)?;271		Ok(())272	}273274	/// Get current contract sponsoring fee limit275	/// @param contractAddress Contract to get sponsoring fee limit of276	/// @return uint256 Maximum amount of fee that could be spent by single277	///  transaction278	fn sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {279		self.recorder().consume_sload()?;280281		Ok(get_sponsoring_fee_limit::<T>(contract_address))282	}283284	/// Is specified user present in contract allow list285	/// @dev Contract owner always implicitly included286	/// @param contractAddress Contract to check allowlist of287	/// @param user User to check288	/// @return bool Is specified users exists in contract allowlist289	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {290		self.0.consume_sload()?;291		Ok(<Pallet<T>>::allowed(contract_address, user))292	}293294	/// Toggle user presence in contract allowlist295	/// @param contractAddress Contract to change allowlist of296	/// @param user Which user presence should be toggled297	/// @param isAllowed `true` if user should be allowed to be sponsored298	///  or call this contract, `false` otherwise299	/// @dev Only contract owner can change this setting300	fn toggle_allowed(301		&mut self,302		caller: caller,303		contract_address: address,304		user: address,305		is_allowed: bool,306	) -> Result<void> {307		self.recorder().consume_sload()?;308		self.recorder().consume_sstore()?;309310		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;311		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);312313		Ok(())314	}315316	/// Is this contract has allowlist access enabled317	/// @dev Allowlist always can have users, and it is used for two purposes:318	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist319	///  in case of allowlist access enabled, only users from allowlist may call this contract320	/// @param contractAddress Contract to get allowlist access of321	/// @return bool Is specified contract has allowlist access enabled322	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {323		Ok(<AllowlistEnabled<T>>::get(contract_address))324	}325326	/// Toggle contract allowlist access327	/// @param contractAddress Contract to change allowlist access of328	/// @param enabled Should allowlist access to be enabled?329	fn toggle_allowlist(330		&mut self,331		caller: caller,332		contract_address: address,333		enabled: bool,334	) -> Result<void> {335		self.recorder().consume_sload()?;336		self.recorder().consume_sstore()?;337338		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;339		<Pallet<T>>::toggle_allowlist(contract_address, enabled);340		Ok(())341	}342}343344/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]345pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);346impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>347where348	T::AccountId: AsRef<[u8; 32]>,349{350	fn is_reserved(contract: &sp_core::H160) -> bool {351		contract == &T::ContractAddress::get()352	}353354	fn is_used(contract: &sp_core::H160) -> bool {355		contract == &T::ContractAddress::get()356	}357358	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {359		// TODO: Extract to another OnMethodCall handler360		if <AllowlistEnabled<T>>::get(handle.code_address())361			&& !<Pallet<T>>::allowed(handle.code_address(), handle.context().caller)362		{363			return Some(Err(PrecompileFailure::Revert {364				exit_status: ExitRevert::Reverted,365				output: {366					let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));367					writer.string("Target contract is allowlisted");368					writer.finish()369				},370			}));371		}372373		if handle.code_address() != T::ContractAddress::get() {374			return None;375		}376377		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));378		pallet_evm_coder_substrate::call(handle, helpers)379	}380381	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {382		(contract == &T::ContractAddress::get())383			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())384	}385}386387/// Hooks into contract creation, storing owner of newly deployed contract388pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);389impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {390	fn on_create(owner: H160, contract: H160) {391		<Owner<T>>::insert(contract, owner);392	}393}394395/// Bridge to pallet-sponsoring396pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);397impl<T: Config> SponsorshipHandler<T::CrossAccountId, CallContext>398	for HelpersContractSponsoring<T>399{400	fn get_sponsor(401		who: &T::CrossAccountId,402		call_context: &CallContext,403	) -> Option<T::CrossAccountId> {404		let contract_address = call_context.contract_address;405		let mode = <Pallet<T>>::sponsoring_mode(contract_address);406		if mode == SponsoringModeT::Disabled {407			return None;408		}409410		let sponsor = match <Pallet<T>>::get_sponsor(contract_address) {411			Some(sponsor) => sponsor,412			None => return None,413		};414415		if mode == SponsoringModeT::Allowlisted416			&& !<Pallet<T>>::allowed(contract_address, *who.as_eth())417		{418			return None;419		}420		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;421422		if let Some(last_tx_block) = <SponsorBasket<T>>::get(contract_address, who.as_eth()) {423			let limit = <SponsoringRateLimit<T>>::get(contract_address);424425			let timeout = last_tx_block + limit;426			if block_number < timeout {427				return None;428			}429		}430431		let sponsored_fee_limit = get_sponsoring_fee_limit::<T>(contract_address);432433		if call_context.max_fee > sponsored_fee_limit {434			return None;435		}436437		<SponsorBasket<T>>::insert(contract_address, who.as_eth(), block_number);438439		Some(sponsor)440	}441}442443fn get_sponsoring_fee_limit<T: Config>(contract_address: address) -> uint256 {444	<SponsoringFeeLimit<T>>::get(contract_address)445		.get(&0xffffffff)446		.cloned()447		.unwrap_or(U256::MAX)448}449450generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);451generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);
after · pallets/evm-contract-helpers/src/eth.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/>.1617//! Implementation of magic contract1819extern crate alloc;20use alloc::{format, string::ToString};21use core::marker::PhantomData;22use evm_coder::{23	abi::AbiWriter,24	execution::Result,25	generate_stubgen, solidity_interface,26	types::*,27	ToLog,28	custom_signature::{FunctionName, FunctionSignature},29	make_signature,30};31use pallet_evm::{32	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,33	account::CrossAccountId,34};35use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder, dispatch_to_evm};36use pallet_evm_transaction_payment::CallContext;37use sp_core::{H160, U256};38use up_data_structs::SponsorshipState;39use crate::{40	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,41	SponsoringRateLimit, SponsoringModeT, Sponsoring,42};43use frame_support::traits::Get;44use up_sponsorship::SponsorshipHandler;45use sp_std::vec::Vec;4647/// Pallet events.48#[derive(ToLog)]49pub enum ContractHelpersEvents {50	/// Contract sponsor was set.51	ContractSponsorSet {52		/// Contract address of the affected collection.53		#[indexed]54		contract_address: address,55		/// New sponsor address.56		sponsor: address,57	},5859	/// New sponsor was confirm.60	ContractSponsorshipConfirmed {61		/// Contract address of the affected collection.62		#[indexed]63		contract_address: address,64		/// New sponsor address.65		sponsor: address,66	},6768	/// Collection sponsor was removed.69	ContractSponsorRemoved {70		/// Contract address of the affected collection.71		#[indexed]72		contract_address: address,73	},74}7576/// See [`ContractHelpersCall`]77pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);78impl<T: Config> WithRecorder<T> for ContractHelpers<T> {79	fn recorder(&self) -> &SubstrateRecorder<T> {80		&self.081	}8283	fn into_recorder(self) -> SubstrateRecorder<T> {84		self.085	}86}8788/// @title Magic contract, which allows users to reconfigure other contracts89#[solidity_interface(name = ContractHelpers, events(ContractHelpersEvents))]90impl<T: Config> ContractHelpers<T>91where92	T::AccountId: AsRef<[u8; 32]>,93{94	/// Get user, which deployed specified contract95	/// @dev May return zero address in case if contract is deployed96	///  using uniquenetwork evm-migration pallet, or using other terms not97	///  intended by pallet-evm98	/// @dev Returns zero address if contract does not exists99	/// @param contractAddress Contract to get owner of100	/// @return address Owner of contract101	fn contract_owner(&self, contract_address: address) -> Result<address> {102		Ok(<Owner<T>>::get(contract_address))103	}104105	/// Set sponsor.106	/// @param contractAddress Contract for which a sponsor is being established.107	/// @param sponsor User address who set as pending sponsor.108	fn set_sponsor(109		&mut self,110		caller: caller,111		contract_address: address,112		sponsor: address,113	) -> Result<void> {114		self.recorder().consume_sload()?;115		self.recorder().consume_sstore()?;116117		Pallet::<T>::set_sponsor(118			&T::CrossAccountId::from_eth(caller),119			contract_address,120			&T::CrossAccountId::from_eth(sponsor),121		)122		.map_err(dispatch_to_evm::<T>)?;123124		Ok(())125	}126127	/// Set contract as self sponsored.128	///129	/// @param contractAddress Contract for which a self sponsoring is being enabled.130	fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<void> {131		self.recorder().consume_sload()?;132		self.recorder().consume_sstore()?;133134		let caller = T::CrossAccountId::from_eth(caller);135136		Pallet::<T>::ensure_owner(contract_address, *caller.as_eth())137			.map_err(dispatch_to_evm::<T>)?;138139		Pallet::<T>::force_set_sponsor(140			contract_address,141			&T::CrossAccountId::from_eth(contract_address),142		)143		.map_err(dispatch_to_evm::<T>)?;144145		Ok(())146	}147148	/// Remove sponsor.149	///150	/// @param contractAddress Contract for which a sponsorship is being removed.151	fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<void> {152		self.recorder().consume_sload()?;153		self.recorder().consume_sstore()?;154155		Pallet::<T>::remove_sponsor(&T::CrossAccountId::from_eth(caller), contract_address)156			.map_err(dispatch_to_evm::<T>)?;157158		Ok(())159	}160161	/// Confirm sponsorship.162	///163	/// @dev Caller must be same that set via [`setSponsor`].164	///165	/// @param contractAddress Сontract for which need to confirm sponsorship.166	fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<void> {167		self.recorder().consume_sload()?;168		self.recorder().consume_sstore()?;169170		Pallet::<T>::confirm_sponsorship(&T::CrossAccountId::from_eth(caller), contract_address)171			.map_err(dispatch_to_evm::<T>)?;172173		Ok(())174	}175176	/// Get current sponsor.177	///178	/// @param contractAddress The contract for which a sponsor is requested.179	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.180	fn sponsor(&self, contract_address: address) -> Result<(address, uint256)> {181		let sponsor =182			Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;183		Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(184			&sponsor,185		))186	}187188	/// Check tat contract has confirmed sponsor.189	///190	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.191	/// @return **true** if contract has confirmed sponsor.192	fn has_sponsor(&self, contract_address: address) -> Result<bool> {193		Ok(Pallet::<T>::get_sponsor(contract_address).is_some())194	}195196	/// Check tat contract has pending sponsor.197	///198	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.199	/// @return **true** if contract has pending sponsor.200	fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {201		Ok(match Sponsoring::<T>::get(contract_address) {202			SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,203			SponsorshipState::Unconfirmed(_) => true,204		})205	}206207	fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {208		Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)209	}210211	fn set_sponsoring_mode(212		&mut self,213		caller: caller,214		contract_address: address,215		// TODO: implement support for enums in evm-coder216		mode: uint8,217	) -> Result<void> {218		self.recorder().consume_sload()?;219		self.recorder().consume_sstore()?;220221		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;222		let mode = SponsoringModeT::from_eth(mode).ok_or("unknown mode")?;223		<Pallet<T>>::set_sponsoring_mode(contract_address, mode);224225		Ok(())226	}227228	/// Get current contract sponsoring rate limit229	/// @param contractAddress Contract to get sponsoring rate limit of230	/// @return uint32 Amount of blocks between two sponsored transactions231	fn sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {232		self.recorder().consume_sload()?;233234		Ok(<SponsoringRateLimit<T>>::get(contract_address)235			.try_into()236			.map_err(|_| "rate limit > u32::MAX")?)237	}238239	/// Set contract sponsoring rate limit240	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should241	///  pass between two sponsored transactions242	/// @param contractAddress Contract to change sponsoring rate limit of243	/// @param rateLimit Target rate limit244	/// @dev Only contract owner can change this setting245	fn set_sponsoring_rate_limit(246		&mut self,247		caller: caller,248		contract_address: address,249		rate_limit: uint32,250	) -> Result<void> {251		self.recorder().consume_sload()?;252		self.recorder().consume_sstore()?;253254		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;255		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());256		Ok(())257	}258259	/// Set contract sponsoring fee limit260	/// @dev Sponsoring fee limit - is maximum fee that could be spent by261	///  single transaction262	/// @param contractAddress Contract to change sponsoring fee limit of263	/// @param feeLimit Fee limit264	/// @dev Only contract owner can change this setting265	fn set_sponsoring_fee_limit(266		&mut self,267		caller: caller,268		contract_address: address,269		fee_limit: uint256,270	) -> Result<void> {271		self.recorder().consume_sload()?;272		self.recorder().consume_sstore()?;273274		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;275		<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit.into())276			.map_err(dispatch_to_evm::<T>)?;277		Ok(())278	}279280	/// Get current contract sponsoring fee limit281	/// @param contractAddress Contract to get sponsoring fee limit of282	/// @return uint256 Maximum amount of fee that could be spent by single283	///  transaction284	fn sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {285		self.recorder().consume_sload()?;286287		Ok(get_sponsoring_fee_limit::<T>(contract_address))288	}289290	/// Is specified user present in contract allow list291	/// @dev Contract owner always implicitly included292	/// @param contractAddress Contract to check allowlist of293	/// @param user User to check294	/// @return bool Is specified users exists in contract allowlist295	fn allowed(&self, contract_address: address, user: address) -> Result<bool> {296		self.0.consume_sload()?;297		Ok(<Pallet<T>>::allowed(contract_address, user))298	}299300	/// Toggle user presence in contract allowlist301	/// @param contractAddress Contract to change allowlist of302	/// @param user Which user presence should be toggled303	/// @param isAllowed `true` if user should be allowed to be sponsored304	///  or call this contract, `false` otherwise305	/// @dev Only contract owner can change this setting306	fn toggle_allowed(307		&mut self,308		caller: caller,309		contract_address: address,310		user: address,311		is_allowed: bool,312	) -> Result<void> {313		self.recorder().consume_sload()?;314		self.recorder().consume_sstore()?;315316		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;317		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);318319		Ok(())320	}321322	/// Is this contract has allowlist access enabled323	/// @dev Allowlist always can have users, and it is used for two purposes:324	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist325	///  in case of allowlist access enabled, only users from allowlist may call this contract326	/// @param contractAddress Contract to get allowlist access of327	/// @return bool Is specified contract has allowlist access enabled328	fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {329		Ok(<AllowlistEnabled<T>>::get(contract_address))330	}331332	/// Toggle contract allowlist access333	/// @param contractAddress Contract to change allowlist access of334	/// @param enabled Should allowlist access to be enabled?335	fn toggle_allowlist(336		&mut self,337		caller: caller,338		contract_address: address,339		enabled: bool,340	) -> Result<void> {341		self.recorder().consume_sload()?;342		self.recorder().consume_sstore()?;343344		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;345		<Pallet<T>>::toggle_allowlist(contract_address, enabled);346		Ok(())347	}348}349350/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]351pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);352impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>353where354	T::AccountId: AsRef<[u8; 32]>,355{356	fn is_reserved(contract: &sp_core::H160) -> bool {357		contract == &T::ContractAddress::get()358	}359360	fn is_used(contract: &sp_core::H160) -> bool {361		contract == &T::ContractAddress::get()362	}363364	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {365		// TODO: Extract to another OnMethodCall handler366		if <AllowlistEnabled<T>>::get(handle.code_address())367			&& !<Pallet<T>>::allowed(handle.code_address(), handle.context().caller)368		{369			return Some(Err(PrecompileFailure::Revert {370				exit_status: ExitRevert::Reverted,371				output: {372					let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));373					writer.string("Target contract is allowlisted");374					writer.finish()375				},376			}));377		}378379		if handle.code_address() != T::ContractAddress::get() {380			return None;381		}382383		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));384		pallet_evm_coder_substrate::call(handle, helpers)385	}386387	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {388		(contract == &T::ContractAddress::get())389			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())390	}391}392393/// Hooks into contract creation, storing owner of newly deployed contract394pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);395impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {396	fn on_create(owner: H160, contract: H160) {397		<Owner<T>>::insert(contract, owner);398	}399}400401/// Bridge to pallet-sponsoring402pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);403impl<T: Config> SponsorshipHandler<T::CrossAccountId, CallContext>404	for HelpersContractSponsoring<T>405{406	fn get_sponsor(407		who: &T::CrossAccountId,408		call_context: &CallContext,409	) -> Option<T::CrossAccountId> {410		let contract_address = call_context.contract_address;411		let mode = <Pallet<T>>::sponsoring_mode(contract_address);412		if mode == SponsoringModeT::Disabled {413			return None;414		}415416		let sponsor = match <Pallet<T>>::get_sponsor(contract_address) {417			Some(sponsor) => sponsor,418			None => return None,419		};420421		if mode == SponsoringModeT::Allowlisted422			&& !<Pallet<T>>::allowed(contract_address, *who.as_eth())423		{424			return None;425		}426		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;427428		if let Some(last_tx_block) = <SponsorBasket<T>>::get(contract_address, who.as_eth()) {429			let limit = <SponsoringRateLimit<T>>::get(contract_address);430431			let timeout = last_tx_block + limit;432			if block_number < timeout {433				return None;434			}435		}436437		let sponsored_fee_limit = get_sponsoring_fee_limit::<T>(contract_address);438439		if call_context.max_fee > sponsored_fee_limit {440			return None;441		}442443		<SponsorBasket<T>>::insert(contract_address, who.as_eth(), block_number);444445		Some(sponsor)446	}447}448449fn get_sponsoring_fee_limit<T: Config>(contract_address: address) -> uint256 {450	<SponsoringFeeLimit<T>>::get(contract_address)451		.get(&0xffffffff)452		.cloned()453		.unwrap_or(U256::MAX)454}455456generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);457generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -20,7 +20,15 @@
 use alloc::{format, string::ToString};
 use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
 use core::convert::TryInto;
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
+use evm_coder::{
+	ToLog,
+	execution::*,
+	generate_stubgen, solidity_interface,
+	types::*,
+	weight,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
+};
 use pallet_common::eth::convert_tuple_to_cross_account;
 use up_data_structs::CollectionMode;
 use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -25,7 +25,15 @@
 	char::{REPLACEMENT_CHARACTER, decode_utf16},
 	convert::TryInto,
 };
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+	ToLog,
+	execution::*,
+	generate_stubgen, solidity, solidity_interface,
+	types::*,
+	weight,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
+};
 use frame_support::BoundedVec;
 use up_data_structs::{
 	TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,
modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -104,7 +104,11 @@
 }
 
 /// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
 /// @dev the ERC-165 identifier for this interface is 0xb3152af3
+=======
+/// @dev the ERC-165 identifier for this interface is 0x674be726
+>>>>>>> feat: Add custum signature with unlimited nesting.
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -198,7 +202,7 @@
 	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
 	///
 	/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
-	/// @dev EVM selector for this function is: 0x84a1d5a8,
+	/// @dev EVM selector for this function is: 0x403e96a7,
 	///  or in textual repr: setCollectionSponsorCross((address,uint256))
 	function setCollectionSponsorCross(Tuple6 memory sponsor) public {
 		require(false, stub_error);
@@ -239,6 +243,7 @@
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
 <<<<<<< HEAD
+<<<<<<< HEAD
 	function collectionSponsor() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
@@ -249,6 +254,12 @@
 		dummy;
 		return Tuple19(0x0000000000000000000000000000000000000000, 0);
 >>>>>>> feat: add `EthCrossAccount` type
+=======
+	function collectionSponsor() public view returns (Tuple8 memory) {
+		require(false, stub_error);
+		dummy;
+		return Tuple8(0x0000000000000000000000000000000000000000, 0);
+>>>>>>> feat: Add custum signature with unlimited nesting.
 	}
 
 	/// Set limits for the collection.
@@ -297,7 +308,7 @@
 
 	/// Add collection admin.
 	/// @param newAdmin Cross account administrator address.
-	/// @dev EVM selector for this function is: 0x859aa7d6,
+	/// @dev EVM selector for this function is: 0x62e3c7c2,
 	///  or in textual repr: addCollectionAdminCross((address,uint256))
 	function addCollectionAdminCross(Tuple6 memory newAdmin) public {
 		require(false, stub_error);
@@ -307,7 +318,7 @@
 
 	/// Remove collection admin.
 	/// @param admin Cross account administrator address.
-	/// @dev EVM selector for this function is: 0x6c0cd173,
+	/// @dev EVM selector for this function is: 0x810d1503,
 	///  or in textual repr: removeCollectionAdminCross((address,uint256))
 	function removeCollectionAdminCross(Tuple6 memory admin) public {
 		require(false, stub_error);
@@ -351,7 +362,7 @@
 	///
 	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
 	/// @param collections Addresses of collections that will be available for nesting.
-	/// @dev EVM selector for this function is: 0x64872396,
+	/// @dev EVM selector for this function is: 0x112d4586,
 	///  or in textual repr: setCollectionNesting(bool,address[])
 	function setCollectionNesting(bool enable, address[] memory collections) public {
 		require(false, stub_error);
@@ -398,7 +409,7 @@
 	/// Add user to allowed list.
 	///
 	/// @param user User cross account address.
-	/// @dev EVM selector for this function is: 0xa0184a3a,
+	/// @dev EVM selector for this function is: 0xf074da88,
 	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
 	function addToCollectionAllowListCross(Tuple6 memory user) public {
 		require(false, stub_error);
@@ -420,7 +431,7 @@
 	/// Remove user from allowed list.
 	///
 	/// @param user User cross account address.
-	/// @dev EVM selector for this function is: 0x09ba452a,
+	/// @dev EVM selector for this function is: 0xc00df45c,
 	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
 	function removeFromCollectionAllowListCross(Tuple6 memory user) public {
 		require(false, stub_error);
@@ -456,7 +467,7 @@
 	///
 	/// @param user User cross account to verify
 	/// @return "true" if account is the owner or admin
-	/// @dev EVM selector for this function is: 0x3e75a905,
+	/// @dev EVM selector for this function is: 0x5aba3351,
 	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
 	function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {
 		require(false, stub_error);
@@ -483,6 +494,7 @@
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
 <<<<<<< HEAD
+<<<<<<< HEAD
 	function collectionOwner() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
@@ -493,6 +505,12 @@
 		dummy;
 		return Tuple19(0x0000000000000000000000000000000000000000, 0);
 >>>>>>> feat: add `EthCrossAccount` type
+=======
+	function collectionOwner() public view returns (Tuple8 memory) {
+		require(false, stub_error);
+		dummy;
+		return Tuple8(0x0000000000000000000000000000000000000000, 0);
+>>>>>>> feat: Add custum signature with unlimited nesting.
 	}
 
 	/// Changes collection owner to another account
@@ -523,7 +541,7 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner cross account
-	/// @dev EVM selector for this function is: 0xe5c9913f,
+	/// @dev EVM selector for this function is: 0xbdff793d,
 	///  or in textual repr: setOwnerCross((address,uint256))
 	function setOwnerCross(Tuple6 memory newOwner) public {
 		require(false, stub_error);
@@ -532,6 +550,7 @@
 	}
 }
 
+<<<<<<< HEAD
 /// @dev anonymous struct
 struct Tuple19 {
 	address field_0;
@@ -581,6 +600,8 @@
 	}
 }
 
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 contract ERC721Burnable is Dummy, ERC165 {
@@ -682,7 +703,11 @@
 }
 
 /// @title Unique extensions for ERC721.
+<<<<<<< HEAD
 /// @dev the ERC-165 identifier for this interface is 0x244543ee
+=======
+/// @dev the ERC-165 identifier for this interface is 0xcc97cb35
+>>>>>>> feat: Add custum signature with unlimited nesting.
 contract ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -708,7 +733,7 @@
 	///  operator of the current owner.
 	/// @param approved The new substrate address approved NFT controller
 	/// @param tokenId The NFT to approve
-	/// @dev EVM selector for this function is: 0x0ecd0ab0,
+	/// @dev EVM selector for this function is: 0x106fdb59,
 	///  or in textual repr: approveCross((address,uint256),uint256)
 	function approveCross(Tuple6 memory approved, uint256 tokenId) public {
 		require(false, stub_error);
@@ -738,10 +763,15 @@
 	/// @param to Cross acccount address of new owner
 	/// @param tokenId The NFT to transfer
 	/// @dev EVM selector for this function is: 0xd5cf430b,
-	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	///  or in textual repr: transferFromCross(EthCrossAccount,EthCrossAccount,uint256)
 	function transferFromCross(
+<<<<<<< HEAD
 		Tuple6 memory from,
 		Tuple6 memory to,
+=======
+		EthCrossAccount memory from,
+		EthCrossAccount memory to,
+>>>>>>> feat: Add custum signature with unlimited nesting.
 		uint256 tokenId
 	) public {
 		require(false, stub_error);
@@ -772,7 +802,7 @@
 	///  if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
 	/// @param from The current owner of the NFT
 	/// @param tokenId The NFT to transfer
-	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	/// @dev EVM selector for this function is: 0xa8106d4a,
 	///  or in textual repr: burnFromCross((address,uint256),uint256)
 	function burnFromCross(Tuple6 memory from, uint256 tokenId) public {
 		require(false, stub_error);
@@ -819,10 +849,46 @@
 	// 	return false;
 	// }
 
+<<<<<<< HEAD
 }
 
 /// @dev anonymous struct
 struct Tuple8 {
+=======
+	/// @notice Function to mint multiple tokens.
+	/// @dev `tokenIds` should be an array of consecutive numbers and first number
+	///  should be obtained with `nextTokenId` method
+	/// @param to The new owner
+	/// @param tokenIds IDs of the minted NFTs
+	/// @dev EVM selector for this function is: 0xf9d9a5a3,
+	///  or in textual repr: mintBulk(address,uint256[])
+	function mintBulk(address to, uint256[] memory tokenIds) public returns (bool) {
+		require(false, stub_error);
+		to;
+		tokenIds;
+		dummy = 0;
+		return false;
+	}
+
+	/// @notice Function to mint multiple tokens with the given tokenUris.
+	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+	///  numbers and first number should be obtained with `nextTokenId` method
+	/// @param to The new owner
+	/// @param tokens array of pairs of token ID and token URI for minted tokens
+	/// @dev EVM selector for this function is: 0xfd4e2a99,
+	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
+	function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) public returns (bool) {
+		require(false, stub_error);
+		to;
+		tokens;
+		dummy = 0;
+		return false;
+	}
+}
+
+/// @dev anonymous struct
+struct Tuple12 {
+>>>>>>> feat: Add custum signature with unlimited nesting.
 	uint256 field_0;
 	string field_1;
 }
@@ -840,6 +906,12 @@
 >>>>>>> feat: add `EthCrossAccount` type
 }
 
+/// @dev anonymous struct
+struct Tuple8 {
+	address field_0;
+	uint256 field_1;
+}
+
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 /// @dev See https://eips.ethereum.org/EIPS/eip-721
 /// @dev the ERC-165 identifier for this interface is 0x780e9d63
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -26,7 +26,15 @@
 	char::{REPLACEMENT_CHARACTER, decode_utf16},
 	convert::TryInto,
 };
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+	ToLog,
+	execution::*,
+	generate_stubgen, solidity, solidity_interface,
+	types::*,
+	weight,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
+};
 use frame_support::{BoundedBTreeMap, BoundedVec};
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions,
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -29,7 +29,15 @@
 	convert::TryInto,
 	ops::Deref,
 };
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
+use evm_coder::{
+	ToLog,
+	execution::*,
+	generate_stubgen, solidity_interface,
+	types::*,
+	weight,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
+};
 use pallet_common::{
 	CommonWeightInfo,
 	erc::{CommonEvmHandler, PrecompileResult},
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -18,7 +18,13 @@
 
 use core::marker::PhantomData;
 use ethereum as _;
-use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{
+	execution::*,
+	generate_stubgen, solidity, solidity_interface,
+	types::*,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
+, weight};
 use frame_support::{traits::Get, storage::StorageNMap};
 use crate::sp_api_hidden_includes_decl_storage::hidden_include::StorageDoubleMap;
 use crate::Pallet;
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -70,7 +70,11 @@
 }
 
 /// @title A contract that allows you to work with collections.
+<<<<<<< HEAD
 /// @dev the ERC-165 identifier for this interface is 0xb3152af3
+=======
+/// @dev the ERC-165 identifier for this interface is 0x674be726
+>>>>>>> feat: Add custum signature with unlimited nesting.
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -133,7 +137,7 @@
 	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
 	///
 	/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.
-	/// @dev EVM selector for this function is: 0x84a1d5a8,
+	/// @dev EVM selector for this function is: 0x403e96a7,
 	///  or in textual repr: setCollectionSponsorCross((address,uint256))
 	function setCollectionSponsorCross(Tuple6 memory sponsor) external;
 
@@ -193,13 +197,13 @@
 
 	/// Add collection admin.
 	/// @param newAdmin Cross account administrator address.
-	/// @dev EVM selector for this function is: 0x859aa7d6,
+	/// @dev EVM selector for this function is: 0x62e3c7c2,
 	///  or in textual repr: addCollectionAdminCross((address,uint256))
 	function addCollectionAdminCross(Tuple6 memory newAdmin) external;
 
 	/// Remove collection admin.
 	/// @param admin Cross account administrator address.
-	/// @dev EVM selector for this function is: 0x6c0cd173,
+	/// @dev EVM selector for this function is: 0x810d1503,
 	///  or in textual repr: removeCollectionAdminCross((address,uint256))
 	function removeCollectionAdminCross(Tuple6 memory admin) external;
 
@@ -227,7 +231,7 @@
 	///
 	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
 	/// @param collections Addresses of collections that will be available for nesting.
-	/// @dev EVM selector for this function is: 0x64872396,
+	/// @dev EVM selector for this function is: 0x112d4586,
 	///  or in textual repr: setCollectionNesting(bool,address[])
 	function setCollectionNesting(bool enable, address[] memory collections) external;
 
@@ -256,7 +260,7 @@
 	/// Add user to allowed list.
 	///
 	/// @param user User cross account address.
-	/// @dev EVM selector for this function is: 0xa0184a3a,
+	/// @dev EVM selector for this function is: 0xf074da88,
 	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
 	function addToCollectionAllowListCross(Tuple6 memory user) external;
 
@@ -270,7 +274,7 @@
 	/// Remove user from allowed list.
 	///
 	/// @param user User cross account address.
-	/// @dev EVM selector for this function is: 0x09ba452a,
+	/// @dev EVM selector for this function is: 0xc00df45c,
 	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
 	function removeFromCollectionAllowListCross(Tuple6 memory user) external;
 
@@ -293,7 +297,7 @@
 	///
 	/// @param user User cross account to verify
 	/// @return "true" if account is the owner or admin
-	/// @dev EVM selector for this function is: 0x3e75a905,
+	/// @dev EVM selector for this function is: 0x5aba3351,
 	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
 	function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);
 
@@ -332,11 +336,12 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner cross account
-	/// @dev EVM selector for this function is: 0xe5c9913f,
+	/// @dev EVM selector for this function is: 0xbdff793d,
 	///  or in textual repr: setOwnerCross((address,uint256))
 	function setOwnerCross(Tuple6 memory newOwner) external;
 }
 
+<<<<<<< HEAD
 /// @dev anonymous struct
 struct Tuple19 {
 	address field_0;
@@ -373,6 +378,8 @@
 	function tokenURI(uint256 tokenId) external view returns (string memory);
 }
 
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
 /// @title ERC721 Token that can be irreversibly burned (destroyed).
 /// @dev the ERC-165 identifier for this interface is 0x42966c68
 interface ERC721Burnable is Dummy, ERC165 {
@@ -438,7 +445,11 @@
 }
 
 /// @title Unique extensions for ERC721.
+<<<<<<< HEAD
 /// @dev the ERC-165 identifier for this interface is 0x244543ee
+=======
+/// @dev the ERC-165 identifier for this interface is 0xcc97cb35
+>>>>>>> feat: Add custum signature with unlimited nesting.
 interface ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -456,7 +467,7 @@
 	///  operator of the current owner.
 	/// @param approved The new substrate address approved NFT controller
 	/// @param tokenId The NFT to approve
-	/// @dev EVM selector for this function is: 0x0ecd0ab0,
+	/// @dev EVM selector for this function is: 0x106fdb59,
 	///  or in textual repr: approveCross((address,uint256),uint256)
 	function approveCross(Tuple6 memory approved, uint256 tokenId) external;
 
@@ -476,10 +487,15 @@
 	/// @param to Cross acccount address of new owner
 	/// @param tokenId The NFT to transfer
 	/// @dev EVM selector for this function is: 0xd5cf430b,
-	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	///  or in textual repr: transferFromCross(EthCrossAccount,EthCrossAccount,uint256)
 	function transferFromCross(
+<<<<<<< HEAD
 		Tuple6 memory from,
 		Tuple6 memory to,
+=======
+		EthCrossAccount memory from,
+		EthCrossAccount memory to,
+>>>>>>> feat: Add custum signature with unlimited nesting.
 		uint256 tokenId
 	) external;
 
@@ -499,7 +515,7 @@
 	///  if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
 	/// @param from The current owner of the NFT
 	/// @param tokenId The NFT to transfer
-	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	/// @dev EVM selector for this function is: 0xa8106d4a,
 	///  or in textual repr: burnFromCross((address,uint256),uint256)
 	function burnFromCross(Tuple6 memory from, uint256 tokenId) external;
 
@@ -507,6 +523,7 @@
 	/// @dev EVM selector for this function is: 0x75794a3c,
 	///  or in textual repr: nextTokenId()
 	function nextTokenId() external view returns (uint256);
+<<<<<<< HEAD
 	// /// @notice Function to mint multiple tokens.
 	// /// @dev `tokenIds` should be an array of consecutive numbers and first number
 	// ///  should be obtained with `nextTokenId` method
@@ -528,6 +545,30 @@
 
 /// @dev anonymous struct
 struct Tuple8 {
+=======
+
+	/// @notice Function to mint multiple tokens.
+	/// @dev `tokenIds` should be an array of consecutive numbers and first number
+	///  should be obtained with `nextTokenId` method
+	/// @param to The new owner
+	/// @param tokenIds IDs of the minted NFTs
+	/// @dev EVM selector for this function is: 0xf9d9a5a3,
+	///  or in textual repr: mintBulk(address,uint256[])
+	function mintBulk(address to, uint256[] memory tokenIds) external returns (bool);
+
+	/// @notice Function to mint multiple tokens with the given tokenUris.
+	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+	///  numbers and first number should be obtained with `nextTokenId` method
+	/// @param to The new owner
+	/// @param tokens array of pairs of token ID and token URI for minted tokens
+	/// @dev EVM selector for this function is: 0xfd4e2a99,
+	///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
+	function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);
+}
+
+/// @dev anonymous struct
+struct Tuple12 {
+>>>>>>> feat: Add custum signature with unlimited nesting.
 	uint256 field_0;
 	string field_1;
 }
@@ -538,6 +579,12 @@
 	uint256 field_1;
 }
 
+/// @dev anonymous struct
+struct Tuple8 {
+	address field_0;
+	uint256 field_1;
+}
+
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 /// @dev See https://eips.ethereum.org/EIPS/eip-721
 /// @dev the ERC-165 identifier for this interface is 0x780e9d63
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -409,7 +409,7 @@
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
   });
 
-  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
+  itEth.only('Can perform transferFromCross()', async ({helper, privateKey}) => {
     const alice = privateKey('//Alice');
     const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
 
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -251,10 +251,14 @@
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
 <<<<<<< HEAD
+<<<<<<< HEAD
         "internalType": "struct Tuple6",
 =======
         "internalType": "struct Tuple19",
 >>>>>>> feat: add `EthCrossAccount` type
+=======
+        "internalType": "struct Tuple8",
+>>>>>>> feat: Add custum signature with unlimited nesting.
         "name": "",
         "type": "tuple"
       }
@@ -263,6 +267,7 @@
     "type": "function"
   },
   {
+<<<<<<< HEAD
     "inputs": [
       { "internalType": "string[]", "name": "keys", "type": "string[]" }
     ],
@@ -278,6 +283,11 @@
         "type": "tuple[]"
       }
     ],
+=======
+    "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
+    "name": "collectionProperty",
+    "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
     "stateMutability": "view",
     "type": "function"
   },
@@ -298,10 +308,14 @@
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
 <<<<<<< HEAD
+<<<<<<< HEAD
         "internalType": "struct Tuple6",
 =======
         "internalType": "struct Tuple19",
 >>>>>>> feat: add `EthCrossAccount` type
+=======
+        "internalType": "struct Tuple8",
+>>>>>>> feat: Add custum signature with unlimited nesting.
         "name": "",
         "type": "tuple"
       }
@@ -324,6 +338,7 @@
     "type": "function"
   },
   {
+<<<<<<< HEAD
     "inputs": [
       { "internalType": "string[]", "name": "keys", "type": "string[]" }
     ],
@@ -333,6 +348,8 @@
     "type": "function"
   },
   {
+=======
+>>>>>>> feat: Add custum signature with unlimited nesting.
     "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],
     "name": "deleteCollectionProperty",
     "outputs": [],
@@ -409,19 +426,64 @@
     "type": "function"
   },
   {
+<<<<<<< HEAD
     "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
     "name": "mint",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+=======
+    "inputs": [
+      { "internalType": "address", "name": "to", "type": "address" },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "mint",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
     "stateMutability": "nonpayable",
     "type": "function"
   },
   {
     "inputs": [
       { "internalType": "address", "name": "to", "type": "address" },
+<<<<<<< HEAD
       { "internalType": "string", "name": "tokenUri", "type": "string" }
     ],
     "name": "mintWithTokenURI",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+=======
+      { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }
+    ],
+    "name": "mintBulk",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      { "internalType": "address", "name": "to", "type": "address" },
+      {
+        "components": [
+          { "internalType": "uint256", "name": "field_0", "type": "uint256" },
+          { "internalType": "string", "name": "field_1", "type": "string" }
+        ],
+        "internalType": "struct Tuple12[]",
+        "name": "tokens",
+        "type": "tuple[]"
+      }
+    ],
+    "name": "mintBulkWithTokenURI",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      { "internalType": "address", "name": "to", "type": "address" },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+      { "internalType": "string", "name": "tokenUri", "type": "string" }
+    ],
+    "name": "mintWithTokenURI",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+>>>>>>> feat: Add custum signature with unlimited nesting.
     "stateMutability": "nonpayable",
     "type": "function"
   },
@@ -614,6 +676,7 @@
   },
   {
     "inputs": [
+<<<<<<< HEAD
       {
         "components": [
           { "internalType": "string", "name": "field_0", "type": "string" },
@@ -623,6 +686,10 @@
         "name": "properties",
         "type": "tuple[]"
       }
+=======
+      { "internalType": "string", "name": "key", "type": "string" },
+      { "internalType": "bytes", "name": "value", "type": "bytes" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
     ],
     "name": "setCollectionProperties",
     "outputs": [],
@@ -667,6 +734,7 @@
   },
   {
     "inputs": [
+<<<<<<< HEAD
       {
         "components": [
           { "internalType": "address", "name": "field_0", "type": "address" },
@@ -676,6 +744,9 @@
         "name": "newOwner",
         "type": "tuple"
       }
+=======
+      { "internalType": "address", "name": "newOwner", "type": "address" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
     ],
     "name": "setOwnerCross",
     "outputs": [],
@@ -687,8 +758,13 @@
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
       {
         "components": [
+<<<<<<< HEAD
           { "internalType": "string", "name": "field_0", "type": "string" },
           { "internalType": "bytes", "name": "field_1", "type": "bytes" }
+=======
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
         ],
         "internalType": "struct Tuple19[]",
         "name": "properties",
@@ -799,8 +875,13 @@
     "inputs": [
       {
         "components": [
+<<<<<<< HEAD
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+=======
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
         ],
 <<<<<<< HEAD
         "internalType": "struct Tuple6",
@@ -812,8 +893,13 @@
       },
       {
         "components": [
+<<<<<<< HEAD
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+=======
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+>>>>>>> feat: Add custum signature with unlimited nesting.
         ],
 <<<<<<< HEAD
         "internalType": "struct Tuple6",
modifiedtests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -14,10 +14,8 @@
   args: { [key: string]: string }
 };
 export interface TEthCrossAccount {
-  readonly 0: string,
-  readonly 1: string | Uint8Array,
-  readonly field_0: string,
-  readonly field_1: string | Uint8Array,
+  readonly eth: string,
+  readonly sub: string | Uint8Array,
 }
 
 export type EthProperty = string[];
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -364,19 +364,15 @@
 export class EthCrossAccountGroup extends EthGroupBase {
   fromAddress(address: TEthereumAccount): TEthCrossAccount {
     return {
-      0: address,
-      1: '0',
-      field_0: address,
-      field_1: '0',
+      eth: address,
+      sub: '0',
     };
   }
 
   fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
     return {
-      0: '0x0000000000000000000000000000000000000000',
-      1: keyring.addressRaw,
-      field_0: '0x0000000000000000000000000000000000000000',
-      field_1: keyring.addressRaw,
+      eth: '0x0000000000000000000000000000000000000000',
+      sub: keyring.addressRaw,
     };
   }
 }
@@ -429,7 +425,6 @@
   ethAddress: EthAddressGroup;
   ethNativeContract: NativeContractGroup;
   ethContract: ContractGroup;
-  ethCrossAccount: EthCrossAccountGroup;
   ethProperty: EthPropertyGroup;
 
   constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {