@@ -11,6 +11,7 @@ import {
1111import {
1212 argentWallet ,
1313 coinbaseWallet ,
14+ injectedWallet ,
1415 ledgerWallet ,
1516 metaMaskWallet ,
1617 rainbowWallet ,
@@ -38,30 +39,59 @@ export function initWagmi(multiProvider: MultiProtocolProvider) {
3839 throw chainsError ;
3940 }
4041
41- const [ connectorsError , connectors ] = trySync ( ( ) =>
42- connectorsForWallets (
42+ const [ connectorsError , connectors ] = trySync ( ( ) => {
43+ const shouldIncludeInjected = ( ( ) => {
44+ if ( typeof window === "undefined" ) return false ;
45+ const eth = ( window as unknown as { ethereum ?: unknown } ) . ethereum ;
46+ if ( ! eth ) return false ;
47+
48+ interface InjectedProvider {
49+ isMetaMask ?: boolean ;
50+ isCoinbaseWallet ?: boolean ;
51+ [ key : string ] : unknown ;
52+ }
53+
54+ const providers : InjectedProvider [ ] = Array . isArray (
55+ ( eth as { providers ?: InjectedProvider [ ] } ) . providers ,
56+ )
57+ ? ( eth as { providers : InjectedProvider [ ] } ) . providers
58+ : [ eth as InjectedProvider ] ;
59+
60+ // Include injected only if there's an injected provider that is NOT MetaMask or Coinbase
61+ return providers . some (
62+ ( p : InjectedProvider ) => ! p . isMetaMask && ! p . isCoinbaseWallet ,
63+ ) ;
64+ } ) ( ) ;
65+
66+ const moreWallets = [
67+ coinbaseWallet ,
68+ rainbowWallet ,
69+ trustWallet ,
70+ argentWallet ,
71+ uniswapWallet ,
72+ ] ;
73+
74+ if ( shouldIncludeInjected ) {
75+ moreWallets . push ( injectedWallet ) ;
76+ }
77+
78+ return connectorsForWallets (
4379 [
4480 {
4581 groupName : "Recommended" ,
4682 wallets : [ metaMaskWallet , walletConnectWallet , ledgerWallet ] ,
4783 } ,
4884 {
4985 groupName : "More" ,
50- wallets : [
51- coinbaseWallet ,
52- rainbowWallet ,
53- trustWallet ,
54- argentWallet ,
55- uniswapWallet ,
56- ] ,
86+ wallets : moreWallets ,
5787 } ,
5888 ] ,
5989 {
6090 appName : "Torus Base Bridge" ,
6191 projectId : config . walletConnectProjectId ,
6292 } ,
63- ) ,
64- ) ;
93+ ) ;
94+ } ) ;
6595
6696 if ( connectorsError !== undefined ) {
6797 console . error ( "Error creating wallet connectors:" , connectorsError ) ;
0 commit comments