@nexus-cross/connect-kit-wagmi 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 +195 -0
- package/dist/adapters/helpers.d.ts +46 -0
- package/dist/adapters/helpers.d.ts.map +1 -0
- package/dist/adapters/helpers.js +124 -0
- package/dist/adapters/helpers.js.map +1 -0
- package/dist/adapters/reownAdapter.d.ts +20 -0
- package/dist/adapters/reownAdapter.d.ts.map +1 -0
- package/dist/adapters/reownAdapter.js +213 -0
- package/dist/adapters/reownAdapter.js.map +1 -0
- package/dist/adapters/toNexusAdapter.d.ts +12 -0
- package/dist/adapters/toNexusAdapter.d.ts.map +1 -0
- package/dist/adapters/toNexusAdapter.js +167 -0
- package/dist/adapters/toNexusAdapter.js.map +1 -0
- package/dist/adapters/types.d.ts +101 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +3 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/config/createCrossxConfig.d.ts +75 -0
- package/dist/config/createCrossxConfig.d.ts.map +1 -0
- package/dist/config/createCrossxConfig.js +77 -0
- package/dist/config/createCrossxConfig.js.map +1 -0
- package/dist/connectors/embeddedConnector.d.ts +30 -0
- package/dist/connectors/embeddedConnector.d.ts.map +1 -0
- package/dist/connectors/embeddedConnector.js +43 -0
- package/dist/connectors/embeddedConnector.js.map +1 -0
- package/dist/connectors/extensionConnector.d.ts +7 -0
- package/dist/connectors/extensionConnector.d.ts.map +1 -0
- package/dist/connectors/extensionConnector.js +60 -0
- package/dist/connectors/extensionConnector.js.map +1 -0
- package/dist/connectors/walletConnectConnector.d.ts +19 -0
- package/dist/connectors/walletConnectConnector.d.ts.map +1 -0
- package/dist/connectors/walletConnectConnector.js +33 -0
- package/dist/connectors/walletConnectConnector.js.map +1 -0
- package/dist/embedded.d.ts +19 -0
- package/dist/embedded.d.ts.map +1 -0
- package/dist/embedded.js +18 -0
- package/dist/embedded.js.map +1 -0
- package/dist/events.d.ts +11 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +17 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/ConnectorRegistry.d.ts +68 -0
- package/dist/registry/ConnectorRegistry.d.ts.map +1 -0
- package/dist/registry/ConnectorRegistry.js +52 -0
- package/dist/registry/ConnectorRegistry.js.map +1 -0
- package/dist/reown.d.ts +3 -0
- package/dist/reown.d.ts.map +1 -0
- package/dist/reown.js +2 -0
- package/dist/reown.js.map +1 -0
- package/dist/ssr.d.ts +43 -0
- package/dist/ssr.d.ts.map +1 -0
- package/dist/ssr.js +50 -0
- package/dist/ssr.js.map +1 -0
- package/dist/to-nexus.d.ts +3 -0
- package/dist/to-nexus.d.ts.map +1 -0
- package/dist/to-nexus.js +2 -0
- package/dist/to-nexus.js.map +1 -0
- package/dist/utils/sessionStorage.d.ts +21 -0
- package/dist/utils/sessionStorage.d.ts.map +1 -0
- package/dist/utils/sessionStorage.js +55 -0
- package/dist/utils/sessionStorage.js.map +1 -0
- package/dist/utils/theme.d.ts +58 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/dist/utils/theme.js +112 -0
- package/dist/utils/theme.js.map +1 -0
- package/dist/wallets/detection.d.ts +28 -0
- package/dist/wallets/detection.d.ts.map +1 -0
- package/dist/wallets/detection.js +187 -0
- package/dist/wallets/detection.js.map +1 -0
- package/dist/wallets/icons.d.ts +20 -0
- package/dist/wallets/icons.d.ts.map +1 -0
- package/dist/wallets/icons.js +33 -0
- package/dist/wallets/icons.js.map +1 -0
- package/dist/wallets/registry.d.ts +3 -0
- package/dist/wallets/registry.d.ts.map +1 -0
- package/dist/wallets/registry.js +33 -0
- package/dist/wallets/registry.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { walletConnect } from 'wagmi/connectors';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a WalletConnect connector for external wallets
|
|
4
|
+
* (MetaMask, Binance Wallet, etc. via QR/deep-link).
|
|
5
|
+
*/
|
|
6
|
+
export function createWalletConnectConnector(config) {
|
|
7
|
+
return walletConnect({
|
|
8
|
+
projectId: config.projectId,
|
|
9
|
+
metadata: config.metadata
|
|
10
|
+
? {
|
|
11
|
+
name: config.metadata.name,
|
|
12
|
+
description: config.metadata.description ?? '',
|
|
13
|
+
url: config.metadata.url,
|
|
14
|
+
icons: config.metadata.icons ?? [],
|
|
15
|
+
}
|
|
16
|
+
: undefined,
|
|
17
|
+
showQrModal: config.showQrModal ?? false,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function createWalletConnectFromKitConfig(kitConfig) {
|
|
21
|
+
if (!kitConfig.reownProjectId)
|
|
22
|
+
return null;
|
|
23
|
+
return createWalletConnectConnector({
|
|
24
|
+
projectId: kitConfig.reownProjectId,
|
|
25
|
+
metadata: {
|
|
26
|
+
name: kitConfig.appMetadata.name,
|
|
27
|
+
description: kitConfig.appMetadata.description,
|
|
28
|
+
url: kitConfig.appMetadata.url,
|
|
29
|
+
icons: kitConfig.appMetadata.icons,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=walletConnectConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletConnectConnector.js","sourceRoot":"","sources":["../../src/connectors/walletConnectConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAejD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAA2B;IAE3B,OAAO,aAAa,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACvB,CAAC,CAAC;gBACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;gBAC1B,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE;gBAC9C,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;gBACxB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;aACnC;YACH,CAAC,CAAC,SAAS;QACb,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,KAAK;KACzC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,SAAgC;IAEhC,IAAI,CAAC,SAAS,CAAC,cAAc;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,4BAA4B,CAAC;QAClC,SAAS,EAAE,SAAS,CAAC,cAAc;QACnC,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,IAAI;YAChC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,WAAW;YAC9C,GAAG,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG;YAC9B,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK;SACnC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in entry point for the embedded CROSSx wallet connector.
|
|
3
|
+
*
|
|
4
|
+
* The underlying `@nexus-cross/crossx-sdk-wagmi` package touches
|
|
5
|
+
* `indexedDB` at module load time, which throws under Next.js App Router
|
|
6
|
+
* SSR. Importing it only from this subpath lets the core
|
|
7
|
+
* `@nexus-cross/connect-kit-wagmi` entry stay server-safe — DApps that need the
|
|
8
|
+
* embedded connector pull it in from a client boundary:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // providers.tsx ('use client')
|
|
12
|
+
* import { embeddedConnectorFactory } from '@nexus-cross/connect-kit-wagmi/embedded';
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Pass the factory to `createCrossxConfig({ embeddedConnectorFactory })`.
|
|
16
|
+
*/
|
|
17
|
+
export { createEmbeddedConnector, createEmbeddedConnectorFromKitConfig as embeddedConnectorFactory, } from './connectors/embeddedConnector.js';
|
|
18
|
+
export type { EmbeddedConnectorConfig } from './connectors/embeddedConnector.js';
|
|
19
|
+
//# sourceMappingURL=embedded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,uBAAuB,EACvB,oCAAoC,IAAI,wBAAwB,GACjE,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/embedded.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in entry point for the embedded CROSSx wallet connector.
|
|
3
|
+
*
|
|
4
|
+
* The underlying `@nexus-cross/crossx-sdk-wagmi` package touches
|
|
5
|
+
* `indexedDB` at module load time, which throws under Next.js App Router
|
|
6
|
+
* SSR. Importing it only from this subpath lets the core
|
|
7
|
+
* `@nexus-cross/connect-kit-wagmi` entry stay server-safe — DApps that need the
|
|
8
|
+
* embedded connector pull it in from a client boundary:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // providers.tsx ('use client')
|
|
12
|
+
* import { embeddedConnectorFactory } from '@nexus-cross/connect-kit-wagmi/embedded';
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Pass the factory to `createCrossxConfig({ embeddedConnectorFactory })`.
|
|
16
|
+
*/
|
|
17
|
+
export { createEmbeddedConnector, createEmbeddedConnectorFromKitConfig as embeddedConnectorFactory, } from './connectors/embeddedConnector.js';
|
|
18
|
+
//# sourceMappingURL=embedded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded.js","sourceRoot":"","sources":["../src/embedded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,uBAAuB,EACvB,oCAAoC,IAAI,wBAAwB,GACjE,MAAM,mCAAmC,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Listener = () => void;
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe to "open other wallets" events.
|
|
4
|
+
* Fired by the embedded connector when the SDK modal's
|
|
5
|
+
* "Connect with Other Wallets" button is clicked.
|
|
6
|
+
*/
|
|
7
|
+
export declare function onOpenOtherWallets(cb: Listener): () => void;
|
|
8
|
+
/** @internal Called by createCrossxConfig to wire the embedded connector */
|
|
9
|
+
export declare function fireOpenOtherWallets(): void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAI3B;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAK3D;AAED,4EAA4E;AAC5E,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const otherWalletsListeners = new Set();
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe to "open other wallets" events.
|
|
4
|
+
* Fired by the embedded connector when the SDK modal's
|
|
5
|
+
* "Connect with Other Wallets" button is clicked.
|
|
6
|
+
*/
|
|
7
|
+
export function onOpenOtherWallets(cb) {
|
|
8
|
+
otherWalletsListeners.add(cb);
|
|
9
|
+
return () => {
|
|
10
|
+
otherWalletsListeners.delete(cb);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** @internal Called by createCrossxConfig to wire the embedded connector */
|
|
14
|
+
export function fireOpenOtherWallets() {
|
|
15
|
+
otherWalletsListeners.forEach((cb) => cb());
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAY,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAY;IAC7C,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,OAAO,GAAG,EAAE;QACV,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB;IAClC,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { createCrossxConfig } from './config/createCrossxConfig.js';
|
|
2
|
+
export type { CrossxConfig, CreateCrossxConfigOptions, EmbeddedConnectorFactory, } from './config/createCrossxConfig.js';
|
|
3
|
+
export type { ProviderKind } from './registry/ConnectorRegistry.js';
|
|
4
|
+
export type { WalletConnectAdapter, WalletConnectAdapterContext, CrossWalletProviderKind, } from './adapters/types.js';
|
|
5
|
+
export { clearWalletSessionStorage, DEFAULT_SESSION_STORAGE_PREFIXES, } from './utils/sessionStorage.js';
|
|
6
|
+
export { cookieToCrossConnectKitState, pickInitialState } from './ssr.js';
|
|
7
|
+
export type { CrossConnectKitInitialState } from './ssr.js';
|
|
8
|
+
export { readWalletInfoTokens, deriveSDKThemeTokensFromWalletInfo, } from './utils/theme.js';
|
|
9
|
+
export type { SDKThemeTokenOverrides, SDKThemeTokensShape, } from './utils/theme.js';
|
|
10
|
+
export { createConnectorRegistry, resolveCurrentWallet, } from './registry/ConnectorRegistry.js';
|
|
11
|
+
export type { ConnectorEntry, ConnectorRegistry, } from './registry/ConnectorRegistry.js';
|
|
12
|
+
export { onOpenOtherWallets } from './events.js';
|
|
13
|
+
export { DEFAULT_WALLET_REGISTRY } from './wallets/registry.js';
|
|
14
|
+
export { detectWallets, debugDetect } from './wallets/detection.js';
|
|
15
|
+
export { CROSSX_ICON, EXTENSION_ICON, METAMASK_ICON, BINANCE_ICON, WALLETCONNECT_ICON, GOOGLE_ICON, APPLE_ICON, } from './wallets/icons.js';
|
|
16
|
+
export { crossExtensionConnector } from './connectors/extensionConnector.js';
|
|
17
|
+
export { createWalletConnectConnector } from './connectors/walletConnectConnector.js';
|
|
18
|
+
export type { WalletConnectConfig } from './connectors/walletConnectConnector.js';
|
|
19
|
+
export type { CrossConnectKitConfig, AppMetadata, NetworkConfig } from '@nexus-cross/connect-kit-core';
|
|
20
|
+
export type { ConnectorPort, ConnectorType, ConnectorResult, Account, WalletId, WalletDescriptor, } from '@nexus-cross/connect-kit-core';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAExC,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC1E,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,EACL,oBAAoB,EACpB,kCAAkC,GACnC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,cAAc,EACd,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,YAAY,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAElF,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEvG,YAAY,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,OAAO,EACP,QAAQ,EACR,gBAAgB,GACjB,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createCrossxConfig } from './config/createCrossxConfig.js';
|
|
2
|
+
export { clearWalletSessionStorage, DEFAULT_SESSION_STORAGE_PREFIXES, } from './utils/sessionStorage.js';
|
|
3
|
+
export { cookieToCrossConnectKitState, pickInitialState } from './ssr.js';
|
|
4
|
+
export { readWalletInfoTokens, deriveSDKThemeTokensFromWalletInfo, } from './utils/theme.js';
|
|
5
|
+
export { createConnectorRegistry, resolveCurrentWallet, } from './registry/ConnectorRegistry.js';
|
|
6
|
+
export { onOpenOtherWallets } from './events.js';
|
|
7
|
+
export { DEFAULT_WALLET_REGISTRY } from './wallets/registry.js';
|
|
8
|
+
export { detectWallets, debugDetect } from './wallets/detection.js';
|
|
9
|
+
export { CROSSX_ICON, EXTENSION_ICON, METAMASK_ICON, BINANCE_ICON, WALLETCONNECT_ICON, GOOGLE_ICON, APPLE_ICON, } from './wallets/icons.js';
|
|
10
|
+
export { crossExtensionConnector } from './connectors/extensionConnector.js';
|
|
11
|
+
export { createWalletConnectConnector } from './connectors/walletConnectConnector.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAepE,OAAO,EACL,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG1E,OAAO,EACL,oBAAoB,EACpB,kCAAkC,GACnC,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,UAAU,GACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { WalletId, ConnectorType, WalletDescriptor } from '@nexus-cross/connect-kit-core';
|
|
2
|
+
/**
|
|
3
|
+
* Which wagmi `Config` a connector lives in.
|
|
4
|
+
*
|
|
5
|
+
* - `'cross'` — CROSSx 1.0 stack (`@to-nexus/*` WagmiAdapter + CROSS relay)
|
|
6
|
+
* - `'reown'` — standard Reown relay (optional side)
|
|
7
|
+
*
|
|
8
|
+
* crossx-kit keeps the two configs separate (posa-style dual config)
|
|
9
|
+
* so a DApp that cannot or will not depend on Reown still gets a working
|
|
10
|
+
* cross-only setup. `CrossConnectKitProvider` swaps the active `WagmiProvider`
|
|
11
|
+
* by remounting when the user picks a wallet from the other side.
|
|
12
|
+
*/
|
|
13
|
+
export type ProviderKind = 'cross' | 'reown';
|
|
14
|
+
export interface ConnectorEntry {
|
|
15
|
+
readonly walletId: WalletId;
|
|
16
|
+
readonly providerKind: ProviderKind;
|
|
17
|
+
readonly type: ConnectorType;
|
|
18
|
+
readonly connectorId: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly iconUrl?: string;
|
|
21
|
+
readonly installUrl?: string;
|
|
22
|
+
readonly fallbackConnectorId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Alternative wagmi connector ids that resolve to the same walletId.
|
|
25
|
+
* Needed because wagmi's MIPD (multi-injected-provider-discovery)
|
|
26
|
+
* elevates `injected()` to the EIP-6963 `rdns` at runtime — e.g.
|
|
27
|
+
* MetaMask ends up as `io.metamask` even though we registered
|
|
28
|
+
* `'injected'`. Listing the known aliases here keeps
|
|
29
|
+
* `resolveCurrentWallet` from returning `null` in that case.
|
|
30
|
+
*/
|
|
31
|
+
readonly aliasConnectorIds?: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* Optional URL the modal renders as a "Required Settings" style notice
|
|
34
|
+
* below the wallet row (e.g. a Binance CROSS-network setup guide).
|
|
35
|
+
* Keep undefined to hide the notice.
|
|
36
|
+
*/
|
|
37
|
+
readonly guideUrl?: string;
|
|
38
|
+
/** Override the default "Required Settings" CTA label. */
|
|
39
|
+
readonly guideLabel?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ConnectorRegistry {
|
|
42
|
+
readonly entries: readonly ConnectorEntry[];
|
|
43
|
+
getEntry(walletId: WalletId): ConnectorEntry | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* All entries that share a wagmi connectorId. Used when a single wagmi
|
|
46
|
+
* connector serves multiple walletIds (e.g. `cross_wallet` and `binance`
|
|
47
|
+
* both go through the shared `walletConnect` connector) — the caller
|
|
48
|
+
* disambiguates via the user's connect-intent hint.
|
|
49
|
+
*/
|
|
50
|
+
getEntriesByConnectorId(connectorId: string): readonly ConnectorEntry[];
|
|
51
|
+
/**
|
|
52
|
+
* Convenience: returns the first entry for the given connectorId.
|
|
53
|
+
* Prefer {@link getEntriesByConnectorId} when collisions are expected.
|
|
54
|
+
*/
|
|
55
|
+
getEntryByConnectorId(connectorId: string): ConnectorEntry | undefined;
|
|
56
|
+
toWalletDescriptors(): WalletDescriptor[];
|
|
57
|
+
}
|
|
58
|
+
export declare function createConnectorRegistry(entries: ConnectorEntry[]): ConnectorRegistry;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the currently connected walletId from the active wagmi connector.
|
|
61
|
+
*
|
|
62
|
+
* When multiple walletIds share a single connector (e.g. `cross_wallet` and
|
|
63
|
+
* `binance` both go through `walletConnect`), pass the last recorded
|
|
64
|
+
* connect-intent as `preferredWalletId` to disambiguate. If the hint
|
|
65
|
+
* doesn't match any candidate, the first registered entry wins.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveCurrentWallet(registry: ConnectorRegistry, activeConnectorId: string | undefined, preferredWalletId?: WalletId | null): WalletId | null;
|
|
68
|
+
//# sourceMappingURL=ConnectorRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/ConnectorRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAE/F;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;IACzD;;;;;OAKG;IACH,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAAC;IACxE;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IACvE,mBAAmB,IAAI,gBAAgB,EAAE,CAAC;CAC3C;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,cAAc,EAAE,GACxB,iBAAiB,CA4BnB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,iBAAiB,EAC3B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,iBAAiB,CAAC,EAAE,QAAQ,GAAG,IAAI,GAClC,QAAQ,GAAG,IAAI,CAUjB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export function createConnectorRegistry(entries) {
|
|
2
|
+
const byWalletId = new Map();
|
|
3
|
+
const byConnectorId = new Map();
|
|
4
|
+
for (const entry of entries) {
|
|
5
|
+
byWalletId.set(entry.walletId, entry);
|
|
6
|
+
const ids = [entry.connectorId, ...(entry.aliasConnectorIds ?? [])];
|
|
7
|
+
for (const id of ids) {
|
|
8
|
+
const list = byConnectorId.get(id);
|
|
9
|
+
if (list)
|
|
10
|
+
list.push(entry);
|
|
11
|
+
else
|
|
12
|
+
byConnectorId.set(id, [entry]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
entries,
|
|
17
|
+
getEntry: (walletId) => byWalletId.get(walletId),
|
|
18
|
+
getEntriesByConnectorId: (connectorId) => byConnectorId.get(connectorId) ?? [],
|
|
19
|
+
getEntryByConnectorId: (connectorId) => byConnectorId.get(connectorId)?.[0],
|
|
20
|
+
toWalletDescriptors: () => entries.map((e) => ({
|
|
21
|
+
id: e.walletId,
|
|
22
|
+
name: e.name,
|
|
23
|
+
type: e.type,
|
|
24
|
+
iconUrl: e.iconUrl,
|
|
25
|
+
installUrl: e.installUrl,
|
|
26
|
+
})),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the currently connected walletId from the active wagmi connector.
|
|
31
|
+
*
|
|
32
|
+
* When multiple walletIds share a single connector (e.g. `cross_wallet` and
|
|
33
|
+
* `binance` both go through `walletConnect`), pass the last recorded
|
|
34
|
+
* connect-intent as `preferredWalletId` to disambiguate. If the hint
|
|
35
|
+
* doesn't match any candidate, the first registered entry wins.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveCurrentWallet(registry, activeConnectorId, preferredWalletId) {
|
|
38
|
+
if (!activeConnectorId)
|
|
39
|
+
return null;
|
|
40
|
+
const candidates = registry.getEntriesByConnectorId(activeConnectorId);
|
|
41
|
+
if (candidates.length === 0)
|
|
42
|
+
return null;
|
|
43
|
+
if (candidates.length === 1)
|
|
44
|
+
return candidates[0].walletId;
|
|
45
|
+
if (preferredWalletId) {
|
|
46
|
+
const match = candidates.find((e) => e.walletId === preferredWalletId);
|
|
47
|
+
if (match)
|
|
48
|
+
return match.walletId;
|
|
49
|
+
}
|
|
50
|
+
return candidates[0].walletId;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ConnectorRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectorRegistry.js","sourceRoot":"","sources":["../../src/registry/ConnectorRegistry.ts"],"names":[],"mappings":"AA6DA,MAAM,UAAU,uBAAuB,CACrC,OAAyB;IAEzB,MAAM,UAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;IACvD,MAAM,aAAa,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE1D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;QACpE,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACnC,IAAI,IAAI;gBAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;gBACtB,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO;QACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;QAChD,uBAAuB,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE;QAC9E,qBAAqB,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,mBAAmB,EAAE,GAAG,EAAE,CACxB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClB,EAAE,EAAE,CAAC,CAAC,QAAQ;YACd,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,UAAU,EAAE,CAAC,CAAC,UAAU;SACzB,CAAC,CAAC;KACN,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA2B,EAC3B,iBAAqC,EACrC,iBAAmC;IAEnC,IAAI,CAAC,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,UAAU,GAAG,QAAQ,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;IACvE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC;IAC5D,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,iBAAiB,CAAC,CAAC;QACvE,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,QAAQ,CAAC;IACnC,CAAC;IACD,OAAO,UAAU,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC;AACjC,CAAC"}
|
package/dist/reown.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reown.d.ts","sourceRoot":"","sources":["../src/reown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/reown.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reown.js","sourceRoot":"","sources":["../src/reown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/ssr.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type State } from 'wagmi';
|
|
2
|
+
import type { CrossxConfig } from './config/createCrossxConfig.js';
|
|
3
|
+
import type { ProviderKind } from './registry/ConnectorRegistry.js';
|
|
4
|
+
/**
|
|
5
|
+
* Hydration state for one side of the dual wagmi config.
|
|
6
|
+
*/
|
|
7
|
+
export interface CrossConnectKitInitialState {
|
|
8
|
+
readonly cross?: State;
|
|
9
|
+
readonly reown?: State;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extract wagmi's initialState for BOTH cross-side and reown-side
|
|
13
|
+
* wagmi configs from a cookie header. The React provider passes the
|
|
14
|
+
* correct slice into whichever `<WagmiProvider>` is currently active.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // app/layout.tsx (Server Component, Next.js App Router)
|
|
18
|
+
* import { headers } from 'next/headers';
|
|
19
|
+
* import { cookieToCrossConnectKitState } from '@nexus-cross/connect-kit-wagmi';
|
|
20
|
+
* import { config } from './config';
|
|
21
|
+
* import { Providers } from './providers';
|
|
22
|
+
*
|
|
23
|
+
* export default async function RootLayout({ children }) {
|
|
24
|
+
* const cookie = (await headers()).get('cookie');
|
|
25
|
+
* const initialState = cookieToCrossConnectKitState(config, cookie);
|
|
26
|
+
* return (
|
|
27
|
+
* <html><body>
|
|
28
|
+
* <Providers initialState={initialState}>{children}</Providers>
|
|
29
|
+
* </body></html>
|
|
30
|
+
* );
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Returns `undefined` when no cookie is present. Requires
|
|
35
|
+
* `createCrossxConfig({ ssr: true })`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function cookieToCrossConnectKitState(config: CrossxConfig, cookieHeader: string | null | undefined): CrossConnectKitInitialState | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Pick the active-provider slice from the dual hydration state.
|
|
40
|
+
* Internal helper used by CrossConnectKitProvider; exported for tests.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pickInitialState(state: CrossConnectKitInitialState | undefined, providerKind: ProviderKind): State | undefined;
|
|
43
|
+
//# sourceMappingURL=ssr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.d.ts","sourceRoot":"","sources":["../src/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,2BAA2B,GAAG,SAAS,CAWzC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,2BAA2B,GAAG,SAAS,EAC9C,YAAY,EAAE,YAAY,GACzB,KAAK,GAAG,SAAS,CAGnB"}
|
package/dist/ssr.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cookieToInitialState } from 'wagmi';
|
|
2
|
+
/**
|
|
3
|
+
* Extract wagmi's initialState for BOTH cross-side and reown-side
|
|
4
|
+
* wagmi configs from a cookie header. The React provider passes the
|
|
5
|
+
* correct slice into whichever `<WagmiProvider>` is currently active.
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // app/layout.tsx (Server Component, Next.js App Router)
|
|
9
|
+
* import { headers } from 'next/headers';
|
|
10
|
+
* import { cookieToCrossConnectKitState } from '@nexus-cross/connect-kit-wagmi';
|
|
11
|
+
* import { config } from './config';
|
|
12
|
+
* import { Providers } from './providers';
|
|
13
|
+
*
|
|
14
|
+
* export default async function RootLayout({ children }) {
|
|
15
|
+
* const cookie = (await headers()).get('cookie');
|
|
16
|
+
* const initialState = cookieToCrossConnectKitState(config, cookie);
|
|
17
|
+
* return (
|
|
18
|
+
* <html><body>
|
|
19
|
+
* <Providers initialState={initialState}>{children}</Providers>
|
|
20
|
+
* </body></html>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Returns `undefined` when no cookie is present. Requires
|
|
26
|
+
* `createCrossxConfig({ ssr: true })`.
|
|
27
|
+
*/
|
|
28
|
+
export function cookieToCrossConnectKitState(config, cookieHeader) {
|
|
29
|
+
if (!cookieHeader)
|
|
30
|
+
return undefined;
|
|
31
|
+
const out = {
|
|
32
|
+
cross: config.crossWagmiConfig
|
|
33
|
+
? cookieToInitialState(config.crossWagmiConfig, cookieHeader)
|
|
34
|
+
: undefined,
|
|
35
|
+
reown: config.reownWagmiConfig
|
|
36
|
+
? cookieToInitialState(config.reownWagmiConfig, cookieHeader)
|
|
37
|
+
: undefined,
|
|
38
|
+
};
|
|
39
|
+
return out.cross || out.reown ? out : undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Pick the active-provider slice from the dual hydration state.
|
|
43
|
+
* Internal helper used by CrossConnectKitProvider; exported for tests.
|
|
44
|
+
*/
|
|
45
|
+
export function pickInitialState(state, providerKind) {
|
|
46
|
+
if (!state)
|
|
47
|
+
return undefined;
|
|
48
|
+
return providerKind === 'cross' ? state.cross : state.reown;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=ssr.js.map
|
package/dist/ssr.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.js","sourceRoot":"","sources":["../src/ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAYzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAAoB,EACpB,YAAuC;IAEvC,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,GAAG,GAAgC;QACvC,KAAK,EAAE,MAAM,CAAC,gBAAgB;YAC5B,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;YAC7D,CAAC,CAAC,SAAS;QACb,KAAK,EAAE,MAAM,CAAC,gBAAgB;YAC5B,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC;YAC7D,CAAC,CAAC,SAAS;KACd,CAAC;IACF,OAAO,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAA8C,EAC9C,YAA0B;IAE1B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-nexus.d.ts","sourceRoot":"","sources":["../src/to-nexus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/to-nexus.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-nexus.js","sourceRoot":"","sources":["../src/to-nexus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefixes used by the wallet SDKs crossx-kit integrates with. Disconnect
|
|
3
|
+
* flows must clear these so a stale WalletConnect session does not
|
|
4
|
+
* silently reconnect on the next page load.
|
|
5
|
+
*
|
|
6
|
+
* Derived from posa's manual cleanup (WalletProvider.tsx:207): `wc@`,
|
|
7
|
+
* `@w3m`, `wagmi`. Extended with `@walletconnect` and `@appkit` which some
|
|
8
|
+
* newer SDK versions write to.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_SESSION_STORAGE_PREFIXES: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Remove every `localStorage` key starting with any of the given prefixes.
|
|
13
|
+
* No-op on server environments (SSR, Node) and on browsers where storage
|
|
14
|
+
* access is blocked (private mode, quota exceeded).
|
|
15
|
+
*
|
|
16
|
+
* Intended for disconnect flows where we need to evict cached
|
|
17
|
+
* WalletConnect pairings before the user attempts to connect to a
|
|
18
|
+
* different wallet — without resorting to `window.location.reload()`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clearWalletSessionStorage(prefixes?: readonly string[]): void;
|
|
21
|
+
//# sourceMappingURL=sessionStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStorage.d.ts","sourceRoot":"","sources":["../../src/utils/sessionStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,EAAE,SAAS,MAAM,EAM7D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,SAAS,MAAM,EAAqC,GAC7D,IAAI,CA0BN"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefixes used by the wallet SDKs crossx-kit integrates with. Disconnect
|
|
3
|
+
* flows must clear these so a stale WalletConnect session does not
|
|
4
|
+
* silently reconnect on the next page load.
|
|
5
|
+
*
|
|
6
|
+
* Derived from posa's manual cleanup (WalletProvider.tsx:207): `wc@`,
|
|
7
|
+
* `@w3m`, `wagmi`. Extended with `@walletconnect` and `@appkit` which some
|
|
8
|
+
* newer SDK versions write to.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_SESSION_STORAGE_PREFIXES = [
|
|
11
|
+
'wc@',
|
|
12
|
+
'@w3m',
|
|
13
|
+
'@walletconnect',
|
|
14
|
+
'@appkit',
|
|
15
|
+
'wagmi',
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Remove every `localStorage` key starting with any of the given prefixes.
|
|
19
|
+
* No-op on server environments (SSR, Node) and on browsers where storage
|
|
20
|
+
* access is blocked (private mode, quota exceeded).
|
|
21
|
+
*
|
|
22
|
+
* Intended for disconnect flows where we need to evict cached
|
|
23
|
+
* WalletConnect pairings before the user attempts to connect to a
|
|
24
|
+
* different wallet — without resorting to `window.location.reload()`.
|
|
25
|
+
*/
|
|
26
|
+
export function clearWalletSessionStorage(prefixes = DEFAULT_SESSION_STORAGE_PREFIXES) {
|
|
27
|
+
if (typeof window === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
const storage = (() => {
|
|
30
|
+
try {
|
|
31
|
+
return window.localStorage;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
if (!storage)
|
|
38
|
+
return;
|
|
39
|
+
try {
|
|
40
|
+
const toRemove = [];
|
|
41
|
+
for (let i = 0; i < storage.length; i += 1) {
|
|
42
|
+
const key = storage.key(i);
|
|
43
|
+
if (key && prefixes.some((p) => key.startsWith(p))) {
|
|
44
|
+
toRemove.push(key);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (const key of toRemove) {
|
|
48
|
+
storage.removeItem(key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
/* storage access blocked — continue silently, SDK retries on next use */
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=sessionStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionStorage.js","sourceRoot":"","sources":["../../src/utils/sessionStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAsB;IACjE,KAAK;IACL,MAAM;IACN,gBAAgB;IAChB,SAAS;IACT,OAAO;CACR,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAA8B,gCAAgC;IAE9D,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAE1C,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE;QACpB,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,YAAY,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC3B,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge between the `--wi-*` CSS variables exposed by
|
|
3
|
+
* `@nexus-cross/dapp-ui`'s `WalletInfo` and `SDKThemeTokens` consumed by
|
|
4
|
+
* `crossy-sdk-js`'s embedded login modal.
|
|
5
|
+
*
|
|
6
|
+
* DApps typically theme their shell once (either by overriding `--wi-*`
|
|
7
|
+
* on `:root` or by relying on WalletInfo's built-in light/dark
|
|
8
|
+
* defaults). This helper reads that state at connector-creation time and
|
|
9
|
+
* forwards it into the embedded SDK so its modal renders with the same
|
|
10
|
+
* palette as WalletInfo — and by extension `OtherWalletsModal`, which
|
|
11
|
+
* also consumes `--wi-*`.
|
|
12
|
+
*
|
|
13
|
+
* Resolution order per token:
|
|
14
|
+
* 1. `--wi-*` CSS variable on `document.documentElement` (DApp override)
|
|
15
|
+
* 2. WalletInfo's built-in default for the requested mode
|
|
16
|
+
* 3. (embedded SDK's own default — we omit the key entirely)
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Minimal structural shape matching `@nexus-cross/crossx-sdk-core`'s
|
|
20
|
+
* `SDKColorOverrides`. Kept local so `@nexus-cross/connect-kit-wagmi`'s public API
|
|
21
|
+
* does not harden on external SDK internals.
|
|
22
|
+
*/
|
|
23
|
+
export interface SDKThemeTokenOverrides {
|
|
24
|
+
primary?: string;
|
|
25
|
+
secondary?: string;
|
|
26
|
+
onPrimary?: string;
|
|
27
|
+
borderDefault?: string;
|
|
28
|
+
borderSubtle?: string;
|
|
29
|
+
textIconPrimary?: string;
|
|
30
|
+
textIconSecondary?: string;
|
|
31
|
+
textIconTertiary?: string;
|
|
32
|
+
surfaceDefault?: string;
|
|
33
|
+
surfaceSubtle?: string;
|
|
34
|
+
bg?: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SDKThemeTokensShape {
|
|
38
|
+
light?: SDKThemeTokenOverrides;
|
|
39
|
+
dark?: SDKThemeTokenOverrides;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read overridden `--wi-*` values from `document.documentElement`.
|
|
43
|
+
* Empty/absent variables are skipped. Returns `undefined` when called
|
|
44
|
+
* outside a browser environment.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readWalletInfoTokens(): SDKThemeTokenOverrides | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Build the `themeTokens` argument for `crossxConnector`. Merges
|
|
49
|
+
* WalletInfo's built-in mode defaults with any `--wi-*` overrides on
|
|
50
|
+
* `:root` — the latter takes precedence per CSS cascade.
|
|
51
|
+
*
|
|
52
|
+
* The same resolved palette is applied to both `light` and `dark`
|
|
53
|
+
* entries. `crossxConnector`'s own `theme` prop then selects which
|
|
54
|
+
* entry to display; setting both prevents the SDK from flipping into a
|
|
55
|
+
* mismatched palette if `autoDetectTheme` is enabled elsewhere.
|
|
56
|
+
*/
|
|
57
|
+
export declare function deriveSDKThemeTokensFromWalletInfo(mode?: 'light' | 'dark'): SDKThemeTokensShape;
|
|
58
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/utils/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAC/B;AAsDD;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,sBAAsB,GAAG,SAAS,CAqBzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,IAAI,GAAE,OAAO,GAAG,MAAe,GAC9B,mBAAmB,CAOrB"}
|