Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mints: fix insufficient eth check #5186

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/screens/mints/MintSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ const MintSheet = () => {
const { result: aspectRatio } = usePersistentAspectRatio(imageUrl || '');
// isMintingPublicSale handles if theres a time based mint, otherwise if there is a price we should be able to mint
const isMintingAvailable =
!(isReadOnlyWallet || isHardwareWallet) &&
!!mintCollection.publicMintInfo &&
!gasError;
!!mintCollection.publicMintInfo && (!gasError || insufficientEth);
jinchung marked this conversation as resolved.
Show resolved Hide resolved

const imageColor =
usePersistentDominantColorFromImage(imageUrl) ?? colors.paleBlue;
Expand Down Expand Up @@ -265,9 +263,14 @@ const MintSheet = () => {
accountAddress
)
)?.balance?.amount ?? 0;

const totalMintPrice = multiply(price.amount, quantity);
if (greaterThanOrEqualTo(totalMintPrice, nativeBalance)) {
setInsufficientEth(true);
return;
}
const txFee = getTotalGasPrice();
const txFeeWithBuffer = multiply(txFee, 1.2);
const totalMintPrice = multiply(price.amount, quantity);
// gas price + mint price
setInsufficientEth(
greaterThanOrEqualTo(
Expand Down Expand Up @@ -343,7 +346,6 @@ const MintSheet = () => {
value: item.data?.value,
};
const gas = await estimateGas(tx, provider);

let l1GasFeeOptimism = null;
// add l1Fee for OP Chains
if (getNetworkObj(currentNetwork).gas.OptimismTxFee) {
Expand Down Expand Up @@ -724,7 +726,6 @@ const MintSheet = () => {
plusAction={() => setQuantity(1)}
minusAction={() => setQuantity(-1)}
buttonColor={imageColor}
disabled={!isMintingAvailable}
maxValue={Number(maxMintsPerWallet)}
/>
</Stack>
Expand Down
Loading