Created
April 24, 2022 21:22
-
-
Save qruz-hq/7be9123c41b43f3c324ac124602e166d to your computer and use it in GitHub Desktop.
Minting function (FrontEnd)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function mint() { | |
if (contract) { | |
showNotification({ | |
id: 'MINT', | |
message: 'Minting...', | |
loading: true, | |
color: 'blue', | |
autoClose: false, | |
}); | |
setMinting(true); | |
const _count = Number(count); | |
if (publicSale) { | |
contract.estimateGas | |
.publicSaleMint(_count, { | |
value: actualPrice().mul(_count), | |
}) | |
.then(async (gas: BigNumber) => { | |
contract | |
.publicSaleMint(_count, { | |
value: actualPrice().mul(_count), | |
gasLimit: Math.floor(gas.toNumber() * 1.4), | |
}) | |
.then((tx: TransactionResponse) => handleMintResponse(tx)) | |
.catch((e: Error) => handleMintError(e)); | |
}); | |
} else if (preSale) { | |
contract.estimateGas | |
.preSaleMint(_count, { | |
value: actualPrice().mul(_count), | |
}) | |
.then(async (gas: BigNumber) => { | |
contract | |
.preSaleMint(_count, { | |
value: actualPrice().mul(_count), | |
gasLimit: Math.floor(gas.toNumber() * 1.4), | |
}) | |
.then((tx: TransactionResponse) => handleMintResponse(tx)) | |
.catch((e: Error) => handleMintError(e)); | |
}); | |
} else if (!isDAEnded()) { | |
contract.estimateGas | |
.dutchAuctionMint(_count, { | |
value: actualPrice().mul(_count), | |
}) | |
.then(async (gas: BigNumber) => { | |
contract | |
.dutchAuctionMint(_count, { | |
value: actualPrice().mul(_count), | |
gasLimit: Math.floor(gas.toNumber() * 1.4), | |
}) | |
.then((tx: TransactionResponse) => handleMintResponse(tx)) | |
.catch((e: Error) => handleMintError(e)); | |
}); | |
} else { | |
setMinting(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment