Skip to content

Commit

Permalink
[thirdweb] fix: Initialize wallet connection status as unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Feb 27, 2025
1 parent 2ec6cc0 commit d423a9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-vans-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Initialize activeWalletConnectionStatus as 'unknown' instead of 'disconnected'
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("useAddConnectedWallet", () => {
},
);
const { result } = renderHook(() => useConnect(), { wrapper });
expect(statusResult.current).toEqual("disconnected");
expect(statusResult.current).toEqual("unknown");
await result.current.connect(async () => wallet);
expect(statusResult.current).toEqual("connected");

Expand All @@ -67,7 +67,7 @@ describe("useAddConnectedWallet", () => {
},
);
const { result } = renderHook(() => useConnect(), { wrapper });
expect(statusResult.current).toEqual("disconnected");
expect(statusResult.current).toEqual("unknown");
await result.current.connect(async () => wallet);
expect(statusResult.current).toEqual("connected");

Expand All @@ -85,7 +85,7 @@ describe("useAddConnectedWallet", () => {
wrapper,
},
);
expect(statusResult.current).toEqual("disconnected");
expect(statusResult.current).toEqual("unknown");
const { result } = renderHook(() => useConnect(), { wrapper });
await result.current.connect(async () => {
throw new Error("test");
Expand Down
8 changes: 6 additions & 2 deletions packages/thirdweb/src/wallets/manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import type { SmartWalletOptions } from "../smart/types.js";
import type { WalletId } from "../wallet-types.js";

type WalletIdToConnectedWalletMap = Map<string, Wallet>;
export type ConnectionStatus = "connected" | "disconnected" | "connecting";
export type ConnectionStatus =
| "connected"
| "disconnected"
| "connecting"
| "unknown";

const CONNECTED_WALLET_IDS = "thirdweb:connected-wallet-ids";
const LAST_ACTIVE_EOA_ID = "thirdweb:active-wallet-id";
Expand Down Expand Up @@ -47,7 +51,7 @@ export function createConnectionManager(storage: AsyncStorage) {
const activeAccountStore = createStore<Account | undefined>(undefined);
const activeWalletChainStore = createStore<Chain | undefined>(undefined);
const activeWalletConnectionStatusStore =
createStore<ConnectionStatus>("disconnected");
createStore<ConnectionStatus>("unknown");

const definedChainsStore = createStore<Map<number, Chain>>(new Map());

Expand Down

0 comments on commit d423a9d

Please sign in to comment.