Skip to content

Commit

Permalink
fix: avoid failing when parsing eligible amount + etherscan for arb nova
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Jan 7, 2023
1 parent 8e21c98 commit 274fddb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/chains/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ const newChains: Chain[] = [
blockExplorers: {
etherscan: {
name: 'Arbitrum Nova explorer',
url: 'https://nova-explorer.arbitrum.io',
url: 'https://nova.arbiscan.io',
},
default: {
name: 'Arbitrum Nova explorer',
url: 'https://nova-explorer.arbitrum.io',
url: 'https://nova.arbiscan.io',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ethers from 'ethers';
import { BigNumber } from 'ethers';
import { useEffect } from 'react';
import { useEffect, useMemo } from 'react';

import { CryptoAmountInput } from '../../../../core/ui/components/elements/CryptoAmountInput';
import { useTieredSalesContext } from '../providers';
Expand All @@ -15,15 +15,21 @@ export const TieredSalesMintInput = ({ className }: Props) => {
setMintCount,
} = useTieredSalesContext();

const maxAllowedMintCountFormatted = Math.min(
Number(
eligibleAmount?.toString()
? contractDecimals
? ethers.utils.formatUnits(eligibleAmount, contractDecimals)
: Math.ceil(Number(eligibleAmount.toString()))
: Infinity,
),
);
const maxAllowedMintCountFormatted = useMemo(() => {
try {
return Math.min(
Number(
eligibleAmount?.toString()
? contractDecimals
? ethers.utils.formatUnits(eligibleAmount, contractDecimals)
: Math.ceil(Number(eligibleAmount.toString()))
: Infinity,
),
);
} catch (e) {
return Infinity;
}
}, [contractDecimals, eligibleAmount]);

useEffect(() => {
try {
Expand Down

0 comments on commit 274fddb

Please sign in to comment.