From dd0e402ed12ce6d78d50b2f20f03c42a76416985 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Thu, 31 Oct 2024 14:05:42 +0300 Subject: [PATCH 1/4] refactor(wrap/unwrap): preparing FAQ for other networks --- .../shared/wrap-faq/ethereum-faq/faq.tsx | 21 ++++++++ .../list/do-i-get-my-staking-rewards.tsx | 0 .../do-i-need-to-claim-my-staking-rewards.tsx | 0 .../list/do_i_need_to_unwrap_my_wsteth.tsx | 0 .../list/how-can-i-get-wsteth.tsx | 0 .../list/how-can-i-use-wsteth.tsx | 0 .../how-could-i-unwrap-wsteth-to-steth.tsx | 0 .../wrap-faq/{ => ethereum-faq}/list/index.ts | 0 .../list/what-is-wsteth.tsx | 0 .../shared/wrap-faq/optimism-faq/faq.tsx | 23 ++++++++ ...an-i-stake-my-eth-directly-on-optimism.tsx | 0 ...-if-i-wrap-steth-to-wsteth-on-optimism.tsx | 0 ...wards-with-steth-or-wsteth-on-optimism.tsx | 0 .../list}/how-can-i-get-wsteth.tsx | 0 .../how-can-i-use-wsteth-on-optimism.tsx | 0 ...nwrap-wsteth-back-to-steth-on-optimism.tsx | 0 .../list}/index.ts | 0 ...n-ethereum-can-i-do-that-from-optimism.tsx | 0 .../list}/what-is-wsteth.tsx | 0 features/wsteth/shared/wrap-faq/wrap-faq.tsx | 52 +++++-------------- 20 files changed, 56 insertions(+), 40 deletions(-) create mode 100644 features/wsteth/shared/wrap-faq/ethereum-faq/faq.tsx rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/do-i-get-my-staking-rewards.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/do-i-need-to-claim-my-staking-rewards.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/do_i_need_to_unwrap_my_wsteth.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/how-can-i-get-wsteth.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/how-can-i-use-wsteth.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/how-could-i-unwrap-wsteth-to-steth.tsx (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/index.ts (100%) rename features/wsteth/shared/wrap-faq/{ => ethereum-faq}/list/what-is-wsteth.tsx (100%) create mode 100644 features/wsteth/shared/wrap-faq/optimism-faq/faq.tsx rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/can-i-stake-my-eth-directly-on-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/do-i-need-to-claim-my-staking-rewards-if-i-wrap-steth-to-wsteth-on-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/do-i-still-get-staking-rewards-with-steth-or-wsteth-on-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/how-can-i-get-wsteth.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/how-can-i-use-wsteth-on-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/how-could-i-unwrap-wsteth-back-to-steth-on-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/index.ts (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/what-happens-if-i-want-to-unstake-eth-on-ethereum-can-i-do-that-from-optimism.tsx (100%) rename features/wsteth/shared/wrap-faq/{optimism-list => optimism-faq/list}/what-is-wsteth.tsx (100%) diff --git a/features/wsteth/shared/wrap-faq/ethereum-faq/faq.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/faq.tsx new file mode 100644 index 000000000..f0ad570a8 --- /dev/null +++ b/features/wsteth/shared/wrap-faq/ethereum-faq/faq.tsx @@ -0,0 +1,21 @@ +import { + WhatIsWsteth, + HowCanIGetWsteth, + HowCanIUseWsteth, + DoIGetMyStakingRewards, + DoINeedToClaimMyStakingRewards, + HowCouldIUnwrapWstethToSteth, + DoINeedToUnwrapMyWsteth, +} from './list'; + +export const EthereumFAQ = () => ( + <> + + + + + + + + +); diff --git a/features/wsteth/shared/wrap-faq/list/do-i-get-my-staking-rewards.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/do-i-get-my-staking-rewards.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/do-i-get-my-staking-rewards.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/do-i-get-my-staking-rewards.tsx diff --git a/features/wsteth/shared/wrap-faq/list/do-i-need-to-claim-my-staking-rewards.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/do-i-need-to-claim-my-staking-rewards.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/do-i-need-to-claim-my-staking-rewards.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/do-i-need-to-claim-my-staking-rewards.tsx diff --git a/features/wsteth/shared/wrap-faq/list/do_i_need_to_unwrap_my_wsteth.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/do_i_need_to_unwrap_my_wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/do_i_need_to_unwrap_my_wsteth.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/do_i_need_to_unwrap_my_wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/list/how-can-i-get-wsteth.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/how-can-i-get-wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/how-can-i-get-wsteth.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/how-can-i-get-wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/list/how-can-i-use-wsteth.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/how-can-i-use-wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/how-can-i-use-wsteth.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/how-can-i-use-wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/list/how-could-i-unwrap-wsteth-to-steth.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/how-could-i-unwrap-wsteth-to-steth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/how-could-i-unwrap-wsteth-to-steth.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/how-could-i-unwrap-wsteth-to-steth.tsx diff --git a/features/wsteth/shared/wrap-faq/list/index.ts b/features/wsteth/shared/wrap-faq/ethereum-faq/list/index.ts similarity index 100% rename from features/wsteth/shared/wrap-faq/list/index.ts rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/index.ts diff --git a/features/wsteth/shared/wrap-faq/list/what-is-wsteth.tsx b/features/wsteth/shared/wrap-faq/ethereum-faq/list/what-is-wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/list/what-is-wsteth.tsx rename to features/wsteth/shared/wrap-faq/ethereum-faq/list/what-is-wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-faq/faq.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/faq.tsx new file mode 100644 index 000000000..12efac87a --- /dev/null +++ b/features/wsteth/shared/wrap-faq/optimism-faq/faq.tsx @@ -0,0 +1,23 @@ +import { + WhatIsWstethOnOptimism, + HowCanIGetWstethOnOptimism, + HowCanIUseWstethOnOptimism, + CanIStakeMyETHDirectlyOnOptimism, + DoIStillGetStakingRewardsWithStETHOrWstETHOnOptimism, + DoINeedToClaimMyStakingRewardsIfIWrapStETHToWstETHOnOptimism, + HowCouldIUnwrapWstETHBackToStETHOnOptimism, + WhatHappensIfIWantToUnstakeETHOnEthereumCanIDoThatFromOptimism, +} from './list'; + +export const OptimismFAQ = () => ( + <> + + + + + + + + + +); diff --git a/features/wsteth/shared/wrap-faq/optimism-list/can-i-stake-my-eth-directly-on-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/can-i-stake-my-eth-directly-on-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/can-i-stake-my-eth-directly-on-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/can-i-stake-my-eth-directly-on-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/do-i-need-to-claim-my-staking-rewards-if-i-wrap-steth-to-wsteth-on-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/do-i-need-to-claim-my-staking-rewards-if-i-wrap-steth-to-wsteth-on-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/do-i-need-to-claim-my-staking-rewards-if-i-wrap-steth-to-wsteth-on-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/do-i-need-to-claim-my-staking-rewards-if-i-wrap-steth-to-wsteth-on-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/do-i-still-get-staking-rewards-with-steth-or-wsteth-on-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/do-i-still-get-staking-rewards-with-steth-or-wsteth-on-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/do-i-still-get-staking-rewards-with-steth-or-wsteth-on-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/do-i-still-get-staking-rewards-with-steth-or-wsteth-on-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/how-can-i-get-wsteth.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/how-can-i-get-wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/how-can-i-get-wsteth.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/how-can-i-get-wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/how-can-i-use-wsteth-on-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/how-can-i-use-wsteth-on-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/how-can-i-use-wsteth-on-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/how-can-i-use-wsteth-on-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/how-could-i-unwrap-wsteth-back-to-steth-on-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/how-could-i-unwrap-wsteth-back-to-steth-on-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/how-could-i-unwrap-wsteth-back-to-steth-on-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/how-could-i-unwrap-wsteth-back-to-steth-on-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/index.ts b/features/wsteth/shared/wrap-faq/optimism-faq/list/index.ts similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/index.ts rename to features/wsteth/shared/wrap-faq/optimism-faq/list/index.ts diff --git a/features/wsteth/shared/wrap-faq/optimism-list/what-happens-if-i-want-to-unstake-eth-on-ethereum-can-i-do-that-from-optimism.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/what-happens-if-i-want-to-unstake-eth-on-ethereum-can-i-do-that-from-optimism.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/what-happens-if-i-want-to-unstake-eth-on-ethereum-can-i-do-that-from-optimism.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/what-happens-if-i-want-to-unstake-eth-on-ethereum-can-i-do-that-from-optimism.tsx diff --git a/features/wsteth/shared/wrap-faq/optimism-list/what-is-wsteth.tsx b/features/wsteth/shared/wrap-faq/optimism-faq/list/what-is-wsteth.tsx similarity index 100% rename from features/wsteth/shared/wrap-faq/optimism-list/what-is-wsteth.tsx rename to features/wsteth/shared/wrap-faq/optimism-faq/list/what-is-wsteth.tsx diff --git a/features/wsteth/shared/wrap-faq/wrap-faq.tsx b/features/wsteth/shared/wrap-faq/wrap-faq.tsx index 347a390b3..3aa677b5a 100644 --- a/features/wsteth/shared/wrap-faq/wrap-faq.tsx +++ b/features/wsteth/shared/wrap-faq/wrap-faq.tsx @@ -1,56 +1,28 @@ +import React from 'react'; import { Section } from 'shared/components'; import { useMatomoEventHandle } from 'shared/hooks'; import { useDappStatus, DAPP_CHAIN_TYPE } from 'modules/web3'; -import { - WhatIsWsteth, - HowCanIGetWsteth, - HowCanIUseWsteth, - DoIGetMyStakingRewards, - DoINeedToClaimMyStakingRewards, - HowCouldIUnwrapWstethToSteth, - DoINeedToUnwrapMyWsteth, -} from './list'; +import { EthereumFAQ } from './ethereum-faq/faq'; +import { OptimismFAQ } from './optimism-faq/faq'; -import { - WhatIsWstethOnOptimism, - HowCanIGetWstethOnOptimism, - HowCanIUseWstethOnOptimism, - CanIStakeMyETHDirectlyOnOptimism, - DoIStillGetStakingRewardsWithStETHOrWstETHOnOptimism, - DoINeedToClaimMyStakingRewardsIfIWrapStETHToWstETHOnOptimism, - HowCouldIUnwrapWstETHBackToStETHOnOptimism, - WhatHappensIfIWantToUnstakeETHOnEthereumCanIDoThatFromOptimism, -} from './optimism-list'; +export const faqComponentsMap = new Map([ + [DAPP_CHAIN_TYPE.Ethereum, EthereumFAQ], + [DAPP_CHAIN_TYPE.Optimism, OptimismFAQ], + // FAQ for other networks +]); export const WrapFaq = () => { const { isWalletConnected, chainType } = useDappStatus(); const onClickHandler = useMatomoEventHandle(); - if (isWalletConnected && chainType === DAPP_CHAIN_TYPE.Optimism) { - return ( -
- - - - - - - - -
- ); - } + const faqComponent = !isWalletConnected + ? EthereumFAQ + : faqComponentsMap.get(chainType) || EthereumFAQ; return (
- - - - - - - + {React.createElement(faqComponent, { key: chainType })}
); }; From 759ff003593a10bda54321ecd4cd1a71bb82b7f2 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Thu, 31 Oct 2024 16:19:42 +0300 Subject: [PATCH 2/4] refactor(etherscan): helpers --- features/rewards/components/IndexerLink.tsx | 2 +- features/stake/lido-stats/lido-stats.tsx | 9 ++--- .../tx-link-etherscan/tx-link-etherscan.tsx | 8 ++-- shared/wallet/wallet-modal/wallet-modal.tsx | 12 ++++-- utils/etherscan.ts | 38 +++++++++++++++++++ utils/get-etherscan-address-link.ts | 26 ------------- utils/get-etherscan-tx-link.ts | 18 --------- 7 files changed, 55 insertions(+), 58 deletions(-) create mode 100644 utils/etherscan.ts delete mode 100644 utils/get-etherscan-address-link.ts delete mode 100644 utils/get-etherscan-tx-link.ts diff --git a/features/rewards/components/IndexerLink.tsx b/features/rewards/components/IndexerLink.tsx index b2a064ab7..2c7fac089 100644 --- a/features/rewards/components/IndexerLink.tsx +++ b/features/rewards/components/IndexerLink.tsx @@ -1,5 +1,5 @@ import { Box, External as ExternalLinkIcon } from '@lidofinance/lido-ui'; -import { getEtherscanTxLink } from 'utils/get-etherscan-tx-link'; +import { getEtherscanTxLink } from 'utils/etherscan'; import { config } from 'config'; diff --git a/features/stake/lido-stats/lido-stats.tsx b/features/stake/lido-stats/lido-stats.tsx index f0deebd64..9f8e8f6aa 100644 --- a/features/stake/lido-stats/lido-stats.tsx +++ b/features/stake/lido-stats/lido-stats.tsx @@ -1,17 +1,16 @@ import { FC, memo, useMemo } from 'react'; -import { getEtherscanTokenLink } from '@lido-sdk/helpers'; import { useSDK } from '@lido-sdk/react'; import { getTokenAddress, TOKENS } from '@lido-sdk/constants'; import { Block, DataTable, Question, Tooltip } from '@lidofinance/lido-ui'; -import { Section, MatomoLink } from 'shared/components'; -import { useLidoApr, useLidoStats } from 'shared/hooks'; - import { config } from 'config'; - import { LIDO_APR_TOOLTIP_TEXT, DATA_UNAVAILABLE } from 'consts/text'; import { MATOMO_CLICK_EVENTS_TYPES } from 'consts/matomo-click-events'; +import { getEtherscanTokenLink } from 'utils/etherscan'; + +import { Section, MatomoLink } from 'shared/components'; +import { useLidoApr, useLidoStats } from 'shared/hooks'; import { FlexCenterVertical } from './styles'; import { LidoStatsItem } from './lido-stats-item'; diff --git a/shared/components/tx-link-etherscan/tx-link-etherscan.tsx b/shared/components/tx-link-etherscan/tx-link-etherscan.tsx index 19c3220f6..1ddd22dcd 100644 --- a/shared/components/tx-link-etherscan/tx-link-etherscan.tsx +++ b/shared/components/tx-link-etherscan/tx-link-etherscan.tsx @@ -1,7 +1,7 @@ import { Link } from '@lidofinance/lido-ui'; -import { CHAINS } from 'consts/chains'; -import { getEtherscanTxLink } from 'utils/get-etherscan-tx-link'; +import { config } from 'config'; +import { getEtherscanTxLink } from 'utils/etherscan'; import { useDappStatus } from 'modules/web3'; type TxLinkEtherscanProps = { @@ -12,14 +12,14 @@ type TxLinkEtherscanProps = { export const TxLinkEtherscan = (props: TxLinkEtherscanProps) => { const { txHash, text = 'View on Etherscan', onClick } = props; - const { chainId } = useDappStatus(); + const { walletChainId } = useDappStatus(); if (!txHash) return null; return ( {text} diff --git a/shared/wallet/wallet-modal/wallet-modal.tsx b/shared/wallet/wallet-modal/wallet-modal.tsx index c1675e753..6af86eba5 100644 --- a/shared/wallet/wallet-modal/wallet-modal.tsx +++ b/shared/wallet/wallet-modal/wallet-modal.tsx @@ -10,9 +10,10 @@ import { import { openWindow } from '@lido-sdk/helpers'; import { useConnectorInfo, useDisconnect } from 'reef-knot/core-react'; +import { config } from 'config'; import type { ModalComponentType } from 'providers/modal-provider'; import { useCopyToClipboard } from 'shared/hooks'; -import { getEtherscanAddressLink } from 'utils/get-etherscan-address-link'; +import { getEtherscanAddressLink } from 'utils/etherscan'; import { WalletModalContentStyle, WalletModalConnectedStyle, @@ -25,7 +26,7 @@ import { import { useDappStatus } from 'modules/web3'; export const WalletModal: ModalComponentType = ({ onClose, ...props }) => { - const { address, chainId } = useDappStatus(); + const { address, walletChainId } = useDappStatus(); const { connectorName } = useConnectorInfo(); const { disconnect } = useDisconnect(); @@ -36,9 +37,12 @@ export const WalletModal: ModalComponentType = ({ onClose, ...props }) => { const handleCopy = useCopyToClipboard(address ?? ''); const handleEtherscan = useCallback(() => { - const link = getEtherscanAddressLink(chainId, address ?? '', chainId); + const link = getEtherscanAddressLink( + walletChainId ?? config.defaultChain, + address ?? '', + ); openWindow(link); - }, [address, chainId]); + }, [address, walletChainId]); useEffect(() => { // Close the modal if a wallet was somehow disconnected while the modal was open diff --git a/utils/etherscan.ts b/utils/etherscan.ts new file mode 100644 index 000000000..6f5f5f75c --- /dev/null +++ b/utils/etherscan.ts @@ -0,0 +1,38 @@ +import { mainnet } from 'viem/chains'; +import { wagmiChainMap } from 'modules/web3/web3-provider/web3-provider'; + +export enum ETHERSCAN_ENTITIES { + TX = 'tx', + TOKEN = 'token', + ADDRESS = 'address', +} + +export const getEtherscanLink = ( + chainId: number, + hash: string, + entity: ETHERSCAN_ENTITIES, +): string => { + const wagmiChain = wagmiChainMap[chainId] ?? mainnet; + return wagmiChain?.blockExplorers?.default?.url + ? `${wagmiChain.blockExplorers.default.url}/${entity}/${hash}` + : // Most likely this fallback will never work + `https://etherscan1.io/${entity}/${hash}`; +}; + +export const getEtherscanTxLink = (chainId: number, hash: string): string => { + return getEtherscanLink(chainId, hash, ETHERSCAN_ENTITIES.TX); +}; + +export const getEtherscanTokenLink = ( + chainId: number, + hash: string, +): string => { + return getEtherscanLink(chainId, hash, ETHERSCAN_ENTITIES.TOKEN); +}; + +export const getEtherscanAddressLink = ( + chainId: number, + hash: string, +): string => { + return getEtherscanLink(chainId, hash, ETHERSCAN_ENTITIES.ADDRESS); +}; diff --git a/utils/get-etherscan-address-link.ts b/utils/get-etherscan-address-link.ts deleted file mode 100644 index 66d959389..000000000 --- a/utils/get-etherscan-address-link.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { getEtherscanLink as getEtherscanLinkSDK } from '@lido-sdk/helpers'; -import { CHAINS as CHAINS_SDK } from '@lido-sdk/constants'; - -import { CHAINS } from 'consts/chains'; - -export const getEtherscanAddressLink = ( - chainId: number, - address: string, - fallbackChainId: number, -): string => { - if (chainId === CHAINS.OptimismSepolia) { - return `https://sepolia-optimistic.etherscan.io/address/${address}`; - } else if (chainId === CHAINS.Optimism) { - return `https://optimistic.etherscan.io/address/${address}`; - } - - try { - return getEtherscanLinkSDK(chainId as CHAINS_SDK, address, 'address'); - } catch { - return getEtherscanLinkSDK( - fallbackChainId as CHAINS_SDK, - address, - 'address', - ); - } -}; diff --git a/utils/get-etherscan-tx-link.ts b/utils/get-etherscan-tx-link.ts deleted file mode 100644 index f7ca4fe46..000000000 --- a/utils/get-etherscan-tx-link.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { getEtherscanTxLink as getEtherscanTxLinkSDK } from '@lido-sdk/helpers'; -import { CHAINS as CHAINS_SDK } from '@lido-sdk/constants'; - -import { CHAINS } from 'consts/chains'; - -export const getEtherscanTxLink = ( - chainId: CHAINS | CHAINS_SDK, - hash: string, -): string => { - // TODO: use viem for getting explorer - if (chainId === CHAINS.OptimismSepolia) { - return `https://sepolia-optimistic.etherscan.io/tx/${hash}`; - } else if (chainId === CHAINS.Optimism) { - return `https://optimistic.etherscan.io/tx/${hash}`; - } - - return getEtherscanTxLinkSDK(chainId as CHAINS_SDK, hash); -}; From a7d2eaf835dd6d3dc5fb6aa1accce9f22a452341 Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Fri, 1 Nov 2024 16:08:54 +0300 Subject: [PATCH 3/4] refactor: getEtherscanLink --- utils/etherscan.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/utils/etherscan.ts b/utils/etherscan.ts index 6f5f5f75c..8a28dc4c8 100644 --- a/utils/etherscan.ts +++ b/utils/etherscan.ts @@ -1,4 +1,4 @@ -import { mainnet } from 'viem/chains'; +import invariant from 'tiny-invariant'; import { wagmiChainMap } from 'modules/web3/web3-provider/web3-provider'; export enum ETHERSCAN_ENTITIES { @@ -12,11 +12,9 @@ export const getEtherscanLink = ( hash: string, entity: ETHERSCAN_ENTITIES, ): string => { - const wagmiChain = wagmiChainMap[chainId] ?? mainnet; - return wagmiChain?.blockExplorers?.default?.url - ? `${wagmiChain.blockExplorers.default.url}/${entity}/${hash}` - : // Most likely this fallback will never work - `https://etherscan1.io/${entity}/${hash}`; + const wagmiChain = wagmiChainMap[chainId]; + invariant(wagmiChain, `chainId ${chainId} is unknown by wagmiChainMap`); + return `${wagmiChain?.blockExplorers?.default?.url}/${entity}/${hash}`; }; export const getEtherscanTxLink = (chainId: number, hash: string): string => { From 75e8dc2d3bd06ff573a4d298b0e9c11a1b473a2b Mon Sep 17 00:00:00 2001 From: Anton Shalimov Date: Fri, 1 Nov 2024 16:15:46 +0300 Subject: [PATCH 4/4] refactor: simplify --- features/wsteth/shared/wrap-faq/wrap-faq.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/wsteth/shared/wrap-faq/wrap-faq.tsx b/features/wsteth/shared/wrap-faq/wrap-faq.tsx index 3aa677b5a..c2409724f 100644 --- a/features/wsteth/shared/wrap-faq/wrap-faq.tsx +++ b/features/wsteth/shared/wrap-faq/wrap-faq.tsx @@ -16,13 +16,13 @@ export const WrapFaq = () => { const { isWalletConnected, chainType } = useDappStatus(); const onClickHandler = useMatomoEventHandle(); - const faqComponent = !isWalletConnected + const FAQ = !isWalletConnected ? EthereumFAQ : faqComponentsMap.get(chainType) || EthereumFAQ; return (
- {React.createElement(faqComponent, { key: chainType })} +
); };