Skip to content

Commit

Permalink
[SDK] fix: Initialize wallet connection status as unknown (#6360)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges authored Feb 28, 2025
1 parent d8e9245 commit 6235fe7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 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'
8 changes: 4 additions & 4 deletions packages/thirdweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@
"clean": "rimraf dist",
"size": "size-limit",
"test:watch": "vitest -c ./test/vitest.config.ts dev",
"test": "vitest run -c ./test/vitest.config.ts --coverage",
"test:cov": "vitest dev -c ./test/vitest.config.ts --coverage",
"test:ui": "vitest dev -c ./test/vitest.config.ts --coverage --ui",
"test:dev": "vitest run -c ./test/vitest.config.ts",
"test": "NODE_OPTIONS=--max-old-space-size=8192 vitest run -c ./test/vitest.config.ts --coverage",
"test:cov": "NODE_OPTIONS=--max-old-space-size=8192 vitest dev -c ./test/vitest.config.ts --coverage",
"test:ui": "NODE_OPTIONS=--max-old-space-size=8192 vitest dev -c ./test/vitest.config.ts --coverage --ui",
"test:dev": "NODE_OPTIONS=--max-old-space-size=8192 vitest run -c ./test/vitest.config.ts",
"test:react": "vitest run -c ./test/vitest.config.ts dev --ui src/react",
"typedoc": "node scripts/typedoc.mjs && node scripts/parse.mjs",
"update-version": "node scripts/version.mjs",
Expand Down
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
4 changes: 3 additions & 1 deletion packages/thirdweb/test/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export default defineConfig({
globalSetup: [join(__dirname, "./globalSetup.ts")],
testTimeout: 90_000,
retry: 3,
maxConcurrency: 3,
maxConcurrency: 1,
maxWorkers: 4,
minWorkers: 2,
bail: 1,
// clear any mocks between any tests
clearMocks: true,
Expand Down

0 comments on commit 6235fe7

Please sign in to comment.