@coin-voyage/swapkit 0.5.0 → 0.5.2

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.
@@ -1,4 +1,4 @@
1
- import { ChainType } from "@coin-voyage/shared/types";
1
+ import type { ChainType } from "@coin-voyage/shared/types";
2
2
  interface WalletConnectorProps {
3
3
  open: boolean;
4
4
  chainType?: ChainType;
@@ -1,20 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createWalletConnectModalConnector } from "@coin-voyage/crypto/connectors";
3
- import { useInstalledWallets, useUniversalConnect } from "@coin-voyage/crypto/hooks";
4
- import { getConnectorId, getErrorMessage, isWalletConnectionCancelledError } from "@coin-voyage/crypto/utils";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useInstalledWallets } from "@coin-voyage/crypto/hooks";
5
3
  import { getChainTypeName } from "@coin-voyage/shared/chain";
6
- import { ChainType } from "@coin-voyage/shared/types";
7
- import { useMemo, useRef, useState } from "react";
8
- import { EmptyState, Hint, MultichainBadge, WalletList, WalletOption, WalletOptionMeta, WalletSwitchButton, } from "./styles";
4
+ import { useMemo, useState } from "react";
5
+ import { useWalletConnection } from "../hooks/use-wallet-connection";
6
+ import { EmptyState, ErrorBox, Hint, MultichainBadge, PrimaryButton, WalletList, WalletOption, WalletOptionMeta, WalletSwitchButton, } from "./styles";
9
7
  import { Modal } from "./modal";
10
8
  import { WalletIconDisplay } from "./wallet-icon";
11
9
  const getWalletDisplayName = (wallet) => wallet.id.toLowerCase() === "walletconnect" ? "Mobile Wallets" : wallet.name;
12
- const addWalletConnectModalStyle = () => {
13
- const style = document.createElement("style");
14
- style.textContent = "w3m-modal, wcm-modal { --wcm-z-index: 2147483647; --w3m-z-index: 2147483647; }";
15
- document.head.appendChild(style);
16
- return style;
17
- };
18
10
  export function WalletConnector(props) {
19
11
  if (!props.open)
20
12
  return null;
@@ -25,55 +17,12 @@ function OpenWalletConnector({ chainType, intent = "connect", beforeConnect, onC
25
17
  const wallets = useMemo(() => chainType
26
18
  ? installedWallets.filter((wallet) => wallet.connectors.some((connector) => connector.chainType === chainType))
27
19
  : installedWallets, [chainType, installedWallets]);
28
- const [error, setError] = useState(null);
29
- const [pending, setPending] = useState(false);
20
+ const { pendingLabel, error, connect, cancel } = useWalletConnection(onClose, beforeConnect);
30
21
  const [selectedWallet, setSelectedWallet] = useState(null);
31
- const pendingRef = useRef(false);
22
+ const pending = pendingLabel !== null;
32
23
  const selectedConnectors = selectedWallet
33
24
  ? selectedWallet.connectors.filter((connector, index, connectors) => connectors.findIndex((candidate) => candidate.chainType === connector.chainType) === index)
34
25
  : [];
35
- const close = () => {
36
- pendingRef.current = false;
37
- onClose();
38
- };
39
- const showError = (error) => {
40
- if (isWalletConnectionCancelledError(error))
41
- return;
42
- setError(getErrorMessage(error) || "Unable to connect wallet");
43
- };
44
- const { connect } = useUniversalConnect({
45
- onSuccess: close,
46
- onError: showError,
47
- });
48
- const handleConnect = async (connector) => {
49
- if (pendingRef.current)
50
- return;
51
- pendingRef.current = true;
52
- setPending(true);
53
- setError(null);
54
- let walletConnectModalStyle;
55
- try {
56
- await beforeConnect?.();
57
- const connectorId = getConnectorId(connector.connector);
58
- const isWalletConnect = connectorId?.toLowerCase().includes("walletconnect");
59
- if (isWalletConnect)
60
- walletConnectModalStyle = addWalletConnectModalStyle();
61
- const walletConnector = connector.chainType === ChainType.EVM && isWalletConnect
62
- ? { ...connector, connector: await createWalletConnectModalConnector(connector.connector) }
63
- : connector;
64
- await connect({ walletConnector });
65
- }
66
- catch (error) {
67
- showError(error);
68
- }
69
- finally {
70
- walletConnectModalStyle?.remove();
71
- const shouldUpdatePending = pendingRef.current;
72
- pendingRef.current = false;
73
- if (shouldUpdatePending)
74
- setPending(false);
75
- }
76
- };
77
26
  const chooseWallet = (wallet) => {
78
27
  const connectors = wallet.connectors.filter(({ chainType: connectorChainType }) => !chainType || connectorChainType === chainType);
79
28
  if (!chainType && new Set(connectors.map((connector) => connector.chainType)).size > 1) {
@@ -81,14 +30,14 @@ function OpenWalletConnector({ chainType, intent = "connect", beforeConnect, onC
81
30
  return;
82
31
  }
83
32
  if (connectors[0])
84
- void handleConnect(connectors[0]);
33
+ void connect(connectors[0], getWalletDisplayName(wallet));
85
34
  };
86
35
  const modalTitle = selectedWallet ? "Choose network" : intent === "switch" ? "Switch wallet" : "Connect wallet";
87
- return (_jsxs(Modal, { open: true, title: modalTitle, onClose: close, closeDisabled: pending, children: [selectedWallet && (_jsx(WalletSwitchButton, { type: "button", disabled: pending, onClick: () => setSelectedWallet(null), children: "Back" })), _jsx(WalletList, { "aria-busy": pending, children: selectedWallet
36
+ return (_jsxs(Modal, { open: true, title: modalTitle, onClose: onClose, preventDismiss: pending, children: [selectedWallet && (_jsx(WalletSwitchButton, { type: "button", disabled: pending, onClick: () => setSelectedWallet(null), children: "Back" })), _jsx(WalletList, { "aria-busy": pending, children: selectedWallet
88
37
  ? selectedConnectors.map((connector) => {
89
38
  const chainName = getChainTypeName(connector.chainType);
90
39
  const walletName = getWalletDisplayName(selectedWallet);
91
- return (_jsxs(WalletOption, { type: "button", disabled: pending, "aria-label": `Connect ${walletName} on ${chainName}`, onClick: () => void handleConnect(connector), children: [_jsx(WalletIconDisplay, { icon: selectedWallet.icon, name: chainName }), _jsxs(WalletOptionMeta, { children: [_jsx("span", { children: _jsx("strong", { children: chainName }) }), _jsxs("small", { children: [chainName, " network"] })] })] }, connector.chainType));
40
+ return (_jsxs(WalletOption, { type: "button", disabled: pending, "aria-label": `Connect ${walletName} on ${chainName}`, onClick: () => void connect(connector, walletName), children: [_jsx(WalletIconDisplay, { icon: selectedWallet.icon, name: chainName }), _jsxs(WalletOptionMeta, { children: [_jsx("span", { children: _jsx("strong", { children: chainName }) }), _jsxs("small", { children: [chainName, " network"] })] })] }, connector.chainType));
92
41
  })
93
42
  : wallets.map((wallet) => {
94
43
  const connector = wallet.connectors.find((candidate) => !chainType || candidate.chainType === chainType);
@@ -98,5 +47,5 @@ function OpenWalletConnector({ chainType, intent = "connect", beforeConnect, onC
98
47
  const chainTypes = [...new Set(wallet.connectors.map(({ chainType }) => chainType))];
99
48
  const capabilityLabel = chainTypes.map(getChainTypeName).join(" · ");
100
49
  return (_jsxs(WalletOption, { type: "button", disabled: pending, "aria-label": `${intent === "switch" ? "Switch to" : "Connect"} ${walletName} wallet`, onClick: () => chooseWallet(wallet), children: [_jsx(WalletIconDisplay, { icon: wallet.icon, name: walletName }), _jsxs(WalletOptionMeta, { children: [_jsxs("span", { children: [_jsx("strong", { children: walletName }), chainTypes.length > 1 && _jsx(MultichainBadge, { children: "Multichain" })] }), _jsx("small", { children: chainTypes.length > 1 ? capabilityLabel : `${capabilityLabel} wallet` })] })] }, wallet.id));
101
- }) }), !selectedWallet && wallets.length === 0 && _jsx(EmptyState, { children: "No compatible installed wallets found" }), error && (_jsx(Hint, { "$tone": "danger", role: "alert", children: error }))] }));
50
+ }) }), !selectedWallet && wallets.length === 0 && _jsx(EmptyState, { children: "No compatible installed wallets found" }), pending && (_jsxs(_Fragment, { children: [_jsxs(Hint, { role: "status", children: ["Waiting for ", pendingLabel, ". Open your wallet to approve the request."] }), _jsx(PrimaryButton, { type: "button", style: { marginTop: 12 }, onClick: cancel, children: "Cancel" })] })), error && (_jsxs(ErrorBox, { role: "alert", style: { marginTop: 12 }, children: [_jsx("strong", { children: error.title }), _jsx("div", { children: error.details }), _jsx("div", { children: "Unlock your wallet, check it for open requests, and try again." })] }))] }));
102
51
  }
@@ -8,7 +8,6 @@ import { WalletConnector } from "./wallet-connector";
8
8
  import { Overlay } from "./styles";
9
9
  const connectWallet = vi.fn();
10
10
  const createWalletConnectModalConnector = vi.fn();
11
- let connectErrorHandler;
12
11
  let installedWallets = [
13
12
  {
14
13
  id: "phantom",
@@ -18,22 +17,19 @@ let installedWallets = [
18
17
  ];
19
18
  vi.mock("@coin-voyage/crypto/hooks", () => ({
20
19
  useInstalledWallets: () => installedWallets,
21
- useUniversalConnect: ({ onError }) => {
22
- connectErrorHandler = onError;
23
- return { connect: connectWallet };
24
- },
20
+ useUniversalConnect: () => ({ connect: connectWallet }),
25
21
  }));
26
22
  vi.mock("@coin-voyage/crypto/connectors", () => ({
27
23
  createWalletConnectModalConnector: (...args) => createWalletConnectModalConnector(...args),
28
24
  }));
29
25
  vi.mock("./modal", () => ({
30
- Modal: ({ open, title, closeDisabled, children, }) => open ? (_jsx("div", { role: "dialog", "aria-label": title, "data-close-disabled": closeDisabled || undefined, children: children })) : null,
26
+ Modal: ({ open, title, preventDismiss, children, }) => open ? (_jsx("div", { role: "dialog", "aria-label": title, "data-prevent-dismiss": preventDismiss || undefined, children: children })) : null,
31
27
  }));
32
28
  afterEach(() => {
33
29
  cleanup();
30
+ vi.useRealTimers();
34
31
  connectWallet.mockReset();
35
32
  createWalletConnectModalConnector.mockReset();
36
- connectErrorHandler = undefined;
37
33
  installedWallets = [
38
34
  {
39
35
  id: "phantom",
@@ -63,7 +59,7 @@ describe("WalletConnector", () => {
63
59
  await user.dblClick(option);
64
60
  expect(connectWallet).toHaveBeenCalledTimes(1);
65
61
  expect(option.hasAttribute("disabled")).toBe(true);
66
- expect(screen.getByRole("dialog").getAttribute("data-close-disabled")).toBe("true");
62
+ expect(screen.getByRole("dialog").getAttribute("data-prevent-dismiss")).toBe("true");
67
63
  finishConnect?.();
68
64
  await waitFor(() => expect(option.hasAttribute("disabled")).toBe(false));
69
65
  });
@@ -128,16 +124,82 @@ describe("WalletConnector", () => {
128
124
  failConnect?.();
129
125
  await waitFor(() => expect([...document.head.querySelectorAll("style")].some((style) => style.textContent?.includes("--w3m-z-index: 2147483647"))).toBe(false));
130
126
  });
131
- it("does not show viem's resource-unavailable error when the wallet prompt is closed", () => {
127
+ it("does not show viem's resource-unavailable error when the wallet prompt is closed", async () => {
128
+ connectWallet.mockRejectedValue(new Error("Requested resource not available. Details: Requested resource not available. Version: viem@2.55.10"));
132
129
  render(_jsx(WalletConnector, { open: true, onClose: vi.fn() }));
133
- act(() => {
134
- connectErrorHandler?.(new Error("Requested resource not available. Details: Requested resource not available. Version: viem@2.55.10"));
135
- });
130
+ await userEvent.click(screen.getByRole("button", { name: "Connect Phantom wallet" }));
131
+ expect(connectWallet).toHaveBeenCalledTimes(1);
132
+ expect(screen.queryByRole("alert")).toBeNull();
133
+ });
134
+ it("names the wallet and network and shows actionable error details", async () => {
135
+ connectWallet.mockRejectedValue({ code: -32603, message: "Unexpected error" });
136
+ const onClose = vi.fn();
137
+ render(_jsx(WalletConnector, { open: true, onClose: onClose }));
138
+ await userEvent.click(screen.getByRole("button", { name: "Connect Phantom wallet" }));
139
+ const alert = screen.getByRole("alert").textContent;
140
+ expect(alert).toContain("Couldn't connect Phantom on Solana");
141
+ expect(alert).toContain("Unexpected error (code -32603)");
142
+ expect(onClose).not.toHaveBeenCalled();
143
+ });
144
+ it.each([
145
+ ["success", (late) => late.resolve()],
146
+ ["failure", (late) => late.reject(new Error("Too late"))],
147
+ ])("cancels a pending request and ignores its late %s", async (_result, settle) => {
148
+ const late = Promise.withResolvers();
149
+ connectWallet.mockReturnValue(late.promise);
150
+ const onClose = vi.fn();
151
+ render(_jsx(WalletConnector, { open: true, onClose: onClose }));
152
+ const option = screen.getByRole("button", { name: "Connect Phantom wallet" });
153
+ await userEvent.click(option);
154
+ await userEvent.click(screen.getByRole("button", { name: "Cancel" }));
155
+ await act(async () => settle(late));
156
+ expect(option.hasAttribute("disabled")).toBe(false);
157
+ expect(onClose).not.toHaveBeenCalled();
136
158
  expect(screen.queryByRole("alert")).toBeNull();
137
159
  });
138
- it("still shows actionable connection errors", () => {
160
+ it("explains a request that is still open in the wallet when retrying after a cancel", async () => {
161
+ connectWallet
162
+ .mockReturnValueOnce(new Promise(() => { }))
163
+ .mockRejectedValueOnce(new Error("Requested resource not available."))
164
+ .mockResolvedValueOnce(undefined);
165
+ const onClose = vi.fn();
166
+ render(_jsx(WalletConnector, { open: true, onClose: onClose }));
167
+ const option = screen.getByRole("button", { name: "Connect Phantom wallet" });
168
+ await userEvent.click(option);
169
+ await userEvent.click(screen.getByRole("button", { name: "Cancel" }));
170
+ await userEvent.click(option);
171
+ expect(screen.getByRole("alert").textContent).toContain("Requested resource not available.");
172
+ await userEvent.click(option);
173
+ expect(onClose).toHaveBeenCalledTimes(1);
174
+ });
175
+ it("ignores a late success after the dialog is closed", async () => {
176
+ let finish;
177
+ connectWallet.mockReturnValue(new Promise((resolve) => (finish = resolve)));
178
+ const onClose = vi.fn();
179
+ const { unmount } = render(_jsx(WalletConnector, { open: true, onClose: onClose }));
180
+ await userEvent.click(screen.getByRole("button", { name: "Connect Phantom wallet" }));
181
+ unmount();
182
+ await act(async () => finish());
183
+ expect(onClose).not.toHaveBeenCalled();
184
+ });
185
+ it("does not connect when cancelled while the previous wallet disconnects", async () => {
186
+ let finishDisconnect;
187
+ const beforeConnect = () => new Promise((resolve) => (finishDisconnect = resolve));
188
+ render(_jsx(WalletConnector, { open: true, beforeConnect: beforeConnect, onClose: vi.fn() }));
189
+ await userEvent.click(screen.getByRole("button", { name: "Connect Phantom wallet" }));
190
+ await userEvent.click(screen.getByRole("button", { name: "Cancel" }));
191
+ await act(async () => finishDisconnect());
192
+ expect(connectWallet).not.toHaveBeenCalled();
193
+ });
194
+ it("times out when the wallet never responds", async () => {
195
+ vi.useFakeTimers();
196
+ connectWallet.mockReturnValue(new Promise(() => { }));
139
197
  render(_jsx(WalletConnector, { open: true, onClose: vi.fn() }));
140
- act(() => connectErrorHandler?.(new Error("Wallet provider unavailable")));
141
- expect(screen.getByRole("alert").textContent).toBe("Wallet provider unavailable");
198
+ const option = screen.getByRole("button", { name: "Connect Phantom wallet" });
199
+ act(() => option.click());
200
+ expect(option.hasAttribute("disabled")).toBe(true);
201
+ await act(() => vi.advanceTimersByTimeAsync(60000));
202
+ expect(screen.getByRole("alert").textContent).toContain("No response after 60 seconds");
203
+ expect(option.hasAttribute("disabled")).toBe(false);
142
204
  });
143
205
  });
@@ -0,0 +1,10 @@
1
+ import type { ChainTypeWalletConnector } from "@coin-voyage/crypto/types";
2
+ export declare function useWalletConnection(onConnected: () => void, beforeConnect?: () => Promise<unknown>): {
3
+ pendingLabel: string | null;
4
+ error: {
5
+ title: string;
6
+ details: string;
7
+ } | null;
8
+ connect: (wallet: ChainTypeWalletConnector, walletName: string) => Promise<void>;
9
+ cancel: () => void | undefined;
10
+ };
@@ -0,0 +1,71 @@
1
+ import { createWalletConnectModalConnector } from "@coin-voyage/crypto/connectors";
2
+ import { useUniversalConnect } from "@coin-voyage/crypto/hooks";
3
+ import { getConnectorId, getErrorDetails, isUserRejectedError, isWalletConnectionCancelledError, } from "@coin-voyage/crypto/utils";
4
+ import { getChainTypeName } from "@coin-voyage/shared/chain";
5
+ import { ChainType } from "@coin-voyage/shared/types";
6
+ import { useEffect, useRef, useState } from "react";
7
+ const CONNECT_TIMEOUT_MS = 60000;
8
+ const addWalletConnectModalStyle = () => {
9
+ const style = document.createElement("style");
10
+ style.textContent = "w3m-modal, wcm-modal { --wcm-z-index: 2147483647; --w3m-z-index: 2147483647; }";
11
+ document.head.appendChild(style);
12
+ return style;
13
+ };
14
+ export function useWalletConnection(onConnected, beforeConnect) {
15
+ const { connect: connectWallet } = useUniversalConnect();
16
+ const [pendingLabel, setPendingLabel] = useState(null);
17
+ const [error, setError] = useState(null);
18
+ const controllerRef = useRef(null);
19
+ const abandonedRef = useRef(false);
20
+ const cancel = () => controllerRef.current?.abort();
21
+ useEffect(() => cancel, []);
22
+ const connect = async (wallet, walletName) => {
23
+ const label = `${walletName} on ${getChainTypeName(wallet.chainType)}`;
24
+ const isWalletConnect = getConnectorId(wallet.connector)?.toLowerCase().includes("walletconnect");
25
+ const controller = new AbortController();
26
+ const { signal } = controller;
27
+ const aborted = new Promise((_, reject) => {
28
+ signal.addEventListener("abort", () => reject(signal.reason));
29
+ });
30
+ const timeout = setTimeout(() => {
31
+ if (!isWalletConnect)
32
+ controller.abort(new Error(`No response after ${CONNECT_TIMEOUT_MS / 1000} seconds`));
33
+ }, CONNECT_TIMEOUT_MS);
34
+ let modalStyle;
35
+ const run = async () => {
36
+ await beforeConnect?.();
37
+ signal.throwIfAborted();
38
+ if (isWalletConnect)
39
+ modalStyle = addWalletConnectModalStyle();
40
+ const walletConnector = isWalletConnect && wallet.chainType === ChainType.EVM
41
+ ? { ...wallet, connector: await createWalletConnectModalConnector(wallet.connector) }
42
+ : wallet;
43
+ signal.throwIfAborted();
44
+ await connectWallet({ walletConnector });
45
+ };
46
+ controllerRef.current = controller;
47
+ setPendingLabel(label);
48
+ setError(null);
49
+ try {
50
+ await Promise.race([run(), aborted]);
51
+ onConnected();
52
+ }
53
+ catch (error) {
54
+ abandonedRef.current || (abandonedRef.current = signal.aborted);
55
+ const isCancelled = abandonedRef.current ? isUserRejectedError : isWalletConnectionCancelledError;
56
+ const cancelledHere = error instanceof DOMException && error === signal.reason;
57
+ if (cancelledHere || isCancelled(error))
58
+ return;
59
+ setError({
60
+ title: `Couldn't connect ${label}`,
61
+ details: getErrorDetails(error) || "The wallet returned no error details",
62
+ });
63
+ }
64
+ finally {
65
+ clearTimeout(timeout);
66
+ modalStyle?.remove();
67
+ setPendingLabel(null);
68
+ }
69
+ };
70
+ return { pendingLabel, error, connect, cancel };
71
+ }
@@ -2,23 +2,23 @@ import { css } from "styled-components";
2
2
  import styled from "./styled";
3
3
  import { darkTheme, lightTheme } from "./theme";
4
4
  function variables(theme) {
5
- return css `
6
- --sk-font-family: ${theme.fontFamily};
7
- --sk-background: ${theme.background};
8
- --sk-surface: ${theme.surface};
9
- --sk-surface-elevated: ${theme.surfaceElevated};
10
- --sk-border: ${theme.border};
11
- --sk-text: ${theme.text};
12
- --sk-text-muted: ${theme.textMuted};
13
- --sk-accent: ${theme.accent};
14
- --sk-accent-hover: ${theme.accentHover};
15
- --sk-accent-text: ${theme.accentText};
16
- --sk-danger: ${theme.danger};
17
- --sk-warning: ${theme.warning};
18
- --sk-success: ${theme.success};
19
- --sk-overlay: ${theme.overlay};
20
- --sk-shadow: ${theme.shadow};
21
- --sk-radius: ${theme.radius};
5
+ return css `
6
+ --sk-font-family: ${theme.fontFamily};
7
+ --sk-background: ${theme.background};
8
+ --sk-surface: ${theme.surface};
9
+ --sk-surface-elevated: ${theme.surfaceElevated};
10
+ --sk-border: ${theme.border};
11
+ --sk-text: ${theme.text};
12
+ --sk-text-muted: ${theme.textMuted};
13
+ --sk-accent: ${theme.accent};
14
+ --sk-accent-hover: ${theme.accentHover};
15
+ --sk-accent-text: ${theme.accentText};
16
+ --sk-danger: ${theme.danger};
17
+ --sk-warning: ${theme.warning};
18
+ --sk-success: ${theme.success};
19
+ --sk-overlay: ${theme.overlay};
20
+ --sk-shadow: ${theme.shadow};
21
+ --sk-radius: ${theme.radius};
22
22
  `;
23
23
  }
24
24
  function modeVariables(mode, customTheme) {
@@ -28,48 +28,48 @@ function modeVariables(mode, customTheme) {
28
28
  return variables(light);
29
29
  if (mode === "dark")
30
30
  return variables(dark);
31
- return css `
32
- ${variables(light)}
33
- @media (prefers-color-scheme: dark) {
34
- ${variables(dark)}
35
- }
31
+ return css `
32
+ ${variables(light)}
33
+ @media (prefers-color-scheme: dark) {
34
+ ${variables(dark)}
35
+ }
36
36
  `;
37
37
  }
38
- export const SwapKitRoot = styled.div `
39
- ${({ $mode, $customTheme }) => modeVariables($mode, $customTheme)}
40
-
41
- all: initial;
42
- display: block;
43
- width: 100%;
44
- color: var(--sk-text);
45
- background: ${({ $customTheme }) => $customTheme.background ?? "transparent"};
46
- font-family: var(--sk-font-family);
47
- font-size: 16px;
48
- text-align: left;
49
- text-rendering: optimizeLegibility;
50
- -webkit-font-smoothing: antialiased;
51
-
52
- &,
53
- * {
54
- box-sizing: border-box;
55
- font-family: var(--sk-font-family);
56
- }
57
-
58
- button,
59
- input {
60
- font-family: var(--sk-font-family);
61
- }
62
-
63
- button:focus-visible,
64
- input:focus-visible,
65
- a:focus-visible {
66
- outline: 2px solid var(--sk-accent);
67
- outline-offset: 2px;
68
- }
69
-
70
- img,
71
- svg {
72
- display: block;
73
- max-width: 100%;
74
- }
38
+ export const SwapKitRoot = styled.div `
39
+ ${({ $mode, $customTheme }) => modeVariables($mode, $customTheme)}
40
+
41
+ all: initial;
42
+ display: block;
43
+ width: 100%;
44
+ color: var(--sk-text);
45
+ background: ${({ $customTheme }) => $customTheme.background ?? "transparent"};
46
+ font-family: var(--sk-font-family);
47
+ font-size: 16px;
48
+ text-align: left;
49
+ text-rendering: optimizeLegibility;
50
+ -webkit-font-smoothing: antialiased;
51
+
52
+ &,
53
+ * {
54
+ box-sizing: border-box;
55
+ font-family: var(--sk-font-family);
56
+ }
57
+
58
+ button,
59
+ input {
60
+ font-family: var(--sk-font-family);
61
+ }
62
+
63
+ button:focus-visible,
64
+ input:focus-visible,
65
+ a:focus-visible {
66
+ outline: 2px solid var(--sk-accent);
67
+ outline-offset: 2px;
68
+ }
69
+
70
+ img,
71
+ svg {
72
+ display: block;
73
+ max-width: 100%;
74
+ }
75
75
  `;
package/package.json CHANGED
@@ -1,19 +1,25 @@
1
1
  {
2
2
  "name": "@coin-voyage/swapkit",
3
3
  "description": "A reusable cross-chain swap component for CoinVoyage.",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "author": "Lars <lars@coinvoyage.io>",
8
8
  "homepage": "https://coinvoyage.io",
9
9
  "license": "BSD-2-Clause",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/coin-voyage/coin-voyage-pay.git",
13
+ "directory": "packages/swapkit"
14
+ },
10
15
  "type": "module",
11
16
  "main": "./dist/index.js",
12
17
  "types": "./dist/index.d.ts",
13
18
  "exports": {
14
19
  ".": {
20
+ "types": "./dist/index.d.ts",
15
21
  "import": "./dist/index.js",
16
- "types": "./dist/index.d.ts"
22
+ "default": "./dist/index.js"
17
23
  }
18
24
  },
19
25
  "files": [
@@ -22,8 +28,8 @@
22
28
  "LICENSE"
23
29
  ],
24
30
  "dependencies": {
25
- "@coin-voyage/crypto": "3.7.0",
26
- "@coin-voyage/shared": "3.7.0"
31
+ "@coin-voyage/shared": "3.8.0",
32
+ "@coin-voyage/crypto": "3.8.0"
27
33
  },
28
34
  "devDependencies": {
29
35
  "@testing-library/react": "^16.3.0",