diff --git a/src/factories/NFTFactory.ts b/src/factories/NFTFactory.ts index aa87a7c4..1ca179b1 100644 --- a/src/factories/NFTFactory.ts +++ b/src/factories/NFTFactory.ts @@ -35,6 +35,7 @@ export interface NftCreateData { tokenURI: string } +const addressZERO = '0x0000000000000000000000000000000000000000' /** * Provides an interface for NFT Factory contract */ @@ -83,7 +84,7 @@ export class NftFactory { nftData.name, nftData.symbol, nftData.templateIndex, - '0x0000000000000000000000000000000000000000', + addressZERO, nftData.tokenURI ) .estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas)) @@ -107,7 +108,16 @@ export class NftFactory { nftData.name = name nftData.symbol = symbol } + if ( nftData.templateIndex > await this.getCurrentNFTTemplateCount()) { + throw new Error(`Template index doesnt exist`) + } + if ( nftData.templateIndex === 0) { + throw new Error(`Template index cannot be ZERO`) + } + if((await this.getNFTTemplate(nftData.templateIndex)).isActive === false) { + throw new Error(`Template is not active`) + } const estGas = await this.estGasCreateNFT(address, nftData) // Invoke createToken function of the contract @@ -116,7 +126,7 @@ export class NftFactory { nftData.name, nftData.symbol, nftData.templateIndex, - '0x0000000000000000000000000000000000000000', + addressZERO, nftData.tokenURI ) .send({ @@ -179,6 +189,13 @@ export class NftFactory { * @return {Promise