diff --git a/apps/web/src/components/CurrencySelect/index.tsx b/apps/web/src/components/CurrencySelect/index.tsx index 62ecaefd584d4a..0f2720526058d2 100644 --- a/apps/web/src/components/CurrencySelect/index.tsx +++ b/apps/web/src/components/CurrencySelect/index.tsx @@ -1,14 +1,14 @@ -import { styled } from 'styled-components' -import { ArrowDropDownIcon, Box, Button, Text, useModal, Flex, BoxProps } from '@pancakeswap/uikit' -import CurrencySearchModal, { CurrencySearchModalProps } from 'components/SearchModal/CurrencySearchModal' import { useTranslation } from '@pancakeswap/localization' +import { ArrowDropDownIcon, Box, BoxProps, Button, Flex, Text, useModal } from '@pancakeswap/uikit' import { formatNumber } from '@pancakeswap/utils/formatBalance' import { formatAmount } from '@pancakeswap/utils/formatFractions' -import { useCurrencyBalance } from 'state/wallet/hooks' +import CurrencySearchModal, { CurrencySearchModalProps } from 'components/SearchModal/CurrencySearchModal' import { useStablecoinPrice } from 'hooks/useBUSDPrice' +import { useCurrencyBalance } from 'state/wallet/hooks' +import { styled } from 'styled-components' import { useAccount } from 'wagmi' +import { AutoRow, RowBetween } from '../Layout/Row' import { CurrencyLogo } from '../Logo' -import { RowBetween, AutoRow } from '../Layout/Row' const DropDownHeader = styled.div` width: 100%; @@ -116,7 +116,7 @@ export const CurrencySelect = ({
- {Number.isFinite(+quoted?.toExact()) && ( + {quoted && Number.isFinite(+quoted?.toExact()) && ( ~${formatNumber(+quoted.toExact())} diff --git a/apps/web/src/components/EasyMde/index.tsx b/apps/web/src/components/EasyMde/index.tsx index 7c3023bebe5eb5..b84842bc08676c 100644 --- a/apps/web/src/components/EasyMde/index.tsx +++ b/apps/web/src/components/EasyMde/index.tsx @@ -1,7 +1,7 @@ -import { TextareaHTMLAttributes, useEffect, useRef } from 'react' import EasyMde from 'easymde' -import { styled } from 'styled-components' import merge from 'lodash/merge' +import { TextareaHTMLAttributes, useEffect, useRef } from 'react' +import { styled } from 'styled-components' import 'easymde/dist/easymde.min.css' diff --git a/apps/web/src/components/GlobalCheckClaimStatus/AnniversaryAchievementModal.tsx b/apps/web/src/components/GlobalCheckClaimStatus/AnniversaryAchievementModal.tsx index 16a6ab450a49f4..b75027fd454ed5 100644 --- a/apps/web/src/components/GlobalCheckClaimStatus/AnniversaryAchievementModal.tsx +++ b/apps/web/src/components/GlobalCheckClaimStatus/AnniversaryAchievementModal.tsx @@ -1,18 +1,18 @@ -import { AutoRenewIcon, Box, Button, Flex, Modal, Text, ModalV2, useToast } from '@pancakeswap/uikit' -import confetti from 'canvas-confetti' import { ChainId } from '@pancakeswap/chains' import { useTranslation } from '@pancakeswap/localization' -import delay from 'lodash/delay' -import React, { useRef, useEffect, useState } from 'react' -import { styled } from 'styled-components' +import { AutoRenewIcon, Box, Button, Flex, Modal, ModalV2, Text, useToast } from '@pancakeswap/uikit' +import confetti from 'canvas-confetti' import Dots from 'components/Loader/Dots' -import { useRouter } from 'next/router' -import { useAccount } from 'wagmi' +import { ToastDescriptionWithTx } from 'components/Toast' import { useActiveChainId } from 'hooks/useActiveChainId' -import { useAnniversaryAchievementContract } from 'hooks/useContract' import useCatchTxError from 'hooks/useCatchTxError' -import { ToastDescriptionWithTx } from 'components/Toast' +import { useAnniversaryAchievementContract } from 'hooks/useContract' import { useShowOnceAnniversaryModal } from 'hooks/useShowOnceAnniversaryModal' +import delay from 'lodash/delay' +import { useRouter } from 'next/router' +import React, { useEffect, useRef, useState } from 'react' +import { styled } from 'styled-components' +import { useAccount } from 'wagmi' const AnniversaryImage = styled.img` border-radius: 50%; @@ -58,8 +58,8 @@ const AnniversaryAchievementModal: React.FC = ({ excludeL // Check claim status useEffect(() => { const fetchClaimAnniversaryStatus = async () => { - const canClaimAnniversary = await contract.read.canClaim([account]) - setCanClaimAnniversaryPoints(canClaimAnniversary) + const canClaimAnniversary = account && (await contract.read.canClaim([account])) + setCanClaimAnniversaryPoints(Boolean(canClaimAnniversary)) } if (account && chainId === ChainId.BSC) { @@ -117,7 +117,14 @@ const AnniversaryAchievementModal: React.FC = ({ excludeL setIsLoading(true) try { - const receipt = await fetchWithCatchTxError(() => contract.write.claimAnniversaryPoints({ account, chainId })) + const receipt = + account && + (await fetchWithCatchTxError(() => + contract.write.claimAnniversaryPoints({ + account, + chain: contract.chain, + }), + )) if (receipt?.status) { toastSuccess(t('Success!'), ) diff --git a/apps/web/src/components/Menu/UserMenu/WalletModal.tsx b/apps/web/src/components/Menu/UserMenu/WalletModal.tsx index 10fbb53bafe901..a942c1c8e2ddb2 100644 --- a/apps/web/src/components/Menu/UserMenu/WalletModal.tsx +++ b/apps/web/src/components/Menu/UserMenu/WalletModal.tsx @@ -1,4 +1,4 @@ -import { parseEther } from 'viem' +import { useTranslation } from '@pancakeswap/localization' import { ButtonMenu, ButtonMenuItem, @@ -7,14 +7,14 @@ import { IconButton, InjectedModalProps, ModalBody, + ModalTitle, ModalWrapper, ModalHeader as UIKitModalHeader, - ModalTitle, } from '@pancakeswap/uikit' -import { useAccount, useBalance } from 'wagmi' -import { useState, useCallback } from 'react' -import { useTranslation } from '@pancakeswap/localization' +import { useCallback, useState } from 'react' import { styled } from 'styled-components' +import { parseEther } from 'viem' +import { useAccount, useBalance } from 'wagmi' import WalletInfo from './WalletInfo' import WalletTransactions from './WalletTransactions' import WalletWrongNetwork from './WalletWrongNetwork' @@ -67,7 +67,7 @@ const WalletModal: React.FC> = ({ const { t } = useTranslation() const { address: account } = useAccount() const { data, isFetched } = useBalance({ address: account }) - const hasLowNativeBalance = isFetched && data && data.value <= LOW_NATIVE_BALANCE + const hasLowNativeBalance = Boolean(isFetched && data && data.value <= LOW_NATIVE_BALANCE) const handleClick = useCallback((newIndex: number) => { setView(newIndex) @@ -88,8 +88,8 @@ const WalletModal: React.FC> = ({ {view === WalletView.WALLET_INFO && ( )} - {view === WalletView.TRANSACTIONS && } - {view === WalletView.WRONG_NETWORK && } + {view === WalletView.TRANSACTIONS && onDismiss && } + {view === WalletView.WRONG_NETWORK && onDismiss && } ) diff --git a/apps/web/src/quote-worker.ts b/apps/web/src/quote-worker.ts index 09be179679b007..2326f3e9cbcdc1 100644 --- a/apps/web/src/quote-worker.ts +++ b/apps/web/src/quote-worker.ts @@ -1,9 +1,10 @@ -import 'utils/workerPolyfill' import { SmartRouter } from '@pancakeswap/smart-router/evm' +import { SerializedCurrency, SerializedCurrencyAmount } from '@pancakeswap/smart-router/evm/v3-router/utils/transformer' import { Call } from 'state/multicall/actions' import { fetchChunk } from 'state/multicall/fetchChunk' -import { createViemPublicClientGetter } from 'utils/viem' import { getLogger } from 'utils/datadog' +import { createViemPublicClientGetter } from 'utils/viem' +import 'utils/workerPolyfill' const { parseCurrency, parseCurrencyAmount, parsePool, serializeTrade } = SmartRouter.Transformer @@ -156,8 +157,9 @@ addEventListener('message', (event: MessageEvent) => { } = parsed.data const onChainProvider = createViemPublicClientGetter({ transportSignal: abortController.signal }) const onChainQuoteProvider = SmartRouter.createQuoteProvider({ onChainProvider, gasLimit }) - const currencyAAmount = parseCurrencyAmount(chainId, amount) - const currencyB = parseCurrency(chainId, currency) + const currencyAAmount = parseCurrencyAmount(chainId, amount as SerializedCurrencyAmount) + + const currencyB = parseCurrency(chainId, currency as SerializedCurrency) const pools = candidatePools.map((pool) => parsePool(chainId, pool as any)) diff --git a/apps/web/src/state/farms/fetchFarmUser.ts b/apps/web/src/state/farms/fetchFarmUser.ts index ba34836c59af7b..17ff25dcee6e72 100644 --- a/apps/web/src/state/farms/fetchFarmUser.ts +++ b/apps/web/src/state/farms/fetchFarmUser.ts @@ -1,15 +1,15 @@ -import BigNumber from 'bignumber.js' import { ChainId } from '@pancakeswap/chains' +import BigNumber from 'bignumber.js' import { masterChefV2ABI } from 'config/abi/masterchefV2' import { nonBscVaultABI } from 'config/abi/nonBscVault' -import { getMasterChefV2Address, getNonBscVaultAddress } from 'utils/addressHelpers' import { SerializedFarmConfig } from 'config/constants/types' -import { verifyBscNetwork } from 'utils/verifyBscNetwork' -import { getCrossFarmingReceiverContract } from 'utils/contractHelpers' import { farmFetcher } from 'state/farms' -import { Address, erc20ABI } from 'wagmi' +import { getMasterChefV2Address, getNonBscVaultAddress } from 'utils/addressHelpers' +import { getCrossFarmingReceiverContract } from 'utils/contractHelpers' +import { verifyBscNetwork } from 'utils/verifyBscNetwork' import { publicClient } from 'utils/wagmi' import { ContractFunctionResult } from 'viem' +import { Address, erc20ABI } from 'wagmi' export const fetchFarmUserAllowances = async ( account: Address, diff --git a/apps/web/src/views/CakeStaking/hooks/useGaugesVotingCount.ts b/apps/web/src/views/CakeStaking/hooks/useGaugesVotingCount.ts index ef44c3176739bd..a2924fea8f2765 100644 --- a/apps/web/src/views/CakeStaking/hooks/useGaugesVotingCount.ts +++ b/apps/web/src/views/CakeStaking/hooks/useGaugesVotingCount.ts @@ -3,16 +3,18 @@ import { SUPPORT_CAKE_STAKING } from 'config/constants/supportChains' import { useActiveChainId } from 'hooks/useActiveChainId' import { useGaugesVotingContract } from 'hooks/useContract' -export const useGaugesVotingCount = (): bigint | undefined => { +type VointCountData = bigint | undefined + +export const useGaugesVotingCount = (): VointCountData => { const { chainId } = useActiveChainId() const gaugesVotingContract = useGaugesVotingContract() - const { data } = useQuery({ + const { data } = useQuery({ queryKey: ['gaugesVotingCount', gaugesVotingContract.address], queryFn: async () => { try { - const count = (await gaugesVotingContract.read.gaugeCount()) ?? 0n + const count = ((await gaugesVotingContract.read.gaugeCount()) as VointCountData) ?? 0n return count } catch (error) { console.warn(error) diff --git a/apps/web/src/views/GaugesVoting/hooks/useUserVote.ts b/apps/web/src/views/GaugesVoting/hooks/useUserVote.ts index 87153ca7f20521..b77d0db8e77599 100644 --- a/apps/web/src/views/GaugesVoting/hooks/useUserVote.ts +++ b/apps/web/src/views/GaugesVoting/hooks/useUserVote.ts @@ -34,6 +34,8 @@ export type VotedSlope = { ignoredPower?: bigint } +type UserVoteSlopesData = [[bigint, bigint, bigint], bigint, [bigint, bigint, bigint], bigint] + const max = (a: bigint, b: bigint) => (a > b ? a : b) const sum = (a: bigint, b: bigint) => a + b @@ -76,10 +78,11 @@ export const useUserVote = (gauge?: Gauge, useProxyPool: boolean = true) => { ...calls, ] as const if (hasProxy) { - const response = await publicClient.multicall({ + const response = (await publicClient.multicall({ contracts: callsWithProxy, allowFailure: false, - }) + })) as UserVoteSlopesData + const [ [_proxySlope, _proxyPower, proxyEnd], proxyLastVoteTime, @@ -160,10 +163,10 @@ export const useUserVote = (gauge?: Gauge, useProxyPool: boolean = true) => { ignoredSide, } } - const response = await publicClient.multicall({ + const response = (await publicClient.multicall({ contracts: calls, allowFailure: false, - }) + })) as [[bigint, bigint, bigint], bigint] const [[nativeSlope, nativePower, nativeEnd], lastVoteTime] = response const voteLocked = dayjs.unix(Number(lastVoteTime)).add(10, 'day').isAfter(dayjs.unix(currentTimestamp)) diff --git a/apps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts b/apps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts index 683a0f820cfd78..a159cab9c8c051 100644 --- a/apps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts +++ b/apps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts @@ -3,14 +3,7 @@ import { useQuery } from '@tanstack/react-query' import useAccountActiveChain from 'hooks/useAccountActiveChain' import { useGaugesVotingContract } from 'hooks/useContract' import { useMemo } from 'react' -import { - ContractFunctionConfig, - ContractFunctionResult, - Hex, - MulticallContracts, - isAddressEqual, - zeroAddress, -} from 'viem' +import { ContractFunctionConfig, Hex, MulticallContracts, isAddressEqual, zeroAddress } from 'viem' import { useVeCakeUserInfo } from 'views/CakeStaking/hooks/useVeCakeUserInfo' import { usePublicClient } from 'wagmi' import { useGauges } from './useGauges' @@ -68,7 +61,7 @@ export const useUserVoteSlopes = () => { const response = (await publicClient.multicall({ contracts, allowFailure: false, - })) as ContractFunctionResult[] + })) as [bigint, bigint, bigint][] const len = gauges.length return gauges.map((gauge, index) => { diff --git a/apps/web/src/views/Voting/CreateProposal/index.tsx b/apps/web/src/views/Voting/CreateProposal/index.tsx index f3fdeccc655718..d8e28e3851d287 100644 --- a/apps/web/src/views/Voting/CreateProposal/index.tsx +++ b/apps/web/src/views/Voting/CreateProposal/index.tsx @@ -9,11 +9,11 @@ import { Flex, Heading, Input, + ReactMarkdown, + ScanLink, Text, useModal, useToast, - ReactMarkdown, - ScanLink, } from '@pancakeswap/uikit' import snapshot from '@snapshot-labs/snapshot.js' import isEmpty from 'lodash/isEmpty' @@ -34,7 +34,7 @@ import { useAccount, useWalletClient } from 'wagmi' import Layout from '../components/Layout' import VoteDetailsModal from '../components/VoteDetailsModal' import { ADMINS, PANCAKE_SPACE, VOTE_THRESHOLD } from '../config' -import Choices, { ChoiceIdValue, makeChoice, MINIMUM_CHOICES } from './Choices' +import Choices, { ChoiceIdValue, MINIMUM_CHOICES, makeChoice } from './Choices' import { combineDateAndTime, getFormErrors } from './helpers' import { FormErrors, Label, SecondaryLabel } from './styles' import { FormState } from './types' diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 5909638659562f..a3b93aa2da7f5c 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -2,6 +2,7 @@ "extends": "@pancakeswap/tsconfig/nextjs.json", "compilerOptions": { "baseUrl": "./", + "strict": true, "strictNullChecks": true, "noImplicitAny": false, "noFallthroughCasesInSwitch": true, diff --git a/packages/smart-router/legacy-router/onchain/getStableSwapFee.ts b/packages/smart-router/legacy-router/onchain/getStableSwapFee.ts index ecae5aee351ec5..c432068c6c93de 100644 --- a/packages/smart-router/legacy-router/onchain/getStableSwapFee.ts +++ b/packages/smart-router/legacy-router/onchain/getStableSwapFee.ts @@ -1,11 +1,11 @@ -import { Currency, CurrencyAmount } from '@pancakeswap/sdk' import { ChainId } from '@pancakeswap/chains' +import { Currency, CurrencyAmount } from '@pancakeswap/sdk' +import { infoStableSwapABI } from '../../evm/abis/InfoStableSwap' +import { STABLE_SWAP_INFO_ADDRESS } from '../../evm/constants' import { wrappedCurrencyAmount } from '../../evm/utils/currency' +import { Provider, StableSwapFeeRaw, StableSwapPair } from '../types' import { getOutputToken } from '../utils/pair' -import { StableSwapPair, Provider, StableSwapFeeRaw } from '../types' -import { STABLE_SWAP_INFO_ADDRESS } from '../../evm/constants' -import { infoStableSwapABI } from '../../evm/abis/InfoStableSwap' export function getStableSwapFeeCall(pair: StableSwapPair, inputAmount: CurrencyAmount) { const { chainId } = inputAmount.currency @@ -47,10 +47,10 @@ export async function getStableSwapFee( const client = provider({ chainId }) - const [[feeRaw, adminFeeRaw]] = await client.multicall({ + const [[feeRaw, adminFeeRaw]] = (await client.multicall({ contracts: [call], allowFailure: false, - }) + })) as [[bigint, bigint]] return { fee: CurrencyAmount.fromRawAmount(outputToken, feeRaw), diff --git a/packages/uikit/src/components/Chart/index.stories.tsx b/packages/uikit/src/components/Chart/index.stories.tsx index 3283aaeb0a0098..5e0cd95c280153 100644 --- a/packages/uikit/src/components/Chart/index.stories.tsx +++ b/packages/uikit/src/components/Chart/index.stories.tsx @@ -1,5 +1,6 @@ import { LanguageProvider } from "@pancakeswap/localization"; import { Meta, Story } from "@storybook/react"; +// eslint-disable-next-line @typescript-eslint/no-unused-vars import React from "react"; import { Box } from "../Box"; import { PairDataTimeWindowEnum, SwapLineChart, SwapLineChartNewProps } from "./PairPriceChart"; diff --git a/packages/uikit/src/components/Toast/Toast.stories.tsx b/packages/uikit/src/components/Toast/Toast.stories.tsx index f3c3cd2a94619e..aba712eb47480d 100644 --- a/packages/uikit/src/components/Toast/Toast.stories.tsx +++ b/packages/uikit/src/components/Toast/Toast.stories.tsx @@ -1,4 +1,5 @@ import { Meta, StoryObj } from "@storybook/react"; +// eslint-disable-next-line @typescript-eslint/no-unused-vars import React from "react"; import { useToast } from "../../contexts"; import { Button } from "../Button";