@@ -31,6 +31,8 @@ export interface AntDesignWeb3ConfigProviderProps {
31
31
onCurrentChainChange ?: ( chain ?: SolanaChainConfig ) => void ;
32
32
}
33
33
34
+ const MWA_WALLET_NAME = 'Mobile Wallet Adapter' ;
35
+
34
36
export const AntDesignWeb3ConfigProvider : React . FC <
35
37
React . PropsWithChildren < AntDesignWeb3ConfigProviderProps >
36
38
> = ( props ) => {
@@ -99,13 +101,16 @@ export const AntDesignWeb3ConfigProvider: React.FC<
99
101
getBalance ( ) ;
100
102
} , [ connection , publicKey , props . balance ] ) ;
101
103
104
+ console . log ( '__wallet__:' , wallet ?. adapter . name ) ;
105
+
102
106
// connect/disconnect wallet
103
107
useEffect ( ( ) => {
104
108
// 初始化时跳过,避免与 wallet-adapter 的自动连接逻辑冲突
105
109
if ( ! mountRef . current ) {
106
110
return ;
107
111
}
108
112
113
+ console . log ( 'wallet:' , wallet ?. adapter ?. name , connected , wallet ?. adapter ) ;
109
114
if ( wallet ?. adapter ?. name ) {
110
115
// if wallet is not ready, need clear selected wallet
111
116
if ( ! hasWalletReady ( wallet . adapter . readyState ) ) {
@@ -177,13 +182,14 @@ export const AntDesignWeb3ConfigProvider: React.FC<
177
182
178
183
const providedWalletNames = providedWallets . map ( ( w ) => w . name ) ;
179
184
185
+ // standard wallets
180
186
const autoRegisteredWallets = wallets
181
187
. filter ( ( w ) => ! providedWalletNames . includes ( w . adapter . name ) )
182
188
. map < Wallet > ( ( w ) => {
183
189
const adapter = w . adapter ;
184
190
185
- // Mobile Wallet Adapter is a special case, it's always ready
186
- if ( adapter . name === 'Mobile Wallet Adapter' ) {
191
+ // MWA is a special case, it's always ready
192
+ if ( adapter . name === MWA_WALLET_NAME ) {
187
193
return {
188
194
name : adapter . name ,
189
195
icon : adapter . icon ,
@@ -192,9 +198,9 @@ export const AntDesignWeb3ConfigProvider: React.FC<
192
198
193
199
hasCustomHandler : ( ) => { } ,
194
200
195
- // hasExtensionInstalled: async () => {
196
- // return true;
197
- // },
201
+ hasExtensionInstalled : async ( ) => {
202
+ return true ;
203
+ } ,
198
204
hasWalletReady : async ( ) => {
199
205
// return hasWalletReady(adapter.readyState);
200
206
return true ;
@@ -251,6 +257,11 @@ export const AntDesignWeb3ConfigProvider: React.FC<
251
257
} }
252
258
connect = { async ( _wallet , options ) => {
253
259
console . log ( 'connect_wallet:' , _wallet , options ) ;
260
+ if ( _wallet ?. name === MWA_WALLET_NAME ) {
261
+ _wallet . _standardWallet ?. connect ( ) ;
262
+ return ;
263
+ }
264
+
254
265
let resolve : any ;
255
266
let reject : any ;
256
267
0 commit comments