@pollar/stellar-wallets-kit-adapter 0.10.0-rc.8 → 0.10.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @pollar/stellar-wallets-kit-adapter
2
2
 
3
- Plug [Stellar Wallets Kit](https://stellarwalletskit.dev) into [`@pollar/core`](../core) as a single wallet adapter, without `@pollar/core` having to depend on the kit. One install gives Pollar access to **every wallet module the kit supports** — Freighter, Albedo, xBull, Lobstr, Rabet, Hana, Bitget, OneKey, Klever, Fordefi, CactusLink, HotWallet, plus Ledger / Trezor / WalletConnect via opt-in.
3
+ Plug [Stellar Wallets Kit](https://stellarwalletskit.dev) into [`@pollar/core`](../core) as a set of wallet adapters, without `@pollar/core` having to depend on the kit. One install gives Pollar access to **every wallet module the kit supports** — Freighter, Albedo, xBull, Lobstr, Rabet, Hana, Bitget, OneKey, Klever, Fordefi, CactusLink, HotWallet, plus Ledger / Trezor / WalletConnect via opt-in.
4
4
 
5
- The adapter is consumed through the `walletAdapter` slot on `PollarClientConfig`, so swapping wallet stacks (built-in adapters → kit, kit → custom resolver) is a one-line change.
5
+ The adapters are registered through the `walletAdapters` slot on `PollarClientConfig`. `stellarWalletsKitAdapters()` returns a `WalletAdapter[]` (one adapter per kit module) that you spread into that array alongside any other adapters you register.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,46 +16,54 @@ npm install @pollar/stellar-wallets-kit-adapter @creit.tech/stellar-wallets-kit
16
16
 
17
17
  ```ts
18
18
  import { PollarClient } from '@pollar/core';
19
- import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';
19
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
20
20
  import { Networks } from '@creit.tech/stellar-wallets-kit';
21
21
 
22
22
  const client = new PollarClient({
23
23
  apiKey: 'your-api-key',
24
- walletAdapter: stellarWalletsKit({ network: Networks.PUBLIC }),
24
+ walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
25
25
  });
26
26
 
27
- // Triggers the kit's flow for the picked wallet id
28
- client.loginWallet('xbull');
27
+ // Log in with one of the registered kit wallets
28
+ client.login({ provider: 'xbull' });
29
29
  ```
30
30
 
31
31
  With React:
32
32
 
33
33
  ```tsx
34
34
  import { PollarProvider } from '@pollar/react';
35
- import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';
35
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
36
36
  import { Networks } from '@creit.tech/stellar-wallets-kit';
37
37
 
38
38
  <PollarProvider
39
39
  client={{
40
40
  apiKey: 'your-api-key',
41
- walletAdapter: stellarWalletsKit({ network: Networks.TESTNET }),
41
+ walletAdapters: stellarWalletsKitAdapters({ network: Networks.TESTNET }),
42
42
  }}
43
43
  >
44
44
  {/* your app */}
45
45
  </PollarProvider>;
46
46
  ```
47
47
 
48
- This wires the **signing path** but the built-in `LoginModal` still shows
49
- only Freighter / Albedo. To render the kit's full wallet list (xBull, Lobstr,
50
- Rabet, …) inside `LoginModal`, also pass the picker — see
51
- [Wallet picker UI (`/picker`)](#wallet-picker-ui-picker) below.
52
-
53
- The kit is a global singleton. `stellarWalletsKit(...)` returns a resolver and `StellarWalletsKit.init(...)` is called once on the first `loginWallet` call.
54
-
55
- > **0.9.0** — `connect()` resolves to `{ address }` only (the duplicate
56
- > `publicKey` field is gone, matching the new `ConnectWalletResponse`). Requires
57
- > `@pollar/core@^0.9.0` / `@pollar/react@^0.9.0`. Adds `logLevel` / `logger`
58
- > options (set once at init — the kit is a global singleton).
48
+ Every wallet you register this way renders as its own button inside Pollar's
49
+ `LoginModal` (collapsed behind a shared "Wallet" gateway) - see
50
+ [Login UI](#login-ui) below.
51
+
52
+ The kit is a global singleton. `stellarWalletsKitAdapters(...)` returns a
53
+ `WalletAdapter[]` and runs `StellarWalletsKit.init(...)` synchronously at call
54
+ time (via `ensureInit()`), building one `StellarWalletsKitAdapter` per module up
55
+ front. It is not lazy - a later `login({ provider })` just routes to the
56
+ matching adapter that was already built.
57
+
58
+ > **0.10.0** - switched to the `walletAdapters[]` array model: the factory is now
59
+ > `stellarWalletsKitAdapters()` (was `stellarWalletsKit()`) and returns a
60
+ > `WalletAdapter[]` for the plural `walletAdapters` config slot instead of a
61
+ > single resolver for `walletAdapter`. SSR-safe: returns `[]` when there is no
62
+ > `window`. Requires `@pollar/core@^0.10.0` / `@pollar/react@^0.10.0`.
63
+ >
64
+ > **0.9.0** - `connect()` resolves to `{ address }` only (the duplicate
65
+ > `publicKey` field is gone, matching the new `ConnectWalletResponse`). Adds
66
+ > `logLevel` / `logger` options (set once at init - the kit is a global singleton).
59
67
  >
60
68
  > **0.8.0** — `network` is **required**. The previous `Networks.TESTNET`
61
69
  > default was removed because the kit is a global singleton, and silently
@@ -64,7 +72,7 @@ The kit is a global singleton. `stellarWalletsKit(...)` returns a resolver and `
64
72
 
65
73
  ## Default wallets
66
74
 
67
- Calling `stellarWalletsKit({ network })` with no `modules` argument enables every module that loads without extra configuration:
75
+ Calling `stellarWalletsKitAdapters({ network })` with no `modules` argument enables every module that loads without extra configuration (12 in total):
68
76
 
69
77
  | Module | Wallet id (`WalletId`) | Type |
70
78
  | ------------------ | ---------------------- | ------------------ |
@@ -88,7 +96,7 @@ Calling `stellarWalletsKit({ network })` with no `modules` argument enables ever
88
96
  Pass your own `modules` list. Import from the kit's per-wallet subpaths so unused modules tree-shake out:
89
97
 
90
98
  ```ts
91
- import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';
99
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
92
100
  import { Networks } from '@creit.tech/stellar-wallets-kit';
93
101
  import { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';
94
102
  import { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';
@@ -96,7 +104,7 @@ import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wal
96
104
 
97
105
  const client = new PollarClient({
98
106
  apiKey: 'your-api-key',
99
- walletAdapter: stellarWalletsKit({
107
+ walletAdapters: stellarWalletsKitAdapters({
100
108
  network: Networks.PUBLIC,
101
109
  modules: [
102
110
  new FreighterModule(),
@@ -136,11 +144,22 @@ interface StellarWalletsKitAdapterOptions {
136
144
  modules?: ModuleInterface[];
137
145
 
138
146
  /**
139
- * Picker-specific options. Only consumed by `<KitWalletPicker>` /
140
- * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver
141
- * itself ignores them.
147
+ * Picker-specific options: which kit wallets to include, label overrides, and
148
+ * the gateway group label. `wallets`, `labels`, and `groupLabel` are honored by
149
+ * `stellarWalletsKitAdapters()`; the remaining fields are consumed by the
150
+ * `/picker` subpath.
142
151
  */
143
152
  picker?: KitPickerOptions;
153
+
154
+ /**
155
+ * Minimum log severity. `'silent'` disables logging; otherwise
156
+ * `error` < `warn` < `info` < `debug`. Defaults to `'info'`. Set once at init
157
+ * since the kit is a global singleton.
158
+ */
159
+ logLevel?: LogLevel;
160
+
161
+ /** Sink for logs. Defaults to the global `console`. */
162
+ logger?: PollarLogger;
144
163
  }
145
164
 
146
165
  interface KitPickerOptions {
@@ -152,101 +171,82 @@ interface KitPickerOptions {
152
171
  showInstalledOnly?: boolean;
153
172
  /** Per-wallet label overrides. Key = wallet id. */
154
173
  labels?: Record<string, string>;
174
+ /**
175
+ * Label of the gateway button the kit wallets collapse behind in the login UI
176
+ * (applied as each adapter's `meta.group`). Default `'Wallet'` - the same group
177
+ * as the built-in Freighter/Albedo, so they share one gateway. Set a distinct
178
+ * value (e.g. `'More wallets'`) to render the kit wallets as a separate gateway.
179
+ */
180
+ groupLabel?: string;
155
181
  /** Visual layout. Default `'grid'`. */
156
182
  layout?: 'grid' | 'list';
157
- /** Theme passthrough — applied as CSS custom properties on the picker root. */
183
+ /** Theme passthrough - applied as CSS custom properties on the picker root. */
158
184
  theme?: { accent?: string; mode?: 'light' | 'dark' };
159
185
  }
160
186
  ```
161
187
 
162
- The factory returns a `WalletAdapterResolver` from `@pollar/core`:
188
+ `stellarWalletsKitAdapters()` returns `WalletAdapter[]` from `@pollar/core` - one
189
+ adapter per included kit module - which you assign to
190
+ `PollarClientConfig.walletAdapters`. Each adapter's `type` is the kit `WalletId`
191
+ (`WalletType | (string & {})`, so `WalletType.FREIGHTER` keeps autocomplete while
192
+ `'xbull'`, `'lobstr'`, ... are accepted as plain strings) and its `meta` carries
193
+ the module's label/icon for the auto-rendered login button.
163
194
 
164
- ```ts
165
- type WalletAdapterResolver = (id: WalletId) => WalletAdapter | Promise<WalletAdapter>;
166
- ```
195
+ ### SSR safety
167
196
 
168
- `WalletId` is `WalletType | (string & {})` — `WalletType.FREIGHTER` / `WalletType.ALBEDO` keep autocomplete, every other kit id (`'xbull'`, `'lobstr'`, …) is accepted as a plain string.
197
+ `stellarWalletsKitAdapters()` returns `[]` when `typeof window === 'undefined'`.
198
+ The kit talks to browser wallet extensions and touches `window` both at
199
+ `StellarWalletsKit.init()` and inside its module constructors, so there are no
200
+ wallets to build server-side. Under Next.js/Remix, construct your `PollarClient`
201
+ and render the wallet UI on the client (e.g. behind a mounted flag or
202
+ `dynamic(..., { ssr: false })`); the real adapters are built when the factory
203
+ re-runs in the browser.
169
204
 
170
205
  ## How it fits the Pollar wallet contract
171
206
 
172
207
  The adapter implements `WalletAdapter` from `@pollar/core`:
173
208
 
174
- | `WalletAdapter` method | Kit call |
175
- | ---------------------------- | ---------------------------------------------- |
176
- | `isAvailable()` | `StellarWalletsKit.setWallet(id)` |
177
- | `connect()` | `setWallet(id)` → `fetchAddress()` |
178
- | `disconnect()` | `StellarWalletsKit.disconnect()` |
179
- | `getPublicKey()` | `StellarWalletsKit.getAddress()` |
180
- | `signTransaction(xdr, opts)` | `setWallet(id)` → `signTransaction(xdr, opts)` |
181
- | `signAuthEntry(xdr, opts)` | `setWallet(id)` → `signAuthEntry(xdr, opts)` |
182
-
183
- `setWallet` is called before every operation so a single `StellarWalletsKit.init({ modules })` covers many wallets — `PollarClient` resolves a fresh adapter instance per `WalletId`, and the kit routes to the correct module under the hood.
184
-
185
- ## Wallet picker UI (`/picker`)
186
-
187
- The `/picker` subpath ships a React component that renders the kit's full
188
- wallet list inside Pollar's `LoginModal`. It plugs into the
189
- `ui.renderWallets` slot on `<PollarProvider>` (new in `@pollar/react@0.8.0`).
190
-
191
- > **React is an optional peer dep.** Only the `/picker` subpath pulls in
192
- > `react` / `react-dom` / `@pollar/react`. Headless consumers of
193
- > `stellarWalletsKit({ network })` keep working with zero React in the bundle.
194
-
195
- ### Bundle helper
196
-
197
- `createStellarWalletsKitBundle` builds both halves of the integration
198
- (signing resolver + picker slot) from a single options object, so the picker
199
- can only show wallets that signing actually supports:
209
+ | `WalletAdapter` method | Kit call |
210
+ | ---------------------------- | ----------------------------------------------------------- |
211
+ | `isAvailable()` | `refreshSupportedWallets()` then check the wallet's `isAvailable` flag |
212
+ | `connect()` | `setWallet(id)` > `fetchAddress()` |
213
+ | `disconnect()` | `StellarWalletsKit.disconnect()` |
214
+ | `getPublicKey()` | `StellarWalletsKit.getAddress()` |
215
+ | `signTransaction(xdr, opts)` | `setWallet(id)` > `signTransaction(xdr, opts)` |
216
+ | `signAuthEntry(xdr, opts)` | `setWallet(id)` > `signAuthEntry(xdr, opts)` |
217
+
218
+ `setWallet` is called before every signing/connect operation so a single
219
+ `StellarWalletsKit.init({ modules })` covers many wallets. `stellarWalletsKitAdapters()`
220
+ builds one `StellarWalletsKitAdapter` per module up front and returns the array;
221
+ each adapter is bound to its own `WalletId` and the kit routes to the correct
222
+ module under the hood.
223
+
224
+ ## Login UI
225
+
226
+ The wallets you register via `stellarWalletsKitAdapters({ network })` render
227
+ automatically inside Pollar's `LoginModal` — one button per wallet, collapsed
228
+ behind a single "Wallet" gateway button (their shared `meta.group`). Pass
229
+ `picker.groupLabel` to give them a distinct gateway, or `picker.labels` to
230
+ override individual button labels.
200
231
 
201
232
  ```tsx
202
233
  import { PollarProvider } from '@pollar/react';
203
- import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';
234
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
204
235
  import { Networks } from '@creit.tech/stellar-wallets-kit';
205
236
 
206
- const bundle = createStellarWalletsKitBundle({
207
- network: Networks.PUBLIC,
208
- // Optional — subset, order, layout, theme, labels: see `KitPickerOptions`
209
- picker: { wallets: ['xbull', 'lobstr', 'freighter'], layout: 'list' },
210
- });
211
-
212
237
  <PollarProvider
213
- client={{ apiKey: 'your-api-key', walletAdapter: bundle.walletAdapter }}
214
- ui={{ renderWallets: bundle.renderWallets }}
215
- >
216
- {/* your app */}
217
- </PollarProvider>;
218
- ```
219
-
220
- ### Picker component directly
221
-
222
- If you already build the `walletAdapter` yourself (e.g. composing a custom
223
- resolver), use `<KitWalletPicker>` directly inside a `renderWallets` slot:
224
-
225
- ```tsx
226
- import { KitWalletPicker } from '@pollar/stellar-wallets-kit-adapter/picker';
227
- import { Networks } from '@creit.tech/stellar-wallets-kit';
228
-
229
- <PollarProvider
230
- client={{ apiKey: '…', walletAdapter: myResolver }}
231
- ui={{
232
- renderWallets: ({ onConnect, authState }) => (
233
- <KitWalletPicker
234
- onConnect={onConnect}
235
- authState={authState}
236
- network={Networks.PUBLIC}
237
- picker={{ wallets: ['xbull', 'lobstr'], showInstalledOnly: true }}
238
- />
239
- ),
238
+ client={{
239
+ apiKey: 'your-api-key',
240
+ walletAdapters: stellarWalletsKitAdapters({
241
+ network: Networks.PUBLIC,
242
+ picker: { wallets: ['xbull', 'lobstr', 'freighter'] },
243
+ }),
240
244
  }}
241
245
  >
242
- {children}
246
+ {/* your app */}
243
247
  </PollarProvider>;
244
248
  ```
245
249
 
246
- `<KitWalletPicker>` will lazily call `ensureInit({ network, modules })` on
247
- mount, so it works whether or not `stellarWalletsKit(...)` has already been
248
- called elsewhere — both share the same kit singleton.
249
-
250
250
  ## Direct adapter access
251
251
 
252
252
  If you need a `WalletAdapter` instance directly (custom flows outside `PollarClient`), instantiate it yourself once the kit is initialized:
@@ -258,33 +258,36 @@ import { StellarWalletsKitAdapter } from '@pollar/stellar-wallets-kit-adapter';
258
258
 
259
259
  StellarWalletsKit.init({ network: Networks.PUBLIC, modules: [new FreighterModule()] });
260
260
 
261
- const adapter = new StellarWalletsKitAdapter('freighter');
261
+ // The constructor requires a meta arg whose `label` is required.
262
+ const adapter = new StellarWalletsKitAdapter('freighter', { label: 'Freighter' });
262
263
  const { address } = await adapter.connect();
263
264
  ```
264
265
 
265
- ## Writing a custom resolver
266
+ ## Composing with other adapters
266
267
 
267
- `walletAdapter` accepts any function matching `WalletAdapterResolver`. Use this to swap between the kit and your own implementation per-id, or to compose multiple adapter packages:
268
+ `walletAdapters` is a plain `WalletAdapter[]`, so you can spread the kit adapters
269
+ alongside adapters from other packages (`@pollar/privy-adapter`, ...) or your own.
270
+ Entries later in the array override an earlier one that reuses the same `type`, and
271
+ each entry also overrides a built-in Freighter/Albedo with a matching `type`:
268
272
 
269
273
  ```ts
270
- import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';
271
- import { FreighterAdapter, WalletType } from '@pollar/core';
272
-
273
- const kit = stellarWalletsKit({ network: Networks.PUBLIC });
274
+ import { PollarClient } from '@pollar/core';
275
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
276
+ import { Networks } from '@creit.tech/stellar-wallets-kit';
277
+ import { MyCustomAdapter } from './my-custom-adapter';
274
278
 
275
279
  new PollarClient({
276
280
  apiKey: 'your-api-key',
277
- walletAdapter: (id) => {
278
- // Use the in-house Freighter adapter, kit for everything else
279
- if (id === WalletType.FREIGHTER) return new FreighterAdapter();
280
- return kit(id);
281
- },
281
+ walletAdapters: [
282
+ ...stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
283
+ new MyCustomAdapter(),
284
+ ],
282
285
  });
283
286
  ```
284
287
 
285
288
  ## Fallback behaviour
286
289
 
287
- If `walletAdapter` is omitted from `PollarClientConfig`, `@pollar/core` falls back to its built-in `FreighterAdapter` / `AlbedoAdapter`. Installing this package is opt-in — existing apps keep working without changes until they switch the slot.
290
+ If `walletAdapters` is omitted from `PollarClientConfig`, `@pollar/core` falls back to its built-in `FreighterAdapter` / `AlbedoAdapter`. Installing this package is opt-in - existing apps keep working without changes until they add adapters to the slot.
288
291
 
289
292
  ## License
290
293
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { WalletAdapter, WalletId, WalletAdapterMeta, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
2
- export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKitAdapters } from './factory-D5jFO9d8.mjs';
3
- import '@creit.tech/stellar-wallets-kit';
1
+ import { WalletAdapter, WalletId, WalletAdapterMeta, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse, LogLevel, PollarLogger } from '@pollar/core';
2
+ import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
4
3
 
5
4
  /**
6
5
  * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`
@@ -22,4 +21,91 @@ declare class StellarWalletsKitAdapter implements WalletAdapter {
22
21
  signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
23
22
  }
24
23
 
25
- export { StellarWalletsKitAdapter };
24
+ /**
25
+ * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
26
+ * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can
27
+ * receive everything (network + modules + UI) in one call.
28
+ */
29
+ interface KitPickerOptions {
30
+ /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */
31
+ wallets?: string[];
32
+ /** Render order. Default `'as-given'` (the kit's own order). */
33
+ order?: 'as-given' | 'installed-first' | 'alphabetical';
34
+ /** Hide wallets whose `isAvailable` is false. Default `false`. */
35
+ showInstalledOnly?: boolean;
36
+ /** Per-wallet label overrides. Key = wallet id. */
37
+ labels?: Record<string, string>;
38
+ /**
39
+ * Label of the gateway button these kit wallets collapse behind in the login
40
+ * UI (the `meta.group` applied to every adapter this factory builds). Default
41
+ * `'Wallet'` — the same group as the built-in Freighter/Albedo, so they share
42
+ * one gateway. Set a distinct value (e.g. `'More wallets'`) to render the kit
43
+ * wallets as a *separate* gateway button from the built-in ones.
44
+ */
45
+ groupLabel?: string;
46
+ /** Visual layout. Default `'grid'`. */
47
+ layout?: 'grid' | 'list';
48
+ /** Theme passthrough — applied as CSS custom properties on the picker root. */
49
+ theme?: {
50
+ accent?: string;
51
+ mode?: 'light' | 'dark';
52
+ };
53
+ }
54
+ interface StellarWalletsKitAdapterOptions {
55
+ /**
56
+ * Stellar network the kit will use for signing. Required — there is no
57
+ * default. The kit is a global singleton, so picking the network silently
58
+ * for a consumer would risk signing real-looking transactions on the wrong
59
+ * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or
60
+ * `Networks.PUBLIC` explicitly.
61
+ */
62
+ network: Networks;
63
+ /**
64
+ * Wallet modules the kit should drive. Defaults to every module that works
65
+ * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,
66
+ * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list
67
+ * to add Ledger / Trezor / WalletConnect — those need extra setup (a
68
+ * Buffer polyfill for Ledger; constructor params for the other two) so we
69
+ * don't auto-include them.
70
+ *
71
+ * Import modules from their kit subpaths so the bundle stays lean:
72
+ * ```ts
73
+ * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';
74
+ * ```
75
+ */
76
+ modules?: ModuleInterface[];
77
+ /**
78
+ * Picker-specific options. Only consumed by `<KitWalletPicker>` /
79
+ * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver
80
+ * itself ignores them.
81
+ */
82
+ picker?: KitPickerOptions;
83
+ /**
84
+ * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`
85
+ * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global
86
+ * singleton, this is set once at init.
87
+ */
88
+ logLevel?: LogLevel;
89
+ /** Sink for logs. Defaults to the global `console`. */
90
+ logger?: PollarLogger;
91
+ }
92
+ /**
93
+ * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one
94
+ * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter
95
+ * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)
96
+ * and `picker.labels` (overrides) are honored if provided.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
101
+ * import { Networks } from '@creit.tech/stellar-wallets-kit';
102
+ *
103
+ * const client = new PollarClient({
104
+ * apiKey: '…',
105
+ * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
106
+ * });
107
+ * ```
108
+ */
109
+ declare function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[];
110
+
111
+ export { type KitPickerOptions, StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, stellarWalletsKitAdapters };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { WalletAdapter, WalletId, WalletAdapterMeta, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
2
- export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKitAdapters } from './factory-D5jFO9d8.js';
3
- import '@creit.tech/stellar-wallets-kit';
1
+ import { WalletAdapter, WalletId, WalletAdapterMeta, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse, LogLevel, PollarLogger } from '@pollar/core';
2
+ import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
4
3
 
5
4
  /**
6
5
  * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`
@@ -22,4 +21,91 @@ declare class StellarWalletsKitAdapter implements WalletAdapter {
22
21
  signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
23
22
  }
24
23
 
25
- export { StellarWalletsKitAdapter };
24
+ /**
25
+ * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
26
+ * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can
27
+ * receive everything (network + modules + UI) in one call.
28
+ */
29
+ interface KitPickerOptions {
30
+ /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */
31
+ wallets?: string[];
32
+ /** Render order. Default `'as-given'` (the kit's own order). */
33
+ order?: 'as-given' | 'installed-first' | 'alphabetical';
34
+ /** Hide wallets whose `isAvailable` is false. Default `false`. */
35
+ showInstalledOnly?: boolean;
36
+ /** Per-wallet label overrides. Key = wallet id. */
37
+ labels?: Record<string, string>;
38
+ /**
39
+ * Label of the gateway button these kit wallets collapse behind in the login
40
+ * UI (the `meta.group` applied to every adapter this factory builds). Default
41
+ * `'Wallet'` — the same group as the built-in Freighter/Albedo, so they share
42
+ * one gateway. Set a distinct value (e.g. `'More wallets'`) to render the kit
43
+ * wallets as a *separate* gateway button from the built-in ones.
44
+ */
45
+ groupLabel?: string;
46
+ /** Visual layout. Default `'grid'`. */
47
+ layout?: 'grid' | 'list';
48
+ /** Theme passthrough — applied as CSS custom properties on the picker root. */
49
+ theme?: {
50
+ accent?: string;
51
+ mode?: 'light' | 'dark';
52
+ };
53
+ }
54
+ interface StellarWalletsKitAdapterOptions {
55
+ /**
56
+ * Stellar network the kit will use for signing. Required — there is no
57
+ * default. The kit is a global singleton, so picking the network silently
58
+ * for a consumer would risk signing real-looking transactions on the wrong
59
+ * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or
60
+ * `Networks.PUBLIC` explicitly.
61
+ */
62
+ network: Networks;
63
+ /**
64
+ * Wallet modules the kit should drive. Defaults to every module that works
65
+ * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,
66
+ * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list
67
+ * to add Ledger / Trezor / WalletConnect — those need extra setup (a
68
+ * Buffer polyfill for Ledger; constructor params for the other two) so we
69
+ * don't auto-include them.
70
+ *
71
+ * Import modules from their kit subpaths so the bundle stays lean:
72
+ * ```ts
73
+ * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';
74
+ * ```
75
+ */
76
+ modules?: ModuleInterface[];
77
+ /**
78
+ * Picker-specific options. Only consumed by `<KitWalletPicker>` /
79
+ * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver
80
+ * itself ignores them.
81
+ */
82
+ picker?: KitPickerOptions;
83
+ /**
84
+ * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`
85
+ * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global
86
+ * singleton, this is set once at init.
87
+ */
88
+ logLevel?: LogLevel;
89
+ /** Sink for logs. Defaults to the global `console`. */
90
+ logger?: PollarLogger;
91
+ }
92
+ /**
93
+ * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one
94
+ * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter
95
+ * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)
96
+ * and `picker.labels` (overrides) are honored if provided.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
101
+ * import { Networks } from '@creit.tech/stellar-wallets-kit';
102
+ *
103
+ * const client = new PollarClient({
104
+ * apiKey: '…',
105
+ * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
106
+ * });
107
+ * ```
108
+ */
109
+ declare function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[];
110
+
111
+ export { type KitPickerOptions, StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, stellarWalletsKitAdapters };
package/dist/index.js CHANGED
@@ -69,13 +69,15 @@ function getInitNetwork() {
69
69
  return initNetwork;
70
70
  }
71
71
  function stellarWalletsKitAdapters(options) {
72
+ if (typeof window === "undefined") return [];
72
73
  ensureInit(options);
73
74
  const modules = options.modules ?? buildDefaultModules();
74
75
  const wanted = options.picker?.wallets;
75
76
  return modules.filter((m) => !wanted || wanted.includes(m.productId)).map(
76
77
  (m) => new StellarWalletsKitAdapter(m.productId, {
77
78
  label: options.picker?.labels?.[m.productId] ?? m.productName,
78
- iconUrl: m.productIcon
79
+ iconUrl: m.productIcon,
80
+ group: options.picker?.groupLabel ?? "Wallet"
79
81
  })
80
82
  );
81
83
  }
@@ -137,6 +139,11 @@ var StellarWalletsKitAdapter = class {
137
139
  return { signedTxXdr: result.signedTxXdr };
138
140
  }
139
141
  async signAuthEntry(entryXdr, options) {
142
+ if (options?.networkPassphrase !== void 0 && options.networkPassphrase !== getInitNetwork()) {
143
+ throw new Error(
144
+ `[StellarWalletsKit] networkPassphrase override "${options.networkPassphrase}" does not match the network configured at init ("${getInitNetwork()}"). The kit is a global singleton \u2014 configure one network at \`stellarWalletsKit({ network })\` and use that for every call.`
145
+ );
146
+ }
140
147
  stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
141
148
  const result = await stellarWalletsKit.StellarWalletsKit.signAuthEntry(entryXdr, {
142
149
  ...options?.accountToSign !== void 0 && { address: options.accountToSign }