Skip to content

Commit

Permalink
fix: cache mint count on re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Jan 3, 2023
1 parent 76d2535 commit 40de08f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ export const useTieredSalesMinter = ({

const _tierId = tierId;
const _mintCount = mintCount || '0';
const _mintCountBN = contractDecimals
? ethers.utils.parseUnits(_mintCount.toString(), contractDecimals)
: BigNumber.from(Math.ceil(Number(_mintCount || 0)).toString());
const _mintCountBN = useMemo(
() =>
contractDecimals
? ethers.utils.parseUnits(_mintCount.toString(), contractDecimals)
: BigNumber.from(Math.ceil(Number(_mintCount || 0)).toString()),
[_mintCount, contractDecimals],
);
const _maxAllowance = merkleMetadata?.maxAllowance || _mintCountBN;
const _merkleProof = useMemo(() => merkleProof || [], [merkleProof]);
const _totalAmount = useMemo(() => {
Expand Down Expand Up @@ -417,6 +421,7 @@ export const useTieredSalesMinter = ({
},
error: {
tierError,
contractDecimalsError,
allowlistCheckerError,
eligibleAmountError,
allowanceError,
Expand All @@ -425,6 +430,7 @@ export const useTieredSalesMinter = ({
},
isLoading: {
tierLoading,
contractDecimalsLoading,
allowlistCheckerLoading,
eligibleAmountLoading,
allowanceLoading,
Expand Down

0 comments on commit 40de08f

Please sign in to comment.