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

difftreelog

fix bencmark for fee calculation

PraetorP2023-01-16parent: #028059e.patch.diff
in: master
Fixed bugs caused by changes in the signatures of interface functions and data structures

2 files changed

modifiedtests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth
293 const evmContract = await helper.ethNativeContract.collection(293 const evmContract = await helper.ethNativeContract.collection(
294 helper.ethAddress.fromCollectionId(collection.collectionId),294 helper.ethAddress.fromCollectionId(collection.collectionId),
295 'nft',295 'nft',
296 undefined,
297 true,
296 );298 );
297299
298 const subTokenId = await evmContract.methods.nextTokenId().call();300 const subTokenId = await evmContract.methods.nextTokenId().call();
351 encodedCall = await evmContract.methods353 encodedCall = await evmContract.methods
352 .setProperties(354 .setProperties(
353 subTokenId,355 subTokenId,
354 PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {356 PROPERTIES.slice(0, setup.propertiesNumber),
355 return {field_0: p.key, field_1: p.value};
356 }),
357 )357 )
358 .encodeABI();358 .encodeABI();
359359
394 .mintToSubstrateBulkProperty(394 .mintToSubstrateBulkProperty(
395 helper.ethAddress.fromCollectionId(collection.collectionId),395 helper.ethAddress.fromCollectionId(collection.collectionId),
396 susbstrateReceiver.addressRaw,396 susbstrateReceiver.addressRaw,
397 PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {397 PROPERTIES.slice(0, setup.propertiesNumber),
398 return {field_0: p.key, field_1: p.value};
399 }),
400 )398 )
401 .send({from: ethSigner, gas: 25_000_000});399 .send({from: ethSigner, gas: 25_000_000});
402 },400 },
modifiedtests/src/benchmarks/mintFee/proxyContract.soldiffbeforeafterboth
--- a/tests/src/benchmarks/mintFee/proxyContract.sol
+++ b/tests/src/benchmarks/mintFee/proxyContract.sol
@@ -3,21 +3,44 @@
 import {CollectionHelpers} from "../../eth/api/CollectionHelpers.sol";
 import {ContractHelpers} from "../../eth/api/ContractHelpers.sol";
 import {UniqueRefungibleToken} from "../../eth/api/UniqueRefungibleToken.sol";
-import {UniqueRefungible, Collection, EthCrossAccount as RftCrossAccountId, Tuple20 as RftProperties} from "../../eth/api/UniqueRefungible.sol";
-import {UniqueNFT, EthCrossAccount as NftCrossAccountId, Tuple21 as NftProperty, TokenProperties} from "../../eth/api/UniqueNFT.sol";
+import {UniqueRefungible, Collection, CrossAddress as RftCrossAccountId, Property as RftProperty} from "../../eth/api/UniqueRefungible.sol";
+import {UniqueNFT, CrossAddress as NftCrossAccountId, Property as NftProperty} from "../../eth/api/UniqueNFT.sol";
 
 struct Property {
 	string key;
 	bytes value;
 }
 
+interface SoftDeprecatedMethods {
+	/// @notice Set token property value.
+	/// @dev Throws error if `msg.sender` has no permission to edit the property.
+	/// @param tokenId ID of the token.
+	/// @param key Property key.
+	/// @param value Property value.
+	/// @dev EVM selector for this function is: 0x1752d67b,
+	///  or in textual repr: setProperty(uint256,string,bytes)
+	function setProperty(
+		uint256 tokenId,
+		string memory key,
+		bytes memory value
+	) external;
+}
+
+interface BenchUniqueRefungible is UniqueRefungible, SoftDeprecatedMethods {}
+interface BenchUniqueNFT is UniqueNFT, SoftDeprecatedMethods {}
+
+
+
 contract ProxyMint {
 	bytes32 constant REFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("ReFungible"));
 	bytes32 constant NONFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("NFT"));
 
 	modifier checkRestrictions(address _collection) {
 		Collection commonContract = Collection(_collection);
-		require(commonContract.isOwnerOrAdmin(msg.sender), "Only collection admin/owner can call this method");
+		require(
+			commonContract.isOwnerOrAdminCross(RftCrossAccountId(msg.sender, 0)),
+			"Only collection admin/owner can call this method"
+		);
 		_;
 	}
 
@@ -58,9 +81,9 @@
 	function mintToSubstrateWithProperty(
 		address _collection,
 		uint256 _substrateReceiver,
-		Property[] calldata properties
+		Property[] calldata _properties
 	) external checkRestrictions(_collection) {
-		uint256 propertiesLength = properties.length;
+		uint256 propertiesLength = _properties.length;
 		require(propertiesLength > 0, "Properies is empty");
 
 		Collection commonContract = Collection(_collection);
@@ -68,11 +91,12 @@
 		uint256 tokenId;
 
 		if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {
-			UniqueRefungible rftCollection = UniqueRefungible(_collection);
+			BenchUniqueRefungible rftCollection = BenchUniqueRefungible(_collection);
 			tokenId = rftCollection.nextTokenId();
 			rftCollection.mint(address(this));
+
 			for (uint256 i = 0; i < propertiesLength; ++i) {
-				rftCollection.setProperty(tokenId, properties[i].key, properties[i].value);
+				rftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);
 			}
 			rftCollection.transferFromCross(
 				RftCrossAccountId(address(this), 0),
@@ -80,10 +104,10 @@
 				tokenId
 			);
 		} else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {
-			UniqueNFT nftCollection = UniqueNFT(_collection);
+			BenchUniqueNFT nftCollection = BenchUniqueNFT(_collection);
 			tokenId = nftCollection.mint(address(this));
 			for (uint256 i = 0; i < propertiesLength; ++i) {
-				nftCollection.setProperty(tokenId, properties[i].key, properties[i].value);
+				nftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);
 			}
 			nftCollection.transferFromCross(
 				NftCrossAccountId(address(this), 0),