From 789d7047c703c2dc2598f7d145736488bedbd633 Mon Sep 17 00:00:00 2001 From: Alex Harley Date: Wed, 12 Jun 2024 18:29:10 +0200 Subject: [PATCH 1/2] feat: only show wallets useful to loaded warp routes --- .../wallet/WalletEnvSelectionModal.tsx | 68 +++++++++++++------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/features/wallet/WalletEnvSelectionModal.tsx b/src/features/wallet/WalletEnvSelectionModal.tsx index c2872f55..2b6404e7 100644 --- a/src/features/wallet/WalletEnvSelectionModal.tsx +++ b/src/features/wallet/WalletEnvSelectionModal.tsx @@ -1,16 +1,34 @@ import Image from 'next/image'; -import { PropsWithChildren } from 'react'; +import { PropsWithChildren, useMemo } from 'react'; import { ethereum, solana } from '@hyperlane-xyz/registry'; import { ProtocolType } from '@hyperlane-xyz/utils'; import { ChainLogo } from '../../components/icons/ChainLogo'; import { Modal } from '../../components/layout/Modal'; +import { getWarpCore } from '../../context/context'; import { useConnectFns } from './hooks/multiProtocol'; export function WalletEnvSelectionModal({ isOpen, close }: { isOpen: boolean; close: () => void }) { const connectFns = useConnectFns(); + const protocolsEnabled = useMemo(() => { + const wc = getWarpCore(); + + return wc.getTokenChains().reduce( + (accum, chainName) => { + return { + ...accum, + [wc.multiProvider.getChainMetadata(chainName).protocol]: true, + }; + }, + { + [ProtocolType.Ethereum]: false, + [ProtocolType.Cosmos]: false, + [ProtocolType.Sealevel]: false, + }, + ); + }, []); const onClickEnv = (env: ProtocolType) => () => { close(); @@ -21,27 +39,33 @@ export function WalletEnvSelectionModal({ isOpen, close }: { isOpen: boolean; cl return (
- - Ethereum - - - Solana - - } - > - Cosmos - + {protocolsEnabled[ProtocolType.Ethereum] && ( + + Ethereum + + )} + {protocolsEnabled[ProtocolType.Sealevel] && ( + + Solana + + )} + {protocolsEnabled[ProtocolType.Cosmos] && ( + } + > + Cosmos + + )}
); From 8390eb649b202e650ac7ace16112e87f53c82e53 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 13 Jun 2024 16:35:09 +0200 Subject: [PATCH 2/2] Update src/features/wallet/WalletEnvSelectionModal.tsx Co-authored-by: J M Rossy --- src/features/wallet/WalletEnvSelectionModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/wallet/WalletEnvSelectionModal.tsx b/src/features/wallet/WalletEnvSelectionModal.tsx index 2b6404e7..28895838 100644 --- a/src/features/wallet/WalletEnvSelectionModal.tsx +++ b/src/features/wallet/WalletEnvSelectionModal.tsx @@ -19,7 +19,7 @@ export function WalletEnvSelectionModal({ isOpen, close }: { isOpen: boolean; cl (accum, chainName) => { return { ...accum, - [wc.multiProvider.getChainMetadata(chainName).protocol]: true, + [wc.multiProvider.getProtocol(chainName)]: true, }; }, {