Skip to content

Commit

Permalink
Merge branch 'main' into feat/front-page
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini authored Jan 28, 2025
2 parents 9bc120c + 3a8de90 commit b16a6de
Show file tree
Hide file tree
Showing 276 changed files with 5,385 additions and 2,855 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ This repository is organized as follows:
- `/apps/lend`: Lend [React](https://react.dev/) application.
- `/tests`: DApp tests
- `/packages/curve-ui-kit`: Shared UI kit created using Material UI, mapped as `@ui-kit`
- `/packages/prices-api`: Package for consuming the Prices API, mapped as `@curvefi/prices-api`. Soon to be to separated its own NPM package.

## Development Guide

Expand Down
9 changes: 9 additions & 0 deletions apps/dao/src/file-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="next-images" />

declare module '*.svg' {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
const content: string

export { ReactComponent }
export default content
}
9 changes: 9 additions & 0 deletions apps/lend/src/file-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="next-images" />

declare module '*.svg' {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
const content: string

export { ReactComponent }
export default content
}
9 changes: 9 additions & 0 deletions apps/loan/src/file-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="next-images" />

declare module '*.svg' {
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
const content: string

export { ReactComponent }
export default content
}
8 changes: 4 additions & 4 deletions apps/main/sitemap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MAIN_ROUTE as MAIN_ROUTES } from '@main/constants'
import { MAIN_ROUTE as LOAN_ROUTES } from '@loan/constants'
import { MAIN_ROUTE as LEND_ROUTES } from '@lend/constants'
import { MAIN_ROUTE as DAO_ROUTES } from '@dao/constants'
import { MAIN_ROUTE as MAIN_ROUTES } from '@/dex/constants'
import { MAIN_ROUTE as LOAN_ROUTES } from '@/loan/constants'
import { MAIN_ROUTE as LEND_ROUTES } from '@/lend/constants'
import { MAIN_ROUTE as DAO_ROUTES } from '@/dao/constants'
import { getAppRoot } from 'curve-ui-kit/src/shared/routes'

const ROUTES = {
Expand Down
32 changes: 0 additions & 32 deletions apps/main/src/dao/components/ConnectWallet.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions apps/main/src/dao/components/PageAnalytics/CrvStats/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useEffect } from 'react'
import styled from 'styled-components'

import useStore from '@/dao/store/useStore'
import { formatNumber } from '@ui/utils'
import { t } from '@lingui/macro'

import Box from '@ui/Box'
import MetricsComp, { MetricsColumnData } from '@/dao/components/MetricsComp'
import Tooltip from '@ui/Tooltip'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

const CrvStats: React.FC = () => {
const provider = useStore((state) => state.wallet.getProvider(''))
const provider = useWalletStore((s) => s.provider)
const { veCrvData, getVeCrvData, veCrvFees, veCrvHolders } = useStore((state) => state.analytics)
const { loading: usdRatesLoading, usdRatesMapper } = useStore((state) => state.usdRates)
const crv = usdRatesMapper.crv
Expand Down
14 changes: 9 additions & 5 deletions apps/main/src/dao/components/PageGauges/GaugeVoting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import styled from 'styled-components'
import { useEffect } from 'react'

import useStore from '@/dao/store/useStore'

import CurrentVotes from './CurrentVotes'
import ConnectWallet from '@/dao/components/ConnectWallet'
import { ConnectWalletPrompt } from '@ui-kit/features/connect-wallet'
import { useWalletStore } from '@ui-kit/features/connect-wallet'
import { isLoading } from '@ui/utils'

const GaugeVoting = ({ userAddress }: { userAddress: string | undefined }) => {
const { getUserGaugeVoteWeights, userGaugeVoteWeightsMapper } = useStore((state) => state.user)
const curve = useStore((state) => state.curve)
const provider = useStore((state) => state.wallet.getProvider(''))
const provider = useWalletStore((s) => s.provider)
const connectWallet = useStore((s) => s.updateConnectState)
const connectState = useStore((s) => s.connectState)

useEffect(() => {
if (userAddress && curve && userGaugeVoteWeightsMapper[userAddress.toLowerCase()] === undefined) {
Expand All @@ -19,10 +21,12 @@ const GaugeVoting = ({ userAddress }: { userAddress: string | undefined }) => {

return !provider ? (
<ConnectWrapper>
<ConnectWallet
<ConnectWalletPrompt
description="Connect your wallet to view your current votes and vote on gauges"
connectText="Connect Wallet"
loadingText="Connecting"
connectWallet={() => connectWallet()}
isLoading={isLoading(connectState)}
/>
</ConnectWrapper>
) : (
Expand Down
2 changes: 1 addition & 1 deletion apps/main/src/dao/components/PageGauges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SubNav from '@/dao/components/SubNav'

const Gauges = () => {
const { isMdUp } = useStore((state) => state.layout)
const [{ wallet }] = useConnectWallet()
const { wallet } = useConnectWallet()
const userAddress = wallet?.accounts[0].address

const [navSelection, setNavSelection] = useState('gaugeList')
Expand Down
3 changes: 2 additions & 1 deletion apps/main/src/dao/components/PageProposal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import BackButton from '../BackButton'
import ProposalHeader from './ProposalHeader'
import ProposalInformation from './ProposalInformation'
import { ProposalType } from '@/dao/types/dao.types'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

type ProposalProps = {
routerParams: {
Expand All @@ -34,7 +35,7 @@ type ProposalProps = {

const Proposal: React.FC<ProposalProps> = ({ routerParams: { rProposalId } }) => {
const [voteId, voteType] = rProposalId.split('-') as [string, ProposalType]
const provider = useStore((state) => state.wallet.getProvider(''))
const provider = useWalletStore((s) => s.provider)
const { proposalsLoadingState, getProposal, proposalLoadingState, getUserProposalVote } = useStore(
(state) => state.proposals,
)
Expand Down
3 changes: 2 additions & 1 deletion apps/main/src/dao/components/PageUser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import UserLocksTable from './UserLocksTable'
import UserGaugeVotesTable from './UserGaugeVotesTable'
import SubNav from '@/dao/components/SubNav'
import { VeCrvHolder } from '@/dao/types/dao.types'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

type UserPageProps = {
routerParams: {
Expand All @@ -25,7 +26,7 @@ const UserPage: React.FC<UserPageProps> = ({ routerParams: { rUserAddress } }) =
getVeCrvHolders,
} = useStore((state) => state.analytics)
const { getUserEns, userMapper } = useStore((state) => state.user)
const provider = useStore((state) => state.wallet.getProvider(''))
const provider = useWalletStore((s) => s.provider)
const [activeNavKey, setNavKey] = useState('proposals')

const navItems = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import { t } from '@lingui/macro'

import useStore from '@/dao/store/useStore'

import Button from '@ui/Button'
import Spinner from '@ui/Spinner'
import useStore from '@/dao/store/useStore'

const FormActions = ({
haveSigner,
Expand All @@ -14,12 +12,11 @@ const FormActions = ({
haveSigner: boolean
loading: boolean
}>) => {
const updateConnectWalletStateKeys = useStore((state) => state.wallet.updateConnectWalletStateKeys)

const connectWallet = useStore((s) => s.updateConnectState)
return (
<>
{!haveSigner && !loading ? (
<Button fillWidth size="large" variant="filled" onClick={updateConnectWalletStateKeys}>
<Button fillWidth size="large" variant="filled" onClick={() => connectWallet()}>
{t`Connect Wallet`}
</Button>
) : loading ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import FieldLockedAmt from '@/dao/components/PageVeCrv/components/FieldLockedAmt
import Stepper from '@ui/Stepper'
import TxInfoBar from '@ui/TxInfoBar'
import { CurveApi } from '@/dao/types/dao.types'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

const FormLockCreate = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) => {
const isSubscribed = useRef(false)
Expand All @@ -36,7 +37,7 @@ const FormLockCreate = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) =>
const formValues = useStore((state) => state.lockedCrv.formValues)
const fetchStepApprove = useStore((state) => state.lockedCrv.fetchStepApprove)
const fetchStepCreate = useStore((state) => state.lockedCrv.fetchStepCreate)
const notifyNotification = useStore((state) => state.wallet.notifyNotification)
const notifyNotification = useWalletStore((s) => s.notify)
const setFormValues = useStore((state) => state.lockedCrv.setFormValues)

const [steps, setSteps] = useState<Step[]>([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import FieldLockedAmt from '@/dao/components/PageVeCrv/components/FieldLockedAmt
import Stepper from '@ui/Stepper'
import TxInfoBar from '@ui/TxInfoBar'
import { CurveApi } from '@/dao/types/dao.types'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

const FormLockCrv = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) => {
const isSubscribed = useRef(false)
Expand All @@ -29,7 +30,7 @@ const FormLockCrv = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) => {
const formEstGas = useStore((state) => state.lockedCrv.formEstGas[activeKey] ?? DEFAULT_FORM_EST_GAS)
const formStatus = useStore((state) => state.lockedCrv.formStatus)
const formValues = useStore((state) => state.lockedCrv.formValues)
const notifyNotification = useStore((state) => state.wallet.notifyNotification)
const notifyNotification = useWalletStore((s) => s.notify)
const fetchStepApprove = useStore((state) => state.lockedCrv.fetchStepApprove)
const fetchStepIncreaseCrv = useStore((state) => state.lockedCrv.fetchStepIncreaseCrv)
const setFormValues = useStore((state) => state.lockedCrv.setFormValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import FieldDatePicker from '@/dao/components/PageVeCrv/components/FieldDatePick
import Stepper from '@ui/Stepper'
import TxInfoBar from '@ui/TxInfoBar'
import { CurveApi } from '@/dao/types/dao.types'
import { useWalletStore } from '@ui-kit/features/connect-wallet'

const FormLockDate = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) => {
const isSubscribed = useRef(false)
Expand All @@ -33,7 +34,7 @@ const FormLockDate = ({ curve, rChainId, rFormType, vecrvInfo }: PageVecrv) => {
const formEstGas = useStore((state) => state.lockedCrv.formEstGas[activeKey] ?? DEFAULT_FORM_EST_GAS)
const formStatus = useStore((state) => state.lockedCrv.formStatus)
const formValues = useStore((state) => state.lockedCrv.formValues)
const notifyNotification = useStore((state) => state.wallet.notifyNotification)
const notifyNotification = useWalletStore((s) => s.notify)
const fetchStepIncreaseTime = useStore((state) => state.lockedCrv.fetchStepIncreaseTime)
const setFormValues = useStore((state) => state.lockedCrv.setFormValues)

Expand Down
11 changes: 3 additions & 8 deletions apps/main/src/dao/components/UserBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { t } from '@lingui/macro'
import Box from '@ui/Box'
import Button from '@ui/Button'
import UserInformation from './UserInformation'
import { SnapshotVotingPower, ActiveProposal } from '@/dao/types/dao.types'
import { ActiveProposal, SnapshotVotingPower } from '@/dao/types/dao.types'

type Props = {
children?: React.ReactNode
Expand All @@ -17,12 +17,7 @@ type Props = {
}

const UserBox = ({ className, children, votingPower, snapshotVotingPower, activeProposal, row }: Props) => {
const [{ wallet }, connect] = useConnectWallet()

const handleConnectWallet = async () => {
await connect()
}

const { wallet, connect } = useConnectWallet()
return (
<Wrapper className={className}>
{wallet ? (
Expand All @@ -37,7 +32,7 @@ const UserBox = ({ className, children, votingPower, snapshotVotingPower, active
) : (
<ConnectMessage>
<p>{t`Please connect a wallet to see user information.`}</p>
<StyledButton variant="outlined" onClick={handleConnectWallet}>
<StyledButton variant="outlined" onClick={() => connect()}>
{t`Connect Wallet`}
</StyledButton>
</ConnectMessage>
Expand Down
8 changes: 1 addition & 7 deletions apps/main/src/dao/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DAO_ROUTES } from '@ui-kit/shared/routes'
export { CONNECT_STAGE } from '@ui/utils/utilsConnectState'

export const NETWORK_TOKEN = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'

Expand All @@ -10,13 +11,6 @@ export const ROUTE = {
PAGE_404: '/404',
} as const

export const CONNECT_STAGE = {
CONNECT_API: 'api',
CONNECT_WALLET: 'connect-wallet',
DISCONNECT_WALLET: 'disconnect-wallet',
SWITCH_NETWORK: 'switch-network',
} as const

export const REFRESH_INTERVAL = {
'3s': 3000,
'1m': 60000,
Expand Down
Loading

0 comments on commit b16a6de

Please sign in to comment.