@reown/appkit-controllers 1.8.21 → 1.8.22-headless-js.0
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/esm/exports/index.js +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/react.js +1 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/src/utils/HeadlessWalletUtil.js +137 -0
- package/dist/esm/src/utils/HeadlessWalletUtil.js.map +1 -0
- package/dist/esm/tests/utils/HeadlessWalletUtil.test.js +184 -0
- package/dist/esm/tests/utils/HeadlessWalletUtil.test.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/exports/index.d.ts +2 -0
- package/dist/types/exports/react.d.ts +3 -27
- package/dist/types/src/utils/HeadlessWalletUtil.d.ts +89 -0
- package/dist/types/tests/utils/HeadlessWalletUtil.test.d.ts +1 -0
- package/package.json +3 -3
|
@@ -73,5 +73,7 @@ export { MobileWalletUtil } from '../src/utils/MobileWallet.js';
|
|
|
73
73
|
export type * from '../src/utils/TypeUtil.js';
|
|
74
74
|
export type * from '../src/utils/SIWXUtil.js';
|
|
75
75
|
export type { WalletItem } from '../src/utils/ConnectUtil.js';
|
|
76
|
+
export { HeadlessWalletUtil } from '../src/utils/HeadlessWalletUtil.js';
|
|
77
|
+
export type { ConnectOptions, FetchWalletsOptions, WalletListSnapshot } from '../src/utils/HeadlessWalletUtil.js';
|
|
76
78
|
export * from '../src/utils/ChainControllerUtil.js';
|
|
77
79
|
export * from '../src/utils/WalletConnectUtil.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CaipNetwork, type ChainNamespace, type Connection } from '@reown/appkit-common';
|
|
2
2
|
import { type WalletItem } from '../src/utils/ConnectUtil.js';
|
|
3
|
-
import
|
|
3
|
+
import { type ConnectOptions, type FetchWalletsOptions } from '../src/utils/HeadlessWalletUtil.js';
|
|
4
|
+
import type { UseAppKitAccountReturn, UseAppKitNetworkReturn } from '../src/utils/TypeUtil.js';
|
|
4
5
|
export type { Connection } from '@reown/appkit-common';
|
|
5
6
|
interface DisconnectParams {
|
|
6
7
|
id?: string;
|
|
@@ -25,9 +26,7 @@ interface DeleteRecentConnectionProps {
|
|
|
25
26
|
address: string;
|
|
26
27
|
connectorId: string;
|
|
27
28
|
}
|
|
28
|
-
export
|
|
29
|
-
wcPayUrl?: string;
|
|
30
|
-
}
|
|
29
|
+
export type { ConnectOptions, FetchWalletsOptions } from '../src/utils/HeadlessWalletUtil.js';
|
|
31
30
|
export declare function useAppKitProvider<T>(chainNamespace: ChainNamespace): {
|
|
32
31
|
walletProvider: T;
|
|
33
32
|
walletProviderType: import("./index.js").ConnectorType | undefined;
|
|
@@ -81,29 +80,6 @@ export declare function useAppKitConnection({ namespace, onSuccess, onError }: U
|
|
|
81
80
|
switchConnection: ({ connection: _connection, address }: SwitchConnectionParams) => Promise<void>;
|
|
82
81
|
deleteConnection: ({ address, connectorId }: DeleteRecentConnectionProps) => void;
|
|
83
82
|
};
|
|
84
|
-
export interface FetchWalletsOptions {
|
|
85
|
-
/** Page number to fetch (default: 1) */
|
|
86
|
-
page?: number;
|
|
87
|
-
/** @deprecated Use `search` instead */
|
|
88
|
-
query?: string;
|
|
89
|
-
/** Search query to filter wallets. When provided, switches to search mode. */
|
|
90
|
-
search?: string;
|
|
91
|
-
/** Number of entries per page. Defaults to 40 for list mode, 100 for search mode. */
|
|
92
|
-
entries?: number;
|
|
93
|
-
/** Filter wallets by badge type ('none' | 'certified') */
|
|
94
|
-
badge?: BadgeType;
|
|
95
|
-
/** Wallet IDs to include. Overrides the global includeWalletIds config when provided. */
|
|
96
|
-
include?: string[];
|
|
97
|
-
/** Wallet IDs to exclude. Overrides the default exclude list when provided. */
|
|
98
|
-
exclude?: string[];
|
|
99
|
-
/**
|
|
100
|
-
* Include wallets that support WalletConnect Pay but are not v2-compatible.
|
|
101
|
-
* By default these are filtered out. Enable for WalletConnect Pay surfaces.
|
|
102
|
-
*/
|
|
103
|
-
includePayOnly?: boolean;
|
|
104
|
-
/** Sort mode. 'wcpay' bubbles WalletConnect Pay-supporting wallets to the top. */
|
|
105
|
-
sort?: 'default' | 'wcpay';
|
|
106
|
-
}
|
|
107
83
|
export interface UseAppKitWalletsReturn {
|
|
108
84
|
/**
|
|
109
85
|
* List of wallets for the initial connect view including WalletConnect wallet and injected wallets together. If user doesn't have any injected wallets, it'll fill the list with most ranked WalletConnect wallets.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ChainNamespace } from '@reown/appkit-common';
|
|
2
|
+
import { type WalletItem } from './ConnectUtil.js';
|
|
3
|
+
/** Options for {@link HeadlessWalletUtil.fetchWallets}. */
|
|
4
|
+
export interface FetchWalletsOptions {
|
|
5
|
+
/** Page number to fetch (default: 1) */
|
|
6
|
+
page?: number;
|
|
7
|
+
/** @deprecated Use `search` instead */
|
|
8
|
+
query?: string;
|
|
9
|
+
/** Search query to filter wallets. When provided, switches to search mode. */
|
|
10
|
+
search?: string;
|
|
11
|
+
/** Number of entries per page. Defaults to 40 for list mode, 100 for search mode. */
|
|
12
|
+
entries?: number;
|
|
13
|
+
/** Filter wallets by badge type ('none' | 'certified') */
|
|
14
|
+
badge?: 'none' | 'certified';
|
|
15
|
+
/** Wallet IDs to include. Overrides the global includeWalletIds config when provided. */
|
|
16
|
+
include?: string[];
|
|
17
|
+
/** Wallet IDs to exclude. Overrides the default exclude list when provided. */
|
|
18
|
+
exclude?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Include wallets that support WalletConnect Pay but are not v2-compatible.
|
|
21
|
+
* By default these are filtered out. Enable for WalletConnect Pay surfaces.
|
|
22
|
+
*/
|
|
23
|
+
includePayOnly?: boolean;
|
|
24
|
+
/** Sort mode. 'wcpay' bubbles WalletConnect Pay-supporting wallets to the top. */
|
|
25
|
+
sort?: 'default' | 'wcpay';
|
|
26
|
+
}
|
|
27
|
+
/** Options for {@link HeadlessWalletUtil.connect} / {@link HeadlessWalletUtil.getWalletConnectUri}. */
|
|
28
|
+
export interface ConnectOptions {
|
|
29
|
+
/**
|
|
30
|
+
* A WalletConnect Pay deeplink appended to the WC URI, so a WCPay-capable wallet
|
|
31
|
+
* returns to — and processes — this payment after pairing.
|
|
32
|
+
*/
|
|
33
|
+
wcPayUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
/** The headless wallet list, read imperatively. */
|
|
36
|
+
export interface WalletListSnapshot {
|
|
37
|
+
/** Initial connect-view wallets: installed extensions + top-ranked WalletConnect wallets. */
|
|
38
|
+
wallets: WalletItem[];
|
|
39
|
+
/** The full WalletGuide WalletConnect list (with the current search results applied). */
|
|
40
|
+
wcWallets: WalletItem[];
|
|
41
|
+
/** Current page of the WalletConnect list. */
|
|
42
|
+
page: number;
|
|
43
|
+
/** Total number of available WalletConnect wallets for the current parameters. */
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Framework-agnostic headless wallet-list logic — the imperative core behind the
|
|
48
|
+
* `useAppKitWallets` React hook and the `AppKit` client's wallet methods.
|
|
49
|
+
*
|
|
50
|
+
* AppKit runs headless (no modal): the host renders its own picker and connects a
|
|
51
|
+
* chosen wallet programmatically. That orchestration (list / search / paginate the
|
|
52
|
+
* WalletGuide wallets, fetch the WalletConnect URI, and connect injected / API / mobile
|
|
53
|
+
* wallets) lived only inside the React hook; lifting it here lets a non-React host
|
|
54
|
+
* (e.g. `@walletconnect/pay-appkit`) drive the same flow through `appKit.*` methods,
|
|
55
|
+
* with the hook and the client sharing one tested code path.
|
|
56
|
+
*
|
|
57
|
+
* Reads/writes the global controllers directly (valtio singletons), so it takes no
|
|
58
|
+
* AppKit instance — exactly like {@link ConnectionControllerUtil}.
|
|
59
|
+
*/
|
|
60
|
+
export declare const HeadlessWalletUtil: {
|
|
61
|
+
/**
|
|
62
|
+
* Fetch / search / paginate the WalletConnect wallet list from the explorer API.
|
|
63
|
+
* With a `search` (or the deprecated `query`), switches to search mode; otherwise
|
|
64
|
+
* lists/paginates. Reads results from `ApiController.state` (see {@link getWalletList}).
|
|
65
|
+
*/
|
|
66
|
+
fetchWallets(fetchOptions?: FetchWalletsOptions): Promise<void>;
|
|
67
|
+
/** Read the current wallet list (initial view + WalletConnect list + pagination). */
|
|
68
|
+
getWalletList(): WalletListSnapshot;
|
|
69
|
+
/** Subscribe to wallet-list changes (the WalletGuide list + search results). */
|
|
70
|
+
subscribeWalletList(callback: () => void): () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Pre-fetch the WalletConnect URI (read from `ConnectionController.state.wcUri`).
|
|
73
|
+
* Call when a wallet is selected so a later connect can deeplink synchronously
|
|
74
|
+
* (required for iOS Safari). Uses 'auto' cache to reuse a valid URI or fetch a new one.
|
|
75
|
+
*/
|
|
76
|
+
getWalletConnectUri(_options?: ConnectOptions): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Connect a chosen wallet programmatically (headless — no modal).
|
|
79
|
+
*
|
|
80
|
+
* Handles injected wallets, API wallets (from the "all wallets" list), and mobile
|
|
81
|
+
* deeplinks. For API wallets without pre-populated connectors, falls back to a lookup
|
|
82
|
+
* by the wallet's ID via `explorerId` matching (e.g. Coinbase/Base from "all wallets").
|
|
83
|
+
*/
|
|
84
|
+
connect(wallet: WalletItem, namespace?: ChainNamespace, options?: ConnectOptions): Promise<void>;
|
|
85
|
+
/** Reset the WalletConnect URI + linking state (e.g. when a QR is closed). */
|
|
86
|
+
resetWcUri(): void;
|
|
87
|
+
/** Clear the `connectingWallet` state. */
|
|
88
|
+
resetConnectingWallet(): void;
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reown/appkit-controllers",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.22-headless-js.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/exports/index.js",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@walletconnect/universal-provider": "2.23.7",
|
|
57
57
|
"valtio": "2.1.7",
|
|
58
58
|
"viem": ">=2.45.0",
|
|
59
|
-
"@reown/appkit-common": "1.8.
|
|
60
|
-
"@reown/appkit-wallet": "1.8.
|
|
59
|
+
"@reown/appkit-common": "1.8.22-headless-js.0",
|
|
60
|
+
"@reown/appkit-wallet": "1.8.22-headless-js.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@vitest/coverage-v8": "2.1.9",
|