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

difftreelog

feat Rewrite tuple to named structures for CollectionLimits.

Trubnikov Sergey2022-12-20parent: #8298cf8.patch.diff
in: master

21 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -36,7 +36,7 @@
 	Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
 	eth::{
 		Property as PropertyStruct, EthCrossAccount, CollectionPermissions as EvmPermissions,
-		CollectionLimits as EvmCollectionLimits,
+		CollectionLimitField as EvmCollectionLimits, self,
 	},
 	weights::WeightInfo,
 };
@@ -299,52 +299,16 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
-	fn collection_limits(&self) -> Result<Vec<(EvmCollectionLimits, bool, uint256)>> {
-		let convert_value_limit = |limit: EvmCollectionLimits,
-		                           value: Option<u32>|
-		 -> (EvmCollectionLimits, bool, uint256) {
-			value
-				.map(|v| (limit, true, v.into()))
-				.unwrap_or((limit, false, Default::default()))
-		};
-
-		let convert_bool_limit = |limit: EvmCollectionLimits,
-		                          value: Option<bool>|
-		 -> (EvmCollectionLimits, bool, uint256) {
-			value
-				.map(|v| {
-					(
-						limit,
-						true,
-						if v {
-							uint256::from(1)
-						} else {
-							Default::default()
-						},
-					)
-				})
-				.unwrap_or((limit, false, Default::default()))
-		};
-
+	/// @return Array of collection limits
+	fn collection_limits(&self) -> Result<Vec<eth::CollectionLimit>> {
 		let limits = &self.collection.limits;
 
 		Ok(vec![
-			convert_value_limit(
+			eth::CollectionLimit::from_opt_int(
 				EvmCollectionLimits::AccountTokenOwnership,
 				limits.account_token_ownership_limit,
 			),
-			convert_value_limit(
+			eth::CollectionLimit::from_opt_int(
 				EvmCollectionLimits::SponsoredDataSize,
 				limits.sponsored_data_size,
 			),
@@ -352,38 +316,36 @@
 				.sponsored_data_rate_limit
 				.and_then(|limit| {
 					if let SponsoringRateLimit::Blocks(blocks) = limit {
-						Some((
+						Some(eth::CollectionLimit::from_int(
 							EvmCollectionLimits::SponsoredDataRateLimit,
-							true,
-							blocks.into(),
+							blocks,
 						))
 					} else {
 						None
 					}
 				})
-				.unwrap_or((
+				.unwrap_or(eth::CollectionLimit::from_int(
 					EvmCollectionLimits::SponsoredDataRateLimit,
-					false,
 					Default::default(),
 				)),
-			convert_value_limit(EvmCollectionLimits::TokenLimit, limits.token_limit),
-			convert_value_limit(
+			eth::CollectionLimit::from_opt_int(EvmCollectionLimits::TokenLimit, limits.token_limit),
+			eth::CollectionLimit::from_opt_int(
 				EvmCollectionLimits::SponsorTransferTimeout,
 				limits.sponsor_transfer_timeout,
 			),
-			convert_value_limit(
+			eth::CollectionLimit::from_opt_int(
 				EvmCollectionLimits::SponsorApproveTimeout,
 				limits.sponsor_approve_timeout,
 			),
-			convert_bool_limit(
+			eth::CollectionLimit::from_opt_bool(
 				EvmCollectionLimits::OwnerCanTransfer,
 				limits.owner_can_transfer,
 			),
-			convert_bool_limit(
+			eth::CollectionLimit::from_opt_bool(
 				EvmCollectionLimits::OwnerCanDestroy,
 				limits.owner_can_destroy,
 			),
-			convert_bool_limit(
+			eth::CollectionLimit::from_opt_bool(
 				EvmCollectionLimits::TransferEnabled,
 				limits.transfers_enabled,
 			),
@@ -392,82 +354,17 @@
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
+	/// @param limit Some limit.
 	#[solidity(rename_selector = "setCollectionLimit")]
 	fn set_collection_limit(
 		&mut self,
 		caller: caller,
-		limit: EvmCollectionLimits,
-		status: bool,
-		value: uint256,
+		limit: eth::CollectionLimit,
 	) -> Result<void> {
 		self.consume_store_reads_and_writes(1, 1)?;
-
-		if !status {
-			return Err(Error::Revert("user can't disable limits".into()));
-		}
-
-		let value = value
-			.try_into()
-			.map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;
-
-		let convert_value_to_bool = || match value {
-			0 => Ok(false),
-			1 => Ok(true),
-			_ => {
-				return Err(Error::Revert(format!(
-					"can't convert value to boolean \"{}\"",
-					value
-				)))
-			}
-		};
-
-		let mut limits = self.limits.clone();
-
-		match limit {
-			EvmCollectionLimits::AccountTokenOwnership => {
-				limits.account_token_ownership_limit = Some(value);
-			}
-			EvmCollectionLimits::SponsoredDataSize => {
-				limits.sponsored_data_size = Some(value);
-			}
-			EvmCollectionLimits::SponsoredDataRateLimit => {
-				limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));
-			}
-			EvmCollectionLimits::TokenLimit => {
-				limits.token_limit = Some(value);
-			}
-			EvmCollectionLimits::SponsorTransferTimeout => {
-				limits.sponsor_transfer_timeout = Some(value);
-			}
-			EvmCollectionLimits::SponsorApproveTimeout => {
-				limits.sponsor_approve_timeout = Some(value);
-			}
-			EvmCollectionLimits::OwnerCanTransfer => {
-				limits.owner_can_transfer = Some(convert_value_to_bool()?);
-			}
-			EvmCollectionLimits::OwnerCanDestroy => {
-				limits.owner_can_destroy = Some(convert_value_to_bool()?);
-			}
-			EvmCollectionLimits::TransferEnabled => {
-				limits.transfers_enabled = Some(convert_value_to_bool()?);
-			}
-			_ => return Err(Error::Revert(format!("unknown limit \"{:?}\"", limit))),
-		}
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		<Pallet<T>>::update_limits(&caller, self, limits).map_err(dispatch_to_evm::<T>)
+		<Pallet<T>>::update_limits(&caller, self, limit.try_into()?).map_err(dispatch_to_evm::<T>)
 	}
 
 	/// Get contract address.
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -16,6 +16,7 @@
 
 //! The module contains a number of functions for converting and checking ethereum identifiers.
 
+use alloc::format;
 use sp_std::{vec, vec::Vec};
 use evm_coder::{
 	AbiCoder,
@@ -129,7 +130,7 @@
 /// [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
 #[derive(Debug, Default, Clone, Copy, AbiCoder)]
 #[repr(u8)]
-pub enum CollectionLimits {
+pub enum CollectionLimitField {
 	/// How many tokens can a user have on one account.
 	#[default]
 	AccountTokenOwnership,
@@ -158,6 +159,116 @@
 	/// Is it possible to send tokens from this collection between users.
 	TransferEnabled,
 }
+
+#[derive(Debug, Default, AbiCoder)]
+pub struct CollectionLimit {
+	field: CollectionLimitField,
+	status: bool,
+	value: uint256,
+}
+
+impl CollectionLimit {
+	pub fn from_int(field: CollectionLimitField, value: u32) -> Self {
+		Self {
+			field,
+			status: true,
+			value: value.into(),
+		}
+	}
+
+	pub fn from_opt_int(field: CollectionLimitField, value: Option<u32>) -> Self {
+		value
+			.map(|v| Self {
+				field,
+				status: true,
+				value: v.into(),
+			})
+			.unwrap_or(Self {
+				field,
+				status: false,
+				value: Default::default(),
+			})
+	}
+
+	pub fn from_opt_bool(field: CollectionLimitField, value: Option<bool>) -> Self {
+		value
+			.map(|v| Self {
+				field,
+				status: true,
+				value: if v {
+					uint256::from(1)
+				} else {
+					Default::default()
+				},
+			})
+			.unwrap_or(Self {
+				field,
+				status: false,
+				value: Default::default(),
+			})
+	}
+}
+
+impl TryInto<up_data_structs::CollectionLimits> for CollectionLimit {
+	type Error = evm_coder::execution::Error;
+
+	fn try_into(self) -> Result<up_data_structs::CollectionLimits, Self::Error> {
+		if !self.status {
+			return Err(Self::Error::Revert("user can't disable limits".into()));
+		}
+
+		let value = self.value.try_into().map_err(|error| {
+			Self::Error::Revert(format!(
+				"can't convert value to u32 \"{}\" because: \"{error}\"",
+				self.value
+			))
+		})?;
+
+		let convert_value_to_bool = || match value {
+			0 => Ok(false),
+			1 => Ok(true),
+			_ => {
+				return Err(Self::Error::Revert(format!(
+					"can't convert value to boolean \"{value}\""
+				)))
+			}
+		};
+
+		let mut limits = up_data_structs::CollectionLimits::default();
+		match self.field {
+			CollectionLimitField::AccountTokenOwnership => {
+				limits.account_token_ownership_limit = Some(value);
+			}
+			CollectionLimitField::SponsoredDataSize => {
+				limits.sponsored_data_size = Some(value);
+			}
+			CollectionLimitField::SponsoredDataRateLimit => {
+				limits.sponsored_data_rate_limit =
+					Some(up_data_structs::SponsoringRateLimit::Blocks(value));
+			}
+			CollectionLimitField::TokenLimit => {
+				limits.token_limit = Some(value);
+			}
+			CollectionLimitField::SponsorTransferTimeout => {
+				limits.sponsor_transfer_timeout = Some(value);
+			}
+			CollectionLimitField::SponsorApproveTimeout => {
+				limits.sponsor_approve_timeout = Some(value);
+			}
+			CollectionLimitField::OwnerCanTransfer => {
+				limits.owner_can_transfer = Some(convert_value_to_bool()?);
+			}
+			CollectionLimitField::OwnerCanDestroy => {
+				limits.owner_can_destroy = Some(convert_value_to_bool()?);
+			}
+			CollectionLimitField::TransferEnabled => {
+				limits.transfers_enabled = Some(convert_value_to_bool()?);
+			}
+		};
+		Ok(limits)
+	}
+}
+
 /// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
 #[derive(Default, Debug, Clone, Copy, AbiCoder)]
 #[repr(u8)]
@@ -173,7 +284,7 @@
 /// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
 #[derive(AbiCoder, Copy, Clone, Default, Debug)]
 #[repr(u8)]
-pub enum EthTokenPermissions {
+pub enum TokenPermissionField {
 	/// Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
 	#[default]
 	Mutable,
@@ -189,7 +300,7 @@
 #[derive(Debug, Default, AbiCoder)]
 pub struct PropertyPermission {
 	/// TokenPermission field.
-	code: EthTokenPermissions,
+	code: TokenPermissionField,
 	/// TokenPermission value.
 	value: bool,
 }
@@ -198,15 +309,15 @@
 	pub fn into_vec(pp: up_data_structs::PropertyPermission) -> Vec<Self> {
 		vec![
 			PropertyPermission {
-				code: EthTokenPermissions::Mutable,
+				code: TokenPermissionField::Mutable,
 				value: pp.mutable,
 			},
 			PropertyPermission {
-				code: EthTokenPermissions::TokenOwner,
+				code: TokenPermissionField::TokenOwner,
 				value: pp.token_owner,
 			},
 			PropertyPermission {
-				code: EthTokenPermissions::CollectionAdmin,
+				code: TokenPermissionField::CollectionAdmin,
 				value: pp.collection_admin,
 			},
 		]
@@ -217,9 +328,9 @@
 
 		for PropertyPermission { code, value } in permission {
 			match code {
-				EthTokenPermissions::Mutable => token_permission.mutable = value,
-				EthTokenPermissions::TokenOwner => token_permission.token_owner = value,
-				EthTokenPermissions::CollectionAdmin => token_permission.collection_admin = value,
+				TokenPermissionField::Mutable => token_permission.mutable = value,
+				TokenPermissionField::TokenOwner => token_permission.token_owner = value,
+				TokenPermissionField::CollectionAdmin => token_permission.collection_admin = value,
 			}
 		}
 		token_permission
@@ -262,12 +373,12 @@
 		let mut perms = Vec::new();
 
 		for TokenPropertyPermission { key, permissions } in permissions {
-			if permissions.len() > <EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT {
+			if permissions.len() > <TokenPermissionField as evm_coder::abi::AbiType>::FIELDS_COUNT {
 				return Err(alloc::format!(
 					"Actual number of fields {} for {}, which exceeds the maximum value of {}",
 					permissions.len(),
 					stringify!(EthTokenPermissions),
-					<EthTokenPermissions as evm_coder::abi::AbiType>::FIELDS_COUNT
+					<TokenPermissionField as evm_coder::abi::AbiType>::FIELDS_COUNT
 				)
 				.as_str()
 				.into());
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 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -160,50 +160,23 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() public view returns (Tuple23[] memory) {
+	function collectionLimits() public view returns (CollectionLimit[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple23[](0);
+		return new CollectionLimit[](0);
 	}
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) public {
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) public {
 		require(false, stub_error);
 		limit;
-		status;
-		value;
 		dummy = 0;
 	}
 
@@ -284,19 +257,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple29 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (Tuple30 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple29(false, new uint256[](0));
+		return Tuple30(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple32[] memory) {
+	function collectionNestingPermissions() public view returns (Tuple33[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple32[](0);
+		return new Tuple33[](0);
 	}
 
 	/// Set the collection access method.
@@ -479,19 +452,25 @@
 }
 
 /// @dev anonymous struct
-struct Tuple32 {
+struct Tuple33 {
 	CollectionPermissions field_0;
 	bool field_1;
 }
 
 /// @dev anonymous struct
-struct Tuple29 {
+struct Tuple30 {
 	bool field_0;
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -510,13 +489,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple23 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
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
@@ -146,13 +146,13 @@
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
 struct PropertyPermission {
 	/// @dev TokenPermission field.
-	EthTokenPermissions code;
+	TokenPermissionField code;
 	/// @dev TokenPermission value.
 	bool value;
 }
 
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
-enum EthTokenPermissions {
+enum TokenPermissionField {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
 	Mutable,
 	/// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
@@ -162,7 +162,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -304,50 +304,23 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() public view returns (Tuple35[] memory) {
+	function collectionLimits() public view returns (CollectionLimit[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple35[](0);
+		return new CollectionLimit[](0);
 	}
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) public {
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) public {
 		require(false, stub_error);
 		limit;
-		status;
-		value;
 		dummy = 0;
 	}
 
@@ -428,19 +401,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (Tuple42 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple41(false, new uint256[](0));
+		return Tuple42(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple44[] memory) {
+	function collectionNestingPermissions() public view returns (Tuple45[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple44[](0);
+		return new Tuple45[](0);
 	}
 
 	/// Set the collection access method.
@@ -623,19 +596,25 @@
 }
 
 /// @dev anonymous struct
-struct Tuple44 {
+struct Tuple45 {
 	CollectionPermissions field_0;
 	bool field_1;
 }
 
 /// @dev anonymous struct
-struct Tuple41 {
+struct Tuple42 {
 	bool field_0;
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -654,13 +633,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple35 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
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
@@ -146,13 +146,13 @@
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
 struct PropertyPermission {
 	/// @dev TokenPermission field.
-	EthTokenPermissions code;
+	TokenPermissionField code;
 	/// @dev TokenPermission value.
 	bool value;
 }
 
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
-enum EthTokenPermissions {
+enum TokenPermissionField {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
 	Mutable,
 	/// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
@@ -162,7 +162,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -304,50 +304,23 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() public view returns (Tuple34[] memory) {
+	function collectionLimits() public view returns (CollectionLimit[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple34[](0);
+		return new CollectionLimit[](0);
 	}
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) public {
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) public {
 		require(false, stub_error);
 		limit;
-		status;
-		value;
 		dummy = 0;
 	}
 
@@ -428,19 +401,19 @@
 	/// Returns nesting for a collection
 	/// @dev EVM selector for this function is: 0x22d25bfe,
 	///  or in textual repr: collectionNestingRestrictedCollectionIds()
-	function collectionNestingRestrictedCollectionIds() public view returns (Tuple40 memory) {
+	function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple40(false, new uint256[](0));
+		return Tuple41(false, new uint256[](0));
 	}
 
 	/// Returns permissions for a collection
 	/// @dev EVM selector for this function is: 0x5b2eaf4b,
 	///  or in textual repr: collectionNestingPermissions()
-	function collectionNestingPermissions() public view returns (Tuple43[] memory) {
+	function collectionNestingPermissions() public view returns (Tuple44[] memory) {
 		require(false, stub_error);
 		dummy;
-		return new Tuple43[](0);
+		return new Tuple44[](0);
 	}
 
 	/// Set the collection access method.
@@ -623,19 +596,25 @@
 }
 
 /// @dev anonymous struct
-struct Tuple43 {
+struct Tuple44 {
 	CollectionPermissions field_0;
 	bool field_1;
 }
 
 /// @dev anonymous struct
-struct Tuple40 {
+struct Tuple41 {
 	bool field_0;
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -654,13 +633,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple34 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -213,14 +213,14 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionLimits",
-            "name": "field_0",
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" },
-          { "internalType": "uint256", "name": "field_2", "type": "uint256" }
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
         ],
-        "internalType": "struct Tuple23[]",
+        "internalType": "struct CollectionLimit[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -241,7 +241,7 @@
           },
           { "internalType": "bool", "name": "field_1", "type": "bool" }
         ],
-        "internalType": "struct Tuple32[]",
+        "internalType": "struct Tuple33[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -262,7 +262,7 @@
             "type": "uint256[]"
           }
         ],
-        "internalType": "struct Tuple29",
+        "internalType": "struct Tuple30",
         "name": "",
         "type": "tuple"
       }
@@ -494,12 +494,19 @@
   {
     "inputs": [
       {
-        "internalType": "enum CollectionLimits",
+        "components": [
+          {
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
+            "type": "uint8"
+          },
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
+        ],
+        "internalType": "struct CollectionLimit",
         "name": "limit",
-        "type": "uint8"
-      },
-      { "internalType": "bool", "name": "status", "type": "bool" },
-      { "internalType": "uint256", "name": "value", "type": "uint256" }
+        "type": "tuple"
+      }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -243,14 +243,14 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionLimits",
-            "name": "field_0",
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" },
-          { "internalType": "uint256", "name": "field_2", "type": "uint256" }
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
         ],
-        "internalType": "struct Tuple35[]",
+        "internalType": "struct CollectionLimit[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -271,7 +271,7 @@
           },
           { "internalType": "bool", "name": "field_1", "type": "bool" }
         ],
-        "internalType": "struct Tuple44[]",
+        "internalType": "struct Tuple45[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -292,7 +292,7 @@
             "type": "uint256[]"
           }
         ],
-        "internalType": "struct Tuple41",
+        "internalType": "struct Tuple42",
         "name": "",
         "type": "tuple"
       }
@@ -656,12 +656,19 @@
   {
     "inputs": [
       {
-        "internalType": "enum CollectionLimits",
+        "components": [
+          {
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
+            "type": "uint8"
+          },
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
+        ],
+        "internalType": "struct CollectionLimit",
         "name": "limit",
-        "type": "uint8"
-      },
-      { "internalType": "bool", "name": "status", "type": "bool" },
-      { "internalType": "uint256", "name": "value", "type": "uint256" }
+        "type": "tuple"
+      }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
@@ -756,7 +763,7 @@
           {
             "components": [
               {
-                "internalType": "enum EthTokenPermissions",
+                "internalType": "enum TokenPermissionField",
                 "name": "code",
                 "type": "uint8"
               },
@@ -822,7 +829,7 @@
           {
             "components": [
               {
-                "internalType": "enum EthTokenPermissions",
+                "internalType": "enum TokenPermissionField",
                 "name": "code",
                 "type": "uint8"
               },
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -225,14 +225,14 @@
       {
         "components": [
           {
-            "internalType": "enum CollectionLimits",
-            "name": "field_0",
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
             "type": "uint8"
           },
-          { "internalType": "bool", "name": "field_1", "type": "bool" },
-          { "internalType": "uint256", "name": "field_2", "type": "uint256" }
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
         ],
-        "internalType": "struct Tuple34[]",
+        "internalType": "struct CollectionLimit[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -253,7 +253,7 @@
           },
           { "internalType": "bool", "name": "field_1", "type": "bool" }
         ],
-        "internalType": "struct Tuple43[]",
+        "internalType": "struct Tuple44[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -274,7 +274,7 @@
             "type": "uint256[]"
           }
         ],
-        "internalType": "struct Tuple40",
+        "internalType": "struct Tuple41",
         "name": "",
         "type": "tuple"
       }
@@ -638,12 +638,19 @@
   {
     "inputs": [
       {
-        "internalType": "enum CollectionLimits",
+        "components": [
+          {
+            "internalType": "enum CollectionLimitField",
+            "name": "field",
+            "type": "uint8"
+          },
+          { "internalType": "bool", "name": "status", "type": "bool" },
+          { "internalType": "uint256", "name": "value", "type": "uint256" }
+        ],
+        "internalType": "struct CollectionLimit",
         "name": "limit",
-        "type": "uint8"
-      },
-      { "internalType": "bool", "name": "status", "type": "bool" },
-      { "internalType": "uint256", "name": "value", "type": "uint256" }
+        "type": "tuple"
+      }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
@@ -738,7 +745,7 @@
           {
             "components": [
               {
-                "internalType": "enum EthTokenPermissions",
+                "internalType": "enum TokenPermissionField",
                 "name": "code",
                 "type": "uint8"
               },
@@ -813,7 +820,7 @@
           {
             "components": [
               {
-                "internalType": "enum EthTokenPermissions",
+                "internalType": "enum TokenPermissionField",
                 "name": "code",
                 "type": "uint8"
               },
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 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -106,42 +106,17 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() external view returns (Tuple21[] memory);
+	function collectionLimits() external view returns (CollectionLimit[] memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) external;
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -330,8 +305,14 @@
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -350,13 +331,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple21 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @dev Ethereum representation of collection [`PropertyKey`](up_data_structs::PropertyKey) and [`PropertyValue`](up_data_structs::PropertyValue).
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -99,13 +99,13 @@
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
 struct PropertyPermission {
 	/// @dev TokenPermission field.
-	EthTokenPermissions code;
+	TokenPermissionField code;
 	/// @dev TokenPermission value.
 	bool value;
 }
 
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
-enum EthTokenPermissions {
+enum TokenPermissionField {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
 	Mutable,
 	/// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
@@ -115,7 +115,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -208,42 +208,17 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() external view returns (Tuple31[] memory);
+	function collectionLimits() external view returns (CollectionLimit[] memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) external;
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -432,8 +407,14 @@
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -452,13 +433,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple31 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -99,13 +99,13 @@
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) as an key and value.
 struct PropertyPermission {
 	/// @dev TokenPermission field.
-	EthTokenPermissions code;
+	TokenPermissionField code;
 	/// @dev TokenPermission value.
 	bool value;
 }
 
 /// @dev Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
-enum EthTokenPermissions {
+enum TokenPermissionField {
 	/// @dev Permission to change the property and property permission. See [`up_data_structs::PropertyPermission::mutable`]
 	Mutable,
 	/// @dev Change permission for the collection administrator. See [`up_data_structs::PropertyPermission::token_owner`]
@@ -115,7 +115,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x81172a75
+/// @dev the ERC-165 identifier for this interface is 0x23201442
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -208,42 +208,17 @@
 
 	/// Get current collection limits.
 	///
-	/// @return Array of tuples (byte, bool, uint256) with limits and their values. Order of limits:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// Return `false` if a limit not set.
+	/// @return Array of collection limits
 	/// @dev EVM selector for this function is: 0xf63bc572,
 	///  or in textual repr: collectionLimits()
-	function collectionLimits() external view returns (Tuple30[] memory);
+	function collectionLimits() external view returns (CollectionLimit[] memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"accountTokenOwnershipLimit",
-	/// 	"sponsoredDataSize",
-	/// 	"sponsoredDataRateLimit",
-	/// 	"tokenLimit",
-	/// 	"sponsorTransferTimeout",
-	/// 	"sponsorApproveTimeout"
-	///  	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param status enable\disable limit. Works only with `true`.
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x88150bd0,
-	///  or in textual repr: setCollectionLimit(uint8,bool,uint256)
-	function setCollectionLimit(
-		CollectionLimits limit,
-		bool status,
-		uint256 value
-	) external;
+	/// @param limit Some limit.
+	/// @dev EVM selector for this function is: 0x2a2235e7,
+	///  or in textual repr: setCollectionLimit((uint8,bool,uint256))
+	function setCollectionLimit(CollectionLimit memory limit) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
@@ -432,8 +407,14 @@
 	uint256[] field_1;
 }
 
+struct CollectionLimit {
+	CollectionLimitField field;
+	bool status;
+	uint256 value;
+}
+
 /// @dev [`CollectionLimits`](up_data_structs::CollectionLimits) representation for EVM.
-enum CollectionLimits {
+enum CollectionLimitField {
 	/// @dev How many tokens can a user have on one account.
 	AccountTokenOwnership,
 	/// @dev How many bytes of data are available for sponsorship.
@@ -452,13 +433,6 @@
 	OwnerCanDestroy,
 	/// @dev Is it possible to send tokens from this collection between users.
 	TransferEnabled
-}
-
-/// @dev anonymous struct
-struct Tuple30 {
-	CollectionLimits field_0;
-	bool field_1;
-	uint256 field_2;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
modifiedtests/src/eth/collectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionLimits.test.ts
+++ b/tests/src/eth/collectionLimits.test.ts
@@ -1,7 +1,7 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {Pallets} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import {CollectionLimits} from './util/playgrounds/types';
+import {CollectionLimitField} from './util/playgrounds/types';
 
 
 describe('Can set collection limits', () => {
@@ -46,15 +46,15 @@
       };
      
       const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.TokenLimit, true, limits.tokenLimit).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorTransferTimeout, true, limits.sponsorTransferTimeout).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsorApproveTimeout, true, limits.sponsorApproveTimeout).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, limits.ownerCanTransfer).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.OwnerCanDestroy, true, limits.ownerCanDestroy).send();
-      await collectionEvm.methods.setCollectionLimit(CollectionLimits.TransferEnabled, true, limits.transfersEnabled).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: limits.accountTokenOwnershipLimit}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, status: true, value: limits.sponsoredDataSize}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsoredDataRateLimit, status: true, value: limits.sponsoredDataRateLimit}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TokenLimit, status: true, value: limits.tokenLimit}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorTransferTimeout, status: true, value: limits.sponsorTransferTimeout}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.SponsorApproveTimeout, status: true, value: limits.sponsorApproveTimeout}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, status: true, value: limits.ownerCanTransfer}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanDestroy, status: true, value: limits.ownerCanDestroy}).send();
+      await collectionEvm.methods.setCollectionLimit({field: CollectionLimitField.TransferEnabled, status: true, value: limits.transfersEnabled}).send();
       
       // Check limits from sub:
       const data = (await helper.rft.getData(collectionId))!;
@@ -63,15 +63,15 @@
       // Check limits from eth:
       const limitsEvm = await collectionEvm.methods.collectionLimits().call({from: owner});
       expect(limitsEvm).to.have.length(9);
-      expect(limitsEvm[0]).to.deep.eq([CollectionLimits.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);
-      expect(limitsEvm[1]).to.deep.eq([CollectionLimits.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);
-      expect(limitsEvm[2]).to.deep.eq([CollectionLimits.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);
-      expect(limitsEvm[3]).to.deep.eq([CollectionLimits.TokenLimit.toString(), true, limits.tokenLimit.toString()]);
-      expect(limitsEvm[4]).to.deep.eq([CollectionLimits.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);
-      expect(limitsEvm[5]).to.deep.eq([CollectionLimits.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);
-      expect(limitsEvm[6]).to.deep.eq([CollectionLimits.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);
-      expect(limitsEvm[7]).to.deep.eq([CollectionLimits.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);
-      expect(limitsEvm[8]).to.deep.eq([CollectionLimits.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);
+      expect(limitsEvm[0]).to.deep.eq([CollectionLimitField.AccountTokenOwnership.toString(), true, limits.accountTokenOwnershipLimit.toString()]);
+      expect(limitsEvm[1]).to.deep.eq([CollectionLimitField.SponsoredDataSize.toString(), true, limits.sponsoredDataSize.toString()]);
+      expect(limitsEvm[2]).to.deep.eq([CollectionLimitField.SponsoredDataRateLimit.toString(), true, limits.sponsoredDataRateLimit.toString()]);
+      expect(limitsEvm[3]).to.deep.eq([CollectionLimitField.TokenLimit.toString(), true, limits.tokenLimit.toString()]);
+      expect(limitsEvm[4]).to.deep.eq([CollectionLimitField.SponsorTransferTimeout.toString(), true, limits.sponsorTransferTimeout.toString()]);
+      expect(limitsEvm[5]).to.deep.eq([CollectionLimitField.SponsorApproveTimeout.toString(), true, limits.sponsorApproveTimeout.toString()]);
+      expect(limitsEvm[6]).to.deep.eq([CollectionLimitField.OwnerCanTransfer.toString(), true, limits.ownerCanTransfer.toString()]);
+      expect(limitsEvm[7]).to.deep.eq([CollectionLimitField.OwnerCanDestroy.toString(), true, limits.ownerCanDestroy.toString()]);
+      expect(limitsEvm[8]).to.deep.eq([CollectionLimitField.TransferEnabled.toString(), true, limits.transfersEnabled.toString()]);
     }));
 });
 
@@ -101,24 +101,24 @@
 
       // Cannot set non-existing limit
       await expect(collectionEvm.methods
-        .setCollectionLimit(9, true, 1)
-        .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert Value not convertible into enum "CollectionLimits"');      
+        .setCollectionLimit({field: 9, status: true, value: 1})
+        .call()).to.be.rejectedWith('Value not convertible into enum "CollectionLimitField"');      
         
       // Cannot disable limits
       await expect(collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, false, 200)
-        .call()).to.be.rejectedWith('Returned error: VM Exception while processing transaction: revert user can\'t disable limits');
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: false, value: 200})
+        .call()).to.be.rejectedWith('user can\'t disable limits');
 
       await expect(collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, invalidLimits.accountTokenOwnershipLimit)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: invalidLimits.accountTokenOwnershipLimit})
         .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
  
       await expect(collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.TransferEnabled, true, 3)
+        .setCollectionLimit({field: CollectionLimitField.TransferEnabled, status: true, value: 3})
         .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
 
       expect(() => collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.SponsoredDataSize, true, -1).send()).to.throw('value out-of-bounds');
+        .setCollectionLimit({field: CollectionLimitField.SponsoredDataSize, status: true, value: -1}).send()).to.throw('value out-of-bounds');
     }));
 
   [
@@ -133,12 +133,12 @@
 
       const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);
       await expect(collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call({from: nonOwner}))
         .to.be.rejectedWith('NoPermission');
 
       await expect(collectionEvm.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .send({from: nonOwner}))
         .to.be.rejected;
     }));
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -18,7 +18,7 @@
 import {evmToAddress} from '@polkadot/util-crypto';
 import {Pallets, requirePalletsOrSkip} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import { CollectionLimits } from './util/playgrounds/types';
+import {CollectionLimitField} from './util/playgrounds/types';
 
 const DECIMALS = 18;
 
@@ -197,7 +197,7 @@
     }
     {
       await expect(peasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });
@@ -222,7 +222,7 @@
     }
     {
       await expect(peasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });    
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -17,7 +17,7 @@
 import {evmToAddress} from '@polkadot/util-crypto';
 import {IKeyringPair} from '@polkadot/types/types';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import { CollectionLimits } from './util/playgrounds/types';
+import {CollectionLimitField} from './util/playgrounds/types';
 
 
 describe('Create NFT collection from EVM', () => {
@@ -208,7 +208,7 @@
     }
     {
       await expect(malfeasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });
@@ -233,7 +233,7 @@
     }
     {
       await expect(malfeasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -18,7 +18,7 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {Pallets, requirePalletsOrSkip} from '../util';
 import {expect, itEth, usingEthPlaygrounds} from './util';
-import {CollectionLimits} from './util/playgrounds/types';
+import {CollectionLimitField} from './util/playgrounds/types';
 
 
 describe('Create RFT collection from EVM', () => {
@@ -240,7 +240,7 @@
     }
     {
       await expect(peasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });
@@ -265,7 +265,7 @@
     }
     {
       await expect(peasantCollection.methods
-        .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)
+        .setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, status: true, value: 1000})
         .call()).to.be.rejectedWith(EXPECTED_ERROR);
     }
   });
modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -19,7 +19,7 @@
 import {EthUniqueHelper, itEth, usingEthPlaygrounds} from './util';
 import {IEvent, TCollectionMode} from '../util/playgrounds/types';
 import {Pallets, requirePalletsOrSkip} from '../util';
-import {CollectionLimits, EthTokenPermissions, NormalizedEvent} from './util/playgrounds/types';
+import {CollectionLimitField, TokenPermissionField, NormalizedEvent} from './util/playgrounds/types';
 
 let donor: IKeyringPair;
   
@@ -121,9 +121,9 @@
   const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['PropertyPermissionSet']}]);
   await collection.methods.setTokenPropertyPermissions([
     ['A', [
-      [EthTokenPermissions.Mutable, true], 
-      [EthTokenPermissions.TokenOwner, true], 
-      [EthTokenPermissions.CollectionAdmin, true]],
+      [TokenPermissionField.Mutable, true], 
+      [TokenPermissionField.TokenOwner, true], 
+      [TokenPermissionField.CollectionAdmin, true]],
     ],
   ]).send({from: owner});
   await helper.wait.newBlocks(1);
@@ -233,7 +233,7 @@
   });
   const {unsubscribe, collectedEvents: subEvents} = await helper.subscribeEvents([{section: 'common', names: ['CollectionLimitSet']}]);
   {
-    await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, 0).send({from: owner});
+    await collection.methods.setCollectionLimit({field: CollectionLimitField.OwnerCanTransfer, status: true, value: 0}).send({from: owner});
     await helper.wait.newBlocks(1);
     expect(ethEvents).to.containSubset([
       {
@@ -379,9 +379,9 @@
   const tokenId = result.events.Transfer.returnValues.tokenId;
   await collection.methods.setTokenPropertyPermissions([
     ['A', [
-      [EthTokenPermissions.Mutable, true], 
-      [EthTokenPermissions.TokenOwner, true], 
-      [EthTokenPermissions.CollectionAdmin, true]],
+      [TokenPermissionField.Mutable, true], 
+      [TokenPermissionField.TokenOwner, true], 
+      [TokenPermissionField.CollectionAdmin, true]],
     ],
   ]).send({from: owner});
 
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
before · tests/src/eth/tokenProperties.test.ts
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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {Contract} from 'web3-eth-contract';19import {itEth, usingEthPlaygrounds, expect} from './util';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import {Pallets} from '../util';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';23import {EthTokenPermissions} from './util/playgrounds/types';2425describe('EVM token properties', () => {26  let donor: IKeyringPair;27  let alice: IKeyringPair;2829  before(async function() {30    await usingEthPlaygrounds(async (helper, privateKey) => {31      donor = await privateKey({filename: __filename});32      [alice] = await helper.arrange.createAccounts([100n], donor);33    });34  });3536  [37    {mode: 'nft' as const, requiredPallets: []},38    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},39  ].map(testCase =>40    itEth.ifWithPallets(`[${testCase.mode}] Can set all possible token property permissions`, testCase.requiredPallets, async({helper}) => {41      const owner = await helper.eth.createAccountWithBalance(donor);42      const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);43      for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {44        const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');45        const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);46        await collection.methods.addCollectionAdminCross(caller).send({from: owner});4748        await collection.methods.setTokenPropertyPermissions([49          ['testKey', [50            [EthTokenPermissions.Mutable, mutable], 51            [EthTokenPermissions.TokenOwner, tokenOwner], 52            [EthTokenPermissions.CollectionAdmin, collectionAdmin]],53          ],54        ]).send({from: caller.eth});55      56        expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{57          key: 'testKey',58          permission: {mutable, collectionAdmin, tokenOwner},59        }]);6061        expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([62          ['testKey', [63            [EthTokenPermissions.Mutable.toString(), mutable], 64            [EthTokenPermissions.TokenOwner.toString(), tokenOwner], 65            [EthTokenPermissions.CollectionAdmin.toString(), collectionAdmin]],66          ],67        ]);68      }69    }));7071  [72    {mode: 'nft' as const, requiredPallets: []},73    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},74  ].map(testCase =>75    itEth.ifWithPallets(`[${testCase.mode}] Can set multiple token property permissions as owner`, testCase.requiredPallets, async({helper}) => {76      const owner = await helper.eth.createAccountWithBalance(donor);77      78      const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');79      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);8081      await collection.methods.setTokenPropertyPermissions([82        ['testKey_0', [83          [EthTokenPermissions.Mutable, true], 84          [EthTokenPermissions.TokenOwner, true], 85          [EthTokenPermissions.CollectionAdmin, true]],86        ],87        ['testKey_1', [88          [EthTokenPermissions.Mutable, true], 89          [EthTokenPermissions.TokenOwner, false], 90          [EthTokenPermissions.CollectionAdmin, true]],91        ],92        ['testKey_2', [93          [EthTokenPermissions.Mutable, false], 94          [EthTokenPermissions.TokenOwner, true], 95          [EthTokenPermissions.CollectionAdmin, false]],96        ],97      ]).send({from: owner});98      99      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([100        {101          key: 'testKey_0',102          permission: {mutable: true, tokenOwner: true, collectionAdmin: true},103        },104        {105          key: 'testKey_1',106          permission: {mutable: true, tokenOwner: false, collectionAdmin: true},107        },108        {109          key: 'testKey_2',110          permission: {mutable: false, tokenOwner: true, collectionAdmin: false},111        },112      ]);113114      expect(await collection.methods.tokenPropertyPermissions().call({from: owner})).to.be.like([115        ['testKey_0', [116          [EthTokenPermissions.Mutable.toString(), true], 117          [EthTokenPermissions.TokenOwner.toString(), true], 118          [EthTokenPermissions.CollectionAdmin.toString(), true]],119        ],120        ['testKey_1', [121          [EthTokenPermissions.Mutable.toString(), true], 122          [EthTokenPermissions.TokenOwner.toString(), false], 123          [EthTokenPermissions.CollectionAdmin.toString(), true]],124        ],125        ['testKey_2', [126          [EthTokenPermissions.Mutable.toString(), false], 127          [EthTokenPermissions.TokenOwner.toString(), true], 128          [EthTokenPermissions.CollectionAdmin.toString(), false]],129        ],130      ]);131    }));132133  [134    {mode: 'nft' as const, requiredPallets: []},135    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},136  ].map(testCase =>137    itEth.ifWithPallets(`[${testCase.mode}] Can set multiple token property permissions as admin`, testCase.requiredPallets, async({helper}) => {138      const owner = await helper.eth.createAccountWithBalance(donor);139      const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);140      141      const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');142      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);143      await collection.methods.addCollectionAdminCross(caller).send({from: owner});144145      await collection.methods.setTokenPropertyPermissions([146        ['testKey_0', [147          [EthTokenPermissions.Mutable, true], 148          [EthTokenPermissions.TokenOwner, true], 149          [EthTokenPermissions.CollectionAdmin, true]],150        ],151        ['testKey_1', [152          [EthTokenPermissions.Mutable, true], 153          [EthTokenPermissions.TokenOwner, false], 154          [EthTokenPermissions.CollectionAdmin, true]],155        ],156        ['testKey_2', [157          [EthTokenPermissions.Mutable, false], 158          [EthTokenPermissions.TokenOwner, true], 159          [EthTokenPermissions.CollectionAdmin, false]],160        ],161      ]).send({from: caller.eth});162      163      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([164        {165          key: 'testKey_0',166          permission: {mutable: true, tokenOwner: true, collectionAdmin: true},167        },168        {169          key: 'testKey_1',170          permission: {mutable: true, tokenOwner: false, collectionAdmin: true},171        },172        {173          key: 'testKey_2',174          permission: {mutable: false, tokenOwner: true, collectionAdmin: false},175        },176      ]);177178      expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([179        ['testKey_0', [180          [EthTokenPermissions.Mutable.toString(), true], 181          [EthTokenPermissions.TokenOwner.toString(), true], 182          [EthTokenPermissions.CollectionAdmin.toString(), true]],183        ],184        ['testKey_1', [185          [EthTokenPermissions.Mutable.toString(), true], 186          [EthTokenPermissions.TokenOwner.toString(), false], 187          [EthTokenPermissions.CollectionAdmin.toString(), true]],188        ],189        ['testKey_2', [190          [EthTokenPermissions.Mutable.toString(), false], 191          [EthTokenPermissions.TokenOwner.toString(), true], 192          [EthTokenPermissions.CollectionAdmin.toString(), false]],193        ],194      ]);195      196    }));197198  [199    {200      method: 'setProperties',201      methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]],202      expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}],203    },204    {205      method: 'setProperty' /*Soft-deprecated*/, 206      methodParams: ['testKey1', Buffer.from('testValue1')],207      expectedProps: [{key: 'testKey1', value: 'testValue1'}],208    },209  ].map(testCase => 210    itEth(`[${testCase.method}] Can be set`, async({helper}) => {211      const caller = await helper.eth.createAccountWithBalance(donor);212      const collection = await helper.nft.mintCollection(alice, {213        tokenPropertyPermissions: [{214          key: 'testKey1',215          permission: {216            collectionAdmin: true,217          },218        }, {219          key: 'testKey2',220          permission: {221            collectionAdmin: true,222          },223        }],224      });225226      await collection.addAdmin(alice, {Ethereum: caller});227      const token = await collection.mintToken(alice);228  229      const collectionEvm = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller, testCase.method === 'setProperty');230  231      await collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller});232  233      const properties = await token.getProperties();234      expect(properties).to.deep.equal(testCase.expectedProps);235    }));236  237  [238    {mode: 'nft' as const, requiredPallets: []},239    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},240  ].map(testCase => 241    itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {242      const caller = await helper.eth.createAccountWithBalance(donor);243      244      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });245      const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,246        collectionAdmin: true,247        mutable: true}}; });248      249      const collection = await helper[testCase.mode].mintCollection(alice, {250        tokenPrefix: 'ethp',251        tokenPropertyPermissions: permissions,252      }) as UniqueNFTCollection | UniqueRFTCollection;253      254      const token = await collection.mintToken(alice);255      256      const valuesBefore = await token.getProperties(properties.map(p => p.key));257      expect(valuesBefore).to.be.deep.equal([]);258      259      260      await collection.addAdmin(alice, {Ethereum: caller});261      262      const address = helper.ethAddress.fromCollectionId(collection.collectionId);263      const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);264      265      expect(await contract.methods.properties(token.tokenId, []).call()).to.be.deep.equal([]);266  267      await contract.methods.setProperties(token.tokenId, properties).send({from: caller});268  269      const values = await token.getProperties(properties.map(p => p.key));270      expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));271      272      expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties273        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));274      275      expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())276        .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);277    }));278  279  [280    {mode: 'nft' as const, requiredPallets: []},281    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},282  ].map(testCase => 283    itEth.ifWithPallets(`Can be deleted for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {284      const caller = await helper.eth.createAccountWithBalance(donor);285      const collection = await helper[testCase.mode].mintCollection(alice, {286        tokenPropertyPermissions: [{287          key: 'testKey',288          permission: {289            mutable: true,290            collectionAdmin: true,291          },292        },293        {294          key: 'testKey_1',295          permission: {296            mutable: true,297            collectionAdmin: true,298          },299        }],300      });301    302      const token = await collection.mintToken(alice);303      await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}, {key: 'testKey_1', value: 'testValue_1'}]);304      expect(await token.getProperties()).to.has.length(2);305306      await collection.addAdmin(alice, {Ethereum: caller});307308      const address = helper.ethAddress.fromCollectionId(collection.collectionId);309      const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);310311      await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});312313      const result = await token.getProperties(['testKey', 'testKey_1']);314      expect(result.length).to.equal(0);315    }));316317  itEth('Can be read', async({helper}) => {318    const caller = helper.eth.createAccount();319    const collection = await helper.nft.mintCollection(alice, {320      tokenPropertyPermissions: [{321        key: 'testKey',322        permission: {323          collectionAdmin: true,324        },325      }],326    });327  328    const token = await collection.mintToken(alice);329    await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);330331    const address = helper.ethAddress.fromCollectionId(collection.collectionId);332    const contract = helper.ethNativeContract.collection(address, 'nft', caller);333334    const value = await contract.methods.property(token.tokenId, 'testKey').call();335    expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));336  });337});338339describe('EVM token properties negative', () => {340  let donor: IKeyringPair;341  let alice: IKeyringPair;342  let caller: string;343  let aliceCollection: UniqueNFTCollection;344  let token: UniqueNFToken;345  const tokenProps = [{key: 'testKey_1', value: 'testValue_1'}, {key: 'testKey_2', value: 'testValue_2'}];346  let collectionEvm: Contract;347348  before(async function() {349    await usingEthPlaygrounds(async (helper, privateKey) => {350      donor = await privateKey({filename: __filename});351      [alice] = await helper.arrange.createAccounts([100n], donor);352    });353  });354355  beforeEach(async () => {356    // 1. create collection with props: testKey_1, testKey_2357    // 2. create token and set props testKey_1, testKey_2358    await usingEthPlaygrounds(async (helper) => {359      aliceCollection = await helper.nft.mintCollection(alice, {360        tokenPropertyPermissions: [{361          key: 'testKey_1',362          permission: {363            mutable: true,364            collectionAdmin: true,365          },366        },367        {368          key: 'testKey_2',369          permission: {370            mutable: true,371            collectionAdmin: true,372          },373        }],374      }); 375      token = await aliceCollection.mintToken(alice);376      await token.setProperties(alice, tokenProps);377      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);378    });379  });380381  [382    {method: 'setProperty', methodParams: [tokenProps[1].key, Buffer.from('newValue')]},383    {method: 'setProperties', methodParams: [[{key: tokenProps[1].key, value: Buffer.from('newValue')}]]},384  ].map(testCase =>385    itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {386      caller = await helper.eth.createAccountWithBalance(donor);387      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);388      // Caller not an owner and not an admin, so he cannot set properties:389      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');390      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;391392      // Props have not changed:393      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));394      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();395      expect(actualProps).to.deep.eq(expectedProps);396    }));397398  [399    {method: 'setProperty', methodParams: ['testKey_3', Buffer.from('testValue3')]},400    {method: 'setProperties', methodParams: [[{key: 'testKey_3', value: Buffer.from('testValue3')}]]},401  ].map(testCase =>402    itEth(`[${testCase.method}] Cannot set non-existing properties`, async ({helper}) => {403      caller = await helper.eth.createAccountWithBalance(donor);404      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);405      await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});406407      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');408      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;409410      // Props have not changed:411      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));412      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();413      expect(actualProps).to.deep.eq(expectedProps);414    }));415416  [417    {method: 'deleteProperty', methodParams: ['testKey_2']},418    {method: 'deleteProperties', methodParams: [['testKey_2']]},419  ].map(testCase =>  420    itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {421      caller = await helper.eth.createAccountWithBalance(donor);422      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');423      // Caller not an owner and not an admin, so he cannot set properties:424      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');425      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;426427      // Props have not changed:428      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));429      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();430      expect(actualProps).to.deep.eq(expectedProps);431    }));432   433  [434    {method: 'deleteProperty', methodParams: ['testKey_3']},435    {method: 'deleteProperties', methodParams: [['testKey_3']]},436  ].map(testCase =>  437    itEth(`[${testCase.method}] Cannot delete non-existing properties`, async ({helper}) => {438      caller = await helper.eth.createAccountWithBalance(donor);439      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');440      await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});441      // Caller cannot delete non-existing properties:442      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');443      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;444      // Props have not changed:445      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));446      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();447      expect(actualProps).to.deep.eq(expectedProps);448    }));449450  [451    {mode: 'nft' as const, requiredPallets: []},452    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},453  ].map(testCase =>454    itEth.ifWithPallets(`[${testCase.mode}] Cannot set token property permissions as non owner or admin`, testCase.requiredPallets, async({helper}) => {455      const owner = await helper.eth.createAccountWithBalance(donor);456      const caller = await helper.eth.createAccountWithBalance(donor);457        458      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');459      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);460  461      await expect(collection.methods.setTokenPropertyPermissions([462        ['testKey_0', [463          [EthTokenPermissions.Mutable, true], 464          [EthTokenPermissions.TokenOwner, true], 465          [EthTokenPermissions.CollectionAdmin, true]],466        ],467      ]).call({from: caller})).to.be.rejectedWith('NoPermission');  468    }));469470  [471    {mode: 'nft' as const, requiredPallets: []},472    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},473  ].map(testCase =>474    itEth.ifWithPallets(`[${testCase.mode}] Cannot set token property permissions with invalid character`, testCase.requiredPallets, async({helper}) => {475      const owner = await helper.eth.createAccountWithBalance(donor);476        477      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');478      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);479  480      await expect(collection.methods.setTokenPropertyPermissions([481        // "Space" is invalid character482        ['testKey 0', [483          [EthTokenPermissions.Mutable, true], 484          [EthTokenPermissions.TokenOwner, true], 485          [EthTokenPermissions.CollectionAdmin, true]],486        ],487      ]).call({from: owner})).to.be.rejectedWith('InvalidCharacterInPropertyKey');  488    }));489490  [491    {mode: 'nft' as const, requiredPallets: []},492    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},493  ].map(testCase =>494    itEth.ifWithPallets(`[${testCase.mode}] Can reconfigure token property permissions to stricter ones`, testCase.requiredPallets, async({helper}) => {495      const owner = await helper.eth.createAccountWithBalance(donor);496              497      const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');498      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);499        500      // 1. Owner sets strict property-permissions:501      await collection.methods.setTokenPropertyPermissions([502        ['testKey', [503          [EthTokenPermissions.Mutable, true], 504          [EthTokenPermissions.TokenOwner, true], 505          [EthTokenPermissions.CollectionAdmin, true]],506        ],507      ]).send({from: owner});508    509      // 2. Owner can set stricter property-permissions:510      for(const values of [[true, true, false], [true, false, false], [false, false, false]]) {511        await collection.methods.setTokenPropertyPermissions([512          ['testKey', [513            [EthTokenPermissions.Mutable, values[0]], 514            [EthTokenPermissions.TokenOwner, values[1]], 515            [EthTokenPermissions.CollectionAdmin, values[2]]],516          ],517        ]).send({from: owner});518      }519520      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{521        key: 'testKey',522        permission: {mutable: false, collectionAdmin: false, tokenOwner: false},523      }]);524    }));525526  [527    {mode: 'nft' as const, requiredPallets: []},528    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},529  ].map(testCase =>530    itEth.ifWithPallets(`[${testCase.mode}] Cannot reconfigure token property permissions to less strict ones`, testCase.requiredPallets, async({helper}) => {531      const owner = await helper.eth.createAccountWithBalance(donor);532          533      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');534      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);535    536      // 1. Owner sets strict property-permissions:537      await collection.methods.setTokenPropertyPermissions([538        ['testKey', [539          [EthTokenPermissions.Mutable, false], 540          [EthTokenPermissions.TokenOwner, false], 541          [EthTokenPermissions.CollectionAdmin, false]],542        ],543      ]).send({from: owner});544545      // 2. Owner cannot set less strict property-permissions:546      for(const values of [[true, false, false], [false, true, false], [false, false, true]]) {547        await expect(collection.methods.setTokenPropertyPermissions([548          ['testKey', [549            [EthTokenPermissions.Mutable, values[0]], 550            [EthTokenPermissions.TokenOwner, values[1]], 551            [EthTokenPermissions.CollectionAdmin, values[2]]],552          ],553        ]).call({from: owner})).to.be.rejectedWith('NoPermission');554      }555    }));556});557558559type ElementOf<A> = A extends readonly (infer T)[] ? T : never;560function* cartesian<T extends Array<Array<any>>, R extends Array<any>>(internalRest: [...R], ...args: [...T]): Generator<[...R, ...{[K in keyof T]: ElementOf<T[K]>}]> {561  if(args.length === 0) {562    yield internalRest as any;563    return;564  }565  for(const value of args[0]) {566    yield* cartesian([...internalRest, value], ...args.slice(1)) as any;567  }568}
after · tests/src/eth/tokenProperties.test.ts
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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {Contract} from 'web3-eth-contract';19import {itEth, usingEthPlaygrounds, expect} from './util';20import {ITokenPropertyPermission} from '../util/playgrounds/types';21import {Pallets} from '../util';22import {UniqueNFTCollection, UniqueNFToken, UniqueRFTCollection} from '../util/playgrounds/unique';23import {TokenPermissionField} from './util/playgrounds/types';2425describe('EVM token properties', () => {26  let donor: IKeyringPair;27  let alice: IKeyringPair;2829  before(async function() {30    await usingEthPlaygrounds(async (helper, privateKey) => {31      donor = await privateKey({filename: __filename});32      [alice] = await helper.arrange.createAccounts([100n], donor);33    });34  });3536  [37    {mode: 'nft' as const, requiredPallets: []},38    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},39  ].map(testCase =>40    itEth.ifWithPallets(`[${testCase.mode}] Can set all possible token property permissions`, testCase.requiredPallets, async({helper}) => {41      const owner = await helper.eth.createAccountWithBalance(donor);42      const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);43      for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {44        const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');45        const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);46        await collection.methods.addCollectionAdminCross(caller).send({from: owner});4748        await collection.methods.setTokenPropertyPermissions([49          ['testKey', [50            [TokenPermissionField.Mutable, mutable], 51            [TokenPermissionField.TokenOwner, tokenOwner], 52            [TokenPermissionField.CollectionAdmin, collectionAdmin]],53          ],54        ]).send({from: caller.eth});55      56        expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{57          key: 'testKey',58          permission: {mutable, collectionAdmin, tokenOwner},59        }]);6061        expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([62          ['testKey', [63            [TokenPermissionField.Mutable.toString(), mutable], 64            [TokenPermissionField.TokenOwner.toString(), tokenOwner], 65            [TokenPermissionField.CollectionAdmin.toString(), collectionAdmin]],66          ],67        ]);68      }69    }));7071  [72    {mode: 'nft' as const, requiredPallets: []},73    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},74  ].map(testCase =>75    itEth.ifWithPallets(`[${testCase.mode}] Can set multiple token property permissions as owner`, testCase.requiredPallets, async({helper}) => {76      const owner = await helper.eth.createAccountWithBalance(donor);77      78      const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');79      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);8081      await collection.methods.setTokenPropertyPermissions([82        ['testKey_0', [83          [TokenPermissionField.Mutable, true], 84          [TokenPermissionField.TokenOwner, true], 85          [TokenPermissionField.CollectionAdmin, true]],86        ],87        ['testKey_1', [88          [TokenPermissionField.Mutable, true], 89          [TokenPermissionField.TokenOwner, false], 90          [TokenPermissionField.CollectionAdmin, true]],91        ],92        ['testKey_2', [93          [TokenPermissionField.Mutable, false], 94          [TokenPermissionField.TokenOwner, true], 95          [TokenPermissionField.CollectionAdmin, false]],96        ],97      ]).send({from: owner});98      99      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([100        {101          key: 'testKey_0',102          permission: {mutable: true, tokenOwner: true, collectionAdmin: true},103        },104        {105          key: 'testKey_1',106          permission: {mutable: true, tokenOwner: false, collectionAdmin: true},107        },108        {109          key: 'testKey_2',110          permission: {mutable: false, tokenOwner: true, collectionAdmin: false},111        },112      ]);113114      expect(await collection.methods.tokenPropertyPermissions().call({from: owner})).to.be.like([115        ['testKey_0', [116          [TokenPermissionField.Mutable.toString(), true], 117          [TokenPermissionField.TokenOwner.toString(), true], 118          [TokenPermissionField.CollectionAdmin.toString(), true]],119        ],120        ['testKey_1', [121          [TokenPermissionField.Mutable.toString(), true], 122          [TokenPermissionField.TokenOwner.toString(), false], 123          [TokenPermissionField.CollectionAdmin.toString(), true]],124        ],125        ['testKey_2', [126          [TokenPermissionField.Mutable.toString(), false], 127          [TokenPermissionField.TokenOwner.toString(), true], 128          [TokenPermissionField.CollectionAdmin.toString(), false]],129        ],130      ]);131    }));132133  [134    {mode: 'nft' as const, requiredPallets: []},135    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},136  ].map(testCase =>137    itEth.ifWithPallets(`[${testCase.mode}] Can set multiple token property permissions as admin`, testCase.requiredPallets, async({helper}) => {138      const owner = await helper.eth.createAccountWithBalance(donor);139      const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);140      141      const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');142      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);143      await collection.methods.addCollectionAdminCross(caller).send({from: owner});144145      await collection.methods.setTokenPropertyPermissions([146        ['testKey_0', [147          [TokenPermissionField.Mutable, true], 148          [TokenPermissionField.TokenOwner, true], 149          [TokenPermissionField.CollectionAdmin, true]],150        ],151        ['testKey_1', [152          [TokenPermissionField.Mutable, true], 153          [TokenPermissionField.TokenOwner, false], 154          [TokenPermissionField.CollectionAdmin, true]],155        ],156        ['testKey_2', [157          [TokenPermissionField.Mutable, false], 158          [TokenPermissionField.TokenOwner, true], 159          [TokenPermissionField.CollectionAdmin, false]],160        ],161      ]).send({from: caller.eth});162      163      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([164        {165          key: 'testKey_0',166          permission: {mutable: true, tokenOwner: true, collectionAdmin: true},167        },168        {169          key: 'testKey_1',170          permission: {mutable: true, tokenOwner: false, collectionAdmin: true},171        },172        {173          key: 'testKey_2',174          permission: {mutable: false, tokenOwner: true, collectionAdmin: false},175        },176      ]);177178      expect(await collection.methods.tokenPropertyPermissions().call({from: caller.eth})).to.be.like([179        ['testKey_0', [180          [TokenPermissionField.Mutable.toString(), true], 181          [TokenPermissionField.TokenOwner.toString(), true], 182          [TokenPermissionField.CollectionAdmin.toString(), true]],183        ],184        ['testKey_1', [185          [TokenPermissionField.Mutable.toString(), true], 186          [TokenPermissionField.TokenOwner.toString(), false], 187          [TokenPermissionField.CollectionAdmin.toString(), true]],188        ],189        ['testKey_2', [190          [TokenPermissionField.Mutable.toString(), false], 191          [TokenPermissionField.TokenOwner.toString(), true], 192          [TokenPermissionField.CollectionAdmin.toString(), false]],193        ],194      ]);195      196    }));197198  [199    {200      method: 'setProperties',201      methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]],202      expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}],203    },204    {205      method: 'setProperty' /*Soft-deprecated*/, 206      methodParams: ['testKey1', Buffer.from('testValue1')],207      expectedProps: [{key: 'testKey1', value: 'testValue1'}],208    },209  ].map(testCase => 210    itEth(`[${testCase.method}] Can be set`, async({helper}) => {211      const caller = await helper.eth.createAccountWithBalance(donor);212      const collection = await helper.nft.mintCollection(alice, {213        tokenPropertyPermissions: [{214          key: 'testKey1',215          permission: {216            collectionAdmin: true,217          },218        }, {219          key: 'testKey2',220          permission: {221            collectionAdmin: true,222          },223        }],224      });225226      await collection.addAdmin(alice, {Ethereum: caller});227      const token = await collection.mintToken(alice);228  229      const collectionEvm = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller, testCase.method === 'setProperty');230  231      await collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller});232  233      const properties = await token.getProperties();234      expect(properties).to.deep.equal(testCase.expectedProps);235    }));236  237  [238    {mode: 'nft' as const, requiredPallets: []},239    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},240  ].map(testCase => 241    itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {242      const caller = await helper.eth.createAccountWithBalance(donor);243      244      const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });245      const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,246        collectionAdmin: true,247        mutable: true}}; });248      249      const collection = await helper[testCase.mode].mintCollection(alice, {250        tokenPrefix: 'ethp',251        tokenPropertyPermissions: permissions,252      }) as UniqueNFTCollection | UniqueRFTCollection;253      254      const token = await collection.mintToken(alice);255      256      const valuesBefore = await token.getProperties(properties.map(p => p.key));257      expect(valuesBefore).to.be.deep.equal([]);258      259      260      await collection.addAdmin(alice, {Ethereum: caller});261      262      const address = helper.ethAddress.fromCollectionId(collection.collectionId);263      const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);264      265      expect(await contract.methods.properties(token.tokenId, []).call()).to.be.deep.equal([]);266  267      await contract.methods.setProperties(token.tokenId, properties).send({from: caller});268  269      const values = await token.getProperties(properties.map(p => p.key));270      expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));271      272      expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties273        .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));274      275      expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())276        .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);277    }));278  279  [280    {mode: 'nft' as const, requiredPallets: []},281    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},282  ].map(testCase => 283    itEth.ifWithPallets(`Can be deleted for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {284      const caller = await helper.eth.createAccountWithBalance(donor);285      const collection = await helper[testCase.mode].mintCollection(alice, {286        tokenPropertyPermissions: [{287          key: 'testKey',288          permission: {289            mutable: true,290            collectionAdmin: true,291          },292        },293        {294          key: 'testKey_1',295          permission: {296            mutable: true,297            collectionAdmin: true,298          },299        }],300      });301    302      const token = await collection.mintToken(alice);303      await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}, {key: 'testKey_1', value: 'testValue_1'}]);304      expect(await token.getProperties()).to.has.length(2);305306      await collection.addAdmin(alice, {Ethereum: caller});307308      const address = helper.ethAddress.fromCollectionId(collection.collectionId);309      const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);310311      await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});312313      const result = await token.getProperties(['testKey', 'testKey_1']);314      expect(result.length).to.equal(0);315    }));316317  itEth('Can be read', async({helper}) => {318    const caller = helper.eth.createAccount();319    const collection = await helper.nft.mintCollection(alice, {320      tokenPropertyPermissions: [{321        key: 'testKey',322        permission: {323          collectionAdmin: true,324        },325      }],326    });327  328    const token = await collection.mintToken(alice);329    await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);330331    const address = helper.ethAddress.fromCollectionId(collection.collectionId);332    const contract = helper.ethNativeContract.collection(address, 'nft', caller);333334    const value = await contract.methods.property(token.tokenId, 'testKey').call();335    expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));336  });337});338339describe('EVM token properties negative', () => {340  let donor: IKeyringPair;341  let alice: IKeyringPair;342  let caller: string;343  let aliceCollection: UniqueNFTCollection;344  let token: UniqueNFToken;345  const tokenProps = [{key: 'testKey_1', value: 'testValue_1'}, {key: 'testKey_2', value: 'testValue_2'}];346  let collectionEvm: Contract;347348  before(async function() {349    await usingEthPlaygrounds(async (helper, privateKey) => {350      donor = await privateKey({filename: __filename});351      [alice] = await helper.arrange.createAccounts([100n], donor);352    });353  });354355  beforeEach(async () => {356    // 1. create collection with props: testKey_1, testKey_2357    // 2. create token and set props testKey_1, testKey_2358    await usingEthPlaygrounds(async (helper) => {359      aliceCollection = await helper.nft.mintCollection(alice, {360        tokenPropertyPermissions: [{361          key: 'testKey_1',362          permission: {363            mutable: true,364            collectionAdmin: true,365          },366        },367        {368          key: 'testKey_2',369          permission: {370            mutable: true,371            collectionAdmin: true,372          },373        }],374      }); 375      token = await aliceCollection.mintToken(alice);376      await token.setProperties(alice, tokenProps);377      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);378    });379  });380381  [382    {method: 'setProperty', methodParams: [tokenProps[1].key, Buffer.from('newValue')]},383    {method: 'setProperties', methodParams: [[{key: tokenProps[1].key, value: Buffer.from('newValue')}]]},384  ].map(testCase =>385    itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {386      caller = await helper.eth.createAccountWithBalance(donor);387      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);388      // Caller not an owner and not an admin, so he cannot set properties:389      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');390      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;391392      // Props have not changed:393      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));394      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();395      expect(actualProps).to.deep.eq(expectedProps);396    }));397398  [399    {method: 'setProperty', methodParams: ['testKey_3', Buffer.from('testValue3')]},400    {method: 'setProperties', methodParams: [[{key: 'testKey_3', value: Buffer.from('testValue3')}]]},401  ].map(testCase =>402    itEth(`[${testCase.method}] Cannot set non-existing properties`, async ({helper}) => {403      caller = await helper.eth.createAccountWithBalance(donor);404      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);405      await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});406407      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');408      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;409410      // Props have not changed:411      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));412      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();413      expect(actualProps).to.deep.eq(expectedProps);414    }));415416  [417    {method: 'deleteProperty', methodParams: ['testKey_2']},418    {method: 'deleteProperties', methodParams: [['testKey_2']]},419  ].map(testCase =>  420    itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {421      caller = await helper.eth.createAccountWithBalance(donor);422      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');423      // Caller not an owner and not an admin, so he cannot set properties:424      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');425      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;426427      // Props have not changed:428      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));429      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();430      expect(actualProps).to.deep.eq(expectedProps);431    }));432   433  [434    {method: 'deleteProperty', methodParams: ['testKey_3']},435    {method: 'deleteProperties', methodParams: [['testKey_3']]},436  ].map(testCase =>  437    itEth(`[${testCase.method}] Cannot delete non-existing properties`, async ({helper}) => {438      caller = await helper.eth.createAccountWithBalance(donor);439      collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');440      await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});441      // Caller cannot delete non-existing properties:442      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');443      await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;444      // Props have not changed:445      const expectedProps = tokenProps.map(p => helper.ethProperty.property(p.key, p.value.toString()));446      const actualProps = await collectionEvm.methods.properties(token.tokenId, []).call();447      expect(actualProps).to.deep.eq(expectedProps);448    }));449450  [451    {mode: 'nft' as const, requiredPallets: []},452    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},453  ].map(testCase =>454    itEth.ifWithPallets(`[${testCase.mode}] Cannot set token property permissions as non owner or admin`, testCase.requiredPallets, async({helper}) => {455      const owner = await helper.eth.createAccountWithBalance(donor);456      const caller = await helper.eth.createAccountWithBalance(donor);457        458      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');459      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);460  461      await expect(collection.methods.setTokenPropertyPermissions([462        ['testKey_0', [463          [TokenPermissionField.Mutable, true], 464          [TokenPermissionField.TokenOwner, true], 465          [TokenPermissionField.CollectionAdmin, true]],466        ],467      ]).call({from: caller})).to.be.rejectedWith('NoPermission');  468    }));469470  [471    {mode: 'nft' as const, requiredPallets: []},472    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},473  ].map(testCase =>474    itEth.ifWithPallets(`[${testCase.mode}] Cannot set token property permissions with invalid character`, testCase.requiredPallets, async({helper}) => {475      const owner = await helper.eth.createAccountWithBalance(donor);476        477      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');478      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);479  480      await expect(collection.methods.setTokenPropertyPermissions([481        // "Space" is invalid character482        ['testKey 0', [483          [TokenPermissionField.Mutable, true], 484          [TokenPermissionField.TokenOwner, true], 485          [TokenPermissionField.CollectionAdmin, true]],486        ],487      ]).call({from: owner})).to.be.rejectedWith('InvalidCharacterInPropertyKey');  488    }));489490  [491    {mode: 'nft' as const, requiredPallets: []},492    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},493  ].map(testCase =>494    itEth.ifWithPallets(`[${testCase.mode}] Can reconfigure token property permissions to stricter ones`, testCase.requiredPallets, async({helper}) => {495      const owner = await helper.eth.createAccountWithBalance(donor);496              497      const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');498      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);499        500      // 1. Owner sets strict property-permissions:501      await collection.methods.setTokenPropertyPermissions([502        ['testKey', [503          [EthTokenPermissions.Mutable, true], 504          [EthTokenPermissions.TokenOwner, true], 505          [EthTokenPermissions.CollectionAdmin, true]],506        ],507      ]).send({from: owner});508    509      // 2. Owner can set stricter property-permissions:510      for(const values of [[true, true, false], [true, false, false], [false, false, false]]) {511        await collection.methods.setTokenPropertyPermissions([512          ['testKey', [513            [EthTokenPermissions.Mutable, values[0]], 514            [EthTokenPermissions.TokenOwner, values[1]], 515            [EthTokenPermissions.CollectionAdmin, values[2]]],516          ],517        ]).send({from: owner});518      }519520      expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{521        key: 'testKey',522        permission: {mutable: false, collectionAdmin: false, tokenOwner: false},523      }]);524    }));525526  [527    {mode: 'nft' as const, requiredPallets: []},528    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},529  ].map(testCase =>530    itEth.ifWithPallets(`[${testCase.mode}] Cannot reconfigure token property permissions to less strict ones`, testCase.requiredPallets, async({helper}) => {531      const owner = await helper.eth.createAccountWithBalance(donor);532          533      const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');534      const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);535    536      // 1. Owner sets strict property-permissions:537      await collection.methods.setTokenPropertyPermissions([538        ['testKey', [539          [EthTokenPermissions.Mutable, false], 540          [EthTokenPermissions.TokenOwner, false], 541          [EthTokenPermissions.CollectionAdmin, false]],542        ],543      ]).send({from: owner});544545      // 2. Owner cannot set less strict property-permissions:546      for(const values of [[true, false, false], [false, true, false], [false, false, true]]) {547        await expect(collection.methods.setTokenPropertyPermissions([548          ['testKey', [549            [EthTokenPermissions.Mutable, values[0]], 550            [EthTokenPermissions.TokenOwner, values[1]], 551            [EthTokenPermissions.CollectionAdmin, values[2]]],552          ],553        ]).call({from: owner})).to.be.rejectedWith('NoPermission');554      }555    }));556});557558559type ElementOf<A> = A extends readonly (infer T)[] ? T : never;560function* cartesian<T extends Array<Array<any>>, R extends Array<any>>(internalRest: [...R], ...args: [...T]): Generator<[...R, ...{[K in keyof T]: ElementOf<T[K]>}]> {561  if(args.length === 0) {562    yield internalRest as any;563    return;564  }565  for(const value of args[0]) {566    yield* cartesian([...internalRest, value], ...args.slice(1)) as any;567  }568}
modifiedtests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -20,12 +20,12 @@
 
 export type EthProperty = string[];
 
-export enum EthTokenPermissions {
+export enum TokenPermissionField {
   Mutable,
   TokenOwner,
   CollectionAdmin
 }
-export enum CollectionLimits {
+export enum CollectionLimitField {
   AccountTokenOwnership,
 	SponsoredDataSize,
 	SponsoredDataRateLimit,
@@ -36,3 +36,9 @@
 	OwnerCanDestroy,
 	TransferEnabled
 }
+
+export interface EthCollectionLimit {
+  field: CollectionLimitField,
+  status: boolean,
+  value: bigint,
+}