Skip to content

Commit 50246a5

Browse files
Merge branch 'main' into fix/console
2 parents 0f1e345 + cf23f0f commit 50246a5

File tree

257 files changed

+4622
-2863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+4622
-2863
lines changed

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
extends: ['custom'],
55
settings: {
66
next: {
7-
rootDir: ['apps/*/', 'packages/ui/*/', 'packages/curve-common/*/']
8-
}
9-
}
7+
rootDir: ['apps/*/', 'packages/ui/*/'],
8+
},
9+
},
1010
}

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ This repository is organized as follows:
5454
- `/apps/lend`: Lend [React](https://react.dev/) application.
5555
- `/tests`: DApp tests
5656
- `/packages/curve-ui-kit`: Shared UI kit created using Material UI, mapped as `@ui-kit`
57-
- `/packages/curve-common`: List of features for the DApps, mapped as `@/common`
5857

5958
## Development Guide
6059

apps/dao/lingui.config.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

apps/dao/lingui.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { config as default } from '../../lingui.config'

apps/dao/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const nextConfiguration = {
2727
unoptimized: true,
2828
},
2929
trailingSlash: true,
30-
transpilePackages: ['curve-common', 'curve-ui-kit'],
30+
transpilePackages: ['curve-ui-kit'],
3131
webpack(config) {
3232
config.module.rules.push({
3333
test: /\.svg$/,

apps/dao/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,19 @@
2626
"typescript": "*"
2727
},
2828
"dependencies": {
29-
"@curvefi/api": "^2.65.25",
29+
"@curvefi/api": "^2.65.27",
3030
"@hookform/error-message": "^2.0.1",
3131
"@hookform/resolvers": "^3.9.0",
32-
"@lingui/react": "^4.6.0",
3332
"@supercharge/promise-pool": "^2.3.2",
3433
"bignumber.js": "^9.1.2",
35-
"curve-common": "*",
3634
"curve-ui-kit": "*",
37-
"dayjs": "^1.11.7",
3835
"ethers": "^6.13.4",
3936
"focus-visible": "5.2.0",
4037
"fuse.js": "^6.6.2",
4138
"immer": "^9.0.12",
4239
"intersection-observer": "^0.12.0",
4340
"lightweight-charts": "4.1.2",
4441
"lodash": "4.17.21",
45-
"make-plural": "^7.1.0",
4642
"memoizee": "^0.4.17",
4743
"next": "^13.5.6",
4844
"next-images": "^1.8.5",

apps/dao/src/components/ConnectWallet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isLoading } from '@/ui/utils'
22
import useStore from '@/store/useStore'
3+
import { useUserProfileStore } from '@ui-kit/features/user-profile'
34

45
import ConnectWalletPrompt from '@/ui/ConnectWalletPrompt'
56

@@ -12,7 +13,7 @@ type ConnectWalletProps = {
1213
const ConnectWallet: React.FC<ConnectWalletProps> = ({ description, connectText, loadingText }) => {
1314
const updateConnectWalletStateKeys = useStore((state) => state.wallet.updateConnectWalletStateKeys)
1415
const connectState = useStore((state) => state.connectState)
15-
const theme = useStore((state) => state.themeType)
16+
const theme = useUserProfileStore((state) => state.theme)
1617

1718
const loading = isLoading(connectState)
1819

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { NextPage } from 'next'
2+
import { useEffect } from 'react'
3+
import { t } from '@lingui/macro'
4+
5+
import Stack from '@mui/material/Stack'
6+
7+
import DocumentHead from '@/layout/DocumentHead'
8+
import { scrollToTop } from '@/utils'
9+
10+
import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces'
11+
import { Disclaimer } from '@ui-kit/widgets/Disclaimer'
12+
13+
const { Spacing } = SizesAndSpaces
14+
15+
const Page: NextPage = () => {
16+
useEffect(() => {
17+
scrollToTop()
18+
}, [])
19+
20+
return (
21+
<>
22+
<DocumentHead title={t`Risk Disclaimer`} />
23+
24+
<Stack
25+
alignItems="center"
26+
gap={Spacing.xl}
27+
sx={{
28+
marginInline: 'auto',
29+
marginBlockStart: Spacing.xl,
30+
marginBlockEnd: Spacing.xxl,
31+
}}
32+
>
33+
<Disclaimer />
34+
</Stack>
35+
</>
36+
)
37+
}
38+
39+
export default Page

apps/dao/src/hooks/usePageOnMount.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { helpers } from '@/lib/curvejs'
1414
import { isFailure, isLoading, isSuccess } from '@/ui/utils'
1515
import networks from '@/networks'
1616
import useStore from '@/store/useStore'
17+
import { useUserProfileStore } from '@ui-kit/features/user-profile'
1718

1819
function usePageOnMount(params: Params, location: Location, navigate: NavigateFunction, chainIdNotRequired?: boolean) {
1920
const [{ wallet }, connect, disconnect] = useConnectWallet()
@@ -26,6 +27,8 @@ function usePageOnMount(params: Params, location: Location, navigate: NavigateFu
2627
const updateCurveJs = useStore((state) => state.updateCurveJs)
2728
const updateGlobalStoreByKey = useStore((state) => state.updateGlobalStoreByKey)
2829

30+
const setLocale = useUserProfileStore((state) => state.setLocale)
31+
2932
const walletChainId = getWalletChainId(wallet)
3033
const walletSignerAddress = getWalletSignerAddress(wallet)
3134
const parsedParams = parseParams(params, chainIdNotRequired)
@@ -219,7 +222,8 @@ function usePageOnMount(params: Params, location: Location, navigate: NavigateFu
219222
let data = await import(`@/locales/${rLocale}/messages`)
220223
dynamicActivate(rLocale, data)
221224
})()
222-
updateAppLocale(rLocale, updateGlobalStoreByKey)
225+
setLocale(rLocale)
226+
updateAppLocale(rLocale)
223227
updateWalletLocale(rLocale)
224228
} else if (walletChainId && curve && curve.chainId === walletChainId && parsedParams.rChainId !== walletChainId) {
225229
// switch network if url network is not same as wallet

apps/dao/src/layout/Header.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React, { useCallback, useMemo, useRef } from 'react'
22
import { t } from '@lingui/macro'
3-
import { useNavigate } from 'react-router-dom'
3+
import { useLocation, useNavigate } from 'react-router-dom'
44
import { CONNECT_STAGE } from '@/constants'
55
import { getLocaleFromUrl, getNetworkFromUrl, getRestFullPathname } from '@/utils/utilsRouter'
66
import { _parseRouteAndIsActive, isLoading } from '@/ui/utils'
77
import { getWalletSignerAddress, useConnectWallet } from '@ui-kit/features/connect-wallet'
88
import networks, { visibleNetworksList } from '@/networks'
99
import useLayoutHeight from '@/hooks/useLayoutHeight'
1010
import useStore from '@/store/useStore'
11-
import { Header as NewHeader, useHeaderHeight } from '@/common/widgets/Header'
12-
import { NavigationSection } from '@/common/widgets/Header/types'
13-
import { ThemeKey } from 'curve-ui-kit/src/themes/basic-theme'
11+
import { Header as NewHeader, useHeaderHeight } from '@ui-kit/widgets/Header'
12+
import { NavigationSection } from '@ui-kit/widgets/Header/types'
1413
import { APP_LINK } from '@ui-kit/shared/routes'
1514
import { GlobalBannerProps } from '@/ui/Banner/GlobalBanner'
15+
import { useUserProfileStore } from '@ui-kit/features/user-profile'
1616

1717
type HeaderProps = { sections: NavigationSection[]; BannerProps: GlobalBannerProps }
1818

@@ -27,40 +27,29 @@ export const Header = ({ sections, BannerProps }: HeaderProps) => {
2727
const connectState = useStore((state) => state.connectState)
2828
const isMdUp = useStore((state) => state.layout.isMdUp)
2929
const bannerHeight = useStore((state) => state.layoutHeight.globalAlert)
30-
const locale = useStore((state) => state.locale)
3130
const routerProps = useStore((state) => state.routerProps)
32-
const themeType = useStore((state) => state.themeType)
33-
const setAppCache = useStore((state) => state.setAppCache)
3431
const updateConnectState = useStore((state) => state.updateConnectState)
3532

33+
const locale = useUserProfileStore((state) => state.locale)
34+
35+
const location = useLocation()
3636
const { rLocalePathname } = getLocaleFromUrl()
37-
const { params: routerParams, location } = routerProps ?? {}
37+
const { params: routerParams } = routerProps ?? {}
3838

3939
const routerNetwork = routerParams?.network ?? 'ethereum'
4040
const routerPathname = location?.pathname ?? ''
4141

42-
const theme = themeType == 'default' ? 'light' : (themeType as ThemeKey)
4342
return (
4443
<NewHeader<ChainId>
4544
networkName={rNetwork}
4645
mainNavRef={mainNavRef}
47-
locale={locale}
4846
isMdUp={isMdUp}
4947
currentApp="dao"
5048
pages={useMemo(
5149
() => _parseRouteAndIsActive(APP_LINK.dao.pages, rLocalePathname, routerPathname, routerNetwork),
5250
[rLocalePathname, routerNetwork, routerPathname],
5351
)}
54-
themes={[
55-
theme,
56-
useCallback(
57-
(selectedThemeType: ThemeKey) =>
58-
setAppCache('themeType', selectedThemeType == 'light' ? 'default' : selectedThemeType),
59-
[setAppCache],
60-
),
61-
]}
6252
ChainProps={{
63-
theme,
6453
options: visibleNetworksList,
6554
disabled: isLoading(connectState, CONNECT_STAGE.SWITCH_NETWORK),
6655
chainId: rChainId,

apps/dao/src/layout/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Locale } from '@/common/widgets/Header/types'
1+
import { Locale } from '@ui-kit/widgets/Header/types'
22

33
import React, { useEffect, useMemo, useRef, useState } from 'react'
44
import styled from 'styled-components'
@@ -12,7 +12,8 @@ import { useHeightResizeObserver } from '@/ui/hooks'
1212
import useStore from '@/store/useStore'
1313

1414
import Header from '@/layout/Header'
15-
import { Footer } from 'curve-ui-kit/src/widgets/Footer'
15+
import { Footer } from '@ui-kit/widgets/Footer'
16+
import { useUserProfileStore } from '@ui-kit/features/user-profile'
1617

1718
const BaseLayout = ({ children }: { children: React.ReactNode }) => {
1819
const [{ wallet }] = useConnectWallet()
@@ -23,7 +24,8 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
2324
const layoutHeight = useStore((state) => state.layoutHeight)
2425
const updateConnectState = useStore((state) => state.updateConnectState)
2526
const updateLayoutHeight = useStore((state) => state.updateLayoutHeight)
26-
const locale = useStore((state) => state.locale)
27+
28+
const locale = useUserProfileStore((state) => state.locale)
2729

2830
useEffect(() => {
2931
updateLayoutHeight('globalAlert', globalAlertHeight)
@@ -71,7 +73,7 @@ const BaseLayout = ({ children }: { children: React.ReactNode }) => {
7173
}}
7274
/>
7375
<Main minHeight={minHeight}>{children}</Main>
74-
<Footer networkName={rNetwork} />
76+
<Footer appName="dao" networkName={rNetwork} />
7577
</Container>
7678
)
7779
}
@@ -83,6 +85,7 @@ const getSections = (locale: Locale) => [
8385
{ route: 'https://news.curve.fi/', label: t`News` },
8486
{ route: 'https://resources.curve.fi/lending/understanding-lending/', label: t`User Resources` },
8587
{ route: 'https://docs.curve.fi', label: t`Developer Resources` },
88+
{ route: '/disclaimer', label: t`Risk Disclaimers` },
8689
{ route: 'https://resources.curve.fi/glossary-branding/branding/', label: t`Branding` },
8790
...(locale === 'zh-Hans' || locale === 'zh-Hant' ? [{ route: 'https://www.curve.wiki/', label: t`Wiki` }] : []),
8891
],

apps/dao/src/pages/_app.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import delay from 'lodash/delay'
1010
import 'intersection-observer'
1111
import 'focus-visible'
1212
import '@/globals.css'
13-
import { ThemeProvider } from 'curve-ui-kit/src/shared/ui/ThemeProvider'
13+
import { ThemeProvider } from '@ui-kit/shared/ui/ThemeProvider'
1414

1515
import { dynamicActivate, initTranslation, updateAppLocale } from '@ui-kit/lib/i18n'
1616
import { connectWalletLocales, initOnboard } from '@ui-kit/features/connect-wallet'
17-
import { getLocaleFromUrl, getStorageValue } from '@/utils'
17+
import { getLocaleFromUrl } from '@/utils'
1818
import { getIsMobile, getPageWidthClassName, isSuccess } from '@/ui/utils'
1919
import { messages as messagesEn } from '@/locales/en/messages.js'
2020
import networks from '@/networks'
@@ -25,15 +25,14 @@ import usePageVisibleInterval from '@/hooks/usePageVisibleInterval'
2525
import Page from '@/layout'
2626
import GlobalStyle from '@/globalStyle'
2727
import { ChadCssProperties } from '@ui-kit/themes/typography'
28+
import { useUserProfileStore } from '@ui-kit/features/user-profile'
2829

2930
i18n.load({ en: messagesEn })
3031
i18n.activate('en')
3132

3233
function CurveApp({ Component }: AppProps) {
3334
const connectState = useStore((state) => state.connectState)
34-
const locale = useStore((state) => state.locale)
3535
const pageWidth = useStore((state) => state.layout.pageWidth)
36-
const themeType = useStore((state) => state.themeType)
3736
const setPageWidth = useStore((state) => state.layout.setLayoutWidth)
3837
const updateShowScrollButton = useStore((state) => state.updateShowScrollButton)
3938
const updateGlobalStoreByKey = useStore((state) => state.updateGlobalStoreByKey)
@@ -47,6 +46,10 @@ function CurveApp({ Component }: AppProps) {
4746
const onboard = useStore((state) => state.wallet.onboard)
4847
const isPageVisible = useStore((state) => state.isPageVisible)
4948

49+
const theme = useUserProfileStore((state) => state.theme)
50+
const locale = useUserProfileStore((state) => state.locale)
51+
const setLocale = useUserProfileStore((state) => state.setLocale)
52+
5053
const [appLoaded, setAppLoaded] = useState(false)
5154

5255
const handleResizeListener = useCallback(() => {
@@ -57,8 +60,8 @@ function CurveApp({ Component }: AppProps) {
5760
useEffect(() => {
5861
if (!pageWidth) return
5962

60-
document.body.className = `theme-${themeType} ${pageWidth} ${getIsMobile() ? '' : 'scrollSmooth'}`
61-
document.body.setAttribute('data-theme', themeType || '')
63+
document.body.className = `theme-${theme} ${pageWidth} ${getIsMobile() ? '' : 'scrollSmooth'}`
64+
document.body.setAttribute('data-theme', theme)
6265
document.documentElement.lang = locale
6366
})
6467

@@ -67,12 +70,6 @@ function CurveApp({ Component }: AppProps) {
6770
updateShowScrollButton(window.scrollY)
6871
}
6972

70-
const { themeType } = getStorageValue('APP_CACHE') ?? {}
71-
72-
// init theme
73-
const darkModeQuery = window.matchMedia('(prefers-color-scheme: dark)')
74-
updateGlobalStoreByKey('themeType', themeType ? themeType : darkModeQuery.matches ? 'dark' : 'default')
75-
7673
// init locale
7774
const { rLocale } = getLocaleFromUrl()
7875
const parsedLocale = rLocale?.value ?? 'en'
@@ -81,10 +78,11 @@ function CurveApp({ Component }: AppProps) {
8178
let data = await import(`@/locales/${parsedLocale}/messages`)
8279
dynamicActivate(parsedLocale, data)
8380
})()
84-
updateAppLocale(parsedLocale, updateGlobalStoreByKey)
81+
setLocale(parsedLocale)
82+
updateAppLocale(parsedLocale)
8583

8684
// init onboard
87-
const onboardInstance = initOnboard(connectWalletLocales, locale, themeType, networks)
85+
const onboardInstance = initOnboard(connectWalletLocales, locale, theme, networks)
8886
updateWalletStoreByKey('onboard', onboardInstance)
8987

9088
const handleVisibilityChange = () => {
@@ -148,8 +146,8 @@ function CurveApp({ Component }: AppProps) {
148146
)
149147

150148
return (
151-
<div suppressHydrationWarning style={{ ...(themeType === 'chad' && ChadCssProperties) }}>
152-
<ThemeProvider theme={themeType === 'default' ? 'light' : themeType}>
149+
<div suppressHydrationWarning style={{ ...(theme === 'chad' && ChadCssProperties) }}>
150+
<ThemeProvider theme={theme}>
153151
{typeof window === 'undefined' || !appLoaded ? null : (
154152
<HashRouter>
155153
<I18nProvider i18n={i18n}>

apps/dao/src/pages/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ const PageAnalytics = dynamic(() => import('@/components/PageAnalytics/Page'), {
1212
const PageUser = dynamic(() => import('@/components/PageUser/Page'), { ssr: false })
1313
const PageGauge = dynamic(() => import('@/components/PageGauge/Page'), { ssr: false })
1414
const PageVeCrv = dynamic(() => import('@/components/PageVeCrv/Page'), { ssr: false })
15+
const PageDisclaimer = dynamic(() => import('@/components/PageDisclaimer/Page'), { ssr: false })
16+
1517
const App: NextPage = () => {
1618
const SubRoutes = (
1719
<>
1820
<Route path=":network/" element={<PageDao />} />
21+
<Route path=":network/disclaimer" element={<PageDisclaimer />} />
1922
<Route path=":network/proposals" element={<PageDao />} />
2023
<Route path=":network/proposals/:proposalId" element={<PageProposal />} />
2124
<Route path=":network/user/:userAddress" element={<PageUser />} />

0 commit comments

Comments
 (0)