git.delta.rocks / unique-network / refs/commits / d6d8a4572f2e

difftreelog

Merge pull request #858 from UniqueNetwork/feature/erc721bench

Andy Smith2023-02-09parents: #5f3e0fd #c8529d8.patch.diff
in: master
Feature/erc721bench

72 files changed

modifiedtests/.gitignorediffbeforeafterboth
1/node_modules/1/node_modules/
2properties.csv2properties.csv
33erc721.csv
4erc20.csv
deletedtests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth

no changes

addedtests/src/benchmarks/mintFee/index.tsdiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/README.mddiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Address.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Context.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/ZeppelinContract.soldiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.abidiffbeforeafterboth

no changes

deletedtests/src/benchmarks/mintFee/openZeppelin/bin/ZeppelinContract.bindiffbeforeafterboth

no changes

addedtests/src/benchmarks/opsFee/index.tsdiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/common.tsdiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/README.mddiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/governance/utils/IVotes.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/interfaces/IERC3156FlashLender.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/security/Pausable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/ERC20.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/IERC20.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/Context.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/cryptography/ECDSA.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/cryptography/EIP712.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/@openzeppelin/contracts/utils/math/SafeCast.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/ZeppelinContract.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/bin/ZeppelinContract.abidiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC20/bin/ZeppelinContract.bindiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/README.mddiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/access/Ownable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/ERC721.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/IERC721.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/IERC721Receiver.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/Address.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/Context.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/Counters.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/Strings.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/introspection/ERC165.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/introspection/IERC165.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/@openzeppelin/contracts/utils/math/Math.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/ZeppelinContract.soldiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/bin/ZeppelinContract.abidiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/openZeppelin/ERC721/bin/ZeppelinContract.bindiffbeforeafterboth

no changes

addedtests/src/benchmarks/utils/types.tsdiffbeforeafterboth

no changes

modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
16import {evmToAddress} from '@polkadot/util-crypto';16import {evmToAddress} from '@polkadot/util-crypto';
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
1818
19import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';19import {ArrangeGroup, DevUniqueHelper} from '../../../util/playgrounds/unique.dev';
2020
21import {ContractImports, CompiledContract, CrossAddress, NormalizedEvent, EthProperty} from './types';21import {ContractImports, CompiledContract, CrossAddress, NormalizedEvent, EthProperty} from './types';
2222
461 }461 }
462}462}
463463
464export class FeeGas {
465 fee: number | bigint = 0n;
466
467 gas: number | bigint = 0n;
468
469 public static async build(helper: EthUniqueHelper, fee: bigint): Promise<FeeGas> {
470 const instance = new FeeGas();
471 instance.fee = instance.convertToTokens(fee);
472 instance.gas = await instance.convertToGas(fee, helper);
473 return instance;
474 }
475
476 private async convertToGas(fee: bigint, helper: EthUniqueHelper): Promise<bigint> {
477 const gasPrice = BigInt(await helper.getWeb3().eth.getGasPrice());
478 return fee / gasPrice;
479 }
480
481 private convertToTokens(value: bigint, nominal = 1_000_000_000_000_000_000n): number {
482 return Number((value * 1000n) / nominal) / 1000;
483 }
484}
485
486class EthArrangeGroup extends ArrangeGroup {
487 helper: EthUniqueHelper;
488
489 constructor(helper: EthUniqueHelper) {
490 super(helper);
491 this.helper = helper;
492 }
493
494 async calculcateFeeGas(payer: ICrossAccountId, promise: () => Promise<any>): Promise<FeeGas> {
495 const fee = await this.calculcateFee(payer, promise);
496 return await FeeGas.build(this.helper, fee);
497 }
498}
464export class EthUniqueHelper extends DevUniqueHelper {499export class EthUniqueHelper extends DevUniqueHelper {
465 web3: Web3 | null = null;500 web3: Web3 | null = null;
466 web3Provider: WebsocketProvider | null = null;501 web3Provider: WebsocketProvider | null = null;
471 ethNativeContract: NativeContractGroup;506 ethNativeContract: NativeContractGroup;
472 ethContract: ContractGroup;507 ethContract: ContractGroup;
473 ethProperty: EthPropertyGroup;508 ethProperty: EthPropertyGroup;
474509 arrange: EthArrangeGroup;
475 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {510 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
476 options.helperBase = options.helperBase ?? EthUniqueHelper;511 options.helperBase = options.helperBase ?? EthUniqueHelper;
477512
482 this.ethNativeContract = new NativeContractGroup(this);517 this.ethNativeContract = new NativeContractGroup(this);
483 this.ethContract = new ContractGroup(this);518 this.ethContract = new ContractGroup(this);
484 this.ethProperty = new EthPropertyGroup(this);519 this.ethProperty = new EthPropertyGroup(this);
520 this.arrange = new EthArrangeGroup(this);
521 super.arrange = this.arrange;
485 }522 }
486523
487 getWeb3(): Web3 {524 getWeb3(): Web3 {
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
186186
187export class DevKaruraHelper extends DevAcalaHelper {}187export class DevKaruraHelper extends DevAcalaHelper {}
188188
189class ArrangeGroup {189export class ArrangeGroup {
190 helper: DevUniqueHelper;190 helper: DevUniqueHelper;
191191
192 scheduledIdSlider = 0;192 scheduledIdSlider = 0;
321 };321 };
322322
323 async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {323 async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {
324 const address = payer.Substrate ? payer.Substrate : await this.helper.address.ethToSubstrate(payer.Ethereum!);324 const address = payer.Substrate ? payer.Substrate : this.helper.address.ethToSubstrate(payer.Ethereum!);
325 let balance = await this.helper.balance.getSubstrate(address);325 let balance = await this.helper.balance.getSubstrate(address);
326326
327 await promise();327 await promise();