@nexus-cross/connect-kit-core 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.
- package/dist/index.d.ts +369 -14
- package/dist/index.js +1 -9
- package/package.json +9 -4
- package/dist/core/ports/BalancePort.d.ts +0 -14
- package/dist/core/ports/BalancePort.d.ts.map +0 -1
- package/dist/core/ports/BalancePort.js +0 -2
- package/dist/core/ports/BalancePort.js.map +0 -1
- package/dist/core/ports/ConnectorPort.d.ts +0 -32
- package/dist/core/ports/ConnectorPort.d.ts.map +0 -1
- package/dist/core/ports/ConnectorPort.js +0 -2
- package/dist/core/ports/ConnectorPort.js.map +0 -1
- package/dist/core/ports/ModalControlPort.d.ts +0 -8
- package/dist/core/ports/ModalControlPort.d.ts.map +0 -1
- package/dist/core/ports/ModalControlPort.js +0 -2
- package/dist/core/ports/ModalControlPort.js.map +0 -1
- package/dist/core/ports/OAuthPort.d.ts +0 -11
- package/dist/core/ports/OAuthPort.d.ts.map +0 -1
- package/dist/core/ports/OAuthPort.js +0 -2
- package/dist/core/ports/OAuthPort.js.map +0 -1
- package/dist/core/ports/StoragePort.d.ts +0 -6
- package/dist/core/ports/StoragePort.d.ts.map +0 -1
- package/dist/core/ports/StoragePort.js +0 -2
- package/dist/core/ports/StoragePort.js.map +0 -1
- package/dist/core/ports/ThemePort.d.ts +0 -7
- package/dist/core/ports/ThemePort.d.ts.map +0 -1
- package/dist/core/ports/ThemePort.js +0 -2
- package/dist/core/ports/ThemePort.js.map +0 -1
- package/dist/core/ports/WalletDetectionPort.d.ts +0 -14
- package/dist/core/ports/WalletDetectionPort.d.ts.map +0 -1
- package/dist/core/ports/WalletDetectionPort.js +0 -2
- package/dist/core/ports/WalletDetectionPort.js.map +0 -1
- package/dist/core/theme/tokens.d.ts +0 -18
- package/dist/core/theme/tokens.d.ts.map +0 -1
- package/dist/core/theme/tokens.js +0 -32
- package/dist/core/theme/tokens.js.map +0 -1
- package/dist/core/types/index.d.ts +0 -228
- package/dist/core/types/index.d.ts.map +0 -1
- package/dist/core/types/index.js +0 -13
- package/dist/core/types/index.js.map +0 -1
- package/dist/core/utils/balance.d.ts +0 -33
- package/dist/core/utils/balance.d.ts.map +0 -1
- package/dist/core/utils/balance.js +0 -66
- package/dist/core/utils/balance.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,369 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
export { OnRampDisallowReason, OnRampEligibility, OnRampError, OnRampErrorCode, OnRampOpenParams, OnRampPort, OnRampProviderId, OnRampSession, OnRampStatus, OnRampStatusEvent, normalizeDisallowReason } from '@nexus-cross/onramp';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How a connector reaches the blockchain:
|
|
5
|
+
* - embedded: In-app wallet via crossy-sdk-js (social login, no extension)
|
|
6
|
+
* - app: CROSSx mobile app deep-link / QR approval
|
|
7
|
+
* - extension: Browser extension (CROSSx Extension, injected EIP-1193)
|
|
8
|
+
* - external: Third-party wallets via Reown/WalletConnect (MetaMask, Binance …)
|
|
9
|
+
*/
|
|
10
|
+
type ConnectorType = 'embedded' | 'app' | 'extension' | 'external';
|
|
11
|
+
/**
|
|
12
|
+
* Well-known wallet identifiers used throughout the kit.
|
|
13
|
+
* Maps 1:1 to posa's WalletType union so existing apps migrate trivially.
|
|
14
|
+
*/
|
|
15
|
+
type WalletId = 'cross_embedded' | 'cross_wallet' | 'cross_extension' | 'metamask' | 'binance' | (string & {});
|
|
16
|
+
interface WalletDescriptor {
|
|
17
|
+
readonly id: WalletId;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly type: ConnectorType;
|
|
20
|
+
readonly iconUrl?: string;
|
|
21
|
+
/** EIP-6963 rdns for browser-extension detection */
|
|
22
|
+
readonly rdns?: string;
|
|
23
|
+
/** Install URL when extension is not detected */
|
|
24
|
+
readonly installUrl?: string;
|
|
25
|
+
/** Whether the wallet is available in the current environment */
|
|
26
|
+
installed?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface ConnectorResult {
|
|
29
|
+
account: Account;
|
|
30
|
+
chainId: number;
|
|
31
|
+
}
|
|
32
|
+
interface Account {
|
|
33
|
+
/** 0x-prefixed hex string */
|
|
34
|
+
address: string;
|
|
35
|
+
chainId: number;
|
|
36
|
+
}
|
|
37
|
+
interface ChainBalance {
|
|
38
|
+
/** EIP-155 numeric chain ID */
|
|
39
|
+
chainId: number;
|
|
40
|
+
/** Human-readable decimal string (e.g. "1234.5678") */
|
|
41
|
+
balance: string;
|
|
42
|
+
/** Raw integer string in wei */
|
|
43
|
+
balanceWei: string;
|
|
44
|
+
}
|
|
45
|
+
declare const ConnectionStatus: {
|
|
46
|
+
readonly CONNECTED: "connected";
|
|
47
|
+
readonly DISCONNECTED: "disconnected";
|
|
48
|
+
readonly CONNECTING: "connecting";
|
|
49
|
+
readonly RECONNECTING: "reconnecting";
|
|
50
|
+
};
|
|
51
|
+
type ConnectionStatus = (typeof ConnectionStatus)[keyof typeof ConnectionStatus];
|
|
52
|
+
interface WalletState {
|
|
53
|
+
status: ConnectionStatus;
|
|
54
|
+
/** Connected wallet address, undefined when disconnected */
|
|
55
|
+
address: string | undefined;
|
|
56
|
+
/** Currently active wallet identifier */
|
|
57
|
+
activeWalletId: WalletId | null;
|
|
58
|
+
/** True while auto-reconnecting from a previous session */
|
|
59
|
+
isReconnecting: boolean;
|
|
60
|
+
/** Per-chain balances (populated when balance tracking is enabled) */
|
|
61
|
+
chainBalances: ChainBalance[];
|
|
62
|
+
}
|
|
63
|
+
type ModalView = 'connect' | 'account' | 'chain' | 'wallet-info';
|
|
64
|
+
/**
|
|
65
|
+
* Theme mode — mirrors `crossy-sdk-js`'s `SDKConfig.theme` literal union.
|
|
66
|
+
* `autoDetectTheme: true` overrides this at runtime with
|
|
67
|
+
* `prefers-color-scheme`.
|
|
68
|
+
*/
|
|
69
|
+
type ThemeMode = 'light' | 'dark';
|
|
70
|
+
/**
|
|
71
|
+
* Semantic color overrides. Mirrors `crossy-sdk-js`'s `SDKColorOverrides`
|
|
72
|
+
* 1:1 so `@nexus-cross/connect-kit-core` can forward them into the
|
|
73
|
+
* embedded SDK and — via the CSS variables generated by
|
|
74
|
+
* `buildThemeCssText` — apply them uniformly to WalletInfo / Portfolio /
|
|
75
|
+
* AppLauncher / WalletConnectModal.
|
|
76
|
+
*
|
|
77
|
+
* All values are plain CSS color strings (e.g. `"#019D92"`,
|
|
78
|
+
* `"rgba(18,18,18,0.7)"`).
|
|
79
|
+
*/
|
|
80
|
+
interface ColorOverrides {
|
|
81
|
+
/** Buttons, accents, active state. Default `#019D92`. */
|
|
82
|
+
primary?: string;
|
|
83
|
+
/** Error/alert highlight (PIN error etc.). Default `#E70077`. */
|
|
84
|
+
secondary?: string;
|
|
85
|
+
/** Text/icon color placed on top of `primary`. Default `#FFFFFF`. */
|
|
86
|
+
onPrimary?: string;
|
|
87
|
+
/** Card outline border. */
|
|
88
|
+
borderDefault?: string;
|
|
89
|
+
/** Dividers, input outlines. */
|
|
90
|
+
borderSubtle?: string;
|
|
91
|
+
/** Titles, primary text. */
|
|
92
|
+
textIconPrimary?: string;
|
|
93
|
+
/** Secondary copy, labels. */
|
|
94
|
+
textIconSecondary?: string;
|
|
95
|
+
/** Hints, disabled text, tertiary icons. */
|
|
96
|
+
textIconTertiary?: string;
|
|
97
|
+
/** Inline highlighted surfaces (pills, hover, input field bg). */
|
|
98
|
+
surfaceDefault?: string;
|
|
99
|
+
/** Stronger neutral surfaces (divider fill, secondary bg). */
|
|
100
|
+
surfaceSubtle?: string;
|
|
101
|
+
/** Modal / card root background. */
|
|
102
|
+
bg?: string;
|
|
103
|
+
/** Error state, independent from `secondary`. Default `#E70077`. */
|
|
104
|
+
error?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Per-mode theme overrides. `light` is applied when `theme === 'light'`,
|
|
108
|
+
* `dark` is applied when `theme === 'dark'`. Omitted fields fall back to
|
|
109
|
+
* crossy-sdk's built-in palette.
|
|
110
|
+
*
|
|
111
|
+
* Mirrors `crossy-sdk-js`'s `SDKThemeTokens` so the same literal value
|
|
112
|
+
* can be forwarded straight into the embedded SDK.
|
|
113
|
+
*/
|
|
114
|
+
interface ThemeTokens {
|
|
115
|
+
light?: ColorOverrides;
|
|
116
|
+
dark?: ColorOverrides;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @deprecated Use `ThemeMode` / `ThemeTokens` instead.
|
|
120
|
+
* Legacy shape kept for older consumers that typed on the `mode`/
|
|
121
|
+
* `accentColor` fields. New code should pass `theme: 'dark'` and
|
|
122
|
+
* `themeTokens: { dark: { primary: ... } }` at the `CrossConnectKitConfig`
|
|
123
|
+
* level.
|
|
124
|
+
*/
|
|
125
|
+
interface Theme {
|
|
126
|
+
mode: ThemeMode;
|
|
127
|
+
accentColor?: string;
|
|
128
|
+
borderRadius?: 'none' | 'small' | 'medium' | 'large';
|
|
129
|
+
fontFamily?: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* PIN 입력 모달에서 모바일 키보드 노출 방식.
|
|
133
|
+
*
|
|
134
|
+
* Mirrors `crossy-sdk-js`'s `PinKeyboardMode` 1:1 so the kit-level value
|
|
135
|
+
* can be forwarded straight into the embedded SDK.
|
|
136
|
+
*
|
|
137
|
+
* - `'virtual'` (기본): SDK가 그리는 가상 numpad가 모바일에서 뜸.
|
|
138
|
+
* - `'native'`: 모바일에서도 input box를 노출 → OS 기본 숫자 키보드가 뜸.
|
|
139
|
+
*
|
|
140
|
+
* 데스크탑에서는 두 값 모두 동일하게 input box가 보입니다.
|
|
141
|
+
*/
|
|
142
|
+
type PinKeyboardMode = 'virtual' | 'native';
|
|
143
|
+
/**
|
|
144
|
+
* PIN 키보드 분기 옵션.
|
|
145
|
+
*
|
|
146
|
+
* - 값(`'native'` / `'virtual'`)을 주면 정적으로 고정.
|
|
147
|
+
* - 함수를 주면 PIN 모달이 띄워질 때마다 호출되어 동적으로 결정.
|
|
148
|
+
*
|
|
149
|
+
* Mirrors `crossy-sdk-js`'s `PinKeyboardOption`.
|
|
150
|
+
*/
|
|
151
|
+
type PinKeyboardOption = PinKeyboardMode | (() => PinKeyboardMode);
|
|
152
|
+
interface CrossConnectKitConfig {
|
|
153
|
+
/** CROSS relay project ID (CROSSx 1.0 / @to-nexus/sdk walletConnect). Also used as `embeddedProjectId` fallback. */
|
|
154
|
+
crossProjectId: string;
|
|
155
|
+
/** Reown project ID (for WalletConnect / external wallets) */
|
|
156
|
+
reownProjectId?: string;
|
|
157
|
+
/** CROSSx 2.0 embedded wallet project ID (@nexus-cross/crossx-sdk). Falls back to `crossProjectId` when omitted. */
|
|
158
|
+
embeddedProjectId?: string;
|
|
159
|
+
/** App metadata for WalletConnect pairing */
|
|
160
|
+
appMetadata: AppMetadata;
|
|
161
|
+
/** Supported networks */
|
|
162
|
+
networks: readonly NetworkConfig[];
|
|
163
|
+
/** Default network (first connection lands here) */
|
|
164
|
+
defaultNetwork?: NetworkConfig;
|
|
165
|
+
/**
|
|
166
|
+
* Theme mode applied across every surface the kit renders:
|
|
167
|
+
* - crossy-sdk confirmation / login modals
|
|
168
|
+
* - `WalletInfo`, `WalletPortfolio`, `WalletConnectModal`, `AppLauncher`
|
|
169
|
+
* Defaults to `'dark'`.
|
|
170
|
+
*
|
|
171
|
+
* Accepts both the new literal (`'light' | 'dark'`) and the legacy
|
|
172
|
+
* `Partial<Theme>` object (`{ mode: 'dark' }`) so older DApps keep
|
|
173
|
+
* building while migrating.
|
|
174
|
+
*/
|
|
175
|
+
theme?: ThemeMode | Partial<Theme>;
|
|
176
|
+
/**
|
|
177
|
+
* When `true`, ignore `theme` and follow `prefers-color-scheme`.
|
|
178
|
+
* Mirrors crossy-sdk's `SDKConfig.autoDetectTheme`.
|
|
179
|
+
*/
|
|
180
|
+
autoDetectTheme?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Color token overrides forwarded to crossy-sdk's `themeTokens` _and_
|
|
183
|
+
* published as CSS variables so WalletInfo / Portfolio / AppLauncher /
|
|
184
|
+
* WalletConnectModal render with the same palette.
|
|
185
|
+
*/
|
|
186
|
+
themeTokens?: ThemeTokens;
|
|
187
|
+
/**
|
|
188
|
+
* Mobile PIN keyboard mode forwarded to crossy-sdk's embedded modal.
|
|
189
|
+
*
|
|
190
|
+
* - 미지정/`'virtual'`: 기본 동작 (모바일=가상 numpad).
|
|
191
|
+
* - `'native'`: 모바일에서도 OS 기본 숫자 키보드를 사용.
|
|
192
|
+
* - 함수: PIN 모달이 띄워질 때마다 호출되어 동적으로 결정.
|
|
193
|
+
*
|
|
194
|
+
* @example pinKeyboard: 'native'
|
|
195
|
+
* @example pinKeyboard: () => prefersNativeKeyboard() ? 'native' : 'virtual'
|
|
196
|
+
*/
|
|
197
|
+
pinKeyboard?: PinKeyboardOption;
|
|
198
|
+
/** Which wallets to show in connect modal (defaults to all) */
|
|
199
|
+
wallets?: WalletId[];
|
|
200
|
+
/** Enable SSR hydration support (Next.js App Router) */
|
|
201
|
+
ssr?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* fiat→crypto 결제 표면(WalletInfo Buy 버튼, `useOnRamp` 훅) 활성화 토글.
|
|
204
|
+
* default false. true이면 embedded-wallet-gateway의 `/onramp/*` 엔드포인트로
|
|
205
|
+
* 라우팅된다 — DApp 식별자는 `crossProjectId`를 `X-Project-Id` 헤더로
|
|
206
|
+
* 그대로 사용한다. 엔드포인트 URL/provider 이름/secret은 노출하지 않는다.
|
|
207
|
+
*/
|
|
208
|
+
onRampEnabled?: boolean;
|
|
209
|
+
}
|
|
210
|
+
interface AppMetadata {
|
|
211
|
+
name: string;
|
|
212
|
+
description?: string;
|
|
213
|
+
url: string;
|
|
214
|
+
icons?: string[];
|
|
215
|
+
}
|
|
216
|
+
interface NetworkConfig {
|
|
217
|
+
/** EIP-155 numeric chain ID */
|
|
218
|
+
id: number;
|
|
219
|
+
name: string;
|
|
220
|
+
nativeCurrency: {
|
|
221
|
+
name: string;
|
|
222
|
+
symbol: string;
|
|
223
|
+
decimals: number;
|
|
224
|
+
};
|
|
225
|
+
rpcUrl: string;
|
|
226
|
+
blockExplorerUrl?: string;
|
|
227
|
+
testnet?: boolean;
|
|
228
|
+
}
|
|
229
|
+
type Unsubscribe = () => void;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Abstracts a wallet connector's lifecycle.
|
|
233
|
+
*
|
|
234
|
+
* In crossx-kit the wagmi package provides concrete implementations:
|
|
235
|
+
* - EmbeddedWalletConnector (crossy-sdk-js → wagmi connector)
|
|
236
|
+
* - CrossAppConnector (cross-sdk-js → wagmi connector, QR/deep-link)
|
|
237
|
+
* - CrossExtensionConnector (injected CROSSx Extension)
|
|
238
|
+
* - ExternalWalletConnector (Reown/WalletConnect for MetaMask, Binance, etc.)
|
|
239
|
+
*/
|
|
240
|
+
interface ConnectorPort {
|
|
241
|
+
readonly id: WalletId;
|
|
242
|
+
readonly name: string;
|
|
243
|
+
readonly type: ConnectorType;
|
|
244
|
+
readonly iconUrl?: string;
|
|
245
|
+
connect(params?: Record<string, unknown>): Promise<ConnectorResult>;
|
|
246
|
+
disconnect(): Promise<void>;
|
|
247
|
+
getAccount(): Promise<Account | null>;
|
|
248
|
+
isConnected(): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* For embedded wallets: switch to a different sub-wallet (account index).
|
|
251
|
+
* Returns null if the connector does not support wallet selection.
|
|
252
|
+
*/
|
|
253
|
+
selectWallet?(): Promise<{
|
|
254
|
+
address: string;
|
|
255
|
+
index: number;
|
|
256
|
+
} | null>;
|
|
257
|
+
onAccountChanged(cb: (account: Account) => void): Unsubscribe;
|
|
258
|
+
onChainChanged(cb: (chainId: number) => void): Unsubscribe;
|
|
259
|
+
onDisconnect(cb: () => void): Unsubscribe;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface StoragePort {
|
|
263
|
+
get(key: string): Promise<string | null>;
|
|
264
|
+
set(key: string, value: string): Promise<void>;
|
|
265
|
+
remove(key: string): Promise<void>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface ModalControlPort {
|
|
269
|
+
open(view: ModalView): void;
|
|
270
|
+
close(): void;
|
|
271
|
+
isOpen(): boolean;
|
|
272
|
+
onStateChange(cb: (isOpen: boolean, view: ModalView | null) => void): Unsubscribe;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
interface ThemePort {
|
|
276
|
+
getTheme(): Theme;
|
|
277
|
+
setTheme(theme: Partial<Theme>): void;
|
|
278
|
+
onThemeChange(cb: (theme: Theme) => void): Unsubscribe;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Detects available wallets in the current environment.
|
|
283
|
+
* Implementations use EIP-6963, window.ethereum probing, etc.
|
|
284
|
+
*/
|
|
285
|
+
interface WalletDetectionPort {
|
|
286
|
+
/** Returns currently detected wallets (snapshot) */
|
|
287
|
+
getDetectedWallets(): WalletDescriptor[];
|
|
288
|
+
/** Fires when the set of detected wallets changes (e.g. extension loads late) */
|
|
289
|
+
onWalletsChanged(cb: (wallets: WalletDescriptor[]) => void): Unsubscribe;
|
|
290
|
+
/** Check if a specific wallet is installed by its rdns or id */
|
|
291
|
+
isInstalled(walletId: string): boolean;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Tracks native/token balances across configured chains.
|
|
296
|
+
* Implementations fetch via viem public clients or RPC.
|
|
297
|
+
*/
|
|
298
|
+
interface BalancePort {
|
|
299
|
+
/** Fetch balances for the given address across all configured chains */
|
|
300
|
+
fetchBalances(address: string): Promise<ChainBalance[]>;
|
|
301
|
+
/** Subscribe to balance updates (polling or event-driven) */
|
|
302
|
+
onBalanceChanged(address: string, cb: (balances: ChainBalance[]) => void): Unsubscribe;
|
|
303
|
+
/** Force-refresh cached balances */
|
|
304
|
+
invalidate(): void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
type OAuthProvider = 'google' | 'apple';
|
|
308
|
+
/**
|
|
309
|
+
* Entry-point port for social sign-in. The UI layer only calls `signIn` and
|
|
310
|
+
* forgets — the underlying SDK is responsible for opening the OAuth popup,
|
|
311
|
+
* exchanging tokens, and waking the wagmi connector. Errors are owned by the
|
|
312
|
+
* SDK side (the UI does not display them; see CLAUDE.md §6).
|
|
313
|
+
*/
|
|
314
|
+
interface OAuthPort {
|
|
315
|
+
signIn(provider: OAuthProvider): Promise<void>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Theme-mode resolution.
|
|
320
|
+
*
|
|
321
|
+
* Color/typography/layout tokens now live in
|
|
322
|
+
* `@nexus-cross/crossx-design-system` and are published as `--ds-*` CSS
|
|
323
|
+
* variables by `@nexus-cross/connect-kit-react`'s `CrossConnectKitProvider`.
|
|
324
|
+
* Core keeps only the pure mode resolver, which has no env/SDK coupling.
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Resolve the effective {@link ThemeMode} that should be applied.
|
|
329
|
+
* When `autoDetect` is true (and a `window` is available), reads
|
|
330
|
+
* `prefers-color-scheme`; otherwise falls back to `explicit ?? 'dark'`.
|
|
331
|
+
*/
|
|
332
|
+
declare function resolveThemeMode(explicit: ThemeMode | Partial<{
|
|
333
|
+
mode: ThemeMode;
|
|
334
|
+
}> | undefined, autoDetect: boolean | undefined): ThemeMode;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Blockchain numeric formatting utilities — BigInt-only, floor-truncated.
|
|
338
|
+
*
|
|
339
|
+
* These utilities enforce CLAUDE.md §4 Blockchain Numeric Handling:
|
|
340
|
+
* - Inputs are BigInt (never Number) for wei-scale values.
|
|
341
|
+
* - Output is a display string; MUST NOT be parsed back into computation.
|
|
342
|
+
* - Rounding is floor (truncate toward zero) — users never see more than
|
|
343
|
+
* they actually have. BigInt division naturally floors.
|
|
344
|
+
*
|
|
345
|
+
* Signed inputs are accepted (e.g. PnL deltas): the sign is preserved and
|
|
346
|
+
* the magnitude is floor-truncated to `displayDecimals`.
|
|
347
|
+
*/
|
|
348
|
+
/**
|
|
349
|
+
* Format a BigInt balance in raw base units (e.g. wei) to a human-readable
|
|
350
|
+
* decimal string with floor truncation at `displayDecimals` digits.
|
|
351
|
+
*
|
|
352
|
+
* @param value Raw balance in the smallest unit (wei for ETH, etc.)
|
|
353
|
+
* @param decimals Token decimals (e.g. 18 for ETH, 6 for USDC)
|
|
354
|
+
* @param displayDecimals How many fractional digits to show. Defaults to 4.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* formatBalance(1234567890000000000n, 18) // "1.2345"
|
|
358
|
+
* formatBalance(1234567890000000000n, 18, 2) // "1.23"
|
|
359
|
+
* formatBalance(500000000n, 6) // "500"
|
|
360
|
+
* formatBalance(-123n, 0) // "-123"
|
|
361
|
+
*/
|
|
362
|
+
declare function formatBalance(value: bigint, decimals: number, displayDecimals?: number): string;
|
|
363
|
+
/**
|
|
364
|
+
* Shortcut for 18-decimal tokens (native ETH/CROSS on EVM chains).
|
|
365
|
+
* Equivalent to `formatBalance(wei, 18, displayDecimals)`.
|
|
366
|
+
*/
|
|
367
|
+
declare function formatWei(wei: bigint, displayDecimals?: number): string;
|
|
368
|
+
|
|
369
|
+
export { type Account, type AppMetadata, type BalancePort, type ChainBalance, type ColorOverrides, ConnectionStatus, type ConnectorPort, type ConnectorResult, type ConnectorType, type CrossConnectKitConfig, type ModalControlPort, type ModalView, type NetworkConfig, type OAuthPort, type OAuthProvider, type PinKeyboardMode, type PinKeyboardOption, type StoragePort, type Theme, type ThemeMode, type ThemePort, type ThemeTokens, type Unsubscribe, type WalletDescriptor, type WalletDetectionPort, type WalletId, type WalletState, formatBalance, formatWei, resolveThemeMode };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// Theme-mode resolver. Color/typography/layout tokens live in
|
|
3
|
-
// `@nexus-cross/crossx-design-system` (published as `--ds-*`); core only
|
|
4
|
-
// resolves which mode is active.
|
|
5
|
-
export { resolveThemeMode } from './core/theme/tokens.js';
|
|
6
|
-
// Utilities
|
|
7
|
-
export { formatBalance, formatWei } from './core/utils/balance.js';
|
|
8
|
-
export { OnRampError, normalizeDisallowReason } from '@nexus-cross/onramp';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
var f={CONNECTED:"connected",DISCONNECTED:"disconnected",CONNECTING:"connecting",RECONNECTING:"reconnecting"};function u(e,t){if(t&&typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{}return typeof e=="string"?e:e&&typeof e=="object"&&"mode"in e?e.mode??"dark":"dark"}function m(e,t,r=4){if(t<0||!Number.isInteger(t))throw new RangeError(`formatBalance: decimals must be a non-negative integer, got ${t}`);if(r<0||!Number.isInteger(r))throw new RangeError(`formatBalance: displayDecimals must be a non-negative integer, got ${r}`);let n=e<0n,i=n?-e:e;if(t===0){let o=i.toString();return n?`-${o}`:o}let d=10n**BigInt(t),s=i/d,g=i%d;if(r===0){let o=s.toString();return n?`-${o}`:o}let c=g.toString().padStart(t,"0").slice(0,r),a=c.length;for(;a>0&&c.charCodeAt(a-1)===48;)a--;let l=c.slice(0,a),p=l?`${s}.${l}`:s.toString();return n?`-${p}`:p}function y(e,t=4){return m(e,18,t)}import{OnRampError as S,normalizeDisallowReason as I}from"@nexus-cross/onramp";export{f as ConnectionStatus,S as OnRampError,m as formatBalance,y as formatWei,I as normalizeDisallowReason,u as resolveThemeMode};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cross/connect-kit-core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Core domain logic for @nexus-cross/connect-kit — types, ports, utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,17 +14,22 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
|
+
"sideEffects": false,
|
|
17
18
|
"publishConfig": {
|
|
18
19
|
"registry": "https://registry.npmjs.org",
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@nexus-cross/onramp": "
|
|
23
|
+
"@nexus-cross/onramp": "1.3.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsup": "^8.4.0",
|
|
27
|
+
"typescript": "^5.7.0"
|
|
23
28
|
},
|
|
24
29
|
"license": "MIT",
|
|
25
30
|
"scripts": {
|
|
26
|
-
"build": "
|
|
27
|
-
"dev": "
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"dev": "tsup --watch",
|
|
28
33
|
"test": "vitest run",
|
|
29
34
|
"test:watch": "vitest",
|
|
30
35
|
"typecheck": "tsc --noEmit"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ChainBalance, Unsubscribe } from '../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Tracks native/token balances across configured chains.
|
|
4
|
-
* Implementations fetch via viem public clients or RPC.
|
|
5
|
-
*/
|
|
6
|
-
export interface BalancePort {
|
|
7
|
-
/** Fetch balances for the given address across all configured chains */
|
|
8
|
-
fetchBalances(address: string): Promise<ChainBalance[]>;
|
|
9
|
-
/** Subscribe to balance updates (polling or event-driven) */
|
|
10
|
-
onBalanceChanged(address: string, cb: (balances: ChainBalance[]) => void): Unsubscribe;
|
|
11
|
-
/** Force-refresh cached balances */
|
|
12
|
-
invalidate(): void;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=BalancePort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BalancePort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/BalancePort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAExD,6DAA6D;IAC7D,gBAAgB,CACd,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,IAAI,GACrC,WAAW,CAAC;IAEf,oCAAoC;IACpC,UAAU,IAAI,IAAI,CAAC;CACpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BalancePort.js","sourceRoot":"","sources":["../../../src/core/ports/BalancePort.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Account, ConnectorResult, ConnectorType, Unsubscribe, WalletId } from '../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Abstracts a wallet connector's lifecycle.
|
|
4
|
-
*
|
|
5
|
-
* In crossx-kit the wagmi package provides concrete implementations:
|
|
6
|
-
* - EmbeddedWalletConnector (crossy-sdk-js → wagmi connector)
|
|
7
|
-
* - CrossAppConnector (cross-sdk-js → wagmi connector, QR/deep-link)
|
|
8
|
-
* - CrossExtensionConnector (injected CROSSx Extension)
|
|
9
|
-
* - ExternalWalletConnector (Reown/WalletConnect for MetaMask, Binance, etc.)
|
|
10
|
-
*/
|
|
11
|
-
export interface ConnectorPort {
|
|
12
|
-
readonly id: WalletId;
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly type: ConnectorType;
|
|
15
|
-
readonly iconUrl?: string;
|
|
16
|
-
connect(params?: Record<string, unknown>): Promise<ConnectorResult>;
|
|
17
|
-
disconnect(): Promise<void>;
|
|
18
|
-
getAccount(): Promise<Account | null>;
|
|
19
|
-
isConnected(): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* For embedded wallets: switch to a different sub-wallet (account index).
|
|
22
|
-
* Returns null if the connector does not support wallet selection.
|
|
23
|
-
*/
|
|
24
|
-
selectWallet?(): Promise<{
|
|
25
|
-
address: string;
|
|
26
|
-
index: number;
|
|
27
|
-
} | null>;
|
|
28
|
-
onAccountChanged(cb: (account: Account) => void): Unsubscribe;
|
|
29
|
-
onChainChanged(cb: (chainId: number) => void): Unsubscribe;
|
|
30
|
-
onDisconnect(cb: () => void): Unsubscribe;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=ConnectorPort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectorPort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/ConnectorPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACpE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,UAAU,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACtC,WAAW,IAAI,OAAO,CAAC;IAEvB;;;OAGG;IACH,YAAY,CAAC,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAEpE,gBAAgB,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,WAAW,CAAC;IAC9D,cAAc,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW,CAAC;IAC3D,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectorPort.js","sourceRoot":"","sources":["../../../src/core/ports/ConnectorPort.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ModalView, Unsubscribe } from '../types/index.js';
|
|
2
|
-
export interface ModalControlPort {
|
|
3
|
-
open(view: ModalView): void;
|
|
4
|
-
close(): void;
|
|
5
|
-
isOpen(): boolean;
|
|
6
|
-
onStateChange(cb: (isOpen: boolean, view: ModalView | null) => void): Unsubscribe;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=ModalControlPort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalControlPort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/ModalControlPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,GAAG,WAAW,CAAC;CACnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalControlPort.js","sourceRoot":"","sources":["../../../src/core/ports/ModalControlPort.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type OAuthProvider = 'google' | 'apple';
|
|
2
|
-
/**
|
|
3
|
-
* Entry-point port for social sign-in. The UI layer only calls `signIn` and
|
|
4
|
-
* forgets — the underlying SDK is responsible for opening the OAuth popup,
|
|
5
|
-
* exchanging tokens, and waking the wagmi connector. Errors are owned by the
|
|
6
|
-
* SDK side (the UI does not display them; see CLAUDE.md §6).
|
|
7
|
-
*/
|
|
8
|
-
export interface OAuthPort {
|
|
9
|
-
signIn(provider: OAuthProvider): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=OAuthPort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthPort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/OAuthPort.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthPort.js","sourceRoot":"","sources":["../../../src/core/ports/OAuthPort.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StoragePort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/StoragePort.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StoragePort.js","sourceRoot":"","sources":["../../../src/core/ports/StoragePort.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemePort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/ThemePort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,SAAS;IACxB,QAAQ,IAAI,KAAK,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,WAAW,CAAC;CACxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemePort.js","sourceRoot":"","sources":["../../../src/core/ports/ThemePort.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { WalletDescriptor, Unsubscribe } from '../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Detects available wallets in the current environment.
|
|
4
|
-
* Implementations use EIP-6963, window.ethereum probing, etc.
|
|
5
|
-
*/
|
|
6
|
-
export interface WalletDetectionPort {
|
|
7
|
-
/** Returns currently detected wallets (snapshot) */
|
|
8
|
-
getDetectedWallets(): WalletDescriptor[];
|
|
9
|
-
/** Fires when the set of detected wallets changes (e.g. extension loads late) */
|
|
10
|
-
onWalletsChanged(cb: (wallets: WalletDescriptor[]) => void): Unsubscribe;
|
|
11
|
-
/** Check if a specific wallet is installed by its rdns or id */
|
|
12
|
-
isInstalled(walletId: string): boolean;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=WalletDetectionPort.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WalletDetectionPort.d.ts","sourceRoot":"","sources":["../../../src/core/ports/WalletDetectionPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,kBAAkB,IAAI,gBAAgB,EAAE,CAAC;IAEzC,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,IAAI,GAAG,WAAW,CAAC;IAEzE,gEAAgE;IAChE,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WalletDetectionPort.js","sourceRoot":"","sources":["../../../src/core/ports/WalletDetectionPort.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Theme-mode resolution.
|
|
3
|
-
*
|
|
4
|
-
* Color/typography/layout tokens now live in
|
|
5
|
-
* `@nexus-cross/crossx-design-system` and are published as `--ds-*` CSS
|
|
6
|
-
* variables by `@nexus-cross/connect-kit-react`'s `CrossConnectKitProvider`.
|
|
7
|
-
* Core keeps only the pure mode resolver, which has no env/SDK coupling.
|
|
8
|
-
*/
|
|
9
|
-
import type { ThemeMode } from '../types/index.js';
|
|
10
|
-
/**
|
|
11
|
-
* Resolve the effective {@link ThemeMode} that should be applied.
|
|
12
|
-
* When `autoDetect` is true (and a `window` is available), reads
|
|
13
|
-
* `prefers-color-scheme`; otherwise falls back to `explicit ?? 'dark'`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function resolveThemeMode(explicit: ThemeMode | Partial<{
|
|
16
|
-
mode: ThemeMode;
|
|
17
|
-
}> | undefined, autoDetect: boolean | undefined): ThemeMode;
|
|
18
|
-
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/core/theme/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,GAAG,SAAS,EAC9D,UAAU,EAAE,OAAO,GAAG,SAAS,GAC9B,SAAS,CAeX"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Theme-mode resolution.
|
|
3
|
-
*
|
|
4
|
-
* Color/typography/layout tokens now live in
|
|
5
|
-
* `@nexus-cross/crossx-design-system` and are published as `--ds-*` CSS
|
|
6
|
-
* variables by `@nexus-cross/connect-kit-react`'s `CrossConnectKitProvider`.
|
|
7
|
-
* Core keeps only the pure mode resolver, which has no env/SDK coupling.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Resolve the effective {@link ThemeMode} that should be applied.
|
|
11
|
-
* When `autoDetect` is true (and a `window` is available), reads
|
|
12
|
-
* `prefers-color-scheme`; otherwise falls back to `explicit ?? 'dark'`.
|
|
13
|
-
*/
|
|
14
|
-
export function resolveThemeMode(explicit, autoDetect) {
|
|
15
|
-
if (autoDetect && typeof window !== 'undefined' && window.matchMedia) {
|
|
16
|
-
try {
|
|
17
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
18
|
-
? 'dark'
|
|
19
|
-
: 'light';
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
/* fall through */
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (typeof explicit === 'string')
|
|
26
|
-
return explicit;
|
|
27
|
-
if (explicit && typeof explicit === 'object' && 'mode' in explicit) {
|
|
28
|
-
return explicit.mode ?? 'dark';
|
|
29
|
-
}
|
|
30
|
-
return 'dark';
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/core/theme/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA8D,EAC9D,UAA+B;IAE/B,IAAI,UAAU,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACrE,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO;gBAC9D,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,OAAO,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClD,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,QAAQ,EAAE,CAAC;QACnE,OAAO,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a connector reaches the blockchain:
|
|
3
|
-
* - embedded: In-app wallet via crossy-sdk-js (social login, no extension)
|
|
4
|
-
* - app: CROSSx mobile app deep-link / QR approval
|
|
5
|
-
* - extension: Browser extension (CROSSx Extension, injected EIP-1193)
|
|
6
|
-
* - external: Third-party wallets via Reown/WalletConnect (MetaMask, Binance …)
|
|
7
|
-
*/
|
|
8
|
-
export type ConnectorType = 'embedded' | 'app' | 'extension' | 'external';
|
|
9
|
-
/**
|
|
10
|
-
* Well-known wallet identifiers used throughout the kit.
|
|
11
|
-
* Maps 1:1 to posa's WalletType union so existing apps migrate trivially.
|
|
12
|
-
*/
|
|
13
|
-
export type WalletId = 'cross_embedded' | 'cross_wallet' | 'cross_extension' | 'metamask' | 'binance' | (string & {});
|
|
14
|
-
export interface WalletDescriptor {
|
|
15
|
-
readonly id: WalletId;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly type: ConnectorType;
|
|
18
|
-
readonly iconUrl?: string;
|
|
19
|
-
/** EIP-6963 rdns for browser-extension detection */
|
|
20
|
-
readonly rdns?: string;
|
|
21
|
-
/** Install URL when extension is not detected */
|
|
22
|
-
readonly installUrl?: string;
|
|
23
|
-
/** Whether the wallet is available in the current environment */
|
|
24
|
-
installed?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface ConnectorResult {
|
|
27
|
-
account: Account;
|
|
28
|
-
chainId: number;
|
|
29
|
-
}
|
|
30
|
-
export interface Account {
|
|
31
|
-
/** 0x-prefixed hex string */
|
|
32
|
-
address: string;
|
|
33
|
-
chainId: number;
|
|
34
|
-
}
|
|
35
|
-
export interface ChainBalance {
|
|
36
|
-
/** EIP-155 numeric chain ID */
|
|
37
|
-
chainId: number;
|
|
38
|
-
/** Human-readable decimal string (e.g. "1234.5678") */
|
|
39
|
-
balance: string;
|
|
40
|
-
/** Raw integer string in wei */
|
|
41
|
-
balanceWei: string;
|
|
42
|
-
}
|
|
43
|
-
export declare const ConnectionStatus: {
|
|
44
|
-
readonly CONNECTED: "connected";
|
|
45
|
-
readonly DISCONNECTED: "disconnected";
|
|
46
|
-
readonly CONNECTING: "connecting";
|
|
47
|
-
readonly RECONNECTING: "reconnecting";
|
|
48
|
-
};
|
|
49
|
-
export type ConnectionStatus = (typeof ConnectionStatus)[keyof typeof ConnectionStatus];
|
|
50
|
-
export interface WalletState {
|
|
51
|
-
status: ConnectionStatus;
|
|
52
|
-
/** Connected wallet address, undefined when disconnected */
|
|
53
|
-
address: string | undefined;
|
|
54
|
-
/** Currently active wallet identifier */
|
|
55
|
-
activeWalletId: WalletId | null;
|
|
56
|
-
/** True while auto-reconnecting from a previous session */
|
|
57
|
-
isReconnecting: boolean;
|
|
58
|
-
/** Per-chain balances (populated when balance tracking is enabled) */
|
|
59
|
-
chainBalances: ChainBalance[];
|
|
60
|
-
}
|
|
61
|
-
export type ModalView = 'connect' | 'account' | 'chain' | 'wallet-info';
|
|
62
|
-
/**
|
|
63
|
-
* Theme mode — mirrors `crossy-sdk-js`'s `SDKConfig.theme` literal union.
|
|
64
|
-
* `autoDetectTheme: true` overrides this at runtime with
|
|
65
|
-
* `prefers-color-scheme`.
|
|
66
|
-
*/
|
|
67
|
-
export type ThemeMode = 'light' | 'dark';
|
|
68
|
-
/**
|
|
69
|
-
* Semantic color overrides. Mirrors `crossy-sdk-js`'s `SDKColorOverrides`
|
|
70
|
-
* 1:1 so `@nexus-cross/connect-kit-core` can forward them into the
|
|
71
|
-
* embedded SDK and — via the CSS variables generated by
|
|
72
|
-
* `buildThemeCssText` — apply them uniformly to WalletInfo / Portfolio /
|
|
73
|
-
* AppLauncher / WalletConnectModal.
|
|
74
|
-
*
|
|
75
|
-
* All values are plain CSS color strings (e.g. `"#019D92"`,
|
|
76
|
-
* `"rgba(18,18,18,0.7)"`).
|
|
77
|
-
*/
|
|
78
|
-
export interface ColorOverrides {
|
|
79
|
-
/** Buttons, accents, active state. Default `#019D92`. */
|
|
80
|
-
primary?: string;
|
|
81
|
-
/** Error/alert highlight (PIN error etc.). Default `#E70077`. */
|
|
82
|
-
secondary?: string;
|
|
83
|
-
/** Text/icon color placed on top of `primary`. Default `#FFFFFF`. */
|
|
84
|
-
onPrimary?: string;
|
|
85
|
-
/** Card outline border. */
|
|
86
|
-
borderDefault?: string;
|
|
87
|
-
/** Dividers, input outlines. */
|
|
88
|
-
borderSubtle?: string;
|
|
89
|
-
/** Titles, primary text. */
|
|
90
|
-
textIconPrimary?: string;
|
|
91
|
-
/** Secondary copy, labels. */
|
|
92
|
-
textIconSecondary?: string;
|
|
93
|
-
/** Hints, disabled text, tertiary icons. */
|
|
94
|
-
textIconTertiary?: string;
|
|
95
|
-
/** Inline highlighted surfaces (pills, hover, input field bg). */
|
|
96
|
-
surfaceDefault?: string;
|
|
97
|
-
/** Stronger neutral surfaces (divider fill, secondary bg). */
|
|
98
|
-
surfaceSubtle?: string;
|
|
99
|
-
/** Modal / card root background. */
|
|
100
|
-
bg?: string;
|
|
101
|
-
/** Error state, independent from `secondary`. Default `#E70077`. */
|
|
102
|
-
error?: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Per-mode theme overrides. `light` is applied when `theme === 'light'`,
|
|
106
|
-
* `dark` is applied when `theme === 'dark'`. Omitted fields fall back to
|
|
107
|
-
* crossy-sdk's built-in palette.
|
|
108
|
-
*
|
|
109
|
-
* Mirrors `crossy-sdk-js`'s `SDKThemeTokens` so the same literal value
|
|
110
|
-
* can be forwarded straight into the embedded SDK.
|
|
111
|
-
*/
|
|
112
|
-
export interface ThemeTokens {
|
|
113
|
-
light?: ColorOverrides;
|
|
114
|
-
dark?: ColorOverrides;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @deprecated Use `ThemeMode` / `ThemeTokens` instead.
|
|
118
|
-
* Legacy shape kept for older consumers that typed on the `mode`/
|
|
119
|
-
* `accentColor` fields. New code should pass `theme: 'dark'` and
|
|
120
|
-
* `themeTokens: { dark: { primary: ... } }` at the `CrossConnectKitConfig`
|
|
121
|
-
* level.
|
|
122
|
-
*/
|
|
123
|
-
export interface Theme {
|
|
124
|
-
mode: ThemeMode;
|
|
125
|
-
accentColor?: string;
|
|
126
|
-
borderRadius?: 'none' | 'small' | 'medium' | 'large';
|
|
127
|
-
fontFamily?: string;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* PIN 입력 모달에서 모바일 키보드 노출 방식.
|
|
131
|
-
*
|
|
132
|
-
* Mirrors `crossy-sdk-js`'s `PinKeyboardMode` 1:1 so the kit-level value
|
|
133
|
-
* can be forwarded straight into the embedded SDK.
|
|
134
|
-
*
|
|
135
|
-
* - `'virtual'` (기본): SDK가 그리는 가상 numpad가 모바일에서 뜸.
|
|
136
|
-
* - `'native'`: 모바일에서도 input box를 노출 → OS 기본 숫자 키보드가 뜸.
|
|
137
|
-
*
|
|
138
|
-
* 데스크탑에서는 두 값 모두 동일하게 input box가 보입니다.
|
|
139
|
-
*/
|
|
140
|
-
export type PinKeyboardMode = 'virtual' | 'native';
|
|
141
|
-
/**
|
|
142
|
-
* PIN 키보드 분기 옵션.
|
|
143
|
-
*
|
|
144
|
-
* - 값(`'native'` / `'virtual'`)을 주면 정적으로 고정.
|
|
145
|
-
* - 함수를 주면 PIN 모달이 띄워질 때마다 호출되어 동적으로 결정.
|
|
146
|
-
*
|
|
147
|
-
* Mirrors `crossy-sdk-js`'s `PinKeyboardOption`.
|
|
148
|
-
*/
|
|
149
|
-
export type PinKeyboardOption = PinKeyboardMode | (() => PinKeyboardMode);
|
|
150
|
-
export interface CrossConnectKitConfig {
|
|
151
|
-
/** CROSS relay project ID (CROSSx 1.0 / @to-nexus/sdk walletConnect). Also used as `embeddedProjectId` fallback. */
|
|
152
|
-
crossProjectId: string;
|
|
153
|
-
/** Reown project ID (for WalletConnect / external wallets) */
|
|
154
|
-
reownProjectId?: string;
|
|
155
|
-
/** CROSSx 2.0 embedded wallet project ID (@nexus-cross/crossx-sdk). Falls back to `crossProjectId` when omitted. */
|
|
156
|
-
embeddedProjectId?: string;
|
|
157
|
-
/** App metadata for WalletConnect pairing */
|
|
158
|
-
appMetadata: AppMetadata;
|
|
159
|
-
/** Supported networks */
|
|
160
|
-
networks: readonly NetworkConfig[];
|
|
161
|
-
/** Default network (first connection lands here) */
|
|
162
|
-
defaultNetwork?: NetworkConfig;
|
|
163
|
-
/**
|
|
164
|
-
* Theme mode applied across every surface the kit renders:
|
|
165
|
-
* - crossy-sdk confirmation / login modals
|
|
166
|
-
* - `WalletInfo`, `WalletPortfolio`, `WalletConnectModal`, `AppLauncher`
|
|
167
|
-
* Defaults to `'dark'`.
|
|
168
|
-
*
|
|
169
|
-
* Accepts both the new literal (`'light' | 'dark'`) and the legacy
|
|
170
|
-
* `Partial<Theme>` object (`{ mode: 'dark' }`) so older DApps keep
|
|
171
|
-
* building while migrating.
|
|
172
|
-
*/
|
|
173
|
-
theme?: ThemeMode | Partial<Theme>;
|
|
174
|
-
/**
|
|
175
|
-
* When `true`, ignore `theme` and follow `prefers-color-scheme`.
|
|
176
|
-
* Mirrors crossy-sdk's `SDKConfig.autoDetectTheme`.
|
|
177
|
-
*/
|
|
178
|
-
autoDetectTheme?: boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Color token overrides forwarded to crossy-sdk's `themeTokens` _and_
|
|
181
|
-
* published as CSS variables so WalletInfo / Portfolio / AppLauncher /
|
|
182
|
-
* WalletConnectModal render with the same palette.
|
|
183
|
-
*/
|
|
184
|
-
themeTokens?: ThemeTokens;
|
|
185
|
-
/**
|
|
186
|
-
* Mobile PIN keyboard mode forwarded to crossy-sdk's embedded modal.
|
|
187
|
-
*
|
|
188
|
-
* - 미지정/`'virtual'`: 기본 동작 (모바일=가상 numpad).
|
|
189
|
-
* - `'native'`: 모바일에서도 OS 기본 숫자 키보드를 사용.
|
|
190
|
-
* - 함수: PIN 모달이 띄워질 때마다 호출되어 동적으로 결정.
|
|
191
|
-
*
|
|
192
|
-
* @example pinKeyboard: 'native'
|
|
193
|
-
* @example pinKeyboard: () => prefersNativeKeyboard() ? 'native' : 'virtual'
|
|
194
|
-
*/
|
|
195
|
-
pinKeyboard?: PinKeyboardOption;
|
|
196
|
-
/** Which wallets to show in connect modal (defaults to all) */
|
|
197
|
-
wallets?: WalletId[];
|
|
198
|
-
/** Enable SSR hydration support (Next.js App Router) */
|
|
199
|
-
ssr?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* fiat→crypto 결제 표면(WalletInfo Buy 버튼, `useOnRamp` 훅) 활성화 토글.
|
|
202
|
-
* default false. true이면 embedded-wallet-gateway의 `/onramp/*` 엔드포인트로
|
|
203
|
-
* 라우팅된다 — DApp 식별자는 `crossProjectId`를 `X-Project-Id` 헤더로
|
|
204
|
-
* 그대로 사용한다. 엔드포인트 URL/provider 이름/secret은 노출하지 않는다.
|
|
205
|
-
*/
|
|
206
|
-
onRampEnabled?: boolean;
|
|
207
|
-
}
|
|
208
|
-
export interface AppMetadata {
|
|
209
|
-
name: string;
|
|
210
|
-
description?: string;
|
|
211
|
-
url: string;
|
|
212
|
-
icons?: string[];
|
|
213
|
-
}
|
|
214
|
-
export interface NetworkConfig {
|
|
215
|
-
/** EIP-155 numeric chain ID */
|
|
216
|
-
id: number;
|
|
217
|
-
name: string;
|
|
218
|
-
nativeCurrency: {
|
|
219
|
-
name: string;
|
|
220
|
-
symbol: string;
|
|
221
|
-
decimals: number;
|
|
222
|
-
};
|
|
223
|
-
rpcUrl: string;
|
|
224
|
-
blockExplorerUrl?: string;
|
|
225
|
-
testnet?: boolean;
|
|
226
|
-
}
|
|
227
|
-
export type Unsubscribe = () => void;
|
|
228
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAChB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAMlB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAA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CAAC;IACzB,yBAAyB;IACzB,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,oDAAoD;IACpD,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;IACrB,wDAAwD;IACxD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC"}
|
package/dist/core/types/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// Connector taxonomy
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// Wallet connection state
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
export const ConnectionStatus = {
|
|
8
|
-
CONNECTED: 'connected',
|
|
9
|
-
DISCONNECTED: 'disconnected',
|
|
10
|
-
CONNECTING: 'connecting',
|
|
11
|
-
RECONNECTING: 'reconnecting',
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAoE9E,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;CACpB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Blockchain numeric formatting utilities — BigInt-only, floor-truncated.
|
|
3
|
-
*
|
|
4
|
-
* These utilities enforce CLAUDE.md §4 Blockchain Numeric Handling:
|
|
5
|
-
* - Inputs are BigInt (never Number) for wei-scale values.
|
|
6
|
-
* - Output is a display string; MUST NOT be parsed back into computation.
|
|
7
|
-
* - Rounding is floor (truncate toward zero) — users never see more than
|
|
8
|
-
* they actually have. BigInt division naturally floors.
|
|
9
|
-
*
|
|
10
|
-
* Signed inputs are accepted (e.g. PnL deltas): the sign is preserved and
|
|
11
|
-
* the magnitude is floor-truncated to `displayDecimals`.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Format a BigInt balance in raw base units (e.g. wei) to a human-readable
|
|
15
|
-
* decimal string with floor truncation at `displayDecimals` digits.
|
|
16
|
-
*
|
|
17
|
-
* @param value Raw balance in the smallest unit (wei for ETH, etc.)
|
|
18
|
-
* @param decimals Token decimals (e.g. 18 for ETH, 6 for USDC)
|
|
19
|
-
* @param displayDecimals How many fractional digits to show. Defaults to 4.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* formatBalance(1234567890000000000n, 18) // "1.2345"
|
|
23
|
-
* formatBalance(1234567890000000000n, 18, 2) // "1.23"
|
|
24
|
-
* formatBalance(500000000n, 6) // "500"
|
|
25
|
-
* formatBalance(-123n, 0) // "-123"
|
|
26
|
-
*/
|
|
27
|
-
export declare function formatBalance(value: bigint, decimals: number, displayDecimals?: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* Shortcut for 18-decimal tokens (native ETH/CROSS on EVM chains).
|
|
30
|
-
* Equivalent to `formatBalance(wei, 18, displayDecimals)`.
|
|
31
|
-
*/
|
|
32
|
-
export declare function formatWei(wei: bigint, displayDecimals?: number): string;
|
|
33
|
-
//# sourceMappingURL=balance.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../../src/core/utils/balance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,eAAe,SAAI,GAClB,MAAM,CAqCR;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,SAAI,GAAG,MAAM,CAElE"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Blockchain numeric formatting utilities — BigInt-only, floor-truncated.
|
|
3
|
-
*
|
|
4
|
-
* These utilities enforce CLAUDE.md §4 Blockchain Numeric Handling:
|
|
5
|
-
* - Inputs are BigInt (never Number) for wei-scale values.
|
|
6
|
-
* - Output is a display string; MUST NOT be parsed back into computation.
|
|
7
|
-
* - Rounding is floor (truncate toward zero) — users never see more than
|
|
8
|
-
* they actually have. BigInt division naturally floors.
|
|
9
|
-
*
|
|
10
|
-
* Signed inputs are accepted (e.g. PnL deltas): the sign is preserved and
|
|
11
|
-
* the magnitude is floor-truncated to `displayDecimals`.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Format a BigInt balance in raw base units (e.g. wei) to a human-readable
|
|
15
|
-
* decimal string with floor truncation at `displayDecimals` digits.
|
|
16
|
-
*
|
|
17
|
-
* @param value Raw balance in the smallest unit (wei for ETH, etc.)
|
|
18
|
-
* @param decimals Token decimals (e.g. 18 for ETH, 6 for USDC)
|
|
19
|
-
* @param displayDecimals How many fractional digits to show. Defaults to 4.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* formatBalance(1234567890000000000n, 18) // "1.2345"
|
|
23
|
-
* formatBalance(1234567890000000000n, 18, 2) // "1.23"
|
|
24
|
-
* formatBalance(500000000n, 6) // "500"
|
|
25
|
-
* formatBalance(-123n, 0) // "-123"
|
|
26
|
-
*/
|
|
27
|
-
export function formatBalance(value, decimals, displayDecimals = 4) {
|
|
28
|
-
if (decimals < 0 || !Number.isInteger(decimals)) {
|
|
29
|
-
throw new RangeError(`formatBalance: decimals must be a non-negative integer, got ${decimals}`);
|
|
30
|
-
}
|
|
31
|
-
if (displayDecimals < 0 || !Number.isInteger(displayDecimals)) {
|
|
32
|
-
throw new RangeError(`formatBalance: displayDecimals must be a non-negative integer, got ${displayDecimals}`);
|
|
33
|
-
}
|
|
34
|
-
const negative = value < 0n;
|
|
35
|
-
const magnitude = negative ? -value : value;
|
|
36
|
-
if (decimals === 0) {
|
|
37
|
-
const integerOnly = magnitude.toString();
|
|
38
|
-
return negative ? `-${integerOnly}` : integerOnly;
|
|
39
|
-
}
|
|
40
|
-
const divisor = 10n ** BigInt(decimals);
|
|
41
|
-
const whole = magnitude / divisor;
|
|
42
|
-
const remainder = magnitude % divisor;
|
|
43
|
-
if (displayDecimals === 0) {
|
|
44
|
-
const out = whole.toString();
|
|
45
|
-
return negative ? `-${out}` : out;
|
|
46
|
-
}
|
|
47
|
-
const fracFull = remainder.toString().padStart(decimals, '0');
|
|
48
|
-
// Floor by slicing — never rounds up.
|
|
49
|
-
const fracSliced = fracFull.slice(0, displayDecimals);
|
|
50
|
-
// Trailing-zero trim via index walk (avoids /0+$/ regex flagged as ReDoS by
|
|
51
|
-
// Sonar S5852). Linear, backtracking-free, and cheaper than a regex engine.
|
|
52
|
-
let end = fracSliced.length;
|
|
53
|
-
while (end > 0 && fracSliced.charCodeAt(end - 1) === 48)
|
|
54
|
-
end--;
|
|
55
|
-
const fracTrimmed = fracSliced.slice(0, end);
|
|
56
|
-
const body = fracTrimmed ? `${whole}.${fracTrimmed}` : whole.toString();
|
|
57
|
-
return negative ? `-${body}` : body;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Shortcut for 18-decimal tokens (native ETH/CROSS on EVM chains).
|
|
61
|
-
* Equivalent to `formatBalance(wei, 18, displayDecimals)`.
|
|
62
|
-
*/
|
|
63
|
-
export function formatWei(wei, displayDecimals = 4) {
|
|
64
|
-
return formatBalance(wei, 18, displayDecimals);
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=balance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../../src/core/utils/balance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,QAAgB,EAChB,eAAe,GAAG,CAAC;IAEnB,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,UAAU,CAAC,+DAA+D,QAAQ,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,IAAI,eAAe,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,UAA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