difftreelog
Merge pull request #836 from UniqueNetwork/fix/evm-benchmarks
in: master
2 files changed
tests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth--- a/tests/src/benchmarks/mintFee/benchmark.ts
+++ b/tests/src/benchmarks/mintFee/benchmark.ts
@@ -293,6 +293,8 @@
const evmContract = await helper.ethNativeContract.collection(
helper.ethAddress.fromCollectionId(collection.collectionId),
'nft',
+ undefined,
+ true,
);
const subTokenId = await evmContract.methods.nextTokenId().call();
@@ -351,9 +353,7 @@
encodedCall = await evmContract.methods
.setProperties(
subTokenId,
- PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {
- return {field_0: p.key, field_1: p.value};
- }),
+ PROPERTIES.slice(0, setup.propertiesNumber),
)
.encodeABI();
@@ -394,9 +394,7 @@
.mintToSubstrateBulkProperty(
helper.ethAddress.fromCollectionId(collection.collectionId),
susbstrateReceiver.addressRaw,
- PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {
- return {field_0: p.key, field_1: p.value};
- }),
+ PROPERTIES.slice(0, setup.propertiesNumber),
)
.send({from: ethSigner, gas: 25_000_000});
},
tests/src/benchmarks/mintFee/proxyContract.soldiffbeforeafterboth3import {CollectionHelpers} from "../../eth/api/CollectionHelpers.sol";3import {CollectionHelpers} from "../../eth/api/CollectionHelpers.sol";4import {ContractHelpers} from "../../eth/api/ContractHelpers.sol";4import {ContractHelpers} from "../../eth/api/ContractHelpers.sol";5import {UniqueRefungibleToken} from "../../eth/api/UniqueRefungibleToken.sol";5import {UniqueRefungibleToken} from "../../eth/api/UniqueRefungibleToken.sol";6import {UniqueRefungible, Collection, EthCrossAccount as RftCrossAccountId, Tuple20 as RftProperties} from "../../eth/api/UniqueRefungible.sol";6import {UniqueRefungible, Collection, CrossAddress as RftCrossAccountId, Property as RftProperty} from "../../eth/api/UniqueRefungible.sol";7import {UniqueNFT, EthCrossAccount as NftCrossAccountId, Tuple21 as NftProperty, TokenProperties} from "../../eth/api/UniqueNFT.sol";7import {UniqueNFT, CrossAddress as NftCrossAccountId, Property as NftProperty} from "../../eth/api/UniqueNFT.sol";889struct Property {9struct Property {10 string key;10 string key;11 bytes value;11 bytes value;12}12}1314interface SoftDeprecatedMethods {15 /// @notice Set token property value.16 /// @dev Throws error if `msg.sender` has no permission to edit the property.17 /// @param tokenId ID of the token.18 /// @param key Property key.19 /// @param value Property value.20 /// @dev EVM selector for this function is: 0x1752d67b,21 /// or in textual repr: setProperty(uint256,string,bytes)22 function setProperty(23 uint256 tokenId,24 string memory key,25 bytes memory value26 ) external;27}2829interface BenchUniqueRefungible is UniqueRefungible, SoftDeprecatedMethods {}30interface BenchUniqueNFT is UniqueNFT, SoftDeprecatedMethods {}31321333173718 modifier checkRestrictions(address _collection) {38 modifier checkRestrictions(address _collection) {19 Collection commonContract = Collection(_collection);39 Collection commonContract = Collection(_collection);20 require(commonContract.isOwnerOrAdmin(msg.sender), "Only collection admin/owner can call this method");40 require(41 commonContract.isOwnerOrAdminCross(RftCrossAccountId(msg.sender, 0)),42 "Only collection admin/owner can call this method"43 );21 _;44 _;58 function mintToSubstrateWithProperty(81 function mintToSubstrateWithProperty(59 address _collection,82 address _collection,60 uint256 _substrateReceiver,83 uint256 _substrateReceiver,61 Property[] calldata properties84 Property[] calldata _properties62 ) external checkRestrictions(_collection) {85 ) external checkRestrictions(_collection) {63 uint256 propertiesLength = properties.length;86 uint256 propertiesLength = _properties.length;64 require(propertiesLength > 0, "Properies is empty");87 require(propertiesLength > 0, "Properies is empty");658866 Collection commonContract = Collection(_collection);89 Collection commonContract = Collection(_collection);67 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));90 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));68 uint256 tokenId;91 uint256 tokenId;699270 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {93 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {71 UniqueRefungible rftCollection = UniqueRefungible(_collection);94 BenchUniqueRefungible rftCollection = BenchUniqueRefungible(_collection);72 tokenId = rftCollection.nextTokenId();95 tokenId = rftCollection.nextTokenId();73 rftCollection.mint(address(this));96 rftCollection.mint(address(this));9774 for (uint256 i = 0; i < propertiesLength; ++i) {98 for (uint256 i = 0; i < propertiesLength; ++i) {75 rftCollection.setProperty(tokenId, properties[i].key, properties[i].value);99 rftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);76 }100 }77 rftCollection.transferFromCross(101 rftCollection.transferFromCross(78 RftCrossAccountId(address(this), 0),102 RftCrossAccountId(address(this), 0),79 RftCrossAccountId(address(0), _substrateReceiver),103 RftCrossAccountId(address(0), _substrateReceiver),80 tokenId104 tokenId81 );105 );82 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {106 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {83 UniqueNFT nftCollection = UniqueNFT(_collection);107 BenchUniqueNFT nftCollection = BenchUniqueNFT(_collection);84 tokenId = nftCollection.mint(address(this));108 tokenId = nftCollection.mint(address(this));85 for (uint256 i = 0; i < propertiesLength; ++i) {109 for (uint256 i = 0; i < propertiesLength; ++i) {86 nftCollection.setProperty(tokenId, properties[i].key, properties[i].value);110 nftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);87 }111 }88 nftCollection.transferFromCross(112 nftCollection.transferFromCross(89 NftCrossAccountId(address(this), 0),113 NftCrossAccountId(address(this), 0),