git.delta.rocks / unique-network / refs/commits / 71f76028ba5c

difftreelog

chore added some substate benchmarks

PraetorP2023-01-25parent: #c7fed00.patch.diff
in: master
- `mint`
- `mintCross`
- `setCollectionProperties`
- ` deleteCollectionProperties`

1 file changed

modifiedtests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth
9import {UniqueNFTCollection} from '../../util/playgrounds/unique';9import {UniqueNFTCollection} from '../../util/playgrounds/unique';
10import {Contract} from 'web3-eth-contract';10import {Contract} from 'web3-eth-contract';
11import {createObjectCsvWriter} from 'csv-writer';11import {createObjectCsvWriter} from 'csv-writer';
12import {FeeGas} from '../../eth/util/playgrounds/unique.dev';
1312
14const CONTRACT_IMPORT: ContractImports[] = [13const CONTRACT_IMPORT: ContractImports[] = [
15 {14 {
590 await calculatedCall(collection);589 await calculatedCall(collection);
591 });590 });
592}591}
593function convertToTokens(value: bigint, nominal: bigint): number {592function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {
594 return Number((value * 1000n) / nominal) / 1000;593 return Number((value * 1000n) / nominal) / 1000;
595}594}
596595
635 () => evmContract.methods.mint(ethSigner).send(),634 () => evmContract.methods.mint(ethSigner).send(),
636 );635 );
636
637 res['mint'].substrate = convertToTokens((await helper.arrange.calculcateFee(
638 {Substrate: donor.address},
639 () => collection.mintToken(
640 donor,
641 {Ethereum: ethSigner},
642 ),
643 )));
637644
638 res['mintCross'] =645 res['mintCross'] =
639 await helper.arrange.calculcateFeeGas(646 await helper.arrange.calculcateFeeGas(
640 {Ethereum: ethSigner},647 {Ethereum: ethSigner},
641 () => evmContract.methods.mintCross(crossSigner, []).send(),648 () => evmContract.methods.mintCross(crossSigner, []).send(),
642 );649 );
650
651 res['mintCross'].substrate = convertToTokens((await helper.arrange.calculcateFee(
652 {Substrate: donor.address},
653 () => collection.mintMultipleTokens(donor, [{
654 owner: {Ethereum: ethSigner},
655 }]),
656 )));
643657
644 res['mintWithTokenURI'] =658 res['mintWithTokenURI'] =
645 await helper.arrange.calculcateFeeGas(659 await helper.arrange.calculcateFeeGas(
744 {Ethereum: ethSigner},756 {Ethereum: ethSigner},
745 () => evmContract.methods.deleteCollectionProperties(PROPERTIES.slice(0,1).map(p => p.key)).send(),757 () => evmContract.methods.deleteCollectionProperties(PROPERTIES.slice(0,1).map(p => p.key)).send(),
746 );758 );
759 res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
760 {Substrate: donor.address},
761 () => collection.setProperties(donor, PROPERTIES.slice(0, 1)
762 .map(p => { return {key: p.key, value: p.value.toString()}; })),
763 )));
764
765 res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
766 {Substrate: donor.address},
767 () => collection.deleteProperties(donor, PROPERTIES.slice(0, 1)
768 .map(p => p.key)),
769 )));
747770
748 res['setCollectionLimit'] =771 res['setCollectionLimit'] =
749 await helper.arrange.calculcateFeeGas(772 await helper.arrange.calculcateFeeGas(
808 {Ethereum: ethSigner},831 {Ethereum: ethSigner},
809 () => collectionWithEthOwner.methods.changeCollectionOwnerCross(crossReceiver).send(),832 () => collectionWithEthOwner.methods.changeCollectionOwnerCross(crossReceiver).send(),
810 );833 );
811 for (const name in res) {834
812 res[name] = {fee: res[name].fee, gas: res[name].gas};
813 }
814 return res;835 return res;
815}836}