diff --git a/packages/connectkit/src/components/Pages/Connectors/index.tsx b/packages/connectkit/src/components/Pages/Connectors/index.tsx index ef82e9dd..41990add 100644 --- a/packages/connectkit/src/components/Pages/Connectors/index.tsx +++ b/packages/connectkit/src/components/Pages/Connectors/index.tsx @@ -84,11 +84,13 @@ const Wallets: React.FC = () => { const { ethereum } = window; const needsInjectedWalletFallback = - typeof window !== 'undefined' && - ethereum && - !isMetaMask() && - !isCoinbaseWallet(); - //!ethereum?.isBraveWallet; // TODO: Add this line when Brave is supported + (typeof window !== 'undefined' && + ethereum && + !isMetaMask() && + !isCoinbaseWallet()) || + // Trust wallet is a special case that requires further debugging to fix. + // For now, we'll just show the injected wallet option if it's available. + isTrust(); return needsInjectedWalletFallback; }; diff --git a/packages/connectkit/src/utils/index.ts b/packages/connectkit/src/utils/index.ts index 2618f2f5..87a36ef1 100644 --- a/packages/connectkit/src/utils/index.ts +++ b/packages/connectkit/src/utils/index.ts @@ -2,6 +2,13 @@ import { detect } from 'detect-browser'; import React from 'react'; import supportedConnectors from '../constants/supportedConnectors'; +declare global { + interface Window { + trustWallet: any; + trustwallet: any; + } +} + const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/; const truncateEthAddress = (address?: string, separator: string = '••••') => { @@ -133,6 +140,8 @@ const isMetaMask = () => { if (isPhantom()) return false; + if (isTrust()) return false; + return true; }; @@ -189,7 +198,15 @@ const isRabby = () => { const isTrust = () => { if (typeof window === 'undefined') return false; - return window?.ethereum?.isTrust; + const { ethereum } = window; + + return !!( + ethereum?.isTrust || + (ethereum?.providers && + ethereum?.providers.find((provider) => provider.isTrust)) || + window.trustWallet?.isTrust || + window.trustwallet?.isTrust + ); }; const isTokenPocket = () => {