From 36a669ee7f0e2cf0a7934a165aca3853afa98bba Mon Sep 17 00:00:00 2001 From: skylarbarrera Date: Mon, 13 Nov 2023 17:03:47 -0500 Subject: [PATCH 1/2] fix insufficient eth check --- src/screens/mints/MintSheet.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/screens/mints/MintSheet.tsx b/src/screens/mints/MintSheet.tsx index 0ae8dc3597b..06959ce66c9 100644 --- a/src/screens/mints/MintSheet.tsx +++ b/src/screens/mints/MintSheet.tsx @@ -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); const imageColor = usePersistentDominantColorFromImage(imageUrl) ?? colors.paleBlue; @@ -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( @@ -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) { @@ -724,7 +726,6 @@ const MintSheet = () => { plusAction={() => setQuantity(1)} minusAction={() => setQuantity(-1)} buttonColor={imageColor} - disabled={!isMintingAvailable} maxValue={Number(maxMintsPerWallet)} /> From 1a2395a423aca53968cada65e88a7c23ff38d70b Mon Sep 17 00:00:00 2001 From: skylarbarrera Date: Tue, 14 Nov 2023 12:58:22 -0500 Subject: [PATCH 2/2] oop --- src/screens/mints/MintSheet.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/screens/mints/MintSheet.tsx b/src/screens/mints/MintSheet.tsx index 5335e4e5c2d..42f238709c4 100644 --- a/src/screens/mints/MintSheet.tsx +++ b/src/screens/mints/MintSheet.tsx @@ -235,7 +235,9 @@ 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 = - !!mintCollection.publicMintInfo && (!gasError || insufficientEth); + !(isReadOnlyWallet || isHardwareWallet) && + !!mintCollection.publicMintInfo && + (!gasError || insufficientEth); const imageColor = usePersistentDominantColorFromImage(imageUrl) ?? colors.paleBlue;