Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const esRules = {
'no-return-await': 'error',
'default-case': 'error',
'no-fallthrough': 'error',

'prettier/prettier': ['error', { usePrettierrc: true }],
}

Expand All @@ -31,7 +32,7 @@ const tsRules = {
'no-shadow': 'off',
'no-unused-vars': 'off',
'react/jsx-no-undef': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-redeclare': ['error'],
'@typescript-eslint/adjacent-overload-signatures': 'error',
Expand All @@ -44,7 +45,6 @@ const tsRules = {
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
Expand Down Expand Up @@ -89,6 +89,13 @@ const settings = {

module.exports = {
overrides: [
{
files: ['next.config.mjs', '.eslintrc.cjs'],
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
},
{
env,
files: ['**/*.js', '**/*.jsx', '**/*.json'],
Expand Down
21 changes: 21 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import moment from 'moment'

declare module 'moment-duration-format'

declare module 'moment' {
interface Duration {
/**
* Format a duration like moment-duration-format does
* @param template e.g. 'h [h] m [min]'
* @param options trim: 'all'|'left'|'right', minValue, etc.
*/
format(
template?: string,
options?: {
trim?: 'all' | 'left' | 'right'
minValue?: number
},
): string
}
}
34 changes: 0 additions & 34 deletions modules/appProviderWeb3/appProviderWeb3.tsx

This file was deleted.

1 change: 0 additions & 1 deletion modules/appProviderWeb3/index.ts

This file was deleted.

117 changes: 0 additions & 117 deletions modules/appWagmiConfig/appWagmiConfig.tsx

This file was deleted.

1 change: 0 additions & 1 deletion modules/appWagmiConfig/index.tsx

This file was deleted.

12 changes: 6 additions & 6 deletions modules/blockChain/chains.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CHAINS } from '@lido-sdk/constants'
export enum CHAINS {
Mainnet = 1,
Holesky = 17000,
Hoodi = 560048,
Goerli = 5,
}

export const ChainNames = {
[CHAINS.Mainnet]: 'Mainnet',
[CHAINS.Ropsten]: 'Ropsten',
[CHAINS.Rinkeby]: 'Rinkeby',
[CHAINS.Goerli]: 'Goerli',
[CHAINS.Kovan]: 'Kovan',
[CHAINS.Kintsugi]: 'Kintsugi',
[CHAINS.Holesky]: 'Holesky',
[CHAINS.Hoodi]: 'Hoodi',
} as const
Expand Down
8 changes: 6 additions & 2 deletions modules/blockChain/contractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHAINS } from '@lido-sdk/constants'
import { CHAINS } from './chains'
import type { ChainAddressMap, ChainAddressListMap } from './types'

export const NodeOperatorsRegistry: ChainAddressMap = {
Expand Down Expand Up @@ -158,7 +158,7 @@ export const AllowedTokensRegistry: ChainAddressMap = {

export const SandboxStablesAllowedRecipientRegistry: ChainAddressMap = {
[CHAINS.Holesky]: '0xF8a63a36B954D72de197097377aa00C238c653Cf',
[CHAINS.Hoodi]: '0xd57FF1ce54F572F4E8DaF0cB7038F1Bd6049cAa8',
[CHAINS.Hoodi]: '0xdf53b1cd4CFE43b6CdA3640Be0e4f1a45126ec61',
}

export const RccStethAllowedRecipientsRegistry: ChainAddressMap = {
Expand Down Expand Up @@ -279,3 +279,7 @@ export const ValidatorsExitBusOracle: ChainAddressMap = {
[CHAINS.Mainnet]: '0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e',
[CHAINS.Hoodi]: '0x8664d394c2b3278f26a1b44b967aef99707eeab2',
}

export const SandboxStethAllowedRecipientsRegistry: ChainAddressMap = {
[CHAINS.Hoodi]: '0x7E33f2192c2cEC339493B9193110BC0510d6CBD2',
}
21 changes: 21 additions & 0 deletions modules/blockChain/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,24 @@ export const ContractCuratedExitRequestHashesSubmit = createContractHelpers({
factory: TypeChain.SubmitExitRequestHashesAbi__factory,
address: EvmAddressesByType[MotionType.CuratedExitRequestHashesSubmit],
})

export const ContractSandboxStethAllowedRecipientsRegistry =
createContractHelpers({
factory: TypeChain.RegistryWithLimitsAbi__factory,
address: CONTRACT_ADDRESSES.SandboxStethAllowedRecipientsRegistry,
})

export const ContractEvmSandboxStEthTopUp = createContractHelpers({
factory: TypeChain.TopUpAllowedRecipientsAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStEthTopUp],
})

export const ContractEvmSandboxStEthAdd = createContractHelpers({
factory: TypeChain.AddAllowedRecipientAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStEthAdd],
})

export const ContractEvmSandboxStEthRemove = createContractHelpers({
factory: TypeChain.RemoveAllowedRecipientAbi__factory,
address: EvmAddressesByType[MotionType.SandboxStEthRemove],
})
16 changes: 0 additions & 16 deletions modules/blockChain/hooks/useCheckWalletConnect.ts

This file was deleted.

9 changes: 5 additions & 4 deletions modules/blockChain/hooks/useErrorMessage.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useMemo } from 'react'
import { useConnect } from 'wagmi'
import { useConfig } from 'modules/config/hooks/useConfig'
import { useSupportedChains, useConnectorError } from 'reef-knot/web3-react'

import { getChainName } from 'modules/blockChain/chains'
import { useIsChainSupported } from './useIsChainSupported'

export function useErrorMessage() {
const error = useConnectorError()
const { isUnsupported } = useSupportedChains()
const { error } = useConnect()
const isChainSupported = useIsChainSupported()
const { supportedChainIds } = useConfig()

const chains = useMemo(() => {
const networksList = supportedChainIds.map(chainId => getChainName(chainId))
return networksList.join(' / ')
}, [supportedChainIds])

if (isUnsupported) {
if (!isChainSupported) {
return `Unsupported chain. Please switch to ${chains} in your wallet.`
}

Expand Down
12 changes: 12 additions & 0 deletions modules/blockChain/hooks/useEtherscanOpener.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useCallback } from 'react'
import { useWeb3 } from 'modules/blockChain/hooks/useWeb3'
import { openWindow } from 'modules/shared/utils/openWindow'
import { EtherscanEntity, getEtherscanLink } from '../utils/etherscan'

export function useEtherscanOpener(value: string, entity: EtherscanEntity) {
const { chainId } = useWeb3()
return useCallback(() => {
const link = getEtherscanLink(chainId, value, entity)
openWindow(link)
}, [chainId, entity, value])
}
12 changes: 12 additions & 0 deletions modules/blockChain/hooks/useIsChainSupported.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMemo } from 'react'
import { useAccount } from 'wagmi'
import { useConfig } from 'modules/config/hooks/useConfig'

export const useIsChainSupported = () => {
const { chainId: accountChainId } = useAccount()
const { supportedChainIds } = useConfig()

return useMemo(() => {
return accountChainId ? supportedChainIds.includes(accountChainId) : true
}, [supportedChainIds, accountChainId])
}
37 changes: 13 additions & 24 deletions modules/blockChain/hooks/useIsContract.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
import { useEthereumSWR } from '@lido-sdk/react'
import { Hex } from 'viem'
import { useAccount, useBytecode } from 'wagmi'

export const useIsContract = (
account?: string | null,
): { loading: boolean; isContract: boolean } => {
// eth_getCode returns hex string of bytecode at address
// for accounts it's "0x"
// for contract it's potentially very long hex (can't be safely&quickly parsed)
const result = useEthereumSWR({
shouldFetch: !!account,
method: 'getCode',
params: [account, 'latest'],
config: {
// this is very stable request
refreshWhenHidden: false,
revalidateOnFocus: false,
revalidateIfStale: false,
revalidateOnMount: true,
revalidateOnReconnect: false,
refreshInterval: 0,
const toBool = (data: Hex | undefined) => Boolean(data && data != '0x')

export const useIsContract = () => {
const { address, chainId } = useAccount()

return useBytecode({
address,
chainId,
query: {
enabled: !!address,
select: toBool,
},
})

return {
loading: result.loading,
isContract: result.data ? result.data !== '0x' : false,
}
}
Loading
Loading