Skip to content

Commit

Permalink
fix: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Sep 24, 2024
1 parent a97836b commit 210eaa9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
14 changes: 3 additions & 11 deletions consts/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export enum CHAINS {
export enum LIDO_MULTICHAIN_CHAINS {
'zkSync Era' = 324,
Optimism = 10,
OptimismSepolia = 11155420,
Arbitrum = 42161,
'Polygon PoS' = 137,
Base = 8453,
Expand All @@ -27,16 +26,9 @@ export const SDK_LEGACY_SUPPORTED_CHAINS = [
];

// TODO: move to @lidofinance/lido-ethereum-sdk package
export const SDK_SUPPORTED_MULTICHAIN_CHAINS = [
LIDO_MULTICHAIN_CHAINS.OptimismSepolia,
];
export const SDK_SUPPORTED_MULTICHAIN_CHAINS = [CHAINS.OptimismSepolia];

// TODO: move to @lidofinance/lido-ethereum-sdk package
export const isSDKSupportedL2Chain = (
chainId: CHAINS | LIDO_MULTICHAIN_CHAINS,
) => {
return (
SDK_SUPPORTED_MULTICHAIN_CHAINS.indexOf(chainId as LIDO_MULTICHAIN_CHAINS) >
-1
);
export const isSDKSupportedL2Chain = (chainId: CHAINS) => {
return SDK_SUPPORTED_MULTICHAIN_CHAINS.indexOf(chainId) > -1;
};
7 changes: 5 additions & 2 deletions features/wsteth/wrap/hooks/use-approve-gas-limit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import { config } from 'config';
import { WSTETH_APPROVE_GAS_LIMIT } from 'consts/tx';
import { SDK_LEGACY_SUPPORTED_CHAINS } from 'consts/chains';
import { SDK_LEGACY_SUPPORTED_CHAINS, CHAINS } from 'consts/chains';
import { STRATEGY_IMMUTABLE } from 'consts/swr-strategies';

export const useApproveGasLimit = () => {
Expand All @@ -19,7 +19,10 @@ export const useApproveGasLimit = () => {
const { data } = useLidoSWR(
['swr:approve-wrap-gas-limit', chainId],
async (_key, chainId) => {
if (!chainId || SDK_LEGACY_SUPPORTED_CHAINS.indexOf(chainId) < 0) {
if (
!chainId ||
SDK_LEGACY_SUPPORTED_CHAINS.indexOf(chainId as CHAINS) < 0
) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion pages/api/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CHAINS } from '@lido-sdk/constants';
import { wrapRequest as wrapNextRequest } from '@lidofinance/next-api-wrapper';
import { trackedFetchRpcFactory } from '@lidofinance/api-rpc';

import { config, secretConfig } from 'config';
import { API_ROUTES } from 'consts/api';
import { CHAINS } from 'consts/chains';
import { METRICS_PREFIX } from 'consts/metrics';
import {
rateLimit,
Expand Down
6 changes: 3 additions & 3 deletions shared/hooks/use-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import type { GetBalanceData } from 'wagmi/query';

import { config } from 'config';
import { isSDKSupportedL2Chain } from 'consts/chains';
import { isSDKSupportedL2Chain, CHAINS } from 'consts/chains';

const nativeToBN = (data: bigint) => BigNumber.from(data.toString());

Expand Down Expand Up @@ -263,7 +263,7 @@ export const useStethBalance = ({

staleTime: Infinity,
queryFn: async () =>
isSDKSupportedL2Chain(core.chainId)
isSDKSupportedL2Chain(core.chainId as CHAINS)
? l2Steth.getContract()
: steth.getContract(),
});
Expand Down Expand Up @@ -291,7 +291,7 @@ export const useWstethBalance = ({
enabled: !!mergedAccount,
staleTime: Infinity,
queryFn: async () =>
isSDKSupportedL2Chain(core.chainId)
isSDKSupportedL2Chain(core.chainId as CHAINS)
? l2Wsteth.getContract()
: wsteth.getContract(),
});
Expand Down
3 changes: 2 additions & 1 deletion shared/hooks/use-mainnet-static-rpc-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from 'react';
import { CHAINS as SDK_CHAINS } from '@lido-sdk/constants';
import { getStaticRpcBatchProvider } from '@lido-sdk/providers';
import { StaticJsonRpcBatchProvider } from '@lidofinance/eth-providers';

Expand All @@ -10,7 +11,7 @@ export const useMainnetStaticRpcProvider = (): StaticJsonRpcBatchProvider => {
const getRpcUrl = useGetRpcUrlByChainId();
return useMemo(() => {
return getStaticRpcBatchProvider(
CHAINS.Mainnet,
CHAINS.Mainnet as unknown as SDK_CHAINS,
getRpcUrl(CHAINS.Mainnet),
config.PROVIDER_POLLING_INTERVAL,
);
Expand Down
2 changes: 0 additions & 2 deletions utils/getNFTUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const NFT_URL_PREFIX_BY_NETWORK: {
`https://holesky.etherscan.io/nft/${contract}/${nftId}`,
[CHAINS.Sepolia]: (nftId, contract) =>
`https://sepolia.etherscan.io/nft/${contract}/${nftId}`,
[CHAINS.OptimismSepolia]: (nftId, contract) =>
`https://sepolia-optimistic.etherscan.io/nft/${contract}/${nftId}`,
};

export const getNFTUrl = (tokenId: string, chainId?: CHAINS) => {
Expand Down

0 comments on commit 210eaa9

Please sign in to comment.