1import {usingEthPlaygrounds} from '@unique/tests/src/eth/util/index.js';2import {EthUniqueHelper} from '@unique/tests/src/eth/util/playgrounds/unique.dev.js';3import {readFile} from 'fs/promises';4import {CollectionLimitField, CreateCollectionData, TokenPermissionField} from '@unique/tests/src/eth/util/playgrounds/types.js';5import type {IKeyringPair} from '@polkadot/types/types';6import {UniqueFTCollection, UniqueNFTCollection} from '@unique/playgrounds/src/unique.js';7import {Contract} from 'web3-eth-contract';8import {createObjectCsvWriter} from 'csv-writer';9import {FunctionFeeVM} from '../utils/types.js';10import type {IFunctionFee} from '../utils/types.js';11import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES, SUBS_PROPERTIES} from '../utils/common.js';12import {makeNames} from '@unique/tests/src/util/index.js';131415const {dirname} = makeNames(import.meta.url);1617const main = async () => {1819 const headers = [20 'function',21 'ethFee',22 'ethGas',23 'substrate',24 'zeppelinFee',25 'zeppelinGas',26 ];2728 const csvWriter20 = createObjectCsvWriter({29 path: 'erc20.csv',30 header: headers,31 });3233 const csvWriter721 = createObjectCsvWriter({34 path: 'erc721.csv',35 header: headers,36 });3738 await usingEthPlaygrounds(async (helper, privateKey) => {39 console.log('\n ERC20 ops fees');40 const erc20 = FunctionFeeVM.fromModel(await erc20CalculateFeeGas(helper, privateKey));41 console.table(erc20);42 await csvWriter20.writeRecords(FunctionFeeVM.toCsv(erc20));4344 console.log('\n ERC721 ops fees');45 const erc721 = FunctionFeeVM.fromModel(await erc721CalculateFeeGas(helper, privateKey));46 console.table(erc721);4748 await csvWriter721.writeRecords(FunctionFeeVM.toCsv(erc721));49 });50};5152main()53 .then(() => process.exit(0))54 .catch((e) => {55 console.log(e);56 process.exit(1);57 });5859async function erc721CalculateFeeGas(60 helper: EthUniqueHelper,61 privateKey: (seed: string) => Promise<IKeyringPair>,62): Promise<IFunctionFee> {63 const res: IFunctionFee = {};64 const donor = await privateKey('//Alice');65 const [subReceiver] = await helper.arrange.createAccounts([10n], donor);66 const ethSigner = await helper.eth.createAccountWithBalance(donor);67 const ethReceiver = await helper.eth.createAccountWithBalance(donor);68 const crossSigner = helper.ethCrossAccount.fromAddress(ethSigner);69 const crossReceiver = helper.ethCrossAccount.fromAddress(ethReceiver);70 const collection = (await createCollectionForBenchmarks(71 'nft',72 helper,73 privateKey,74 ethSigner,75 null,76 PERMISSIONS,77 )) as UniqueNFTCollection;7879 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);80 let zeppelelinContract: Contract | null = null;81 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${dirname}/../utils/openZeppelin/ERC721/bin/ZeppelinContract.bin`)).toString();82 const ZEPPELIN_ABI = JSON.parse((await readFile(`${dirname}/../utils/openZeppelin/ERC721/bin/ZeppelinContract.abi`)).toString());8384 const evmContract = await helper.ethNativeContract.collection(85 helper.ethAddress.fromCollectionId(collection.collectionId),86 'nft',87 ethSigner,88 true,89 );9091 res['createCollection'] = await helper.arrange.calculcateFeeGas(92 {Ethereum: ethSigner},93 () => helperContract.methods.createNFTCollection('test','test','test').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())}),94 );9596 res['createCollection'].substrate = convertToTokens((await helper.arrange.calculcateFee(97 {Substrate: donor.address},98 () => helper.nft.mintCollection(99 donor,100 {name: 'test', description: 'test', tokenPrefix: 'test'},101 ),102 )));103104 res['createCollection'].zeppelin = await helper.arrange.calculcateFeeGas(105 {Ethereum: ethSigner},106 async () => {107 zeppelelinContract = await helper.ethContract.deployByAbi(108 ethSigner,109 ZEPPELIN_ABI,110 ZEPPELIN_OBJECT,111 );112 },113 );114115 res['mint'] =116 await helper.arrange.calculcateFeeGas(117 {Ethereum: ethSigner},118 () => evmContract.methods.mint(ethSigner).send(),119 );120121 res['mint'].zeppelin =122 await helper.arrange.calculcateFeeGas(123 {Ethereum: ethSigner},124 () => zeppelelinContract!.methods.safeMint(ethSigner, '').send({from: ethSigner}),125 );126127 res['mintCross'] =128 await helper.arrange.calculcateFeeGas(129 {Ethereum: ethSigner},130 () => evmContract.methods.mintCross(crossSigner, []).send(),131 );132133 res['mint'].substrate = convertToTokens((await helper.arrange.calculcateFee(134 {Substrate: donor.address},135 () => collection.mintToken(136 donor,137 {Substrate: donor.address},138 ),139 )));140141 res['mintCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(142 {Substrate: donor.address},143 () => collection.mintMultipleTokens(donor, [{144 owner: {Substrate: donor.address},145 }]),146 )));147148 res['mintWithTokenURI'] =149 await helper.arrange.calculcateFeeGas(150 {Ethereum: ethSigner},151 () => evmContract.methods.mintWithTokenURI(ethSigner, 'Test URI').send(),152 );153154 res['mintWithTokenURI'].substrate = convertToTokens((await helper.arrange.calculcateFee(155 {Substrate: donor.address},156 () => collection.mintToken(157 donor,158 {Ethereum: ethSigner},159 [{key: 'URI', value: 'Test URI'}],160 ),161 )));162163 res['mintWithTokenURI'].zeppelin =164 await helper.arrange.calculcateFeeGas(165 {Ethereum: ethSigner},166 () => zeppelelinContract!.methods.safeMint(ethSigner, 'Test URI').send({from: ethSigner}),167 );168169 res['setProperties'] =170 await helper.arrange.calculcateFeeGas(171 {Ethereum: ethSigner},172 () => evmContract.methods.setProperties(1, PROPERTIES.slice(0,1)).send(),173 );174175 res['deleteProperties'] =176 await helper.arrange.calculcateFeeGas(177 {Ethereum: ethSigner},178 () => evmContract.methods.deleteProperties(1, [PROPERTIES[0].key]).send(),179 );180181 res['setProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(182 {Substrate: donor.address},183 () => collection.setTokenProperties(184 donor,185 1,186 SUBS_PROPERTIES.slice(0, 1),187 ),188 )));189190 res['deleteProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(191 {Substrate: donor.address},192 () => collection.deleteTokenProperties(193 donor,194 1,195 SUBS_PROPERTIES.slice(0, 1)196 .map(p => p.key),197 ),198 )));199200 res['transfer'] =201 await helper.arrange.calculcateFeeGas(202 {Ethereum: ethSigner},203 () => evmContract.methods.transfer(ethReceiver, 1).send(),204 );205206 res['safeTransferFrom*'] = {207 zeppelin:208 await helper.arrange.calculcateFeeGas(209 {Ethereum: ethSigner},210 () => zeppelelinContract!.methods.safeTransferFrom(ethSigner, ethReceiver, 0).send({from: ethSigner}),211 ),212 };213214 res['transferCross'] =215 await helper.arrange.calculcateFeeGas(216 {Ethereum: ethReceiver},217 () => evmContract.methods.transferCross(crossSigner, 1).send({from: ethReceiver}),218 );219220 res['transferCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(221 {Substrate: donor.address},222 () => collection.transferToken(223 donor,224 3,225 {Substrate: subReceiver.address},226 ),227 )));228 await collection.approveToken(subReceiver, 3, {Substrate: donor.address});229230 res['transferFrom*'] =231 await helper.arrange.calculcateFeeGas(232 {Ethereum: ethSigner},233 () => evmContract.methods.transferFrom(ethSigner, ethReceiver, 1).send(),234 );235236 res['transferFrom*'].zeppelin =237 await helper.arrange.calculcateFeeGas(238 {Ethereum: ethReceiver},239 () => zeppelelinContract!.methods.transferFrom(ethReceiver, ethSigner, 0).send({from: ethReceiver}),240 );241242243 res['transferFromCross'] =244 await helper.arrange.calculcateFeeGas(245 {Ethereum: ethReceiver},246 () => evmContract.methods.transferFromCross(crossReceiver, crossSigner, 1).send({from:ethReceiver}),247 );248249 res['transferFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(250 {Substrate: donor.address},251 () => collection.transferTokenFrom(donor, 3, {Substrate: subReceiver.address}, {Substrate: donor.address}),252 )));253254 res['burn'] =255 await helper.arrange.calculcateFeeGas(256 {Ethereum: ethSigner},257 () => evmContract.methods.burn(1).send(),258 );259260 res['burn'].substrate = convertToTokens((await helper.arrange.calculcateFee(261 {Substrate: donor.address},262 () => collection.burnToken(donor, 3),263 )));264265 res['approve*'] =266 await helper.arrange.calculcateFeeGas(267 {Ethereum: ethSigner},268 () => evmContract.methods.approve(ethReceiver, 2).send(),269 );270271 res['approve*'].zeppelin =272 await helper.arrange.calculcateFeeGas(273 {Ethereum: ethSigner},274 () => zeppelelinContract!.methods.approve(ethReceiver, 0).send({from: ethSigner}),275 );276277 res['approveCross'] =278 await helper.arrange.calculcateFeeGas(279 {Ethereum: ethSigner},280 () => evmContract.methods.approveCross(crossReceiver, 2).send(),281 );282283 res['approveCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(284 {Substrate: donor.address},285 () => collection.approveToken(donor, 4, {Substrate: subReceiver.address}),286 )));287288 res['setApprovalForAll*'] =289 await helper.arrange.calculcateFeeGas(290 {Ethereum: ethSigner},291 () => evmContract.methods.setApprovalForAll(ethReceiver, true).send(),292 );293294 res['setApprovalForAll*'].zeppelin =295 await helper.arrange.calculcateFeeGas(296 {Ethereum: ethSigner},297 () => zeppelelinContract!.methods.setApprovalForAll(ethReceiver, true).send({from: ethSigner}),298 );299300 res['setApprovalForAll*'].substrate = convertToTokens((await helper.arrange.calculcateFee(301 {Substrate: donor.address},302 () => helper.nft.setAllowanceForAll(donor, collection.collectionId, {Substrate: subReceiver.address}, true),303 )));304305 res['burnFromCross'] =306 await helper.arrange.calculcateFeeGas(307 {Ethereum: ethReceiver},308 () => evmContract.methods.burnFromCross(crossSigner, 2).send({from:ethReceiver}),309 );310311 res['burnFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(312 {Substrate: subReceiver.address},313 () => collection.burnTokenFrom(subReceiver, 4, {Substrate: donor.address}),314 )));315316 res['setTokenPropertyPermissions'] =317 await helper.arrange.calculcateFeeGas(318 {Ethereum: ethSigner},319 () => evmContract.methods.setTokenPropertyPermissions([320 ['url', [321 [TokenPermissionField.Mutable, true],322 [TokenPermissionField.TokenOwner, true],323 [TokenPermissionField.CollectionAdmin, true]],324 ],325 ]).send(),326 );327328 res['setTokenPropertyPermissions'].substrate = convertToTokens((await helper.arrange.calculcateFee(329 {Substrate: donor.address},330 () => collection.setTokenPropertyPermissions(donor, [{key: 'url', permission: {331 tokenOwner: true,332 collectionAdmin: true,333 mutable: true,334 }}]),335 )));336337 res['setCollectionSponsorCross'] =338 await helper.arrange.calculcateFeeGas(339 {Ethereum: ethSigner},340 () => evmContract.methods.setCollectionSponsorCross(crossReceiver).send(),341 );342343 res['confirmCollectionSponsorship'] =344 await helper.arrange.calculcateFeeGas(345 {Ethereum: ethReceiver},346 () => evmContract.methods.confirmCollectionSponsorship().send({from: ethReceiver}),347 );348349 res['removeCollectionSponsor'] =350 await helper.arrange.calculcateFeeGas(351 {Ethereum: ethSigner},352 () => evmContract.methods.removeCollectionSponsor().send(),353 );354355 res['setCollectionSponsorCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(356 {Substrate: donor.address},357 () => collection.setSponsor(donor, subReceiver.address),358 )));359360 res['confirmCollectionSponsorship'].substrate = convertToTokens((await helper.arrange.calculcateFee(361 {Substrate: subReceiver.address},362 () => collection.confirmSponsorship(subReceiver),363 )));364365 res['removeCollectionSponsor'].substrate = convertToTokens((await helper.arrange.calculcateFee(366 {Substrate: donor.address},367 () => collection.removeSponsor(donor),368 )));369370 res['setCollectionProperties'] =371 await helper.arrange.calculcateFeeGas(372 {Ethereum: ethSigner},373 () => evmContract.methods.setCollectionProperties(PROPERTIES.slice(0, 1)).send(),374 );375376 res['deleteCollectionProperties'] =377 await helper.arrange.calculcateFeeGas(378 {Ethereum: ethSigner},379 () => evmContract.methods.deleteCollectionProperties(PROPERTIES.slice(0,1).map(p => p.key)).send(),380 );381 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(382 {Substrate: donor.address},383 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)384 .map(p => ({key: p.key, value: p.value.toString()}))),385 )));386387 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(388 {Substrate: donor.address},389 () => collection.deleteProperties(donor, PROPERTIES.slice(0, 1)390 .map(p => p.key)),391 )));392393 res['setCollectionLimit'] =394 await helper.arrange.calculcateFeeGas(395 {Ethereum: ethSigner},396 () => evmContract.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: 1000}}).send(),397 );398399 res['setCollectionLimit'].substrate = convertToTokens((await helper.arrange.calculcateFee(400 {Substrate: donor.address},401 () => collection.setLimits(donor, {accountTokenOwnershipLimit: 1000}),402 )));403404 const {collectionAddress} = await helper.eth.createCollection(ethSigner, new CreateCollectionData('A', 'B', 'C', 'nft')).send();405 const collectionWithEthOwner = await helper.ethNativeContract.collection(collectionAddress, 'nft', ethSigner, true);406407408 res['addCollectionAdminCross'] =409 await helper.arrange.calculcateFeeGas(410 {Ethereum: ethSigner},411 () => collectionWithEthOwner.methods.addCollectionAdminCross(crossReceiver).send(),412 );413414 res['removeCollectionAdminCross'] =415 await helper.arrange.calculcateFeeGas(416 {Ethereum: ethSigner},417 () => collectionWithEthOwner.methods.removeCollectionAdminCross(crossReceiver).send(),418 );419420 res['addCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(421 {Substrate: donor.address},422 () => collection.addAdmin(donor, {Ethereum: ethReceiver}),423 )));424425 res['removeCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(426 {Substrate: donor.address},427 () => collection.removeAdmin(donor, {Ethereum: ethReceiver}),428 )));429430 res['setCollectionNesting'] =431 await helper.arrange.calculcateFeeGas(432 {Ethereum: ethSigner},433 () => evmContract.methods.setCollectionNesting(true).send(),434 );435436 res['setCollectionNesting[]'] =437 await helper.arrange.calculcateFeeGas(438 {Ethereum: ethSigner},439 () => evmContract.methods.setCollectionNesting(true, [collectionAddress]).send(),440 );441442 res['setCollectionNesting'].substrate = convertToTokens((await helper.arrange.calculcateFee(443 {Substrate: donor.address},444 () => collection.disableNesting(donor),445 )));446447 res['setCollectionNesting[]'].substrate = convertToTokens((await helper.arrange.calculcateFee(448 {Substrate: donor.address},449 () => collection.setPermissions(450 donor,451 {452 nesting: {453 tokenOwner: true,454 restricted: [collection.collectionId],455 },456 },457 ),458 )));459460 res['setCollectionAccess'] =461 await helper.arrange.calculcateFeeGas(462 {Ethereum: ethSigner},463 () => evmContract.methods.setCollectionAccess(1).send(),464 );465466 res['setCollectionAccess'].substrate = convertToTokens((await helper.arrange.calculcateFee(467 {Substrate: donor.address},468 () => collection.setPermissions(donor, {access: 'AllowList'}),469 )));470471 res['addToCollectionAllowListCross'] =472 await helper.arrange.calculcateFeeGas(473 {Ethereum: ethSigner},474 () => evmContract.methods.addToCollectionAllowListCross(crossReceiver).send(),475 );476477 res['removeFromCollectionAllowListCross'] =478 await helper.arrange.calculcateFeeGas(479 {Ethereum: ethSigner},480 () => evmContract.methods.removeFromCollectionAllowListCross(crossReceiver).send(),481 );482483 res['addToCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(484 {Substrate: donor.address},485 () => collection.addToAllowList(donor, {Ethereum: ethReceiver}),486 )));487488 res['removeFromCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(489 {Substrate: donor.address},490 () => collection.removeFromAllowList(donor, {Ethereum: ethReceiver}),491 )));492493 res['setCollectionMintMode'] =494 await helper.arrange.calculcateFeeGas(495 {Ethereum: ethSigner},496 () => evmContract.methods.setCollectionMintMode(true).send(),497 );498499 res['setCollectionMintMode'].substrate = convertToTokens((await helper.arrange.calculcateFee(500 {Substrate: donor.address},501 () => collection.setPermissions(donor, {mintMode: false}),502 )));503504 res['changeCollectionOwnerCross'] =505 await helper.arrange.calculcateFeeGas(506 {Ethereum: ethSigner},507 () => collectionWithEthOwner.methods.changeCollectionOwnerCross(crossReceiver).send(),508 );509510 res['changeCollectionOwnerCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(511 {Substrate: donor.address},512 () => collection.changeOwner(donor, subReceiver.address),513 )));514515 return res;516}517518async function erc20CalculateFeeGas(519 helper: EthUniqueHelper,520 privateKey: (seed: string) => Promise<IKeyringPair>,521522): Promise<IFunctionFee> {523 const res: IFunctionFee = {};524 const donor = await privateKey('//Alice');525 const [subReceiver] = await helper.arrange.createAccounts([10n], donor);526 const ethSigner = await helper.eth.createAccountWithBalance(donor);527 const ethReceiver = await helper.eth.createAccountWithBalance(donor);528 const crossSigner = helper.ethCrossAccount.fromAddress(ethSigner);529 const crossReceiver = helper.ethCrossAccount.fromAddress(ethReceiver);530 const collection = (await createCollectionForBenchmarks(531 'ft',532 helper,533 privateKey,534 ethSigner,535 null,536 PERMISSIONS,537 )) as UniqueFTCollection;538539 const helperContract = await helper.ethNativeContract.collectionHelpers(ethSigner);540 let zeppelelinContract: Contract | null = null;541 const ZEPPELIN_OBJECT = '0x' + (await readFile(`${dirname}/../utils/openZeppelin/ERC20/bin/ZeppelinContract.bin`)).toString();542 const ZEPPELIN_ABI = JSON.parse((await readFile(`${dirname}/../utils/openZeppelin/ERC20/bin/ZeppelinContract.abi`)).toString());543544 const evmContract = await helper.ethNativeContract.collection(545 helper.ethAddress.fromCollectionId(collection.collectionId),546 'ft',547 ethSigner,548 true,549 );550551 res['createCollection'] = await helper.arrange.calculcateFeeGas(552 {Ethereum: ethSigner},553 () => helperContract.methods.createFTCollection('test', 18,'test','test').send({from: ethSigner, value: Number(2n * helper.balance.getOneTokenNominal())}),554 );555556 res['createCollection'].substrate = convertToTokens((await helper.arrange.calculcateFee(557 {Substrate: donor.address},558 () => helper.ft.mintCollection(559 donor,560 {name: 'test', description: 'test', tokenPrefix: 'test'},561 18,562 ),563 )));564565 res['createCollection'].zeppelin = await helper.arrange.calculcateFeeGas(566 {Ethereum: ethSigner},567 async () => {568 zeppelelinContract = await helper.ethContract.deployByAbi(569 ethSigner,570 ZEPPELIN_ABI,571 ZEPPELIN_OBJECT,572 );573 },574 );575576 res['mint'] =577 await helper.arrange.calculcateFeeGas(578 {Ethereum: ethSigner},579 () => evmContract.methods.mint(ethSigner, 1).send(),580 );581582 res['mint'].zeppelin =583 await helper.arrange.calculcateFeeGas(584 {Ethereum: ethSigner},585 () => zeppelelinContract!.methods.mint(ethSigner, 1).send(),586 );587588 res['mintCross'] =589 await helper.arrange.calculcateFeeGas(590 {Ethereum: ethSigner},591 () => evmContract.methods.mintCross(crossSigner, 1).send(),592 );593594 res['mintCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(595 {Substrate: donor.address},596 () => collection.mint(597 donor,598 10n,599 {Substrate: donor.address},600 ),601 )));602603 res['mintBulk'] =604 await helper.arrange.calculcateFeeGas(605 {Ethereum: ethSigner},606 () => evmContract.methods.mintBulk([{to: ethSigner, amount: 1}]).send(),607 );608609 res['mintBulk'].substrate = convertToTokens((await helper.arrange.calculcateFee(610 {Substrate: donor.address},611 () => helper.executeExtrinsic(donor, 'api.tx.unique.createMultipleItemsEx',[collection.collectionId, {612 Fungible: new Map([613 [JSON.stringify({Ethereum: ethSigner}), 1],614 ]),615 }], true),616 )));617618 res['transfer*'] =619 await helper.arrange.calculcateFeeGas(620 {Ethereum: ethSigner},621 () => evmContract.methods.transfer(ethReceiver, 1).send(),622 );623624 res['transfer*'].zeppelin =625 await helper.arrange.calculcateFeeGas(626 {Ethereum: ethSigner},627 () => zeppelelinContract!.methods.transfer(ethReceiver, 1).send(),628 );629630 res['transferCross'] =631 await helper.arrange.calculcateFeeGas(632 {Ethereum: ethReceiver},633 () => evmContract.methods.transferCross(crossSigner, 1).send({from: ethReceiver}),634 );635636 res['transferCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(637 {Substrate: donor.address},638 () => collection.transfer(639 donor,640 {Substrate: subReceiver.address},641 1n,642 ),643 )));644 await collection.approveTokens(subReceiver, {Substrate: donor.address}, 1n);645646 res['transferFrom*'] =647 await helper.arrange.calculcateFeeGas(648 {Ethereum: ethSigner},649 () => evmContract.methods.transferFrom(ethSigner, ethReceiver, 1).send(),650 );651652 await zeppelelinContract!.methods.approve(ethSigner, 10).send({from: ethReceiver});653654 res['transferFrom*'].zeppelin =655 await helper.arrange.calculcateFeeGas(656 {Ethereum: ethSigner},657 () => zeppelelinContract!.methods.transferFrom(ethReceiver, ethSigner, 1).send({from: ethSigner}),658 );659660 res['transferFromCross'] =661 await helper.arrange.calculcateFeeGas(662 {Ethereum: ethReceiver},663 () => evmContract.methods.transferFromCross(crossReceiver, crossSigner, 1).send({from:ethReceiver}),664 );665666 res['transferFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(667 {Substrate: donor.address},668 () => collection.transferFrom(donor, {Substrate: subReceiver.address}, {Substrate: donor.address}, 1n),669 )));670671672 res['burnTokens'] = {fee: 0n, gas: 0n};673 res['burnTokens'].substrate = convertToTokens((await helper.arrange.calculcateFee(674 {Substrate: donor.address},675 () => collection.burnTokens(donor, 1n),676 )));677678679 res['approve*'] =680 await helper.arrange.calculcateFeeGas(681 {Ethereum: ethSigner},682 () => evmContract.methods.approve(ethReceiver, 2).send(),683 );684685 res['approve*'].zeppelin =686 await helper.arrange.calculcateFeeGas(687 {Ethereum: ethSigner},688 () => zeppelelinContract!.methods.approve(ethReceiver, 10).send(),689 );690691 res['approveCross'] =692 await helper.arrange.calculcateFeeGas(693 {Ethereum: ethSigner},694 () => evmContract.methods.approveCross(crossReceiver, 2).send(),695 );696697 res['approveCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(698 {Substrate: donor.address},699 () => collection.approveTokens(donor, {Substrate: subReceiver.address}, 1n),700 )));701702 res['burnFromCross'] =703 await helper.arrange.calculcateFeeGas(704 {Ethereum: ethReceiver},705 () => evmContract.methods.burnFromCross(crossSigner, 1).send({from:ethReceiver}),706 );707708 res['burnFromCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(709 {Substrate: subReceiver.address},710 () => collection.burnTokensFrom(subReceiver, {Substrate: donor.address}, 1n),711 )));712713 res['setCollectionSponsorCross'] =714 await helper.arrange.calculcateFeeGas(715 {Ethereum: ethSigner},716 () => evmContract.methods.setCollectionSponsorCross(crossReceiver).send(),717 );718719 res['confirmCollectionSponsorship'] =720 await helper.arrange.calculcateFeeGas(721 {Ethereum: ethReceiver},722 () => evmContract.methods.confirmCollectionSponsorship().send({from: ethReceiver}),723 );724725 res['removeCollectionSponsor'] =726 await helper.arrange.calculcateFeeGas(727 {Ethereum: ethSigner},728 () => evmContract.methods.removeCollectionSponsor().send(),729 );730731 res['setCollectionSponsorCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(732 {Substrate: donor.address},733 () => collection.setSponsor(donor, subReceiver.address),734 )));735736 res['confirmCollectionSponsorship'].substrate = convertToTokens((await helper.arrange.calculcateFee(737 {Substrate: subReceiver.address},738 () => collection.confirmSponsorship(subReceiver),739 )));740741 res['removeCollectionSponsor'].substrate = convertToTokens((await helper.arrange.calculcateFee(742 {Substrate: donor.address},743 () => collection.removeSponsor(donor),744 )));745746 res['setCollectionProperties'] =747 await helper.arrange.calculcateFeeGas(748 {Ethereum: ethSigner},749 () => evmContract.methods.setCollectionProperties(PROPERTIES.slice(0, 1)).send(),750 );751752 res['deleteCollectionProperties'] =753 await helper.arrange.calculcateFeeGas(754 {Ethereum: ethSigner},755 () => evmContract.methods.deleteCollectionProperties(PROPERTIES.slice(0,1).map(p => p.key)).send(),756 );757 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(758 {Substrate: donor.address},759 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)760 .map(p => ({key: p.key, value: p.value.toString()}))),761 )));762763 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(764 {Substrate: donor.address},765 () => collection.deleteProperties(donor, PROPERTIES.slice(0, 1)766 .map(p => p.key)),767 )));768769 res['setCollectionLimit'] =770 await helper.arrange.calculcateFeeGas(771 {Ethereum: ethSigner},772 () => evmContract.methods.setCollectionLimit({field: CollectionLimitField.AccountTokenOwnership, value: {status: true, value: 1000}}).send(),773 );774775 res['setCollectionLimit'].substrate = convertToTokens((await helper.arrange.calculcateFee(776 {Substrate: donor.address},777 () => collection.setLimits(donor, {accountTokenOwnershipLimit: 1000}),778 )));779780 const {collectionAddress} = await helper.eth.createCollection(ethSigner, new CreateCollectionData('A', 'B', 'C', 'nft')).send();781 const collectionWithEthOwner = await helper.ethNativeContract.collection(collectionAddress, 'nft', ethSigner, true);782783784 res['addCollectionAdminCross'] =785 await helper.arrange.calculcateFeeGas(786 {Ethereum: ethSigner},787 () => collectionWithEthOwner.methods.addCollectionAdminCross(crossReceiver).send(),788 );789790 res['removeCollectionAdminCross'] =791 await helper.arrange.calculcateFeeGas(792 {Ethereum: ethSigner},793 () => collectionWithEthOwner.methods.removeCollectionAdminCross(crossReceiver).send(),794 );795796 res['addCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(797 {Substrate: donor.address},798 () => collection.addAdmin(donor, {Ethereum: ethReceiver}),799 )));800801 res['removeCollectionAdminCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(802 {Substrate: donor.address},803 () => collection.removeAdmin(donor, {Ethereum: ethReceiver}),804 )));805806 res['setCollectionNesting'] =807 await helper.arrange.calculcateFeeGas(808 {Ethereum: ethSigner},809 () => evmContract.methods.setCollectionNesting(true).send(),810 );811812 res['setCollectionNesting[]'] =813 await helper.arrange.calculcateFeeGas(814 {Ethereum: ethSigner},815 () => evmContract.methods.setCollectionNesting(true, [collectionAddress]).send(),816 );817818 res['setCollectionNesting'].substrate = convertToTokens((await helper.arrange.calculcateFee(819 {Substrate: donor.address},820 () => collection.disableNesting(donor),821 )));822823 res['setCollectionNesting[]'].substrate = convertToTokens((await helper.arrange.calculcateFee(824 {Substrate: donor.address},825 () => collection.setPermissions(826 donor,827 {828 nesting: {829 tokenOwner: true,830 restricted: [collection.collectionId],831 },832 },833 ),834 )));835836 res['setCollectionAccess'] =837 await helper.arrange.calculcateFeeGas(838 {Ethereum: ethSigner},839 () => evmContract.methods.setCollectionAccess(1).send(),840 );841842 res['setCollectionAccess'].substrate = convertToTokens((await helper.arrange.calculcateFee(843 {Substrate: donor.address},844 () => collection.setPermissions(donor, {access: 'AllowList'}),845 )));846847 res['addToCollectionAllowListCross'] =848 await helper.arrange.calculcateFeeGas(849 {Ethereum: ethSigner},850 () => evmContract.methods.addToCollectionAllowListCross(crossReceiver).send(),851 );852853 res['removeFromCollectionAllowListCross'] =854 await helper.arrange.calculcateFeeGas(855 {Ethereum: ethSigner},856 () => evmContract.methods.removeFromCollectionAllowListCross(crossReceiver).send(),857 );858859 res['addToCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(860 {Substrate: donor.address},861 () => collection.addToAllowList(donor, {Ethereum: ethReceiver}),862 )));863864 res['removeFromCollectionAllowListCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(865 {Substrate: donor.address},866 () => collection.removeFromAllowList(donor, {Ethereum: ethReceiver}),867 )));868869 res['setCollectionMintMode'] =870 await helper.arrange.calculcateFeeGas(871 {Ethereum: ethSigner},872 () => evmContract.methods.setCollectionMintMode(true).send(),873 );874875 res['setCollectionMintMode'].substrate = convertToTokens((await helper.arrange.calculcateFee(876 {Substrate: donor.address},877 () => collection.setPermissions(donor, {mintMode: false}),878 )));879880 res['changeCollectionOwnerCross'] =881 await helper.arrange.calculcateFeeGas(882 {Ethereum: ethSigner},883 () => collectionWithEthOwner.methods.changeCollectionOwnerCross(crossReceiver).send(),884 );885886 res['changeCollectionOwnerCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(887 {Substrate: donor.address},888 () => collection.changeOwner(donor, subReceiver.address),889 )));890891 return res;892}