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

difftreelog

refac: rename substrate methods to cross

Trubnikov Sergey2022-10-24parent: #7f98069.patch.diff
in: master

27 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1077,13 +1077,13 @@
 
 [[package]]
 name = "console"
-version = "0.15.1"
+version = "0.15.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847"
+checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c"
 dependencies = [
  "encode_unicode",
+ "lazy_static",
  "libc",
- "once_cell",
  "terminal_size",
  "winapi",
 ]
@@ -1871,9 +1871,9 @@
 
 [[package]]
 name = "cxx"
-version = "1.0.79"
+version = "1.0.78"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f83d0ebf42c6eafb8d7c52f7e5f2d3003b89c7aa4fd2b79229209459a849af8"
+checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4"
 dependencies = [
  "cc",
  "cxxbridge-flags",
@@ -1883,9 +1883,9 @@
 
 [[package]]
 name = "cxx-build"
-version = "1.0.79"
+version = "1.0.78"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07d050484b55975889284352b0ffc2ecbda25c0c55978017c132b29ba0818a86"
+checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199"
 dependencies = [
  "cc",
  "codespan-reporting",
@@ -1898,15 +1898,15 @@
 
 [[package]]
 name = "cxxbridge-flags"
-version = "1.0.79"
+version = "1.0.78"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99d2199b00553eda8012dfec8d3b1c75fce747cf27c169a270b3b99e3448ab78"
+checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c"
 
 [[package]]
 name = "cxxbridge-macro"
-version = "1.0.79"
+version = "1.0.78"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcb67a6de1f602736dd7eaead0080cf3435df806c61b24b13328db128c58868f"
+checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -3561,9 +3561,9 @@
 
 [[package]]
 name = "iana-time-zone-haiku"
-version = "0.1.1"
+version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
+checksum = "fde6edd6cef363e9359ed3c98ba64590ba9eecba2293eb5a723ab32aee8926aa"
 dependencies = [
  "cxx",
  "cxx-build",
@@ -10774,9 +10774,9 @@
 
 [[package]]
 name = "serde_json"
-version = "1.0.87"
+version = "1.0.86"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
+checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074"
 dependencies = [
  "itoa",
  "ryu",
@@ -12055,9 +12055,9 @@
 
 [[package]]
 name = "syn"
-version = "1.0.103"
+version = "1.0.102"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
+checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
 dependencies = [
  "proc-macro2",
  "quote",
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -34,8 +34,8 @@
 use crate::{
 	Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
 	eth::{
-		convert_cross_account_to_uint256, convert_uint256_to_cross_account,
-		convert_cross_account_to_tuple,
+		convert_cross_account_to_uint256, convert_cross_account_to_tuple,
+		convert_tuple_to_cross_account,
 	},
 	weights::WeightInfo,
 };
@@ -139,26 +139,25 @@
 		save(self)
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Set the substrate sponsor of the collection.
-	// ///
-	// /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
-	// ///
-	// /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
-	// fn set_collection_sponsor_substrate(
-	// 	&mut self,
-	// 	caller: caller,
-	// 	sponsor: uint256,
-	// ) -> Result<void> {
-	// 	self.consume_store_reads_and_writes(1, 1)?;
+	/// Set the sponsor of the collection.
+	///
+	/// @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.
+	fn set_collection_sponsor_cross(
+		&mut self,
+		caller: caller,
+		sponsor: (address, uint256),
+	) -> Result<void> {
+		self.consume_store_reads_and_writes(1, 1)?;
 
-	// 	check_is_owner_or_admin(caller, self)?;
+		check_is_owner_or_admin(caller, self)?;
 
-	// 	let sponsor = convert_uint256_to_cross_account::<T>(sponsor);
-	// 	self.set_sponsor(sponsor.as_sub().clone())
-	// 		.map_err(dispatch_to_evm::<T>)?;
-	// 	save(self)
-	// }
+		let sponsor = convert_tuple_to_cross_account::<T>(sponsor)?;
+		self.set_sponsor(sponsor.as_sub().clone())
+			.map_err(dispatch_to_evm::<T>)?;
+		save(self)
+	}
 
 	/// Whether there is a pending sponsor.
 	fn has_collection_pending_sponsor(&self) -> Result<bool> {
@@ -300,37 +299,35 @@
 		Ok(crate::eth::collection_id_to_address(self.id))
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Add collection admin by substrate address.
-	// /// @param newAdmin Substrate administrator address.
-	// fn add_collection_admin_substrate(
-	// 	&mut self,
-	// 	caller: caller,
-	// 	new_admin: uint256,
-	// ) -> Result<void> {
-	// 	self.consume_store_writes(2)?;
+	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	fn add_collection_admin_cross(
+		&mut self,
+		caller: caller,
+		new_admin: (address, uint256),
+	) -> Result<void> {
+		self.consume_store_writes(2)?;
 
-	// 	let caller = T::CrossAccountId::from_eth(caller);
-	// 	let new_admin = convert_uint256_to_cross_account::<T>(new_admin);
-	// 	<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;
-	// 	Ok(())
-	// }
+		let caller = T::CrossAccountId::from_eth(caller);
+		let new_admin = convert_tuple_to_cross_account::<T>(new_admin)?;
+		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Remove collection admin by substrate address.
-	// /// @param admin Substrate administrator address.
-	// fn remove_collection_admin_substrate(
-	// 	&mut self,
-	// 	caller: caller,
-	// 	admin: uint256,
-	// ) -> Result<void> {
-	// 	self.consume_store_writes(2)?;
+	/// Remove collection admin.
+	/// @param admin Cross account administrator address.
+	fn remove_collection_admin_cross(
+		&mut self,
+		caller: caller,
+		admin: (address, uint256),
+	) -> Result<void> {
+		self.consume_store_writes(2)?;
 
-	// 	let caller = T::CrossAccountId::from_eth(caller);
-	// 	let admin = convert_uint256_to_cross_account::<T>(admin);
-	// 	<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
-	// 	Ok(())
-	// }
+		let caller = T::CrossAccountId::from_eth(caller);
+		let admin = convert_tuple_to_cross_account::<T>(admin)?;
+		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
 
 	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
@@ -479,22 +476,21 @@
 		Ok(())
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Add substrate user to allowed list.
-	// ///
-	// /// @param user User substrate address.
-	// fn add_to_collection_allow_list_substrate(
-	// 	&mut self,
-	// 	caller: caller,
-	// 	user: uint256,
-	// ) -> Result<void> {
-	// 	self.consume_store_writes(1)?;
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	fn add_to_collection_allow_list_cross(
+		&mut self,
+		caller: caller,
+		user: (address, uint256),
+	) -> Result<void> {
+		self.consume_store_writes(1)?;
 
-	// 	let caller = T::CrossAccountId::from_eth(caller);
-	// 	let user = convert_uint256_to_cross_account::<T>(user);
-	// 	Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;
-	// 	Ok(())
-	// }
+		let caller = T::CrossAccountId::from_eth(caller);
+		let user = convert_tuple_to_cross_account::<T>(user)?;
+		Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
 
 	/// Remove the user from the allowed list.
 	///
@@ -508,22 +504,21 @@
 		Ok(())
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Remove substrate user from allowed list.
-	// ///
-	// /// @param user User substrate address.
-	// fn remove_from_collection_allow_list_substrate(
-	// 	&mut self,
-	// 	caller: caller,
-	// 	user: uint256,
-	// ) -> Result<void> {
-	// 	self.consume_store_writes(1)?;
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	fn remove_from_collection_allow_list_cross(
+		&mut self,
+		caller: caller,
+		user: (address, uint256),
+	) -> Result<void> {
+		self.consume_store_writes(1)?;
 
-	// 	let caller = T::CrossAccountId::from_eth(caller);
-	// 	let user = convert_uint256_to_cross_account::<T>(user);
-	// 	Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;
-	// 	Ok(())
-	// }
+		let caller = T::CrossAccountId::from_eth(caller);
+		let user = convert_tuple_to_cross_account::<T>(user)?;
+		Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
 
 	/// Switch permission for minting.
 	///
@@ -556,15 +551,14 @@
 		Ok(self.is_owner_or_admin(&user))
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Check that substrate account is the owner or admin of the collection
-	// ///
-	// /// @param user account to verify
-	// /// @return "true" if account is the owner or admin
-	// fn is_owner_or_admin_substrate(&self, user: uint256) -> Result<bool> {
-	// 	let user = convert_uint256_to_cross_account::<T>(user);
-	// 	Ok(self.is_owner_or_admin(&user))
-	// }
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	fn is_owner_or_admin_cross(&self, user: (address, uint256)) -> Result<bool> {
+		let user = convert_tuple_to_cross_account::<T>(user)?;
+		Ok(self.is_owner_or_admin(&user))
+	}
 
 	/// Returns collection type
 	///
@@ -580,7 +574,7 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	fn collection_owner(&self) -> Result<(address, uint256)> {
 		Ok(convert_cross_account_to_tuple::<T>(
@@ -602,20 +596,6 @@
 			.map_err(dispatch_to_evm::<T>)
 	}
 
-	// TODO: Temprorary off. Need refactor
-	// /// Changes collection owner to another substrate account
-	// ///
-	// /// @dev Owner can be changed only by current owner
-	// /// @param newOwner new owner substrate account
-	// fn set_owner_substrate(&mut self, caller: caller, new_owner: uint256) -> Result<void> {
-	// 	self.consume_store_writes(1)?;
-
-	// 	let caller = T::CrossAccountId::from_eth(caller);
-	// 	let new_owner = convert_uint256_to_cross_account::<T>(new_owner);
-	// 	self.set_owner_internal(caller, new_owner)
-	// 		.map_err(dispatch_to_evm::<T>)
-	// }
-
 	/// Get collection administrators
 	///
 	/// @return Vector of tuples with admins address and his substrate mirror.
@@ -626,6 +606,19 @@
 			.collect();
 		Ok(result)
 	}
+
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	fn set_owner_cross(&mut self, caller: caller, new_owner: (address, uint256)) -> Result<void> {
+		self.consume_store_writes(1)?;
+
+		let caller = T::CrossAccountId::from_eth(caller);
+		let new_owner = convert_tuple_to_cross_account::<T>(new_owner)?;
+		self.set_owner_internal(caller, new_owner)
+			.map_err(dispatch_to_evm::<T>)
+	}
 }
 
 /// ### Note
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -85,3 +85,27 @@
 		(eth, Default::default())
 	}
 }
+
+/// Convert tuple `(address, uint256)` to `CrossAccountId`.
+///
+/// If `address` in the tuple has *default* value, then the canonical form is substrate,
+/// if `uint256` has *default* value, then the ethereum form is canonical,
+/// if both values are *default* or *non default*, then this is considered an invalid address and `Error` is returned.
+pub fn convert_tuple_to_cross_account<T: Config>(
+	eth_cross_account_id: (address, uint256),
+) -> evm_coder::execution::Result<T::CrossAccountId>
+where
+	T::AccountId: From<[u8; 32]>,
+{
+	if eth_cross_account_id == Default::default() {
+		Err("All fields of cross account is zeroed".into())
+	} else if eth_cross_account_id.0 == Default::default() {
+		Ok(convert_uint256_to_cross_account::<T>(
+			eth_cross_account_id.1,
+		))
+	} else if eth_cross_account_id.1 == Default::default() {
+		Ok(T::CrossAccountId::from_eth(eth_cross_account_id.0))
+	} else {
+		Err("All fields of cross account is non zeroed".into())
+	}
+}
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -19,6 +19,7 @@
 use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
 use core::convert::TryInto;
 use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
+use pallet_common::eth::convert_tuple_to_cross_account;
 use up_data_structs::CollectionMode;
 use pallet_common::erc::{CommonEvmHandler, PrecompileResult};
 use sp_std::vec::Vec;
@@ -149,7 +150,26 @@
 }
 
 #[solidity_interface(name = ERC20UniqueExtensions)]
-impl<T: Config> FungibleHandle<T> {
+impl<T: Config> FungibleHandle<T>
+where
+	T::AccountId: From<[u8; 32]>,
+{
+	#[weight(<SelfWeightOf<T>>::approve())]
+	fn approve_cross(
+		&mut self,
+		caller: caller,
+		spender: (address, uint256),
+		amount: uint256,
+	) -> Result<bool> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let spender = convert_tuple_to_cross_account::<T>(spender)?;
+		let amount = amount.try_into().map_err(|_| "amount overflow")?;
+
+		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(true)
+	}
+
 	/// Burn tokens from account
 	/// @dev Function that burns an `amount` of the tokens of a given account,
 	/// deducting from the sender's allowance for said account.
@@ -169,6 +189,30 @@
 		Ok(true)
 	}
 
+	/// Burn tokens from account
+	/// @dev Function that burns an `amount` of the tokens of a given account,
+	/// deducting from the sender's allowance for said account.
+	/// @param from The account whose tokens will be burnt.
+	/// @param amount The amount that will be burnt.
+	#[weight(<SelfWeightOf<T>>::burn_from())]
+	fn burn_from_cross(
+		&mut self,
+		caller: caller,
+		from: (address, uint256),
+		amount: uint256,
+	) -> Result<bool> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let amount = amount.try_into().map_err(|_| "amount overflow")?;
+		let budget = self
+			.recorder
+			.weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+		<Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(true)
+	}
+
 	/// Mint tokens for multiple accounts.
 	/// @param amounts array of pairs of account address and amount
 	#[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]
@@ -191,6 +235,27 @@
 			.map_err(dispatch_to_evm::<T>)?;
 		Ok(true)
 	}
+
+	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	fn transfer_from_cross(
+		&mut self,
+		caller: caller,
+		from: (address, uint256),
+		to: (address, uint256),
+		amount: uint256,
+	) -> Result<bool> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let to = convert_tuple_to_cross_account::<T>(to)?;
+		let amount = amount.try_into().map_err(|_| "amount overflow")?;
+		let budget = self
+			.recorder
+			.weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(true)
+	}
 }
 
 #[solidity_interface(
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -18,7 +18,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -72,6 +72,19 @@
 		dummy = 0;
 	}
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) public {
+		require(false, stub_error);
+		sponsor;
+		dummy = 0;
+	}
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -155,6 +168,26 @@
 	}
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  or in textual repr: addCollectionAdminCross((address,uint256))
+	function addCollectionAdminCross(Tuple6 memory newAdmin) public {
+		require(false, stub_error);
+		newAdmin;
+		dummy = 0;
+	}
+
+	/// Remove collection admin.
+	/// @param admin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x6c0cd173,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) public {
+		require(false, stub_error);
+		admin;
+		dummy = 0;
+	}
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -234,6 +267,17 @@
 		dummy = 0;
 	}
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -245,6 +289,17 @@
 		dummy = 0;
 	}
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -269,6 +324,19 @@
 		return false;
 	}
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {
+		require(false, stub_error);
+		user;
+		dummy;
+		return false;
+	}
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -282,7 +350,7 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
@@ -315,10 +383,32 @@
 		dummy;
 		return new Tuple6[](0);
 	}
+
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) public {
+		require(false, stub_error);
+		newOwner;
+		dummy = 0;
+	}
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x63034ac5
+/// @dev the ERC-165 identifier for this interface is 0x032e5926
 contract ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev EVM selector for this function is: 0x0ecd0ab0,
+	///  or in textual repr: approveCross((address,uint256),uint256)
+	function approveCross(Tuple6 memory spender, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		spender;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
 	/// Burn tokens from account
 	/// @dev Function that burns an `amount` of the tokens of a given account,
 	/// deducting from the sender's allowance for said account.
@@ -334,6 +424,21 @@
 		return false;
 	}
 
+	/// Burn tokens from account
+	/// @dev Function that burns an `amount` of the tokens of a given account,
+	/// deducting from the sender's allowance for said account.
+	/// @param from The account whose tokens will be burnt.
+	/// @param amount The amount that will be burnt.
+	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 amount) public returns (bool) {
+		require(false, stub_error);
+		from;
+		amount;
+		dummy = 0;
+		return false;
+	}
+
 	/// Mint tokens for multiple accounts.
 	/// @param amounts array of pairs of account address and amount
 	/// @dev EVM selector for this function is: 0x1acf2d55,
@@ -344,6 +449,21 @@
 		dummy = 0;
 		return false;
 	}
+
+	/// @dev EVM selector for this function is: 0xd5cf430b,
+	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 amount
+	) public returns (bool) {
+		require(false, stub_error);
+		from;
+		to;
+		amount;
+		dummy = 0;
+		return false;
+	}
 }
 
 /// @dev anonymous struct
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -35,6 +35,7 @@
 use pallet_common::{
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
 	CollectionHandle, CollectionPropertyPermissions,
+	eth::convert_tuple_to_cross_account,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
@@ -198,7 +199,10 @@
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 /// @dev See https://eips.ethereum.org/EIPS/eip-721
 #[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
-impl<T: Config> NonfungibleHandle<T> {
+impl<T: Config> NonfungibleHandle<T>
+where
+	T::AccountId: From<[u8; 32]>,
+{
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
 	#[solidity(hide, rename_selector = "name")]
@@ -603,7 +607,10 @@
 
 /// @title Unique extensions for ERC721.
 #[solidity_interface(name = ERC721UniqueExtensions)]
-impl<T: Config> NonfungibleHandle<T> {
+impl<T: Config> NonfungibleHandle<T>
+where
+	T::AccountId: From<[u8; 32]>,
+{
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	fn name(&self) -> Result<string> {
 		Ok(decode_utf16(self.name.iter().copied())
@@ -616,6 +623,28 @@
 		Ok(string::from_utf8_lossy(&self.token_prefix).into())
 	}
 
+	/// @notice Set or reaffirm the approved address for an NFT
+	/// @dev The zero address indicates there is no approved address.
+	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+	///  operator of the current owner.
+	/// @param approved The new substrate address approved NFT controller
+	/// @param tokenId The NFT to approve
+	#[weight(<SelfWeightOf<T>>::approve())]
+	fn approve_cross(
+		&mut self,
+		caller: caller,
+		approved: (address, uint256),
+		token_id: uint256,
+	) -> Result<void> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let approved = convert_tuple_to_cross_account::<T>(approved)?;
+		let token = token_id.try_into()?;
+
+		<Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -634,6 +663,32 @@
 		Ok(())
 	}
 
+	/// @notice Transfer ownership of an NFT from cross account address to cross account address
+	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	///  is the zero address. Throws if `tokenId` is not a valid NFT.
+	/// @param from Cross acccount address of current owner
+	/// @param to Cross acccount address of new owner
+	/// @param tokenId The NFT to transfer
+	#[weight(<SelfWeightOf<T>>::transfer())]
+	fn transfer_from_cross(
+		&mut self,
+		caller: caller,
+		from: (address, uint256),
+		to: (address, uint256),
+		token_id: uint256,
+	) -> Result<void> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let to = convert_tuple_to_cross_account::<T>(to)?;
+		let token_id = token_id.try_into()?;
+		let budget = self
+			.recorder
+			.weight_calls_budget(<StructureWeight<T>>::find_parent());
+		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, &budget)
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
+
 	/// @notice Burns a specific ERC721 token.
 	/// @dev Throws unless `msg.sender` is the current owner or an authorized
 	///  operator for this NFT. Throws if `from` is not the current owner. Throws
@@ -654,6 +709,31 @@
 		Ok(())
 	}
 
+	/// @notice Burns a specific ERC721 token.
+	/// @dev Throws unless `msg.sender` is the current owner or an authorized
+	///  operator for this NFT. Throws if `from` is not the current owner. Throws
+	///  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
+	#[weight(<SelfWeightOf<T>>::burn_from())]
+	fn burn_from_cross(
+		&mut self,
+		caller: caller,
+		from: (address, uint256),
+		token_id: uint256,
+	) -> Result<void> {
+		let caller = T::CrossAccountId::from_eth(caller);
+		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let token = token_id.try_into()?;
+		let budget = self
+			.recorder
+			.weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+		<Pallet<T>>::burn_from(self, &caller, &from, token, &budget)
+			.map_err(dispatch_to_evm::<T>)?;
+		Ok(())
+	}
+
 	/// @notice Returns next free NFT ID.
 	fn next_token_id(&self) -> Result<uint256> {
 		self.consume_store_reads(1)?;
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -91,7 +91,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -145,6 +145,19 @@
 		dummy = 0;
 	}
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) public {
+		require(false, stub_error);
+		sponsor;
+		dummy = 0;
+	}
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -177,10 +190,10 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() public view returns (Tuple17 memory) {
+	function collectionSponsor() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple17(0x0000000000000000000000000000000000000000, 0);
+		return Tuple6(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Set limits for the collection.
@@ -228,6 +241,26 @@
 	}
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  or in textual repr: addCollectionAdminCross((address,uint256))
+	function addCollectionAdminCross(Tuple6 memory newAdmin) public {
+		require(false, stub_error);
+		newAdmin;
+		dummy = 0;
+	}
+
+	/// Remove collection admin.
+	/// @param admin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x6c0cd173,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) public {
+		require(false, stub_error);
+		admin;
+		dummy = 0;
+	}
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -307,6 +340,17 @@
 		dummy = 0;
 	}
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -318,6 +362,17 @@
 		dummy = 0;
 	}
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -342,6 +397,19 @@
 		return false;
 	}
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {
+		require(false, stub_error);
+		user;
+		dummy;
+		return false;
+	}
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -355,14 +423,14 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
-	function collectionOwner() public view returns (Tuple17 memory) {
+	function collectionOwner() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple17(0x0000000000000000000000000000000000000000, 0);
+		return Tuple6(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Changes collection owner to another account
@@ -383,17 +451,23 @@
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0x5813216b,
 	///  or in textual repr: collectionAdmins()
-	function collectionAdmins() public view returns (Tuple17[] memory) {
+	function collectionAdmins() public view returns (Tuple6[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple17[](0);
+		return new Tuple6[](0);
 	}
-}
 
-/// @dev anonymous struct
-struct Tuple17 {
-	address field_0;
-	uint256 field_1;
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) public {
+		require(false, stub_error);
+		newOwner;
+		dummy = 0;
+	}
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
@@ -540,7 +614,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x4468500d
+/// @dev the ERC-165 identifier for this interface is 0x244543ee
 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,
@@ -560,6 +634,21 @@
 		return "";
 	}
 
+	/// @notice Set or reaffirm the approved address for an NFT
+	/// @dev The zero address indicates there is no approved address.
+	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+	///  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,
+	///  or in textual repr: approveCross((address,uint256),uint256)
+	function approveCross(Tuple6 memory approved, uint256 tokenId) public {
+		require(false, stub_error);
+		approved;
+		tokenId;
+		dummy = 0;
+	}
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -574,6 +663,26 @@
 		dummy = 0;
 	}
 
+	/// @notice Transfer ownership of an NFT from cross account address to cross account address
+	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	///  is the zero address. Throws if `tokenId` is not a valid NFT.
+	/// @param from Cross acccount address of current owner
+	/// @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)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 tokenId
+	) public {
+		require(false, stub_error);
+		from;
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
 	/// @notice Burns a specific ERC721 token.
 	/// @dev Throws unless `msg.sender` is the current owner or an authorized
 	///  operator for this NFT. Throws if `from` is not the current owner. Throws
@@ -589,6 +698,21 @@
 		dummy = 0;
 	}
 
+	/// @notice Burns a specific ERC721 token.
+	/// @dev Throws unless `msg.sender` is the current owner or an authorized
+	///  operator for this NFT. Throws if `from` is not the current owner. Throws
+	///  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,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 tokenId) public {
+		require(false, stub_error);
+		from;
+		tokenId;
+		dummy = 0;
+	}
+
 	/// @notice Returns next free NFT ID.
 	/// @dev EVM selector for this function is: 0x75794a3c,
 	///  or in textual repr: nextTokenId()
@@ -619,7 +743,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -630,11 +754,17 @@
 }
 
 /// @dev anonymous struct
-struct Tuple6 {
+struct Tuple8 {
 	uint256 field_0;
 	string field_1;
 }
 
+/// @dev anonymous struct
+struct Tuple6 {
+	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
before · pallets/refungible/src/erc.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//! # Refungible Pallet EVM API for tokens18//!19//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Refungible Pallet.20//! Method implementations are mostly doing parameter conversion and calling Refungible Pallet methods.2122extern crate alloc;2324use core::{25	char::{REPLACEMENT_CHARACTER, decode_utf16},26	convert::TryInto,27};28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};29use frame_support::{BoundedBTreeMap, BoundedVec};30use pallet_common::{31	CollectionHandle, CollectionPropertyPermissions,32	erc::{CommonEvmHandler, CollectionCall, static_property::key},33};34use pallet_evm::{account::CrossAccountId, PrecompileHandle};35use pallet_evm_coder_substrate::{call, dispatch_to_evm};36use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};37use sp_core::H160;38use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};39use up_data_structs::{40	CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,41	PropertyKeyPermission, PropertyPermission, TokenId,42};4344use crate::{45	AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,46	TokenProperties, TokensMinted, TotalSupply, weights::WeightInfo,47};4849pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);5051/// @title A contract that allows to set and delete token properties and change token property permissions.52#[solidity_interface(name = TokenProperties)]53impl<T: Config> RefungibleHandle<T> {54	/// @notice Set permissions for token property.55	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.56	/// @param key Property key.57	/// @param isMutable Permission to mutate property.58	/// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.59	/// @param tokenOwner Permission to mutate property by token owner if property is mutable.60	fn set_token_property_permission(61		&mut self,62		caller: caller,63		key: string,64		is_mutable: bool,65		collection_admin: bool,66		token_owner: bool,67	) -> Result<()> {68		let caller = T::CrossAccountId::from_eth(caller);69		<Pallet<T>>::set_token_property_permissions(70			self,71			&caller,72			vec![PropertyKeyPermission {73				key: <Vec<u8>>::from(key)74					.try_into()75					.map_err(|_| "too long key")?,76				permission: PropertyPermission {77					mutable: is_mutable,78					collection_admin,79					token_owner,80				},81			}],82		)83		.map_err(dispatch_to_evm::<T>)84	}8586	/// @notice Set token property value.87	/// @dev Throws error if `msg.sender` has no permission to edit the property.88	/// @param tokenId ID of the token.89	/// @param key Property key.90	/// @param value Property value.91	fn set_property(92		&mut self,93		caller: caller,94		token_id: uint256,95		key: string,96		value: bytes,97	) -> Result<()> {98		let caller = T::CrossAccountId::from_eth(caller);99		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;100		let key = <Vec<u8>>::from(key)101			.try_into()102			.map_err(|_| "key too long")?;103		let value = value.0.try_into().map_err(|_| "value too long")?;104105		let nesting_budget = self106			.recorder107			.weight_calls_budget(<StructureWeight<T>>::find_parent());108109		<Pallet<T>>::set_token_property(110			self,111			&caller,112			TokenId(token_id),113			Property { key, value },114			&nesting_budget,115		)116		.map_err(dispatch_to_evm::<T>)117	}118119	/// @notice Delete token property value.120	/// @dev Throws error if `msg.sender` has no permission to edit the property.121	/// @param tokenId ID of the token.122	/// @param key Property key.123	fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {124		let caller = T::CrossAccountId::from_eth(caller);125		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;126		let key = <Vec<u8>>::from(key)127			.try_into()128			.map_err(|_| "key too long")?;129130		let nesting_budget = self131			.recorder132			.weight_calls_budget(<StructureWeight<T>>::find_parent());133134		<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)135			.map_err(dispatch_to_evm::<T>)136	}137138	/// @notice Get token property value.139	/// @dev Throws error if key not found140	/// @param tokenId ID of the token.141	/// @param key Property key.142	/// @return Property value bytes143	fn property(&self, token_id: uint256, key: string) -> Result<bytes> {144		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;145		let key = <Vec<u8>>::from(key)146			.try_into()147			.map_err(|_| "key too long")?;148149		let props = <TokenProperties<T>>::get((self.id, token_id));150		let prop = props.get(&key).ok_or("key not found")?;151152		Ok(prop.to_vec().into())153	}154}155156#[derive(ToLog)]157pub enum ERC721Events {158	/// @dev This event emits when NFTs are created (`from` == 0) and destroyed159	///  (`to` == 0). Exception: during contract creation, any number of RFTs160	///  may be created and assigned without emitting Transfer.161	Transfer {162		#[indexed]163		from: address,164		#[indexed]165		to: address,166		#[indexed]167		token_id: uint256,168	},169	/// @dev Not supported170	Approval {171		#[indexed]172		owner: address,173		#[indexed]174		approved: address,175		#[indexed]176		token_id: uint256,177	},178	/// @dev Not supported179	#[allow(dead_code)]180	ApprovalForAll {181		#[indexed]182		owner: address,183		#[indexed]184		operator: address,185		approved: bool,186	},187}188189#[derive(ToLog)]190pub enum ERC721UniqueMintableEvents {191	/// @dev Not supported192	#[allow(dead_code)]193	MintingFinished {},194}195196#[solidity_interface(name = ERC721Metadata)]197impl<T: Config> RefungibleHandle<T> {198	/// @notice A descriptive name for a collection of NFTs in this contract199	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`200	#[solidity(hide, rename_selector = "name")]201	fn name_proxy(&self) -> Result<string> {202		self.name()203	}204205	/// @notice An abbreviated name for NFTs in this contract206	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`207	#[solidity(hide, rename_selector = "symbol")]208	fn symbol_proxy(&self) -> Result<string> {209		self.symbol()210	}211212	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.213	///214	/// @dev If the token has a `url` property and it is not empty, it is returned.215	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.216	///  If the collection property `baseURI` is empty or absent, return "" (empty string)217	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix218	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).219	///220	/// @return token's const_metadata221	#[solidity(rename_selector = "tokenURI")]222	fn token_uri(&self, token_id: uint256) -> Result<string> {223		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;224225		match get_token_property(self, token_id_u32, &key::url()).as_deref() {226			Err(_) | Ok("") => (),227			Ok(url) => {228				return Ok(url.into());229			}230		};231232		let base_uri =233			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())234				.map(BoundedVec::into_inner)235				.map(string::from_utf8)236				.transpose()237				.map_err(|e| {238					Error::Revert(alloc::format!(239						"Can not convert value \"baseURI\" to string with error \"{}\"",240						e241					))242				})?;243244		let base_uri = match base_uri.as_deref() {245			None | Some("") => {246				return Ok("".into());247			}248			Some(base_uri) => base_uri.into(),249		};250251		Ok(252			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {253				Err(_) | Ok("") => base_uri,254				Ok(suffix) => base_uri + suffix,255			},256		)257	}258}259260/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension261/// @dev See https://eips.ethereum.org/EIPS/eip-721262#[solidity_interface(name = ERC721Enumerable)]263impl<T: Config> RefungibleHandle<T> {264	/// @notice Enumerate valid RFTs265	/// @param index A counter less than `totalSupply()`266	/// @return The token identifier for the `index`th NFT,267	///  (sort order not specified)268	fn token_by_index(&self, index: uint256) -> Result<uint256> {269		Ok(index)270	}271272	/// Not implemented273	fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {274		// TODO: Not implemetable275		Err("not implemented".into())276	}277278	/// @notice Count RFTs tracked by this contract279	/// @return A count of valid RFTs tracked by this contract, where each one of280	///  them has an assigned and queryable owner not equal to the zero address281	fn total_supply(&self) -> Result<uint256> {282		self.consume_store_reads(1)?;283		Ok(<Pallet<T>>::total_supply(self).into())284	}285}286287/// @title ERC-721 Non-Fungible Token Standard288/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md289#[solidity_interface(name = ERC721, events(ERC721Events))]290impl<T: Config> RefungibleHandle<T> {291	/// @notice Count all RFTs assigned to an owner292	/// @dev RFTs assigned to the zero address are considered invalid, and this293	///  function throws for queries about the zero address.294	/// @param owner An address for whom to query the balance295	/// @return The number of RFTs owned by `owner`, possibly zero296	fn balance_of(&self, owner: address) -> Result<uint256> {297		self.consume_store_reads(1)?;298		let owner = T::CrossAccountId::from_eth(owner);299		let balance = <AccountBalance<T>>::get((self.id, owner));300		Ok(balance.into())301	}302303	/// @notice Find the owner of an RFT304	/// @dev RFTs assigned to zero address are considered invalid, and queries305	///  about them do throw.306	///  Returns special 0xffffffffffffffffffffffffffffffffffffffff address for307	///  the tokens that are partially owned.308	/// @param tokenId The identifier for an RFT309	/// @return The address of the owner of the RFT310	fn owner_of(&self, token_id: uint256) -> Result<address> {311		self.consume_store_reads(2)?;312		let token = token_id.try_into()?;313		let owner = <Pallet<T>>::token_owner(self.id, token);314		Ok(owner315			.map(|address| *address.as_eth())316			.unwrap_or_else(|| ADDRESS_FOR_PARTIALLY_OWNED_TOKENS))317	}318319	/// @dev Not implemented320	fn safe_transfer_from_with_data(321		&mut self,322		_from: address,323		_to: address,324		_token_id: uint256,325		_data: bytes,326	) -> Result<void> {327		// TODO: Not implemetable328		Err("not implemented".into())329	}330331	/// @dev Not implemented332	fn safe_transfer_from(333		&mut self,334		_from: address,335		_to: address,336		_token_id: uint256,337	) -> Result<void> {338		// TODO: Not implemetable339		Err("not implemented".into())340	}341342	/// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE343	///  TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE344	///  THEY MAY BE PERMANENTLY LOST345	/// @dev Throws unless `msg.sender` is the current owner or an authorized346	///  operator for this RFT. Throws if `from` is not the current owner. Throws347	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.348	///  Throws if RFT pieces have multiple owners.349	/// @param from The current owner of the NFT350	/// @param to The new owner351	/// @param tokenId The NFT to transfer352	#[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]353	fn transfer_from(354		&mut self,355		caller: caller,356		from: address,357		to: address,358		token_id: uint256,359	) -> Result<void> {360		let caller = T::CrossAccountId::from_eth(caller);361		let from = T::CrossAccountId::from_eth(from);362		let to = T::CrossAccountId::from_eth(to);363		let token = token_id.try_into()?;364		let budget = self365			.recorder366			.weight_calls_budget(<StructureWeight<T>>::find_parent());367368		let balance = balance(&self, token, &from)?;369		ensure_single_owner(&self, token, balance)?;370371		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)372			.map_err(dispatch_to_evm::<T>)?;373374		Ok(())375	}376377	/// @dev Not implemented378	fn approve(&mut self, _caller: caller, _approved: address, _token_id: uint256) -> Result<void> {379		Err("not implemented".into())380	}381382	/// @dev Not implemented383	fn set_approval_for_all(384		&mut self,385		_caller: caller,386		_operator: address,387		_approved: bool,388	) -> Result<void> {389		// TODO: Not implemetable390		Err("not implemented".into())391	}392393	/// @dev Not implemented394	fn get_approved(&self, _token_id: uint256) -> Result<address> {395		// TODO: Not implemetable396		Err("not implemented".into())397	}398399	/// @dev Not implemented400	fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {401		// TODO: Not implemetable402		Err("not implemented".into())403	}404}405406/// Returns amount of pieces of `token` that `owner` have407pub fn balance<T: Config>(408	collection: &RefungibleHandle<T>,409	token: TokenId,410	owner: &T::CrossAccountId,411) -> Result<u128> {412	collection.consume_store_reads(1)?;413	let balance = <Balance<T>>::get((collection.id, token, &owner));414	Ok(balance)415}416417/// Throws if `owner_balance` is lower than total amount of `token` pieces418pub fn ensure_single_owner<T: Config>(419	collection: &RefungibleHandle<T>,420	token: TokenId,421	owner_balance: u128,422) -> Result<()> {423	collection.consume_store_reads(1)?;424	let total_supply = <TotalSupply<T>>::get((collection.id, token));425	if total_supply != owner_balance {426		return Err("token has multiple owners".into());427	}428	Ok(())429}430431/// @title ERC721 Token that can be irreversibly burned (destroyed).432#[solidity_interface(name = ERC721Burnable)]433impl<T: Config> RefungibleHandle<T> {434	/// @notice Burns a specific ERC721 token.435	/// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized436	///  operator of the current owner.437	/// @param tokenId The RFT to approve438	#[weight(<SelfWeightOf<T>>::burn_item_fully())]439	fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {440		let caller = T::CrossAccountId::from_eth(caller);441		let token = token_id.try_into()?;442443		let balance = balance(&self, token, &caller)?;444		ensure_single_owner(&self, token, balance)?;445446		<Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;447		Ok(())448	}449}450451/// @title ERC721 minting logic.452#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]453impl<T: Config> RefungibleHandle<T> {454	fn minting_finished(&self) -> Result<bool> {455		Ok(false)456	}457458	/// @notice Function to mint token.459	/// @param to The new owner460	/// @return uint256 The id of the newly minted token461	#[weight(<SelfWeightOf<T>>::create_item())]462	fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {463		let token_id: uint256 = <TokensMinted<T>>::get(self.id)464			.checked_add(1)465			.ok_or("item id overflow")?466			.into();467		self.mint_check_id(caller, to, token_id)?;468		Ok(token_id)469	}470471	/// @notice Function to mint token.472	/// @dev `tokenId` should be obtained with `nextTokenId` method,473	///  unlike standard, you can't specify it manually474	/// @param to The new owner475	/// @param tokenId ID of the minted RFT476	#[solidity(hide, rename_selector = "mint")]477	#[weight(<SelfWeightOf<T>>::create_item())]478	fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {479		let caller = T::CrossAccountId::from_eth(caller);480		let to = T::CrossAccountId::from_eth(to);481		let token_id: u32 = token_id.try_into()?;482		let budget = self483			.recorder484			.weight_calls_budget(<StructureWeight<T>>::find_parent());485486		if <TokensMinted<T>>::get(self.id)487			.checked_add(1)488			.ok_or("item id overflow")?489			!= token_id490		{491			return Err("item id should be next".into());492		}493494		let users = [(to.clone(), 1)]495			.into_iter()496			.collect::<BTreeMap<_, _>>()497			.try_into()498			.unwrap();499		<Pallet<T>>::create_item(500			self,501			&caller,502			CreateItemData::<T::CrossAccountId> {503				users,504				properties: CollectionPropertiesVec::default(),505			},506			&budget,507		)508		.map_err(dispatch_to_evm::<T>)?;509510		Ok(true)511	}512513	/// @notice Function to mint token with the given tokenUri.514	/// @param to The new owner515	/// @param tokenUri Token URI that would be stored in the NFT properties516	/// @return uint256 The id of the newly minted token517	#[solidity(rename_selector = "mintWithTokenURI")]518	#[weight(<SelfWeightOf<T>>::create_item())]519	fn mint_with_token_uri(520		&mut self,521		caller: caller,522		to: address,523		token_uri: string,524	) -> Result<uint256> {525		let token_id: uint256 = <TokensMinted<T>>::get(self.id)526			.checked_add(1)527			.ok_or("item id overflow")?528			.into();529		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;530		Ok(token_id)531	}532533	/// @notice Function to mint token with the given tokenUri.534	/// @dev `tokenId` should be obtained with `nextTokenId` method,535	///  unlike standard, you can't specify it manually536	/// @param to The new owner537	/// @param tokenId ID of the minted RFT538	/// @param tokenUri Token URI that would be stored in the RFT properties539	#[solidity(hide, rename_selector = "mintWithTokenURI")]540	#[weight(<SelfWeightOf<T>>::create_item())]541	fn mint_with_token_uri_check_id(542		&mut self,543		caller: caller,544		to: address,545		token_id: uint256,546		token_uri: string,547	) -> Result<bool> {548		let key = key::url();549		let permission = get_token_permission::<T>(self.id, &key)?;550		if !permission.collection_admin {551			return Err("Operation is not allowed".into());552		}553554		let caller = T::CrossAccountId::from_eth(caller);555		let to = T::CrossAccountId::from_eth(to);556		let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;557		let budget = self558			.recorder559			.weight_calls_budget(<StructureWeight<T>>::find_parent());560561		if <TokensMinted<T>>::get(self.id)562			.checked_add(1)563			.ok_or("item id overflow")?564			!= token_id565		{566			return Err("item id should be next".into());567		}568569		let mut properties = CollectionPropertiesVec::default();570		properties571			.try_push(Property {572				key,573				value: token_uri574					.into_bytes()575					.try_into()576					.map_err(|_| "token uri is too long")?,577			})578			.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;579580		let users = [(to.clone(), 1)]581			.into_iter()582			.collect::<BTreeMap<_, _>>()583			.try_into()584			.unwrap();585		<Pallet<T>>::create_item(586			self,587			&caller,588			CreateItemData::<T::CrossAccountId> { users, properties },589			&budget,590		)591		.map_err(dispatch_to_evm::<T>)?;592		Ok(true)593	}594595	/// @dev Not implemented596	fn finish_minting(&mut self, _caller: caller) -> Result<bool> {597		Err("not implementable".into())598	}599}600601fn get_token_property<T: Config>(602	collection: &CollectionHandle<T>,603	token_id: u32,604	key: &up_data_structs::PropertyKey,605) -> Result<string> {606	collection.consume_store_reads(1)?;607	let properties = <TokenProperties<T>>::try_get((collection.id, token_id))608		.map_err(|_| Error::Revert("Token properties not found".into()))?;609	if let Some(property) = properties.get(key) {610		return Ok(string::from_utf8_lossy(property).into());611	}612613	Err("Property tokenURI not found".into())614}615616fn get_token_permission<T: Config>(617	collection_id: CollectionId,618	key: &PropertyKey,619) -> Result<PropertyPermission> {620	let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)621		.map_err(|_| Error::Revert("No permissions for collection".into()))?;622	let a = token_property_permissions623		.get(key)624		.map(Clone::clone)625		.ok_or_else(|| {626			let key = string::from_utf8(key.clone().into_inner()).unwrap_or_default();627			Error::Revert(alloc::format!("No permission for key {}", key))628		})?;629	Ok(a)630}631632/// @title Unique extensions for ERC721.633#[solidity_interface(name = ERC721UniqueExtensions)]634impl<T: Config> RefungibleHandle<T> {635	/// @notice A descriptive name for a collection of NFTs in this contract636	fn name(&self) -> Result<string> {637		Ok(decode_utf16(self.name.iter().copied())638			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))639			.collect::<string>())640	}641642	/// @notice An abbreviated name for NFTs in this contract643	fn symbol(&self) -> Result<string> {644		Ok(string::from_utf8_lossy(&self.token_prefix).into())645	}646647	/// @notice Transfer ownership of an RFT648	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`649	///  is the zero address. Throws if `tokenId` is not a valid RFT.650	///  Throws if RFT pieces have multiple owners.651	/// @param to The new owner652	/// @param tokenId The RFT to transfer653	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]654	fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result<void> {655		let caller = T::CrossAccountId::from_eth(caller);656		let to = T::CrossAccountId::from_eth(to);657		let token = token_id.try_into()?;658		let budget = self659			.recorder660			.weight_calls_budget(<StructureWeight<T>>::find_parent());661662		let balance = balance(&self, token, &caller)?;663		ensure_single_owner(&self, token, balance)?;664665		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)666			.map_err(dispatch_to_evm::<T>)?;667		Ok(())668	}669670	/// @notice Burns a specific ERC721 token.671	/// @dev Throws unless `msg.sender` is the current owner or an authorized672	///  operator for this RFT. Throws if `from` is not the current owner. Throws673	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.674	///  Throws if RFT pieces have multiple owners.675	/// @param from The current owner of the RFT676	/// @param tokenId The RFT to transfer677	#[weight(<SelfWeightOf<T>>::burn_from())]678	fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {679		let caller = T::CrossAccountId::from_eth(caller);680		let from = T::CrossAccountId::from_eth(from);681		let token = token_id.try_into()?;682		let budget = self683			.recorder684			.weight_calls_budget(<StructureWeight<T>>::find_parent());685686		let balance = balance(&self, token, &caller)?;687		ensure_single_owner(&self, token, balance)?;688689		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)690			.map_err(dispatch_to_evm::<T>)?;691		Ok(())692	}693694	/// @notice Returns next free RFT ID.695	fn next_token_id(&self) -> Result<uint256> {696		self.consume_store_reads(1)?;697		Ok(<TokensMinted<T>>::get(self.id)698			.checked_add(1)699			.ok_or("item id overflow")?700			.into())701	}702703	/// @notice Function to mint multiple tokens.704	/// @dev `tokenIds` should be an array of consecutive numbers and first number705	///  should be obtained with `nextTokenId` method706	/// @param to The new owner707	/// @param tokenIds IDs of the minted RFTs708	#[solidity(hide)]709	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]710	fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {711		let caller = T::CrossAccountId::from_eth(caller);712		let to = T::CrossAccountId::from_eth(to);713		let mut expected_index = <TokensMinted<T>>::get(self.id)714			.checked_add(1)715			.ok_or("item id overflow")?;716		let budget = self717			.recorder718			.weight_calls_budget(<StructureWeight<T>>::find_parent());719720		let total_tokens = token_ids.len();721		for id in token_ids.into_iter() {722			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;723			if id != expected_index {724				return Err("item id should be next".into());725			}726			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;727		}728		let users = [(to.clone(), 1)]729			.into_iter()730			.collect::<BTreeMap<_, _>>()731			.try_into()732			.unwrap();733		let create_item_data = CreateItemData::<T::CrossAccountId> {734			users,735			properties: CollectionPropertiesVec::default(),736		};737		let data = (0..total_tokens)738			.map(|_| create_item_data.clone())739			.collect();740741		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)742			.map_err(dispatch_to_evm::<T>)?;743		Ok(true)744	}745746	/// @notice Function to mint multiple tokens with the given tokenUris.747	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive748	///  numbers and first number should be obtained with `nextTokenId` method749	/// @param to The new owner750	/// @param tokens array of pairs of token ID and token URI for minted tokens751	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]752	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]753	fn mint_bulk_with_token_uri(754		&mut self,755		caller: caller,756		to: address,757		tokens: Vec<(uint256, string)>,758	) -> Result<bool> {759		let key = key::url();760		let caller = T::CrossAccountId::from_eth(caller);761		let to = T::CrossAccountId::from_eth(to);762		let mut expected_index = <TokensMinted<T>>::get(self.id)763			.checked_add(1)764			.ok_or("item id overflow")?;765		let budget = self766			.recorder767			.weight_calls_budget(<StructureWeight<T>>::find_parent());768769		let mut data = Vec::with_capacity(tokens.len());770		let users: BoundedBTreeMap<_, _, _> = [(to.clone(), 1)]771			.into_iter()772			.collect::<BTreeMap<_, _>>()773			.try_into()774			.unwrap();775		for (id, token_uri) in tokens {776			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;777			if id != expected_index {778				return Err("item id should be next".into());779			}780			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;781782			let mut properties = CollectionPropertiesVec::default();783			properties784				.try_push(Property {785					key: key.clone(),786					value: token_uri787						.into_bytes()788						.try_into()789						.map_err(|_| "token uri is too long")?,790				})791				.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;792793			let create_item_data = CreateItemData::<T::CrossAccountId> {794				users: users.clone(),795				properties,796			};797			data.push(create_item_data);798		}799800		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)801			.map_err(dispatch_to_evm::<T>)?;802		Ok(true)803	}804805	/// Returns EVM address for refungible token806	///807	/// @param token ID of the token808	fn token_contract_address(&self, token: uint256) -> Result<address> {809		Ok(T::EvmTokenAddressMapping::token_to_address(810			self.id,811			token.try_into().map_err(|_| "token id overflow")?,812		))813	}814}815816#[solidity_interface(817	name = UniqueRefungible,818	is(819		ERC721,820		ERC721Enumerable,821		ERC721UniqueExtensions,822		ERC721UniqueMintable,823		ERC721Burnable,824		ERC721Metadata(if(this.flags.erc721metadata)),825		Collection(via(common_mut returns CollectionHandle<T>)),826		TokenProperties,827	)828)]829impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}830831// Not a tests, but code generators832generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);833generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);834835impl<T: Config> CommonEvmHandler for RefungibleHandle<T>836where837	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,838{839	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");840	fn call(841		self,842		handle: &mut impl PrecompileHandle,843	) -> Option<pallet_common::erc::PrecompileResult> {844		call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)845	}846}
after · pallets/refungible/src/erc.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//! # Refungible Pallet EVM API for tokens18//!19//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Refungible Pallet.20//! Method implementations are mostly doing parameter conversion and calling Refungible Pallet methods.2122extern crate alloc;2324use core::{25	char::{REPLACEMENT_CHARACTER, decode_utf16},26	convert::TryInto,27};28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};29use frame_support::{BoundedBTreeMap, BoundedVec};30use pallet_common::{31	CollectionHandle, CollectionPropertyPermissions,32	erc::{CommonEvmHandler, CollectionCall, static_property::key},33	eth::convert_tuple_to_cross_account,34};35use pallet_evm::{account::CrossAccountId, PrecompileHandle};36use pallet_evm_coder_substrate::{call, dispatch_to_evm};37use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};38use sp_core::H160;39use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};40use up_data_structs::{41	CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,42	PropertyKeyPermission, PropertyPermission, TokenId,43};4445use crate::{46	AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,47	TokenProperties, TokensMinted, TotalSupply, weights::WeightInfo,48};4950pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);5152/// @title A contract that allows to set and delete token properties and change token property permissions.53#[solidity_interface(name = TokenProperties)]54impl<T: Config> RefungibleHandle<T> {55	/// @notice Set permissions for token property.56	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.57	/// @param key Property key.58	/// @param isMutable Permission to mutate property.59	/// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.60	/// @param tokenOwner Permission to mutate property by token owner if property is mutable.61	fn set_token_property_permission(62		&mut self,63		caller: caller,64		key: string,65		is_mutable: bool,66		collection_admin: bool,67		token_owner: bool,68	) -> Result<()> {69		let caller = T::CrossAccountId::from_eth(caller);70		<Pallet<T>>::set_token_property_permissions(71			self,72			&caller,73			vec![PropertyKeyPermission {74				key: <Vec<u8>>::from(key)75					.try_into()76					.map_err(|_| "too long key")?,77				permission: PropertyPermission {78					mutable: is_mutable,79					collection_admin,80					token_owner,81				},82			}],83		)84		.map_err(dispatch_to_evm::<T>)85	}8687	/// @notice Set token property value.88	/// @dev Throws error if `msg.sender` has no permission to edit the property.89	/// @param tokenId ID of the token.90	/// @param key Property key.91	/// @param value Property value.92	fn set_property(93		&mut self,94		caller: caller,95		token_id: uint256,96		key: string,97		value: bytes,98	) -> Result<()> {99		let caller = T::CrossAccountId::from_eth(caller);100		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;101		let key = <Vec<u8>>::from(key)102			.try_into()103			.map_err(|_| "key too long")?;104		let value = value.0.try_into().map_err(|_| "value too long")?;105106		let nesting_budget = self107			.recorder108			.weight_calls_budget(<StructureWeight<T>>::find_parent());109110		<Pallet<T>>::set_token_property(111			self,112			&caller,113			TokenId(token_id),114			Property { key, value },115			&nesting_budget,116		)117		.map_err(dispatch_to_evm::<T>)118	}119120	/// @notice Delete token property value.121	/// @dev Throws error if `msg.sender` has no permission to edit the property.122	/// @param tokenId ID of the token.123	/// @param key Property key.124	fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {125		let caller = T::CrossAccountId::from_eth(caller);126		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;127		let key = <Vec<u8>>::from(key)128			.try_into()129			.map_err(|_| "key too long")?;130131		let nesting_budget = self132			.recorder133			.weight_calls_budget(<StructureWeight<T>>::find_parent());134135		<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)136			.map_err(dispatch_to_evm::<T>)137	}138139	/// @notice Get token property value.140	/// @dev Throws error if key not found141	/// @param tokenId ID of the token.142	/// @param key Property key.143	/// @return Property value bytes144	fn property(&self, token_id: uint256, key: string) -> Result<bytes> {145		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;146		let key = <Vec<u8>>::from(key)147			.try_into()148			.map_err(|_| "key too long")?;149150		let props = <TokenProperties<T>>::get((self.id, token_id));151		let prop = props.get(&key).ok_or("key not found")?;152153		Ok(prop.to_vec().into())154	}155}156157#[derive(ToLog)]158pub enum ERC721Events {159	/// @dev This event emits when NFTs are created (`from` == 0) and destroyed160	///  (`to` == 0). Exception: during contract creation, any number of RFTs161	///  may be created and assigned without emitting Transfer.162	Transfer {163		#[indexed]164		from: address,165		#[indexed]166		to: address,167		#[indexed]168		token_id: uint256,169	},170	/// @dev Not supported171	Approval {172		#[indexed]173		owner: address,174		#[indexed]175		approved: address,176		#[indexed]177		token_id: uint256,178	},179	/// @dev Not supported180	#[allow(dead_code)]181	ApprovalForAll {182		#[indexed]183		owner: address,184		#[indexed]185		operator: address,186		approved: bool,187	},188}189190#[derive(ToLog)]191pub enum ERC721UniqueMintableEvents {192	/// @dev Not supported193	#[allow(dead_code)]194	MintingFinished {},195}196197#[solidity_interface(name = ERC721Metadata)]198impl<T: Config> RefungibleHandle<T>199where200	T::AccountId: From<[u8; 32]>,201{202	/// @notice A descriptive name for a collection of NFTs in this contract203	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`204	#[solidity(hide, rename_selector = "name")]205	fn name_proxy(&self) -> Result<string> {206		self.name()207	}208209	/// @notice An abbreviated name for NFTs in this contract210	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`211	#[solidity(hide, rename_selector = "symbol")]212	fn symbol_proxy(&self) -> Result<string> {213		self.symbol()214	}215216	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.217	///218	/// @dev If the token has a `url` property and it is not empty, it is returned.219	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.220	///  If the collection property `baseURI` is empty or absent, return "" (empty string)221	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix222	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).223	///224	/// @return token's const_metadata225	#[solidity(rename_selector = "tokenURI")]226	fn token_uri(&self, token_id: uint256) -> Result<string> {227		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;228229		match get_token_property(self, token_id_u32, &key::url()).as_deref() {230			Err(_) | Ok("") => (),231			Ok(url) => {232				return Ok(url.into());233			}234		};235236		let base_uri =237			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())238				.map(BoundedVec::into_inner)239				.map(string::from_utf8)240				.transpose()241				.map_err(|e| {242					Error::Revert(alloc::format!(243						"Can not convert value \"baseURI\" to string with error \"{}\"",244						e245					))246				})?;247248		let base_uri = match base_uri.as_deref() {249			None | Some("") => {250				return Ok("".into());251			}252			Some(base_uri) => base_uri.into(),253		};254255		Ok(256			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {257				Err(_) | Ok("") => base_uri,258				Ok(suffix) => base_uri + suffix,259			},260		)261	}262}263264/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension265/// @dev See https://eips.ethereum.org/EIPS/eip-721266#[solidity_interface(name = ERC721Enumerable)]267impl<T: Config> RefungibleHandle<T> {268	/// @notice Enumerate valid RFTs269	/// @param index A counter less than `totalSupply()`270	/// @return The token identifier for the `index`th NFT,271	///  (sort order not specified)272	fn token_by_index(&self, index: uint256) -> Result<uint256> {273		Ok(index)274	}275276	/// Not implemented277	fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {278		// TODO: Not implemetable279		Err("not implemented".into())280	}281282	/// @notice Count RFTs tracked by this contract283	/// @return A count of valid RFTs tracked by this contract, where each one of284	///  them has an assigned and queryable owner not equal to the zero address285	fn total_supply(&self) -> Result<uint256> {286		self.consume_store_reads(1)?;287		Ok(<Pallet<T>>::total_supply(self).into())288	}289}290291/// @title ERC-721 Non-Fungible Token Standard292/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md293#[solidity_interface(name = ERC721, events(ERC721Events))]294impl<T: Config> RefungibleHandle<T> {295	/// @notice Count all RFTs assigned to an owner296	/// @dev RFTs assigned to the zero address are considered invalid, and this297	///  function throws for queries about the zero address.298	/// @param owner An address for whom to query the balance299	/// @return The number of RFTs owned by `owner`, possibly zero300	fn balance_of(&self, owner: address) -> Result<uint256> {301		self.consume_store_reads(1)?;302		let owner = T::CrossAccountId::from_eth(owner);303		let balance = <AccountBalance<T>>::get((self.id, owner));304		Ok(balance.into())305	}306307	/// @notice Find the owner of an RFT308	/// @dev RFTs assigned to zero address are considered invalid, and queries309	///  about them do throw.310	///  Returns special 0xffffffffffffffffffffffffffffffffffffffff address for311	///  the tokens that are partially owned.312	/// @param tokenId The identifier for an RFT313	/// @return The address of the owner of the RFT314	fn owner_of(&self, token_id: uint256) -> Result<address> {315		self.consume_store_reads(2)?;316		let token = token_id.try_into()?;317		let owner = <Pallet<T>>::token_owner(self.id, token);318		Ok(owner319			.map(|address| *address.as_eth())320			.unwrap_or_else(|| ADDRESS_FOR_PARTIALLY_OWNED_TOKENS))321	}322323	/// @dev Not implemented324	fn safe_transfer_from_with_data(325		&mut self,326		_from: address,327		_to: address,328		_token_id: uint256,329		_data: bytes,330	) -> Result<void> {331		// TODO: Not implemetable332		Err("not implemented".into())333	}334335	/// @dev Not implemented336	fn safe_transfer_from(337		&mut self,338		_from: address,339		_to: address,340		_token_id: uint256,341	) -> Result<void> {342		// TODO: Not implemetable343		Err("not implemented".into())344	}345346	/// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE347	///  TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE348	///  THEY MAY BE PERMANENTLY LOST349	/// @dev Throws unless `msg.sender` is the current owner or an authorized350	///  operator for this RFT. Throws if `from` is not the current owner. Throws351	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.352	///  Throws if RFT pieces have multiple owners.353	/// @param from The current owner of the NFT354	/// @param to The new owner355	/// @param tokenId The NFT to transfer356	#[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]357	fn transfer_from(358		&mut self,359		caller: caller,360		from: address,361		to: address,362		token_id: uint256,363	) -> Result<void> {364		let caller = T::CrossAccountId::from_eth(caller);365		let from = T::CrossAccountId::from_eth(from);366		let to = T::CrossAccountId::from_eth(to);367		let token = token_id.try_into()?;368		let budget = self369			.recorder370			.weight_calls_budget(<StructureWeight<T>>::find_parent());371372		let balance = balance(&self, token, &from)?;373		ensure_single_owner(&self, token, balance)?;374375		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)376			.map_err(dispatch_to_evm::<T>)?;377378		Ok(())379	}380381	/// @dev Not implemented382	fn approve(&mut self, _caller: caller, _approved: address, _token_id: uint256) -> Result<void> {383		Err("not implemented".into())384	}385386	/// @dev Not implemented387	fn set_approval_for_all(388		&mut self,389		_caller: caller,390		_operator: address,391		_approved: bool,392	) -> Result<void> {393		// TODO: Not implemetable394		Err("not implemented".into())395	}396397	/// @dev Not implemented398	fn get_approved(&self, _token_id: uint256) -> Result<address> {399		// TODO: Not implemetable400		Err("not implemented".into())401	}402403	/// @dev Not implemented404	fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {405		// TODO: Not implemetable406		Err("not implemented".into())407	}408}409410/// Returns amount of pieces of `token` that `owner` have411pub fn balance<T: Config>(412	collection: &RefungibleHandle<T>,413	token: TokenId,414	owner: &T::CrossAccountId,415) -> Result<u128> {416	collection.consume_store_reads(1)?;417	let balance = <Balance<T>>::get((collection.id, token, &owner));418	Ok(balance)419}420421/// Throws if `owner_balance` is lower than total amount of `token` pieces422pub fn ensure_single_owner<T: Config>(423	collection: &RefungibleHandle<T>,424	token: TokenId,425	owner_balance: u128,426) -> Result<()> {427	collection.consume_store_reads(1)?;428	let total_supply = <TotalSupply<T>>::get((collection.id, token));429	if total_supply != owner_balance {430		return Err("token has multiple owners".into());431	}432	Ok(())433}434435/// @title ERC721 Token that can be irreversibly burned (destroyed).436#[solidity_interface(name = ERC721Burnable)]437impl<T: Config> RefungibleHandle<T> {438	/// @notice Burns a specific ERC721 token.439	/// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized440	///  operator of the current owner.441	/// @param tokenId The RFT to approve442	#[weight(<SelfWeightOf<T>>::burn_item_fully())]443	fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {444		let caller = T::CrossAccountId::from_eth(caller);445		let token = token_id.try_into()?;446447		let balance = balance(&self, token, &caller)?;448		ensure_single_owner(&self, token, balance)?;449450		<Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;451		Ok(())452	}453}454455/// @title ERC721 minting logic.456#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]457impl<T: Config> RefungibleHandle<T> {458	fn minting_finished(&self) -> Result<bool> {459		Ok(false)460	}461462	/// @notice Function to mint token.463	/// @param to The new owner464	/// @return uint256 The id of the newly minted token465	#[weight(<SelfWeightOf<T>>::create_item())]466	fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {467		let token_id: uint256 = <TokensMinted<T>>::get(self.id)468			.checked_add(1)469			.ok_or("item id overflow")?470			.into();471		self.mint_check_id(caller, to, token_id)?;472		Ok(token_id)473	}474475	/// @notice Function to mint token.476	/// @dev `tokenId` should be obtained with `nextTokenId` method,477	///  unlike standard, you can't specify it manually478	/// @param to The new owner479	/// @param tokenId ID of the minted RFT480	#[solidity(hide, rename_selector = "mint")]481	#[weight(<SelfWeightOf<T>>::create_item())]482	fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {483		let caller = T::CrossAccountId::from_eth(caller);484		let to = T::CrossAccountId::from_eth(to);485		let token_id: u32 = token_id.try_into()?;486		let budget = self487			.recorder488			.weight_calls_budget(<StructureWeight<T>>::find_parent());489490		if <TokensMinted<T>>::get(self.id)491			.checked_add(1)492			.ok_or("item id overflow")?493			!= token_id494		{495			return Err("item id should be next".into());496		}497498		let users = [(to.clone(), 1)]499			.into_iter()500			.collect::<BTreeMap<_, _>>()501			.try_into()502			.unwrap();503		<Pallet<T>>::create_item(504			self,505			&caller,506			CreateItemData::<T::CrossAccountId> {507				users,508				properties: CollectionPropertiesVec::default(),509			},510			&budget,511		)512		.map_err(dispatch_to_evm::<T>)?;513514		Ok(true)515	}516517	/// @notice Function to mint token with the given tokenUri.518	/// @param to The new owner519	/// @param tokenUri Token URI that would be stored in the NFT properties520	/// @return uint256 The id of the newly minted token521	#[solidity(rename_selector = "mintWithTokenURI")]522	#[weight(<SelfWeightOf<T>>::create_item())]523	fn mint_with_token_uri(524		&mut self,525		caller: caller,526		to: address,527		token_uri: string,528	) -> Result<uint256> {529		let token_id: uint256 = <TokensMinted<T>>::get(self.id)530			.checked_add(1)531			.ok_or("item id overflow")?532			.into();533		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;534		Ok(token_id)535	}536537	/// @notice Function to mint token with the given tokenUri.538	/// @dev `tokenId` should be obtained with `nextTokenId` method,539	///  unlike standard, you can't specify it manually540	/// @param to The new owner541	/// @param tokenId ID of the minted RFT542	/// @param tokenUri Token URI that would be stored in the RFT properties543	#[solidity(hide, rename_selector = "mintWithTokenURI")]544	#[weight(<SelfWeightOf<T>>::create_item())]545	fn mint_with_token_uri_check_id(546		&mut self,547		caller: caller,548		to: address,549		token_id: uint256,550		token_uri: string,551	) -> Result<bool> {552		let key = key::url();553		let permission = get_token_permission::<T>(self.id, &key)?;554		if !permission.collection_admin {555			return Err("Operation is not allowed".into());556		}557558		let caller = T::CrossAccountId::from_eth(caller);559		let to = T::CrossAccountId::from_eth(to);560		let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;561		let budget = self562			.recorder563			.weight_calls_budget(<StructureWeight<T>>::find_parent());564565		if <TokensMinted<T>>::get(self.id)566			.checked_add(1)567			.ok_or("item id overflow")?568			!= token_id569		{570			return Err("item id should be next".into());571		}572573		let mut properties = CollectionPropertiesVec::default();574		properties575			.try_push(Property {576				key,577				value: token_uri578					.into_bytes()579					.try_into()580					.map_err(|_| "token uri is too long")?,581			})582			.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;583584		let users = [(to.clone(), 1)]585			.into_iter()586			.collect::<BTreeMap<_, _>>()587			.try_into()588			.unwrap();589		<Pallet<T>>::create_item(590			self,591			&caller,592			CreateItemData::<T::CrossAccountId> { users, properties },593			&budget,594		)595		.map_err(dispatch_to_evm::<T>)?;596		Ok(true)597	}598599	/// @dev Not implemented600	fn finish_minting(&mut self, _caller: caller) -> Result<bool> {601		Err("not implementable".into())602	}603}604605fn get_token_property<T: Config>(606	collection: &CollectionHandle<T>,607	token_id: u32,608	key: &up_data_structs::PropertyKey,609) -> Result<string> {610	collection.consume_store_reads(1)?;611	let properties = <TokenProperties<T>>::try_get((collection.id, token_id))612		.map_err(|_| Error::Revert("Token properties not found".into()))?;613	if let Some(property) = properties.get(key) {614		return Ok(string::from_utf8_lossy(property).into());615	}616617	Err("Property tokenURI not found".into())618}619620fn get_token_permission<T: Config>(621	collection_id: CollectionId,622	key: &PropertyKey,623) -> Result<PropertyPermission> {624	let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)625		.map_err(|_| Error::Revert("No permissions for collection".into()))?;626	let a = token_property_permissions627		.get(key)628		.map(Clone::clone)629		.ok_or_else(|| {630			let key = string::from_utf8(key.clone().into_inner()).unwrap_or_default();631			Error::Revert(alloc::format!("No permission for key {}", key))632		})?;633	Ok(a)634}635636/// @title Unique extensions for ERC721.637#[solidity_interface(name = ERC721UniqueExtensions)]638impl<T: Config> RefungibleHandle<T>639where640	T::AccountId: From<[u8; 32]>,641{642	/// @notice A descriptive name for a collection of NFTs in this contract643	fn name(&self) -> Result<string> {644		Ok(decode_utf16(self.name.iter().copied())645			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))646			.collect::<string>())647	}648649	/// @notice An abbreviated name for NFTs in this contract650	fn symbol(&self) -> Result<string> {651		Ok(string::from_utf8_lossy(&self.token_prefix).into())652	}653654	/// @notice Transfer ownership of an RFT655	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`656	///  is the zero address. Throws if `tokenId` is not a valid RFT.657	///  Throws if RFT pieces have multiple owners.658	/// @param to The new owner659	/// @param tokenId The RFT to transfer660	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]661	fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result<void> {662		let caller = T::CrossAccountId::from_eth(caller);663		let to = T::CrossAccountId::from_eth(to);664		let token = token_id.try_into()?;665		let budget = self666			.recorder667			.weight_calls_budget(<StructureWeight<T>>::find_parent());668669		let balance = balance(self, token, &caller)?;670		ensure_single_owner(self, token, balance)?;671672		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)673			.map_err(dispatch_to_evm::<T>)?;674		Ok(())675	}676677	/// @notice Transfer ownership of an RFT678	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`679	///  is the zero address. Throws if `tokenId` is not a valid RFT.680	///  Throws if RFT pieces have multiple owners.681	/// @param to The new owner682	/// @param tokenId The RFT to transfer683	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]684	fn transfer_from_cross(685		&mut self,686		caller: caller,687		from: (address, uint256),688		to: (address, uint256),689		token_id: uint256,690	) -> Result<void> {691		let caller = T::CrossAccountId::from_eth(caller);692		let from = convert_tuple_to_cross_account::<T>(from)?;693		let to = convert_tuple_to_cross_account::<T>(to)?;694		let token_id = token_id.try_into()?;695		let budget = self696			.recorder697			.weight_calls_budget(<StructureWeight<T>>::find_parent());698699		let balance = balance(self, token_id, &from)?;700		ensure_single_owner(self, token_id, balance)?;701702		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)703			.map_err(dispatch_to_evm::<T>)?;704		Ok(())705	}706707	/// @notice Burns a specific ERC721 token.708	/// @dev Throws unless `msg.sender` is the current owner or an authorized709	///  operator for this RFT. Throws if `from` is not the current owner. Throws710	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.711	///  Throws if RFT pieces have multiple owners.712	/// @param from The current owner of the RFT713	/// @param tokenId The RFT to transfer714	#[weight(<SelfWeightOf<T>>::burn_from())]715	fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {716		let caller = T::CrossAccountId::from_eth(caller);717		let from = T::CrossAccountId::from_eth(from);718		let token = token_id.try_into()?;719		let budget = self720			.recorder721			.weight_calls_budget(<StructureWeight<T>>::find_parent());722723		let balance = balance(self, token, &from)?;724		ensure_single_owner(self, token, balance)?;725726		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)727			.map_err(dispatch_to_evm::<T>)?;728		Ok(())729	}730731	/// @notice Burns a specific ERC721 token.732	/// @dev Throws unless `msg.sender` is the current owner or an authorized733	///  operator for this RFT. Throws if `from` is not the current owner. Throws734	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.735	///  Throws if RFT pieces have multiple owners.736	/// @param from The current owner of the RFT737	/// @param tokenId The RFT to transfer738	#[weight(<SelfWeightOf<T>>::burn_from())]739	fn burn_from_cross(740		&mut self,741		caller: caller,742		from: (address, uint256),743		token_id: uint256,744	) -> Result<void> {745		let caller = T::CrossAccountId::from_eth(caller);746		let from = convert_tuple_to_cross_account::<T>(from)?;747		let token = token_id.try_into()?;748		let budget = self749			.recorder750			.weight_calls_budget(<StructureWeight<T>>::find_parent());751752		let balance = balance(self, token, &from)?;753		ensure_single_owner(self, token, balance)?;754755		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)756			.map_err(dispatch_to_evm::<T>)?;757		Ok(())758	}759760	/// @notice Returns next free RFT ID.761	fn next_token_id(&self) -> Result<uint256> {762		self.consume_store_reads(1)?;763		Ok(<TokensMinted<T>>::get(self.id)764			.checked_add(1)765			.ok_or("item id overflow")?766			.into())767	}768769	/// @notice Function to mint multiple tokens.770	/// @dev `tokenIds` should be an array of consecutive numbers and first number771	///  should be obtained with `nextTokenId` method772	/// @param to The new owner773	/// @param tokenIds IDs of the minted RFTs774	#[solidity(hide)]775	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]776	fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {777		let caller = T::CrossAccountId::from_eth(caller);778		let to = T::CrossAccountId::from_eth(to);779		let mut expected_index = <TokensMinted<T>>::get(self.id)780			.checked_add(1)781			.ok_or("item id overflow")?;782		let budget = self783			.recorder784			.weight_calls_budget(<StructureWeight<T>>::find_parent());785786		let total_tokens = token_ids.len();787		for id in token_ids.into_iter() {788			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;789			if id != expected_index {790				return Err("item id should be next".into());791			}792			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;793		}794		let users = [(to.clone(), 1)]795			.into_iter()796			.collect::<BTreeMap<_, _>>()797			.try_into()798			.unwrap();799		let create_item_data = CreateItemData::<T::CrossAccountId> {800			users,801			properties: CollectionPropertiesVec::default(),802		};803		let data = (0..total_tokens)804			.map(|_| create_item_data.clone())805			.collect();806807		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)808			.map_err(dispatch_to_evm::<T>)?;809		Ok(true)810	}811812	/// @notice Function to mint multiple tokens with the given tokenUris.813	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive814	///  numbers and first number should be obtained with `nextTokenId` method815	/// @param to The new owner816	/// @param tokens array of pairs of token ID and token URI for minted tokens817	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]818	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]819	fn mint_bulk_with_token_uri(820		&mut self,821		caller: caller,822		to: address,823		tokens: Vec<(uint256, string)>,824	) -> Result<bool> {825		let key = key::url();826		let caller = T::CrossAccountId::from_eth(caller);827		let to = T::CrossAccountId::from_eth(to);828		let mut expected_index = <TokensMinted<T>>::get(self.id)829			.checked_add(1)830			.ok_or("item id overflow")?;831		let budget = self832			.recorder833			.weight_calls_budget(<StructureWeight<T>>::find_parent());834835		let mut data = Vec::with_capacity(tokens.len());836		let users: BoundedBTreeMap<_, _, _> = [(to.clone(), 1)]837			.into_iter()838			.collect::<BTreeMap<_, _>>()839			.try_into()840			.unwrap();841		for (id, token_uri) in tokens {842			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;843			if id != expected_index {844				return Err("item id should be next".into());845			}846			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;847848			let mut properties = CollectionPropertiesVec::default();849			properties850				.try_push(Property {851					key: key.clone(),852					value: token_uri853						.into_bytes()854						.try_into()855						.map_err(|_| "token uri is too long")?,856				})857				.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;858859			let create_item_data = CreateItemData::<T::CrossAccountId> {860				users: users.clone(),861				properties,862			};863			data.push(create_item_data);864		}865866		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)867			.map_err(dispatch_to_evm::<T>)?;868		Ok(true)869	}870871	/// Returns EVM address for refungible token872	///873	/// @param token ID of the token874	fn token_contract_address(&self, token: uint256) -> Result<address> {875		Ok(T::EvmTokenAddressMapping::token_to_address(876			self.id,877			token.try_into().map_err(|_| "token id overflow")?,878		))879	}880}881882#[solidity_interface(883	name = UniqueRefungible,884	is(885		ERC721,886		ERC721Enumerable,887		ERC721UniqueExtensions,888		ERC721UniqueMintable,889		ERC721Burnable,890		ERC721Metadata(if(this.flags.erc721metadata)),891		Collection(via(common_mut returns CollectionHandle<T>)),892		TokenProperties,893	)894)]895impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}896897// Not a tests, but code generators898generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);899generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);900901impl<T: Config> CommonEvmHandler for RefungibleHandle<T>902where903	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,904{905	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");906	fn call(907		self,908		handle: &mut impl PrecompileHandle,909	) -> Option<pallet_common::erc::PrecompileResult> {910		call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)911	}912}
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -91,7 +91,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 contract Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -145,6 +145,19 @@
 		dummy = 0;
 	}
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) public {
+		require(false, stub_error);
+		sponsor;
+		dummy = 0;
+	}
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -177,10 +190,10 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() public view returns (Tuple17 memory) {
+	function collectionSponsor() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple17(0x0000000000000000000000000000000000000000, 0);
+		return Tuple6(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Set limits for the collection.
@@ -228,6 +241,26 @@
 	}
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  or in textual repr: addCollectionAdminCross((address,uint256))
+	function addCollectionAdminCross(Tuple6 memory newAdmin) public {
+		require(false, stub_error);
+		newAdmin;
+		dummy = 0;
+	}
+
+	/// Remove collection admin.
+	/// @param admin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x6c0cd173,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) public {
+		require(false, stub_error);
+		admin;
+		dummy = 0;
+	}
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -307,6 +340,17 @@
 		dummy = 0;
 	}
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -318,6 +362,17 @@
 		dummy = 0;
 	}
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) public {
+		require(false, stub_error);
+		user;
+		dummy = 0;
+	}
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -342,6 +397,19 @@
 		return false;
 	}
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) public view returns (bool) {
+		require(false, stub_error);
+		user;
+		dummy;
+		return false;
+	}
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -355,14 +423,14 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
-	function collectionOwner() public view returns (Tuple17 memory) {
+	function collectionOwner() public view returns (Tuple6 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple17(0x0000000000000000000000000000000000000000, 0);
+		return Tuple6(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Changes collection owner to another account
@@ -383,17 +451,23 @@
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0x5813216b,
 	///  or in textual repr: collectionAdmins()
-	function collectionAdmins() public view returns (Tuple17[] memory) {
+	function collectionAdmins() public view returns (Tuple6[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple17[](0);
+		return new Tuple6[](0);
 	}
-}
 
-/// @dev anonymous struct
-struct Tuple17 {
-	address field_0;
-	uint256 field_1;
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) public {
+		require(false, stub_error);
+		newOwner;
+		dummy = 0;
+	}
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -538,7 +612,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xef1eaacb
+/// @dev the ERC-165 identifier for this interface is 0x81feb398
 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,
@@ -573,6 +647,26 @@
 		dummy = 0;
 	}
 
+	/// @notice Transfer ownership of an RFT
+	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	///  is the zero address. Throws if `tokenId` is not a valid RFT.
+	///  Throws if RFT pieces have multiple owners.
+	/// @param to The new owner
+	/// @param tokenId The RFT to transfer
+	/// @dev EVM selector for this function is: 0xd5cf430b,
+	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 tokenId
+	) public {
+		require(false, stub_error);
+		from;
+		to;
+		tokenId;
+		dummy = 0;
+	}
+
 	/// @notice Burns a specific ERC721 token.
 	/// @dev Throws unless `msg.sender` is the current owner or an authorized
 	///  operator for this RFT. Throws if `from` is not the current owner. Throws
@@ -589,6 +683,22 @@
 		dummy = 0;
 	}
 
+	/// @notice Burns a specific ERC721 token.
+	/// @dev Throws unless `msg.sender` is the current owner or an authorized
+	///  operator for this RFT. Throws if `from` is not the current owner. Throws
+	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+	///  Throws if RFT pieces have multiple owners.
+	/// @param from The current owner of the RFT
+	/// @param tokenId The RFT to transfer
+	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 tokenId) public {
+		require(false, stub_error);
+		from;
+		tokenId;
+		dummy = 0;
+	}
+
 	/// @notice Returns next free RFT ID.
 	/// @dev EVM selector for this function is: 0x75794a3c,
 	///  or in textual repr: nextTokenId()
@@ -620,7 +730,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -642,11 +752,17 @@
 }
 
 /// @dev anonymous struct
-struct Tuple6 {
+struct Tuple8 {
 	uint256 field_0;
 	string field_1;
 }
 
+/// @dev anonymous struct
+struct Tuple6 {
+	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/allowlist.test.tsdiffbeforeafterboth
--- a/tests/src/eth/allowlist.test.ts
+++ b/tests/src/eth/allowlist.test.ts
@@ -89,22 +89,22 @@
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
   });
 
-  // TODO: Temprorary off. Need refactor
-  // itEth('Collection allowlist can be added and removed by [sub] address', async ({helper}) => {
-  //   const owner = await helper.eth.createAccountWithBalance(donor);
-  //   const user = donor;
-
-  //   const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
-  //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
-  //   await collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).send({from: owner});
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
+  //itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {
+  //  const owner = await helper.eth.createAccountWithBalance(donor);
+  //  const user = donor;
+  //  
+  //  const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+  //  const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+  //  const userCross = helper.ethCrossAccount.fromKeyringPair(user);
+  //  
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
+  //  await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
+  //  
+  //  await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
+  //});
 
-  //   await collectionEvm.methods.removeFromCollectionAllowListSubstrate(user.addressRaw).send({from: owner});
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
-  // });
-
   itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const notOwner = await helper.eth.createAccountWithBalance(donor);
@@ -117,28 +117,27 @@
     await expect(collectionEvm.methods.addToCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
     await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});
-
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;
     await expect(collectionEvm.methods.removeFromCollectionAllowList(user).call({from: notOwner})).to.be.rejectedWith('NoPermission');
     expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;
   });
 
-  // TODO: Temprorary off. Need refactor
-  // itEth('Collection allowlist can not be add and remove [sub] address by not owner', async ({helper}) => {
-  //   const owner = await helper.eth.createAccountWithBalance(donor);
-  //   const notOwner = await helper.eth.createAccountWithBalance(donor);
-  //   const user = donor;
-
-  //   const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
-  //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
-  //   await expect(collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).call({from: notOwner})).to.be.rejectedWith('NoPermission');
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
-  //   await collectionEvm.methods.addToCollectionAllowListSubstrate(user.addressRaw).send({from: owner});
-
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
-  //   await expect(collectionEvm.methods.removeFromCollectionAllowListSubstrate(user.addressRaw).call({from: notOwner})).to.be.rejectedWith('NoPermission');
-  //   expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
-  // });
+  //itEth('Collection allowlist can not be add and remove [cross] address by not owner', async ({helper}) => {
+  //  const owner = await helper.eth.createAccountWithBalance(donor);
+  //  const notOwner = await helper.eth.createAccountWithBalance(donor);
+  //  const user = donor;
+  //  
+  //  const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+  //  const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+  //  
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
+  //  const userCross = helper.ethCrossAccount.fromKeyringPair(user);
+  //  await expect(collectionEvm.methods.addToCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
+  //  await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
+  //  
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
+  //  await expect(collectionEvm.methods.removeFromCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
+  //  expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
+  //});
 });
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -13,7 +13,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -49,6 +49,15 @@
 	///  or in textual repr: setCollectionSponsor(address)
 	function setCollectionSponsor(address sponsor) external;
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) external;
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -104,6 +113,18 @@
 	function contractAddress() external view returns (address);
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  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,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) external;
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -153,6 +174,13 @@
 	///  or in textual repr: addToCollectionAllowList(address)
 	function addToCollectionAllowList(address user) external;
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -160,6 +188,13 @@
 	///  or in textual repr: removeFromCollectionAllowList(address)
 	function removeFromCollectionAllowList(address user) external;
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -175,6 +210,14 @@
 	///  or in textual repr: isOwnerOrAdmin(address)
 	function isOwnerOrAdmin(address user) external view returns (bool);
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -184,7 +227,7 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
@@ -205,10 +248,22 @@
 	/// @dev EVM selector for this function is: 0x5813216b,
 	///  or in textual repr: collectionAdmins()
 	function collectionAdmins() external view returns (Tuple6[] memory);
+
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) external;
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x63034ac5
+/// @dev the ERC-165 identifier for this interface is 0x032e5926
 interface ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev EVM selector for this function is: 0x0ecd0ab0,
+	///  or in textual repr: approveCross((address,uint256),uint256)
+	function approveCross(Tuple6 memory spender, uint256 amount) external returns (bool);
+
 	/// Burn tokens from account
 	/// @dev Function that burns an `amount` of the tokens of a given account,
 	/// deducting from the sender's allowance for said account.
@@ -218,11 +273,28 @@
 	///  or in textual repr: burnFrom(address,uint256)
 	function burnFrom(address from, uint256 amount) external returns (bool);
 
+	/// Burn tokens from account
+	/// @dev Function that burns an `amount` of the tokens of a given account,
+	/// deducting from the sender's allowance for said account.
+	/// @param from The account whose tokens will be burnt.
+	/// @param amount The amount that will be burnt.
+	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 amount) external returns (bool);
+
 	/// Mint tokens for multiple accounts.
 	/// @param amounts array of pairs of account address and amount
 	/// @dev EVM selector for this function is: 0x1acf2d55,
 	///  or in textual repr: mintBulk((address,uint256)[])
 	function mintBulk(Tuple6[] memory amounts) external returns (bool);
+
+	/// @dev EVM selector for this function is: 0xd5cf430b,
+	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 amount
+	) external returns (bool);
 }
 
 /// @dev anonymous struct
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -62,7 +62,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -98,6 +98,15 @@
 	///  or in textual repr: setCollectionSponsor(address)
 	function setCollectionSponsor(address sponsor) external;
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) external;
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -120,7 +129,7 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() external view returns (Tuple17 memory);
+	function collectionSponsor() external view returns (Tuple6 memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
@@ -153,6 +162,18 @@
 	function contractAddress() external view returns (address);
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  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,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) external;
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -202,6 +223,13 @@
 	///  or in textual repr: addToCollectionAllowList(address)
 	function addToCollectionAllowList(address user) external;
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -209,6 +237,13 @@
 	///  or in textual repr: removeFromCollectionAllowList(address)
 	function removeFromCollectionAllowList(address user) external;
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -224,6 +259,14 @@
 	///  or in textual repr: isOwnerOrAdmin(address)
 	function isOwnerOrAdmin(address user) external view returns (bool);
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -233,11 +276,11 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
-	function collectionOwner() external view returns (Tuple17 memory);
+	function collectionOwner() external view returns (Tuple6 memory);
 
 	/// Changes collection owner to another account
 	///
@@ -253,13 +296,15 @@
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0x5813216b,
 	///  or in textual repr: collectionAdmins()
-	function collectionAdmins() external view returns (Tuple17[] memory);
-}
+	function collectionAdmins() external view returns (Tuple6[] memory);
 
-/// @dev anonymous struct
-struct Tuple17 {
-	address field_0;
-	uint256 field_1;
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) external;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
@@ -357,7 +402,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x4468500d
+/// @dev the ERC-165 identifier for this interface is 0x244543ee
 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,
@@ -369,6 +414,16 @@
 	///  or in textual repr: symbol()
 	function symbol() external view returns (string memory);
 
+	/// @notice Set or reaffirm the approved address for an NFT
+	/// @dev The zero address indicates there is no approved address.
+	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+	///  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,
+	///  or in textual repr: approveCross((address,uint256),uint256)
+	function approveCross(Tuple6 memory approved, uint256 tokenId) external;
+
 	/// @notice Transfer ownership of an NFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
@@ -378,6 +433,20 @@
 	///  or in textual repr: transfer(address,uint256)
 	function transfer(address to, uint256 tokenId) external;
 
+	/// @notice Transfer ownership of an NFT from cross account address to cross account address
+	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	///  is the zero address. Throws if `tokenId` is not a valid NFT.
+	/// @param from Cross acccount address of current owner
+	/// @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)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 tokenId
+	) external;
+
 	/// @notice Burns a specific ERC721 token.
 	/// @dev Throws unless `msg.sender` is the current owner or an authorized
 	///  operator for this NFT. Throws if `from` is not the current owner. Throws
@@ -388,6 +457,16 @@
 	///  or in textual repr: burnFrom(address,uint256)
 	function burnFrom(address from, uint256 tokenId) external;
 
+	/// @notice Burns a specific ERC721 token.
+	/// @dev Throws unless `msg.sender` is the current owner or an authorized
+	///  operator for this NFT. Throws if `from` is not the current owner. Throws
+	///  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,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 tokenId) external;
+
 	/// @notice Returns next free NFT ID.
 	/// @dev EVM selector for this function is: 0x75794a3c,
 	///  or in textual repr: nextTokenId()
@@ -408,16 +487,22 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);
 
 }
 
 /// @dev anonymous struct
-struct Tuple6 {
+struct Tuple8 {
 	uint256 field_0;
 	string field_1;
 }
 
+/// @dev anonymous struct
+struct Tuple6 {
+	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/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -62,7 +62,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x3af103fb
+/// @dev the ERC-165 identifier for this interface is 0x25d897dc
 interface Collection is Dummy, ERC165 {
 	/// Set collection property.
 	///
@@ -98,6 +98,15 @@
 	///  or in textual repr: setCollectionSponsor(address)
 	function setCollectionSponsor(address sponsor) external;
 
+	/// Set the sponsor of the collection.
+	///
+	/// @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,
+	///  or in textual repr: setCollectionSponsorCross((address,uint256))
+	function setCollectionSponsorCross(Tuple6 memory sponsor) external;
+
 	/// Whether there is a pending sponsor.
 	/// @dev EVM selector for this function is: 0x058ac185,
 	///  or in textual repr: hasCollectionPendingSponsor()
@@ -120,7 +129,7 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() external view returns (Tuple17 memory);
+	function collectionSponsor() external view returns (Tuple6 memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
@@ -153,6 +162,18 @@
 	function contractAddress() external view returns (address);
 
 	/// Add collection admin.
+	/// @param newAdmin Cross account administrator address.
+	/// @dev EVM selector for this function is: 0x859aa7d6,
+	///  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,
+	///  or in textual repr: removeCollectionAdminCross((address,uint256))
+	function removeCollectionAdminCross(Tuple6 memory admin) external;
+
+	/// Add collection admin.
 	/// @param newAdmin Address of the added administrator.
 	/// @dev EVM selector for this function is: 0x92e462c7,
 	///  or in textual repr: addCollectionAdmin(address)
@@ -202,6 +223,13 @@
 	///  or in textual repr: addToCollectionAllowList(address)
 	function addToCollectionAllowList(address user) external;
 
+	/// Add user to allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0xa0184a3a,
+	///  or in textual repr: addToCollectionAllowListCross((address,uint256))
+	function addToCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Remove the user from the allowed list.
 	///
 	/// @param user Address of a removed user.
@@ -209,6 +237,13 @@
 	///  or in textual repr: removeFromCollectionAllowList(address)
 	function removeFromCollectionAllowList(address user) external;
 
+	/// Remove user from allowed list.
+	///
+	/// @param user User cross account address.
+	/// @dev EVM selector for this function is: 0x09ba452a,
+	///  or in textual repr: removeFromCollectionAllowListCross((address,uint256))
+	function removeFromCollectionAllowListCross(Tuple6 memory user) external;
+
 	/// Switch permission for minting.
 	///
 	/// @param mode Enable if "true".
@@ -224,6 +259,14 @@
 	///  or in textual repr: isOwnerOrAdmin(address)
 	function isOwnerOrAdmin(address user) external view returns (bool);
 
+	/// Check that account is the owner or admin of the collection
+	///
+	/// @param user User cross account to verify
+	/// @return "true" if account is the owner or admin
+	/// @dev EVM selector for this function is: 0x3e75a905,
+	///  or in textual repr: isOwnerOrAdminCross((address,uint256))
+	function isOwnerOrAdminCross(Tuple6 memory user) external view returns (bool);
+
 	/// Returns collection type
 	///
 	/// @return `Fungible` or `NFT` or `ReFungible`
@@ -233,11 +276,11 @@
 
 	/// Get collection owner.
 	///
-	/// @return Tuple with sponsor address and his substrate mirror.
+	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0xdf727d3b,
 	///  or in textual repr: collectionOwner()
-	function collectionOwner() external view returns (Tuple17 memory);
+	function collectionOwner() external view returns (Tuple6 memory);
 
 	/// Changes collection owner to another account
 	///
@@ -253,13 +296,15 @@
 	/// If address is canonical then substrate mirror is zero and vice versa.
 	/// @dev EVM selector for this function is: 0x5813216b,
 	///  or in textual repr: collectionAdmins()
-	function collectionAdmins() external view returns (Tuple17[] memory);
-}
+	function collectionAdmins() external view returns (Tuple6[] memory);
 
-/// @dev anonymous struct
-struct Tuple17 {
-	address field_0;
-	uint256 field_1;
+	/// Changes collection owner to another account
+	///
+	/// @dev Owner can be changed only by current owner
+	/// @param newOwner new owner cross account
+	/// @dev EVM selector for this function is: 0xe5c9913f,
+	///  or in textual repr: setOwnerCross((address,uint256))
+	function setOwnerCross(Tuple6 memory newOwner) external;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -355,7 +400,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xef1eaacb
+/// @dev the ERC-165 identifier for this interface is 0x81feb398
 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,
@@ -377,6 +422,20 @@
 	///  or in textual repr: transfer(address,uint256)
 	function transfer(address to, uint256 tokenId) external;
 
+	/// @notice Transfer ownership of an RFT
+	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+	///  is the zero address. Throws if `tokenId` is not a valid RFT.
+	///  Throws if RFT pieces have multiple owners.
+	/// @param to The new owner
+	/// @param tokenId The RFT to transfer
+	/// @dev EVM selector for this function is: 0xd5cf430b,
+	///  or in textual repr: transferFromCross((address,uint256),(address,uint256),uint256)
+	function transferFromCross(
+		Tuple6 memory from,
+		Tuple6 memory to,
+		uint256 tokenId
+	) external;
+
 	/// @notice Burns a specific ERC721 token.
 	/// @dev Throws unless `msg.sender` is the current owner or an authorized
 	///  operator for this RFT. Throws if `from` is not the current owner. Throws
@@ -388,6 +447,17 @@
 	///  or in textual repr: burnFrom(address,uint256)
 	function burnFrom(address from, uint256 tokenId) external;
 
+	/// @notice Burns a specific ERC721 token.
+	/// @dev Throws unless `msg.sender` is the current owner or an authorized
+	///  operator for this RFT. Throws if `from` is not the current owner. Throws
+	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+	///  Throws if RFT pieces have multiple owners.
+	/// @param from The current owner of the RFT
+	/// @param tokenId The RFT to transfer
+	/// @dev EVM selector for this function is: 0xbb2f5a58,
+	///  or in textual repr: burnFromCross((address,uint256),uint256)
+	function burnFromCross(Tuple6 memory from, uint256 tokenId) external;
+
 	/// @notice Returns next free RFT ID.
 	/// @dev EVM selector for this function is: 0x75794a3c,
 	///  or in textual repr: nextTokenId()
@@ -409,7 +479,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);
 
 	/// Returns EVM address for refungible token
 	///
@@ -420,11 +490,17 @@
 }
 
 /// @dev anonymous struct
-struct Tuple6 {
+struct Tuple8 {
 	uint256 field_0;
 	string field_1;
 }
 
+/// @dev anonymous struct
+struct Tuple6 {
+	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/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -116,8 +116,8 @@
     await checkInterface(helper, '0x780e9d63', true, true);
   });
 
-  itEth('ERC721UniqueExtensions - 0x4468500d - support', async ({helper}) => {
-    await checkInterface(helper, '0x4468500d', true, true);
+  itEth('ERC721UniqueExtensions - 0x244543ee - support', async ({helper}) => {
+    await checkInterface(helper, '0x244543ee', true, true);
   });
 
   itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -50,17 +50,18 @@
       .to.be.eq(newAdmin.toLocaleLowerCase());
   });
 
-  itEth.skip('Add substrate admin by owner', async ({helper}) => {
+  itEth('Add cross account admin by owner', async ({helper, privateKey}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
+        
     const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-
-    const [newAdmin] = await helper.arrange.createAccounts([10n], donor);
-    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();
+    
+    const newAdmin = await privateKey('//Bob');
+    const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);
+    await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();
 
-    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);
-    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())
-      .to.be.eq(newAdmin.address.toLocaleLowerCase());
+    const adminList = await helper.collection.getAdmins(collectionId);
+    expect(adminList).to.be.like([{Substrate: newAdmin.address}]);
   });
 
   itEth('Verify owner or admin', async ({helper}) => {
modifiedtests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth
--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -84,7 +84,11 @@
 	) external payable onlyOwner {
 		require(rftCollection == address(0), "RFT collection is already set");
 		address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
-		rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection{value: msg.value}(_name, _description, _tokenPrefix);
+		rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection{value: msg.value}(
+			_name,
+			_description,
+			_tokenPrefix
+		);
 		emit RFTCollectionSet(rftCollection);
 	}
 
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -148,6 +148,49 @@
     }
   });
 
+  itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const sender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
+
+    await collection.mint(alice, 200n, {Substrate: alice.address});
+    await collection.approveTokens(alice, {Ethereum: sender}, 100n);
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'ft');
+
+    const fromBalanceBefore = await collection.getBalance({Substrate: alice.address});
+    
+    const ownerCross = helper.ethCrossAccount.fromKeyringPair(alice);
+    const result = await contract.methods.burnFromCross(ownerCross, 49).send({from: sender});
+    const events = result.events;
+
+    expect(events).to.be.like({
+      Transfer: {
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(alice.address),
+          to: '0x0000000000000000000000000000000000000000',
+          value: '49',
+        },
+      },
+      Approval: {
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        returnValues: {
+          owner: helper.address.substrateToEth(alice.address),
+          spender: sender,
+          value: '51',
+        },
+        event: 'Approval',
+      },
+    });
+
+    const fromBalanceAfter = await collection.getBalance({Substrate: alice.address});
+    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(49n);
+  });
+
   itEth('Can perform transferFrom()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const spender = await helper.eth.createAccountWithBalance(donor);
@@ -216,6 +259,54 @@
       expect(+balance).to.equal(50);
     }
   });
+
+  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const sender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
+
+    const receiver = helper.eth.createAccount();
+
+    await collection.mint(alice, 200n, {Substrate: alice.address});
+    await collection.approveTokens(alice, {Ethereum: sender}, 100n);
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'ft');
+
+    const from = helper.ethCrossAccount.fromKeyringPair(alice);
+    const to = helper.ethCrossAccount.fromAddress(receiver);
+
+    const fromBalanceBefore = await collection.getBalance({Substrate: alice.address});
+    const toBalanceBefore = await collection.getBalance({Ethereum: receiver});
+    
+    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});
+
+    expect(result.events).to.be.like({
+      Transfer: {
+        address,
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(alice.address),
+          to: receiver,
+          value: '51',
+        },
+      },
+      Approval: {
+        address,
+        event: 'Approval',
+        returnValues: {
+          owner: helper.address.substrateToEth(alice.address),
+          spender: sender,
+          value: '49',
+        },
+      }});
+
+    const fromBalanceAfter = await collection.getBalance({Substrate: alice.address});
+    expect(fromBalanceBefore - fromBalanceAfter).to.be.eq(51n);
+    const toBalanceAfter = await collection.getBalance({Ethereum: receiver});
+    expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);
+  });
 });
 
 describe('Fungible: Fees', () => {
@@ -362,4 +453,44 @@
     expect(event.returnValues.to).to.be.equal(receiver);
     expect(event.returnValues.value).to.be.equal('51');
   });
+
+  itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const sender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
+
+    const receiver = helper.eth.createAccount();
+
+    await collection.mint(alice, 200n, {Substrate: alice.address});
+    await collection.approveTokens(alice, {Ethereum: sender}, 100n);
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'ft');
+
+    const from = helper.ethCrossAccount.fromKeyringPair(alice);
+    const to = helper.ethCrossAccount.fromAddress(receiver);
+    
+    const result = await contract.methods.transferFromCross(from, to, 51).send({from: sender});
+
+    expect(result.events).to.be.like({
+      Transfer: {
+        address,
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(alice.address),
+          to: receiver,
+          value: '51',
+        },
+      },
+      Approval: {
+        address,
+        event: 'Approval',
+        returnValues: {
+          owner: helper.address.substrateToEth(alice.address),
+          spender: sender,
+          value: '49',
+        },
+      }});
+  });
 });
modifiedtests/src/eth/fungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -60,6 +60,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newAdmin",
+        "type": "tuple"
+      }
+    ],
+    "name": "addCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "user", "type": "address" }
     ],
     "name": "addToCollectionAllowList",
@@ -69,6 +86,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "addToCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "owner", "type": "address" },
       { "internalType": "address", "name": "spender", "type": "address" }
     ],
@@ -98,6 +132,24 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "spender",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "amount", "type": "uint256" }
+    ],
+    "name": "approveCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "owner", "type": "address" }
     ],
     "name": "balanceOf",
@@ -117,6 +169,24 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "amount", "type": "uint256" }
+    ],
+    "name": "burnFromCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "newOwner", "type": "address" }
     ],
     "name": "changeCollectionOwner",
@@ -228,6 +298,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "isOwnerOrAdminCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "to", "type": "address" },
       { "internalType": "uint256", "name": "amount", "type": "uint256" }
     ],
@@ -270,6 +357,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "admin",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "removeCollectionSponsor",
     "outputs": [],
@@ -286,6 +390,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeFromCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],
     "name": "setCollectionAccess",
     "outputs": [],
@@ -361,6 +482,40 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "sponsor",
+        "type": "tuple"
+      }
+    ],
+    "name": "setCollectionSponsorCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newOwner",
+        "type": "tuple"
+      }
+    ],
+    "name": "setOwnerCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
     ],
     "name": "supportsInterface",
@@ -404,6 +559,33 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "to",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "amount", "type": "uint256" }
+    ],
+    "name": "transferFromCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "uniqueCollectionType",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -246,6 +246,64 @@
     }
   });
 
+  itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await privateKey('//Bob');
+    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const token = await collection.mintToken(alice, {Substrate: owner.address});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'nft');
+
+    {
+      await token.approve(owner, {Ethereum: spender});
+      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
+      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender});
+      const events = result.events.Transfer;
+
+      expect(events).to.be.like({
+        address,
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(owner.address),
+          to: '0x0000000000000000000000000000000000000000',
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+  });
+
+  itEth('Can perform approveCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await helper.eth.createAccountWithBalance(alice, 100n);
+    const receiver = await privateKey('//Charlie');
+
+    const token = await collection.mintToken(alice, {Ethereum: owner});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'nft');
+
+    {
+      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
+      const result = await contract.methods.approveCross(recieverCross, token.tokenId).send({from: owner});
+      const event = result.events.Approval;
+      expect(event).to.be.like({
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Approval',
+        returnValues: {
+          owner,
+          approved: helper.address.substrateToEth(receiver.address),
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+  });
+
   itEth('Can perform transferFrom()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const spender = await helper.eth.createAccountWithBalance(donor);
@@ -351,6 +409,40 @@
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
   });
 
+  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await privateKey('//Bob');
+    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+    const receiver = await privateKey('//Charlie');
+
+    const token = await collection.mintToken(alice, {Substrate: owner.address});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'nft');
+
+    await token.approve(owner, {Ethereum: spender});
+
+    {
+      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
+      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
+      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});
+      const event = result.events.Transfer;
+      expect(event).to.be.like({
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(owner.address),
+          to: helper.address.substrateToEth(receiver.address),
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+
+    expect(await token.getOwner()).to.be.like({Substrate: receiver.address});
+  });
+
   itEth('transfer() call fee is less than 0.2UNQ', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
modifiedtests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -91,6 +91,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newAdmin",
+        "type": "tuple"
+      }
+    ],
+    "name": "addCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "user", "type": "address" }
     ],
     "name": "addToCollectionAllowList",
@@ -100,6 +117,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "addToCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "user", "type": "address" }
     ],
     "name": "allowed",
@@ -119,6 +153,24 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "approved",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "approveCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "owner", "type": "address" }
     ],
     "name": "balanceOf",
@@ -147,6 +199,24 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "burnFromCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "newOwner", "type": "address" }
     ],
     "name": "changeCollectionOwner",
@@ -163,7 +233,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17[]",
+        "internalType": "struct Tuple6[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -180,7 +250,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17",
+        "internalType": "struct Tuple6",
         "name": "",
         "type": "tuple"
       }
@@ -204,7 +274,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17",
+        "internalType": "struct Tuple6",
         "name": "",
         "type": "tuple"
       }
@@ -286,6 +356,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "isOwnerOrAdminCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
     "name": "mint",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
@@ -352,6 +439,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "admin",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "removeCollectionSponsor",
     "outputs": [],
@@ -369,6 +473,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeFromCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "from", "type": "address" },
       { "internalType": "address", "name": "to", "type": "address" },
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
@@ -476,6 +597,40 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "sponsor",
+        "type": "tuple"
+      }
+    ],
+    "name": "setCollectionSponsorCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newOwner",
+        "type": "tuple"
+      }
+    ],
+    "name": "setOwnerCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
       { "internalType": "string", "name": "key", "type": "string" },
       { "internalType": "bytes", "name": "value", "type": "bytes" }
@@ -570,6 +725,33 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "to",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "transferFromCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "uniqueCollectionType",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -227,6 +227,108 @@
     }
   });
 
+  itEth('Can perform burnFrom()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await helper.eth.createAccountWithBalance(alice, 100n);
+    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const token = await collection.mintToken(alice, 100n, {Ethereum: owner});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'rft');
+
+    const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);
+    const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);
+    await tokenContract.methods.repartition(15).send();
+    await tokenContract.methods.approve(spender, 15).send();
+
+    {
+      const result = await contract.methods.burnFrom(owner, token.tokenId).send({from: spender});
+      const event = result.events.Transfer;
+      expect(event).to.be.like({
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Transfer',
+        returnValues: {
+          from: owner,
+          to: '0x0000000000000000000000000000000000000000',
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+
+    expect(await collection.getTokenBalance(token.tokenId, {Ethereum: owner})).to.be.eq(0n);
+  });
+
+  itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await privateKey('//Bob');
+    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+
+    const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'rft');
+
+    await token.repartition(owner, 15n);
+    await token.approve(owner, {Ethereum: spender}, 15n);
+
+    {
+      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
+      const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender});
+      const event = result.events.Transfer;
+      expect(event).to.be.like({
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(owner.address),
+          to: '0x0000000000000000000000000000000000000000',
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+
+    expect(await collection.getTokenBalance(token.tokenId, {Substrate: owner.address})).to.be.eq(0n);
+  });
+
+  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
+    const alice = await privateKey('//Alice');
+    const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
+
+    const owner = await privateKey('//Bob');
+    const spender = await helper.eth.createAccountWithBalance(alice, 100n);
+    const receiver = await privateKey('//Charlie');
+
+    const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
+
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const contract = helper.ethNativeContract.collection(address, 'rft');
+
+    await token.repartition(owner, 15n);
+    await token.approve(owner, {Ethereum: spender}, 15n);
+
+    {
+      const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);
+      const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);
+      const result = await contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender});
+      const event = result.events.Transfer;
+      expect(event).to.be.like({
+        address: helper.ethAddress.fromCollectionId(collection.collectionId),
+        event: 'Transfer',
+        returnValues: {
+          from: helper.address.substrateToEth(owner.address),
+          to: helper.address.substrateToEth(receiver.address),
+          tokenId: token.tokenId.toString(),
+        },
+      });
+    }
+
+    expect(await token.getTop10Owners()).to.be.like([{Substrate: receiver.address}]);
+  });
+
   itEth('Can perform transfer()', async ({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
modifiedtests/src/eth/reFungibleAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -91,6 +91,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newAdmin",
+        "type": "tuple"
+      }
+    ],
+    "name": "addCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "user", "type": "address" }
     ],
     "name": "addToCollectionAllowList",
@@ -100,6 +117,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "addToCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "user", "type": "address" }
     ],
     "name": "allowed",
@@ -147,6 +181,24 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "burnFromCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "newOwner", "type": "address" }
     ],
     "name": "changeCollectionOwner",
@@ -163,7 +215,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17[]",
+        "internalType": "struct Tuple6[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -180,7 +232,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17",
+        "internalType": "struct Tuple6",
         "name": "",
         "type": "tuple"
       }
@@ -204,7 +256,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple17",
+        "internalType": "struct Tuple6",
         "name": "",
         "type": "tuple"
       }
@@ -286,6 +338,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "isOwnerOrAdminCross",
+    "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
     "inputs": [{ "internalType": "address", "name": "to", "type": "address" }],
     "name": "mint",
     "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
@@ -352,6 +421,23 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "admin",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeCollectionAdminCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "removeCollectionSponsor",
     "outputs": [],
@@ -369,6 +455,23 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "user",
+        "type": "tuple"
+      }
+    ],
+    "name": "removeFromCollectionAllowListCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "from", "type": "address" },
       { "internalType": "address", "name": "to", "type": "address" },
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
@@ -476,6 +579,40 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "sponsor",
+        "type": "tuple"
+      }
+    ],
+    "name": "setCollectionSponsorCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "newOwner",
+        "type": "tuple"
+      }
+    ],
+    "name": "setOwnerCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
       { "internalType": "string", "name": "key", "type": "string" },
       { "internalType": "bytes", "name": "value", "type": "bytes" }
@@ -579,6 +716,33 @@
     "type": "function"
   },
   {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "from",
+        "type": "tuple"
+      },
+      {
+        "components": [
+          { "internalType": "address", "name": "field_0", "type": "address" },
+          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+        ],
+        "internalType": "struct Tuple6",
+        "name": "to",
+        "type": "tuple"
+      },
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "transferFromCross",
+    "outputs": [],
+    "stateMutability": "nonpayable",
+    "type": "function"
+  },
+  {
     "inputs": [],
     "name": "uniqueCollectionType",
     "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
modifiedtests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -13,3 +13,9 @@
   event: string,
   args: { [key: string]: string }
 };
+export interface TEthCrossAccount {
+  readonly 0: string,
+  readonly 1: string | Uint8Array,
+  readonly field_0: string,
+  readonly field_1: string | Uint8Array,
+}
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
@@ -18,7 +18,7 @@
 
 import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';
 
-import {ContractImports, CompiledContract, NormalizedEvent} from './types';
+import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent} from './types';
 
 // Native contracts ABI
 import collectionHelpersAbi from '../../collectionHelpersAbi.json';
@@ -343,6 +343,26 @@
 
 export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
 
+export class EthCrossAccountGroup extends EthGroupBase {
+  fromAddress(address: TEthereumAccount): TEthCrossAccount {
+    return {
+      0: address,
+      1: '0',
+      field_0: address,
+      field_1: '0',
+    };
+  }
+
+  fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
+    return {
+      0: '0x0000000000000000000000000000000000000000',
+      1: keyring.addressRaw,
+      field_0: '0x0000000000000000000000000000000000000000',
+      field_1: keyring.addressRaw,
+    };
+  }
+}
+
 export class EthUniqueHelper extends DevUniqueHelper {
   web3: Web3 | null = null;
   web3Provider: WebsocketProvider | null = null;
@@ -351,6 +371,7 @@
   ethAddress: EthAddressGroup;
   ethNativeContract: NativeContractGroup;
   ethContract: ContractGroup;
+  ethCrossAccount: EthCrossAccountGroup;
 
   constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
     options.helperBase = options.helperBase ?? EthUniqueHelper;
@@ -358,6 +379,7 @@
     super(logger, options);
     this.eth = new EthGroup(this);
     this.ethAddress = new EthAddressGroup(this);
+    this.ethCrossAccount = new EthCrossAccountGroup(this);
     this.ethNativeContract = new NativeContractGroup(this);
     this.ethContract = new ContractGroup(this);
   }