difftreelog
fix bencmark for fee calculation
in: master
Fixed bugs caused by changes in the signatures of interface functions and data structures
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.soldiffbeforeafterboth1// SPDX-License-Identifier: Apache License2pragma solidity >=0.8.0;3import {CollectionHelpers} from "../../eth/api/CollectionHelpers.sol";4import {ContractHelpers} from "../../eth/api/ContractHelpers.sol";5import {UniqueRefungibleToken} from "../../eth/api/UniqueRefungibleToken.sol";6import {UniqueRefungible, Collection, EthCrossAccount as RftCrossAccountId, Tuple20 as RftProperties} from "../../eth/api/UniqueRefungible.sol";7import {UniqueNFT, EthCrossAccount as NftCrossAccountId, Tuple21 as NftProperty, TokenProperties} from "../../eth/api/UniqueNFT.sol";89struct Property {10 string key;11 bytes value;12}1314contract ProxyMint {15 bytes32 constant REFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("ReFungible"));16 bytes32 constant NONFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("NFT"));1718 modifier checkRestrictions(address _collection) {19 Collection commonContract = Collection(_collection);20 require(commonContract.isOwnerOrAdmin(msg.sender), "Only collection admin/owner can call this method");21 _;22 }2324 /// @dev This emits when a mint to a substrate address has been made.25 event MintToSub(address _toEth, uint256 _toSub, address _collection, uint256 _tokenId);2627 function mintToSubstrate(address _collection, uint256 _substrateReceiver) external checkRestrictions(_collection) {28 Collection commonContract = Collection(_collection);29 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));30 uint256 tokenId;3132 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {33 UniqueRefungible rftCollection = UniqueRefungible(_collection);3435 tokenId = rftCollection.mint(address(this));3637 rftCollection.transferFromCross(38 RftCrossAccountId(address(this), 0),39 RftCrossAccountId(address(0), _substrateReceiver),40 tokenId41 );42 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {43 UniqueNFT nftCollection = UniqueNFT(_collection);44 tokenId = nftCollection.mint(address(this));4546 nftCollection.transferFromCross(47 NftCrossAccountId(address(this), 0),48 NftCrossAccountId(address(0), _substrateReceiver),49 tokenId50 );51 } else {52 revert("Wrong collection type. Works only with NFT or RFT");53 }5455 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);56 }5758 function mintToSubstrateWithProperty(59 address _collection,60 uint256 _substrateReceiver,61 Property[] calldata properties62 ) external checkRestrictions(_collection) {63 uint256 propertiesLength = properties.length;64 require(propertiesLength > 0, "Properies is empty");6566 Collection commonContract = Collection(_collection);67 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));68 uint256 tokenId;6970 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {71 UniqueRefungible rftCollection = UniqueRefungible(_collection);72 tokenId = rftCollection.nextTokenId();73 rftCollection.mint(address(this));74 for (uint256 i = 0; i < propertiesLength; ++i) {75 rftCollection.setProperty(tokenId, properties[i].key, properties[i].value);76 }77 rftCollection.transferFromCross(78 RftCrossAccountId(address(this), 0),79 RftCrossAccountId(address(0), _substrateReceiver),80 tokenId81 );82 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {83 UniqueNFT nftCollection = UniqueNFT(_collection);84 tokenId = nftCollection.mint(address(this));85 for (uint256 i = 0; i < propertiesLength; ++i) {86 nftCollection.setProperty(tokenId, properties[i].key, properties[i].value);87 }88 nftCollection.transferFromCross(89 NftCrossAccountId(address(this), 0),90 NftCrossAccountId(address(0), _substrateReceiver),91 tokenId92 );93 } else {94 revert("Wrong collection type. Works only with NFT or RFT");95 }9697 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);98 }99100 function mintToSubstrateBulkProperty(101 address _collection,102 uint256 _substrateReceiver,103 NftProperty[] calldata _properties104 ) external checkRestrictions(_collection) {105 uint256 propertiesLength = _properties.length;106 require(propertiesLength > 0, "Properies is empty");107108 Collection commonContract = Collection(_collection);109 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));110 uint256 tokenId;111112 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {} else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {113 UniqueNFT nftCollection = UniqueNFT(_collection);114 tokenId = nftCollection.mint(address(this));115116 nftCollection.setProperties(tokenId, _properties);117118 nftCollection.transferFromCross(119 NftCrossAccountId(address(this), 0),120 NftCrossAccountId(address(0), _substrateReceiver),121 tokenId122 );123 } else {124 revert("Wrong collection type. Works only with NFT or RFT");125 }126127 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);128 }129}1// SPDX-License-Identifier: Apache License2pragma solidity >=0.8.0;3import {CollectionHelpers} from "../../eth/api/CollectionHelpers.sol";4import {ContractHelpers} from "../../eth/api/ContractHelpers.sol";5import {UniqueRefungibleToken} from "../../eth/api/UniqueRefungibleToken.sol";6import {UniqueRefungible, Collection, CrossAddress as RftCrossAccountId, Property as RftProperty} from "../../eth/api/UniqueRefungible.sol";7import {UniqueNFT, CrossAddress as NftCrossAccountId, Property as NftProperty} from "../../eth/api/UniqueNFT.sol";89struct Property {10 string key;11 bytes value;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 {}31323334contract ProxyMint {35 bytes32 constant REFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("ReFungible"));36 bytes32 constant NONFUNGIBLE_COLLECTION_TYPE = keccak256(bytes("NFT"));3738 modifier checkRestrictions(address _collection) {39 Collection commonContract = Collection(_collection);40 require(41 commonContract.isOwnerOrAdminCross(RftCrossAccountId(msg.sender, 0)),42 "Only collection admin/owner can call this method"43 );44 _;45 }4647 /// @dev This emits when a mint to a substrate address has been made.48 event MintToSub(address _toEth, uint256 _toSub, address _collection, uint256 _tokenId);4950 function mintToSubstrate(address _collection, uint256 _substrateReceiver) external checkRestrictions(_collection) {51 Collection commonContract = Collection(_collection);52 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));53 uint256 tokenId;5455 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {56 UniqueRefungible rftCollection = UniqueRefungible(_collection);5758 tokenId = rftCollection.mint(address(this));5960 rftCollection.transferFromCross(61 RftCrossAccountId(address(this), 0),62 RftCrossAccountId(address(0), _substrateReceiver),63 tokenId64 );65 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {66 UniqueNFT nftCollection = UniqueNFT(_collection);67 tokenId = nftCollection.mint(address(this));6869 nftCollection.transferFromCross(70 NftCrossAccountId(address(this), 0),71 NftCrossAccountId(address(0), _substrateReceiver),72 tokenId73 );74 } else {75 revert("Wrong collection type. Works only with NFT or RFT");76 }7778 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);79 }8081 function mintToSubstrateWithProperty(82 address _collection,83 uint256 _substrateReceiver,84 Property[] calldata _properties85 ) external checkRestrictions(_collection) {86 uint256 propertiesLength = _properties.length;87 require(propertiesLength > 0, "Properies is empty");8889 Collection commonContract = Collection(_collection);90 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));91 uint256 tokenId;9293 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {94 BenchUniqueRefungible rftCollection = BenchUniqueRefungible(_collection);95 tokenId = rftCollection.nextTokenId();96 rftCollection.mint(address(this));9798 for (uint256 i = 0; i < propertiesLength; ++i) {99 rftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);100 }101 rftCollection.transferFromCross(102 RftCrossAccountId(address(this), 0),103 RftCrossAccountId(address(0), _substrateReceiver),104 tokenId105 );106 } else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {107 BenchUniqueNFT nftCollection = BenchUniqueNFT(_collection);108 tokenId = nftCollection.mint(address(this));109 for (uint256 i = 0; i < propertiesLength; ++i) {110 nftCollection.setProperty(tokenId, _properties[i].key, _properties[i].value);111 }112 nftCollection.transferFromCross(113 NftCrossAccountId(address(this), 0),114 NftCrossAccountId(address(0), _substrateReceiver),115 tokenId116 );117 } else {118 revert("Wrong collection type. Works only with NFT or RFT");119 }120121 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);122 }123124 function mintToSubstrateBulkProperty(125 address _collection,126 uint256 _substrateReceiver,127 NftProperty[] calldata _properties128 ) external checkRestrictions(_collection) {129 uint256 propertiesLength = _properties.length;130 require(propertiesLength > 0, "Properies is empty");131132 Collection commonContract = Collection(_collection);133 bytes32 collectionType = keccak256(bytes(commonContract.uniqueCollectionType()));134 uint256 tokenId;135136 if (collectionType == REFUNGIBLE_COLLECTION_TYPE) {} else if (collectionType == NONFUNGIBLE_COLLECTION_TYPE) {137 UniqueNFT nftCollection = UniqueNFT(_collection);138 tokenId = nftCollection.mint(address(this));139140 nftCollection.setProperties(tokenId, _properties);141142 nftCollection.transferFromCross(143 NftCrossAccountId(address(this), 0),144 NftCrossAccountId(address(0), _substrateReceiver),145 tokenId146 );147 } else {148 revert("Wrong collection type. Works only with NFT or RFT");149 }150151 emit MintToSub(address(0), _substrateReceiver, _collection, tokenId);152 }153}