lesson 14 04-mint.js #3022
Answered
by
alymurtazamemon
SidharthK2
asked this question in
Q&A
-
await new Promise(async (resolve, reject) => {
setTimeout(() => reject("Timeout: 'NFTMinted' event did not fire"), 300000) // 5 minute timeout time
// setup listener for our event
randomIpfsNft.once("NftMinted", async () => {
resolve()
})
if (chainId == 31337) {
const requestId = randomIpfsNftMintTxReceipt.events[1].args.requestId.toString()
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock", deployer)
await vrfCoordinatorV2Mock.fulfillRandomWords(requestId, randomIpfsNft.address)
}
}) Why are we wrapping this code inside a promise? why can't we just use await. |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Oct 2, 2022
Replies: 1 comment 1 reply
-
@SidharthK2 Because we want this execution to be rejected if something goes wrong. With await, it will be stuck at that point if our event does not trigger. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
SidharthK2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@SidharthK2 Because we want this execution to be rejected if something goes wrong. With await, it will be stuck at that point if our event does not trigger.