git.delta.rocks / unique-network / refs/commits / 7db8050cffa0

difftreelog

Merge pull request #836 from UniqueNetwork/fix/evm-benchmarks

ut-akuznetsov2023-01-17parents: #2991c90 #a68cb1a.patch.diff
in: master

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
3import {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";
88
9struct Property {9struct Property {
10 string key;10 string key;
11 bytes value;11 bytes value;
12}12}
13
14interface 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 value
26 ) external;
27}
28
29interface BenchUniqueRefungible is UniqueRefungible, SoftDeprecatedMethods {}
30interface BenchUniqueNFT is UniqueNFT, SoftDeprecatedMethods {}
31
32
1333
1737
18 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 _properties
62 ) 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");
6588
66 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;
6992
70 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));
97
74 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 tokenId
81 );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),