diff --git a/public/wallets/okx-wallet.png b/public/wallets/okx-wallet.png new file mode 100644 index 000000000..fc09d030b Binary files /dev/null and b/public/wallets/okx-wallet.png differ diff --git a/src/constants/wallets.ts b/src/constants/wallets.ts index b4ab501d6..83411cc15 100644 --- a/src/constants/wallets.ts +++ b/src/constants/wallets.ts @@ -16,6 +16,7 @@ import { KeplrIcon, MathWalletIcon, MetaMaskIcon, + OkxWalletIcon, RainbowIcon, TokenPocketIcon, TrustWalletIcon, @@ -89,6 +90,7 @@ export enum WalletType { // Ledger = 'LEDGER', MathWallet = 'MATH_WALLET', MetaMask = 'METAMASK', + OkxWallet = 'OKX_WALLET', Rainbow = 'RAINBOW_WALLET', TokenPocket = 'TOKEN_POCKET', TrustWallet = 'TRUST_WALLET', @@ -102,6 +104,7 @@ const WALLET_CONNECT_EXPLORER_RECOMMENDED_WALLETS = { imToken: 'ef333840daf915aafdc4a004525502d6d49d77bd9c65e0642dbaefb3c2893bef', TokenPocket: '20459438007b75f4f4acb98bf29aa3b800550309646d375da5fd4aac6c2a2c66', Trust: '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0', + OkxWallet: '971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709', Rainbow: '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', Zerion: 'ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18', Ledger: '19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927', @@ -212,6 +215,14 @@ export const wallets: Record = { matchesInjectedEip1193: isMetaMask, walletconnect2Id: WALLET_CONNECT_EXPLORER_RECOMMENDED_WALLETS.Metamask, }, + [WalletType.OkxWallet]: { + type: WalletType.OkxWallet, + stringKey: STRING_KEYS.OKX_WALLET, + icon: OkxWalletIcon, + connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2], + matchesInjectedEip1193: (provider) => provider.isOkxWallet, + walletconnect2Id: WALLET_CONNECT_EXPLORER_RECOMMENDED_WALLETS.OkxWallet, + }, [WalletType.Rainbow]: { type: WalletType.Rainbow, stringKey: STRING_KEYS.RAINBOW_WALLET, @@ -278,6 +289,10 @@ export type WithInjectedWeb3Provider = { }; }; +export type WithInjectedOkxWalletProvider = { + okxwallet: InjectedWeb3Provider; +}; + // Wallet connections export type WalletConnection = { diff --git a/src/hooks/useDisplayedWallets.ts b/src/hooks/useDisplayedWallets.ts index 38de2a517..876b5d7c3 100644 --- a/src/hooks/useDisplayedWallets.ts +++ b/src/hooks/useDisplayedWallets.ts @@ -10,9 +10,10 @@ export const useDisplayedWallets = () => { isDev && WalletType.Keplr, WalletType.WalletConnect2, - + WalletType.CoinbaseWallet, - + + WalletType.OkxWallet, // Hide these wallet options until they can be properly tested on mainnet // WalletType.ImToken, // WalletType.Rainbow, diff --git a/src/icons/index.ts b/src/icons/index.ts index 836b13096..af109cb9d 100644 --- a/src/icons/index.ts +++ b/src/icons/index.ts @@ -83,6 +83,7 @@ export { default as LedgerIcon } from './wallets/ledger.svg'; export { default as MagicIcon } from './wallets/magic.svg'; export { default as MathWalletIcon } from './wallets/mathwallet.svg'; export { default as MetaMaskIcon } from './wallets/metamask.svg'; +export { default as OkxWalletIcon } from './wallets/okx-wallet.svg'; export { default as RainbowIcon } from './wallets/rainbow-wallet.svg'; export { default as TestWalletIcon } from './wallets/test-wallet.svg'; export { default as TokenPocketIcon } from './wallets/tokenpocket.svg'; diff --git a/src/icons/wallets/okx-wallet.svg b/src/icons/wallets/okx-wallet.svg new file mode 100644 index 000000000..5e45efad8 --- /dev/null +++ b/src/icons/wallets/okx-wallet.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/lib/wallet/providers.ts b/src/lib/wallet/providers.ts index 0de886af0..df9748f82 100644 --- a/src/lib/wallet/providers.ts +++ b/src/lib/wallet/providers.ts @@ -5,6 +5,7 @@ import { type InjectedCoinbaseWalletExtensionProvider, type WithInjectedEthereumProvider, type WithInjectedWeb3Provider, + type WithInjectedOkxWalletProvider, } from '@/constants/wallets'; import { isTruthy } from '../isTruthy'; @@ -18,15 +19,6 @@ export const isMetaMask = (provider: ExternalProvider) => ( && ( !(provider as InjectedCoinbaseWalletExtensionProvider).overrideIsMetaMask ) - - /* not a MetaMask wannabe! */ - && ( - Reflect.ownKeys(provider).filter((key) => - typeof key === 'string' - && key.match(/^is/) - && !['isConnected', 'isMetaMask'].includes(key) - ).length === 0 - ) ) /* @@ -54,5 +46,10 @@ export const detectInjectedEip1193Providers = (): ExternalProvider[] => { ? ethereumProvider.providers : []; - return [...displacedProviders, ethereumProvider, web3Provider].filter(isTruthy); + const okxWalletProvider = (globalThis as typeof globalThis & WithInjectedOkxWalletProvider) + ?.okxwallet; + + return [...displacedProviders, ethereumProvider, web3Provider, okxWalletProvider].filter( + isTruthy + ); };