Skip to content

Commit

Permalink
Merge branch 'main' of github.com:curvefi/curve-frontend into refacto…
Browse files Browse the repository at this point in the history
…r/remove-apps
  • Loading branch information
DanielSchiavini committed Jan 24, 2025
2 parents 5358874 + 852a980 commit c73c0c1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 73 deletions.
2 changes: 1 addition & 1 deletion apps/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"typescript": "*"
},
"dependencies": {
"@curvefi/api": "^2.65.29",
"@curvefi/api": "^2.66.1",
"@curvefi/lending-api": "^2.4.1",
"@curvefi/stablecoin-api": "^1.5.8",
"@hookform/error-message": "^2.0.1",
Expand Down
111 changes: 50 additions & 61 deletions apps/main/src/dex/components/PagePoolList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const PoolList = ({
const fetchPoolsRewardsApy = useStore((state) => state.pools.fetchPoolsRewardsApy)
const setFormValues = useStore((state) => state.poolList.setFormValues)
const { initCampaignRewards, initiated } = useStore((state) => state.campaigns)
const provider = useStore((state) => state.wallet.getProvider(''))
const network = useStore((state) => state.networks.networks[rChainId])

const [showDetail, setShowDetail] = useState('')
Expand Down Expand Up @@ -183,71 +182,61 @@ const PoolList = ({
updatePath={updatePath}
/>

{!provider ? (
<ConnectWalletWrapper>
<ConnectWallet
description={t`Connect wallet to view pool list`}
connectText={t`Connect Wallet`}
loadingText={t`Connecting`}
<Table cellPadding={0} cellSpacing={0}>
{isXSmDown ? (
<TableHeadMobile showInPoolColumn={showInPoolColumn} />
) : (
<TableHead
columnKeys={columnKeys}
isLite={isLite}
isReadyRewardsApy={!!rewardsApyMapper}
isReadyTvl={!!tvlMapper}
isReadyVolume={!!volumeMapper}
searchParams={searchParams}
tableLabels={tableLabels}
updatePath={updatePath}
/>
</ConnectWalletWrapper>
) : (
<Table cellPadding={0} cellSpacing={0}>
{isXSmDown ? (
<TableHeadMobile showInPoolColumn={showInPoolColumn} />
) : (
<TableHead
columnKeys={columnKeys}
isLite={isLite}
isReadyRewardsApy={!!rewardsApyMapper}
isReadyTvl={!!tvlMapper}
isReadyVolume={!!volumeMapper}
)}
<Tbody $borderBottom>
{isReadyWithApiData && formStatus.noResult ? (
<TableRowNoResult
colSpan={colSpan}
searchParams={searchParams}
tableLabels={tableLabels}
signerAddress={signerAddress}
updatePath={updatePath}
/>
) : isReady && Array.isArray(result) ? (
<>
{result.map((poolId: string, index: number) => (
<PoolRow
key={poolId}
index={index}
columnKeys={columnKeys}
isLite={isLite}
poolId={poolId}
rChainId={rChainId}
searchParams={searchParams}
imageBaseUrl={network?.imageBaseUrl ?? ''}
showInPoolColumn={showInPoolColumn}
tableLabels={tableLabels}
searchTermMapper={searchTermMapper}
showDetail={showDetail}
setShowDetail={setShowDetail}
curve={curve}
/>
))}
</>
) : (
<tr>
<td colSpan={colSpan}>
<SpinnerWrapper>
<Spinner />
</SpinnerWrapper>
</td>
</tr>
)}
<Tbody $borderBottom>
{isReadyWithApiData && formStatus.noResult ? (
<TableRowNoResult
colSpan={colSpan}
searchParams={searchParams}
signerAddress={signerAddress}
updatePath={updatePath}
/>
) : isReady && Array.isArray(result) ? (
<>
{result.map((poolId: string, index: number) => (
<PoolRow
key={poolId}
index={index}
columnKeys={columnKeys}
isLite={isLite}
poolId={poolId}
rChainId={rChainId}
searchParams={searchParams}
imageBaseUrl={network?.imageBaseUrl ?? ''}
showInPoolColumn={showInPoolColumn}
tableLabels={tableLabels}
searchTermMapper={searchTermMapper}
showDetail={showDetail}
setShowDetail={setShowDetail}
curve={curve}
/>
))}
</>
) : (
<tr>
<td colSpan={colSpan}>
<SpinnerWrapper>
<Spinner />
</SpinnerWrapper>
</td>
</tr>
)}
</Tbody>
</Table>
)}
</Tbody>
</Table>
</>
)
}
Expand Down
8 changes: 4 additions & 4 deletions apps/main/src/dex/hooks/usePageOnMount.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { Location, NavigateFunction, Params } from 'react-router'
import type { ConnectState } from '@ui/utils'
import { isFailure, isLoading, isSuccess } from '@ui/utils'
import type { INetworkName } from '@curvefi/api/lib/interfaces'

import { ethers } from 'ethers'
import { useCallback, useEffect } from 'react'
import { useConnectWallet, useSetChain, useSetLocale, getWalletSignerAddress } from '@ui-kit/features/connect-wallet'
import { getWalletSignerAddress, useConnectWallet, useSetChain, useSetLocale } from '@ui-kit/features/connect-wallet'

import { CONNECT_STAGE, REFRESH_INTERVAL, ROUTE } from '@main/constants'
import { dynamicActivate, updateAppLocale } from '@ui-kit/lib/i18n'
import { getStorageValue, setStorageValue } from '@main/utils/storage'
import { useNetworkFromUrl, useParsedParams } from '@main/utils/utilsRouter'
import { getWalletChainId } from '@main/store/createWalletSlice'
import { initCurveJs } from '@main/utils/utilsCurvejs'
import { isFailure, isLoading, isSuccess } from '@ui/utils'
import useStore from '@main/store/useStore'
import { useUserProfileStore } from '@ui-kit/features/user-profile'
import { ChainId, PageProps, Wallet } from '@main/types/main.types'
Expand Down Expand Up @@ -47,8 +47,8 @@ function usePageOnMount(params: Params, location: Location, navigate: NavigateFu
updateGlobalStoreByKey('isLoadingApi', true)
updateGlobalStoreByKey('isLoadingCurve', true) // remove -> use connectState

if (useWallet && wallet && chainId) {
const api = await initCurveJs(chainId, wallet)
if (chainId) {
const api = await initCurveJs(chainId, (useWallet && wallet) || undefined)
setNetworkConfigs(api)
updateCurveJs(api, prevCurveApi, wallet)
updateConnectState('success', '')
Expand Down
1 change: 1 addition & 0 deletions apps/main/src/dex/store/createPoolsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ const createPoolsSlice = (set: SetState<State>, get: GetState<State>): PoolsSlic
},
fetchBasePools: async (curve: CurveApi) => {
const chainId = curve.chainId
if (curve.isNoRPC) return
set(
produce((state: State) => {
state.pools.basePoolsLoading = true
Expand Down
8 changes: 6 additions & 2 deletions apps/main/src/dex/utils/utilsCurvejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import cloneDeep from 'lodash/cloneDeep'
import { FORMAT_OPTIONS, formatNumber } from '@ui/utils'
import { CurveApi, ChainId, Pool, RewardsApy, Wallet } from '@main/types/main.types'

export async function initCurveJs(chainId: ChainId, wallet: Wallet) {
export async function initCurveJs(chainId: ChainId, wallet?: Wallet) {
const curveApi = cloneDeep((await import('@curvefi/api')).default) as CurveApi
await curveApi.init('Web3', { network: { chainId }, externalProvider: getWalletProvider(wallet) }, { chainId })
if (wallet) {
await curveApi.init('Web3', { network: { chainId }, externalProvider: getWalletProvider(wallet) }, { chainId })
} else {
await curveApi.init('NoRPC', 'NoRPC', { chainId })
}
return curveApi
}

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3328,15 +3328,15 @@ __metadata:
languageName: node
linkType: hard

"@curvefi/api@npm:^2.65.29":
version: 2.65.29
resolution: "@curvefi/api@npm:2.65.29"
"@curvefi/api@npm:^2.66.1":
version: 2.66.1
resolution: "@curvefi/api@npm:2.66.1"
dependencies:
"@curvefi/ethcall": "npm:6.0.7"
bignumber.js: "npm:^9.1.2"
ethers: "npm:^6.13.4"
memoizee: "npm:^0.4.17"
checksum: 10c0/90a04fc6a7842e63b977580b449bce4f1f6776abacae5ac7a0c9dca1a51f6a561827574092d62c7bfddd67fc48c1d270acbbc584e18ff2c89613e9c98c3a87ce
checksum: 10c0/70e1510f7fbc5b88edbc67e049dba38ce9e7f6c150237a04fda7b63aa3f317ffd0d5f49df414cc4360a98452c017652bec4532245a12a02ea7bcaecdb110565e
languageName: node
linkType: hard

Expand Down Expand Up @@ -21162,7 +21162,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "main@workspace:apps/main"
dependencies:
"@curvefi/api": "npm:^2.65.29"
"@curvefi/api": "npm:^2.66.1"
"@curvefi/lending-api": "npm:^2.4.1"
"@curvefi/stablecoin-api": "npm:^1.5.8"
"@hookform/error-message": "npm:^2.0.1"
Expand Down

0 comments on commit c73c0c1

Please sign in to comment.