From 944cea0d3d766b2e46ab56365091d6cd10b0441d Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 16 Oct 2023 09:07:35 -0700 Subject: [PATCH] Hide wallet options (#70) * Hide wallet options * remove WC 1 * gitignore .env * remove .env * remove wc1 --- .env | 6 --- .env.example | 1 - .gitignore | 1 + src/constants/wallets.ts | 81 +++++--------------------------- src/hooks/useDisplayedWallets.ts | 22 ++++----- src/lib/wagmi.ts | 25 ---------- src/lib/wallet/index.ts | 6 --- 7 files changed, 22 insertions(+), 120 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index e3b0a04..0000000 --- a/.env +++ /dev/null @@ -1,6 +0,0 @@ -VITE_BASE_URL=https://v4.testnet.dydx.exchange - -VITE_ALCHEMY_API_KEY=FP275q327Yh7qswtZWenbPXdZZdnAFmC - -VITE_WALLETCONNECT1_BRIDGE=wss://api.dydx.exchange/wc/ -VITE_WALLETCONNECT2_PROJECT_ID=fbe94eaa691fa8d929561f8567062b32 diff --git a/.env.example b/.env.example index 84ce9c6..3a0d1b2 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,6 @@ VITE_ALCHEMY_API_KEY= VITE_PK_ENCRYPTION_KEY= -VITE_WALLETCONNECT1_BRIDGE= VITE_WALLETCONNECT2_PROJECT_ID= VITE_V3_TOKEN_ADDRESS= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 384dab7..27e504a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ dist dist-ssr *.local *.key +.env # Editor directories and files .vscode/* diff --git a/src/constants/wallets.ts b/src/constants/wallets.ts index 4eaccac..efb4077 100644 --- a/src/constants/wallets.ts +++ b/src/constants/wallets.ts @@ -32,7 +32,6 @@ export enum WalletConnectionType { CoinbaseWalletSdk = 'coinbaseWalletSdk', CosmosSigner = 'CosmosSigner', InjectedEip1193 = 'injectedEip1193', - WalletConnect1 = 'walletConnect1', WalletConnect2 = 'walletConnect2', } @@ -62,10 +61,6 @@ export const walletConnectionTypes: Record boolean; - walletconnect1Name?: string; walletconnect2Id?: string; }; @@ -117,7 +110,6 @@ export const wallets: Record = { WalletConnectionType.InjectedEip1193, // WalletConnectionType.CoinbaseWalletSdk, WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, ], matchesInjectedEip1193: (provider) => Object.entries(wallets).every( @@ -131,30 +123,23 @@ export const wallets: Record = { type: WalletType.BitKeep, stringKey: STRING_KEYS.BITKEEP, icon: BitkeepIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isBitKeep, // isBitKeepChrome, isBitEthereum - walletconnect1Name: 'bitkeep', walletconnect2Id: '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662', }, [WalletType.BitPie]: { type: WalletType.BitPie, stringKey: STRING_KEYS.BITPIE, icon: BitpieIcon, - connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1], + connectionTypes: [WalletConnectionType.InjectedEip1193], matchesInjectedEip1193: (provider) => provider.isBitpie, - walletconnect1Name: 'bitpie', }, [WalletType.CloverWallet]: { type: WalletType.CloverWallet, stringKey: STRING_KEYS.CLOVER_WALLET, icon: CloverWalletIcon, - connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1], + connectionTypes: [WalletConnectionType.InjectedEip1193], matchesInjectedEip1193: (provider) => provider.isClover, - // walletconnect1Name: 'clover', }, [WalletType.CoinbaseWallet]: { type: WalletType.CoinbaseWallet, @@ -163,33 +148,23 @@ export const wallets: Record = { connectionTypes: [ WalletConnectionType.CoinbaseWalletSdk, WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect1, + WalletConnectionType.WalletConnect2, ], matchesInjectedEip1193: (provider) => provider.isCoinbaseWallet, // provider.selectedProvider?.isCoinbaseWallet, - walletconnect1Name: 'coinbase', }, [WalletType.Coin98]: { type: WalletType.Coin98, stringKey: STRING_KEYS.COIN98, icon: Coin98Icon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isCoin98, - walletconnect1Name: 'coin98', walletconnect2Id: '2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01', }, [WalletType.HuobiWallet]: { type: WalletType.HuobiWallet, stringKey: STRING_KEYS.HUOBI_WALLET, icon: HuobiIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isHbWallet, walletconnect2Id: '797c615e2c556b610c048eb35535f212c0dd58de5d03e763120e90a7d1350a77', }, @@ -197,74 +172,48 @@ export const wallets: Record = { type: WalletType.ImToken, stringKey: STRING_KEYS.IMTOKEN, icon: ImTokenIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isImToken, - walletconnect1Name: 'imtoken', walletconnect2Id: 'ef333840daf915aafdc4a004525502d6d49d77bd9c65e0642dbaefb3c2893bef', }, [WalletType.MathWallet]: { type: WalletType.MathWallet, stringKey: STRING_KEYS.MATH_WALLET, icon: MathWalletIcon, - connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1], + connectionTypes: [WalletConnectionType.InjectedEip1193], matchesInjectedEip1193: (provider) => provider.isMathWallet, - walletconnect1Name: 'math', walletconnect2Id: '7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26', }, [WalletType.MetaMask]: { type: WalletType.MetaMask, stringKey: STRING_KEYS.METAMASK, icon: MetaMaskIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: isMetaMask, - walletconnect1Name: 'metamask', walletconnect2Id: 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', }, [WalletType.Rainbow]: { type: WalletType.Rainbow, stringKey: STRING_KEYS.RAINBOW_WALLET, icon: RainbowIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isRainbowWallet, - walletconnect1Name: 'rainbow', walletconnect2Id: '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', }, [WalletType.TokenPocket]: { type: WalletType.TokenPocket, stringKey: STRING_KEYS.TOKEN_POCKET, icon: TokenPocketIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isTokenPocket, - walletconnect1Name: 'tokenpocket', walletconnect2Id: '20459438007b75f4f4acb98bf29aa3b800550309646d375da5fd4aac6c2a2c66', }, [WalletType.TrustWallet]: { type: WalletType.TrustWallet, stringKey: STRING_KEYS.TRUST_WALLET, icon: TrustWalletIcon, - connectionTypes: [ - WalletConnectionType.InjectedEip1193, - WalletConnectionType.WalletConnect2, - WalletConnectionType.WalletConnect1, - ], + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], matchesInjectedEip1193: (provider) => provider.isTrust, - walletconnect1Name: 'trust', walletconnect2Id: '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0', }, [WalletType.WalletConnect2]: { @@ -273,12 +222,6 @@ export const wallets: Record = { icon: WalletConnectIcon, connectionTypes: [WalletConnectionType.WalletConnect2], }, - [WalletType.WalletConnect]: { - type: WalletType.WalletConnect, - stringKey: STRING_KEYS.WALLET_CONNECT, - icon: WalletConnectIcon, - connectionTypes: [WalletConnectionType.WalletConnect1], - }, [WalletType.Keplr]: { type: WalletType.Keplr, stringKey: STRING_KEYS.KEPLR, diff --git a/src/hooks/useDisplayedWallets.ts b/src/hooks/useDisplayedWallets.ts index 2454a4f..0627be9 100644 --- a/src/hooks/useDisplayedWallets.ts +++ b/src/hooks/useDisplayedWallets.ts @@ -2,27 +2,23 @@ import { WalletType } from '@/constants/wallets'; import { isTruthy } from '@/lib/isTruthy'; -import { useSelectedNetwork } from './useSelectedNetwork'; - export const useDisplayedWallets = () => { - const { selectedNetwork } = useSelectedNetwork(); - return [ WalletType.MetaMask, import.meta.env.MODE !== 'production' && WalletType.Keplr, WalletType.WalletConnect2, - WalletType.WalletConnect, - + WalletType.CoinbaseWallet, - - WalletType.ImToken, - WalletType.Rainbow, - WalletType.TrustWallet, - WalletType.HuobiWallet, - WalletType.BitKeep, - WalletType.Coin98, + + // Hide these wallet options until they can be properly tested on mainnet + // WalletType.ImToken, + // WalletType.Rainbow, + // WalletType.TrustWallet, + // WalletType.HuobiWallet, + // WalletType.BitKeep, + // WalletType.Coin98, WalletType.OtherWallet, ].filter(isTruthy); diff --git a/src/lib/wagmi.ts b/src/lib/wagmi.ts index c1a28ff..c7a86e8 100644 --- a/src/lib/wagmi.ts +++ b/src/lib/wagmi.ts @@ -87,14 +87,6 @@ const injectedConnectorOptions = { }, }; -const walletconnect1ConnectorOptions = { - chains, - options: { - bridge: import.meta.env.VITE_WALLETCONNECT1_BRIDGE, - qrcode: true, - }, -}; - const walletconnect2ConnectorOptions: ConstructorParameters[0] = { chains, options: { @@ -142,7 +134,6 @@ const connectors = [ reloadOnDisconnect: false, }, }), - new WalletConnectLegacyConnector(walletconnect1ConnectorOptions), new WalletConnectConnector(walletconnect2ConnectorOptions), new InjectedConnector(injectedConnectorOptions), ]; @@ -165,19 +156,6 @@ const createInjectedConnectorWithProvider = (provider: ExternalProvider) => provider as unknown as Awaited>; })(injectedConnectorOptions) as InjectedConnector; -// Create a custom wagmi WalletConnectLegacyConnector with a modal showing only wallet links matching the given name -const createWalletConnect1ConnectorWithName = (walletconnect1Name: string) => - new WalletConnectLegacyConnector({ - ...walletconnect1ConnectorOptions, - options: { - ...walletconnect1ConnectorOptions.options, - qrcodeModalOptions: { - desktopLinks: [walletconnect1Name], - mobileLinks: [walletconnect1Name], - }, - }, - }); - const createWalletConnect2ConnectorWithId = (walletconnect2Id: string) => new WalletConnectConnector({ ...walletconnect2ConnectorOptions, @@ -213,9 +191,6 @@ export const resolveWagmiConnector = ({ return walletConnection.type === WalletConnectionType.InjectedEip1193 && walletConnection.provider ? createInjectedConnectorWithProvider(walletConnection.provider) - : walletConnection.type === WalletConnectionType.WalletConnect1 && - walletConfig.walletconnect1Name - ? createWalletConnect1ConnectorWithName(walletConfig.walletconnect1Name) : walletConnection.type === WalletConnectionType.WalletConnect2 && walletConfig.walletconnect2Id ? createWalletConnect2ConnectorWithId(walletConfig.walletconnect2Id) : connectors.find(({ id }: { id: string }) => id === walletConnectionConfig.wagmiConnectorId); diff --git a/src/lib/wallet/index.ts b/src/lib/wallet/index.ts index c8619d2..80ee1c4 100644 --- a/src/lib/wallet/index.ts +++ b/src/lib/wallet/index.ts @@ -45,12 +45,6 @@ export const getWalletConnection = ({ break; } - case WalletConnectionType.WalletConnect1: { - return { - type: WalletConnectionType.WalletConnect1, - }; - } - case WalletConnectionType.WalletConnect2: { return { type: WalletConnectionType.WalletConnect2,