git.delta.rocks / unique-network / refs/commits / 2e0d1a668d33

difftreelog

feature/setCollectionLimit Behavior of the `setCollectionLimit` method. Removed method overload: single signature `(string, uint256)` is used for both cases.

PraetorP2022-11-16parent: #78a9ca0.patch.diff
in: master

22 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5831,7 +5831,7 @@
 
 [[package]]
 name = "pallet-common"
-version = "0.1.10"
+version = "0.1.11"
 dependencies = [
  "ethereum",
  "evm-coder",
modifiedpallets/common/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -2,10 +2,22 @@
 
 All notable changes to this project will be documented in this file.
 
+<!-- bureaucrate goes here -->
+
+## [0.1.11] - 2022-11-16
+
+### Changed
+
+- Behavior of the `setCollectionLimit` method.
+  Removed method overload: single signature `(string, uint256)`
+  is used for both cases.
+
 ## [0.1.10] - 2022-11-02
+
 ### Changed
- - Use named structure `EthCrossAccount` in eth functions.
 
+- Use named structure `EthCrossAccount` in eth functions.
+
 ## [0.1.9] - 2022-10-13
 
 ## Added
@@ -34,8 +46,6 @@
 ### Added
 
 - New Ethereum API methods: changeOwner, changeOwner(Substrate) and verifyOwnerOrAdmin(Substrate).
-
-<!-- bureaucrate goes here -->
 
 ## [v0.1.5] 2022-08-16
 
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "pallet-common"
-version = "0.1.10"
+version = "0.1.11"
 license = "GPLv3"
 edition = "2021"
 
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -303,11 +303,29 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
+	///  	"ownerCanTransfer",
+	/// 	"ownerCanDestroy",
+	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
 	#[solidity(rename_selector = "setCollectionLimit")]
-	fn set_int_limit(&mut self, caller: caller, limit: string, value: uint32) -> Result<void> {
+	fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {
 		self.consume_store_reads_and_writes(1, 1)?;
 
+		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
+				)))
+			}
+		};
+
 		check_is_owner_or_admin(caller, self)?;
 		let mut limits = self.limits.clone();
 
@@ -330,48 +348,16 @@
 			"sponsorApproveTimeout" => {
 				limits.sponsor_approve_timeout = Some(value);
 			}
-			_ => {
-				return Err(Error::Revert(format!(
-					"unknown integer limit \"{}\"",
-					limit
-				)))
-			}
-		}
-		self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
-			.map_err(dispatch_to_evm::<T>)?;
-		save(self)
-	}
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
-	/// 	"ownerCanDestroy",
-	/// 	"transfersEnabled"
-	/// @param value Value of the limit.
-	#[solidity(rename_selector = "setCollectionLimit")]
-	fn set_bool_limit(&mut self, caller: caller, limit: string, value: bool) -> Result<void> {
-		self.consume_store_reads_and_writes(1, 1)?;
-
-		check_is_owner_or_admin(caller, self)?;
-		let mut limits = self.limits.clone();
-
-		match limit.as_str() {
 			"ownerCanTransfer" => {
-				limits.owner_can_transfer = Some(value);
+				limits.owner_can_transfer = Some(convert_value_to_bool()?);
 			}
 			"ownerCanDestroy" => {
-				limits.owner_can_destroy = Some(value);
+				limits.owner_can_destroy = Some(convert_value_to_bool()?);
 			}
 			"transfersEnabled" => {
-				limits.transfers_enabled = Some(value);
-			}
-			_ => {
-				return Err(Error::Revert(format!(
-					"unknown boolean limit \"{}\"",
-					limit
-				)))
+				limits.transfers_enabled = Some(convert_value_to_bool()?);
 			}
+			_ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),
 		}
 		self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)
 			.map_err(dispatch_to_evm::<T>)?;
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

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 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -167,26 +167,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) public {
-		require(false, stub_error);
-		limit;
-		value;
-		dummy = 0;
-	}
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) public {
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) public {
 		require(false, stub_error);
 		limit;
 		value;
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
@@ -119,7 +119,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -268,26 +268,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) public {
-		require(false, stub_error);
-		limit;
-		value;
-		dummy = 0;
-	}
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) public {
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) public {
 		require(false, stub_error);
 		limit;
 		value;
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
@@ -119,7 +119,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 contract Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -268,26 +268,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) public {
-		require(false, stub_error);
-		limit;
-		value;
-		dummy = 0;
-	}
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) public {
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) public {
 		require(false, stub_error);
 		limit;
 		value;
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -390,17 +390,7 @@
   {
     "inputs": [
       { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "uint32", "name": "value", "type": "uint32" }
-    ],
-    "name": "setCollectionLimit",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "bool", "name": "value", "type": "bool" }
+      { "internalType": "uint256", "name": "value", "type": "uint256" }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -505,17 +505,7 @@
   {
     "inputs": [
       { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "uint32", "name": "value", "type": "uint32" }
-    ],
-    "name": "setCollectionLimit",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "bool", "name": "value", "type": "bool" }
+      { "internalType": "uint256", "name": "value", "type": "uint256" }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -487,17 +487,7 @@
   {
     "inputs": [
       { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "uint32", "name": "value", "type": "uint32" }
-    ],
-    "name": "setCollectionLimit",
-    "outputs": [],
-    "stateMutability": "nonpayable",
-    "type": "function"
-  },
-  {
-    "inputs": [
-      { "internalType": "string", "name": "limit", "type": "string" },
-      { "internalType": "bool", "name": "value", "type": "bool" }
+      { "internalType": "uint256", "name": "value", "type": "uint256" }
     ],
     "name": "setCollectionLimit",
     "outputs": [],
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 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -113,21 +113,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) external;
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) external;
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -80,7 +80,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -180,21 +180,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) external;
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) external;
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -80,7 +80,7 @@
 }
 
 /// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0x324a7f5b
+/// @dev the ERC-165 identifier for this interface is 0x8b91d192
 interface Collection is Dummy, ERC165 {
 	// /// Set collection property.
 	// ///
@@ -180,21 +180,13 @@
 	/// 	"tokenLimit",
 	/// 	"sponsorTransferTimeout",
 	/// 	"sponsorApproveTimeout"
-	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x6a3841db,
-	///  or in textual repr: setCollectionLimit(string,uint32)
-	function setCollectionLimit(string memory limit, uint32 value) external;
-
-	/// Set limits for the collection.
-	/// @dev Throws error if limit not found.
-	/// @param limit Name of the limit. Valid names:
-	/// 	"ownerCanTransfer",
+	///  	"ownerCanTransfer",
 	/// 	"ownerCanDestroy",
 	/// 	"transfersEnabled"
 	/// @param value Value of the limit.
-	/// @dev EVM selector for this function is: 0x993b7fba,
-	///  or in textual repr: setCollectionLimit(string,bool)
-	function setCollectionLimit(string memory limit, bool value) external;
+	/// @dev EVM selector for this function is: 0x4ad890a8,
+	///  or in textual repr: setCollectionLimit(string,uint256)
+	function setCollectionLimit(string memory limit, uint256 value) external;
 
 	/// Get contract address.
 	/// @dev EVM selector for this function is: 0xf6b4dfb4,
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -85,32 +85,44 @@
       tokenLimit: 1000000,
       sponsorTransferTimeout: 6,
       sponsorApproveTimeout: 6,
+      ownerCanTransfer: 0,
+      ownerCanDestroy: 0,
+      transfersEnabled: 0,
+    };
+    
+    const expectedLimits = {
+      accountTokenOwnershipLimit: 1000,
+      sponsoredDataSize: 1024,
+      sponsoredDataRateLimit: 30,
+      tokenLimit: 1000000,
+      sponsorTransferTimeout: 6,
+      sponsorApproveTimeout: 6,
       ownerCanTransfer: false,
       ownerCanDestroy: false,
       transfersEnabled: false,
     };
-
+   
     const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
-    await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
-    await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
-    await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
-    await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+    await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+    await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
+    await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+    await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
+    await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+    await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+    await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
+    await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
+    await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
     
     const data = (await helper.rft.getData(collectionId))!;
-    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
-    expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
-    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
-    expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
-    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
-    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
-    expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
-    expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
-    expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
   });
 
   itEth('Collection address exist', async ({helper}) => {
@@ -257,11 +269,28 @@
   });
 
   itEth('(!negative test!) Set limits', async ({helper}) => {
+
+    const invalidLimits = {
+      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+      transfersEnabled: 3,
+    };
+
     const owner = await helper.eth.createAccountWithBalance(donor);
     const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
     await expect(collectionEvm.methods
-      .setCollectionLimit('badLimit', 'true')
-      .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+      .setCollectionLimit('badLimit', '1')
+      .call()).to.be.rejectedWith('unknown limit "badLimit"');
+    
+    await expect(collectionEvm.methods
+      .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+    
+    await expect(collectionEvm.methods
+      .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
   });
+
+   
+    
 });
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
before · tests/src/eth/createNFTCollection.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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';19import {expect, itEth, usingEthPlaygrounds} from './util';202122describe('Create NFT collection from EVM', () => {23  let donor: IKeyringPair;2425  before(async function () {26    await usingEthPlaygrounds(async (_helper, privateKey) => {27      donor = await privateKey({filename: __filename});28    });29  });3031  itEth('Create collection with properties', async ({helper}) => {32    const owner = await helper.eth.createAccountWithBalance(donor);3334    const name = 'CollectionEVM';35    const description = 'Some description';36    const prefix = 'token prefix';37    const baseUri = 'BaseURI';3839    const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);4041    expect(events).to.be.deep.equal([42      {43        address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',44        event: 'CollectionCreated',45        args: {46          owner: owner,47          collectionId: collectionAddress,48        },49      },50    ]);5152    const collection = helper.nft.getCollectionObject(collectionId);53    const data = (await collection.getData())!;54    55    expect(data.name).to.be.eq(name);56    expect(data.description).to.be.eq(description);57    expect(data.raw.tokenPrefix).to.be.eq(prefix);58    expect(data.raw.mode).to.be.eq('NFT');5960    const options = await collection.getOptions();61    expect(options.tokenPropertyPermissions).to.be.deep.equal([62      {63        key: 'URI',64        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},65      },66      {67        key: 'URISuffix',68        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},69      },70    ]);71  });7273  // Soft-deprecated74  itEth('[eth] Set sponsorship', async ({helper}) => {75    const owner = await helper.eth.createAccountWithBalance(donor);76    const sponsor = await helper.eth.createAccountWithBalance(donor);77    const ss58Format = helper.chain.getChainProperties().ss58Format;78    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');7980    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);81    await collection.methods.setCollectionSponsor(sponsor).send();8283    let data = (await helper.nft.getData(collectionId))!;84    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));8586    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');8788    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);89    await sponsorCollection.methods.confirmCollectionSponsorship().send();9091    data = (await helper.nft.getData(collectionId))!;92    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));93  });9495  itEth('[cross] Set sponsorship', async ({helper}) => {96    const owner = await helper.eth.createAccountWithBalance(donor);97    const sponsor = await helper.eth.createAccountWithBalance(donor);98    const ss58Format = helper.chain.getChainProperties().ss58Format;99    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');100101    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);102    const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);103    await collection.methods.setCollectionSponsorCross(sponsorCross).send();104105    let data = (await helper.nft.getData(collectionId))!;106    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));107108    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');109110    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);111    await sponsorCollection.methods.confirmCollectionSponsorship().send();112113    data = (await helper.nft.getData(collectionId))!;114    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));115  });116117  itEth('Set limits', async ({helper}) => {118    const owner = await helper.eth.createAccountWithBalance(donor);119    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');120    const limits = {121      accountTokenOwnershipLimit: 1000,122      sponsoredDataSize: 1024,123      sponsoredDataRateLimit: 30,124      tokenLimit: 1000000,125      sponsorTransferTimeout: 6,126      sponsorApproveTimeout: 6,127      ownerCanTransfer: false,128      ownerCanDestroy: false,129      transfersEnabled: false,130    };131132    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);133    await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();134    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();135    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();136    await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();137    await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();138    await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();139    await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();140    await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();141    await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();142143    const data = (await helper.nft.getData(collectionId))!;144    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);145    expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);146    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);147    expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);148    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);149    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);150    expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);151    expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);152    expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);153  });154155  itEth('Collection address exist', async ({helper}) => {156    const owner = await helper.eth.createAccountWithBalance(donor);157    const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';158    expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)159      .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())160      .to.be.false;161162    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');163    expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)164      .methods.isCollectionExist(collectionAddress).call())165      .to.be.true;166  });167});168169describe('(!negative tests!) Create NFT collection from EVM', () => {170  let donor: IKeyringPair;171  let nominal: bigint;172173  before(async function () {174    await usingEthPlaygrounds(async (helper, privateKey) => {175      donor = await privateKey({filename: __filename});176      nominal = helper.balance.getOneTokenNominal();177    });178  });179180  itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {181    const owner = await helper.eth.createAccountWithBalance(donor);182    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);183    {184      const MAX_NAME_LENGTH = 64;185      const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);186      const description = 'A';187      const tokenPrefix = 'A';188189      await expect(collectionHelper.methods190        .createNFTCollection(collectionName, description, tokenPrefix)191        .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);192193    }194    {195      const MAX_DESCRIPTION_LENGTH = 256;196      const collectionName = 'A';197      const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);198      const tokenPrefix = 'A';199      await expect(collectionHelper.methods200        .createNFTCollection(collectionName, description, tokenPrefix)201        .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);202    }203    {204      const MAX_TOKEN_PREFIX_LENGTH = 16;205      const collectionName = 'A';206      const description = 'A';207      const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);208      await expect(collectionHelper.methods209        .createNFTCollection(collectionName, description, tokenPrefix)210        .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);211    }212  });213214  itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {215    const owner = await helper.eth.createAccountWithBalance(donor);216    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);217    await expect(collectionHelper.methods218      .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')219      .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');220  });221222  // Soft-deprecated223  itEth('(!negative test!) [eth] Check owner', async ({helper}) => {224    const owner = await helper.eth.createAccountWithBalance(donor);225    const malfeasant = helper.eth.createAccount();226    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');227    const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);228    const EXPECTED_ERROR = 'NoPermission';229    {230      const sponsor = await helper.eth.createAccountWithBalance(donor);231      await expect(malfeasantCollection.methods232        .setCollectionSponsor(sponsor)233        .call()).to.be.rejectedWith(EXPECTED_ERROR);234235      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);236      await expect(sponsorCollection.methods237        .confirmCollectionSponsorship()238        .call()).to.be.rejectedWith('caller is not set as sponsor');239    }240    {241      await expect(malfeasantCollection.methods242        .setCollectionLimit('account_token_ownership_limit', '1000')243        .call()).to.be.rejectedWith(EXPECTED_ERROR);244    }245  });246247  itEth('(!negative test!) [cross] Check owner', async ({helper}) => {248    const owner = await helper.eth.createAccountWithBalance(donor);249    const malfeasant = helper.eth.createAccount();250    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');251    const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);252    const EXPECTED_ERROR = 'NoPermission';253    {254      const sponsor = await helper.eth.createAccountWithBalance(donor);255      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);256      await expect(malfeasantCollection.methods257        .setCollectionSponsorCross(sponsorCross)258        .call()).to.be.rejectedWith(EXPECTED_ERROR);259260      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);261      await expect(sponsorCollection.methods262        .confirmCollectionSponsorship()263        .call()).to.be.rejectedWith('caller is not set as sponsor');264    }265    {266      await expect(malfeasantCollection.methods267        .setCollectionLimit('account_token_ownership_limit', '1000')268        .call()).to.be.rejectedWith(EXPECTED_ERROR);269    }270  });271272  itEth('(!negative test!) Set limits', async ({helper}) => {273    const owner = await helper.eth.createAccountWithBalance(donor);274    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');275    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);276    await expect(collectionEvm.methods277      .setCollectionLimit('badLimit', 'true')278      .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');279  });280281  itEth('destroyCollection', async ({helper}) => {282    const owner = await helper.eth.createAccountWithBalance(donor);283    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');284    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);285286287    const result = await collectionHelper.methods288      .destroyCollection(collectionAddress)289      .send({from: owner});290291    const events = helper.eth.normalizeEvents(result.events);292    293    expect(events).to.be.deep.equal([294      {295        address: collectionHelper.options.address,296        event: 'CollectionDestroyed',297        args: {298          collectionId: collectionAddress,299        },300      },301    ]);302303    expect(await collectionHelper.methods304      .isCollectionExist(collectionAddress)305      .call()).to.be.false;306  });307});
after · tests/src/eth/createNFTCollection.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.8//9// 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 {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';19import {expect, itEth, usingEthPlaygrounds} from './util';202122describe('Create NFT collection from EVM', () => {23  let donor: IKeyringPair;2425  before(async function () {26    await usingEthPlaygrounds(async (_helper, privateKey) => {27      donor = await privateKey({filename: __filename});28    });29  });3031  itEth('Create collection with properties', async ({helper}) => {32    const owner = await helper.eth.createAccountWithBalance(donor);3334    const name = 'CollectionEVM';35    const description = 'Some description';36    const prefix = 'token prefix';37    const baseUri = 'BaseURI';3839    const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);4041    expect(events).to.be.deep.equal([42      {43        address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',44        event: 'CollectionCreated',45        args: {46          owner: owner,47          collectionId: collectionAddress,48        },49      },50    ]);5152    const collection = helper.nft.getCollectionObject(collectionId);53    const data = (await collection.getData())!;54    55    expect(data.name).to.be.eq(name);56    expect(data.description).to.be.eq(description);57    expect(data.raw.tokenPrefix).to.be.eq(prefix);58    expect(data.raw.mode).to.be.eq('NFT');5960    const options = await collection.getOptions();61    expect(options.tokenPropertyPermissions).to.be.deep.equal([62      {63        key: 'URI',64        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},65      },66      {67        key: 'URISuffix',68        permission: {mutable: true, collectionAdmin: true, tokenOwner: false},69      },70    ]);71  });7273  // Soft-deprecated74  itEth('[eth] Set sponsorship', async ({helper}) => {75    const owner = await helper.eth.createAccountWithBalance(donor);76    const sponsor = await helper.eth.createAccountWithBalance(donor);77    const ss58Format = helper.chain.getChainProperties().ss58Format;78    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');7980    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);81    await collection.methods.setCollectionSponsor(sponsor).send();8283    let data = (await helper.nft.getData(collectionId))!;84    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));8586    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');8788    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);89    await sponsorCollection.methods.confirmCollectionSponsorship().send();9091    data = (await helper.nft.getData(collectionId))!;92    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));93  });9495  itEth('[cross] Set sponsorship', async ({helper}) => {96    const owner = await helper.eth.createAccountWithBalance(donor);97    const sponsor = await helper.eth.createAccountWithBalance(donor);98    const ss58Format = helper.chain.getChainProperties().ss58Format;99    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');100101    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);102    const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);103    await collection.methods.setCollectionSponsorCross(sponsorCross).send();104105    let data = (await helper.nft.getData(collectionId))!;106    expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));107108    await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');109110    const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);111    await sponsorCollection.methods.confirmCollectionSponsorship().send();112113    data = (await helper.nft.getData(collectionId))!;114    expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));115  });116117  itEth('Set limits', async ({helper}) => {118    const owner = await helper.eth.createAccountWithBalance(donor);119    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'FLO');120    const limits = {121      accountTokenOwnershipLimit: 1000,122      sponsoredDataSize: 1024,123      sponsoredDataRateLimit: 30,124      tokenLimit: 1000000,125      sponsorTransferTimeout: 6,126      sponsorApproveTimeout: 6,127      ownerCanTransfer: 0,128      ownerCanDestroy: 0,129      transfersEnabled: 0,130    };131    132    const expectedLimits = {133      accountTokenOwnershipLimit: 1000,134      sponsoredDataSize: 1024,135      sponsoredDataRateLimit: 30,136      tokenLimit: 1000000,137      sponsorTransferTimeout: 6,138      sponsorApproveTimeout: 6,139      ownerCanTransfer: false,140      ownerCanDestroy: false,141      transfersEnabled: false,142    };143144    const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);145    await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();146    await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();147    await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();148    await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();149    await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();150    await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();151    await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();152    await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();153    await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();154155    const data = (await helper.rft.getData(collectionId))!;156    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);157    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);158    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);159    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);160    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);161    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);162    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);163    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);164    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);165  });166167  itEth('Collection address exist', async ({helper}) => {168    const owner = await helper.eth.createAccountWithBalance(donor);169    const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';170    expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)171      .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())172      .to.be.false;173174    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');175    expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)176      .methods.isCollectionExist(collectionAddress).call())177      .to.be.true;178  });179});180181describe('(!negative tests!) Create NFT collection from EVM', () => {182  let donor: IKeyringPair;183  let nominal: bigint;184185  before(async function () {186    await usingEthPlaygrounds(async (helper, privateKey) => {187      donor = await privateKey({filename: __filename});188      nominal = helper.balance.getOneTokenNominal();189    });190  });191192  itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {193    const owner = await helper.eth.createAccountWithBalance(donor);194    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);195    {196      const MAX_NAME_LENGTH = 64;197      const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);198      const description = 'A';199      const tokenPrefix = 'A';200201      await expect(collectionHelper.methods202        .createNFTCollection(collectionName, description, tokenPrefix)203        .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);204205    }206    {207      const MAX_DESCRIPTION_LENGTH = 256;208      const collectionName = 'A';209      const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);210      const tokenPrefix = 'A';211      await expect(collectionHelper.methods212        .createNFTCollection(collectionName, description, tokenPrefix)213        .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);214    }215    {216      const MAX_TOKEN_PREFIX_LENGTH = 16;217      const collectionName = 'A';218      const description = 'A';219      const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);220      await expect(collectionHelper.methods221        .createNFTCollection(collectionName, description, tokenPrefix)222        .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);223    }224  });225226  itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {227    const owner = await helper.eth.createAccountWithBalance(donor);228    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);229    await expect(collectionHelper.methods230      .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')231      .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');232  });233234  // Soft-deprecated235  itEth('(!negative test!) [eth] Check owner', async ({helper}) => {236    const owner = await helper.eth.createAccountWithBalance(donor);237    const malfeasant = helper.eth.createAccount();238    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');239    const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);240    const EXPECTED_ERROR = 'NoPermission';241    {242      const sponsor = await helper.eth.createAccountWithBalance(donor);243      await expect(malfeasantCollection.methods244        .setCollectionSponsor(sponsor)245        .call()).to.be.rejectedWith(EXPECTED_ERROR);246247      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);248      await expect(sponsorCollection.methods249        .confirmCollectionSponsorship()250        .call()).to.be.rejectedWith('caller is not set as sponsor');251    }252    {253      await expect(malfeasantCollection.methods254        .setCollectionLimit('account_token_ownership_limit', '1000')255        .call()).to.be.rejectedWith(EXPECTED_ERROR);256    }257  });258259  itEth('(!negative test!) [cross] Check owner', async ({helper}) => {260    const owner = await helper.eth.createAccountWithBalance(donor);261    const malfeasant = helper.eth.createAccount();262    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');263    const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);264    const EXPECTED_ERROR = 'NoPermission';265    {266      const sponsor = await helper.eth.createAccountWithBalance(donor);267      const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);268      await expect(malfeasantCollection.methods269        .setCollectionSponsorCross(sponsorCross)270        .call()).to.be.rejectedWith(EXPECTED_ERROR);271272      const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);273      await expect(sponsorCollection.methods274        .confirmCollectionSponsorship()275        .call()).to.be.rejectedWith('caller is not set as sponsor');276    }277    {278      await expect(malfeasantCollection.methods279        .setCollectionLimit('account_token_ownership_limit', '1000')280        .call()).to.be.rejectedWith(EXPECTED_ERROR);281    }282  });283284  itEth('(!negative test!) Set limits', async ({helper}) => {285    const invalidLimits = {286      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),287      transfersEnabled: 3,288    };289290    const owner = await helper.eth.createAccountWithBalance(donor);291    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');292    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);293    294    await expect(collectionEvm.methods295      .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)296      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);297    298    await expect(collectionEvm.methods299      .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)300      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);301  });302303  itEth('destroyCollection', async ({helper}) => {304    const owner = await helper.eth.createAccountWithBalance(donor);305    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');306    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);307308309    const result = await collectionHelper.methods310      .destroyCollection(collectionAddress)311      .send({from: owner});312313    const events = helper.eth.normalizeEvents(result.events);314    315    expect(events).to.be.deep.equal([316      {317        address: collectionHelper.options.address,318        event: 'CollectionDestroyed',319        args: {320          collectionId: collectionAddress,321        },322      },323    ]);324325    expect(await collectionHelper.methods326      .isCollectionExist(collectionAddress)327      .call()).to.be.false;328  });329});
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -159,32 +159,44 @@
       tokenLimit: 1000000,
       sponsorTransferTimeout: 6,
       sponsorApproveTimeout: 6,
+      ownerCanTransfer: 0,
+      ownerCanDestroy: 0,
+      transfersEnabled: 0,
+    };
+    
+    const expectedLimits = {
+      accountTokenOwnershipLimit: 1000,
+      sponsoredDataSize: 1024,
+      sponsoredDataRateLimit: 30,
+      tokenLimit: 1000000,
+      sponsorTransferTimeout: 6,
+      sponsorApproveTimeout: 6,
       ownerCanTransfer: false,
       ownerCanDestroy: false,
       transfersEnabled: false,
     };
-
+    
     const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
-    await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
-    await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
-    await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
-    await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
-    await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+    await collection.methods.setCollectionLimit('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+    await collection.methods.setCollectionLimit('sponsoredDataSize', limits.sponsoredDataSize).send();
+    await collection.methods.setCollectionLimit('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+    await collection.methods.setCollectionLimit('tokenLimit', limits.tokenLimit).send();
+    await collection.methods.setCollectionLimit('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+    await collection.methods.setCollectionLimit('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+    await collection.methods.setCollectionLimit('ownerCanTransfer', limits.ownerCanTransfer).send();
+    await collection.methods.setCollectionLimit('ownerCanDestroy', limits.ownerCanDestroy).send();
+    await collection.methods.setCollectionLimit('transfersEnabled', limits.transfersEnabled).send();
     
     const data = (await helper.rft.getData(collectionId))!;
-    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
-    expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
-    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
-    expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
-    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
-    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
-    expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
-    expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
-    expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+    expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(expectedLimits.accountTokenOwnershipLimit);
+    expect(data.raw.limits.sponsoredDataSize).to.be.eq(expectedLimits.sponsoredDataSize);
+    expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(expectedLimits.sponsoredDataRateLimit);
+    expect(data.raw.limits.tokenLimit).to.be.eq(expectedLimits.tokenLimit);
+    expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(expectedLimits.sponsorTransferTimeout);
+    expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(expectedLimits.sponsorApproveTimeout);
+    expect(data.raw.limits.ownerCanTransfer).to.be.eq(expectedLimits.ownerCanTransfer);
+    expect(data.raw.limits.ownerCanDestroy).to.be.eq(expectedLimits.ownerCanDestroy);
+    expect(data.raw.limits.transfersEnabled).to.be.eq(expectedLimits.transfersEnabled);
   });
 
   itEth('Collection address exist', async ({helper}) => {
@@ -305,12 +317,22 @@
   });
 
   itEth('(!negative test!) Set limits', async ({helper}) => {
+    const invalidLimits = {
+      accountTokenOwnershipLimit: BigInt(Number.MAX_SAFE_INTEGER),
+      transfersEnabled: 3,
+    };
+
     const owner = await helper.eth.createAccountWithBalance(donor);
     const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+    
+    await expect(collectionEvm.methods
+      .setCollectionLimit(Object.keys(invalidLimits)[0], invalidLimits.accountTokenOwnershipLimit)
+      .call()).to.be.rejectedWith(`can't convert value to u32 "${invalidLimits.accountTokenOwnershipLimit}"`);
+    
     await expect(collectionEvm.methods
-      .setCollectionLimit('badLimit', 'true')
-      .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+      .setCollectionLimit(Object.keys(invalidLimits)[1], invalidLimits.transfersEnabled)
+      .call()).to.be.rejectedWith(`can't convert value to boolean "${invalidLimits.transfersEnabled}"`);
   });
   
   itEth('destroyCollection', async ({helper}) => {