File tree 2 files changed +20
-8
lines changed 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -46,17 +46,23 @@ async function disconnect(options: DisconnectOptions): Promise<WalletState[]> {
46
46
47
47
const lastConnectedWallets = getLocalStore ( STORAGE_KEYS . LAST_CONNECTED_WALLET )
48
48
if ( lastConnectedWallets ) {
49
- const labels = JSON . parse ( lastConnectedWallets )
49
+ try {
50
+ const labels = JSON . parse ( lastConnectedWallets )
50
51
51
- if ( Array . isArray ( labels ) && labels . indexOf ( label ) >= 0 ) {
52
- setLocalStore (
53
- STORAGE_KEYS . LAST_CONNECTED_WALLET ,
54
- JSON . stringify ( labels . filter ( walletLabel => walletLabel !== label ) )
52
+ if ( Array . isArray ( labels ) && labels . indexOf ( label ) >= 0 ) {
53
+ setLocalStore (
54
+ STORAGE_KEYS . LAST_CONNECTED_WALLET ,
55
+ JSON . stringify ( labels . filter ( walletLabel => walletLabel !== label ) )
56
+ )
57
+ }
58
+ if ( typeof labels === 'string' && labels === label ) {
59
+ delLocalStore ( STORAGE_KEYS . LAST_CONNECTED_WALLET )
60
+ }
61
+ } catch ( e ) {
62
+ console . error (
63
+ `There was an error disconnecting the last connected wallet from localStorage - Error: ${ e } `
55
64
)
56
65
}
57
- if ( typeof labels === 'string' && labels === label ) {
58
- delLocalStore ( STORAGE_KEYS . LAST_CONNECTED_WALLET )
59
- }
60
66
}
61
67
62
68
return state . get ( ) . wallets
Original file line number Diff line number Diff line change @@ -290,6 +290,12 @@ function init(options: InitOptions): OnboardAPI {
290
290
) {
291
291
connectAllPreviousWallets ( lastConnectedWalletsParsed , connect )
292
292
}
293
+ if (
294
+ lastConnectedWalletsParsed &&
295
+ typeof lastConnectedWalletsParsed === 'string'
296
+ ) {
297
+ connectAllPreviousWallets ( [ lastConnectedWalletsParsed ] , connect )
298
+ }
293
299
} catch ( err ) {
294
300
// Handle for legacy single wallet approach
295
301
// Above try will throw syntax error is local storage is not json
You can’t perform that action at this time.
0 commit comments