@nexus-cross/connect-kit-core 1.0.0-beta.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/README.md +108 -0
- package/dist/core/ports/BalancePort.d.ts +14 -0
- package/dist/core/ports/BalancePort.d.ts.map +1 -0
- package/dist/core/ports/BalancePort.js +2 -0
- package/dist/core/ports/BalancePort.js.map +1 -0
- package/dist/core/ports/ConnectorPort.d.ts +32 -0
- package/dist/core/ports/ConnectorPort.d.ts.map +1 -0
- package/dist/core/ports/ConnectorPort.js +2 -0
- package/dist/core/ports/ConnectorPort.js.map +1 -0
- package/dist/core/ports/ModalControlPort.d.ts +8 -0
- package/dist/core/ports/ModalControlPort.d.ts.map +1 -0
- package/dist/core/ports/ModalControlPort.js +2 -0
- package/dist/core/ports/ModalControlPort.js.map +1 -0
- package/dist/core/ports/StoragePort.d.ts +6 -0
- package/dist/core/ports/StoragePort.d.ts.map +1 -0
- package/dist/core/ports/StoragePort.js +2 -0
- package/dist/core/ports/StoragePort.js.map +1 -0
- package/dist/core/ports/ThemePort.d.ts +7 -0
- package/dist/core/ports/ThemePort.d.ts.map +1 -0
- package/dist/core/ports/ThemePort.js +2 -0
- package/dist/core/ports/ThemePort.js.map +1 -0
- package/dist/core/ports/WalletDetectionPort.d.ts +14 -0
- package/dist/core/ports/WalletDetectionPort.d.ts.map +1 -0
- package/dist/core/ports/WalletDetectionPort.js +2 -0
- package/dist/core/ports/WalletDetectionPort.js.map +1 -0
- package/dist/core/theme/tokens.d.ts +74 -0
- package/dist/core/theme/tokens.d.ts.map +1 -0
- package/dist/core/theme/tokens.js +162 -0
- package/dist/core/theme/tokens.js.map +1 -0
- package/dist/core/types/index.d.ts +189 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +13 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/utils/balance.d.ts +33 -0
- package/dist/core/utils/balance.d.ts.map +1 -0
- package/dist/core/utils/balance.js +66 -0
- package/dist/core/utils/balance.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @nexus-cross/connect-kit-core
|
|
2
|
+
|
|
3
|
+
Pure domain layer for **crossx-kit** — TypeScript types, port interfaces, and
|
|
4
|
+
framework-agnostic utilities. This package has **no runtime dependencies** on
|
|
5
|
+
wagmi, viem, React, or any wallet SDK. It is the seam that lets the wagmi and
|
|
6
|
+
React layers evolve independently.
|
|
7
|
+
|
|
8
|
+
> DApp developers normally don't install this package directly. Install
|
|
9
|
+
> [`@nexus-cross/connect-kit-react`](../react) (and optionally
|
|
10
|
+
> [`@nexus-cross/connect-kit-wagmi`](../wagmi)) — both re-export the types you need.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pnpm add @nexus-cross/connect-kit-core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What's inside
|
|
19
|
+
|
|
20
|
+
### Domain types
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import type {
|
|
24
|
+
// Wallet taxonomy
|
|
25
|
+
WalletId, // 'cross_embedded' | 'cross_wallet' | 'cross_extension' | 'metamask' | 'binance' | (string & {})
|
|
26
|
+
ConnectorType, // 'embedded' | 'app' | 'extension' | 'external'
|
|
27
|
+
WalletDescriptor,
|
|
28
|
+
|
|
29
|
+
// Connection result
|
|
30
|
+
Account,
|
|
31
|
+
ConnectorResult,
|
|
32
|
+
ChainBalance,
|
|
33
|
+
|
|
34
|
+
// Kit config (input to createCrossxConfig)
|
|
35
|
+
CrossConnectKitConfig,
|
|
36
|
+
AppMetadata,
|
|
37
|
+
NetworkConfig,
|
|
38
|
+
|
|
39
|
+
// UI
|
|
40
|
+
ModalView,
|
|
41
|
+
Theme,
|
|
42
|
+
|
|
43
|
+
// Misc
|
|
44
|
+
Unsubscribe,
|
|
45
|
+
WalletState,
|
|
46
|
+
} from '@nexus-cross/connect-kit-core';
|
|
47
|
+
|
|
48
|
+
import { ConnectionStatus } from '@nexus-cross/connect-kit-core';
|
|
49
|
+
// ConnectionStatus.CONNECTED | .DISCONNECTED | .CONNECTING | .RECONNECTING
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Ports (capability interfaces)
|
|
53
|
+
|
|
54
|
+
Ports describe **what** the kit needs from its environment, not **how** it is
|
|
55
|
+
delivered. Adapters in `@nexus-cross/connect-kit-wagmi` and `@nexus-cross/connect-kit-react` implement
|
|
56
|
+
them.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import type {
|
|
60
|
+
ConnectorPort, // Connect / disconnect / subscribe to wallet state
|
|
61
|
+
StoragePort, // Async key-value storage (localStorage, cookies, …)
|
|
62
|
+
ModalControlPort, // Open / close the kit's modal views
|
|
63
|
+
ThemePort, // Read & write theme tokens
|
|
64
|
+
WalletDetectionPort, // EIP-6963 / injected / SDK wallet discovery
|
|
65
|
+
BalancePort, // Per-chain balance fetcher
|
|
66
|
+
} from '@nexus-cross/connect-kit-core';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Ports are the only contract core has with the outside world — any new external
|
|
70
|
+
capability must enter through a port, never as a direct dependency.
|
|
71
|
+
|
|
72
|
+
### Utilities
|
|
73
|
+
|
|
74
|
+
BigInt-safe formatters for blockchain numerics. These **always floor** when
|
|
75
|
+
truncating decimals and never round up or use banker's rounding.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { formatBalance, formatWei } from '@nexus-cross/connect-kit-core';
|
|
79
|
+
|
|
80
|
+
formatBalance(1234567890000000000n, 18); // '1.234567890000000000'
|
|
81
|
+
formatBalance(1234567890000000000n, 18, 4); // '1.2345' (truncated)
|
|
82
|
+
formatWei('0xde0b6b3a7640000'); // '1' (1 ETH)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Design rules
|
|
86
|
+
|
|
87
|
+
The core package enforces the architectural spine:
|
|
88
|
+
|
|
89
|
+
- **No environment dependencies** — no wagmi, viem, React, DOM, or Node APIs.
|
|
90
|
+
Anything impure lives behind a port.
|
|
91
|
+
- **Constructor injection only** — no singletons, no module-level globals,
|
|
92
|
+
no hidden `window` access.
|
|
93
|
+
- **BigInt end-to-end** — wei / gas / balance values stay in `BigInt` through
|
|
94
|
+
every computation; display values are UI-only and never fed back into
|
|
95
|
+
arithmetic.
|
|
96
|
+
- **External SDK types don't leak** — the wagmi package converts between
|
|
97
|
+
external shapes (viem `Address`, wagmi `Connector`) and core's plain types
|
|
98
|
+
(`string` addresses, `WalletDescriptor`) at its own boundary.
|
|
99
|
+
|
|
100
|
+
## Compatibility
|
|
101
|
+
|
|
102
|
+
- TypeScript 5.x
|
|
103
|
+
- Node 18+ / modern browsers (ES2020 target)
|
|
104
|
+
- No peer dependencies
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BalancePort.js","sourceRoot":"","sources":["../../../src/core/ports/BalancePort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorPort.js","sourceRoot":"","sources":["../../../src/core/ports/ConnectorPort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalControlPort.js","sourceRoot":"","sources":["../../../src/core/ports/ModalControlPort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StoragePort.js","sourceRoot":"","sources":["../../../src/core/ports/StoragePort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemePort.js","sourceRoot":"","sources":["../../../src/core/ports/ThemePort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WalletDetectionPort.js","sourceRoot":"","sources":["../../../src/core/ports/WalletDetectionPort.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme token resolver — bridges `CrossConnectKitConfig.{theme, themeTokens}`
|
|
3
|
+
* to:
|
|
4
|
+
* - crossy-sdk's `SDKConfig.{theme, themeTokens}` (passed straight
|
|
5
|
+
* through, same semantic keys)
|
|
6
|
+
* - `--cck-*` CSS variables consumed by `@nexus-cross/dapp-ui`'s
|
|
7
|
+
* WalletInfo / WalletPortfolio / WalletConnectModal / AppLauncher
|
|
8
|
+
* stylesheets (they reference `var(--cck-<key>, <fallback>)` for
|
|
9
|
+
* every token below)
|
|
10
|
+
*
|
|
11
|
+
* Defaults match crossy-sdk-js's built-in palette so an absent
|
|
12
|
+
* `themeTokens` still yields a consistent look across every surface.
|
|
13
|
+
*/
|
|
14
|
+
import type { ColorOverrides, ThemeMode, ThemeTokens } from '../types/index.js';
|
|
15
|
+
/**
|
|
16
|
+
* Baseline palette. Light and dark default values mirror
|
|
17
|
+
* `crossy-sdk-js`'s `THEMES.light` / `THEMES.dark`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_THEME_TOKENS: Record<ThemeMode, Required<ColorOverrides>>;
|
|
20
|
+
/**
|
|
21
|
+
* Merge user overrides onto the default palette for a given mode.
|
|
22
|
+
* Undefined/empty values fall through to the default — matching
|
|
23
|
+
* crossy-sdk's `resolveTokens` behavior so `@nexus-cross/connect-kit`
|
|
24
|
+
* renders the same resolved palette the embedded modal does.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveColorTokens(mode: ThemeMode, overrides?: ColorOverrides): Required<ColorOverrides>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the effective {@link ThemeMode} that should be applied.
|
|
29
|
+
* When `autoDetect` is true (and a `window` is available), reads
|
|
30
|
+
* `prefers-color-scheme`; otherwise falls back to `explicit ?? 'dark'`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveThemeMode(explicit: ThemeMode | Partial<{
|
|
33
|
+
mode: ThemeMode;
|
|
34
|
+
}> | undefined, autoDetect: boolean | undefined): ThemeMode;
|
|
35
|
+
/**
|
|
36
|
+
* `ColorOverrides` key → CSS variable name under the shared `--cck-*`
|
|
37
|
+
* namespace.
|
|
38
|
+
*
|
|
39
|
+
* The dapp-ui feature stylesheets (`wallet-info/styles/theme.css`,
|
|
40
|
+
* `wallet-portfolio/styles/portfolio.css`, `wallet-connect-modal/
|
|
41
|
+
* styles/theme.css`, `app-launcher/styles/theme.css`) reference these
|
|
42
|
+
* names via `var(--cck-<key>, <fallback>)`, so emitting them on
|
|
43
|
+
* `:root` (or any ancestor) recolors every surface at once.
|
|
44
|
+
*/
|
|
45
|
+
export declare const CCK_VAR: Record<keyof ColorOverrides, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Serialize `{ light, dark }` token sets to a self-contained CSS string
|
|
48
|
+
* attached to a root (e.g. `:root` or `[data-ckit-root]`). Both modes
|
|
49
|
+
* are always emitted — one inside `[data-cck-theme="light"]` and one
|
|
50
|
+
* inside `[data-cck-theme="dark"]` — so flipping
|
|
51
|
+
* `document.documentElement.dataset.ckitTheme` is enough to switch
|
|
52
|
+
* palettes without re-rendering the `<style>` tag.
|
|
53
|
+
*
|
|
54
|
+
* The caller is responsible for setting `data-cck-theme` (and
|
|
55
|
+
* optionally `data-theme` on the same element) to match the active
|
|
56
|
+
* mode. `CrossConnectKitProvider` in `@nexus-cross/connect-kit-react` does
|
|
57
|
+
* both.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildThemeCssText(tokens: ThemeTokens | undefined,
|
|
60
|
+
/** Selector scope. Defaults to `:root` so the variables are globally available. */
|
|
61
|
+
scope?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Convenience: flatten a resolved token set to a `CSSProperties`-style
|
|
64
|
+
* inline-style object. Useful when a DApp wants to apply the palette to
|
|
65
|
+
* a single subtree rather than the documentElement.
|
|
66
|
+
*
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <div style={themeTokensToInlineStyle('dark', tokens.dark)}>
|
|
69
|
+
* ...
|
|
70
|
+
* </div>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function themeTokensToInlineStyle(mode: ThemeMode, overrides?: ColorOverrides): Record<string, string>;
|
|
74
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/core/theme/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,CA6B5E,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,SAAS,CAAC,EAAE,cAAc,GACzB,QAAQ,CAAC,cAAc,CAAC,CAS1B;AAED;;;;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;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,cAAc,EAAE,MAAM,CAaxD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,GAAG,SAAS;AAC/B,mFAAmF;AACnF,KAAK,GAAE,MAAgB,GACtB,MAAM,CAkBR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS,EACf,SAAS,CAAC,EAAE,cAAc,GACzB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme token resolver — bridges `CrossConnectKitConfig.{theme, themeTokens}`
|
|
3
|
+
* to:
|
|
4
|
+
* - crossy-sdk's `SDKConfig.{theme, themeTokens}` (passed straight
|
|
5
|
+
* through, same semantic keys)
|
|
6
|
+
* - `--cck-*` CSS variables consumed by `@nexus-cross/dapp-ui`'s
|
|
7
|
+
* WalletInfo / WalletPortfolio / WalletConnectModal / AppLauncher
|
|
8
|
+
* stylesheets (they reference `var(--cck-<key>, <fallback>)` for
|
|
9
|
+
* every token below)
|
|
10
|
+
*
|
|
11
|
+
* Defaults match crossy-sdk-js's built-in palette so an absent
|
|
12
|
+
* `themeTokens` still yields a consistent look across every surface.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Baseline palette. Light and dark default values mirror
|
|
16
|
+
* `crossy-sdk-js`'s `THEMES.light` / `THEMES.dark`.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_THEME_TOKENS = {
|
|
19
|
+
light: {
|
|
20
|
+
primary: '#019D92',
|
|
21
|
+
secondary: '#E70077',
|
|
22
|
+
onPrimary: '#FFFFFF',
|
|
23
|
+
borderDefault: 'rgba(18, 18, 18, 0.05)',
|
|
24
|
+
borderSubtle: 'rgba(18, 18, 18, 0.1)',
|
|
25
|
+
textIconPrimary: '#121212',
|
|
26
|
+
textIconSecondary: 'rgba(18, 18, 18, 0.7)',
|
|
27
|
+
textIconTertiary: 'rgba(18, 18, 18, 0.5)',
|
|
28
|
+
surfaceDefault: 'rgba(18, 18, 18, 0.05)',
|
|
29
|
+
surfaceSubtle: 'rgba(18, 18, 18, 0.1)',
|
|
30
|
+
bg: '#FFFFFF',
|
|
31
|
+
error: '#E70077',
|
|
32
|
+
},
|
|
33
|
+
dark: {
|
|
34
|
+
primary: '#019D92',
|
|
35
|
+
secondary: '#E70077',
|
|
36
|
+
onPrimary: '#FFFFFF',
|
|
37
|
+
borderDefault: 'rgba(255, 255, 255, 0.05)',
|
|
38
|
+
borderSubtle: 'rgba(255, 255, 255, 0.1)',
|
|
39
|
+
textIconPrimary: '#FFFFFF',
|
|
40
|
+
textIconSecondary: 'rgba(255, 255, 255, 0.7)',
|
|
41
|
+
textIconTertiary: 'rgba(255, 255, 255, 0.5)',
|
|
42
|
+
surfaceDefault: 'rgba(255, 255, 255, 0.05)',
|
|
43
|
+
surfaceSubtle: 'rgba(255, 255, 255, 0.1)',
|
|
44
|
+
bg: '#121212',
|
|
45
|
+
error: '#E70077',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Merge user overrides onto the default palette for a given mode.
|
|
50
|
+
* Undefined/empty values fall through to the default — matching
|
|
51
|
+
* crossy-sdk's `resolveTokens` behavior so `@nexus-cross/connect-kit`
|
|
52
|
+
* renders the same resolved palette the embedded modal does.
|
|
53
|
+
*/
|
|
54
|
+
export function resolveColorTokens(mode, overrides) {
|
|
55
|
+
const base = DEFAULT_THEME_TOKENS[mode];
|
|
56
|
+
if (!overrides)
|
|
57
|
+
return { ...base };
|
|
58
|
+
const merged = { ...base };
|
|
59
|
+
Object.keys(base).forEach((key) => {
|
|
60
|
+
const v = overrides[key];
|
|
61
|
+
if (typeof v === 'string' && v.length > 0)
|
|
62
|
+
merged[key] = v;
|
|
63
|
+
});
|
|
64
|
+
return merged;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the effective {@link ThemeMode} that should be applied.
|
|
68
|
+
* When `autoDetect` is true (and a `window` is available), reads
|
|
69
|
+
* `prefers-color-scheme`; otherwise falls back to `explicit ?? 'dark'`.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveThemeMode(explicit, autoDetect) {
|
|
72
|
+
if (autoDetect && typeof window !== 'undefined' && window.matchMedia) {
|
|
73
|
+
try {
|
|
74
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
75
|
+
? 'dark'
|
|
76
|
+
: 'light';
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
/* fall through */
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (typeof explicit === 'string')
|
|
83
|
+
return explicit;
|
|
84
|
+
if (explicit && typeof explicit === 'object' && 'mode' in explicit) {
|
|
85
|
+
return explicit.mode ?? 'dark';
|
|
86
|
+
}
|
|
87
|
+
return 'dark';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* `ColorOverrides` key → CSS variable name under the shared `--cck-*`
|
|
91
|
+
* namespace.
|
|
92
|
+
*
|
|
93
|
+
* The dapp-ui feature stylesheets (`wallet-info/styles/theme.css`,
|
|
94
|
+
* `wallet-portfolio/styles/portfolio.css`, `wallet-connect-modal/
|
|
95
|
+
* styles/theme.css`, `app-launcher/styles/theme.css`) reference these
|
|
96
|
+
* names via `var(--cck-<key>, <fallback>)`, so emitting them on
|
|
97
|
+
* `:root` (or any ancestor) recolors every surface at once.
|
|
98
|
+
*/
|
|
99
|
+
export const CCK_VAR = {
|
|
100
|
+
primary: '--cck-primary',
|
|
101
|
+
secondary: '--cck-secondary',
|
|
102
|
+
onPrimary: '--cck-on-primary',
|
|
103
|
+
borderDefault: '--cck-border-default',
|
|
104
|
+
borderSubtle: '--cck-border-subtle',
|
|
105
|
+
textIconPrimary: '--cck-texticon-primary',
|
|
106
|
+
textIconSecondary: '--cck-texticon-secondary',
|
|
107
|
+
textIconTertiary: '--cck-texticon-tertiary',
|
|
108
|
+
surfaceDefault: '--cck-surface-default',
|
|
109
|
+
surfaceSubtle: '--cck-surface-subtle',
|
|
110
|
+
bg: '--cck-surface-bg',
|
|
111
|
+
error: '--cck-error',
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Serialize `{ light, dark }` token sets to a self-contained CSS string
|
|
115
|
+
* attached to a root (e.g. `:root` or `[data-ckit-root]`). Both modes
|
|
116
|
+
* are always emitted — one inside `[data-cck-theme="light"]` and one
|
|
117
|
+
* inside `[data-cck-theme="dark"]` — so flipping
|
|
118
|
+
* `document.documentElement.dataset.ckitTheme` is enough to switch
|
|
119
|
+
* palettes without re-rendering the `<style>` tag.
|
|
120
|
+
*
|
|
121
|
+
* The caller is responsible for setting `data-cck-theme` (and
|
|
122
|
+
* optionally `data-theme` on the same element) to match the active
|
|
123
|
+
* mode. `CrossConnectKitProvider` in `@nexus-cross/connect-kit-react` does
|
|
124
|
+
* both.
|
|
125
|
+
*/
|
|
126
|
+
export function buildThemeCssText(tokens,
|
|
127
|
+
/** Selector scope. Defaults to `:root` so the variables are globally available. */
|
|
128
|
+
scope = ':root') {
|
|
129
|
+
const light = resolveColorTokens('light', tokens?.light);
|
|
130
|
+
const dark = resolveColorTokens('dark', tokens?.dark);
|
|
131
|
+
const emit = (mode, values) => {
|
|
132
|
+
const lines = [];
|
|
133
|
+
Object.keys(values).forEach((key) => {
|
|
134
|
+
lines.push(` ${CCK_VAR[key]}: ${values[key]};`);
|
|
135
|
+
});
|
|
136
|
+
// Two selectors so it works whether the DApp tags the documentElement
|
|
137
|
+
// (`<html data-cck-theme="dark">`) or a deeper wrapper.
|
|
138
|
+
return (`${scope}[data-cck-theme="${mode}"],\n` +
|
|
139
|
+
`[data-cck-theme="${mode}"] {\n${lines.join('\n')}\n}`);
|
|
140
|
+
};
|
|
141
|
+
return `${emit('light', light)}\n${emit('dark', dark)}`;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Convenience: flatten a resolved token set to a `CSSProperties`-style
|
|
145
|
+
* inline-style object. Useful when a DApp wants to apply the palette to
|
|
146
|
+
* a single subtree rather than the documentElement.
|
|
147
|
+
*
|
|
148
|
+
* ```tsx
|
|
149
|
+
* <div style={themeTokensToInlineStyle('dark', tokens.dark)}>
|
|
150
|
+
* ...
|
|
151
|
+
* </div>
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export function themeTokensToInlineStyle(mode, overrides) {
|
|
155
|
+
const values = resolveColorTokens(mode, overrides);
|
|
156
|
+
const out = {};
|
|
157
|
+
Object.keys(values).forEach((key) => {
|
|
158
|
+
out[CCK_VAR[key]] = values[key];
|
|
159
|
+
});
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/core/theme/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgD;IAC/E,KAAK,EAAE;QACL,OAAO,EAAE,SAAS;QAClB,SAA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IAAI,GAAG,CAAC,IAAe,EAAE,MAAgC,EAAU,EAAE;QACzE,MAAM,KAAK,GAAa,EAAE,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAiC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnE,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,sEAAsE;QACtE,wDAAwD;QACxD,OAAO,CACL,GAAG,KAAK,oBAAoB,IAAI,OAAO;YACvC,oBAAoB,IAAI,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CACvD,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAe,EACf,SAA0B;IAE1B,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACnD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACtC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAiC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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
|
+
export interface CrossConnectKitConfig {
|
|
130
|
+
/** CROSS SDK project ID (for embedded/app wallet) */
|
|
131
|
+
crossProjectId: string;
|
|
132
|
+
/** Reown project ID (for WalletConnect / external wallets) */
|
|
133
|
+
reownProjectId?: string;
|
|
134
|
+
/** Embedded wallet project ID */
|
|
135
|
+
embeddedProjectId?: string;
|
|
136
|
+
/** App metadata for WalletConnect pairing */
|
|
137
|
+
appMetadata: AppMetadata;
|
|
138
|
+
/** Supported networks */
|
|
139
|
+
networks: readonly NetworkConfig[];
|
|
140
|
+
/** Default network (first connection lands here) */
|
|
141
|
+
defaultNetwork?: NetworkConfig;
|
|
142
|
+
/**
|
|
143
|
+
* Theme mode applied across every surface the kit renders:
|
|
144
|
+
* - crossy-sdk confirmation / login modals
|
|
145
|
+
* - `WalletInfo`, `WalletPortfolio`, `WalletConnectModal`, `AppLauncher`
|
|
146
|
+
* Defaults to `'dark'`.
|
|
147
|
+
*
|
|
148
|
+
* Accepts both the new literal (`'light' | 'dark'`) and the legacy
|
|
149
|
+
* `Partial<Theme>` object (`{ mode: 'dark' }`) so older DApps keep
|
|
150
|
+
* building while migrating.
|
|
151
|
+
*/
|
|
152
|
+
theme?: ThemeMode | Partial<Theme>;
|
|
153
|
+
/**
|
|
154
|
+
* When `true`, ignore `theme` and follow `prefers-color-scheme`.
|
|
155
|
+
* Mirrors crossy-sdk's `SDKConfig.autoDetectTheme`.
|
|
156
|
+
*/
|
|
157
|
+
autoDetectTheme?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Color token overrides forwarded to crossy-sdk's `themeTokens` _and_
|
|
160
|
+
* published as CSS variables so WalletInfo / Portfolio / AppLauncher /
|
|
161
|
+
* WalletConnectModal render with the same palette.
|
|
162
|
+
*/
|
|
163
|
+
themeTokens?: ThemeTokens;
|
|
164
|
+
/** Which wallets to show in connect modal (defaults to all) */
|
|
165
|
+
wallets?: WalletId[];
|
|
166
|
+
/** Enable SSR hydration support (Next.js App Router) */
|
|
167
|
+
ssr?: boolean;
|
|
168
|
+
}
|
|
169
|
+
export interface AppMetadata {
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
url: string;
|
|
173
|
+
icons?: string[];
|
|
174
|
+
}
|
|
175
|
+
export interface NetworkConfig {
|
|
176
|
+
/** EIP-155 numeric chain ID */
|
|
177
|
+
id: number;
|
|
178
|
+
name: string;
|
|
179
|
+
nativeCurrency: {
|
|
180
|
+
name: string;
|
|
181
|
+
symbol: string;
|
|
182
|
+
decimals: number;
|
|
183
|
+
};
|
|
184
|
+
rpcUrl: string;
|
|
185
|
+
blockExplorerUrl?: string;
|
|
186
|
+
testnet?: boolean;
|
|
187
|
+
}
|
|
188
|
+
export type Unsubscribe = () => void;
|
|
189
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAA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W,CAAC;IAC1B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;IACrB,wDAAwD;IACxD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,UAAU,CAClB,sEAAsE,eAAe,EAAE,CACxF,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAE5C,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IACpD,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,IAAI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
1
|
+
export type { ConnectorPort } from './core/ports/ConnectorPort.js';
|
|
2
|
+
export type { StoragePort } from './core/ports/StoragePort.js';
|
|
3
|
+
export type { ModalControlPort } from './core/ports/ModalControlPort.js';
|
|
4
|
+
export type { ThemePort } from './core/ports/ThemePort.js';
|
|
5
|
+
export type { WalletDetectionPort } from './core/ports/WalletDetectionPort.js';
|
|
6
|
+
export type { BalancePort } from './core/ports/BalancePort.js';
|
|
7
|
+
export type { ConnectorType, WalletId, WalletDescriptor, ConnectorResult, Account, ChainBalance, WalletState, ModalView, Theme, ThemeMode, ColorOverrides, ThemeTokens, CrossConnectKitConfig, AppMetadata, NetworkConfig, Unsubscribe, } from './core/types/index.js';
|
|
8
|
+
export { ConnectionStatus } from './core/types/index.js';
|
|
9
|
+
export { DEFAULT_THEME_TOKENS, CCK_VAR, resolveColorTokens, resolveThemeMode, buildThemeCssText, themeTokensToInlineStyle, } from './core/theme/tokens.js';
|
|
10
|
+
export { formatBalance, formatWei } from './core/utils/balance.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,YAAY,EACV,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,YAAY,EACZ,WAAW,EACX,SAAS,EACT,KAAK,EACL,SAAS,EACT,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ConnectionStatus } from './core/types/index.js';
|
|
2
|
+
// Theme utilities — shared between `@nexus-cross/connect-kit-react` (for
|
|
3
|
+
// the CSS variable runtime) and `@nexus-cross/connect-kit-wagmi` (for
|
|
4
|
+
// forwarding into the crossy-sdk embedded connector).
|
|
5
|
+
export { DEFAULT_THEME_TOKENS, CCK_VAR, resolveColorTokens, resolveThemeMode, buildThemeCssText, themeTokensToInlineStyle, } from './core/theme/tokens.js';
|
|
6
|
+
// Utilities
|
|
7
|
+
export { formatBalance, formatWei } from './core/utils/balance.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,yEAAyE;AACzE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,YAAY;AACZ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexus-cross/connect-kit-core",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "Core domain logic for @nexus-cross/connect-kit — types, ports, utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"registry": "https://registry.npmjs.org",
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"dev": "tsc --watch",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
}
|
|
29
|
+
}
|