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

difftreelog

CORE-302 Implement setSponsor method.

Trubnikov Sergey2022-04-20parent: #281abcb.patch.diff
in: master

10 files changed

modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@
 TESTS_API=./tests/src/eth/api/
 
 .PHONY: regenerate_solidity
-regenerate_solidity: UniqueFungible.sol UniqueNFT.sol ContractHelpers.sol
+regenerate_solidity: UniqueFungible.sol UniqueNFT.sol ContractHelpers.sol Collection.sol
 
 UniqueFungible.sol:
 	PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
@@ -36,8 +36,8 @@
 	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=$(CONTRACT_HELPERS_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
 
 Collection.sol:
-	PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
-	PACKAGE=pallet-evm-collection NAME=eth::contract_helpers_impl OUTPUT=$(COLLECTION_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
+	PACKAGE=pallet-evm-collection NAME=eth::collection_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
+	PACKAGE=pallet-evm-collection NAME=eth::collection_impl OUTPUT=$(COLLECTION_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
 
 UniqueFungible: UniqueFungible.sol
 	INPUT=$(FUNGIBLE_EVM_STUBS)/$< OUTPUT=$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw ./.maintain/scripts/compile_stub.sh
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -114,6 +114,15 @@
 			recorder: SubstrateRecorder::new(gas_limit),
 		})
 	}
+
+	pub fn new_with_recorder(id: CollectionId, recorder: Rc<SubstrateRecorder<T>>) -> Option<Self> {
+		<CollectionById<T>>::get(id).map(|collection| Self {
+			id,
+			collection,
+			recorder,
+		})
+	}
+
 	pub fn new(id: CollectionId) -> Option<Self> {
 		Self::new_with_gas_limit(id, u64::MAX)
 	}
@@ -140,6 +149,10 @@
 		<CollectionById<T>>::insert(self.id, self.collection);
 		Ok(())
 	}
+
+	pub fn set_sponsor(&mut self, sponsor: T::AccountId) {
+		self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor);
+	}
 }
 impl<T: Config> Deref for CollectionHandle<T> {
 	type Target = Collection<T::AccountId>;
modifiedpallets/evm-collection/src/eth.rsdiffbeforeafterboth
before · pallets/evm-collection/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/>.1617use core::marker::PhantomData;18use evm_coder::{abi::AbiWriter, execution::*, generate_stubgen, solidity_interface, types::*, ToLog};19use ethereum as _;20use pallet_common::CollectionById;21use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};22use pallet_evm::{23	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,24	account::CrossAccountId, Pallet as PalletEvm,25};26use sp_core::H160;27use up_data_structs::{28	CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,29	MAX_COLLECTION_NAME_LENGTH,30};31use crate::{Config, Pallet};32use frame_support::traits::Get;3334use sp_std::{vec::Vec, rc::Rc};35use alloc::format;3637struct EvmCollection<T: Config>(SubstrateRecorder<T>);38impl<T: Config> WithRecorder<T> for EvmCollection<T> {39	fn recorder(&self) -> &SubstrateRecorder<T> {40		&self.041	}4243	fn into_recorder(self) -> SubstrateRecorder<T> {44		self.045	}46}4748#[derive(ToLog)]49pub enum CollectionEvent {50	CollectionCreated {51		#[indexed]52		owner: address,53		#[indexed]54		collection_id: address,55	},56}5758#[solidity_interface(name = "Collection")]59impl<T: Config> EvmCollection<T> {60	fn create_721_collection(61		&self,62		caller: caller,63		name: string,64		description: string,65		token_prefix: string,66	) -> Result<address> {67		let caller = T::CrossAccountId::from_eth(caller);68		let name = name69			.encode_utf16()70			.collect::<Vec<u16>>()71			.try_into()72			.map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;73		let description = description74			.encode_utf16()75			.collect::<Vec<u16>>()76			.try_into()77			.map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;78		let token_prefix = token_prefix79			.into_bytes()80			.try_into()81			.map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;8283		let data = CreateCollectionData {84			name,85			description,86			token_prefix,87			..Default::default()88		};8990		let collection_id =91			<pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)92				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;9394		let address = pallet_common::eth::collection_id_to_address(collection_id);95		<PalletEvm<T>>::deposit_log(96			CollectionEvent::CollectionCreated {97				owner: *caller.as_eth(),98				collection_id: address,99			}100			.to_log(address),101		);102		Ok(address)103	}104105	// fn set_sponsor(collection_id: address, sponsor: address) -> Result<void> {106	// 	let collection_id =107	// 		pallet_common::eth::map_eth_to_id(&collection_id).ok_or(Error::Revert("".into()))?;108	// 	let mut collection = <CollectionById<T>>::get(collection_id).ok_or(Error::Revert("".into()))?;109	// 	let sponsor = T::CrossAccountId::from_eth(sponsor);110	// 	collection.sponsorship = SponsorshipState::Unconfirmed(sponsor.as_sub().clone());111	// 	<CollectionById<T>>::insert(collection_id, collection);112	// 	Ok(())113	// }114115	// fn set_offchain_shema(shema: string) -> Result<void> {116	// 	Ok(())117	// }118119	// fn set_const_on_chain_schema(shema: string) -> Result<void> {120	// 	Ok(())121	// }122123	// fn set_variable_on_chain_schema(shema: string) -> Result<void> {124	// 	Ok(())125	// }126127	// fn set_limits(limits: string) -> Result<void> {128	// 	Ok(())129	// }130}131132fn error_feild_too_long(feild: &str, bound: u32) -> Error {133	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))134}135136pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);137impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {138	fn is_reserved(contract: &sp_core::H160) -> bool {139		contract == &T::ContractAddress::get()140	}141142	fn is_used(contract: &sp_core::H160) -> bool {143		contract == &T::ContractAddress::get()144	}145146	fn call(147		source: &sp_core::H160,148		target: &sp_core::H160,149		gas_left: u64,150		input: &[u8],151		value: sp_core::U256,152	) -> Option<PrecompileResult> {153		// TODO: Extract to another OnMethodCall handler154		if target != &T::ContractAddress::get() {155			return None;156		}157158		let helpers = EvmCollection::<T>(SubstrateRecorder::<T>::new(gas_left));159		pallet_evm_coder_substrate::call(*source, helpers, value, input)160	}161162	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {163		(contract == &T::ContractAddress::get())164			.then(|| include_bytes!("./stubs/Collection.raw").to_vec())165	}166}167168generate_stubgen!(collection_impl, CollectionCall<()>, true);169generate_stubgen!(collection_iface, CollectionCall<()>, false);
after · pallets/evm-collection/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/>.1617use core::marker::PhantomData;18use evm_coder::{abi::AbiWriter, execution::*, generate_stubgen, solidity_interface, types::*, ToLog};19use ethereum as _;20use pallet_common::{CollectionById, CollectionHandle};21use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};22use pallet_evm::{23	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure,24	account::CrossAccountId, Pallet as PalletEvm,25};26use sp_core::H160;27use up_data_structs::{28	CreateCollectionData, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,29	MAX_COLLECTION_NAME_LENGTH, SponsorshipState,30};31use crate::{Config, Pallet};32use frame_support::traits::Get;3334use sp_std::{vec::Vec, rc::Rc};35use alloc::format;3637struct EvmCollection<T: Config>(SubstrateRecorder<T>);38impl<T: Config> WithRecorder<T> for EvmCollection<T> {39	fn recorder(&self) -> &SubstrateRecorder<T> {40		&self.041	}4243	fn into_recorder(self) -> SubstrateRecorder<T> {44		self.045	}46}4748#[derive(ToLog)]49pub enum CollectionEvent {50	CollectionCreated {51		#[indexed]52		owner: address,53		#[indexed]54		collection_id: address,55	},56}5758#[solidity_interface(name = "Collection")]59impl<T: Config> EvmCollection<T> {6061	fn create_721_collection(62		&self,63		caller: caller,64		name: string,65		description: string,66		token_prefix: string,67	) -> Result<address> {68		let caller = T::CrossAccountId::from_eth(caller);69		let name = name70			.encode_utf16()71			.collect::<Vec<u16>>()72			.try_into()73			.map_err(|_| error_feild_too_long("name", MAX_COLLECTION_NAME_LENGTH))?;74		let description = description75			.encode_utf16()76			.collect::<Vec<u16>>()77			.try_into()78			.map_err(|_| error_feild_too_long("description", MAX_COLLECTION_DESCRIPTION_LENGTH))?;79		let token_prefix = token_prefix80			.into_bytes()81			.try_into()82			.map_err(|_| error_feild_too_long("token_prefix", MAX_TOKEN_PREFIX_LENGTH))?;8384		let data = CreateCollectionData {85			name,86			description,87			token_prefix,88			..Default::default()89		};9091		let collection_id =92			<pallet_nonfungible::Pallet<T>>::init_collection(caller.as_sub().clone(), data)93				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;9495		let address = pallet_common::eth::collection_id_to_address(collection_id);96		<PalletEvm<T>>::deposit_log(97			CollectionEvent::CollectionCreated {98				owner: *caller.as_eth(),99				collection_id: address,100			}101			.to_log(address),102		);103		Ok(address)104	}105106	fn set_sponsor(107		&self,108		caller: caller,109		contract_address: address,110		sponsor: address,111	) -> Result<void> {112		let collection_id =113			pallet_common::eth::map_eth_to_id(&contract_address).ok_or(Error::Revert("".into()))?;114		let mut collection =115			pallet_common::CollectionHandle::new_with_recorder(collection_id, self.0.clone())116				.ok_or(Error::Revert("".into()))?;117		118		let caller = T::CrossAccountId::from_eth(caller);119		collection.check_is_owner(&caller).map_err(|e| Error::Revert(format!("{:?}", e)))?;120121		let sponsor = T::CrossAccountId::from_eth(sponsor);122		collection.set_sponsor(sponsor.as_sub().clone());123		collection124			.save()125			.map_err(|e| Error::Revert(format!("{:?}", e)))126	}127128	// fn set_offchain_shema(shema: string) -> Result<void> {129	// 	Ok(())130	// }131132	// fn set_const_on_chain_schema(shema: string) -> Result<void> {133	// 	Ok(())134	// }135136	// fn set_variable_on_chain_schema(shema: string) -> Result<void> {137	// 	Ok(())138	// }139140	// fn set_limits(limits: string) -> Result<void> {141	// 	Ok(())142	// }143}144145fn error_feild_too_long(feild: &str, bound: u32) -> Error {146	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))147}148149pub struct CollectionOnMethodCall<T: Config>(PhantomData<*const T>);150impl<T: Config> OnMethodCall<T> for CollectionOnMethodCall<T> {151	fn is_reserved(contract: &sp_core::H160) -> bool {152		contract == &T::ContractAddress::get()153	}154155	fn is_used(contract: &sp_core::H160) -> bool {156		contract == &T::ContractAddress::get()157	}158159	fn call(160		source: &sp_core::H160,161		target: &sp_core::H160,162		gas_left: u64,163		input: &[u8],164		value: sp_core::U256,165	) -> Option<PrecompileResult> {166		// TODO: Extract to another OnMethodCall handler167		if target != &T::ContractAddress::get() {168			return None;169		}170171		let helpers = EvmCollection::<T>(SubstrateRecorder::<T>::new(gas_left));172		pallet_evm_coder_substrate::call(*source, helpers, value, input)173	}174175	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {176		(contract == &T::ContractAddress::get())177			.then(|| include_bytes!("./stubs/Collection.raw").to_vec())178	}179}180181generate_stubgen!(collection_impl, CollectionCall<()>, true);182generate_stubgen!(collection_iface, CollectionCall<()>, false);
modifiedpallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-collection/src/stubs/Collection.soldiffbeforeafterboth
--- a/pallets/evm-collection/src/stubs/Collection.sol
+++ b/pallets/evm-collection/src/stubs/Collection.sol
@@ -21,130 +21,8 @@
 	}
 }
 
-// Selector: ee5467a8
+// Selector: 6503bbc2
 contract Collection is Dummy, ERC165 {
-	// Selector: contractOwner(address) 5152b14c
-	function contractOwner(address contractAddress)
-		public
-		view
-		returns (address)
-	{
-		require(false, stub_error);
-		contractAddress;
-		dummy;
-		return 0x0000000000000000000000000000000000000000;
-	}
-
-	// Selector: sponsoringEnabled(address) 6027dc61
-	function sponsoringEnabled(address contractAddress)
-		public
-		view
-		returns (bool)
-	{
-		require(false, stub_error);
-		contractAddress;
-		dummy;
-		return false;
-	}
-
-	// Deprecated
-	//
-	// Selector: toggleSponsoring(address,bool) fcac6d86
-	function toggleSponsoring(address contractAddress, bool enabled) public {
-		require(false, stub_error);
-		contractAddress;
-		enabled;
-		dummy = 0;
-	}
-
-	// Selector: setSponsoringMode(address,uint8) fde8a560
-	function setSponsoringMode(address contractAddress, uint8 mode) public {
-		require(false, stub_error);
-		contractAddress;
-		mode;
-		dummy = 0;
-	}
-
-	// Selector: sponsoringMode(address) b70c7267
-	function sponsoringMode(address contractAddress)
-		public
-		view
-		returns (uint8)
-	{
-		require(false, stub_error);
-		contractAddress;
-		dummy;
-		return 0;
-	}
-
-	// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
-	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
-		public
-	{
-		require(false, stub_error);
-		contractAddress;
-		rateLimit;
-		dummy = 0;
-	}
-
-	// Selector: getSponsoringRateLimit(address) 610cfabd
-	function getSponsoringRateLimit(address contractAddress)
-		public
-		view
-		returns (uint32)
-	{
-		require(false, stub_error);
-		contractAddress;
-		dummy;
-		return 0;
-	}
-
-	// Selector: allowed(address,address) 5c658165
-	function allowed(address contractAddress, address user)
-		public
-		view
-		returns (bool)
-	{
-		require(false, stub_error);
-		contractAddress;
-		user;
-		dummy;
-		return false;
-	}
-
-	// Selector: allowlistEnabled(address) c772ef6c
-	function allowlistEnabled(address contractAddress)
-		public
-		view
-		returns (bool)
-	{
-		require(false, stub_error);
-		contractAddress;
-		dummy;
-		return false;
-	}
-
-	// Selector: toggleAllowlist(address,bool) 36de20f5
-	function toggleAllowlist(address contractAddress, bool enabled) public {
-		require(false, stub_error);
-		contractAddress;
-		enabled;
-		dummy = 0;
-	}
-
-	// Selector: toggleAllowed(address,address,bool) 4706cc1c
-	function toggleAllowed(
-		address contractAddress,
-		address user,
-		bool allowed
-	) public {
-		require(false, stub_error);
-		contractAddress;
-		user;
-		allowed;
-		dummy = 0;
-	}
-
 	// Selector: create721Collection(string,string,string) 951c0151
 	function create721Collection(
 		string memory name,
@@ -158,4 +36,12 @@
 		dummy;
 		return 0x0000000000000000000000000000000000000000;
 	}
+
+	// Selector: setSponsor(address,address) f01fba93
+	function setSponsor(address contractAddress, address sponsor) public view {
+		require(false, stub_error);
+		contractAddress;
+		sponsor;
+		dummy;
+	}
 }
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -520,7 +520,7 @@
 			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
 			target_collection.check_is_owner(&sender)?;
 
-			target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor.clone());
+			target_collection.set_sponsor(new_sponsor.clone());
 
 			<Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(
 				collection_id,
modifiedtests/src/eth/api/Collection.soldiffbeforeafterboth
--- a/tests/src/eth/api/Collection.sol
+++ b/tests/src/eth/api/Collection.sol
@@ -12,70 +12,15 @@
 	function supportsInterface(bytes4 interfaceID) external view returns (bool);
 }
 
-// Selector: ee5467a8
+// Selector: 6503bbc2
 interface Collection is Dummy, ERC165 {
-	// Selector: contractOwner(address) 5152b14c
-	function contractOwner(address contractAddress)
-		external
-		view
-		returns (address);
-
-	// Selector: sponsoringEnabled(address) 6027dc61
-	function sponsoringEnabled(address contractAddress)
-		external
-		view
-		returns (bool);
-
-	// Deprecated
-	//
-	// Selector: toggleSponsoring(address,bool) fcac6d86
-	function toggleSponsoring(address contractAddress, bool enabled) external;
-
-	// Selector: setSponsoringMode(address,uint8) fde8a560
-	function setSponsoringMode(address contractAddress, uint8 mode) external;
-
-	// Selector: sponsoringMode(address) b70c7267
-	function sponsoringMode(address contractAddress)
-		external
-		view
-		returns (uint8);
-
-	// Selector: setSponsoringRateLimit(address,uint32) 77b6c908
-	function setSponsoringRateLimit(address contractAddress, uint32 rateLimit)
-		external;
-
-	// Selector: getSponsoringRateLimit(address) 610cfabd
-	function getSponsoringRateLimit(address contractAddress)
-		external
-		view
-		returns (uint32);
-
-	// Selector: allowed(address,address) 5c658165
-	function allowed(address contractAddress, address user)
-		external
-		view
-		returns (bool);
-
-	// Selector: allowlistEnabled(address) c772ef6c
-	function allowlistEnabled(address contractAddress)
-		external
-		view
-		returns (bool);
-
-	// Selector: toggleAllowlist(address,bool) 36de20f5
-	function toggleAllowlist(address contractAddress, bool enabled) external;
-
-	// Selector: toggleAllowed(address,address,bool) 4706cc1c
-	function toggleAllowed(
-		address contractAddress,
-		address user,
-		bool allowed
-	) external;
-
 	// Selector: create721Collection(string,string,string) 951c0151
 	function create721Collection(
 		string memory name,
 		string memory description,
 		string memory tokenPrefix
 	) external view returns (address);
+
+	// Selector: setSponsor(address,address) f01fba93
+	function setSponsor(address contractAddress, address sponsor) external view;
 }
modifiedtests/src/eth/collectionAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/collectionAbi.json
+++ b/tests/src/eth/collectionAbi.json
@@ -1,65 +1,12 @@
 [
   {
     "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      },
-      { "internalType": "address", "name": "user", "type": "address" }
-    ],
-    "name": "allowed",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "allowlistEnabled",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "contractOwner",
-    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
       { "internalType": "string", "name": "name", "type": "string" },
       { "internalType": "string", "name": "description", "type": "string" },
       { "internalType": "string", "name": "tokenPrefix", "type": "string" }
     ],
     "name": "create721Collection",
     "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "getSponsoringRateLimit",
-    "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
     "stateMutability": "view",
     "type": "function"
   },
@@ -70,103 +17,20 @@
         "name": "contractAddress",
         "type": "address"
       },
-      { "internalType": "uint8", "name": "mode", "type": "uint8" }
-    ],
-    "name": "setSponsoringMode",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      },
-      { "internalType": "uint32", "name": "rateLimit", "type": "uint32" }
+      { "internalType": "address", "name": "sponsor", "type": "address" }
     ],
-    "name": "setSponsoringRateLimit",
+    "name": "setSponsor",
     "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "sponsoringEnabled",
-    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
     "stateMutability": "view",
     "type": "function"
   },
   {
     "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      }
-    ],
-    "name": "sponsoringMode",
-    "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
-    "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
       { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
     ],
     "name": "supportsInterface",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
     "stateMutability": "view",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      },
-      { "internalType": "address", "name": "user", "type": "address" },
-      { "internalType": "bool", "name": "allowed", "type": "bool" }
-    ],
-    "name": "toggleAllowed",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      },
-      { "internalType": "bool", "name": "enabled", "type": "bool" }
-    ],
-    "name": "toggleAllowlist",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      {
-        "internalType": "address",
-        "name": "contractAddress",
-        "type": "address"
-      },
-      { "internalType": "bool", "name": "enabled", "type": "bool" }
-    ],
-    "name": "toggleSponsoring",
-    "outputs": [],
-    "stateMutability": "nonpayable",
     "type": "function"
   }
 ]
modifiedtests/src/eth/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createCollection.test.ts
+++ b/tests/src/eth/createCollection.test.ts
@@ -14,32 +14,53 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+import {ApiPromise} from '@polkadot/api';
+import {evmToAddress} from '@polkadot/util-crypto';
 import {expect} from 'chai';
 import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';
-import {collectionHelper, collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';
+import {collectionHelper, collectionIdFromAddress, createEthAccountWithBalance, itWeb3, normalizeAddress} from './util/helpers';
 
+async function getCollectionAddressFromResult(api: ApiPromise, result: any) {
+  const collectionIdAddress = normalizeAddress(result.events[0].raw.topics[2]);
+  const collectionId = collectionIdFromAddress(collectionIdAddress);  
+  const collection = (await getDetailedCollectionInfo(api, collectionId))!;
+  return {collectionIdAddress, collectionId, collection};
+}
+
 describe('Create collection from EVM', () => {
   itWeb3('Create collection', async ({api, web3}) => {
     const owner = await createEthAccountWithBalance(api, web3);
-    const helpers = collectionHelper(web3, owner);
+    const helper = collectionHelper(web3, owner);
     const collectionName = 'CollectionEVM';
     const description = 'Some description';
     const tokenPrefix = 'token prefix';
   
     const collectionCountBefore = await getCreatedCollectionCount(api);
-    const result = await helpers.methods
+    const result = await helper.methods
       .create721Collection(collectionName, description, tokenPrefix)
       .send();
     const collectionCountAfter = await getCreatedCollectionCount(api);
   
-    const collectionId = collectionIdFromAddress(result.events[0].raw.topics[2]);
+    const {collectionId, collection} = await getCollectionAddressFromResult(api, result);
     expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
     expect(collectionId).to.be.eq(collectionCountAfter);
-      
-    const collection = (await getDetailedCollectionInfo(api, collectionId))!;
     expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);
     expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);
     expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);
     expect(collection.schemaVersion.type).to.be.eq('ImageURL');
   });
+  
+  itWeb3('Set sponsorship', async ({api, web3}) => {
+    const owner = await createEthAccountWithBalance(api, web3);
+    const helper = collectionHelper(web3, owner);
+    let result = await helper.methods.create721Collection('Sponsor collection', '1', '1').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+    const sponsor = await createEthAccountWithBalance(api, web3);
+    result = await helper.methods.setSponsor(collectionIdAddress, sponsor).send();
+    const collection = (await getDetailedCollectionInfo(api, collectionId))!;
+    expect(collection.sponsorship.isUnconfirmed).to.be.true;
+    expect(collection.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
+  });
+
+
 });
\ No newline at end of file
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -74,7 +74,15 @@
   return Web3.utils.toChecksumAddress('0x' + buf.toString('hex'));
 }
 export function collectionIdFromAddress(address: string): number {
-  return Number('0x' + address.substring(address.length - 8));
+  if (!address.startsWith('0x'))
+    throw 'address not starts with "0x"';
+  if (address.length > 42)
+    throw 'address length is more than 20 bytes';
+    return Number('0x' + address.substring(address.length - 8));
+}
+  
+export function normalizeAddress(address: string): string {
+  return '0x' + address.substring(address.length - 40);
 }
 
 export function tokenIdToAddress(collection: number, token: number): string {