Skip to content

Commit

Permalink
Add try/catch for failed transactions when deploying new NFT.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina committed Sep 23, 2024
1 parent c622b21 commit f2e5a3b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 21 additions & 17 deletions src/contracts/NFTFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,27 @@ export class NftFactory extends SmartContractWithAddress {
)
if (estimateGas) return <G extends false ? string : BigNumber>estGas
// Invoke createToken function of the contract
const tx = await sendTx(
estGas,
this.signer,
this.config?.gasFeeMultiplier,
this.contract.deployERC721Contract,
nftData.name,
nftData.symbol,
nftData.templateIndex,
ZERO_ADDRESS,
ZERO_ADDRESS,
nftData.tokenURI,
nftData.transferable,
nftData.owner
)
const trxReceipt = await tx.wait()
const events = getEventFromTx(trxReceipt, 'NFTCreated')
return events.args[0]
try {
const tx = await sendTx(
estGas,
this.signer,
this.config?.gasFeeMultiplier,
this.contract.deployERC721Contract,
nftData.name,
nftData.symbol,
nftData.templateIndex,
ZERO_ADDRESS,
ZERO_ADDRESS,
nftData.tokenURI,
nftData.transferable,
nftData.owner
)
const trxReceipt = await tx.wait()
const events = getEventFromTx(trxReceipt, 'NFTCreated')
return events.args[0]
} catch (e) {
console.error(`Creation of AccessList failed: ${e}`)
}
}

/**
Expand Down

0 comments on commit f2e5a3b

Please sign in to comment.