From c2e393a24ac6895ec040f2c7642414cff12b1f2f Mon Sep 17 00:00:00 2001 From: serg-plusplus Date: Mon, 19 Feb 2024 14:33:38 +0000 Subject: [PATCH 1/2] Fix explorer link in network dropdown --- src/app/components/elements/NetworkCard.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/components/elements/NetworkCard.tsx b/src/app/components/elements/NetworkCard.tsx index 13990c51c..c2a4eee7d 100644 --- a/src/app/components/elements/NetworkCard.tsx +++ b/src/app/components/elements/NetworkCard.tsx @@ -7,7 +7,7 @@ import { Network } from "core/types"; import { getNetworkIconUrl } from "fixtures/networks"; import { Page, SettingTab } from "app/nav"; -import { useAccounts } from "app/hooks"; +import { useAccounts, useExplorerLink } from "app/hooks"; import IconedButton from "app/components/elements/IconedButton"; import { ReactComponent as PopoverIcon } from "app/icons/popover.svg"; import { ReactComponent as WalletExplorerIcon } from "app/icons/external-link.svg"; @@ -31,8 +31,13 @@ const NetworkCard: FC = ({ onClick, className, }) => { + const { currentAccount } = useAccounts(); + const explorerLink = useExplorerLink(network); + const [popoverOpened, setPopoverOpened] = useState(false); + const explorerUrl = explorerLink?.address(currentAccount.address); + return ( = ({ "flex flex-col", )} > - {network.explorerUrls?.length ? ( - + {explorerUrl ? ( + Block Explorer ) : null} From ec0263f069d4d9db1feb942ff727ad676dc9fdf8 Mon Sep 17 00:00:00 2001 From: serg-plusplus Date: Mon, 19 Feb 2024 14:41:35 +0000 Subject: [PATCH 2/2] Make deeplink for netwwork setting --- src/app/atoms/nav.ts | 2 ++ src/app/components/elements/NetworkCard.tsx | 6 +++++- src/app/components/screens/settingTabs/Networks.tsx | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/atoms/nav.ts b/src/app/atoms/nav.ts index 767b9dd21..43e8feb21 100644 --- a/src/app/atoms/nav.ts +++ b/src/app/atoms/nav.ts @@ -43,3 +43,5 @@ export const onRampModalAtom = atomWithURLHash("onRampOpened", false); export const tokenSlugAtom = atomWithURLHash("token", null); export const activityModalAtom = atomWithURLHash("activityOpened", false); + +export const chainIdUrlAtom = atomWithURLHash("chainid", null); diff --git a/src/app/components/elements/NetworkCard.tsx b/src/app/components/elements/NetworkCard.tsx index c2a4eee7d..1bea7d53f 100644 --- a/src/app/components/elements/NetworkCard.tsx +++ b/src/app/components/elements/NetworkCard.tsx @@ -128,7 +128,11 @@ const NetworkCard: FC = ({ ) : null} Settings diff --git a/src/app/components/screens/settingTabs/Networks.tsx b/src/app/components/screens/settingTabs/Networks.tsx index 581c6734c..20c18d898 100644 --- a/src/app/components/screens/settingTabs/Networks.tsx +++ b/src/app/components/screens/settingTabs/Networks.tsx @@ -1,11 +1,13 @@ import { FC, useCallback, useMemo, useRef, useState } from "react"; import classNames from "clsx"; import Fuse from "fuse.js"; +import { useAtomValue } from "jotai"; import { getNetworkIconUrl } from "fixtures/networks"; import { NETWORK_SEARCH_OPTIONS } from "app/defaults"; import { useLazyAllNetworks } from "app/hooks"; +import { chainIdUrlAtom } from "app/atoms"; import { ToastOverflowProvider } from "app/hooks/toast"; import SearchInput from "app/components/elements/SearchInput"; import ScrollAreaContainer from "app/components/elements/ScrollAreaContainer"; @@ -17,7 +19,9 @@ const Networks: FC = () => { const allNetworks = useLazyAllNetworks(); const scrollAreaRef = useRef(null); - const [tab, setTab] = useState<"new" | number | null>(null); + const chainIdUrl = useAtomValue(chainIdUrlAtom); + + const [tab, setTab] = useState<"new" | number | null>(chainIdUrl); const [searchValue, setSearchValue] = useState(null); const fuse = useMemo(