@multiplatform.one/web3 7.88.10 → 7.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/web3",
3
- "version": "7.88.10",
3
+ "version": "7.89.0",
4
4
  "description": "Web3 wallet integration for multiplatform.one ecosystem with ConnectKit and wagmi",
5
5
  "keywords": [
6
6
  "connectkit",
@@ -120,10 +120,10 @@
120
120
  "@aave/account": "^0.2.1",
121
121
  "@coinbase/wallet-sdk": "^4.4.0",
122
122
  "@metamask/connect-evm": "^2.1.1",
123
- "@multiplatform.one/connectkit": "^7.88.10",
124
- "@multiplatform.one/gpg": "^7.88.10",
125
- "@multiplatform.one/platform": "^7.88.10",
126
- "@multiplatform.one/theme": "^7.88.10",
123
+ "@multiplatform.one/connectkit": "^7.89.0",
124
+ "@multiplatform.one/gpg": "^7.89.0",
125
+ "@multiplatform.one/platform": "^7.89.0",
126
+ "@multiplatform.one/theme": "^7.89.0",
127
127
  "@noble/ciphers": "^1.3.0",
128
128
  "@noble/curves": "^1.9.7",
129
129
  "@phosphor-icons/react": "^2.1.10",
@@ -147,8 +147,8 @@
147
147
  "wagmi": "^3.7.1"
148
148
  },
149
149
  "devDependencies": {
150
- "@multiplatform.one/config": "7.88.10",
151
- "@multiplatform.one/test-utils": "7.88.10",
150
+ "@multiplatform.one/config": "7.89.0",
151
+ "@multiplatform.one/test-utils": "7.89.0",
152
152
  "@tamagui/build": "2.7.6",
153
153
  "@tanstack/react-query": "^5.104.3",
154
154
  "@testing-library/jest-dom": "^7.0.1",
@@ -14,7 +14,7 @@ export function createBridgeConnector(bridge: BridgeClient): CreateConnectorFn {
14
14
  let provider: BridgeProvider | undefined;
15
15
 
16
16
  const getProvider = async (): Promise<BridgeProvider> => {
17
- if (!provider) provider = createBridgeProvider(bridge);
17
+ provider ??= createBridgeProvider(bridge);
18
18
  return provider;
19
19
  };
20
20
 
@@ -0,0 +1,79 @@
1
+ // @vitest-environment happy-dom
2
+ import React from "react";
3
+ import { afterEach, describe, expect, it, vi } from "vitest";
4
+ import { act, cleanup, render, waitFor } from "@testing-library/react";
5
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
6
+ import { WagmiProvider, createConfig, createStorage, http } from "wagmi";
7
+ import { mock } from "wagmi/connectors";
8
+ import { mainnet } from "wagmi/chains";
9
+
10
+ import { ConnectKitProvider, useModal } from ".";
11
+
12
+ const ACCOUNT = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
13
+ const TRANSITION_MS = 360;
14
+
15
+ function memoryStorage() {
16
+ const map = new Map<string, string>();
17
+ return {
18
+ getItem: (key: string) => map.get(key) ?? null,
19
+ setItem: (key: string, value: string) => void map.set(key, value),
20
+ removeItem: (key: string) => void map.delete(key),
21
+ };
22
+ }
23
+
24
+ let modal: ReturnType<typeof useModal> | undefined;
25
+ function GrabModal() {
26
+ modal = useModal();
27
+ return null;
28
+ }
29
+
30
+ function Harness() {
31
+ const [config] = React.useState(() =>
32
+ createConfig({
33
+ chains: [mainnet],
34
+ connectors: [mock({ accounts: [ACCOUNT], features: {} })],
35
+ transports: { [mainnet.id]: http() },
36
+ storage: createStorage({ storage: memoryStorage() }),
37
+ }),
38
+ );
39
+ const [client] = React.useState(() => new QueryClient());
40
+ return (
41
+ <WagmiProvider config={config}>
42
+ <QueryClientProvider client={client}>
43
+ <ConnectKitProvider>
44
+ <GrabModal />
45
+ </ConnectKitProvider>
46
+ </QueryClientProvider>
47
+ </WagmiProvider>
48
+ );
49
+ }
50
+
51
+ afterEach(() => {
52
+ vi.restoreAllMocks();
53
+ cleanup();
54
+ modal = undefined;
55
+ });
56
+
57
+ // FZ-9681: the modal's transition timer fired after test-web3's happy-dom
58
+ // window was gone and React threw "window is not defined" outside any test.
59
+ describe("connectkit Modal transition timer", () => {
60
+ it("clears every transition timer it set once the modal unmounts", async () => {
61
+ const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");
62
+ const clearTimeoutSpy = vi.spyOn(globalThis, "clearTimeout");
63
+ const { unmount } = render(<Harness />);
64
+ await waitFor(() => expect(modal).toBeDefined());
65
+
66
+ act(() => modal!.setOpen(true));
67
+ const transitionTimers = () =>
68
+ setTimeoutSpy.mock.calls.flatMap(([, delay], index) =>
69
+ delay === TRANSITION_MS ? [setTimeoutSpy.mock.results[index]?.value] : [],
70
+ );
71
+ await waitFor(() => expect(transitionTimers().length).toBeGreaterThan(0));
72
+
73
+ const timers = transitionTimers();
74
+ unmount();
75
+
76
+ const cleared = new Set(clearTimeoutSpy.mock.calls.map(([id]) => id));
77
+ expect(timers.filter((id) => !cleared.has(id))).toEqual([]);
78
+ });
79
+ });