From 2ec7bd7f700ac74137787c09f5f7e71023b1a207 Mon Sep 17 00:00:00 2001 From: "Miquel A. Cabot" Date: Sun, 12 Jun 2022 11:13:02 +0200 Subject: [PATCH] add estimategas optional parameter to functions --- .eslintrc | 3 ++- src/contracts/factories/NFTFactory.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index befef970..6baae5de 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,7 +16,8 @@ "rules": { "no-empty": ["error", { "allowEmptyCatch": true }], "prefer-destructuring": ["warn", { "object": true, "array": false }], - "no-dupe-class-members": ["warn"], + "no-dupe-class-members": "off", + "no-redeclare": "off", "no-useless-constructor": ["warn"], "no-unused-vars": ["warn"], "constructor-super": ["warn"] diff --git a/src/contracts/factories/NFTFactory.ts b/src/contracts/factories/NFTFactory.ts index 5a5879c7..795c831e 100644 --- a/src/contracts/factories/NFTFactory.ts +++ b/src/contracts/factories/NFTFactory.ts @@ -33,7 +33,11 @@ export class NftFactory extends SmartContractWithAddress { * @param {NFTCreateData} nftData * @return {Promise} NFT datatoken address */ - public async createNFT(address: string, nftData: NftCreateData): Promise { + public async createNFT( + address: string, + nftData: NftCreateData, + estimateGas?: G + ): Promise { if (!nftData.templateIndex) nftData.templateIndex = 1 if (!nftData.name || !nftData.symbol) { @@ -63,6 +67,7 @@ export class NftFactory extends SmartContractWithAddress { nftData.transferable, nftData.owner ) + if (estimateGas) return estGas // Invoke createToken function of the contract const trxReceipt = await this.contract.methods @@ -180,10 +185,11 @@ export class NftFactory extends SmartContractWithAddress { * @param {String} templateAddress template address to add * @return {Promise} */ - public async addNFTTemplate( + public async addNFTTemplate( address: string, - templateAddress: string - ): Promise { + templateAddress: string, + estimateGas?: G + ): Promise { if ((await this.getOwner()) !== address) { throw new Error(`Caller is not Factory Owner`) } @@ -196,6 +202,7 @@ export class NftFactory extends SmartContractWithAddress { this.contract.methods.add721TokenTemplate, templateAddress ) + if (estimateGas) return estGas // Invoke add721TokenTemplate function of the contract const trxReceipt = await this.contract.methods