git.delta.rocks / unique-network / refs/commits / 905f9b3923e7

difftreelog

refactor fix complex value type support in evm-coder

Yaroslav Bolyukin2023-08-29parent: #1a4aa2d.patch.diff
in: master

14 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2653,8 +2653,9 @@
 
 [[package]]
 name = "evm-coder"
-version = "0.3.6"
-source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.6#be59ae41a5d2ec9389bae22d54f81122b6ba55a4"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b88ae5a449e7e9dfef59c0dd2df396bc56d81a6f4e297490c0c64aa73f7f7ad4"
 dependencies = [
  "ethereum",
  "evm-coder-procedural",
@@ -2665,8 +2666,9 @@
 
 [[package]]
 name = "evm-coder-procedural"
-version = "0.3.6"
-source = "git+https://github.com/uniquenetwork/evm-coder?tag=v0.3.6#be59ae41a5d2ec9389bae22d54f81122b6ba55a4"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6223c1063c1f53380b4b9aaf2e4d82eba4808c661c61265619b804b09b7a6b1a"
 dependencies = [
  "Inflector",
  "hex",
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@
 [workspace.dependencies]
 # Unique
 app-promotion-rpc = { path = "primitives/app_promotion_rpc", default-features = false }
-evm-coder = { git = "https://github.com/uniquenetwork/evm-coder", tag = "v0.3.6", default-features = false, features = [
+evm-coder = { version = "0.4.2", default-features = false, features = [
 	'bondrewd',
 ] }
 pallet-app-promotion = { path = "pallets/app-promotion", default-features = false }
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -35,7 +35,8 @@
 	"sp-std/std",
 	"up-data-structs/std",
 	"up-pov-estimate-rpc/std",
+	"evm-coder/std",
 ]
-stubgen = ["evm-coder/stubgen"]
+stubgen = ["evm-coder/stubgen", "up-data-structs/stubgen"]
 tests = []
 try-runtime = ["frame-support/try-runtime"]
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -549,8 +549,6 @@
 /// Collection properties
 #[derive(Debug, Default, AbiCoder)]
 pub struct CreateCollectionData {
-	/// Collection sponsor
-	pub pending_sponsor: CrossAddress,
 	/// Collection name
 	pub name: String,
 	/// Collection description
@@ -571,6 +569,8 @@
 	pub nesting_settings: CollectionNestingAndPermission,
 	/// Collection limits
 	pub limits: Vec<CollectionLimitValue>,
+	/// Collection sponsor
+	pub pending_sponsor: CrossAddress,
 	/// Extra collection flags
 	pub flags: CollectionFlags,
 }
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -26,7 +26,7 @@
 use frame_support::dispatch::Weight;
 
 use core::marker::PhantomData;
-use sp_std::cell::RefCell;
+use sp_std::{cell::RefCell, vec::Vec};
 
 use codec::Decode;
 use frame_support::pallet_prelude::DispatchError;
@@ -46,8 +46,8 @@
 pub use spez::spez;
 
 use evm_coder::{
-	abi::{AbiReader, AbiWrite, AbiWriter},
 	types::{Msg, Value},
+	AbiEncode,
 };
 
 pub use pallet::*;
@@ -168,7 +168,7 @@
 	pub fn evm_to_precompile_output(
 		self,
 		handle: &mut impl PrecompileHandle,
-		result: execution::Result<Option<AbiWriter>>,
+		result: execution::Result<Option<Vec<u8>>>,
 	) -> Option<PrecompileResult> {
 		use execution::Error;
 		// We ignore error here, as it should not occur, as we have our own bookkeeping of gas
@@ -176,18 +176,13 @@
 		Some(match result {
 			Ok(Some(v)) => Ok(PrecompileOutput {
 				exit_status: ExitSucceed::Returned,
-				output: v.finish(),
+				output: v,
 			}),
 			Ok(None) => return None,
-			Err(Error::Revert(e)) => {
-				let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));
-				(&e as &str).abi_write(&mut writer);
-
-				Err(PrecompileFailure::Revert {
-					exit_status: ExitRevert::Reverted,
-					output: writer.finish(),
-				})
-			}
+			Err(Error::Revert(e)) => Err(PrecompileFailure::Revert {
+				exit_status: ExitRevert::Reverted,
+				output: (&e as &str,).abi_encode_call(evm_coder::fn_selector!(Error(string))),
+			}),
 			Err(Error::Fatal(f)) => Err(PrecompileFailure::Fatal { exit_status: f }),
 			Err(Error::Error(e)) => Err(e.into()),
 		})
@@ -266,7 +261,7 @@
 	C: evm_coder::Call + PreDispatch,
 	E: evm_coder::Callable<C> + WithRecorder<T>,
 	H: PrecompileHandle,
-	execution::ResultWithPostInfo<AbiWriter>: From<ResultWithPostInfoOf<E, AbiWriter>>,
+	execution::ResultWithPostInfo<Vec<u8>>: From<ResultWithPostInfoOf<E, Vec<u8>>>,
 {
 	let result = call_internal(
 		handle.context().caller,
@@ -282,18 +277,16 @@
 	e: &mut E,
 	value: Value,
 	input: &[u8],
-) -> execution::Result<Option<AbiWriter>>
+) -> execution::Result<Option<Vec<u8>>>
 where
 	T: Config,
 	C: evm_coder::Call + PreDispatch,
 	E: Contract + evm_coder::Callable<C> + WithRecorder<T>,
-	execution::ResultWithPostInfo<AbiWriter>: From<ResultWithPostInfoOf<E, AbiWriter>>,
+	execution::ResultWithPostInfo<Vec<u8>>: From<ResultWithPostInfoOf<E, Vec<u8>>>,
 {
-	let (selector, mut reader) = AbiReader::new_call(input)?;
-	let call = C::parse(selector, &mut reader)?;
+	let call = C::parse_full(input)?;
 	if call.is_none() {
-		let selector = u32::from_be_bytes(selector);
-		return Err(format!("unrecognized selector: 0x{selector:0<8x}").into());
+		return Err("unrecognized selector".into());
 	}
 	let call = call.unwrap();
 
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 core::marker::PhantomData;21use evm_coder::{22	abi::{AbiWriter, AbiType},23	generate_stubgen, solidity_interface,24	types::*,25	ToLog,26};27use pallet_common::eth;28use pallet_evm::{29	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,30	account::CrossAccountId,31};32use pallet_evm_coder_substrate::{33	SubstrateRecorder, WithRecorder, dispatch_to_evm,34	execution::{Result, PreDispatch},35	frontier_contract,36};37use pallet_evm_transaction_payment::CallContext;38use sp_core::{H160, U256};39use up_data_structs::SponsorshipState;40use crate::{41	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,42	SponsoringRateLimit, SponsoringModeT, Sponsoring,43};44use frame_support::traits::Get;45use up_sponsorship::SponsorshipHandler;46use sp_std::vec::Vec;4748frontier_contract! {49	macro_rules! ContractHelpers_result {...}50	impl<T: Config> Contract for ContractHelpers<T> {...}51}5253/// Pallet events.54#[derive(ToLog)]55pub enum ContractHelpersEvents {56	/// Contract sponsor was set.57	ContractSponsorSet {58		/// Contract address of the affected collection.59		#[indexed]60		contract_address: Address,61		/// New sponsor address.62		sponsor: Address,63	},6465	/// New sponsor was confirm.66	ContractSponsorshipConfirmed {67		/// Contract address of the affected collection.68		#[indexed]69		contract_address: Address,70		/// New sponsor address.71		sponsor: Address,72	},7374	/// Collection sponsor was removed.75	ContractSponsorRemoved {76		/// Contract address of the affected collection.77		#[indexed]78		contract_address: Address,79	},80}8182/// See [`ContractHelpersCall`]83pub struct ContractHelpers<T: Config>(SubstrateRecorder<T>);84impl<T: Config> WithRecorder<T> for ContractHelpers<T> {85	fn recorder(&self) -> &SubstrateRecorder<T> {86		&self.087	}8889	fn into_recorder(self) -> SubstrateRecorder<T> {90		self.091	}92}9394/// @title Magic contract, which allows users to reconfigure other contracts95#[solidity_interface(name = ContractHelpers, events(ContractHelpersEvents), enum(derive(PreDispatch)))]96impl<T: Config> ContractHelpers<T>97where98	T::AccountId: AsRef<[u8; 32]>,99{100	/// Get user, which deployed specified contract101	/// @dev May return zero address in case if contract is deployed102	///  using uniquenetwork evm-migration pallet, or using other terms not103	///  intended by pallet-evm104	/// @dev Returns zero address if contract does not exists105	/// @param contractAddress Contract to get owner of106	/// @return address Owner of contract107	fn contract_owner(&self, contract_address: Address) -> Result<Address> {108		Ok(<Owner<T>>::get(contract_address))109	}110111	/// Set sponsor.112	/// @param contractAddress Contract for which a sponsor is being established.113	/// @param sponsor User address who set as pending sponsor.114	fn set_sponsor(115		&mut self,116		caller: Caller,117		contract_address: Address,118		sponsor: Address,119	) -> Result<()> {120		self.recorder().consume_sload()?;121		self.recorder().consume_sstore()?;122123		Pallet::<T>::set_sponsor(124			&T::CrossAccountId::from_eth(caller),125			contract_address,126			&T::CrossAccountId::from_eth(sponsor),127		)128		.map_err(dispatch_to_evm::<T>)?;129130		Ok(())131	}132133	/// Set contract as self sponsored.134	///135	/// @param contractAddress Contract for which a self sponsoring is being enabled.136	fn self_sponsored_enable(&mut self, caller: Caller, contract_address: Address) -> Result<()> {137		self.recorder().consume_sload()?;138		self.recorder().consume_sstore()?;139140		let caller = T::CrossAccountId::from_eth(caller);141142		Pallet::<T>::ensure_owner(contract_address, *caller.as_eth())143			.map_err(dispatch_to_evm::<T>)?;144145		Pallet::<T>::force_set_sponsor(146			contract_address,147			&T::CrossAccountId::from_eth(contract_address),148		)149		.map_err(dispatch_to_evm::<T>)?;150151		Ok(())152	}153154	/// Remove sponsor.155	///156	/// @param contractAddress Contract for which a sponsorship is being removed.157	fn remove_sponsor(&mut self, caller: Caller, contract_address: Address) -> Result<()> {158		self.recorder().consume_sload()?;159		self.recorder().consume_sstore()?;160161		Pallet::<T>::remove_sponsor(&T::CrossAccountId::from_eth(caller), contract_address)162			.map_err(dispatch_to_evm::<T>)?;163164		Ok(())165	}166167	/// Confirm sponsorship.168	///169	/// @dev Caller must be same that set via [`setSponsor`].170	///171	/// @param contractAddress Сontract for which need to confirm sponsorship.172	fn confirm_sponsorship(&mut self, caller: Caller, contract_address: Address) -> Result<()> {173		self.recorder().consume_sload()?;174		self.recorder().consume_sstore()?;175176		Pallet::<T>::confirm_sponsorship(&T::CrossAccountId::from_eth(caller), contract_address)177			.map_err(dispatch_to_evm::<T>)?;178179		Ok(())180	}181182	/// Get current sponsor.183	///184	/// @param contractAddress The contract for which a sponsor is requested.185	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.186	fn sponsor(&self, contract_address: Address) -> Result<Option<eth::CrossAddress>> {187		Ok(Pallet::<T>::get_sponsor(contract_address)188			.as_ref()189			.map(eth::CrossAddress::from_sub_cross_account::<T>))190	}191192	/// Check tat contract has confirmed sponsor.193	///194	/// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.195	/// @return **true** if contract has confirmed sponsor.196	fn has_sponsor(&self, contract_address: Address) -> Result<bool> {197		Ok(Pallet::<T>::get_sponsor(contract_address).is_some())198	}199200	/// Check tat contract has pending sponsor.201	///202	/// @param contractAddress The contract for which the presence of a pending sponsor is checked.203	/// @return **true** if contract has pending sponsor.204	fn has_pending_sponsor(&self, contract_address: Address) -> Result<bool> {205		Ok(match Sponsoring::<T>::get(contract_address) {206			SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,207			SponsorshipState::Unconfirmed(_) => true,208		})209	}210211	fn sponsoring_enabled(&self, contract_address: Address) -> Result<bool> {212		Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)213	}214215	fn set_sponsoring_mode(216		&mut self,217		caller: Caller,218		contract_address: Address,219		mode: SponsoringModeT,220	) -> Result<()> {221		self.recorder().consume_sload()?;222		self.recorder().consume_sstore()?;223224		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;225		<Pallet<T>>::set_sponsoring_mode(contract_address, mode);226227		Ok(())228	}229230	/// Get current contract sponsoring rate limit231	/// @param contractAddress Contract to get sponsoring rate limit of232	/// @return uint32 Amount of blocks between two sponsored transactions233	fn sponsoring_rate_limit(&self, contract_address: Address) -> Result<u32> {234		self.recorder().consume_sload()?;235236		Ok(<SponsoringRateLimit<T>>::get(contract_address)237			.try_into()238			.map_err(|_| "rate limit > u32::MAX")?)239	}240241	/// Set contract sponsoring rate limit242	/// @dev Sponsoring rate limit - is a minimum amount of blocks that should243	///  pass between two sponsored transactions244	/// @param contractAddress Contract to change sponsoring rate limit of245	/// @param rateLimit Target rate limit246	/// @dev Only contract owner can change this setting247	fn set_sponsoring_rate_limit(248		&mut self,249		caller: Caller,250		contract_address: Address,251		rate_limit: u32,252	) -> Result<()> {253		self.recorder().consume_sload()?;254		self.recorder().consume_sstore()?;255256		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;257		<Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());258		Ok(())259	}260261	/// Set contract sponsoring fee limit262	/// @dev Sponsoring fee limit - is maximum fee that could be spent by263	///  single transaction264	/// @param contractAddress Contract to change sponsoring fee limit of265	/// @param feeLimit Fee limit266	/// @dev Only contract owner can change this setting267	fn set_sponsoring_fee_limit(268		&mut self,269		caller: Caller,270		contract_address: Address,271		fee_limit: U256,272	) -> Result<()> {273		self.recorder().consume_sload()?;274		self.recorder().consume_sstore()?;275276		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;277		<Pallet<T>>::set_sponsoring_fee_limit(contract_address, fee_limit)278			.map_err(dispatch_to_evm::<T>)?;279		Ok(())280	}281282	/// Get current contract sponsoring fee limit283	/// @param contractAddress Contract to get sponsoring fee limit of284	/// @return uint256 Maximum amount of fee that could be spent by single285	///  transaction286	fn sponsoring_fee_limit(&self, contract_address: Address) -> Result<U256> {287		self.recorder().consume_sload()?;288289		Ok(get_sponsoring_fee_limit::<T>(contract_address))290	}291292	/// Is specified user present in contract allow list293	/// @dev Contract owner always implicitly included294	/// @param contractAddress Contract to check allowlist of295	/// @param user User to check296	/// @return bool Is specified users exists in contract allowlist297	fn allowed(&self, contract_address: Address, user: Address) -> Result<bool> {298		self.0.consume_sload()?;299		Ok(<Pallet<T>>::allowed(contract_address, user))300	}301302	/// Toggle user presence in contract allowlist303	/// @param contractAddress Contract to change allowlist of304	/// @param user Which user presence should be toggled305	/// @param isAllowed `true` if user should be allowed to be sponsored306	///  or call this contract, `false` otherwise307	/// @dev Only contract owner can change this setting308	fn toggle_allowed(309		&mut self,310		caller: Caller,311		contract_address: Address,312		user: Address,313		is_allowed: bool,314	) -> Result<()> {315		self.recorder().consume_sload()?;316		self.recorder().consume_sstore()?;317318		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;319		<Pallet<T>>::toggle_allowed(contract_address, user, is_allowed);320321		Ok(())322	}323324	/// Is this contract has allowlist access enabled325	/// @dev Allowlist always can have users, and it is used for two purposes:326	///  in case of allowlist sponsoring mode, users will be sponsored if they exist in allowlist327	///  in case of allowlist access enabled, only users from allowlist may call this contract328	/// @param contractAddress Contract to get allowlist access of329	/// @return bool Is specified contract has allowlist access enabled330	fn allowlist_enabled(&self, contract_address: Address) -> Result<bool> {331		Ok(<AllowlistEnabled<T>>::get(contract_address))332	}333334	/// Toggle contract allowlist access335	/// @param contractAddress Contract to change allowlist access of336	/// @param enabled Should allowlist access to be enabled?337	fn toggle_allowlist(338		&mut self,339		caller: Caller,340		contract_address: Address,341		enabled: bool,342	) -> Result<()> {343		self.recorder().consume_sload()?;344		self.recorder().consume_sstore()?;345346		<Pallet<T>>::ensure_owner(contract_address, caller).map_err(dispatch_to_evm::<T>)?;347		<Pallet<T>>::toggle_allowlist(contract_address, enabled);348		Ok(())349	}350}351352/// Implements [`OnMethodCall`], which delegates call to [`ContractHelpers`]353pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);354impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T>355where356	T::AccountId: AsRef<[u8; 32]>,357{358	fn is_reserved(contract: &sp_core::H160) -> bool {359		contract == &T::ContractAddress::get()360	}361362	fn is_used(contract: &sp_core::H160) -> bool {363		contract == &T::ContractAddress::get()364	}365366	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {367		// TODO: Extract to another OnMethodCall handler368		if <AllowlistEnabled<T>>::get(handle.code_address())369			&& !<Pallet<T>>::allowed(handle.code_address(), handle.context().caller)370		{371			return Some(Err(PrecompileFailure::Revert {372				exit_status: ExitRevert::Reverted,373				output: {374					let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));375					writer.string("Target contract is allowlisted");376					writer.finish()377				},378			}));379		}380381		if handle.code_address() != T::ContractAddress::get() {382			return None;383		}384385		let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));386		pallet_evm_coder_substrate::call(handle, helpers)387	}388389	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {390		(contract == &T::ContractAddress::get())391			.then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())392	}393}394395/// Hooks into contract creation, storing owner of newly deployed contract396pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);397impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {398	fn on_create(owner: H160, contract: H160) {399		<Owner<T>>::insert(contract, owner);400	}401}402403/// Bridge to pallet-sponsoring404pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);405impl<T: Config> SponsorshipHandler<T::CrossAccountId, CallContext>406	for HelpersContractSponsoring<T>407{408	fn get_sponsor(409		who: &T::CrossAccountId,410		call_context: &CallContext,411	) -> Option<T::CrossAccountId> {412		let contract_address = call_context.contract_address;413		let mode = <Pallet<T>>::sponsoring_mode(contract_address);414		if mode == SponsoringModeT::Disabled {415			return None;416		}417418		let sponsor = match <Pallet<T>>::get_sponsor(contract_address) {419			Some(sponsor) => sponsor,420			None => return None,421		};422423		if mode == SponsoringModeT::Allowlisted424			&& !<Pallet<T>>::allowed(contract_address, *who.as_eth())425		{426			return None;427		}428		let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;429430		if let Some(last_tx_block) = <SponsorBasket<T>>::get(contract_address, who.as_eth()) {431			let limit = <SponsoringRateLimit<T>>::get(contract_address);432433			let timeout = last_tx_block + limit;434			if block_number < timeout {435				return None;436			}437		}438439		let sponsored_fee_limit = get_sponsoring_fee_limit::<T>(contract_address);440441		if call_context.max_fee > sponsored_fee_limit {442			return None;443		}444445		<SponsorBasket<T>>::insert(contract_address, who.as_eth(), block_number);446447		Some(sponsor)448	}449}450451fn get_sponsoring_fee_limit<T: Config>(contract_address: Address) -> U256 {452	<SponsoringFeeLimit<T>>::get(contract_address)453		.get(&0xffffffff)454		.cloned()455		.unwrap_or(U256::MAX)456}457458generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);459generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);
modifiedpallets/gov-origins/src/lib.rsdiffbeforeafterboth
--- a/pallets/gov-origins/src/lib.rs
+++ b/pallets/gov-origins/src/lib.rs
@@ -31,6 +31,7 @@
 
 	#[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)]
 	#[pallet::origin]
+	#[non_exhaustive]
 	pub enum Origin {
 		/// Origin able to send proposal from fellowship collective to democracy pallet.
 		FellowshipProposition,
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -139,116 +139,114 @@
 	T: Config + pallet_common::Config + pallet_nonfungible::Config + pallet_refungible::Config,
 	T::AccountId: From<[u8; 32]>,
 {
-	/*
-		/// Create a collection
-		/// @return address Address of the newly created collection
-		#[weight(<SelfWeightOf<T>>::create_collection())]
-		#[solidity(rename_selector = "createCollection")]
-		fn create_collection(
-			&mut self,
-			caller: Caller,
-			value: Value,
-			data: eth::CreateCollectionData,
-		) -> Result<Address> {
-			let (caller, name, description, token_prefix) =
-				convert_data::<T>(caller, data.name, data.description, data.token_prefix)?;
-			if data.mode != eth::CollectionMode::Fungible && data.decimals != 0 {
-				return Err("decimals are only supported for NFT and RFT collections".into());
-			}
-			let mode = match data.mode {
-				eth::CollectionMode::Fungible => CollectionMode::Fungible(data.decimals),
-				eth::CollectionMode::Nonfungible => CollectionMode::NFT,
-				eth::CollectionMode::Refungible => CollectionMode::ReFungible,
-			};
+	/// Create a collection
+	/// @return address Address of the newly created collection
+	#[weight(<SelfWeightOf<T>>::create_collection())]
+	#[solidity(rename_selector = "createCollection")]
+	fn create_collection(
+		&mut self,
+		caller: Caller,
+		value: Value,
+		data: eth::CreateCollectionData,
+	) -> Result<Address> {
+		let (caller, name, description, token_prefix) =
+			convert_data::<T>(caller, data.name, data.description, data.token_prefix)?;
+		if data.mode != eth::CollectionMode::Fungible && data.decimals != 0 {
+			return Err("decimals are only supported for NFT and RFT collections".into());
+		}
+		let mode = match data.mode {
+			eth::CollectionMode::Fungible => CollectionMode::Fungible(data.decimals),
+			eth::CollectionMode::Nonfungible => CollectionMode::NFT,
+			eth::CollectionMode::Refungible => CollectionMode::ReFungible,
+		};
 
-			let properties: BoundedVec<_, _> = data
-				.properties
-				.into_iter()
-				.map(eth::Property::try_into)
-				.collect::<Result<Vec<_>>>()?
-				.try_into()
-				.map_err(|_| "too many properties")?;
+		let properties: BoundedVec<_, _> = data
+			.properties
+			.into_iter()
+			.map(eth::Property::try_into)
+			.collect::<Result<Vec<_>>>()?
+			.try_into()
+			.map_err(|_| "too many properties")?;
 
-			let token_property_permissions =
-				eth::TokenPropertyPermission::into_property_key_permissions(
-					data.token_property_permissions,
-				)?
-				.try_into()
-				.map_err(|_| "too many property permissions")?;
+		let token_property_permissions =
+			eth::TokenPropertyPermission::into_property_key_permissions(
+				data.token_property_permissions,
+			)?
+			.try_into()
+			.map_err(|_| "too many property permissions")?;
 
-			let limits = if !data.limits.is_empty() {
-				Some(
-					data.limits
-						.into_iter()
-						.collect::<Result<up_data_structs::CollectionLimits>>()?,
-				)
-			} else {
-				None
-			};
+		let limits = if !data.limits.is_empty() {
+			Some(
+				data.limits
+					.into_iter()
+					.collect::<Result<up_data_structs::CollectionLimits>>()?,
+			)
+		} else {
+			None
+		};
 
-			let pending_sponsor = data.pending_sponsor.into_option_sub_cross_account::<T>()?;
+		let pending_sponsor = data.pending_sponsor.into_option_sub_cross_account::<T>()?;
 
-			let restricted = if !data.nesting_settings.restricted.is_empty() {
-				Some(
-					data.nesting_settings
-						.restricted
-						.iter()
-						.map(map_eth_to_id)
-						.collect::<Option<BTreeSet<_>>>()
-						.ok_or("can't convert address into collection id")?
-						.try_into()
-						.map_err(|_| "too many collections")?,
-				)
-			} else {
-				None
-			};
+		let restricted = if !data.nesting_settings.restricted.is_empty() {
+			Some(
+				data.nesting_settings
+					.restricted
+					.iter()
+					.map(map_eth_to_id)
+					.collect::<Option<BTreeSet<_>>>()
+					.ok_or("can't convert address into collection id")?
+					.try_into()
+					.map_err(|_| "too many collections")?,
+			)
+		} else {
+			None
+		};
 
-			let admin_list = data
-				.admin_list
-				.into_iter()
-				.map(|admin| admin.into_sub_cross_account::<T>())
-				.collect::<Result<Vec<_>>>()?;
+		let admin_list = data
+			.admin_list
+			.into_iter()
+			.map(|admin| admin.into_sub_cross_account::<T>())
+			.collect::<Result<Vec<_>>>()?;
 
-			let flags = data.flags;
-			if !flags.is_allowed_for_user() {
-				return Err("internal flags were used".into());
-			}
+		let flags = data.flags;
+		if !flags.is_allowed_for_user() {
+			return Err("internal flags were used".into());
+		}
 
-			let data = CreateCollectionData {
-				name,
-				mode,
-				description,
-				token_prefix,
-				properties,
-				token_property_permissions,
-				limits,
-				pending_sponsor,
+		let data = CreateCollectionData {
+			name,
+			mode,
+			description,
+			token_prefix,
+			properties,
+			token_property_permissions,
+			limits,
+			pending_sponsor,
+			access: None,
+			permissions: Some(CollectionPermissions {
 				access: None,
-				permissions: Some(CollectionPermissions {
-					access: None,
-					mint_mode: None,
-					nesting: Some(NestingPermissions {
-						token_owner: data.nesting_settings.token_owner,
-						collection_admin: data.nesting_settings.collection_admin,
-						restricted,
-						#[cfg(feature = "runtime-benchmarks")]
-						permissive: true,
-					}),
+				mint_mode: None,
+				nesting: Some(NestingPermissions {
+					token_owner: data.nesting_settings.token_owner,
+					collection_admin: data.nesting_settings.collection_admin,
+					restricted,
+					#[cfg(feature = "runtime-benchmarks")]
+					permissive: true,
 				}),
-				admin_list,
-				flags,
-			};
-			check_sent_amount_equals_collection_creation_price::<T>(value)?;
-			let collection_helpers_address =
-				T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());
+			}),
+			admin_list,
+			flags,
+		};
+		check_sent_amount_equals_collection_creation_price::<T>(value)?;
+		let collection_helpers_address =
+			T::CrossAccountId::from_eth(<T as pallet_common::Config>::ContractAddress::get());
 
-			let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)
-				.map_err(dispatch_to_evm::<T>)?;
+		let collection_id = T::CollectionDispatch::create(caller, collection_helpers_address, data)
+			.map_err(dispatch_to_evm::<T>)?;
 
-			let address = pallet_common::eth::collection_id_to_address(collection_id);
-			Ok(address)
-		}
-	*/
+		let address = pallet_common::eth::collection_id_to_address(collection_id);
+		Ok(address)
+	}
 
 	/// Create an NFT collection
 	/// @param name Name of the collection
modifiedprimitives/data-structs/Cargo.tomldiffbeforeafterboth
--- a/primitives/data-structs/Cargo.toml
+++ b/primitives/data-structs/Cargo.toml
@@ -39,3 +39,4 @@
 	"sp-runtime/std",
 	"sp-std/std",
 ]
+stubgen = ["evm-coder/stubgen"]
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -24,7 +24,7 @@
 		weights::CommonWeights,
 		RelayChainBlockNumberProvider,
 	},
-	Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS,
+	Runtime, RuntimeEvent, RuntimeCall, RUNTIME_NAME, TOKEN_SYMBOL, DECIMALS,
 	Balances,
 };
 use frame_support::traits::{ConstU32, ConstU64, Currency};
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -17,7 +17,7 @@
 //! Implements EVM sponsoring logic via TransactionValidityHack
 
 use core::{convert::TryInto, marker::PhantomData};
-use evm_coder::{Call, abi::AbiReader};
+use evm_coder::{Call};
 use pallet_common::{CollectionHandle, eth::map_eth_to_id};
 use pallet_evm::account::CrossAccountId;
 use pallet_evm_transaction_payment::CallContext;
@@ -66,11 +66,11 @@
 		if let Some(collection_id) = map_eth_to_id(&call_context.contract_address) {
 			let collection = <CollectionHandle<T>>::new(collection_id)?;
 			let sponsor = collection.sponsorship.sponsor()?.clone();
-			let (method_id, mut reader) = AbiReader::new_call(&call_context.input).ok()?;
+			// let (method_id, mut reader) = AbiReader::new_call(&call_context.input).ok()?;
 			Some(T::CrossAccountId::from_sub(match &collection.mode {
 				CollectionMode::NFT => {
 					let collection = NonfungibleHandle::cast(collection);
-					let call = <UniqueNFTCall<T>>::parse(method_id, &mut reader).ok()??;
+					let call = <UniqueNFTCall<T>>::parse_full(&call_context.input).ok()??;
 					match call {
 						UniqueNFTCall::TokenProperties(call) => match call {
 							TokenPropertiesCall::SetProperty {
@@ -161,11 +161,11 @@
 					}
 				}
 				CollectionMode::ReFungible => {
-					let call = <UniqueRefungibleCall<T>>::parse(method_id, &mut reader).ok()??;
+					let call = <UniqueRefungibleCall<T>>::parse_full(&call_context.input).ok()??;
 					refungible::call_sponsor(call, collection, who).map(|()| sponsor)
 				}
 				CollectionMode::Fungible(_) => {
-					let call = <UniqueFungibleCall<T>>::parse(method_id, &mut reader).ok()??;
+					let call = <UniqueFungibleCall<T>>::parse_full(&call_context.input).ok()??;
 					match call {
 						UniqueFungibleCall::ERC20(ERC20Call::Transfer { .. }) => {
 							withdraw_transfer::<T>(&collection, who, &TokenId::default())
@@ -196,8 +196,7 @@
 			// Token existance isn't checked at this point and should be checked in `withdraw` method.
 			let token = RefungibleTokenHandle(rft_collection, token_id);
 
-			let (method_id, mut reader) = AbiReader::new_call(&call_context.input).ok()?;
-			let call = <UniqueRefungibleTokenCall<T>>::parse(method_id, &mut reader).ok()??;
+			let call = <UniqueRefungibleTokenCall<T>>::parse_full(&call_context.input).ok()??;
 			Some(T::CrossAccountId::from_sub(
 				refungible::token_call_sponsor(call, token, who).map(|()| sponsor)?,
 			))
modifiedtests/src/eth/abi/collectionHelpers.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/collectionHelpers.json
+++ b/tests/src/eth/abi/collectionHelpers.json
@@ -77,15 +77,6 @@
     "inputs": [
       {
         "components": [
-          {
-            "components": [
-              { "internalType": "address", "name": "eth", "type": "address" },
-              { "internalType": "uint256", "name": "sub", "type": "uint256" }
-            ],
-            "internalType": "struct CrossAddress",
-            "name": "pending_sponsor",
-            "type": "tuple"
-          },
           { "internalType": "string", "name": "name", "type": "string" },
           { "internalType": "string", "name": "description", "type": "string" },
           {
@@ -170,6 +161,15 @@
             "type": "tuple[]"
           },
           {
+            "components": [
+              { "internalType": "address", "name": "eth", "type": "address" },
+              { "internalType": "uint256", "name": "sub", "type": "uint256" }
+            ],
+            "internalType": "struct CrossAddress",
+            "name": "pending_sponsor",
+            "type": "tuple"
+          },
+          {
             "internalType": "CollectionFlags",
             "name": "flags",
             "type": "uint8"
modifiedtests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -59,8 +59,8 @@
 }
 
 export enum CollectionMode {
+	Nonfungible,
 	Fungible,
-	Nonfungible,
 	Refungible,
 }
 
@@ -129,4 +129,4 @@
     else
       this.decimals = 0;
   }
-}
\ No newline at end of file
+}
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
@@ -216,7 +216,6 @@
     }
 
     const tx = collectionHelper.methods.createCollection([
-      this.data.pendingSponsor,
       this.data.name,
       this.data.description,
       this.data.tokenPrefix,
@@ -227,6 +226,7 @@
       this.data.adminList,
       this.data.nestingSettings,
       this.data.limits,
+      this.data.pendingSponsor,
       this.data.flags,
     ]);
     return tx;