-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from lidofinance/develop
Develop to main
- Loading branch information
Showing
105 changed files
with
4,912 additions
and
3,709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import getConfig from 'next/config'; | ||
import dynamics from './dynamics'; | ||
|
||
const { serverRuntimeConfig } = getConfig(); | ||
const { basePath = '' } = serverRuntimeConfig; | ||
|
||
export const BASE_PATH_ASSET = dynamics.ipfsMode ? '.' : basePath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
import { useCallback } from 'react'; | ||
import invariant from 'tiny-invariant'; | ||
import { useSDK } from '@lido-sdk/react'; | ||
|
||
import { useClientConfig } from 'providers/client-config'; | ||
import { CHAINS } from 'utils/chains'; | ||
|
||
import dynamics from './dynamics'; | ||
|
||
export const getBackendRPCPath = (chainId: string | number): string => { | ||
const BASE_URL = typeof window === 'undefined' ? '' : window.location.origin; | ||
return `${BASE_URL}/api/rpc?chainId=${chainId}`; | ||
}; | ||
|
||
export const backendRPC = { | ||
[CHAINS.Mainnet]: getBackendRPCPath(CHAINS.Mainnet), | ||
[CHAINS.Goerli]: getBackendRPCPath(CHAINS.Goerli), | ||
[CHAINS.Holesky]: getBackendRPCPath(CHAINS.Holesky), | ||
export const useGetRpcUrlByChainId = () => { | ||
const clientConfig = useClientConfig(); | ||
|
||
return useCallback( | ||
(chainId: CHAINS) => { | ||
// Needs this condition 'cause in 'providers/web3.tsx' we add `wagmiChains.polygonMumbai` to supportedChains | ||
// so, here chainId = 80001 is arriving which to raises an invariant | ||
// chainId = 1 we need anytime! | ||
if ( | ||
chainId !== CHAINS.Mainnet && | ||
!clientConfig.supportedChainIds.includes(chainId) | ||
) { | ||
// Has no effect on functionality. Just a fix. | ||
// Return empty string as stub | ||
// (see: 'providers/web3.tsx' --> jsonRpcBatchProvider --> getStaticRpcBatchProvider) | ||
return ''; | ||
} | ||
|
||
if (dynamics.ipfsMode) { | ||
const rpc = | ||
clientConfig.savedClientConfig.rpcUrls[chainId] || | ||
clientConfig.prefillUnsafeElRpcUrls[chainId]?.[0]; | ||
|
||
invariant(rpc, '[useGetRpcUrlByChainId] RPC is required!'); | ||
return rpc; | ||
} else { | ||
return ( | ||
clientConfig.savedClientConfig.rpcUrls[chainId] || | ||
getBackendRPCPath(chainId) | ||
); | ||
} | ||
}, | ||
[clientConfig], | ||
); | ||
}; | ||
|
||
export const useRpcUrl = () => { | ||
const { chainId } = useSDK(); | ||
const getRpcUrlByChainId = useGetRpcUrlByChainId(); | ||
return getRpcUrlByChainId(chainId as number); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { CHAINS } from 'utils/chains'; | ||
|
||
export type EnvConfigRaw = { | ||
defaultChain: string | number; | ||
supportedChains: number[]; | ||
prefillUnsafeElRpcUrls1: string[]; | ||
prefillUnsafeElRpcUrls5: string[]; | ||
prefillUnsafeElRpcUrls17000: string[]; | ||
ipfsMode: boolean; | ||
walletconnectProjectId: string; | ||
}; | ||
|
||
export type EnvConfigParsed = { | ||
defaultChain: number; | ||
supportedChainIds: number[]; | ||
prefillUnsafeElRpcUrls: { | ||
[CHAINS.Mainnet]: string[]; | ||
[CHAINS.Goerli]: string[]; | ||
[CHAINS.Holesky]: string[]; | ||
}; | ||
ipfsMode: boolean; | ||
walletconnectProjectId: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// TODO: path + basePath | ||
export const HOME_PATH = '/'; | ||
export const WRAP_PATH = '/wrap'; | ||
export const WRAP_UNWRAP_PATH = '/wrap/unwrap'; | ||
export const WITHDRAWALS_PATH = '/withdrawals'; | ||
export const WITHDRAWALS_REQUEST_PATH = '/withdrawals/request'; | ||
export const WITHDRAWALS_CLAIM_PATH = '/withdrawals/claim'; | ||
export const REWARDS_PATH = '/rewards'; | ||
export const SETTINGS_PATH = '/settings'; | ||
export const REFERRAL_PATH = '/referral'; | ||
|
||
export const getPathWithoutFirstSlash = (path: string): string => { | ||
if (path.length === 0 || path[0] !== '/') return path; | ||
|
||
return path.slice(1, path.length); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { FC } from 'react'; | ||
import Head from 'next/head'; | ||
|
||
import { Layout } from 'shared/components'; | ||
import NoSSRWrapper from 'shared/components/no-ssr-wrapper'; | ||
import { useWeb3Key } from 'shared/hooks/useWeb3Key'; | ||
|
||
import { Wallet } from './wallet/wallet'; | ||
import { StakeForm } from './stake-form/stake-form'; | ||
import { StakeFaq } from './stake-faq/stake-faq'; | ||
import { LidoStats } from './lido-stats/lido-stats'; | ||
|
||
const HomePageRegular: FC = () => { | ||
const key = useWeb3Key(); | ||
|
||
return ( | ||
<> | ||
<Layout | ||
title="Stake Ether" | ||
subtitle="Stake ETH and receive stETH while staking." | ||
> | ||
<Head> | ||
<title>Stake with Lido | Lido</title> | ||
</Head> | ||
|
||
<NoSSRWrapper> | ||
<Wallet key={'wallet' + key} /> | ||
<StakeForm key={'form' + key} /> | ||
</NoSSRWrapper> | ||
<LidoStats /> | ||
<StakeFaq /> | ||
</Layout> | ||
</> | ||
); | ||
}; | ||
|
||
export default HomePageRegular; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { StakeForm } from './stake-form/stake-form'; | ||
export { OneinchInfo } from './oneinch-info/oneinch-info'; | ||
export { OneInchInfo } from './one-inch-info/one-inch-info'; | ||
export { LidoStats } from './lido-stats/lido-stats'; | ||
export { Wallet } from './wallet/wallet'; | ||
export { StakeFaq } from './stake-faq/stake-faq'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FC, memo, PropsWithChildren, ReactNode } from 'react'; | ||
import { DataTableRow } from '@lidofinance/lido-ui'; | ||
import { DATA_UNAVAILABLE } from 'config'; | ||
|
||
type LidoStatsItemProps = { | ||
show: boolean; | ||
loading: boolean; | ||
dataTestId: string; | ||
title: ReactNode; | ||
highlight?: boolean | undefined; | ||
}; | ||
|
||
export const LidoStatsItem: FC<PropsWithChildren<LidoStatsItemProps>> = memo( | ||
(props) => { | ||
const { show, loading, dataTestId, title, children, highlight } = props; | ||
|
||
if (!show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<DataTableRow | ||
title={title} | ||
loading={loading} | ||
data-testid={dataTestId} | ||
highlight={highlight} | ||
> | ||
{children || DATA_UNAVAILABLE} | ||
</DataTableRow> | ||
); | ||
}, | ||
); |
Oops, something went wrong.