@pollar/stellar-wallets-kit-adapter 0.10.0-rc.8 → 0.10.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 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,55 +16,59 @@ 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`.
59
63
  >
60
- > **0.8.0** — `network` is **required**. The previous `Networks.TESTNET`
61
- > default was removed because the kit is a global singleton, and silently
62
- > picking testnet for the consumer risked signing real-looking transactions
63
- > on the wrong chain. Pass `Networks.TESTNET` or `Networks.PUBLIC` explicitly.
64
+ > `connect()` resolves to `{ address }` only, and `network` is **required** (no
65
+ > `Networks.TESTNET` default) — the kit is a global singleton, so silently
66
+ > picking testnet risks signing real-looking transactions on the wrong chain.
67
+ > Pass `Networks.TESTNET` or `Networks.PUBLIC` explicitly.
64
68
 
65
69
  ## Default wallets
66
70
 
67
- Calling `stellarWalletsKit({ network })` with no `modules` argument enables every module that loads without extra configuration:
71
+ Calling `stellarWalletsKitAdapters({ network })` with no `modules` argument enables every module that loads without extra configuration (12 in total):
68
72
 
69
73
  | Module | Wallet id (`WalletId`) | Type |
70
74
  | ------------------ | ---------------------- | ------------------ |
@@ -88,7 +92,7 @@ Calling `stellarWalletsKit({ network })` with no `modules` argument enables ever
88
92
  Pass your own `modules` list. Import from the kit's per-wallet subpaths so unused modules tree-shake out:
89
93
 
90
94
  ```ts
91
- import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';
95
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
92
96
  import { Networks } from '@creit.tech/stellar-wallets-kit';
93
97
  import { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';
94
98
  import { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';
@@ -96,7 +100,7 @@ import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wal
96
100
 
97
101
  const client = new PollarClient({
98
102
  apiKey: 'your-api-key',
99
- walletAdapter: stellarWalletsKit({
103
+ walletAdapters: stellarWalletsKitAdapters({
100
104
  network: Networks.PUBLIC,
101
105
  modules: [
102
106
  new FreighterModule(),
@@ -122,7 +126,7 @@ Trimming the default list (e.g. only Freighter + Albedo for a SEP-43 dapp) works
122
126
  ```ts
123
127
  interface StellarWalletsKitAdapterOptions {
124
128
  /**
125
- * Stellar network used for signing. **Required** as of 0.8.0 — the kit is a
129
+ * Stellar network used for signing. **Required** — the kit is a
126
130
  * global singleton, so the network must be chosen explicitly to avoid
127
131
  * cross-chain signing accidents.
128
132
  */
@@ -136,11 +140,22 @@ interface StellarWalletsKitAdapterOptions {
136
140
  modules?: ModuleInterface[];
137
141
 
138
142
  /**
139
- * Picker-specific options. Only consumed by `<KitWalletPicker>` /
140
- * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver
141
- * itself ignores them.
143
+ * Picker-specific options: which kit wallets to include, label overrides, and
144
+ * the gateway group label. `wallets`, `labels`, and `groupLabel` are honored by
145
+ * `stellarWalletsKitAdapters()`; the remaining fields are consumed by the
146
+ * `/picker` subpath.
142
147
  */
143
148
  picker?: KitPickerOptions;
149
+
150
+ /**
151
+ * Minimum log severity. `'silent'` disables logging; otherwise
152
+ * `error` < `warn` < `info` < `debug`. Defaults to `'info'`. Set once at init
153
+ * since the kit is a global singleton.
154
+ */
155
+ logLevel?: LogLevel;
156
+
157
+ /** Sink for logs. Defaults to the global `console`. */
158
+ logger?: PollarLogger;
144
159
  }
145
160
 
146
161
  interface KitPickerOptions {
@@ -152,101 +167,82 @@ interface KitPickerOptions {
152
167
  showInstalledOnly?: boolean;
153
168
  /** Per-wallet label overrides. Key = wallet id. */
154
169
  labels?: Record<string, string>;
170
+ /**
171
+ * Label of the gateway button the kit wallets collapse behind in the login UI
172
+ * (applied as each adapter's `meta.group`). Default `'Wallet'` - the same group
173
+ * as the built-in Freighter/Albedo, so they share one gateway. Set a distinct
174
+ * value (e.g. `'More wallets'`) to render the kit wallets as a separate gateway.
175
+ */
176
+ groupLabel?: string;
155
177
  /** Visual layout. Default `'grid'`. */
156
178
  layout?: 'grid' | 'list';
157
- /** Theme passthrough — applied as CSS custom properties on the picker root. */
179
+ /** Theme passthrough - applied as CSS custom properties on the picker root. */
158
180
  theme?: { accent?: string; mode?: 'light' | 'dark' };
159
181
  }
160
182
  ```
161
183
 
162
- The factory returns a `WalletAdapterResolver` from `@pollar/core`:
184
+ `stellarWalletsKitAdapters()` returns `WalletAdapter[]` from `@pollar/core` - one
185
+ adapter per included kit module - which you assign to
186
+ `PollarClientConfig.walletAdapters`. Each adapter's `type` is the kit `WalletId`
187
+ (`WalletType | (string & {})`, so `WalletType.FREIGHTER` keeps autocomplete while
188
+ `'xbull'`, `'lobstr'`, ... are accepted as plain strings) and its `meta` carries
189
+ the module's label/icon for the auto-rendered login button.
163
190
 
164
- ```ts
165
- type WalletAdapterResolver = (id: WalletId) => WalletAdapter | Promise<WalletAdapter>;
166
- ```
191
+ ### SSR safety
167
192
 
168
- `WalletId` is `WalletType | (string & {})` — `WalletType.FREIGHTER` / `WalletType.ALBEDO` keep autocomplete, every other kit id (`'xbull'`, `'lobstr'`, …) is accepted as a plain string.
193
+ `stellarWalletsKitAdapters()` returns `[]` when `typeof window === 'undefined'`.
194
+ The kit talks to browser wallet extensions and touches `window` both at
195
+ `StellarWalletsKit.init()` and inside its module constructors, so there are no
196
+ wallets to build server-side. Under Next.js/Remix, construct your `PollarClient`
197
+ and render the wallet UI on the client (e.g. behind a mounted flag or
198
+ `dynamic(..., { ssr: false })`); the real adapters are built when the factory
199
+ re-runs in the browser.
169
200
 
170
201
  ## How it fits the Pollar wallet contract
171
202
 
172
203
  The adapter implements `WalletAdapter` from `@pollar/core`:
173
204
 
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:
205
+ | `WalletAdapter` method | Kit call |
206
+ | ---------------------------- | ---------------------------------------------------------------------- |
207
+ | `isAvailable()` | `refreshSupportedWallets()` then check the wallet's `isAvailable` flag |
208
+ | `connect()` | `setWallet(id)` > `fetchAddress()` |
209
+ | `disconnect()` | `StellarWalletsKit.disconnect()` |
210
+ | `getPublicKey()` | `StellarWalletsKit.getAddress()` |
211
+ | `signTransaction(xdr, opts)` | `setWallet(id)` > `signTransaction(xdr, opts)` |
212
+ | `signAuthEntry(xdr, opts)` | `setWallet(id)` > `signAuthEntry(xdr, opts)` |
213
+
214
+ `setWallet` is called before every signing/connect operation so a single
215
+ `StellarWalletsKit.init({ modules })` covers many wallets. `stellarWalletsKitAdapters()`
216
+ builds one `StellarWalletsKitAdapter` per module up front and returns the array;
217
+ each adapter is bound to its own `WalletId` and the kit routes to the correct
218
+ module under the hood.
219
+
220
+ ## Login UI
221
+
222
+ The wallets you register via `stellarWalletsKitAdapters({ network })` render
223
+ automatically inside Pollar's `LoginModal` — one button per wallet, collapsed
224
+ behind a single "Wallet" gateway button (their shared `meta.group`). Pass
225
+ `picker.groupLabel` to give them a distinct gateway, or `picker.labels` to
226
+ override individual button labels.
200
227
 
201
228
  ```tsx
202
229
  import { PollarProvider } from '@pollar/react';
203
- import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';
204
- import { Networks } from '@creit.tech/stellar-wallets-kit';
205
-
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
- <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';
230
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
227
231
  import { Networks } from '@creit.tech/stellar-wallets-kit';
228
232
 
229
233
  <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
- ),
234
+ client={{
235
+ apiKey: 'your-api-key',
236
+ walletAdapters: stellarWalletsKitAdapters({
237
+ network: Networks.PUBLIC,
238
+ picker: { wallets: ['xbull', 'lobstr', 'freighter'] },
239
+ }),
240
240
  }}
241
241
  >
242
- {children}
242
+ {/* your app */}
243
243
  </PollarProvider>;
244
244
  ```
245
245
 
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
246
  ## Direct adapter access
251
247
 
252
248
  If you need a `WalletAdapter` instance directly (custom flows outside `PollarClient`), instantiate it yourself once the kit is initialized:
@@ -258,33 +254,33 @@ import { StellarWalletsKitAdapter } from '@pollar/stellar-wallets-kit-adapter';
258
254
 
259
255
  StellarWalletsKit.init({ network: Networks.PUBLIC, modules: [new FreighterModule()] });
260
256
 
261
- const adapter = new StellarWalletsKitAdapter('freighter');
257
+ // The constructor requires a meta arg whose `label` is required.
258
+ const adapter = new StellarWalletsKitAdapter('freighter', { label: 'Freighter' });
262
259
  const { address } = await adapter.connect();
263
260
  ```
264
261
 
265
- ## Writing a custom resolver
262
+ ## Composing with other adapters
266
263
 
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:
264
+ `walletAdapters` is a plain `WalletAdapter[]`, so you can spread the kit adapters
265
+ alongside adapters from other packages (`@pollar/privy-adapter`, ...) or your own.
266
+ Entries later in the array override an earlier one that reuses the same `type`, and
267
+ each entry also overrides a built-in Freighter/Albedo with a matching `type`:
268
268
 
269
269
  ```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 });
270
+ import { PollarClient } from '@pollar/core';
271
+ import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
272
+ import { Networks } from '@creit.tech/stellar-wallets-kit';
273
+ import { MyCustomAdapter } from './my-custom-adapter';
274
274
 
275
275
  new PollarClient({
276
276
  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
- },
277
+ walletAdapters: [...stellarWalletsKitAdapters({ network: Networks.PUBLIC }), new MyCustomAdapter()],
282
278
  });
283
279
  ```
284
280
 
285
281
  ## Fallback behaviour
286
282
 
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.
283
+ 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
284
 
289
285
  ## License
290
286
 
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 }