@nexus-cross/connect-kit-react 1.3.0-beta.1 → 1.3.1

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.
Files changed (50) hide show
  1. package/dist/chunk-ZL2BHNN6.js +143 -0
  2. package/dist/client.d.ts +46 -4
  3. package/dist/client.js +1 -3
  4. package/dist/index.d.ts +378 -28
  5. package/dist/index.js +1 -19
  6. package/package.json +11 -8
  7. package/dist/client.d.ts.map +0 -1
  8. package/dist/client.js.map +0 -1
  9. package/dist/components/ConnectButton.d.ts +0 -102
  10. package/dist/components/ConnectButton.d.ts.map +0 -1
  11. package/dist/components/ConnectButton.js +0 -584
  12. package/dist/components/ConnectButton.js.map +0 -1
  13. package/dist/components/CrossConnectKitProvider.d.ts +0 -38
  14. package/dist/components/CrossConnectKitProvider.d.ts.map +0 -1
  15. package/dist/components/CrossConnectKitProvider.js +0 -790
  16. package/dist/components/CrossConnectKitProvider.js.map +0 -1
  17. package/dist/components/CrossConnectModal.d.ts +0 -20
  18. package/dist/components/CrossConnectModal.d.ts.map +0 -1
  19. package/dist/components/CrossConnectModal.js +0 -80
  20. package/dist/components/CrossConnectModal.js.map +0 -1
  21. package/dist/components/OtherWalletsModal.d.ts +0 -20
  22. package/dist/components/OtherWalletsModal.d.ts.map +0 -1
  23. package/dist/components/OtherWalletsModal.js +0 -300
  24. package/dist/components/OtherWalletsModal.js.map +0 -1
  25. package/dist/config/createConnectKitConfig.d.ts +0 -36
  26. package/dist/config/createConnectKitConfig.d.ts.map +0 -1
  27. package/dist/config/createConnectKitConfig.js +0 -80
  28. package/dist/config/createConnectKitConfig.js.map +0 -1
  29. package/dist/context/CrossConnectKitContext.d.ts +0 -100
  30. package/dist/context/CrossConnectKitContext.d.ts.map +0 -1
  31. package/dist/context/CrossConnectKitContext.js +0 -10
  32. package/dist/context/CrossConnectKitContext.js.map +0 -1
  33. package/dist/context/CrossConnectKitThemeContext.d.ts +0 -41
  34. package/dist/context/CrossConnectKitThemeContext.d.ts.map +0 -1
  35. package/dist/context/CrossConnectKitThemeContext.js +0 -22
  36. package/dist/context/CrossConnectKitThemeContext.js.map +0 -1
  37. package/dist/hooks/useCrossxEmbeddedInfo.d.ts +0 -41
  38. package/dist/hooks/useCrossxEmbeddedInfo.d.ts.map +0 -1
  39. package/dist/hooks/useCrossxEmbeddedInfo.js +0 -241
  40. package/dist/hooks/useCrossxEmbeddedInfo.js.map +0 -1
  41. package/dist/index.d.ts.map +0 -1
  42. package/dist/index.js.map +0 -1
  43. package/dist/runtime-log.d.ts +0 -2
  44. package/dist/runtime-log.d.ts.map +0 -1
  45. package/dist/runtime-log.js +0 -44
  46. package/dist/runtime-log.js.map +0 -1
  47. package/dist/version.d.ts +0 -2
  48. package/dist/version.d.ts.map +0 -1
  49. package/dist/version.js +0 -2
  50. package/dist/version.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,28 +1,378 @@
1
- export { CrossConnectKitProvider } from './components/CrossConnectKitProvider.js';
2
- export type { CrossConnectKitProviderProps } from './components/CrossConnectKitProvider.js';
3
- export { ConnectButton } from './components/ConnectButton.js';
4
- export type { ConnectButtonProps, WalletUser, WalletProvider, } from './components/ConnectButton.js';
5
- export { OtherWalletsModal } from './components/OtherWalletsModal.js';
6
- export type { OtherWalletsModalProps } from './components/OtherWalletsModal.js';
7
- export { CrossConnectModal } from './components/CrossConnectModal.js';
8
- export type { CrossConnectModalProps } from './components/CrossConnectModal.js';
9
- export { useCrossConnectKit } from './context/CrossConnectKitContext.js';
10
- export type { CrossConnectKitContextValue } from './context/CrossConnectKitContext.js';
11
- export { useCrossConnectKitTheme, useOptionalCrossConnectKitTheme, } from './context/CrossConnectKitThemeContext.js';
12
- export type { CrossConnectKitThemeContextValue } from './context/CrossConnectKitThemeContext.js';
13
- export { useCrossxEmbeddedInfo } from './hooks/useCrossxEmbeddedInfo.js';
14
- export type { CrossxEmbeddedInfo } from './hooks/useCrossxEmbeddedInfo.js';
15
- export { useOnRamp, useOnRampEligibility, OnRampProvider, } from '@nexus-cross/onramp/react';
16
- export type { UseOnRampResult, UseOnRampOptions, UseOnRampEligibilityResult, UseOnRampEligibilityOptions, OnRampProviderProps, } from '@nexus-cross/onramp/react';
17
- export { WalletInfo, ConnectorId } from '@nexus-cross/dapp-ui';
18
- export type { WalletInfoProps, WalletInfoStyle, WalletInfoTriggerProps, WalletInfoContentProps, SendTransactionArgs, SendTransactionFn, } from '@nexus-cross/dapp-ui';
19
- export { AppLauncher, AppLauncherTrigger, AppLauncherContent, useGlobalMenu, } from '@nexus-cross/dapp-ui';
20
- export type { AppLauncherProps, AppLauncherTriggerProps, AppLauncherTriggerStyle, AppLauncherContentProps, GlobalMenu, GlobalMenuItem, GlobalMenuItemUrl, } from '@nexus-cross/dapp-ui';
21
- export { SkillsButton } from '@nexus-cross/dapp-ui';
22
- export type { SkillsButtonProps, SkillsButtonStyle, } from '@nexus-cross/dapp-ui';
23
- export type { ConnectButtonStyle } from '@nexus-cross/dapp-ui';
24
- export type { Account, WalletState, WalletId, WalletDescriptor, ChainBalance, ConnectorType, Theme, ThemeMode, ColorOverrides, ThemeTokens, ModalView, CrossConnectKitConfig, OnRampEligibility, OnRampDisallowReason, OnRampOpenParams, OnRampSession, OnRampStatus, OnRampStatusEvent, OnRampProviderId, OnRampErrorCode, } from '@nexus-cross/connect-kit-core';
25
- export { OnRampError } from '@nexus-cross/connect-kit-core';
26
- export type { ConnectorEntry, ConnectorRegistry, } from '@nexus-cross/connect-kit-wagmi';
27
- export { ConnectionStatus, formatBalance, formatWei } from '@nexus-cross/connect-kit-core';
28
- //# sourceMappingURL=index.d.ts.map
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { CrossxConfig, CrossConnectKitInitialState, ConnectorRegistry, ConnectorEntry } from '@nexus-cross/connect-kit-wagmi';
4
+ export { ConnectorEntry, ConnectorRegistry } from '@nexus-cross/connect-kit-wagmi';
5
+ import { WalletId, CrossConnectKitConfig, OAuthPort, ThemeMode, ThemeTokens } from '@nexus-cross/connect-kit-core';
6
+ export { Account, ChainBalance, ColorOverrides, ConnectionStatus, ConnectorType, CrossConnectKitConfig, ModalView, OnRampDisallowReason, OnRampEligibility, OnRampError, OnRampErrorCode, OnRampOpenParams, OnRampProviderId, OnRampSession, OnRampStatus, OnRampStatusEvent, Theme, ThemeMode, ThemeTokens, WalletDescriptor, WalletId, WalletState, formatBalance, formatWei } from '@nexus-cross/connect-kit-core';
7
+ import { WalletInfoProps, ConnectButtonStyle, WalletInfoStyle, Environment, BridgeToken, BridgeHistoryItem, BridgeGetApprovalFn, BridgeApproveFn, BridgeQuoteFn, BridgeGetToTokensFn, BridgeSubmitFn } from '@nexus-cross/dapp-ui';
8
+ export { AppLauncher, AppLauncherContent, AppLauncherContentProps, AppLauncherProps, AppLauncherTrigger, AppLauncherTriggerProps, AppLauncherTriggerStyle, ConnectButtonStyle, ConnectorId, GlobalMenu, GlobalMenuItem, GlobalMenuItemUrl, SendTransactionArgs, SendTransactionFn, SkillsButton, SkillsButtonProps, SkillsButtonStyle, WalletInfo, WalletInfoContentProps, WalletInfoProps, WalletInfoStyle, WalletInfoTriggerProps, useGlobalMenu } from '@nexus-cross/dapp-ui';
9
+ import { Connector } from 'wagmi';
10
+ export { OnRampProvider, OnRampProviderProps, UseOnRampEligibilityOptions, UseOnRampEligibilityResult, UseOnRampOptions, UseOnRampResult, useOnRamp, useOnRampEligibility } from '@nexus-cross/onramp/react';
11
+
12
+ interface CrossConnectKitProviderProps {
13
+ children: ReactNode;
14
+ config: CrossxConfig;
15
+ /**
16
+ * SSR hydration state for both sides of the dual wagmi config. Produce
17
+ * with `cookieToCrossConnectKitState(config, cookieHeader)` on the server.
18
+ * The provider passes the correct slice into whichever `<WagmiProvider>`
19
+ * is currently active.
20
+ */
21
+ initialState?: CrossConnectKitInitialState;
22
+ /**
23
+ * Extra wallet entries to render in the unified connect modal that do
24
+ * NOT have a wagmi connector behind them. Use this for "coming soon"
25
+ * placeholders or dapp-ui-only wallets like Verse8 / Tron — pass a
26
+ * click handler that opens an alert / external page.
27
+ *
28
+ * Keys must be walletIds known to dapp-ui's `WALLET_REGISTRY`
29
+ * (e.g. `'verse8'`, `'tron'`). Other keys are ignored.
30
+ */
31
+ extraWallets?: Partial<Record<WalletId, () => void | Promise<void>>>;
32
+ /**
33
+ * Whitelist controlling which wallet ids appear in the modal's
34
+ * "Other Wallets" list.
35
+ *
36
+ * undefined — show every registered wallet (default)
37
+ * [] — show none (social-only modal)
38
+ * [...ids] — show only the listed ids (applies to extras too)
39
+ *
40
+ * Disable social separately by omitting `embeddedConnectorFactory`
41
+ * from `createCrossxConfig`.
42
+ */
43
+ walletAllowlist?: readonly WalletId[];
44
+ }
45
+ declare function CrossConnectKitProvider({ children, config, initialState, extraWallets, walletAllowlist, }: CrossConnectKitProviderProps): react_jsx_runtime.JSX.Element;
46
+
47
+ /**
48
+ * ConnectButton이 사용하는 사용자 프로바이더 식별자.
49
+ * crossy-sdk의 OAuth 로그인(`google`/`apple`)과 실제 지갑 커넥터
50
+ * (`cross`/`metamask`/`binance`)를 하나의 enum처럼 통합 표기한 값.
51
+ */
52
+ type WalletProvider = 'google' | 'apple' | 'cross' | 'metamask' | 'binance';
53
+ /**
54
+ * 외부에서 `ConnectButton`에 전달할 수 있는 사용자 정보 객체.
55
+ * 지정 시 내부 자동 감지 로직(useAccount / crossy-sdk)보다 우선하여
56
+ * trigger pill / WalletInfo 헤더 표시에 사용된다.
57
+ */
58
+ interface WalletUser {
59
+ /** `google` | `apple` | `cross` | `metamask` | `binance` */
60
+ provider: WalletProvider;
61
+ /** WalletInfo 헤더에 노출될 계정 라벨 (예: `"Account 1"`). */
62
+ name?: string;
63
+ /** 0x... 지갑 주소. */
64
+ address: string;
65
+ }
66
+ /**
67
+ * `ConnectButton`에 전달 가능한 prop 중 내부에서 자동 계산되는 항목.
68
+ * 명시적으로 지정되면 자동값을 덮어쓴다.
69
+ *
70
+ * - `walletAddress`: 항상 내부에서 관리(wagmi / `user.address`)하므로 제외.
71
+ * - `children`: 내부에서 Trigger/Content를 조립하므로 제외.
72
+ */
73
+ type ForwardedWalletInfoProps = Omit<WalletInfoProps, 'children' | 'walletAddress' | 'style'>;
74
+ interface ConnectButtonProps extends ForwardedWalletInfoProps {
75
+ /**
76
+ * Disconnected 상태에서 버튼에 표기될 라벨. 기본 `"Connect Wallet"`.
77
+ * `ReactNode`를 받아 아이콘-only / 커스텀 마크업 렌더가 가능하다
78
+ * (예: 모바일에서 텍스트 없이 지갑 아이콘만 노출).
79
+ */
80
+ label?: ReactNode;
81
+ /**
82
+ * 외부(호출부)에서 주입하는 className. disconnected / connecting /
83
+ * connected(트리거 pill)에 공통으로 추가된다 (기본 `cb-button` /
84
+ * `cb-pill` 클래스에 병합).
85
+ */
86
+ className?: string;
87
+ /**
88
+ * 버튼 자체(disconnected / connecting / connected pill)의 CSS 커스텀
89
+ * 변수 오버라이드. WalletInfo popover 스타일은 별도 `walletInfoStyle`
90
+ * 로 분리되어 있다.
91
+ */
92
+ style?: ConnectButtonStyle;
93
+ /**
94
+ * 트리거 pill 을 눌러 열리는 WalletInfo popover/drawer 의 CSS 커스텀
95
+ * 변수 오버라이드 (`WalletInfoStyle`).
96
+ */
97
+ walletInfoStyle?: WalletInfoStyle;
98
+ /**
99
+ * 사용자 정보 객체. 지정 시 `provider`/`name`/`address`가 자동 감지값보다
100
+ * 우선하여 trigger pill과 WalletInfo 헤더에 반영된다. 연결 상태 자체
101
+ * (`isConnected`/`isConnecting`)는 여전히 wagmi에서 가져온다.
102
+ */
103
+ user?: WalletUser;
104
+ /**
105
+ * @deprecated `showPortfolio`를 사용하라. 현재는 `showPortfolio`가 지정되지
106
+ * 않은 경우에만 fallback으로 쓰인다.
107
+ */
108
+ enablePortfolio?: boolean;
109
+ /**
110
+ * Convenience alias for `showPortfolio`. Prefer this in new code:
111
+ * `<ConnectButton portfolio />`.
112
+ */
113
+ portfolio?: boolean;
114
+ /**
115
+ * AlchemyPay 결제 위젯 종료 후 popup이 redirect될 URL. 지정 시 백엔드
116
+ * `/onramp/url` 호출 body의 `redirect_url`로 그대로 전달된다. 미지정 시
117
+ * 클라가 임의 default를 박지 않고 백엔드의 default 흐름을 따른다.
118
+ *
119
+ * DApp이 결제 완료를 자체 페이지에서 받고 싶을 때 사용 (예:
120
+ * `https://example.com/onramp/return`). 보통 그 페이지에서
121
+ * `window.opener.postMessage(...)` + `window.close()`로 메인 윈도우에 알림.
122
+ */
123
+ onRampRedirectUrl?: string;
124
+ }
125
+ /**
126
+ * `ConnectButton`은 내부에서 `WalletInfo`를 조립하지만, 호출측은 그 사실을
127
+ * 몰라도 되도록 `WalletInfoProps`를 전부 pass-through 한다
128
+ * (`walletAddress` / `children` 만 제외).
129
+ *
130
+ * 자동 계산 규칙 (명시적으로 주면 덮어쓰기):
131
+ * - `walletAddress` ← `user.address` ?? wagmi `address`
132
+ * - `connectorId` ← `user.provider` ?? `currentWallet` 매핑
133
+ * - `accountName` ← `user.name` ?? crossy-sdk getAddresses name
134
+ * - `onDisconnect` ← kit `disconnect()`
135
+ * - `onSelectWallet` ← OAuth embedded 세션일 때만 kit `selectWallet()`
136
+ * (외부 지갑은 기본 alert을 막기 위해 CSS로 숨김)
137
+ * - `showPortfolio` ← `portfolio` ?? `showPortfolio` ?? legacy `enablePortfolio`
138
+ * - `theme` ← kit provider의 `themeMode`
139
+ * - `env` ← `NEXT_PUBLIC_CROSSX_ENVIRONMENT`, or `"production"`
140
+ *
141
+ * Trigger 버튼(주소 옆 pill)은 호출측이 건드릴 수 없다 — 플랫폼 아이콘 + 축약
142
+ * 주소의 통일된 UX를 강제한다.
143
+ */
144
+ declare function ConnectButton({ label, className, style, walletInfoStyle, user, enablePortfolio, portfolio, theme: themeProp, accountName: accountNameProp, connectorId: connectorIdProp, showPortfolio: showPortfolioProp, sendAccounts: sendAccountsProp, getTransactionReceipt: getTransactionReceiptProp, sendTransaction: sendTransactionProp, estimateGas: estimateGasProp, onDisconnect: onDisconnectProp, onSelectWallet: onSelectWalletProp, onBuy: onBuyProp, onRampRedirectUrl, bridgeTokens: bridgeTokensProp, bridgeHistory: bridgeHistoryProp, getBridgeQuote: getBridgeQuoteProp, getBridgeToTokens: getBridgeToTokensProp, getBridgeApproval: getBridgeApprovalProp, approveBridge: approveBridgeProp, submitBridge: submitBridgeProp, showBalance, env, ...walletInfoRest }: ConnectButtonProps): react_jsx_runtime.JSX.Element;
145
+
146
+ interface OtherWalletsModalProps {
147
+ open: boolean;
148
+ onClose: () => void;
149
+ onSelect: (walletId: WalletId) => Promise<void>;
150
+ /** Override the modal title. Default: "Connect Wallet". */
151
+ title?: string;
152
+ /** Override the modal description. */
153
+ description?: string;
154
+ /** Override the troubleshooting tip list entirely. */
155
+ troubleshootingTips?: readonly string[];
156
+ }
157
+ /**
158
+ * Wallet selector modal. Port of posa's `ConnectWalletModal` backed by
159
+ * `ConnectorRegistry` — wallet order, icons, and descriptive copy match
160
+ * posa; DApps can override via `walletGuides` passed to
161
+ * `createCrossxConfig` and via modal props.
162
+ */
163
+ declare function OtherWalletsModal({ open, onClose, onSelect, title, description, troubleshootingTips, }: OtherWalletsModalProps): react_jsx_runtime.JSX.Element | null;
164
+
165
+ interface CrossConnectModalProps {
166
+ open: boolean;
167
+ onOpenChange: (open: boolean) => void;
168
+ }
169
+ /**
170
+ * Kit's unified connect modal. Composes dapp-ui's `WalletConnectModal`
171
+ * with two handler sources:
172
+ *
173
+ * - Social row → `oauth.signIn('google' | 'apple')` from the wagmi-side
174
+ * OAuth adapter (no UI; the SDK opens the OAuth popup and resolves
175
+ * addresses on its own).
176
+ * - Wallet list → `connect(walletId)` from the kit context, which
177
+ * drives the regular wagmi connect flow.
178
+ *
179
+ * The modal itself is a thin composition: it owns no connect logic,
180
+ * shows no progress / error state. Users that need a richer UX can copy
181
+ * this component as a starting point.
182
+ */
183
+ declare function CrossConnectModal({ open, onOpenChange, }: CrossConnectModalProps): react_jsx_runtime.JSX.Element;
184
+
185
+ interface CrossConnectKitContextValue {
186
+ kitConfig: CrossConnectKitConfig;
187
+ connectorRegistry: ConnectorRegistry;
188
+ /** Available wallets derived from the registry (excludes embedded) */
189
+ availableWallets: readonly ConnectorEntry[];
190
+ /** Connect by walletId — resolved through the registry */
191
+ connect: (walletId: WalletId) => Promise<void>;
192
+ /** Shortcut: trigger embedded wallet connect (SDK modal) */
193
+ connectWallet: () => Promise<void>;
194
+ /** Disconnect and clean up wagmi + SDK + cached session storage. */
195
+ disconnect: () => Promise<void>;
196
+ /** Open the SDK's wallet selector (embedded only) */
197
+ selectWallet: () => Promise<{
198
+ address: string;
199
+ index: number;
200
+ } | null>;
201
+ /** Currently active wallet type, resolved from registry */
202
+ currentWallet: WalletId | null;
203
+ /**
204
+ * The most recent wallet the user picked from the unified connect
205
+ * modal. Set by `runConnect` before the wagmi-side connect begins,
206
+ * cleared on dismissal/error so callers can detect that the user
207
+ * gave up on the wallet UI even when wagmi's `isConnecting` stays
208
+ * stuck on a pending connector promise (WalletConnect QR, OAuth
209
+ * popup). Reads of this should be paired with `isConnected` —
210
+ * `lastIntent && !isConnected` means "we asked for X but X hasn't
211
+ * succeeded yet", and a transition from non-null → null while
212
+ * disconnected is the kit's "user cancelled" signal.
213
+ */
214
+ lastIntent: WalletId | null;
215
+ /**
216
+ * Unified "a connect attempt is in flight" flag spanning EVERY
217
+ * connection path — so "Connecting…" UI behaves identically regardless
218
+ * of which wallet the user picked. Unlike wagmi's
219
+ * `useAccount().isConnecting`, this also covers:
220
+ *
221
+ * - the reown direct-connect AppKit flow (`metamask` / `binance`),
222
+ * which resolves outside wagmi's `connectAsync` and therefore never
223
+ * flips wagmi's own `isConnecting`;
224
+ * - the embedded OAuth popup (`google` / `apple`), wired through
225
+ * `oauth.signIn` rather than the wagmi connect path.
226
+ *
227
+ * Set the instant the user picks a wallet in the modal; cleared on
228
+ * success (`isConnected`), cancel, or error. In-memory only — a stale
229
+ * persisted `lastIntent` from a previous page load never turns it on,
230
+ * and silent background reconnects (wagmi `isReconnecting`) don't either.
231
+ */
232
+ isConnecting: boolean;
233
+ /**
234
+ * The `walletId` of the in-flight connect attempt, or `null` when idle.
235
+ * Same lifecycle as {@link isConnecting} — use it to drive a per-wallet
236
+ * spinner inside a custom connect modal.
237
+ */
238
+ connectingWalletId: WalletId | null;
239
+ /** Open the "Other Wallets" modal */
240
+ openOtherWallets: () => void;
241
+ /** Close the "Other Wallets" modal */
242
+ closeOtherWallets: () => void;
243
+ /** Whether the "Other Wallets" modal is open */
244
+ otherWalletsOpen: boolean;
245
+ /**
246
+ * Headless OAuth entry point. Non-null only when the kit was created
247
+ * with an `embeddedConnectorFactory` (i.e. crossy-sdk is present).
248
+ * Used by `<CrossConnectModal>` to wire the Google/Apple buttons.
249
+ */
250
+ oauth: OAuthPort | null;
251
+ /**
252
+ * Extra wallet click-handlers the DApp wants to render in the connect
253
+ * modal that have NO wagmi connector behind them (e.g. coming-soon
254
+ * placeholders or dapp-ui-only wallets like Verse8 / Tron). Keys are
255
+ * walletIds known to dapp-ui's `WALLET_REGISTRY`; values are click
256
+ * handlers (typically opening an alert or external page).
257
+ */
258
+ extraWallets: Partial<Record<WalletId, () => void | Promise<void>>>;
259
+ /**
260
+ * Optional whitelist controlling which wallet ids appear in the
261
+ * connect modal's "Other Wallets" list.
262
+ *
263
+ * - `undefined` (default) — show every registered wallet
264
+ * - `[]` — show none (social row only)
265
+ * - `['cross_wallet', ...]` — show only the listed ids
266
+ *
267
+ * Applies to both wagmi-backed entries and `extraWallets`. The social
268
+ * row is independent of this — disable social by omitting
269
+ * `embeddedConnectorFactory` from `createCrossxConfig`.
270
+ */
271
+ walletAllowlist: readonly WalletId[] | null;
272
+ /**
273
+ * On-ramp 활성화 여부 (= `!!kitConfig.onRampId`). 실제 어댑터/훅은
274
+ * `@nexus-cross/onramp/react`의 OnRampProvider/useOnRamp를 통해 노출 —
275
+ * 이 값은 단순히 connect-kit 호출자가 onRampId 설정 여부를 빠르게
276
+ * 알아볼 수 있게 한다.
277
+ */
278
+ onRampEnabled: boolean;
279
+ }
280
+ declare function useCrossConnectKit(): CrossConnectKitContextValue;
281
+
282
+ /**
283
+ * Resolved theme state exposed to consumers inside `<CrossConnectKitProvider>`.
284
+ * `mode` already accounts for `autoDetectTheme` and any runtime
285
+ * overrides via `setTheme`.
286
+ */
287
+ interface CrossConnectKitThemeContextValue {
288
+ /** Active theme mode (respects `autoDetectTheme` + runtime overrides). */
289
+ mode: ThemeMode;
290
+ /** Resolved token set passed to crossy-sdk + published as `--cck-*`. */
291
+ tokens: ThemeTokens | undefined;
292
+ /**
293
+ * Override the theme mode at runtime. Mirrors crossy-sdk's
294
+ * `sdk.applyTheme(mode)`.
295
+ *
296
+ * Passing `null` reverts to whatever the original `CrossConnectKitConfig`
297
+ * declared (including `autoDetectTheme`).
298
+ */
299
+ setThemeMode: (mode: ThemeMode | null) => void;
300
+ /**
301
+ * Override color tokens at runtime. Passed straight through to
302
+ * crossy-sdk's `applyTheme(mode, themeTokens)` on the next render,
303
+ * and re-published as CSS variables so dapp-ui surfaces update too.
304
+ *
305
+ * Passing `null` reverts to `CrossConnectKitConfig.themeTokens`.
306
+ */
307
+ setThemeTokens: (tokens: ThemeTokens | null) => void;
308
+ }
309
+ /**
310
+ * Access the resolved theme and the runtime override setters. Must be
311
+ * called inside `<CrossConnectKitProvider>`.
312
+ */
313
+ declare function useCrossConnectKitTheme(): CrossConnectKitThemeContextValue;
314
+ /**
315
+ * Version that returns `null` when called outside the provider — handy
316
+ * for components (like `WalletInfo`) that want to opt into the kit's
317
+ * theme if mounted under the provider, but keep working standalone.
318
+ */
319
+ declare function useOptionalCrossConnectKitTheme(): CrossConnectKitThemeContextValue | null;
320
+
321
+ interface CrossxEmbeddedInfo {
322
+ /** crossy-sdk OAuth 로그인 타입. embedded가 아니면 `null`. */
323
+ loginType: 'google' | 'apple' | null;
324
+ /** SDK `getAddresses()`가 리턴한 현재 주소의 `name` 필드(계정 라벨). */
325
+ accountName: string | null;
326
+ /** SDK `getAddresses()`가 리턴한 전체 계정 목록. embedded가 아니면 빈 배열. */
327
+ accounts: Array<{
328
+ address: `0x${string}`;
329
+ index?: number;
330
+ name?: string;
331
+ }>;
332
+ /**
333
+ * SDK 조회가 완료됐는지 여부. embedded 세션에서 처음 마운트됐을 때
334
+ * `loginType`은 잠시 `null`이고 다음 틱에 `google`/`apple`로 바뀌는데,
335
+ * 이 플래그로 "아직 해석 중" vs "해석 완료(OAuth 아님)"을 구분한다.
336
+ * embedded가 아닌 wallet은 즉시 `true`.
337
+ */
338
+ isResolved: boolean;
339
+ }
340
+ /**
341
+ * crossy-sdk 2.0 세션 메타데이터(`getUserInfo().loginType`,
342
+ * `getAddresses()[].name`)를 비동기로 읽어오는 훅.
343
+ *
344
+ * - `walletId`가 `"cross_embedded"`가 아니면 항상
345
+ * `{ loginType: null, accountName: null, accounts: [], isResolved: true }`.
346
+ * - 내부 호출은 연결된 Provider가 `sdk` 필드를 노출하는 crossy-sdk 스펙을
347
+ * 가정하며, 필드가 없거나 에러가 나면 조용히 nulls로 떨어진다.
348
+ * - RN native bridge가 walletChanged 이벤트로 보내주는 walletName(예: imported
349
+ * wallet의 사용자 라벨)도 함께 구독해, SDK 서버 캐시 `name`보다 우선
350
+ * accountName으로 사용한다.
351
+ *
352
+ * 인자 없이 호출하면 `useAccount()` / `useCrossConnectKit()`에서 값을 자동으로
353
+ * 받아오고, 명시적으로 제어하고 싶으면 오버라이드 값을 넘길 수 있다.
354
+ */
355
+ declare function useCrossxEmbeddedInfo(args?: {
356
+ walletId?: string | null;
357
+ connector?: Connector;
358
+ address?: string;
359
+ }): CrossxEmbeddedInfo;
360
+
361
+ type CrossdBridgeAdapterOptions = {
362
+ env: Environment;
363
+ walletAddress?: string;
364
+ enabled?: boolean;
365
+ };
366
+ type CrossdBridgeAdapter = {
367
+ bridgeTokens: BridgeToken[];
368
+ bridgeHistory: BridgeHistoryItem[];
369
+ getBridgeApproval: BridgeGetApprovalFn;
370
+ approveBridge: BridgeApproveFn;
371
+ getBridgeQuote: BridgeQuoteFn;
372
+ getBridgeToTokens: BridgeGetToTokensFn;
373
+ submitBridge: BridgeSubmitFn;
374
+ isLoading: boolean;
375
+ };
376
+ declare function useCrossdBridgeAdapter({ env, walletAddress, enabled, }: CrossdBridgeAdapterOptions): CrossdBridgeAdapter;
377
+
378
+ export { ConnectButton, type ConnectButtonProps, type CrossConnectKitContextValue, CrossConnectKitProvider, type CrossConnectKitProviderProps, type CrossConnectKitThemeContextValue, CrossConnectModal, type CrossConnectModalProps, type CrossxEmbeddedInfo, OtherWalletsModal, type OtherWalletsModalProps, type WalletProvider, type WalletUser, useCrossConnectKit, useCrossConnectKitTheme, useCrossdBridgeAdapter, useCrossxEmbeddedInfo, useOptionalCrossConnectKitTheme };
package/dist/index.js CHANGED
@@ -1,19 +1 @@
1
- import { announceConnectKitUsage } from './runtime-log.js';
2
- announceConnectKitUsage();
3
- export { CrossConnectKitProvider } from './components/CrossConnectKitProvider.js';
4
- export { ConnectButton } from './components/ConnectButton.js';
5
- export { OtherWalletsModal } from './components/OtherWalletsModal.js';
6
- export { CrossConnectModal } from './components/CrossConnectModal.js';
7
- export { useCrossConnectKit } from './context/CrossConnectKitContext.js';
8
- export { useCrossConnectKitTheme, useOptionalCrossConnectKitTheme, } from './context/CrossConnectKitThemeContext.js';
9
- export { useCrossxEmbeddedInfo } from './hooks/useCrossxEmbeddedInfo.js';
10
- // On-ramp 훅은 `@nexus-cross/onramp/react`로 이동했다. 1.1.x에서
11
- // `@nexus-cross/connect-kit-react`로부터 직접 import한 사용자가 안 깨지도록
12
- // re-export만 유지. 신규 코드는 `@nexus-cross/onramp/react`를 직접 import 권장.
13
- export { useOnRamp, useOnRampEligibility, OnRampProvider, } from '@nexus-cross/onramp/react';
14
- export { WalletInfo, ConnectorId } from '@nexus-cross/dapp-ui';
15
- export { AppLauncher, AppLauncherTrigger, AppLauncherContent, useGlobalMenu, } from '@nexus-cross/dapp-ui';
16
- export { SkillsButton } from '@nexus-cross/dapp-ui';
17
- export { OnRampError } from '@nexus-cross/connect-kit-core';
18
- export { ConnectionStatus, formatBalance, formatWei } from '@nexus-cross/connect-kit-core';
19
- //# sourceMappingURL=index.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-ZL2BHNN6.js";export{o as AppLauncher,q as AppLauncherContent,p as AppLauncherTrigger,h as ConnectButton,u as ConnectionStatus,n as ConnectorId,e as CrossConnectKitProvider,d as CrossConnectModal,t as OnRampError,l as OnRampProvider,i as OtherWalletsModal,s as SkillsButton,m as WalletInfo,v as formatBalance,w as formatWei,a as useCrossConnectKit,b as useCrossConnectKitTheme,f as useCrossdBridgeAdapter,g as useCrossxEmbeddedInfo,r as useGlobalMenu,j as useOnRamp,k as useOnRampEligibility,c as useOptionalCrossConnectKitTheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cross/connect-kit-react",
3
- "version": "1.3.0-beta.1",
3
+ "version": "1.3.1",
4
4
  "description": "React components and hooks for @nexus-cross/connect-kit wallet connection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,16 +18,17 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
+ "sideEffects": false,
21
22
  "publishConfig": {
22
23
  "registry": "https://registry.npmjs.org",
23
24
  "access": "public"
24
25
  },
25
26
  "dependencies": {
26
- "@nexus-cross/connect-kit-core": "1.3.0-beta.1",
27
- "@nexus-cross/connect-kit-wagmi": "1.3.0-beta.1",
28
- "@nexus-cross/crossx-design-system": "0.1.0",
29
- "@nexus-cross/onramp": "0.1.0",
30
- "@nexus-cross/dapp-ui": "1.3.0-beta.1"
27
+ "@nexus-cross/connect-kit-core": "1.3.1",
28
+ "@nexus-cross/connect-kit-wagmi": "1.3.1",
29
+ "@nexus-cross/crossx-design-system": "1.3.1",
30
+ "@nexus-cross/dapp-ui": "1.3.1",
31
+ "@nexus-cross/onramp": "1.3.1"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@tanstack/react-query": "^5.60.0",
@@ -35,6 +36,8 @@
35
36
  "@types/react-dom": "^19.0.0",
36
37
  "react": "^19.0.0",
37
38
  "react-dom": "^19.0.0",
39
+ "tsup": "^8.4.0",
40
+ "typescript": "^5.7.0",
38
41
  "viem": "^2.21.0",
39
42
  "wagmi": "^3.6.0"
40
43
  },
@@ -46,8 +49,8 @@
46
49
  },
47
50
  "license": "MIT",
48
51
  "scripts": {
49
- "build": "tsc",
50
- "dev": "tsc --watch",
52
+ "build": "tsup",
53
+ "dev": "tsup --watch",
51
54
  "test": "echo 'no tests yet'",
52
55
  "typecheck": "tsc --noEmit"
53
56
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,YAAY,EACV,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,oCAAoC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -1,102 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ConnectButtonStyle, WalletInfoProps, WalletInfoStyle } from '@nexus-cross/dapp-ui';
3
- /**
4
- * ConnectButton이 사용하는 사용자 프로바이더 식별자.
5
- * crossy-sdk의 OAuth 로그인(`google`/`apple`)과 실제 지갑 커넥터
6
- * (`cross`/`metamask`/`binance`)를 하나의 enum처럼 통합 표기한 값.
7
- */
8
- export type WalletProvider = 'google' | 'apple' | 'cross' | 'metamask' | 'binance';
9
- /**
10
- * 외부에서 `ConnectButton`에 전달할 수 있는 사용자 정보 객체.
11
- * 지정 시 내부 자동 감지 로직(useAccount / crossy-sdk)보다 우선하여
12
- * trigger pill / WalletInfo 헤더 표시에 사용된다.
13
- */
14
- export interface WalletUser {
15
- /** `google` | `apple` | `cross` | `metamask` | `binance` */
16
- provider: WalletProvider;
17
- /** WalletInfo 헤더에 노출될 계정 라벨 (예: `"Account 1"`). */
18
- name?: string;
19
- /** 0x... 지갑 주소. */
20
- address: string;
21
- }
22
- /**
23
- * `ConnectButton`에 전달 가능한 prop 중 내부에서 자동 계산되는 항목.
24
- * 명시적으로 지정되면 자동값을 덮어쓴다.
25
- *
26
- * - `walletAddress`: 항상 내부에서 관리(wagmi / `user.address`)하므로 제외.
27
- * - `children`: 내부에서 Trigger/Content를 조립하므로 제외.
28
- */
29
- type ForwardedWalletInfoProps = Omit<WalletInfoProps, 'children' | 'walletAddress' | 'style'>;
30
- export interface ConnectButtonProps extends ForwardedWalletInfoProps {
31
- /**
32
- * Disconnected 상태에서 버튼에 표기될 라벨. 기본 `"Connect Wallet"`.
33
- * `ReactNode`를 받아 아이콘-only / 커스텀 마크업 렌더가 가능하다
34
- * (예: 모바일에서 텍스트 없이 지갑 아이콘만 노출).
35
- */
36
- label?: ReactNode;
37
- /**
38
- * 외부(호출부)에서 주입하는 className. disconnected / connecting /
39
- * connected(트리거 pill)에 공통으로 추가된다 (기본 `cb-button` /
40
- * `cb-pill` 클래스에 병합).
41
- */
42
- className?: string;
43
- /**
44
- * 버튼 자체(disconnected / connecting / connected pill)의 CSS 커스텀
45
- * 변수 오버라이드. WalletInfo popover 스타일은 별도 `walletInfoStyle`
46
- * 로 분리되어 있다.
47
- */
48
- style?: ConnectButtonStyle;
49
- /**
50
- * 트리거 pill 을 눌러 열리는 WalletInfo popover/drawer 의 CSS 커스텀
51
- * 변수 오버라이드 (`WalletInfoStyle`).
52
- */
53
- walletInfoStyle?: WalletInfoStyle;
54
- /**
55
- * 사용자 정보 객체. 지정 시 `provider`/`name`/`address`가 자동 감지값보다
56
- * 우선하여 trigger pill과 WalletInfo 헤더에 반영된다. 연결 상태 자체
57
- * (`isConnected`/`isConnecting`)는 여전히 wagmi에서 가져온다.
58
- */
59
- user?: WalletUser;
60
- /**
61
- * @deprecated `showPortfolio`를 사용하라. 현재는 `showPortfolio`가 지정되지
62
- * 않은 경우에만 fallback으로 쓰인다.
63
- */
64
- enablePortfolio?: boolean;
65
- /**
66
- * Convenience alias for `showPortfolio`. Prefer this in new code:
67
- * `<ConnectButton portfolio />`.
68
- */
69
- portfolio?: boolean;
70
- /**
71
- * AlchemyPay 결제 위젯 종료 후 popup이 redirect될 URL. 지정 시 백엔드
72
- * `/onramp/url` 호출 body의 `redirect_url`로 그대로 전달된다. 미지정 시
73
- * 클라가 임의 default를 박지 않고 백엔드의 default 흐름을 따른다.
74
- *
75
- * DApp이 결제 완료를 자체 페이지에서 받고 싶을 때 사용 (예:
76
- * `https://example.com/onramp/return`). 보통 그 페이지에서
77
- * `window.opener.postMessage(...)` + `window.close()`로 메인 윈도우에 알림.
78
- */
79
- onRampRedirectUrl?: string;
80
- }
81
- /**
82
- * `ConnectButton`은 내부에서 `WalletInfo`를 조립하지만, 호출측은 그 사실을
83
- * 몰라도 되도록 `WalletInfoProps`를 전부 pass-through 한다
84
- * (`walletAddress` / `children` 만 제외).
85
- *
86
- * 자동 계산 규칙 (명시적으로 주면 덮어쓰기):
87
- * - `walletAddress` ← `user.address` ?? wagmi `address`
88
- * - `connectorId` ← `user.provider` ?? `currentWallet` 매핑
89
- * - `accountName` ← `user.name` ?? crossy-sdk getAddresses name
90
- * - `onDisconnect` ← kit `disconnect()`
91
- * - `onSelectWallet` ← OAuth embedded 세션일 때만 kit `selectWallet()`
92
- * (외부 지갑은 기본 alert을 막기 위해 CSS로 숨김)
93
- * - `showPortfolio` ← `portfolio` ?? `showPortfolio` ?? legacy `enablePortfolio`
94
- * - `theme` ← kit provider의 `themeMode`
95
- * - `env` ← `NEXT_PUBLIC_CROSSX_ENVIRONMENT`, or `"production"`
96
- *
97
- * Trigger 버튼(주소 옆 pill)은 호출측이 건드릴 수 없다 — 플랫폼 아이콘 + 축약
98
- * 주소의 통일된 UX를 강제한다.
99
- */
100
- export declare function ConnectButton({ label, className, style, walletInfoStyle, user, enablePortfolio, portfolio, theme: themeProp, accountName: accountNameProp, connectorId: connectorIdProp, showPortfolio: showPortfolioProp, sendAccounts: sendAccountsProp, getTransactionReceipt: getTransactionReceiptProp, sendTransaction: sendTransactionProp, estimateGas: estimateGasProp, onDisconnect: onDisconnectProp, onSelectWallet: onSelectWalletProp, onBuy: onBuyProp, onRampRedirectUrl, showBalance, env, ...walletInfoRest }: ConnectButtonProps): import("react/jsx-runtime").JSX.Element;
101
- export {};
102
- //# sourceMappingURL=ConnectButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConnectButton.d.ts","sourceRoot":"","sources":["../../src/components/ConnectButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,KAAK,EACV,kBAAkB,EAIlB,eAAe,EACf,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAiB9B;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,UAAU,GACV,SAAS,CAAC;AAEd;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,QAAQ,EAAE,cAAc,CAAC;IACzB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,KAAK,wBAAwB,GAAG,IAAI,CAClC,eAAe,EACf,UAAU,GAAG,eAAe,GAAG,OAAO,CACvC,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,wBAAwB;IAClE;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAuGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAwB,EACxB,SAAS,EACT,KAAK,EACL,eAAe,EACf,IAAI,EACJ,eAAe,EACf,SAAS,EAET,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,EAC9B,qBAAqB,EAAE,yBAAyB,EAChD,eAAe,EAAE,mBAAmB,EACpC,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,gBAAgB,EAC9B,cAAc,EAAE,kBAAkB,EAClC,KAAK,EAAE,SAAS,EAChB,iBAAiB,EAEjB,WAAkB,EAClB,GAAG,EAEH,GAAG,cAAc,EAClB,EAAE,kBAAkB,2CA0bpB"}