difftreelog
feat added zeppelin erc20 measurements
in: master
66 files changed
tests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth1import {EthUniqueHelper, SponsoringMode, usingEthPlaygrounds} from '../../eth/util';1import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';2import {readFile} from 'fs/promises';2import {readFile} from 'fs/promises';3import {CollectionLimitField, ContractImports, TokenPermissionField} from '../../eth/util/playgrounds/types';3import {CollectionLimitField, ContractImports, TokenPermissionField} from '../../eth/util/playgrounds/types';4import {4import {5 ICrossAccountId,5 ICrossAccountId,6 ITokenPropertyPermission,6 ITokenPropertyPermission,7 TCollectionMode,7} from '../../util/playgrounds/types';8} from '../../util/playgrounds/types';8import {IKeyringPair} from '@polkadot/types/types';9import {IKeyringPair} from '@polkadot/types/types';9import {UniqueNFTCollection} from '../../util/playgrounds/unique';10import {UniqueFTCollection, UniqueNFTCollection, UniqueRFTCollection} from '../../util/playgrounds/unique';10import {Contract} from 'web3-eth-contract';11import {Contract} from 'web3-eth-contract';11import {createObjectCsvWriter} from 'csv-writer';12import {createObjectCsvWriter} from 'csv-writer';13import {FunctionFeeVM, IFunctionFee} from './types';121413const CONTRACT_IMPORT: ContractImports[] = [15const CONTRACT_IMPORT: ContractImports[] = [14 {16 {71 evmProxyContractFee: number;73 evmProxyContractFee: number;72 evmProxyContractBulkFee: number;74 evmProxyContractBulkFee: number;73}75}74interface IBenchmarkCollection {7675 createFee: number,76 mintFee: number,77 transferFee: number,78}79const main = async () => {77const main = async () => {80 const benchmarks = [78 const benchmarks = [81 'substrateFee',79 'substrateFee',101 const CONTRACT_SOURCE = (99 const CONTRACT_SOURCE = (102 await readFile(`${__dirname}/proxyContract.sol`)100 await readFile(`${__dirname}/proxyContract.sol`)103 ).toString();101 ).toString();104 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.bin`)).toString();105 const ZEPPELIN_ABI = JSON.parse((await readFile(`${__dirname}/openZeppelin/bin/ZeppelinContract.abi`)).toString());106102103 console.log('\n ERC20 ops fees');104 console.table(FunctionFeeVM.fromModel(await erc20CalculateFeeGas(helper, privateKey)));105107 console.log('\n ERC721 ops fees');106 console.log('\n ERC721 ops fees');108 console.table(await ERC721CalculateFeeGas(helper, privateKey), ['fee', 'gas', 'substrate']);107 const erc721 = await erc721CalculateFeeGas(helper, privateKey);108 console.table(FunctionFeeVM.fromModel(erc721));109109110 const donor = await privateKey('//Alice'); // Seed from account with balance on this network110 const donor = await privateKey('//Alice'); // Seed from account with balance on this network111 const [substrateReceiver] = await helper.arrange.createAccounts([10n], donor);112113 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);111 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);114 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 5n);115112116 let susbtrateCollection: UniqueNFTCollection | null;117 const createCollectionSubstrateFee = convertToTokens(118 await helper.arrange.calculcateFee({Substrate: donor.address}, async () => {119 susbtrateCollection = await helper.nft.mintCollection(donor, {tokenPropertyPermissions: [120 {121 key: 'url',122 permission: {123 tokenOwner: true,124 collectionAdmin: true,125 mutable: true,126 },127 },128 ]});129 }),130 NOMINAL,131 );132133 const susbstrateMintFee = convertToTokens(134 await helper.arrange.calculcateFee(135 {Substrate: donor.address},136 () => susbtrateCollection!.mintToken(donor, {Substrate: substrateReceiver.address}, [{key: 'url', value: 'test'}]),137 ),138 NOMINAL,139 );140 const susbstrateTransferFee = convertToTokens(141 await helper.arrange.calculcateFee(142 {Substrate: substrateReceiver.address},143 () => susbtrateCollection!.transferToken(substrateReceiver, 1, {Substrate: donor.address}),144 ),145 NOMINAL,146 );147 const substrateFee: IBenchmarkCollection = {148 createFee: createCollectionSubstrateFee,149 mintFee: susbstrateMintFee,150 transferFee: susbstrateTransferFee,151 };152153 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);154155 let ethContract: Contract | null = null;156157 const createCollectionEthFee = convertToTokens(158 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {159 const result = await helperContract.methods.createNFTCollection('a', 'b', 'c').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())});160 ethContract = await helper.ethNativeContract.collection(helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId), 'nft', ethSigner);161 }),162 NOMINAL,163 );164165 await ethContract!.methods.setTokenPropertyPermissions([166 ['url', [167 [TokenPermissionField.Mutable, true],168 [TokenPermissionField.TokenOwner, true],169 [TokenPermissionField.CollectionAdmin, true]],170 ],171 ]).send({from: ethSigner});172173 const ethMintFee = convertToTokens(await helper.arrange.calculcateFee(174 {Ethereum: ethSigner},175 () => ethContract!.methods.mintCross(176 helper.ethCrossAccount.fromAddress(ethReceiver),177 [{key: 'url', value: Buffer.from('test')}],178 )179 .send({from: ethSigner}),180 ), NOMINAL);181182 const ethTransferFee = convertToTokens(await helper.arrange.calculcateFee(183 {Ethereum: ethReceiver},184 () => ethContract!.methods.transferFrom(ethReceiver, ethSigner, 1)185 .send({from: ethReceiver}),186 ), NOMINAL);187188 const ethFee: IBenchmarkCollection = {189 createFee: createCollectionEthFee,190 mintFee: ethMintFee,191 transferFee: ethTransferFee,192 };193194 let zeppelelinContract: Contract | null = null;195196 const zeppelinDeployFee = convertToTokens(197 await helper.arrange.calculcateFee({Ethereum: ethSigner}, async () => {198 zeppelelinContract = await helper.ethContract.deployByAbi(199 ethSigner,200 ZEPPELIN_ABI,201 ZEPPELIN_OBJECT,202 );203 }),204 NOMINAL,205 );206207 const zeppelinMintFee = convertToTokens(await helper.arrange.calculcateFee(208 {Ethereum: ethSigner},209 () => zeppelelinContract!.methods.safeMint(ethReceiver, 'test').send({from: ethSigner}),210 ), NOMINAL);211212213 const zeppelinTransferFee = convertToTokens(await helper.arrange.calculcateFee(214 {Ethereum: ethReceiver},215 () => zeppelelinContract!.methods.safeTransferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),216 ), NOMINAL);217218 const zeppelinFee: IBenchmarkCollection = {219 createFee: zeppelinDeployFee,220 mintFee: zeppelinMintFee,221 transferFee: zeppelinTransferFee,222 };223224 console.log('collection ops fees');225 const results = {substrate: substrateFee, eth: ethFee, zeppelin: zeppelinFee};226 console.table(results);227228 const contract = await helper.ethContract.deployByCode(113 const contract = await helper.ethContract.deployByCode(229 ethSigner,114 ethSigner,270 });155 });271156272async function createCollectionForBenchmarks(157async function createCollectionForBenchmarks(158 mode : TCollectionMode,273 helper: EthUniqueHelper,159 helper: EthUniqueHelper,274 privateKey: (seed: string) => Promise<IKeyringPair>,160 privateKey: (seed: string) => Promise<IKeyringPair>,275 ethSigner: string,161 ethSigner: string,278) {164) {279 const donor = await privateKey('//Alice');165 const donor = await privateKey('//Alice');280166281 const collection = await helper.nft.mintCollection(donor, {167 const collection = await helper[mode].mintCollection(donor, {282 name: 'test mintToSubstrate',168 name: 'test mintToSubstrate',283 description: 'EVMHelpers',169 description: 'EVMHelpers',284 tokenPrefix: 'ap',170 tokenPrefix: mode,171 ...(mode != 'ft' ? {285 tokenPropertyPermissions: [172 tokenPropertyPermissions: [286 {173 {287 key: 'url',174 key: 'url',288 permission: {175 permission: {289 tokenOwner: true,176 tokenOwner: true,290 collectionAdmin: true,177 collectionAdmin: true,291 mutable: true,178 mutable: true,179 },292 },180 },293 },181 {294 {182 key: 'URI',295 key: 'URI',296 permission: {183 permission: {297 tokenOwner: true,184 tokenOwner: true,298 collectionAdmin: true,185 collectionAdmin: true,299 mutable: true,186 mutable: true,187 },300 },188 },301 },189 ],302 ],190 } : {}),303 limits: {sponsorTransferTimeout: 0, sponsorApproveTimeout: 0},191 limits: {sponsorTransferTimeout: 0, sponsorApproveTimeout: 0},304 permissions: {mintMode: true},192 permissions: {mintMode: true},305 });193 });317 await collection.addToAllowList(donor, {Ethereum: proxyContract});205 await collection.addToAllowList(donor, {Ethereum: proxyContract});318 await collection.addAdmin(donor, {Ethereum: proxyContract});206 await collection.addAdmin(donor, {Ethereum: proxyContract});319 }207 }208 if (collection instanceof UniqueNFTCollection || collection instanceof UniqueRFTCollection)209 await collection.setTokenPropertyPermissions(donor, permissions);320210321 await collection.setTokenPropertyPermissions(donor, permissions);322323 return collection;211 return collection;324}212}325213344 100n,232 100n,345 );233 );346234347 const collection = await createCollectionForBenchmarks(235 const collection = (await createCollectionForBenchmarks(236 'nft',348 helper,237 helper,349 privateKey,238 privateKey,350 ethSigner,239 ethSigner,351 proxyContract.options.address,240 proxyContract.options.address,352 PERMISSIONS,241 PERMISSIONS,353 );242 )) as UniqueNFTCollection;354243355 const substrateFee = await helper.arrange.calculcateFee(244 const substrateFee = await helper.arrange.calculcateFee(356 {Substrate: donor.address},245 {Substrate: donor.address},587 proxyContractAddress: string,476 proxyContractAddress: string,588 calculatedCall: (collection: UniqueNFTCollection) => Promise<any>,477 calculatedCall: (collection: UniqueNFTCollection) => Promise<any>,589): Promise<bigint> {478): Promise<bigint> {590 const collection = await createCollectionForBenchmarks(479 const collection = (await createCollectionForBenchmarks(480 'nft',591 helper,481 helper,592 privateKey,482 privateKey,593 ethSigner,483 ethSigner,594 proxyContractAddress,484 proxyContractAddress,595 PERMISSIONS,485 PERMISSIONS,596 );486 )) as UniqueNFTCollection;597 return helper.arrange.calculcateFee(payer, async () => {487 return helper.arrange.calculcateFee(payer, async () => {598 await calculatedCall(collection);488 await calculatedCall(collection);599 });489 });600}490}491601function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {492function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {602 return Number((value * 1000n) / nominal) / 1000;493 return Number((value * 1000n) / nominal) / 1000;603}494}604495605interface IFeeGas {606 fee: number | bigint,607 gas: number | bigint,608 substrate?: number,609}610interface IFunctionFee {611 [name: string]: IFeeGas612}613614async function ERC721CalculateFeeGas(496async function erc721CalculateFeeGas(615 helper: EthUniqueHelper,497 helper: EthUniqueHelper,616 privateKey: (seed: string) => Promise<IKeyringPair>,498 privateKey: (seed: string) => Promise<IKeyringPair>,617499623 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 10n);505 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 10n);624 const crossSigner = helper.ethCrossAccount.fromAddress(ethSigner);506 const crossSigner = helper.ethCrossAccount.fromAddress(ethSigner);625 const crossReceiver = helper.ethCrossAccount.fromAddress(ethReceiver);507 const crossReceiver = helper.ethCrossAccount.fromAddress(ethReceiver);626 const collection = await createCollectionForBenchmarks(508 const collection = (await createCollectionForBenchmarks(509 'nft',627 helper,510 helper,628 privateKey,511 privateKey,629 ethSigner,512 ethSigner,630 null,513 null,631 PERMISSIONS,514 PERMISSIONS,632 );515 )) as UniqueNFTCollection;633516517 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);518 let zeppelelinContract: Contract | null = null;519 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${__dirname}/openZeppelin/ERC721/bin/ZeppelinContract.bin`)).toString();520 const ZEPPELIN_ABI = JSON.parse((await readFile(`${__dirname}/openZeppelin/ERC721/bin/ZeppelinContract.abi`)).toString());521634 const evmContract = await helper.ethNativeContract.collection(522 const evmContract = await helper.ethNativeContract.collection(635 helper.ethAddress.fromCollectionId(collection.collectionId),523 helper.ethAddress.fromCollectionId(collection.collectionId),636 'nft',524 'nft',637 ethSigner,525 ethSigner,638 true,526 true,639 );527 );640528529 res['createCollection'] = await helper.arrange.calculcateFeeGas(530 {Ethereum: ethSigner},531 () => helperContract.methods.createNFTCollection('test','test','test').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())}),532 );533534 res['createCollection'].substrate = convertToTokens((await helper.arrange.calculcateFee(535 {Substrate: donor.address},536 () => helper.nft.mintCollection(537 donor,538 {name: 'test', description: 'test', tokenPrefix: 'test'},539 ),540 )));541542 res['createCollection'].zeppelin = await helper.arrange.calculcateFeeGas(543 {Ethereum: ethSigner},544 async () => {545 zeppelelinContract = await helper.ethContract.deployByAbi(546 ethSigner,547 ZEPPELIN_ABI,548 ZEPPELIN_OBJECT,549 );550 },551 );552641 res['mint'] =553 res['mint'] =642 await helper.arrange.calculcateFeeGas(554 await helper.arrange.calculcateFeeGas(643 {Ethereum: ethSigner},555 {Ethereum: ethSigner},644 () => evmContract.methods.mint(ethSigner).send(),556 () => evmContract.methods.mint(ethSigner).send(),645 );557 );646558559 res['mint'].zeppelin =560 await helper.arrange.calculcateFeeGas(561 {Ethereum: ethSigner},562 () => zeppelelinContract!.methods.safeMint(ethSigner, 'test').send({from: ethSigner}),563 );564647 res['mintCross'] =565 res['mintCross'] =648 await helper.arrange.calculcateFeeGas(566 await helper.arrange.calculcateFeeGas(649 {Ethereum: ethSigner},567 {Ethereum: ethSigner},717 () => evmContract.methods.transfer(ethReceiver, 1).send(),635 () => evmContract.methods.transfer(ethReceiver, 1).send(),718 );636 );719637638 res['safeTransferFrom*'] = {639 zeppelin:640 await helper.arrange.calculcateFeeGas(641 {Ethereum: ethSigner},642 () => zeppelelinContract!.methods.safeTransferFrom(ethSigner, ethReceiver, 0).send({from: ethSigner}),643 ),644 };645720 res['transferCross'] =646 res['transferCross'] =721 await helper.arrange.calculcateFeeGas(647 await helper.arrange.calculcateFeeGas(722 {Ethereum: ethReceiver},648 {Ethereum: ethReceiver},733 )));659 )));734 await collection.approveToken(subReceiver, 3, {Substrate: donor.address});660 await collection.approveToken(subReceiver, 3, {Substrate: donor.address});735661736 res['transferFrom'] =662 res['transferFrom*'] =737 await helper.arrange.calculcateFeeGas(663 await helper.arrange.calculcateFeeGas(738 {Ethereum: ethSigner},664 {Ethereum: ethSigner},739 () => evmContract.methods.transferFrom(ethSigner, ethReceiver, 1).send(),665 () => evmContract.methods.transferFrom(ethSigner, ethReceiver, 1).send(),740 );666 );741667668 res['transferFrom*'].zeppelin =669 await helper.arrange.calculcateFeeGas(670 {Ethereum: ethReceiver},671 () => zeppelelinContract!.methods.transferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),672 );673674742 res['transferFromCross'] =675 res['transferFromCross'] =743 await helper.arrange.calculcateFeeGas(676 await helper.arrange.calculcateFeeGas(744 {Ethereum: ethReceiver},677 {Ethereum: ethReceiver},761 () => collection.burnToken(donor, 3),694 () => collection.burnToken(donor, 3),762 )));695 )));763696697 res['approve*'] =698 await helper.arrange.calculcateFeeGas(699 {Ethereum: ethSigner},700 () => evmContract.methods.approve(ethReceiver, 2).send(),701 );764702703 res['approve*'].zeppelin =704 await helper.arrange.calculcateFeeGas(705 {Ethereum: ethSigner},706 () => zeppelelinContract!.methods.approve(ethReceiver, 0).send({from: ethSigner}),707 );708765 res['approveCross'] =709 res['approveCross'] =766 await helper.arrange.calculcateFeeGas(710 await helper.arrange.calculcateFeeGas(767 {Ethereum: ethSigner},711 {Ethereum: ethSigner},773 () => collection.approveToken(donor, 4, {Substrate: subReceiver.address}),717 () => collection.approveToken(donor, 4, {Substrate: subReceiver.address}),774 )));718 )));775719720 res['setApprovalForAll*'] =721 await helper.arrange.calculcateFeeGas(722 {Ethereum: ethSigner},723 () => evmContract.methods.setApprovalForAll(ethReceiver, true).send(),724 );725726 res['setApprovalForAll*'].zeppelin =727 await helper.arrange.calculcateFeeGas(728 {Ethereum: ethSigner},729 () => zeppelelinContract!.methods.setApprovalForAll(ethReceiver, true).send({from: ethSigner}),730 );731732 res['setApprovalForAll*'].substrate = convertToTokens((await helper.arrange.calculcateFee(733 {Substrate: donor.address},734 () => helper.nft.setAllowanceForAll(donor, collection.collectionId, {Substrate: subReceiver.address}, true),735 )));736776 res['burnFromCross'] =737 res['burnFromCross'] =777 await helper.arrange.calculcateFeeGas(738 await helper.arrange.calculcateFeeGas(778 {Ethereum: ethReceiver},739 {Ethereum: ethReceiver},803 collectionAdmin: true,764 collectionAdmin: true,804 mutable: true,765 mutable: true,805 }}]),766 }}]),767 )));768769 res['setCollectionSponsorCross'] =770 await helper.arrange.calculcateFeeGas(771 {Ethereum: ethSigner},772 () => evmContract.methods.setCollectionSponsorCross(crossReceiver).send(),773 );774775 res['confirmCollectionSponsorship'] =776 await helper.arrange.calculcateFeeGas(777 {Ethereum: ethReceiver},778 () => evmContract.methods.confirmCollectionSponsorship().send({from: ethReceiver}),779 );780781 res['removeCollectionSponsor'] =782 await helper.arrange.calculcateFeeGas(783 {Ethereum: ethSigner},784 () => evmContract.methods.removeCollectionSponsor().send(),785 );786787 res['setCollectionSponsorCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(788 {Substrate: donor.address},789 () => collection.setSponsor(donor, subReceiver.address),790 )));791792 res['confirmCollectionSponsorship'].substrate = convertToTokens((await helper.arrange.calculcateFee(793 {Substrate: subReceiver.address},794 () => collection.confirmSponsorship(subReceiver),795 )));796797 res['removeCollectionSponsor'].substrate = convertToTokens((await helper.arrange.calculcateFee(798 {Substrate: donor.address},799 () => collection.removeSponsor(donor),800 )));801802 res['setCollectionProperties'] =803 await helper.arrange.calculcateFeeGas(804 {Ethereum: ethSigner},805 () => evmContract.methods.setCollectionProperties(PROPERTIES.slice(0, 1)).send(),806 );807808 res['deleteCollectionProperties'] =809 await helper.arrange.calculcateFeeGas(810 {Ethereum: ethSigner},811 () => evmContract.methods.deleteCollectionProperties(PROPERTIES.slice(0,1).map(p => p.key)).send(),812 );813 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(814 {Substrate: donor.address},815 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)816 .map(p => { return {key: p.key, value: p.value.toString()}; })),817 )));818819 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(820 {Substrate: donor.address},821 () => collection.deleteProperties(donor, PROPERTIES.slice(0, 1)822 .map(p => p.key)),823 )));824825 res['setCollectionLimit'] =826 await helper.arrange.calculcateFeeGas(827 {Ethereum: ethSigner},828 () => evmContract.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: 1000}}).send(),829 );830831 res['setCollectionLimit'].substrate = convertToTokens((await helper.arrange.calculcateFee(832 {Substrate: donor.address},833 () => collection.setLimits(donor, {accountTokenOwnershipLimit: 1000}),834 )));835836 const {collectionAddress} = await helper.eth.createCollection('nft', ethSigner, 'A', 'B', 'C');837 const collectionWithEthOwner = await helper.ethNativeContract.collection(collectionAddress, 'nft', ethSigner, true);838839840 res['addCollectionAdminCross'] =841 await helper.arrange.calculcateFeeGas(842 {Ethereum: ethSigner},843 () => collectionWithEthOwner.methods.addCollectionAdminCross(crossReceiver).send(),844 );845846 res['removeCollectionAdminCross'] =847 await helper.arrange.calculcateFeeGas(848 {Ethereum: ethSigner},849 () => collectionWithEthOwner.methods.removeCollectionAdminCross(crossReceiver).send(),850 );851852 res['addCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(853 {Substrate: donor.address},854 () => collection.addAdmin(donor, {Ethereum: ethReceiver}),855 )));856857 res['removeCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(858 {Substrate: donor.address},859 () => collection.removeAdmin(donor, {Ethereum: ethReceiver}),860 )));861862 res['setCollectionNesting'] =863 await helper.arrange.calculcateFeeGas(864 {Ethereum: ethSigner},865 () => evmContract.methods.setCollectionNesting(true).send(),866 );867868 res['setCollectionNesting[]'] =869 await helper.arrange.calculcateFeeGas(870 {Ethereum: ethSigner},871 () => evmContract.methods.setCollectionNesting(true, [collectionAddress]).send(),872 );873874 res['setCollectionNesting'].substrate = convertToTokens((await helper.arrange.calculcateFee(875 {Substrate: donor.address},876 () => collection.disableNesting(donor),877 )));878879 res['setCollectionNesting[]'].substrate = convertToTokens((await helper.arrange.calculcateFee(880 {Substrate: donor.address},881 () => collection.setPermissions(882 donor,883 {884 nesting: {885 tokenOwner: true,886 restricted: [collection.collectionId],887 },888 },889 ),890 )));891892 res['setCollectionAccess'] =893 await helper.arrange.calculcateFeeGas(894 {Ethereum: ethSigner},895 () => evmContract.methods.setCollectionAccess(1).send(),896 );897898 res['setCollectionAccess'].substrate = convertToTokens((await helper.arrange.calculcateFee(899 {Substrate: donor.address},900 () => collection.setPermissions(donor, {access: 'AllowList'}),901 )));902903 res['addToCollectionAllowListCross'] =904 await helper.arrange.calculcateFeeGas(905 {Ethereum: ethSigner},906 () => evmContract.methods.addToCollectionAllowListCross(crossReceiver).send(),907 );908909 res['removeFromCollectionAllowListCross'] =910 await helper.arrange.calculcateFeeGas(911 {Ethereum: ethSigner},912 () => evmContract.methods.removeFromCollectionAllowListCross(crossReceiver).send(),913 );914915 res['addToCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(916 {Substrate: donor.address},917 () => collection.addToAllowList(donor, {Ethereum: ethReceiver}),918 )));919920 res['removeFromCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(921 {Substrate: donor.address},922 () => collection.removeFromAllowList(donor, {Ethereum: ethReceiver}),923 )));924925 res['setCollectionMintMode'] =926 await helper.arrange.calculcateFeeGas(927 {Ethereum: ethSigner},928 () => evmContract.methods.setCollectionMintMode(true).send(),929 );930931 res['setCollectionMintMode'].substrate = convertToTokens((await helper.arrange.calculcateFee(932 {Substrate: donor.address},933 () => collection.setPermissions(donor, {mintMode: false}),934 )));935936 res['changeCollectionOwnerCross'] =937 await helper.arrange.calculcateFeeGas(938 {Ethereum: ethSigner},939 () => collectionWithEthOwner.methods.changeCollectionOwnerCross(crossReceiver).send(),940 );941942 res['changeCollectionOwnerCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(943 {Substrate: donor.address},944 () => collection.changeOwner(donor, subReceiver.address),945 )));946947 return res;948}949950async function erc20CalculateFeeGas(951 helper: EthUniqueHelper,952 privateKey: (seed: string) => Promise<IKeyringPair>,953954): Promise<IFunctionFee> {955 const res: IFunctionFee = {};956 const donor = await privateKey('//Alice');957 const [subReceiver] = await helper.arrange.createAccounts([10n], donor);958 const ethSigner = await helper.eth.createAccountWithBalance(donor, 100n);959 const ethReceiver = await helper.eth.createAccountWithBalance(donor, 10n);960 const crossSigner = helper.ethCrossAccount.fromAddress(ethSigner);961 const crossReceiver = helper.ethCrossAccount.fromAddress(ethReceiver);962 const collection = (await createCollectionForBenchmarks(963 'ft',964 helper,965 privateKey,966 ethSigner,967 null,968 PERMISSIONS,969 )) as UniqueFTCollection;970971 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);972 let zeppelelinContract: Contract | null = null;973 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${__dirname}/openZeppelin/ERC20/bin/ZeppelinContract.bin`)).toString();974 const ZEPPELIN_ABI = JSON.parse((await readFile(`${__dirname}/openZeppelin/ERC20/bin/ZeppelinContract.abi`)).toString());975976 const evmContract = await helper.ethNativeContract.collection(977 helper.ethAddress.fromCollectionId(collection.collectionId),978 'ft',979 ethSigner,980 true,981 );982983 res['createCollection'] = await helper.arrange.calculcateFeeGas(984 {Ethereum: ethSigner},985 () => helperContract.methods.createFTCollection('test', 18,'test','test').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())}),986 );987988 res['createCollection'].substrate = convertToTokens((await helper.arrange.calculcateFee(989 {Substrate: donor.address},990 () => helper.ft.mintCollection(991 donor,992 {name: 'test', description: 'test', tokenPrefix: 'test'},993 18,994 ),995 )));996997 res['createCollection'].zeppelin = await helper.arrange.calculcateFeeGas(998 {Ethereum: ethSigner},999 async () => {1000 zeppelelinContract = await helper.ethContract.deployByAbi(1001 ethSigner,1002 ZEPPELIN_ABI,1003 ZEPPELIN_OBJECT,1004 );1005 },1006 );10071008 res['mint'] =1009 await helper.arrange.calculcateFeeGas(1010 {Ethereum: ethSigner},1011 () => evmContract.methods.mint(ethSigner, 1).send(),1012 );10131014 res['mint'].zeppelin =1015 await helper.arrange.calculcateFeeGas(1016 {Ethereum: ethSigner},1017 () => zeppelelinContract!.methods.mint(ethSigner, 1).send(),1018 );10191020 res['mintCross'] =1021 await helper.arrange.calculcateFeeGas(1022 {Ethereum: ethSigner},1023 () => evmContract.methods.mintCross(crossSigner, 1).send(),1024 );10251026 res['mintCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(1027 {Substrate: donor.address},1028 () => collection.mint(1029 donor,1030 10n,1031 {Substrate: donor.address},1032 ),1033 )));10341035 res['mintBulk'] =1036 await helper.arrange.calculcateFeeGas(1037 {Ethereum: ethSigner},1038 () => evmContract.methods.mintBulk([{field_0: ethSigner, field_1: 1}]).send(),1039 );10401041 res['mintBulk'].substrate = convertToTokens((await helper.arrange.calculcateFee(1042 {Substrate: donor.address},1043 () => helper.executeExtrinsic(donor, 'api.tx.unique.createMultipleItemsEx',[collection.collectionId, {1044 Fungible: new Map([1045 [JSON.stringify({Ethereum: ethSigner}), 1],10461047 ]),1048 }], true),1049 )));10501051 res['transfer*'] =1052 await helper.arrange.calculcateFeeGas(1053 {Ethereum: ethSigner},1054 () => evmContract.methods.transfer(ethReceiver, 1).send(),1055 );10561057 res['transfer*'].zeppelin =1058 await helper.arrange.calculcateFeeGas(1059 {Ethereum: ethSigner},1060 () => zeppelelinContract!.methods.transfer(ethReceiver, 1).send(),1061 );10621063 res['transferCross'] =1064 await helper.arrange.calculcateFeeGas(1065 {Ethereum: ethReceiver},1066 () => evmContract.methods.transferCross(crossSigner, 1).send({from: ethReceiver}),1067 );10681069 res['transferCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(1070 {Substrate: donor.address},1071 () => collection.transfer(1072 donor,1073 {Substrate: subReceiver.address},1074 1n,1075 ),1076 )));1077 await collection.approveTokens(subReceiver, {Substrate: donor.address}, 1n);10781079 res['transferFrom*'] =1080 await helper.arrange.calculcateFeeGas(1081 {Ethereum: ethSigner},1082 () => evmContract.methods.transferFrom(ethSigner, ethReceiver, 1).send(),1083 );10841085 res['transferFrom*'].zeppelin =1086 await helper.arrange.calculcateFeeGas(1087 {Ethereum: ethReceiver},1088 () => zeppelelinContract!.methods.transferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),1089 );10901091 res['transferFromCross'] =1092 await helper.arrange.calculcateFeeGas(1093 {Ethereum: ethReceiver},1094 () => evmContract.methods.transferFromCross(crossReceiver, crossSigner, 1).send({from:ethReceiver}),1095 );10961097 res['transferFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(1098 {Substrate: donor.address},1099 () => collection.transferFrom(donor, {Substrate: subReceiver.address}, {Substrate: donor.address}, 1n),1100 )));110111021103 res['burnTokens'] = {fee: 0n, gas: 0n};1104 res['burnTokens'].substrate = convertToTokens((await helper.arrange.calculcateFee(1105 {Substrate: donor.address},1106 () => collection.burnTokens(donor, 1n),1107 )));110811091110 res['approve*'] =1111 await helper.arrange.calculcateFeeGas(1112 {Ethereum: ethSigner},1113 () => evmContract.methods.approve(ethReceiver, 2).send(),1114 );11151116 res['approve*'].zeppelin =1117 await helper.arrange.calculcateFeeGas(1118 {Ethereum: ethSigner},1119 () => zeppelelinContract!.methods.approve(ethReceiver, 0).send(),1120 );11211122 res['approveCross'] =1123 await helper.arrange.calculcateFeeGas(1124 {Ethereum: ethSigner},1125 () => evmContract.methods.approveCross(crossReceiver, 2).send(),1126 );11271128 res['approveCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(1129 {Substrate: donor.address},1130 () => collection.approveTokens(donor, {Substrate: subReceiver.address}, 1n),1131 )));11321133 res['burnFromCross'] =1134 await helper.arrange.calculcateFeeGas(1135 {Ethereum: ethReceiver},1136 () => evmContract.methods.burnFromCross(crossSigner, 1).send({from:ethReceiver}),1137 );11381139 res['burnFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(1140 {Substrate: subReceiver.address},1141 () => collection.burnTokensFrom(subReceiver, {Substrate: donor.address}, 1n),806 )));1142 )));8071143808 res['setCollectionSponsorCross'] =1144 res['setCollectionSponsorCross'] =tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/README.mddiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Address.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Context.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/README.mddiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/governance/utils/IVotes.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/interfaces/IERC3156FlashLender.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/security/Pausable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/ERC20.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/IERC20.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/Context.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/cryptography/ECDSA.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/cryptography/EIP712.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/@openzeppelin/contracts/utils/math/SafeCast.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/ZeppelinContract.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/bin/ZeppelinContract.abidiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC20/bin/ZeppelinContract.bindiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/README.mddiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/Address.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/Context.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/ZeppelinContract.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/bin/ZeppelinContract.abidiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ERC721/bin/ZeppelinContract.bindiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/ZeppelinContract.soldiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.abidiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.bindiffbeforeafterbothno changes
tests/src/benchmarks/mintFee/types.tsdiffbeforeafterbothno changes