git.delta.rocks / unique-network / refs/commits / 8dd063b578e3

difftreelog

Merge pull request #869 from UniqueNetwork/feature/generalize_2_methods

Yaroslav Bolyukin2023-02-03parents: #f1a5ba7 #ccafa37.patch.diff
in: master
Feature/generalize_2_methods

34 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6361,7 +6361,7 @@
 
 [[package]]
 name = "pallet-fungible"
-version = "0.1.9"
+version = "0.1.10"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
@@ -6774,7 +6774,7 @@
 
 [[package]]
 name = "pallet-refungible"
-version = "0.2.12"
+version = "0.2.13"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -18,7 +18,10 @@
 
 use alloc::format;
 use sp_std::{vec, vec::Vec};
-use evm_coder::{AbiCoder, types::Address};
+use evm_coder::{
+	AbiCoder,
+	types::{Address, String},
+};
 pub use pallet_evm::{Config, account::CrossAccountId};
 use sp_core::{H160, U256};
 use up_data_structs::CollectionId;
@@ -390,6 +393,16 @@
 	}
 }
 
+/// Data for creation token with uri.
+#[derive(Debug, AbiCoder)]
+pub struct TokenUri {
+	/// Id of new token.
+	pub id: U256,
+
+	/// Uri of new token.
+	pub uri: String,
+}
+
 /// Nested collections.
 #[derive(Debug, Default, AbiCoder)]
 pub struct CollectionNesting {
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -66,10 +66,11 @@
 	ensure,
 	traits::{Imbalance, Get, Currency, WithdrawReasons, ExistenceRequirement},
 	dispatch::Pays,
-	transactional,
+	transactional, fail,
 };
 use pallet_evm::GasWeightMapping;
 use up_data_structs::{
+	AccessMode,
 	COLLECTION_NUMBER_LIMIT,
 	Collection,
 	RpcCollection,
@@ -124,6 +125,8 @@
 pub use pallet::*;
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
+
+use crate::erc::CollectionHelpersEvents;
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
 pub mod dispatch;
@@ -1264,6 +1267,133 @@
 		Ok(())
 	}
 
+	/// A batch operation to add, edit or remove properties for a token.
+	/// It sets or removes a token's properties according to
+	/// `properties_updates` contents:
+	/// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`
+	/// * removes a property under the <key> if the value is `None` `(<key>, None)`.
+	///
+	/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
+	/// - `is_token_create`: Indicates that method is called during token initialization.
+	///   Allows to bypass ownership check.
+	///
+	/// All affected properties should have `mutable` permission
+	/// to be **deleted** or to be **set more than once**,
+	/// and the sender should have permission to edit those properties.
+	///
+	/// This function fires an event for each property change.
+	/// In case of an error, all the changes (including the events) will be reverted
+	/// since the function is transactional.
+	pub fn modify_token_properties(
+		collection: &CollectionHandle<T>,
+		sender: &T::CrossAccountId,
+		token_id: TokenId,
+		properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
+		is_token_create: bool,
+		mut stored_properties: Properties,
+		is_token_owner: impl Fn() -> Result<bool, DispatchError>,
+		set_token_properties: impl FnOnce(Properties),
+	) -> DispatchResult {
+		let is_collection_admin = collection.is_owner_or_admin(sender);
+		let permissions = Self::property_permissions(collection.id);
+
+		let mut token_owner_result = None;
+		let mut is_token_owner = || -> Result<bool, DispatchError> {
+			*token_owner_result.get_or_insert_with(&is_token_owner)
+		};
+
+		for (key, value) in properties_updates {
+			let permission = permissions
+				.get(&key)
+				.cloned()
+				.unwrap_or_else(PropertyPermission::none);
+
+			let is_property_exists = stored_properties.get(&key).is_some();
+
+			match permission {
+				PropertyPermission { mutable: false, .. } if is_property_exists => {
+					return Err(<Error<T>>::NoPermission.into());
+				}
+
+				PropertyPermission {
+					collection_admin,
+					token_owner,
+					..
+				} => {
+					//TODO: investigate threats during public minting.
+					let is_token_create =
+						is_token_create && (collection_admin || token_owner) && value.is_some();
+					if !(is_token_create
+						|| (collection_admin && is_collection_admin)
+						|| (token_owner && is_token_owner()?))
+					{
+						fail!(<Error<T>>::NoPermission);
+					}
+				}
+			}
+
+			match value {
+				Some(value) => {
+					stored_properties
+						.try_set(key.clone(), value)
+						.map_err(<Error<T>>::from)?;
+
+					Self::deposit_event(Event::TokenPropertySet(collection.id, token_id, key));
+				}
+				None => {
+					stored_properties.remove(&key).map_err(<Error<T>>::from)?;
+
+					Self::deposit_event(Event::TokenPropertyDeleted(collection.id, token_id, key));
+				}
+			}
+
+			<PalletEvm<T>>::deposit_log(
+				CollectionHelpersEvents::TokenChanged {
+					collection_id: eth::collection_id_to_address(collection.id),
+					token_id: token_id.into(),
+				}
+				.to_log(T::ContractAddress::get()),
+			);
+		}
+
+		set_token_properties(stored_properties);
+
+		Ok(())
+	}
+
+	/// Sets or unsets the approval of a given operator.
+	///
+	/// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.
+	/// - `owner`: Token owner
+	/// - `operator`: Operator
+	/// - `approve`: Should operator status be granted or revoked?
+	pub fn set_allowance_for_all(
+		collection: &CollectionHandle<T>,
+		owner: &T::CrossAccountId,
+		operator: &T::CrossAccountId,
+		approve: bool,
+		set_allowance: impl FnOnce(),
+		log: evm_coder::ethereum::Log,
+	) -> DispatchResult {
+		if collection.permissions.access() == AccessMode::AllowList {
+			collection.check_allowlist(owner)?;
+			collection.check_allowlist(operator)?;
+		}
+
+		Self::ensure_correct_receiver(operator)?;
+
+		set_allowance();
+
+		<PalletEvm<T>>::deposit_log(log);
+		Self::deposit_event(Event::ApprovedForAll(
+			collection.id,
+			owner.clone(),
+			operator.clone(),
+			approve,
+		));
+		Ok(())
+	}
+
 	/// Set collection property.
 	///
 	/// * `collection` - Collection handler.
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.10] - 2023-02-01
+
+### Added
+
+- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.
+
 ## [0.1.9] - 2022-12-01
 
 ### Added
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-fungible"
-version = "0.1.9"
+version = "0.1.10"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
before · pallets/fungible/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//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::{23	abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,24	weight,25};26use up_data_structs::CollectionMode;27use pallet_common::{28	CollectionHandle,29	erc::{CommonEvmHandler, PrecompileResult, CollectionCall},30};31use sp_std::vec::Vec;32use pallet_evm::{account::CrossAccountId, PrecompileHandle};33use pallet_evm_coder_substrate::{call, dispatch_to_evm};34use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};35use sp_core::{U256, Get};3637use crate::{38	Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,39	weights::WeightInfo,40};4142#[derive(ToLog)]43pub enum ERC20Events {44	Transfer {45		#[indexed]46		from: Address,47		#[indexed]48		to: Address,49		value: U256,50	},51	Approval {52		#[indexed]53		owner: Address,54		#[indexed]55		spender: Address,56		value: U256,57	},58}5960#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]61impl<T: Config> FungibleHandle<T> {62	fn name(&self) -> Result<String> {63		Ok(decode_utf16(self.name.iter().copied())64			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))65			.collect::<String>())66	}67	fn symbol(&self) -> Result<String> {68		Ok(String::from_utf8_lossy(&self.token_prefix).into())69	}70	fn total_supply(&self) -> Result<U256> {71		self.consume_store_reads(1)?;72		Ok(<TotalSupply<T>>::get(self.id).into())73	}7475	fn decimals(&self) -> Result<u8> {76		Ok(if let CollectionMode::Fungible(decimals) = &self.mode {77			*decimals78		} else {79			unreachable!()80		})81	}82	fn balance_of(&self, owner: Address) -> Result<U256> {83		self.consume_store_reads(1)?;84		let owner = T::CrossAccountId::from_eth(owner);85		let balance = <Balance<T>>::get((self.id, owner));86		Ok(balance.into())87	}88	#[weight(<SelfWeightOf<T>>::transfer())]89	fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {90		let caller = T::CrossAccountId::from_eth(caller);91		let to = T::CrossAccountId::from_eth(to);92		let amount = amount.try_into().map_err(|_| "amount overflow")?;93		let budget = self94			.recorder95			.weight_calls_budget(<StructureWeight<T>>::find_parent());9697		<Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;98		Ok(true)99	}100101	#[weight(<SelfWeightOf<T>>::transfer_from())]102	fn transfer_from(103		&mut self,104		caller: Caller,105		from: Address,106		to: Address,107		amount: U256,108	) -> Result<bool> {109		let caller = T::CrossAccountId::from_eth(caller);110		let from = T::CrossAccountId::from_eth(from);111		let to = T::CrossAccountId::from_eth(to);112		let amount = amount.try_into().map_err(|_| "amount overflow")?;113		let budget = self114			.recorder115			.weight_calls_budget(<StructureWeight<T>>::find_parent());116117		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)118			.map_err(dispatch_to_evm::<T>)?;119		Ok(true)120	}121	#[weight(<SelfWeightOf<T>>::approve())]122	fn approve(&mut self, caller: Caller, spender: Address, amount: U256) -> Result<bool> {123		let caller = T::CrossAccountId::from_eth(caller);124		let spender = T::CrossAccountId::from_eth(spender);125		let amount = amount.try_into().map_err(|_| "amount overflow")?;126127		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)128			.map_err(dispatch_to_evm::<T>)?;129		Ok(true)130	}131	fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {132		self.consume_store_reads(1)?;133		let owner = T::CrossAccountId::from_eth(owner);134		let spender = T::CrossAccountId::from_eth(spender);135136		Ok(<Allowance<T>>::get((self.id, owner, spender)).into())137	}138}139140#[solidity_interface(name = ERC20Mintable)]141impl<T: Config> FungibleHandle<T> {142	/// Mint tokens for `to` account.143	/// @param to account that will receive minted tokens144	/// @param amount amount of tokens to mint145	#[weight(<SelfWeightOf<T>>::create_item())]146	fn mint(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {147		let caller = T::CrossAccountId::from_eth(caller);148		let to = T::CrossAccountId::from_eth(to);149		let amount = amount.try_into().map_err(|_| "amount overflow")?;150		let budget = self151			.recorder152			.weight_calls_budget(<StructureWeight<T>>::find_parent());153		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)154			.map_err(dispatch_to_evm::<T>)?;155		Ok(true)156	}157}158159#[solidity_interface(name = ERC20UniqueExtensions)]160impl<T: Config> FungibleHandle<T>161where162	T::AccountId: From<[u8; 32]>,163{164	/// @notice A description for the collection.165	fn description(&self) -> Result<String> {166		Ok(decode_utf16(self.description.iter().copied())167			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))168			.collect::<String>())169	}170171	#[weight(<SelfWeightOf<T>>::create_item())]172	fn mint_cross(173		&mut self,174		caller: Caller,175		to: pallet_common::eth::CrossAddress,176		amount: U256,177	) -> Result<bool> {178		let caller = T::CrossAccountId::from_eth(caller);179		let to = to.into_sub_cross_account::<T>()?;180		let amount = amount.try_into().map_err(|_| "amount overflow")?;181		let budget = self182			.recorder183			.weight_calls_budget(<StructureWeight<T>>::find_parent());184		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)185			.map_err(dispatch_to_evm::<T>)?;186		Ok(true)187	}188189	#[weight(<SelfWeightOf<T>>::approve())]190	fn approve_cross(191		&mut self,192		caller: Caller,193		spender: pallet_common::eth::CrossAddress,194		amount: U256,195	) -> Result<bool> {196		let caller = T::CrossAccountId::from_eth(caller);197		let spender = spender.into_sub_cross_account::<T>()?;198		let amount = amount.try_into().map_err(|_| "amount overflow")?;199200		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)201			.map_err(dispatch_to_evm::<T>)?;202		Ok(true)203	}204205	/// Burn tokens from account206	/// @dev Function that burns an `amount` of the tokens of a given account,207	/// deducting from the sender's allowance for said account.208	/// @param from The account whose tokens will be burnt.209	/// @param amount The amount that will be burnt.210	#[solidity(hide)]211	#[weight(<SelfWeightOf<T>>::burn_from())]212	fn burn_from(&mut self, caller: Caller, from: Address, amount: U256) -> Result<bool> {213		let caller = T::CrossAccountId::from_eth(caller);214		let from = T::CrossAccountId::from_eth(from);215		let amount = amount.try_into().map_err(|_| "amount overflow")?;216		let budget = self217			.recorder218			.weight_calls_budget(<StructureWeight<T>>::find_parent());219220		<Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)221			.map_err(dispatch_to_evm::<T>)?;222		Ok(true)223	}224225	/// Burn tokens from account226	/// @dev Function that burns an `amount` of the tokens of a given account,227	/// deducting from the sender's allowance for said account.228	/// @param from The account whose tokens will be burnt.229	/// @param amount The amount that will be burnt.230	#[weight(<SelfWeightOf<T>>::burn_from())]231	fn burn_from_cross(232		&mut self,233		caller: Caller,234		from: pallet_common::eth::CrossAddress,235		amount: U256,236	) -> Result<bool> {237		let caller = T::CrossAccountId::from_eth(caller);238		let from = from.into_sub_cross_account::<T>()?;239		let amount = amount.try_into().map_err(|_| "amount overflow")?;240		let budget = self241			.recorder242			.weight_calls_budget(<StructureWeight<T>>::find_parent());243244		<Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)245			.map_err(dispatch_to_evm::<T>)?;246		Ok(true)247	}248249	/// Mint tokens for multiple accounts.250	/// @param amounts array of pairs of account address and amount251	#[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]252	fn mint_bulk(&mut self, caller: Caller, amounts: Vec<(Address, U256)>) -> Result<bool> {253		let caller = T::CrossAccountId::from_eth(caller);254		let budget = self255			.recorder256			.weight_calls_budget(<StructureWeight<T>>::find_parent());257		let amounts = amounts258			.into_iter()259			.map(|(to, amount)| {260				Ok((261					T::CrossAccountId::from_eth(to),262					amount.try_into().map_err(|_| "amount overflow")?,263				))264			})265			.collect::<Result<_>>()?;266267		<Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)268			.map_err(dispatch_to_evm::<T>)?;269		Ok(true)270	}271272	#[weight(<SelfWeightOf<T>>::transfer())]273	fn transfer_cross(274		&mut self,275		caller: Caller,276		to: pallet_common::eth::CrossAddress,277		amount: U256,278	) -> Result<bool> {279		let caller = T::CrossAccountId::from_eth(caller);280		let to = to.into_sub_cross_account::<T>()?;281		let amount = amount.try_into().map_err(|_| "amount overflow")?;282		let budget = self283			.recorder284			.weight_calls_budget(<StructureWeight<T>>::find_parent());285286		<Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;287		Ok(true)288	}289290	#[weight(<SelfWeightOf<T>>::transfer_from())]291	fn transfer_from_cross(292		&mut self,293		caller: Caller,294		from: pallet_common::eth::CrossAddress,295		to: pallet_common::eth::CrossAddress,296		amount: U256,297	) -> Result<bool> {298		let caller = T::CrossAccountId::from_eth(caller);299		let from = from.into_sub_cross_account::<T>()?;300		let to = to.into_sub_cross_account::<T>()?;301		let amount = amount.try_into().map_err(|_| "amount overflow")?;302		let budget = self303			.recorder304			.weight_calls_budget(<StructureWeight<T>>::find_parent());305306		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)307			.map_err(dispatch_to_evm::<T>)?;308		Ok(true)309	}310311	/// @notice Returns collection helper contract address312	fn collection_helper_address(&self) -> Result<Address> {313		Ok(T::ContractAddress::get())314	}315}316317#[solidity_interface(318	name = UniqueFungible,319	is(320		ERC20,321		ERC20Mintable,322		ERC20UniqueExtensions,323		Collection(via(common_mut returns CollectionHandle<T>)),324	)325)]326impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}327328generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);329generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);330331impl<T: Config> CommonEvmHandler for FungibleHandle<T>332where333	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,334{335	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");336337	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {338		call::<T, UniqueFungibleCall<T>, _, _>(handle, self)339	}340}
after · pallets/fungible/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//! ERC-20 standart support implementation.1819extern crate alloc;20use core::char::{REPLACEMENT_CHARACTER, decode_utf16};21use core::convert::TryInto;22use evm_coder::AbiCoder;23use evm_coder::{24	abi::AbiType, ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*,25	weight,26};27use up_data_structs::CollectionMode;28use pallet_common::{29	CollectionHandle,30	erc::{CommonEvmHandler, PrecompileResult, CollectionCall},31	eth::CrossAddress,32};33use sp_std::vec::Vec;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::{U256, Get};3839use crate::{40	Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,41	weights::WeightInfo,42};4344#[derive(ToLog)]45pub enum ERC20Events {46	Transfer {47		#[indexed]48		from: Address,49		#[indexed]50		to: Address,51		value: U256,52	},53	Approval {54		#[indexed]55		owner: Address,56		#[indexed]57		spender: Address,58		value: U256,59	},60}6162#[derive(AbiCoder, Debug)]63pub struct AmountForAddress {64	to: Address,65	amount: U256,66}6768#[solidity_interface(name = ERC20, events(ERC20Events), expect_selector = 0x942e8b22)]69impl<T: Config> FungibleHandle<T> {70	fn name(&self) -> Result<String> {71		Ok(decode_utf16(self.name.iter().copied())72			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))73			.collect::<String>())74	}75	fn symbol(&self) -> Result<String> {76		Ok(String::from_utf8_lossy(&self.token_prefix).into())77	}78	fn total_supply(&self) -> Result<U256> {79		self.consume_store_reads(1)?;80		Ok(<TotalSupply<T>>::get(self.id).into())81	}8283	fn decimals(&self) -> Result<u8> {84		Ok(if let CollectionMode::Fungible(decimals) = &self.mode {85			*decimals86		} else {87			unreachable!()88		})89	}90	fn balance_of(&self, owner: Address) -> Result<U256> {91		self.consume_store_reads(1)?;92		let owner = T::CrossAccountId::from_eth(owner);93		let balance = <Balance<T>>::get((self.id, owner));94		Ok(balance.into())95	}96	#[weight(<SelfWeightOf<T>>::transfer())]97	fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {98		let caller = T::CrossAccountId::from_eth(caller);99		let to = T::CrossAccountId::from_eth(to);100		let amount = amount.try_into().map_err(|_| "amount overflow")?;101		let budget = self102			.recorder103			.weight_calls_budget(<StructureWeight<T>>::find_parent());104105		<Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;106		Ok(true)107	}108109	#[weight(<SelfWeightOf<T>>::transfer_from())]110	fn transfer_from(111		&mut self,112		caller: Caller,113		from: Address,114		to: Address,115		amount: U256,116	) -> Result<bool> {117		let caller = T::CrossAccountId::from_eth(caller);118		let from = T::CrossAccountId::from_eth(from);119		let to = T::CrossAccountId::from_eth(to);120		let amount = amount.try_into().map_err(|_| "amount overflow")?;121		let budget = self122			.recorder123			.weight_calls_budget(<StructureWeight<T>>::find_parent());124125		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)126			.map_err(dispatch_to_evm::<T>)?;127		Ok(true)128	}129	#[weight(<SelfWeightOf<T>>::approve())]130	fn approve(&mut self, caller: Caller, spender: Address, amount: U256) -> Result<bool> {131		let caller = T::CrossAccountId::from_eth(caller);132		let spender = T::CrossAccountId::from_eth(spender);133		let amount = amount.try_into().map_err(|_| "amount overflow")?;134135		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)136			.map_err(dispatch_to_evm::<T>)?;137		Ok(true)138	}139	fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {140		self.consume_store_reads(1)?;141		let owner = T::CrossAccountId::from_eth(owner);142		let spender = T::CrossAccountId::from_eth(spender);143144		Ok(<Allowance<T>>::get((self.id, owner, spender)).into())145	}146}147148#[solidity_interface(name = ERC20Mintable)]149impl<T: Config> FungibleHandle<T> {150	/// Mint tokens for `to` account.151	/// @param to account that will receive minted tokens152	/// @param amount amount of tokens to mint153	#[weight(<SelfWeightOf<T>>::create_item())]154	fn mint(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {155		let caller = T::CrossAccountId::from_eth(caller);156		let to = T::CrossAccountId::from_eth(to);157		let amount = amount.try_into().map_err(|_| "amount overflow")?;158		let budget = self159			.recorder160			.weight_calls_budget(<StructureWeight<T>>::find_parent());161		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)162			.map_err(dispatch_to_evm::<T>)?;163		Ok(true)164	}165}166167#[solidity_interface(name = ERC20UniqueExtensions)]168impl<T: Config> FungibleHandle<T>169where170	T::AccountId: From<[u8; 32]>,171{172	/// @dev Function to check the amount of tokens that an owner allowed to a spender.173	/// @param owner crossAddress The address which owns the funds.174	/// @param spender crossAddress The address which will spend the funds.175	/// @return A uint256 specifying the amount of tokens still available for the spender.176	fn allowance_cross(&self, owner: CrossAddress, spender: CrossAddress) -> Result<U256> {177		let owner = owner.into_sub_cross_account::<T>()?;178		let spender = spender.into_sub_cross_account::<T>()?;179180		Ok(<Allowance<T>>::get((self.id, owner, spender)).into())181	}182183	/// @notice A description for the collection.184	fn description(&self) -> Result<String> {185		Ok(decode_utf16(self.description.iter().copied())186			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))187			.collect::<String>())188	}189190	#[weight(<SelfWeightOf<T>>::create_item())]191	fn mint_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {192		let caller = T::CrossAccountId::from_eth(caller);193		let to = to.into_sub_cross_account::<T>()?;194		let amount = amount.try_into().map_err(|_| "amount overflow")?;195		let budget = self196			.recorder197			.weight_calls_budget(<StructureWeight<T>>::find_parent());198		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)199			.map_err(dispatch_to_evm::<T>)?;200		Ok(true)201	}202203	#[weight(<SelfWeightOf<T>>::approve())]204	fn approve_cross(205		&mut self,206		caller: Caller,207		spender: CrossAddress,208		amount: U256,209	) -> Result<bool> {210		let caller = T::CrossAccountId::from_eth(caller);211		let spender = spender.into_sub_cross_account::<T>()?;212		let amount = amount.try_into().map_err(|_| "amount overflow")?;213214		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)215			.map_err(dispatch_to_evm::<T>)?;216		Ok(true)217	}218219	/// Burn tokens from account220	/// @dev Function that burns an `amount` of the tokens of a given account,221	/// deducting from the sender's allowance for said account.222	/// @param from The account whose tokens will be burnt.223	/// @param amount The amount that will be burnt.224	#[solidity(hide)]225	#[weight(<SelfWeightOf<T>>::burn_from())]226	fn burn_from(&mut self, caller: Caller, from: Address, amount: U256) -> Result<bool> {227		let caller = T::CrossAccountId::from_eth(caller);228		let from = T::CrossAccountId::from_eth(from);229		let amount = amount.try_into().map_err(|_| "amount overflow")?;230		let budget = self231			.recorder232			.weight_calls_budget(<StructureWeight<T>>::find_parent());233234		<Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)235			.map_err(dispatch_to_evm::<T>)?;236		Ok(true)237	}238239	/// Burn tokens from account240	/// @dev Function that burns an `amount` of the tokens of a given account,241	/// deducting from the sender's allowance for said account.242	/// @param from The account whose tokens will be burnt.243	/// @param amount The amount that will be burnt.244	#[weight(<SelfWeightOf<T>>::burn_from())]245	fn burn_from_cross(246		&mut self,247		caller: Caller,248		from: CrossAddress,249		amount: U256,250	) -> Result<bool> {251		let caller = T::CrossAccountId::from_eth(caller);252		let from = from.into_sub_cross_account::<T>()?;253		let amount = amount.try_into().map_err(|_| "amount overflow")?;254		let budget = self255			.recorder256			.weight_calls_budget(<StructureWeight<T>>::find_parent());257258		<Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)259			.map_err(dispatch_to_evm::<T>)?;260		Ok(true)261	}262263	/// Mint tokens for multiple accounts.264	/// @param amounts array of pairs of account address and amount265	#[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]266	fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {267		let caller = T::CrossAccountId::from_eth(caller);268		let budget = self269			.recorder270			.weight_calls_budget(<StructureWeight<T>>::find_parent());271		let amounts = amounts272			.into_iter()273			.map(|AmountForAddress { to, amount }| {274				Ok((275					T::CrossAccountId::from_eth(to),276					amount.try_into().map_err(|_| "amount overflow")?,277				))278			})279			.collect::<Result<_>>()?;280281		<Pallet<T>>::create_multiple_items(&self, &caller, amounts, &budget)282			.map_err(dispatch_to_evm::<T>)?;283		Ok(true)284	}285286	#[weight(<SelfWeightOf<T>>::transfer())]287	fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {288		let caller = T::CrossAccountId::from_eth(caller);289		let to = to.into_sub_cross_account::<T>()?;290		let amount = amount.try_into().map_err(|_| "amount overflow")?;291		let budget = self292			.recorder293			.weight_calls_budget(<StructureWeight<T>>::find_parent());294295		<Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;296		Ok(true)297	}298299	#[weight(<SelfWeightOf<T>>::transfer_from())]300	fn transfer_from_cross(301		&mut self,302		caller: Caller,303		from: CrossAddress,304		to: CrossAddress,305		amount: U256,306	) -> Result<bool> {307		let caller = T::CrossAccountId::from_eth(caller);308		let from = from.into_sub_cross_account::<T>()?;309		let to = to.into_sub_cross_account::<T>()?;310		let amount = amount.try_into().map_err(|_| "amount overflow")?;311		let budget = self312			.recorder313			.weight_calls_budget(<StructureWeight<T>>::find_parent());314315		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)316			.map_err(dispatch_to_evm::<T>)?;317		Ok(true)318	}319320	/// @notice Returns collection helper contract address321	fn collection_helper_address(&self) -> Result<Address> {322		Ok(T::ContractAddress::get())323	}324}325326#[solidity_interface(327	name = UniqueFungible,328	is(329		ERC20,330		ERC20Mintable,331		ERC20UniqueExtensions,332		Collection(via(common_mut returns CollectionHandle<T>)),333	)334)]335impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}336337generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);338generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);339340impl<T: Config> CommonEvmHandler for FungibleHandle<T>341where342	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,343{344	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");345346	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {347		call::<T, UniqueFungibleCall<T>, _, _>(handle, self)348	}349}
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -165,8 +165,8 @@
 	pub type Allowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128, T::CrossAccountId>,
-			Key<Blake2_128Concat, T::CrossAccountId>,
+			Key<Blake2_128, T::CrossAccountId>,       // Owner
+			Key<Blake2_128Concat, T::CrossAccountId>, // Spender
 		),
 		Value = u128,
 		QueryKind = ValueQuery,
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
@@ -511,8 +511,22 @@
 	bytes value;
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x65789571
+/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
 contract ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev Function to check the amount of tokens that an owner allowed to a spender.
+	/// @param owner crossAddress The address which owns the funds.
+	/// @param spender crossAddress The address which will spend the funds.
+	/// @return A uint256 specifying the amount of tokens still available for the spender.
+	/// @dev EVM selector for this function is: 0xe0af4bd7,
+	///  or in textual repr: allowanceCross((address,uint256),(address,uint256))
+	function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) public view returns (uint256) {
+		require(false, stub_error);
+		owner;
+		spender;
+		dummy;
+		return 0;
+	}
+
 	/// @notice A description for the collection.
 	/// @dev EVM selector for this function is: 0x7284e416,
 	///  or in textual repr: description()
@@ -576,7 +590,7 @@
 	/// @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(Tuple9[] memory amounts) public returns (bool) {
+	function mintBulk(AmountForAddress[] memory amounts) public returns (bool) {
 		require(false, stub_error);
 		amounts;
 		dummy = 0;
@@ -618,10 +632,9 @@
 	}
 }
 
-/// @dev anonymous struct
-struct Tuple9 {
-	address field_0;
-	uint256 field_1;
+struct AmountForAddress {
+	address to;
+	uint256 amount;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x40c10f19
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -38,7 +38,7 @@
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
-	eth,
+	eth::{self, TokenUri},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
@@ -948,7 +948,7 @@
 		&mut self,
 		caller: Caller,
 		to: Address,
-		tokens: Vec<(U256, String)>,
+		tokens: Vec<TokenUri>,
 	) -> Result<bool> {
 		let key = key::url();
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -961,7 +961,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		let mut data = Vec::with_capacity(tokens.len());
-		for (id, token_uri) in tokens {
+		for TokenUri { id, uri } in tokens {
 			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
 			if id != expected_index {
 				return Err("item id should be next".into());
@@ -972,7 +972,7 @@
 			properties
 				.try_push(Property {
 					key: key.clone(),
-					value: token_uri
+					value: uri
 						.into_bytes()
 						.try_into()
 						.map_err(|_| "token uri is too long")?,
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -101,18 +101,18 @@
 };
 use up_data_structs::{
 	AccessMode, CollectionId, CollectionFlags, CustomDataLimit, TokenId, CreateCollectionData,
-	CreateNftExData, mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission,
-	PropertyKey, PropertyValue, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty,
-	TokenChild, AuxPropertyValue, PropertiesPermissionMap,
+	CreateNftExData, mapping::TokenAddressMapping, budget::Budget, Property, PropertyKey,
+	PropertyValue, PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild,
+	AuxPropertyValue, PropertiesPermissionMap,
 };
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_common::{
 	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
-	eth::collection_id_to_address, erc::CollectionHelpersEvents,
+	eth::collection_id_to_address,
 };
 use pallet_structure::{Pallet as PalletStructure, Error as StructureError};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use sp_core::{H160, Get};
+use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
 use core::ops::Deref;
@@ -578,10 +578,6 @@
 	}
 
 	/// A batch operation to add, edit or remove properties for a token.
-	/// It sets or removes a token's properties according to
-	/// `properties_updates` contents:
-	/// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`
-	/// * removes a property under the <key> if the value is `None` `(<key>, None)`.
 	///
 	/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
 	/// - `is_token_create`: Indicates that method is called during token initialization.
@@ -603,97 +599,30 @@
 		is_token_create: bool,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		let mut collection_admin_status = None;
-		let mut token_owner_result = None;
-
-		let mut is_collection_admin =
-			|| *collection_admin_status.get_or_insert_with(|| collection.is_owner_or_admin(sender));
+		let is_token_owner = || {
+			let is_owned = <PalletStructure<T>>::check_indirectly_owned(
+				sender.clone(),
+				collection.id,
+				token_id,
+				None,
+				nesting_budget,
+			)?;
 
-		let mut is_token_owner = || {
-			*token_owner_result.get_or_insert_with(|| -> Result<bool, DispatchError> {
-				let is_owned = <PalletStructure<T>>::check_indirectly_owned(
-					sender.clone(),
-					collection.id,
-					token_id,
-					None,
-					nesting_budget,
-				)?;
-
-				Ok(is_owned)
-			})
+			Ok(is_owned)
 		};
-
-		let mut stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
-		let permissions = <PalletCommon<T>>::property_permissions(collection.id);
-
-		for (key, value) in properties_updates {
-			let permission = permissions
-				.get(&key)
-				.cloned()
-				.unwrap_or_else(PropertyPermission::none);
-
-			let is_property_exists = stored_properties.get(&key).is_some();
-
-			match permission {
-				PropertyPermission { mutable: false, .. } if is_property_exists => {
-					return Err(<CommonError<T>>::NoPermission.into());
-				}
-
-				PropertyPermission {
-					collection_admin,
-					token_owner,
-					..
-				} => {
-					//TODO: investigate threats during public minting.
-					if is_token_create && (collection_admin || token_owner) && value.is_some() {
-						// Pass
-					} else if collection_admin && is_collection_admin() {
-						// Pass
-					} else if token_owner && is_token_owner()? {
-						// Pass
-					} else {
-						fail!(<CommonError<T>>::NoPermission);
-					}
-				}
-			}
 
-			match value {
-				Some(value) => {
-					stored_properties
-						.try_set(key.clone(), value)
-						.map_err(<CommonError<T>>::from)?;
-
-					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
-						collection.id,
-						token_id,
-						key,
-					));
-				}
-				None => {
-					stored_properties
-						.remove(&key)
-						.map_err(<CommonError<T>>::from)?;
-
-					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(
-						collection.id,
-						token_id,
-						key,
-					));
-				}
-			}
-
-			<PalletEvm<T>>::deposit_log(
-				CollectionHelpersEvents::TokenChanged {
-					collection_id: collection_id_to_address(collection.id),
-					token_id: token_id.into(),
-				}
-				.to_log(T::ContractAddress::get()),
-			);
-		}
-
-		<TokenProperties<T>>::set((collection.id, token_id), stored_properties);
+		let stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
 
-		Ok(())
+		<PalletCommon<T>>::modify_token_properties(
+			collection,
+			sender,
+			token_id,
+			properties_updates,
+			is_token_create,
+			stored_properties,
+			is_token_owner,
+			|properties| <TokenProperties<T>>::set((collection.id, token_id), properties),
+		)
 	}
 
 	/// Batch operation to add or edit properties for the token
@@ -1418,31 +1347,19 @@
 		operator: &T::CrossAccountId,
 		approve: bool,
 	) -> DispatchResult {
-		if collection.permissions.access() == AccessMode::AllowList {
-			collection.check_allowlist(owner)?;
-			collection.check_allowlist(operator)?;
-		}
-
-		<PalletCommon<T>>::ensure_correct_receiver(operator)?;
-
-		// =========
-
-		<CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);
-		<PalletEvm<T>>::deposit_log(
+		<PalletCommon<T>>::set_allowance_for_all(
+			collection,
+			owner,
+			operator,
+			approve,
+			|| <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve),
 			ERC721Events::ApprovalForAll {
 				owner: *owner.as_eth(),
 				operator: *operator.as_eth(),
 				approved: approve,
 			}
 			.to_log(collection_id_to_address(collection.id)),
-		);
-		<PalletCommon<T>>::deposit_event(CommonEvent::ApprovedForAll(
-			collection.id,
-			owner.clone(),
-			operator.clone(),
-			approve,
-		));
-		Ok(())
+		)
 	}
 
 	/// Tells whether the given `owner` approves the `operator`.
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
@@ -949,7 +949,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, Tuple15[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -981,10 +981,12 @@
 	}
 }
 
-/// @dev anonymous struct
-struct Tuple15 {
-	uint256 field_0;
-	string field_1;
+/// Data for creation token with uri.
+struct TokenUri {
+	/// Id of new token.
+	uint256 id;
+	/// Uri of new token.
+	string uri;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.2.13] - 2023-02-01
+
+### Added
+
+- The functions `allowanceCross` to `ERC20UniqueExtensions` interface.
+
 ## [0.2.12] - 2023-01-20
 
 ### Fixed
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-refungible"
-version = "0.2.12"
+version = "0.2.13"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -34,7 +34,7 @@
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	Error as CommonError,
 	erc::{CommonEvmHandler, CollectionCall, static_property::key},
-	eth,
+	eth::{self, TokenUri},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm};
@@ -999,7 +999,7 @@
 		&mut self,
 		caller: Caller,
 		to: Address,
-		tokens: Vec<(U256, String)>,
+		tokens: Vec<TokenUri>,
 	) -> Result<bool> {
 		let key = key::url();
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -1017,7 +1017,7 @@
 			.collect::<BTreeMap<_, _>>()
 			.try_into()
 			.unwrap();
-		for (id, token_uri) in tokens {
+		for TokenUri { id, uri } in tokens {
 			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;
 			if id != expected_index {
 				return Err("item id should be next".into());
@@ -1028,7 +1028,7 @@
 			properties
 				.try_push(Property {
 					key: key.clone(),
-					value: token_uri
+					value: uri
 						.into_bytes()
 						.try_into()
 						.map_err(|_| "token uri is too long")?,
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -31,7 +31,7 @@
 use pallet_common::{
 	CommonWeightInfo,
 	erc::{CommonEvmHandler, PrecompileResult},
-	eth::collection_id_to_address,
+	eth::{collection_id_to_address, CrossAddress},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};
@@ -203,6 +203,17 @@
 where
 	T::AccountId: From<[u8; 32]>,
 {
+	/// @dev Function to check the amount of tokens that an owner allowed to a spender.
+	/// @param owner crossAddress The address which owns the funds.
+	/// @param spender crossAddress The address which will spend the funds.
+	/// @return A uint256 specifying the amount of tokens still available for the spender.
+	fn allowance_cross(&self, owner: CrossAddress, spender: CrossAddress) -> Result<U256> {
+		let owner = owner.into_sub_cross_account::<T>()?;
+		let spender = spender.into_sub_cross_account::<T>()?;
+
+		Ok(<Allowance<T>>::get((self.id, self.1, owner, spender)).into())
+	}
+
 	/// @dev Function that burns an amount of the token of a given account,
 	/// deducting from the sender's allowance for said account.
 	/// @param from The account whose tokens will be burnt.
@@ -230,7 +241,7 @@
 	fn burn_from_cross(
 		&mut self,
 		caller: Caller,
-		from: pallet_common::eth::CrossAddress,
+		from: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -256,7 +267,7 @@
 	fn approve_cross(
 		&mut self,
 		caller: Caller,
-		spender: pallet_common::eth::CrossAddress,
+		spender: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -283,12 +294,7 @@
 	/// @param to The crossaccount to transfer to.
 	/// @param amount The amount to be transferred.
 	#[weight(<CommonWeights<T>>::transfer())]
-	fn transfer_cross(
-		&mut self,
-		caller: Caller,
-		to: pallet_common::eth::CrossAddress,
-		amount: U256,
-	) -> Result<bool> {
+	fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = to.into_sub_cross_account::<T>()?;
 		let amount = amount.try_into().map_err(|_| "amount overflow")?;
@@ -309,8 +315,8 @@
 	fn transfer_from_cross(
 		&mut self,
 		caller: Caller,
-		from: pallet_common::eth::CrossAddress,
-		to: pallet_common::eth::CrossAddress,
+		from: CrossAddress,
+		to: CrossAddress,
 		amount: U256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -92,22 +92,22 @@
 
 use core::ops::Deref;
 use evm_coder::ToLog;
-use frame_support::{ensure, fail, storage::with_transaction, transactional};
+use frame_support::{ensure, storage::with_transaction, transactional};
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_evm_coder_substrate::WithRecorder;
 use pallet_common::{
 	CommonCollectionOperations, Error as CommonError, eth::collection_id_to_address,
-	Event as CommonEvent, Pallet as PalletCommon, erc::CollectionHelpersEvents,
+	Event as CommonEvent, Pallet as PalletCommon,
 };
 use pallet_structure::Pallet as PalletStructure;
-use sp_core::{Get, H160};
+use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
 use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
 use up_data_structs::{
 	AccessMode, budget::Budget, CollectionId, CollectionFlags, CreateCollectionData,
 	mapping::TokenAddressMapping, MAX_REFUNGIBLE_PIECES, Property, PropertyKey,
-	PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue, TokenId,
-	TrySetProperty, PropertiesPermissionMap, CreateRefungibleExMultipleOwners, TokenOwnerError,
+	PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TrySetProperty,
+	PropertiesPermissionMap, CreateRefungibleExMultipleOwners, TokenOwnerError,
 };
 
 pub use pallet::*;
@@ -240,13 +240,13 @@
 		QueryKind = ValueQuery,
 	>;
 
-	/// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.
+	/// Spender set by a wallet owner that could perform certain transactions on all tokens in the wallet.
 	#[pallet::storage]
 	pub type CollectionAllowance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128Concat, T::CrossAccountId>,
-			Key<Blake2_128Concat, T::CrossAccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>, // Owner
+			Key<Blake2_128Concat, T::CrossAccountId>, // Spender
 		),
 		Value = bool,
 		QueryKind = ValueQuery,
@@ -541,7 +541,6 @@
 		is_token_create: bool,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		let is_collection_admin = || collection.is_owner_or_admin(sender);
 		let is_token_owner = || -> Result<bool, DispatchError> {
 			let balance = collection.balance(sender.clone(), token_id);
 			let total_pieces: u128 =
@@ -560,77 +559,19 @@
 
 			Ok(is_bundle_owner)
 		};
-
-		let mut stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
-		let permissions = <PalletCommon<T>>::property_permissions(collection.id);
-
-		for (key, value) in properties_updates {
-			let permission = permissions
-				.get(&key)
-				.cloned()
-				.unwrap_or_else(PropertyPermission::none);
-
-			let is_property_exists = stored_properties.get(&key).is_some();
-
-			match permission {
-				PropertyPermission { mutable: false, .. } if is_property_exists => {
-					return Err(<CommonError<T>>::NoPermission.into());
-				}
 
-				PropertyPermission {
-					collection_admin,
-					token_owner,
-					..
-				} => {
-					//TODO: investigate threats during public minting.
-					let is_token_create =
-						is_token_create && (collection_admin || token_owner) && value.is_some();
-					if !(is_token_create
-						|| (collection_admin && is_collection_admin())
-						|| (token_owner && is_token_owner()?))
-					{
-						fail!(<CommonError<T>>::NoPermission);
-					}
-				}
-			}
-
-			match value {
-				Some(value) => {
-					stored_properties
-						.try_set(key.clone(), value)
-						.map_err(<CommonError<T>>::from)?;
-
-					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(
-						collection.id,
-						token_id,
-						key,
-					));
-				}
-				None => {
-					stored_properties
-						.remove(&key)
-						.map_err(<CommonError<T>>::from)?;
-
-					<PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(
-						collection.id,
-						token_id,
-						key,
-					));
-				}
-			}
-
-			<PalletEvm<T>>::deposit_log(
-				CollectionHelpersEvents::TokenChanged {
-					collection_id: collection_id_to_address(collection.id),
-					token_id: token_id.into(),
-				}
-				.to_log(T::ContractAddress::get()),
-			);
-		}
+		let stored_properties = <TokenProperties<T>>::get((collection.id, token_id));
 
-		<TokenProperties<T>>::set((collection.id, token_id), stored_properties);
-
-		Ok(())
+		<PalletCommon<T>>::modify_token_properties(
+			collection,
+			sender,
+			token_id,
+			properties_updates,
+			is_token_create,
+			stored_properties,
+			is_token_owner,
+			|properties| <TokenProperties<T>>::set((collection.id, token_id), properties),
+		)
 	}
 
 	pub fn set_token_properties(
@@ -1462,43 +1403,31 @@
 	pub fn set_allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
-		operator: &T::CrossAccountId,
+		spender: &T::CrossAccountId,
 		approve: bool,
 	) -> DispatchResult {
-		if collection.permissions.access() == AccessMode::AllowList {
-			collection.check_allowlist(owner)?;
-			collection.check_allowlist(operator)?;
-		}
-
-		<PalletCommon<T>>::ensure_correct_receiver(operator)?;
-
-		// =========
-
-		<CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);
-		<PalletEvm<T>>::deposit_log(
+		<PalletCommon<T>>::set_allowance_for_all(
+			collection,
+			owner,
+			spender,
+			approve,
+			|| <CollectionAllowance<T>>::insert((collection.id, owner, spender), approve),
 			ERC721Events::ApprovalForAll {
 				owner: *owner.as_eth(),
-				operator: *operator.as_eth(),
+				operator: *spender.as_eth(),
 				approved: approve,
 			}
 			.to_log(collection_id_to_address(collection.id)),
-		);
-		<PalletCommon<T>>::deposit_event(CommonEvent::ApprovedForAll(
-			collection.id,
-			owner.clone(),
-			operator.clone(),
-			approve,
-		));
-		Ok(())
+		)
 	}
 
 	/// Tells whether the given `owner` approves the `operator`.
 	pub fn allowance_for_all(
 		collection: &RefungibleHandle<T>,
 		owner: &T::CrossAccountId,
-		operator: &T::CrossAccountId,
+		spender: &T::CrossAccountId,
 	) -> bool {
-		<CollectionAllowance<T>>::get((collection.id, owner, operator))
+		<CollectionAllowance<T>>::get((collection.id, owner, spender))
 	}
 
 	pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {
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
@@ -938,7 +938,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, Tuple14[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -982,10 +982,12 @@
 	}
 }
 
-/// @dev anonymous struct
-struct Tuple14 {
-	uint256 field_0;
-	string field_1;
+/// Data for creation token with uri.
+struct TokenUri {
+	/// Id of new token.
+	uint256 id;
+	/// Uri of new token.
+	string uri;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungibleToken.sol
@@ -36,8 +36,22 @@
 	}
 }
 
-/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
+/// @dev the ERC-165 identifier for this interface is 0x01d536fc
 contract ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev Function to check the amount of tokens that an owner allowed to a spender.
+	/// @param owner crossAddress The address which owns the funds.
+	/// @param spender crossAddress The address which will spend the funds.
+	/// @return A uint256 specifying the amount of tokens still available for the spender.
+	/// @dev EVM selector for this function is: 0xe0af4bd7,
+	///  or in textual repr: allowanceCross((address,uint256),(address,uint256))
+	function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) public view returns (uint256) {
+		require(false, stub_error);
+		owner;
+		spender;
+		dummy;
+		return 0;
+	}
+
 	// /// @dev Function that burns an amount of the token of a given account,
 	// /// deducting from the sender's allowance for said account.
 	// /// @param from The account whose tokens will be burnt.
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedruntime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring/refungible.rs
+++ b/runtime/common/ethereum/sponsoring/refungible.rs
@@ -341,7 +341,9 @@
 			ERC165Call(_, _) => None,
 
 			// Not sponsored
-			BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => None,
+			AllowanceCross { .. } | BurnFrom { .. } | BurnFromCross { .. } | Repartition { .. } => {
+				None
+			}
 
 			TransferCross { .. } | TransferFromCross { .. } => {
 				let RefungibleTokenHandle(handle, token_id) = token;
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -101,6 +101,32 @@
           { "internalType": "uint256", "name": "sub", "type": "uint256" }
         ],
         "internalType": "struct CrossAddress",
+        "name": "owner",
+        "type": "tuple"
+      },
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct CrossAddress",
+        "name": "spender",
+        "type": "tuple"
+      }
+    ],
+    "name": "allowanceCross",
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct CrossAddress",
         "name": "user",
         "type": "tuple"
       }
@@ -408,10 +434,10 @@
     "inputs": [
       {
         "components": [
-          { "internalType": "address", "name": "field_0", "type": "address" },
-          { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+          { "internalType": "address", "name": "to", "type": "address" },
+          { "internalType": "uint256", "name": "amount", "type": "uint256" }
         ],
-        "internalType": "struct Tuple9[]",
+        "internalType": "struct AmountForAddress[]",
         "name": "amounts",
         "type": "tuple[]"
       }
modifiedtests/src/eth/abi/reFungibleToken.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungibleToken.json
+++ b/tests/src/eth/abi/reFungibleToken.json
@@ -61,6 +61,32 @@
   },
   {
     "inputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct CrossAddress",
+        "name": "owner",
+        "type": "tuple"
+      },
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct CrossAddress",
+        "name": "spender",
+        "type": "tuple"
+      }
+    ],
+    "name": "allowanceCross",
+    "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "address", "name": "spender", "type": "address" },
       { "internalType": "uint256", "name": "amount", "type": "uint256" }
     ],
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -353,8 +353,16 @@
 	bytes value;
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x65789571
+/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
 interface ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev Function to check the amount of tokens that an owner allowed to a spender.
+	/// @param owner crossAddress The address which owns the funds.
+	/// @param spender crossAddress The address which will spend the funds.
+	/// @return A uint256 specifying the amount of tokens still available for the spender.
+	/// @dev EVM selector for this function is: 0xe0af4bd7,
+	///  or in textual repr: allowanceCross((address,uint256),(address,uint256))
+	function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) external view returns (uint256);
+
 	/// @notice A description for the collection.
 	/// @dev EVM selector for this function is: 0x7284e416,
 	///  or in textual repr: description()
@@ -390,7 +398,7 @@
 	/// @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(Tuple9[] memory amounts) external returns (bool);
+	function mintBulk(AmountForAddress[] memory amounts) external returns (bool);
 
 	/// @dev EVM selector for this function is: 0x2ada85ff,
 	///  or in textual repr: transferCross((address,uint256),uint256)
@@ -410,10 +418,9 @@
 	function collectionHelperAddress() external view returns (address);
 }
 
-/// @dev anonymous struct
-struct Tuple9 {
-	address field_0;
-	uint256 field_1;
+struct AmountForAddress {
+	address to;
+	uint256 amount;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x40c10f19
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -644,7 +644,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, Tuple13[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) external returns (bool);
 
 	/// @notice Function to mint a token.
 	/// @param to The new owner crossAccountId
@@ -660,10 +660,12 @@
 	function collectionHelperAddress() external view returns (address);
 }
 
-/// @dev anonymous struct
-struct Tuple13 {
-	uint256 field_0;
-	string field_1;
+/// Data for creation token with uri.
+struct TokenUri {
+	/// Id of new token.
+	uint256 id;
+	/// Uri of new token.
+	string uri;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -638,7 +638,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, Tuple12[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, TokenUri[] memory tokens) external returns (bool);
 
 	/// @notice Function to mint a token.
 	/// @param to The new owner crossAccountId
@@ -661,10 +661,12 @@
 	function collectionHelperAddress() external view returns (address);
 }
 
-/// @dev anonymous struct
-struct Tuple12 {
-	uint256 field_0;
-	string field_1;
+/// Data for creation token with uri.
+struct TokenUri {
+	/// Id of new token.
+	uint256 id;
+	/// Uri of new token.
+	string uri;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
modifiedtests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungibleToken.sol
+++ b/tests/src/eth/api/UniqueRefungibleToken.sol
@@ -23,8 +23,16 @@
 	function parentTokenId() external view returns (uint256);
 }
 
-/// @dev the ERC-165 identifier for this interface is 0xe17a7d2b
+/// @dev the ERC-165 identifier for this interface is 0x01d536fc
 interface ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @dev Function to check the amount of tokens that an owner allowed to a spender.
+	/// @param owner crossAddress The address which owns the funds.
+	/// @param spender crossAddress The address which will spend the funds.
+	/// @return A uint256 specifying the amount of tokens still available for the spender.
+	/// @dev EVM selector for this function is: 0xe0af4bd7,
+	///  or in textual repr: allowanceCross((address,uint256),(address,uint256))
+	function allowanceCross(CrossAddress memory owner, CrossAddress memory spender) external view returns (uint256);
+
 	// /// @dev Function that burns an amount of the token of a given account,
 	// /// deducting from the sender's allowance for said account.
 	// /// @param from The account whose tokens will be burnt.
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -134,6 +134,12 @@
       const allowance = await contract.methods.allowance(owner, spender).call();
       expect(+allowance).to.equal(100);
     }
+    {
+      const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+      const spenderCross = helper.ethCrossAccount.fromAddress(spender);
+      const allowance = await contract.methods.allowanceCross(ownerCross, spenderCross).call();
+      expect(+allowance).to.equal(100);
+    }
   });
 
   itEth('Can perform approveCross()', async ({helper}) => {
modifiedtests/src/eth/proxy/UniqueNFTProxy.soldiffbeforeafterboth
--- a/tests/src/eth/proxy/UniqueNFTProxy.sol
+++ b/tests/src/eth/proxy/UniqueNFTProxy.sol
@@ -168,7 +168,7 @@
         return proxied.mintBulk(to, tokenIds);
     }
 
-    function mintBulkWithTokenURI(address to, Tuple6[] memory tokens)
+    function mintBulkWithTokenURI(address to, TokenUri[] memory tokens)
         external
         override
         returns (bool)
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -219,8 +219,16 @@
       await rftToken.methods.approve(operator, 15n).send({from: owner});
       await contract.methods.setApprovalForAll(operator, true).send({from: owner});
       await rftToken.methods.burnFrom(owner, 10n).send({from: operator});
+    }
+    {
       const allowance = await rftToken.methods.allowance(owner, operator).call();
-      expect(allowance).to.be.equal('5');
+      expect(+allowance).to.be.equal(5);
+    }
+    {
+      const ownerCross = helper.ethCrossAccount.fromAddress(owner);
+      const operatorCross = helper.ethCrossAccount.fromAddress(operator);
+      const allowance = await rftToken.methods.allowanceCross(ownerCross, operatorCross).call();
+      expect(+allowance).to.equal(5);
     }
   });