@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 +110 -114
- package/dist/index.d.mts +90 -4
- package/dist/index.d.ts +90 -4
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -30
- package/dist/factory-D5jFO9d8.d.mts +0 -83
- package/dist/factory-D5jFO9d8.d.ts +0 -83
- package/dist/picker.d.mts +0 -45
- package/dist/picker.d.ts +0 -45
- package/dist/picker.js +0 -280
- package/dist/picker.js.map +0 -1
- package/dist/picker.mjs +0 -277
- package/dist/picker.mjs.map +0 -1
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
|
|
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
|
|
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 {
|
|
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
|
-
|
|
24
|
+
walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
//
|
|
28
|
-
client.
|
|
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 {
|
|
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
|
-
|
|
41
|
+
walletAdapters: stellarWalletsKitAdapters({ network: Networks.TESTNET }),
|
|
42
42
|
}}
|
|
43
43
|
>
|
|
44
44
|
{/* your app */}
|
|
45
45
|
</PollarProvider>;
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>
|
|
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
|
-
>
|
|
61
|
-
> default
|
|
62
|
-
> picking testnet
|
|
63
|
-
>
|
|
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 `
|
|
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 {
|
|
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
|
-
|
|
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**
|
|
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
|
|
140
|
-
* `
|
|
141
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
165
|
-
type WalletAdapterResolver = (id: WalletId) => WalletAdapter | Promise<WalletAdapter>;
|
|
166
|
-
```
|
|
191
|
+
### SSR safety
|
|
167
192
|
|
|
168
|
-
`
|
|
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()` | `
|
|
177
|
-
| `connect()` | `setWallet(id)`
|
|
178
|
-
| `disconnect()` | `StellarWalletsKit.disconnect()`
|
|
179
|
-
| `getPublicKey()` | `StellarWalletsKit.getAddress()`
|
|
180
|
-
| `signTransaction(xdr, opts)` | `setWallet(id)`
|
|
181
|
-
| `signAuthEntry(xdr, opts)` | `setWallet(id)`
|
|
182
|
-
|
|
183
|
-
`setWallet` is called before every operation so a single
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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 {
|
|
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={{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
-
##
|
|
262
|
+
## Composing with other adapters
|
|
266
263
|
|
|
267
|
-
`
|
|
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 {
|
|
271
|
-
import {
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
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 `
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 }
|