From fa3a7c6cc03ee82f2384be74776ae205b9f5fce8 Mon Sep 17 00:00:00 2001 From: Manan Tank Date: Tue, 11 Jun 2024 03:15:41 +0530 Subject: [PATCH 1/3] Wallet connection manager fixes --- .changeset/fast-chairs-glow.md | 6 +++++ .../thirdweb/src/wallets/manager/index.ts | 24 ++++--------------- 2 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 .changeset/fast-chairs-glow.md diff --git a/.changeset/fast-chairs-glow.md b/.changeset/fast-chairs-glow.md new file mode 100644 index 00000000000..97dd45248c3 --- /dev/null +++ b/.changeset/fast-chairs-glow.md @@ -0,0 +1,6 @@ +--- +"thirdweb": patch +--- + +- Remove the feature that sets another connected wallet as active when disconnecting the current active wallet. +- Do not save personal wallet as a separate wallet in connected wallets list. diff --git a/packages/thirdweb/src/wallets/manager/index.ts b/packages/thirdweb/src/wallets/manager/index.ts index 2b8770cd9f8..c0be610fe97 100644 --- a/packages/thirdweb/src/wallets/manager/index.ts +++ b/packages/thirdweb/src/wallets/manager/index.ts @@ -75,22 +75,11 @@ export function createConnectionManager(storage: AsyncStorage) { const onWalletDisconnect = (wallet: Wallet) => { deleteConnectParamsFromStorage(storage, wallet.id); removeConnectedWallet(wallet); - - // there are still connected wallets, switch to the next one - if (connectedWallets.getValue().length > 0) { - const nextWallet = connectedWallets.getValue()[0] as Wallet; - setActiveWallet(nextWallet); - return; - } - - // if disconnecting the last wallet - if (activeWalletStore.getValue() === wallet) { - storage.removeItem(LAST_ACTIVE_EOA_ID); - activeAccountStore.setValue(undefined); - activeWalletChainStore.setValue(undefined); - activeWalletStore.setValue(undefined); - activeWalletConnectionStatusStore.setValue("disconnected"); - } + storage.removeItem(LAST_ACTIVE_EOA_ID); + activeAccountStore.setValue(undefined); + activeWalletChainStore.setValue(undefined); + activeWalletStore.setValue(undefined); + activeWalletConnectionStatusStore.setValue("disconnected"); }; const disconnectWallet = (wallet: Wallet) => { @@ -121,9 +110,6 @@ export function createConnectionManager(storage: AsyncStorage) { handleSetActiveWallet(activeWallet); - // add personal wallet to connected wallets list - addConnectedWallet(personalWallet); - if (personalWallet.id !== "smart") { await storage.setItem(LAST_ACTIVE_EOA_ID, personalWallet.id); } From 775bd75858fe81fd6dd1b15d5019e2b47124cdb1 Mon Sep 17 00:00:00 2001 From: Manan Tank Date: Tue, 11 Jun 2024 03:20:13 +0530 Subject: [PATCH 2/3] check for active --- packages/thirdweb/src/wallets/manager/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/thirdweb/src/wallets/manager/index.ts b/packages/thirdweb/src/wallets/manager/index.ts index c0be610fe97..e3e896f1449 100644 --- a/packages/thirdweb/src/wallets/manager/index.ts +++ b/packages/thirdweb/src/wallets/manager/index.ts @@ -75,11 +75,15 @@ export function createConnectionManager(storage: AsyncStorage) { const onWalletDisconnect = (wallet: Wallet) => { deleteConnectParamsFromStorage(storage, wallet.id); removeConnectedWallet(wallet); - storage.removeItem(LAST_ACTIVE_EOA_ID); - activeAccountStore.setValue(undefined); - activeWalletChainStore.setValue(undefined); - activeWalletStore.setValue(undefined); - activeWalletConnectionStatusStore.setValue("disconnected"); + + // if disconnecting the active wallet + if (activeWalletStore.getValue() === wallet) { + storage.removeItem(LAST_ACTIVE_EOA_ID); + activeAccountStore.setValue(undefined); + activeWalletChainStore.setValue(undefined); + activeWalletStore.setValue(undefined); + activeWalletConnectionStatusStore.setValue("disconnected"); + } }; const disconnectWallet = (wallet: Wallet) => { From 2f9c4067b09634356d6ba15432635ff144ec2514 Mon Sep 17 00:00:00 2001 From: Manan Tank Date: Tue, 11 Jun 2024 03:36:59 +0530 Subject: [PATCH 3/3] set personal --- packages/thirdweb/src/wallets/manager/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/thirdweb/src/wallets/manager/index.ts b/packages/thirdweb/src/wallets/manager/index.ts index e3e896f1449..12597ed5cf2 100644 --- a/packages/thirdweb/src/wallets/manager/index.ts +++ b/packages/thirdweb/src/wallets/manager/index.ts @@ -114,6 +114,9 @@ export function createConnectionManager(storage: AsyncStorage) { handleSetActiveWallet(activeWallet); + // add personal wallet to connected wallets list + addConnectedWallet(personalWallet); + if (personalWallet.id !== "smart") { await storage.setItem(LAST_ACTIVE_EOA_ID, personalWallet.id); }