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
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -20,7 +20,13 @@
 use alloc::{format, string::ToString};
 use core::marker::PhantomData;
 use evm_coder::{
-	abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*, ToLog,
+	abi::AbiWriter,
+	execution::Result,
+	generate_stubgen, solidity_interface,
+	types::*,
+	ToLog,
+	custom_signature::{FunctionName, FunctionSignature},
+	make_signature,
 };
 use pallet_evm::{
 	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
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
before · pallets/unique/src/eth/mod.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 CollectionHelpers contract.1819use core::marker::PhantomData;20use ethereum as _;21use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};22use frame_support::{traits::Get, storage::StorageNMap};23use crate::sp_api_hidden_includes_decl_storage::hidden_include::StorageDoubleMap;24use crate::Pallet;2526use pallet_common::{27	CollectionById,28	dispatch::CollectionDispatch,29	erc::{static_property::key, CollectionHelpersEvents},30	Pallet as PalletCommon,31};32use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};33use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};34use sp_std::vec;35use up_data_structs::{36	CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,37	CreateCollectionData,38};3940use crate::{41	weights::WeightInfo, Config, SelfWeightOf, NftTransferBasket, FungibleTransferBasket,42	ReFungibleTransferBasket, NftApproveBasket, FungibleApproveBasket, RefungibleApproveBasket,43};4445use alloc::format;46use sp_std::vec::Vec;4748/// See [`CollectionHelpersCall`]49pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);50impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {51	fn recorder(&self) -> &SubstrateRecorder<T> {52		&self.053	}5455	fn into_recorder(self) -> SubstrateRecorder<T> {56		self.057	}58}5960fn convert_data<T: Config>(61	caller: caller,62	name: string,63	description: string,64	token_prefix: string,65) -> Result<(66	T::CrossAccountId,67	CollectionName,68	CollectionDescription,69	CollectionTokenPrefix,70)> {71	let caller = T::CrossAccountId::from_eth(caller);72	let name = name73		.encode_utf16()74		.collect::<Vec<u16>>()75		.try_into()76		.map_err(|_| error_field_too_long(stringify!(name), CollectionName::bound()))?;77	let description = description78		.encode_utf16()79		.collect::<Vec<u16>>()80		.try_into()81		.map_err(|_| {82			error_field_too_long(stringify!(description), CollectionDescription::bound())83		})?;84	let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {85		error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())86	})?;87	Ok((caller, name, description, token_prefix))88}8990#[inline(always)]91fn create_collection_internal<T: Config>(92	caller: caller,93	value: value,94	name: string,95	collection_mode: CollectionMode,96	description: string,97	token_prefix: string,98) -> Result<address> {99	let (caller, name, description, token_prefix) =100		convert_data::<T>(caller, name, description, token_prefix)?;101	let data = CreateCollectionData {102		name,103		mode: collection_mode,104		description,105		token_prefix,106		..Default::default()107	};108	check_sent_amount_equals_collection_creation_price::<T>(value)?;109	let collection_helpers_address =110		T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());111112	let collection_id = T::CollectionDispatch::create(113		caller.clone(),114		collection_helpers_address,115		data,116		Default::default(),117	)118	.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;119	let address = pallet_common::eth::collection_id_to_address(collection_id);120	Ok(address)121}122123fn check_sent_amount_equals_collection_creation_price<T: Config>(value: value) -> Result<()> {124	let value = value.as_u128();125	let creation_price: u128 = T::CollectionCreationPrice::get()126		.try_into()127		.map_err(|_| ()) // workaround for `expect` requiring `Debug` trait128		.expect("Collection creation price should be convertible to u128");129	if value != creation_price {130		return Err(format!(131			"Sent amount not equals to collection creation price ({0})",132			creation_price133		)134		.into());135	}136	Ok(())137}138139/// @title Contract, which allows users to operate with collections140#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]141impl<T> EvmCollectionHelpers<T>142where143	T: Config + pallet_common::Config + pallet_nonfungible::Config + pallet_refungible::Config,144{145	/// Create an NFT collection146	/// @param name Name of the collection147	/// @param description Informative description of the collection148	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications149	/// @return address Address of the newly created collection150	#[weight(<SelfWeightOf<T>>::create_collection())]151	#[solidity(rename_selector = "createNFTCollection")]152	fn create_nft_collection(153		&mut self,154		caller: caller,155		value: value,156		name: string,157		description: string,158		token_prefix: string,159	) -> Result<address> {160		let (caller, name, description, token_prefix) =161			convert_data::<T>(caller, name, description, token_prefix)?;162		let data = CreateCollectionData {163			name,164			mode: CollectionMode::NFT,165			description,166			token_prefix,167			..Default::default()168		};169		check_sent_amount_equals_collection_creation_price::<T>(value)?;170		let collection_helpers_address =171			T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());172		let collection_id = T::CollectionDispatch::create(173			caller,174			collection_helpers_address,175			data,176			Default::default(),177		)178		.map_err(dispatch_to_evm::<T>)?;179180		let address = pallet_common::eth::collection_id_to_address(collection_id);181		Ok(address)182	}183	/// Create an NFT collection184	/// @param name Name of the collection185	/// @param description Informative description of the collection186	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications187	/// @return address Address of the newly created collection188	#[weight(<SelfWeightOf<T>>::create_collection())]189	#[deprecated(note = "mathod was renamed to `create_nft_collection`, prefer it instead")]190	#[solidity(hide)]191	fn create_nonfungible_collection(192		&mut self,193		caller: caller,194		value: value,195		name: string,196		description: string,197		token_prefix: string,198	) -> Result<address> {199		create_collection_internal::<T>(200			caller,201			value,202			name,203			CollectionMode::NFT,204			description,205			token_prefix,206		)207	}208209	#[weight(<SelfWeightOf<T>>::create_collection())]210	#[solidity(rename_selector = "createRFTCollection")]211	fn create_rft_collection(212		&mut self,213		caller: caller,214		value: value,215		name: string,216		description: string,217		token_prefix: string,218	) -> Result<address> {219		create_collection_internal::<T>(220			caller,221			value,222			name,223			CollectionMode::ReFungible,224			description,225			token_prefix,226		)227	}228229	#[weight(<SelfWeightOf<T>>::create_collection())]230	#[solidity(rename_selector = "createFTCollection")]231	fn create_fungible_collection(232		&mut self,233		caller: caller,234		value: value,235		name: string,236		decimals: uint8,237		description: string,238		token_prefix: string,239	) -> Result<address> {240		create_collection_internal::<T>(241			caller,242			value,243			name,244			CollectionMode::Fungible(decimals),245			description,246			token_prefix,247		)248	}249250	#[solidity(rename_selector = "makeCollectionERC721MetadataCompatible")]251	fn make_collection_metadata_compatible(252		&mut self,253		caller: caller,254		collection: address,255		base_uri: string,256	) -> Result<()> {257		let caller = T::CrossAccountId::from_eth(caller);258		let collection =259			pallet_common::eth::map_eth_to_id(&collection).ok_or("not a collection address")?;260		let mut collection =261			<crate::CollectionHandle<T>>::new(collection).ok_or("collection not found")?;262263		if !matches!(264			collection.mode,265			CollectionMode::NFT | CollectionMode::ReFungible266		) {267			return Err("target collection should be either NFT or Refungible".into());268		}269270		self.recorder().consume_sstore()?;271		collection272			.check_is_owner_or_admin(&caller)273			.map_err(dispatch_to_evm::<T>)?;274275		if collection.flags.erc721metadata {276			return Err("target collection is already Erc721Metadata compatible".into());277		}278		collection.flags.erc721metadata = true;279280		let all_permissions = <pallet_common::CollectionPropertyPermissions<T>>::get(collection.id);281		if all_permissions.get(&key::url()).is_none() {282			self.recorder().consume_sstore()?;283			<PalletCommon<T>>::set_property_permission(284				&collection,285				&caller,286				up_data_structs::PropertyKeyPermission {287					key: key::url(),288					permission: up_data_structs::PropertyPermission {289						mutable: true,290						collection_admin: true,291						token_owner: false,292					},293				},294			)295			.map_err(dispatch_to_evm::<T>)?;296		}297		if all_permissions.get(&key::suffix()).is_none() {298			self.recorder().consume_sstore()?;299			<PalletCommon<T>>::set_property_permission(300				&collection,301				&caller,302				up_data_structs::PropertyKeyPermission {303					key: key::suffix(),304					permission: up_data_structs::PropertyPermission {305						mutable: true,306						collection_admin: true,307						token_owner: false,308					},309				},310			)311			.map_err(dispatch_to_evm::<T>)?;312		}313314		let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);315		if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {316			self.recorder().consume_sstore()?;317			<PalletCommon<T>>::set_collection_properties(318				&collection,319				&caller,320				vec![up_data_structs::Property {321					key: key::base_uri(),322					value: base_uri323						.into_bytes()324						.try_into()325						.map_err(|_| "base uri is too large")?,326				}],327			)328			.map_err(dispatch_to_evm::<T>)?;329		}330331		self.recorder().consume_sstore()?;332		collection.save().map_err(dispatch_to_evm::<T>)?;333334		Ok(())335	}336337	#[weight(<SelfWeightOf<T>>::destroy_collection())]338	fn destroy_collection(&mut self, caller: caller, collection_address: address) -> Result<void> {339		let caller = T::CrossAccountId::from_eth(caller);340341		let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)342			.ok_or("Invalid collection address format")?;343		<Pallet<T>>::destroy_collection_internal(caller, collection_id)344			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)345	}346347	/// Check if a collection exists348	/// @param collectionAddress Address of the collection in question349	/// @return bool Does the collection exist?350	fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {351		if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {352			let collection_id = id;353			return Ok(<CollectionById<T>>::contains_key(collection_id));354		}355356		Ok(false)357	}358359	fn collection_creation_fee(&self) -> Result<value> {360		let price: u128 = T::CollectionCreationPrice::get()361			.try_into()362			.map_err(|_| ()) // workaround for `expect` requiring `Debug` trait363			.expect("Collection creation price should be convertible to u128");364		Ok(price.into())365	}366}367368/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]369pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);370impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>371	for CollectionHelpersOnMethodCall<T>372{373	fn is_reserved(contract: &sp_core::H160) -> bool {374		contract == &T::ContractAddress::get()375	}376377	fn is_used(contract: &sp_core::H160) -> bool {378		contract == &T::ContractAddress::get()379	}380381	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {382		if handle.code_address() != T::ContractAddress::get() {383			return None;384		}385386		let helpers =387			EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));388		pallet_evm_coder_substrate::call(handle, helpers)389	}390391	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {392		(contract == &T::ContractAddress::get())393			.then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())394	}395}396397generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);398generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);399400fn error_field_too_long(feild: &str, bound: usize) -> Error {401	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))402}
after · pallets/unique/src/eth/mod.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 CollectionHelpers contract.1819use core::marker::PhantomData;20use ethereum as _;21use evm_coder::{22	execution::*,23	generate_stubgen, solidity, solidity_interface,24	types::*,25	custom_signature::{FunctionName, FunctionSignature},26	make_signature,27, weight};28use frame_support::{traits::Get, storage::StorageNMap};29use crate::sp_api_hidden_includes_decl_storage::hidden_include::StorageDoubleMap;30use crate::Pallet;3132use pallet_common::{33	CollectionById,34	dispatch::CollectionDispatch,35	erc::{static_property::key, CollectionHelpersEvents},36	Pallet as PalletCommon,37};38use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};39use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};40use sp_std::vec;41use up_data_structs::{42	CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,43	CreateCollectionData,44};4546use crate::{47	weights::WeightInfo, Config, SelfWeightOf, NftTransferBasket, FungibleTransferBasket,48	ReFungibleTransferBasket, NftApproveBasket, FungibleApproveBasket, RefungibleApproveBasket,49};5051use alloc::format;52use sp_std::vec::Vec;5354/// See [`CollectionHelpersCall`]55pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);56impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {57	fn recorder(&self) -> &SubstrateRecorder<T> {58		&self.059	}6061	fn into_recorder(self) -> SubstrateRecorder<T> {62		self.063	}64}6566fn convert_data<T: Config>(67	caller: caller,68	name: string,69	description: string,70	token_prefix: string,71) -> Result<(72	T::CrossAccountId,73	CollectionName,74	CollectionDescription,75	CollectionTokenPrefix,76)> {77	let caller = T::CrossAccountId::from_eth(caller);78	let name = name79		.encode_utf16()80		.collect::<Vec<u16>>()81		.try_into()82		.map_err(|_| error_field_too_long(stringify!(name), CollectionName::bound()))?;83	let description = description84		.encode_utf16()85		.collect::<Vec<u16>>()86		.try_into()87		.map_err(|_| {88			error_field_too_long(stringify!(description), CollectionDescription::bound())89		})?;90	let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {91		error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())92	})?;93	Ok((caller, name, description, token_prefix))94}9596#[inline(always)]97fn create_collection_internal<T: Config>(98	caller: caller,99	value: value,100	name: string,101	collection_mode: CollectionMode,102	description: string,103	token_prefix: string,104) -> Result<address> {105	let (caller, name, description, token_prefix) =106		convert_data::<T>(caller, name, description, token_prefix)?;107	let data = CreateCollectionData {108		name,109		mode: collection_mode,110		description,111		token_prefix,112		..Default::default()113	};114	check_sent_amount_equals_collection_creation_price::<T>(value)?;115	let collection_helpers_address =116		T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());117118	let collection_id = T::CollectionDispatch::create(119		caller.clone(),120		collection_helpers_address,121		data,122		Default::default(),123	)124	.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;125	let address = pallet_common::eth::collection_id_to_address(collection_id);126	Ok(address)127}128129fn check_sent_amount_equals_collection_creation_price<T: Config>(value: value) -> Result<()> {130	let value = value.as_u128();131	let creation_price: u128 = T::CollectionCreationPrice::get()132		.try_into()133		.map_err(|_| ()) // workaround for `expect` requiring `Debug` trait134		.expect("Collection creation price should be convertible to u128");135	if value != creation_price {136		return Err(format!(137			"Sent amount not equals to collection creation price ({0})",138			creation_price139		)140		.into());141	}142	Ok(())143}144145/// @title Contract, which allows users to operate with collections146#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]147impl<T> EvmCollectionHelpers<T>148where149	T: Config + pallet_common::Config + pallet_nonfungible::Config + pallet_refungible::Config,150{151	/// Create an NFT collection152	/// @param name Name of the collection153	/// @param description Informative description of the collection154	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications155	/// @return address Address of the newly created collection156	#[weight(<SelfWeightOf<T>>::create_collection())]157	#[solidity(rename_selector = "createNFTCollection")]158	fn create_nft_collection(159		&mut self,160		caller: caller,161		value: value,162		name: string,163		description: string,164		token_prefix: string,165	) -> Result<address> {166		let (caller, name, description, token_prefix) =167			convert_data::<T>(caller, name, description, token_prefix)?;168		let data = CreateCollectionData {169			name,170			mode: CollectionMode::NFT,171			description,172			token_prefix,173			..Default::default()174		};175		check_sent_amount_equals_collection_creation_price::<T>(value)?;176		let collection_helpers_address =177			T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());178		let collection_id = T::CollectionDispatch::create(179			caller,180			collection_helpers_address,181			data,182			Default::default(),183		)184		.map_err(dispatch_to_evm::<T>)?;185186		let address = pallet_common::eth::collection_id_to_address(collection_id);187		Ok(address)188	}189	/// Create an NFT collection190	/// @param name Name of the collection191	/// @param description Informative description of the collection192	/// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications193	/// @return address Address of the newly created collection194	#[weight(<SelfWeightOf<T>>::create_collection())]195	#[deprecated(note = "mathod was renamed to `create_nft_collection`, prefer it instead")]196	#[solidity(hide)]197	fn create_nonfungible_collection(198		&mut self,199		caller: caller,200		value: value,201		name: string,202		description: string,203		token_prefix: string,204	) -> Result<address> {205		create_collection_internal::<T>(206			caller,207			value,208			name,209			CollectionMode::NFT,210			description,211			token_prefix,212		)213	}214215	#[weight(<SelfWeightOf<T>>::create_collection())]216	#[solidity(rename_selector = "createRFTCollection")]217	fn create_rft_collection(218		&mut self,219		caller: caller,220		value: value,221		name: string,222		description: string,223		token_prefix: string,224	) -> Result<address> {225		create_collection_internal::<T>(226			caller,227			value,228			name,229			CollectionMode::ReFungible,230			description,231			token_prefix,232		)233	}234235	#[weight(<SelfWeightOf<T>>::create_collection())]236	#[solidity(rename_selector = "createFTCollection")]237	fn create_fungible_collection(238		&mut self,239		caller: caller,240		value: value,241		name: string,242		decimals: uint8,243		description: string,244		token_prefix: string,245	) -> Result<address> {246		create_collection_internal::<T>(247			caller,248			value,249			name,250			CollectionMode::Fungible(decimals),251			description,252			token_prefix,253		)254	}255256	#[solidity(rename_selector = "makeCollectionERC721MetadataCompatible")]257	fn make_collection_metadata_compatible(258		&mut self,259		caller: caller,260		collection: address,261		base_uri: string,262	) -> Result<()> {263		let caller = T::CrossAccountId::from_eth(caller);264		let collection =265			pallet_common::eth::map_eth_to_id(&collection).ok_or("not a collection address")?;266		let mut collection =267			<crate::CollectionHandle<T>>::new(collection).ok_or("collection not found")?;268269		if !matches!(270			collection.mode,271			CollectionMode::NFT | CollectionMode::ReFungible272		) {273			return Err("target collection should be either NFT or Refungible".into());274		}275276		self.recorder().consume_sstore()?;277		collection278			.check_is_owner_or_admin(&caller)279			.map_err(dispatch_to_evm::<T>)?;280281		if collection.flags.erc721metadata {282			return Err("target collection is already Erc721Metadata compatible".into());283		}284		collection.flags.erc721metadata = true;285286		let all_permissions = <pallet_common::CollectionPropertyPermissions<T>>::get(collection.id);287		if all_permissions.get(&key::url()).is_none() {288			self.recorder().consume_sstore()?;289			<PalletCommon<T>>::set_property_permission(290				&collection,291				&caller,292				up_data_structs::PropertyKeyPermission {293					key: key::url(),294					permission: up_data_structs::PropertyPermission {295						mutable: true,296						collection_admin: true,297						token_owner: false,298					},299				},300			)301			.map_err(dispatch_to_evm::<T>)?;302		}303		if all_permissions.get(&key::suffix()).is_none() {304			self.recorder().consume_sstore()?;305			<PalletCommon<T>>::set_property_permission(306				&collection,307				&caller,308				up_data_structs::PropertyKeyPermission {309					key: key::suffix(),310					permission: up_data_structs::PropertyPermission {311						mutable: true,312						collection_admin: true,313						token_owner: false,314					},315				},316			)317			.map_err(dispatch_to_evm::<T>)?;318		}319320		let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);321		if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {322			self.recorder().consume_sstore()?;323			<PalletCommon<T>>::set_collection_properties(324				&collection,325				&caller,326				vec![up_data_structs::Property {327					key: key::base_uri(),328					value: base_uri329						.into_bytes()330						.try_into()331						.map_err(|_| "base uri is too large")?,332				}],333			)334			.map_err(dispatch_to_evm::<T>)?;335		}336337		self.recorder().consume_sstore()?;338		collection.save().map_err(dispatch_to_evm::<T>)?;339340		Ok(())341	}342343	#[weight(<SelfWeightOf<T>>::destroy_collection())]344	fn destroy_collection(&mut self, caller: caller, collection_address: address) -> Result<void> {345		let caller = T::CrossAccountId::from_eth(caller);346347		let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)348			.ok_or("Invalid collection address format")?;349		<Pallet<T>>::destroy_collection_internal(caller, collection_id)350			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)351	}352353	/// Check if a collection exists354	/// @param collectionAddress Address of the collection in question355	/// @return bool Does the collection exist?356	fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {357		if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {358			let collection_id = id;359			return Ok(<CollectionById<T>>::contains_key(collection_id));360		}361362		Ok(false)363	}364365	fn collection_creation_fee(&self) -> Result<value> {366		let price: u128 = T::CollectionCreationPrice::get()367			.try_into()368			.map_err(|_| ()) // workaround for `expect` requiring `Debug` trait369			.expect("Collection creation price should be convertible to u128");370		Ok(price.into())371	}372}373374/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]375pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);376impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>377	for CollectionHelpersOnMethodCall<T>378{379	fn is_reserved(contract: &sp_core::H160) -> bool {380		contract == &T::ContractAddress::get()381	}382383	fn is_used(contract: &sp_core::H160) -> bool {384		contract == &T::ContractAddress::get()385	}386387	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {388		if handle.code_address() != T::ContractAddress::get() {389			return None;390		}391392		let helpers =393			EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));394		pallet_evm_coder_substrate::call(handle, helpers)395	}396397	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {398		(contract == &T::ContractAddress::get())399			.then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())400	}401}402403generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);404generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);405406fn error_field_too_long(feild: &str, bound: usize) -> Error {407	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))408}
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} = {}) {