@pollar/stellar-wallets-kit-adapter 0.9.0 → 0.10.0-rc.8
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/{factory-CR-sDzIv.d.mts → factory-D5jFO9d8.d.mts} +9 -8
- package/dist/{factory-CR-sDzIv.d.ts → factory-D5jFO9d8.d.ts} +9 -8
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +25 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/index.mjs.map +1 -1
- package/dist/picker.d.mts +5 -5
- package/dist/picker.d.ts +5 -5
- package/dist/picker.js +27 -20
- package/dist/picker.js.map +1 -1
- package/dist/picker.mjs +15 -8
- package/dist/picker.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
2
|
-
import { LogLevel, PollarLogger,
|
|
2
|
+
import { LogLevel, PollarLogger, WalletAdapter } from '@pollar/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
|
|
@@ -62,21 +62,22 @@ interface StellarWalletsKitAdapterOptions {
|
|
|
62
62
|
logger?: PollarLogger;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Build
|
|
66
|
-
*
|
|
67
|
-
* the
|
|
65
|
+
* Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one
|
|
66
|
+
* per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter
|
|
67
|
+
* carries the module's name/icon as its button `meta`. `picker.wallets` (subset)
|
|
68
|
+
* and `picker.labels` (overrides) are honored if provided.
|
|
68
69
|
*
|
|
69
70
|
* @example
|
|
70
71
|
* ```ts
|
|
71
|
-
* import {
|
|
72
|
+
* import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
|
|
72
73
|
* import { Networks } from '@creit.tech/stellar-wallets-kit';
|
|
73
74
|
*
|
|
74
75
|
* const client = new PollarClient({
|
|
75
76
|
* apiKey: '…',
|
|
76
|
-
*
|
|
77
|
+
* walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
|
|
77
78
|
* });
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
80
|
-
declare function
|
|
81
|
+
declare function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[];
|
|
81
82
|
|
|
82
|
-
export { type KitPickerOptions as K, type StellarWalletsKitAdapterOptions as S,
|
|
83
|
+
export { type KitPickerOptions as K, type StellarWalletsKitAdapterOptions as S, stellarWalletsKitAdapters as s };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
2
|
-
import { LogLevel, PollarLogger,
|
|
2
|
+
import { LogLevel, PollarLogger, WalletAdapter } from '@pollar/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
|
|
@@ -62,21 +62,22 @@ interface StellarWalletsKitAdapterOptions {
|
|
|
62
62
|
logger?: PollarLogger;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Build
|
|
66
|
-
*
|
|
67
|
-
* the
|
|
65
|
+
* Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one
|
|
66
|
+
* per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter
|
|
67
|
+
* carries the module's name/icon as its button `meta`. `picker.wallets` (subset)
|
|
68
|
+
* and `picker.labels` (overrides) are honored if provided.
|
|
68
69
|
*
|
|
69
70
|
* @example
|
|
70
71
|
* ```ts
|
|
71
|
-
* import {
|
|
72
|
+
* import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';
|
|
72
73
|
* import { Networks } from '@creit.tech/stellar-wallets-kit';
|
|
73
74
|
*
|
|
74
75
|
* const client = new PollarClient({
|
|
75
76
|
* apiKey: '…',
|
|
76
|
-
*
|
|
77
|
+
* walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),
|
|
77
78
|
* });
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
80
|
-
declare function
|
|
81
|
+
declare function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[];
|
|
81
82
|
|
|
82
|
-
export { type KitPickerOptions as K, type StellarWalletsKitAdapterOptions as S,
|
|
83
|
+
export { type KitPickerOptions as K, type StellarWalletsKitAdapterOptions as S, stellarWalletsKitAdapters as s };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WalletAdapter, WalletId, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
|
|
2
|
-
export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as
|
|
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
3
|
import '@creit.tech/stellar-wallets-kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,8 +10,10 @@ import '@creit.tech/stellar-wallets-kit';
|
|
|
10
10
|
*/
|
|
11
11
|
declare class StellarWalletsKitAdapter implements WalletAdapter {
|
|
12
12
|
readonly type: WalletId;
|
|
13
|
+
readonly meta: WalletAdapterMeta;
|
|
14
|
+
readonly custody: "external";
|
|
13
15
|
private _address;
|
|
14
|
-
constructor(walletId: WalletId);
|
|
16
|
+
constructor(walletId: WalletId, meta: WalletAdapterMeta);
|
|
15
17
|
isAvailable(): Promise<boolean>;
|
|
16
18
|
connect(): Promise<ConnectWalletResponse>;
|
|
17
19
|
disconnect(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WalletAdapter, WalletId, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
|
|
2
|
-
export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as
|
|
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
3
|
import '@creit.tech/stellar-wallets-kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,8 +10,10 @@ import '@creit.tech/stellar-wallets-kit';
|
|
|
10
10
|
*/
|
|
11
11
|
declare class StellarWalletsKitAdapter implements WalletAdapter {
|
|
12
12
|
readonly type: WalletId;
|
|
13
|
+
readonly meta: WalletAdapterMeta;
|
|
14
|
+
readonly custody: "external";
|
|
13
15
|
private _address;
|
|
14
|
-
constructor(walletId: WalletId);
|
|
16
|
+
constructor(walletId: WalletId, meta: WalletAdapterMeta);
|
|
15
17
|
isAvailable(): Promise<boolean>;
|
|
16
18
|
connect(): Promise<ConnectWalletResponse>;
|
|
17
19
|
disconnect(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var stellarWalletsKit
|
|
3
|
+
var stellarWalletsKit = require('@creit.tech/stellar-wallets-kit');
|
|
4
4
|
var albedo = require('@creit.tech/stellar-wallets-kit/modules/albedo');
|
|
5
5
|
var bitget = require('@creit.tech/stellar-wallets-kit/modules/bitget');
|
|
6
6
|
var cactuslink = require('@creit.tech/stellar-wallets-kit/modules/cactuslink');
|
|
@@ -55,7 +55,7 @@ function ensureInit(options) {
|
|
|
55
55
|
"[StellarWalletsKit] `network` is required \u2014 pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init."
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
stellarWalletsKit
|
|
58
|
+
stellarWalletsKit.StellarWalletsKit.init({
|
|
59
59
|
network: options.network,
|
|
60
60
|
modules: options.modules ?? buildDefaultModules()
|
|
61
61
|
});
|
|
@@ -68,22 +68,29 @@ function getInitNetwork() {
|
|
|
68
68
|
}
|
|
69
69
|
return initNetwork;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
function stellarWalletsKitAdapters(options) {
|
|
72
|
+
ensureInit(options);
|
|
73
|
+
const modules = options.modules ?? buildDefaultModules();
|
|
74
|
+
const wanted = options.picker?.wallets;
|
|
75
|
+
return modules.filter((m) => !wanted || wanted.includes(m.productId)).map(
|
|
76
|
+
(m) => new StellarWalletsKitAdapter(m.productId, {
|
|
77
|
+
label: options.picker?.labels?.[m.productId] ?? m.productName,
|
|
78
|
+
iconUrl: m.productIcon
|
|
79
|
+
})
|
|
80
|
+
);
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
// src/StellarWalletsKitAdapter.ts
|
|
79
84
|
var StellarWalletsKitAdapter = class {
|
|
80
|
-
constructor(walletId) {
|
|
85
|
+
constructor(walletId, meta) {
|
|
86
|
+
this.custody = "external";
|
|
81
87
|
this._address = null;
|
|
82
88
|
this.type = walletId;
|
|
89
|
+
this.meta = meta;
|
|
83
90
|
}
|
|
84
91
|
async isAvailable() {
|
|
85
92
|
try {
|
|
86
|
-
const supported = await stellarWalletsKit
|
|
93
|
+
const supported = await stellarWalletsKit.StellarWalletsKit.refreshSupportedWallets();
|
|
87
94
|
const wallet = supported.find((w) => w.id === String(this.type));
|
|
88
95
|
return wallet?.isAvailable ?? false;
|
|
89
96
|
} catch (err) {
|
|
@@ -92,8 +99,8 @@ var StellarWalletsKitAdapter = class {
|
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
async connect() {
|
|
95
|
-
stellarWalletsKit
|
|
96
|
-
const { address } = await stellarWalletsKit
|
|
102
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
103
|
+
const { address } = await stellarWalletsKit.StellarWalletsKit.fetchAddress();
|
|
97
104
|
if (!address) {
|
|
98
105
|
throw new Error(`[StellarWalletsKit] Empty address returned for wallet "${this.type}"`);
|
|
99
106
|
}
|
|
@@ -102,7 +109,7 @@ var StellarWalletsKitAdapter = class {
|
|
|
102
109
|
}
|
|
103
110
|
async disconnect() {
|
|
104
111
|
try {
|
|
105
|
-
await stellarWalletsKit
|
|
112
|
+
await stellarWalletsKit.StellarWalletsKit.disconnect();
|
|
106
113
|
} finally {
|
|
107
114
|
this._address = null;
|
|
108
115
|
}
|
|
@@ -110,7 +117,7 @@ var StellarWalletsKitAdapter = class {
|
|
|
110
117
|
async getPublicKey() {
|
|
111
118
|
if (this._address) return this._address;
|
|
112
119
|
try {
|
|
113
|
-
const { address } = await stellarWalletsKit
|
|
120
|
+
const { address } = await stellarWalletsKit.StellarWalletsKit.getAddress();
|
|
114
121
|
this._address = address ?? null;
|
|
115
122
|
return this._address;
|
|
116
123
|
} catch {
|
|
@@ -123,15 +130,15 @@ var StellarWalletsKitAdapter = class {
|
|
|
123
130
|
`[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.`
|
|
124
131
|
);
|
|
125
132
|
}
|
|
126
|
-
stellarWalletsKit
|
|
127
|
-
const result = await stellarWalletsKit
|
|
133
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
134
|
+
const result = await stellarWalletsKit.StellarWalletsKit.signTransaction(xdr, {
|
|
128
135
|
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
129
136
|
});
|
|
130
137
|
return { signedTxXdr: result.signedTxXdr };
|
|
131
138
|
}
|
|
132
139
|
async signAuthEntry(entryXdr, options) {
|
|
133
|
-
stellarWalletsKit
|
|
134
|
-
const result = await stellarWalletsKit
|
|
140
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
141
|
+
const result = await stellarWalletsKit.StellarWalletsKit.signAuthEntry(entryXdr, {
|
|
135
142
|
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
136
143
|
});
|
|
137
144
|
return { signedAuthEntry: result.signedAuthEntry };
|
|
@@ -139,6 +146,6 @@ var StellarWalletsKitAdapter = class {
|
|
|
139
146
|
};
|
|
140
147
|
|
|
141
148
|
exports.StellarWalletsKitAdapter = StellarWalletsKitAdapter;
|
|
142
|
-
exports.
|
|
149
|
+
exports.stellarWalletsKitAdapters = stellarWalletsKitAdapters;
|
|
143
150
|
//# sourceMappingURL=index.js.map
|
|
144
151
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["AlbedoModule","BitgetModule","CactusLinkModule","FordefiModule","FreighterModule","HanaModule","HotWalletModule","KleverModule","LobstrModule","OneKeyModule","RabetModule","xBullModule","createLogger","StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;;;;AA2EA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AACnC,IAAI,IAAA,GAAqB,OAAA;AAGlB,SAAS,YAAA,GAA6B;AAC3C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,GAAyC;AACvD,EAAA,OAAO;AAAA,IACL,IAAIA,mBAAA,EAAa;AAAA,IACjB,IAAIC,mBAAA,EAAa;AAAA,IACjB,IAAIC,2BAAA,EAAiB;AAAA,IACrB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AkB,OAAA,EAAgE;AACpG,IAAAA,qCAAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAA,GAAS,MAAMA,qCAAAA,CAAkB,aAAA,CAAc,QAAA,EAAU;AAAA,MAC7D,GAAI,OAAA,EAAS,aAAA,KAAkB,UAAa,EAAE,OAAA,EAAS,QAAQ,aAAA;AAAc,KAC9E,CAAA;AACD,IAAA,OAAO,EAAE,eAAA,EAAiB,MAAA,CAAO,eAAA,EAAgB;AAAA,EACnD;AACF","file":"index.js","sourcesContent":["import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapterResolver, type WalletId } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass\n * the result to `PollarClientConfig.walletAdapter` so Pollar can use any of\n * the kit's modules without `@pollar/core` having to depend on the kit.\n *\n * @example\n * ```ts\n * import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapter: stellarWalletsKit({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKit(options: StellarWalletsKitAdapterOptions): WalletAdapterResolver {\n return (id: WalletId) => {\n ensureInit(options);\n return new StellarWalletsKitAdapter(id);\n };\n}\n","import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n private _address: string | null = null;\n\n constructor(walletId: WalletId) {\n this.type = walletId;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["AlbedoModule","BitgetModule","CactusLinkModule","FordefiModule","FreighterModule","HanaModule","HotWalletModule","KleverModule","LobstrModule","OneKeyModule","RabetModule","xBullModule","createLogger","StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;;;;AA2EA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AACnC,IAAI,IAAA,GAAqB,OAAA;AAGlB,SAAS,YAAA,GAA6B;AA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EA,MAAM,eAAA,CAAgB,GAAA,EAAa,OAAA,EAAoE;AACrG,IAAA,IAAI,SAAS,iBAAA,KAAsB,MAAA,IAAa,OAAA,CAAQ,iBAAA,KAAsB,gBAAe,EAAG;AAC9F,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,gDAAA,EAAmD,OAAA,CAAQ,iBAAiB,CAAA,kDAAA,EAAqD,gBAAgB,CAAA,iIAAA;AAAA,OACnJ;AAAA,IACF;AACA,IAAAA,mCAAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAA,GAAS,MAAMA,mCAAAA,CAAkB,eAAA,CAAgB,GAAA,EAAK;AAAA,MAC1D,GAAI,OAAA,EAAS,aAAA,KAAkB,UAAa,EAAE,OAAA,EAAS,QAAQ,aAAA;AAAc,KAC9E,CAAA;AACD,IAAA,OAAO,EAAE,WAAA,EAAa,MAAA,CAAO,WAAA,EAAY;AAAA,EAC3C;AAAA,EAEA,MAAM,aAAA,CAAc,QAAA,EAAkB,OAAA,EAAgE;AACpG,IAAAA,mCAAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAA,GAAS,MAAMA,mCAAAA,CAAkB,aAAA,CAAc,QAAA,EAAU;AAAA,MAC7D,GAAI,OAAA,EAAS,aAAA,KAAkB,UAAa,EAAE,OAAA,EAAS,QAAQ,aAAA;AAAc,KAC9E,CAAA;AACD,IAAA,OAAO,EAAE,eAAA,EAAiB,MAAA,CAAO,eAAA,EAAgB;AAAA,EACnD;AACF","file":"index.js","sourcesContent":["import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapter } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one\n * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter\n * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)\n * and `picker.labels` (overrides) are honored if provided.\n *\n * @example\n * ```ts\n * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[] {\n ensureInit(options);\n const modules = options.modules ?? buildDefaultModules();\n const wanted = options.picker?.wallets;\n return modules\n .filter((m) => !wanted || wanted.includes(m.productId))\n .map(\n (m) =>\n new StellarWalletsKitAdapter(m.productId, {\n label: options.picker?.labels?.[m.productId] ?? m.productName,\n iconUrl: m.productIcon,\n }),\n );\n}\n","import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletAdapterMeta,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n readonly meta: WalletAdapterMeta;\n readonly custody = 'external' as const;\n private _address: string | null = null;\n\n constructor(walletId: WalletId, meta: WalletAdapterMeta) {\n this.type = walletId;\n this.meta = meta;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -66,18 +66,25 @@ function getInitNetwork() {
|
|
|
66
66
|
}
|
|
67
67
|
return initNetwork;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
function stellarWalletsKitAdapters(options) {
|
|
70
|
+
ensureInit(options);
|
|
71
|
+
const modules = options.modules ?? buildDefaultModules();
|
|
72
|
+
const wanted = options.picker?.wallets;
|
|
73
|
+
return modules.filter((m) => !wanted || wanted.includes(m.productId)).map(
|
|
74
|
+
(m) => new StellarWalletsKitAdapter(m.productId, {
|
|
75
|
+
label: options.picker?.labels?.[m.productId] ?? m.productName,
|
|
76
|
+
iconUrl: m.productIcon
|
|
77
|
+
})
|
|
78
|
+
);
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
// src/StellarWalletsKitAdapter.ts
|
|
77
82
|
var StellarWalletsKitAdapter = class {
|
|
78
|
-
constructor(walletId) {
|
|
83
|
+
constructor(walletId, meta) {
|
|
84
|
+
this.custody = "external";
|
|
79
85
|
this._address = null;
|
|
80
86
|
this.type = walletId;
|
|
87
|
+
this.meta = meta;
|
|
81
88
|
}
|
|
82
89
|
async isAvailable() {
|
|
83
90
|
try {
|
|
@@ -136,6 +143,6 @@ var StellarWalletsKitAdapter = class {
|
|
|
136
143
|
}
|
|
137
144
|
};
|
|
138
145
|
|
|
139
|
-
export { StellarWalletsKitAdapter,
|
|
146
|
+
export { StellarWalletsKitAdapter, stellarWalletsKitAdapters };
|
|
140
147
|
//# sourceMappingURL=index.mjs.map
|
|
141
148
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;;AA2EA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AACnC,IAAI,IAAA,GAAqB,OAAA;AAGlB,SAAS,YAAA,GAA6B;AAC3C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,GAAyC;AACvD,EAAA,OAAO;AAAA,IACL,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,gBAAA,EAAiB;AAAA,IACrB,IAAI,aAAA,EAAc;AAAA,IAClB,IAAI,eAAA,EAAgB;AAAA,IACpB,IAAI,UAAA,EAAW;AAAA,IACf,IAAI,eAAA,EAAgB;AAAA,IACpB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,WAAA,EAAY;AAAA,IAChB,IAAI,WAAA;AAAY,GAClB;AACF;AAUO,SAAS,WAAW,OAAA,EAAyD;AAClF,EAAA,IAAI,OAAA,CAAQ,QAAA,KAAa,MAAA,IAAa,OAAA,CAAQ,WAAW,MAAA,EAAW;AAClE,IAAA,I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ets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapterResolver, type WalletId } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass\n * the result to `PollarClientConfig.walletAdapter` so Pollar can use any of\n * the kit's modules without `@pollar/core` having to depend on the kit.\n *\n * @example\n * ```ts\n * import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapter: stellarWalletsKit({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKit(options: StellarWalletsKitAdapterOptions): WalletAdapterResolver {\n return (id: WalletId) => {\n ensureInit(options);\n return new StellarWalletsKitAdapter(id);\n };\n}\n","import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n private _address: string | null = null;\n\n constructor(walletId: WalletId) {\n this.type = walletId;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;;AA2EA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AACnC,IAAI,IAAA,GAAqB,OAAA;AAGlB,SAAS,YAAA,GAA6B;AAC3C,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,mBAAA,GAAyC;AACvD,EAAA,OAAO;AAAA,IACL,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,gBAAA,EAAiB;AAAA,IACrB,IAAI,aAAA,EAAc;AAAA,IAClB,IAAI,eAAA,EAAgB;AAAA,IACpB,IAAI,UAAA,EAAW;AAAA,IACf,IAAI,eAAA,EAAgB;AAAA,IACpB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,YAAA,EAAa;AAAA,IACjB,IAAI,WAAA,EAAY;AAAA,IAChB,IAAI,WAAA;AAAY,GAClB;AACF;AAUO,SAAS,WAAW,OAAA,EAAyD;AAClF,EAAA,IAAI,OAAA,CAAQ,QAAA,KAAa,MAAA,IAAa,OA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AO,EAAE,WAAA,EAAa,MAAA,CAAO,WAAA,EAAY;AAAA,EAC3C;AAAA,EAEA,MAAM,aAAA,CAAc,QAAA,EAAkB,OAAA,EAAgE;AACpG,IAAAA,iBAAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAA,GAAS,MAAMA,iBAAAA,CAAkB,aAAA,CAAc,QAAA,EAAU;AAAA,MAC7D,GAAI,OAAA,EAAS,aAAA,KAAkB,UAAa,EAAE,OAAA,EAAS,QAAQ,aAAA;AAAc,KAC9E,CAAA;AACD,IAAA,OAAO,EAAE,eAAA,EAAiB,MAAA,CAAO,eAAA,EAAgB;AAAA,EACnD;AACF","file":"index.mjs","sourcesContent":["import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapter } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one\n * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter\n * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)\n * and `picker.labels` (overrides) are honored if provided.\n *\n * @example\n * ```ts\n * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[] {\n ensureInit(options);\n const modules = options.modules ?? buildDefaultModules();\n const wanted = options.picker?.wallets;\n return modules\n .filter((m) => !wanted || wanted.includes(m.productId))\n .map(\n (m) =>\n new StellarWalletsKitAdapter(m.productId, {\n label: options.picker?.labels?.[m.productId] ?? m.productName,\n iconUrl: m.productIcon,\n }),\n );\n}\n","import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletAdapterMeta,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n readonly meta: WalletAdapterMeta;\n readonly custody = 'external' as const;\n private _address: string | null = null;\n\n constructor(walletId: WalletId, meta: WalletAdapterMeta) {\n this.type = walletId;\n this.meta = meta;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n"]}
|
package/dist/picker.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
3
3
|
import { RenderWalletsProps, RenderWalletsSlot } from '@pollar/react';
|
|
4
|
-
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-
|
|
5
|
-
import {
|
|
4
|
+
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-D5jFO9d8.mjs';
|
|
5
|
+
import { WalletAdapter } from '@pollar/core';
|
|
6
6
|
|
|
7
7
|
interface KitWalletPickerProps extends RenderWalletsProps {
|
|
8
8
|
network?: Networks;
|
|
@@ -12,8 +12,8 @@ interface KitWalletPickerProps extends RenderWalletsProps {
|
|
|
12
12
|
declare function KitWalletPicker({ onConnect, authState, network, modules, picker }: KitWalletPickerProps): react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
14
14
|
interface StellarWalletsKitBundle {
|
|
15
|
-
/** Pass to `PollarClientConfig.
|
|
16
|
-
|
|
15
|
+
/** Pass to `PollarClientConfig.walletAdapters`. */
|
|
16
|
+
walletAdapters: WalletAdapter[];
|
|
17
17
|
/** Pass to `<PollarProvider ui={{ renderWallets }}>`. */
|
|
18
18
|
renderWallets: RenderWalletsSlot;
|
|
19
19
|
}
|
|
@@ -35,7 +35,7 @@ interface StellarWalletsKitBundle {
|
|
|
35
35
|
* });
|
|
36
36
|
*
|
|
37
37
|
* <PollarProvider
|
|
38
|
-
* client={{ apiKey: '…',
|
|
38
|
+
* client={{ apiKey: '…', walletAdapters: bundle.walletAdapters }}
|
|
39
39
|
* ui={{ renderWallets: bundle.renderWallets }}
|
|
40
40
|
* />
|
|
41
41
|
* ```
|
package/dist/picker.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
3
3
|
import { RenderWalletsProps, RenderWalletsSlot } from '@pollar/react';
|
|
4
|
-
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-
|
|
5
|
-
import {
|
|
4
|
+
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-D5jFO9d8.js';
|
|
5
|
+
import { WalletAdapter } from '@pollar/core';
|
|
6
6
|
|
|
7
7
|
interface KitWalletPickerProps extends RenderWalletsProps {
|
|
8
8
|
network?: Networks;
|
|
@@ -12,8 +12,8 @@ interface KitWalletPickerProps extends RenderWalletsProps {
|
|
|
12
12
|
declare function KitWalletPicker({ onConnect, authState, network, modules, picker }: KitWalletPickerProps): react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
14
14
|
interface StellarWalletsKitBundle {
|
|
15
|
-
/** Pass to `PollarClientConfig.
|
|
16
|
-
|
|
15
|
+
/** Pass to `PollarClientConfig.walletAdapters`. */
|
|
16
|
+
walletAdapters: WalletAdapter[];
|
|
17
17
|
/** Pass to `<PollarProvider ui={{ renderWallets }}>`. */
|
|
18
18
|
renderWallets: RenderWalletsSlot;
|
|
19
19
|
}
|
|
@@ -35,7 +35,7 @@ interface StellarWalletsKitBundle {
|
|
|
35
35
|
* });
|
|
36
36
|
*
|
|
37
37
|
* <PollarProvider
|
|
38
|
-
* client={{ apiKey: '…',
|
|
38
|
+
* client={{ apiKey: '…', walletAdapters: bundle.walletAdapters }}
|
|
39
39
|
* ui={{ renderWallets: bundle.renderWallets }}
|
|
40
40
|
* />
|
|
41
41
|
* ```
|
package/dist/picker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var stellarWalletsKit
|
|
3
|
+
var stellarWalletsKit = require('@creit.tech/stellar-wallets-kit');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var albedo = require('@creit.tech/stellar-wallets-kit/modules/albedo');
|
|
6
6
|
var bitget = require('@creit.tech/stellar-wallets-kit/modules/bitget');
|
|
@@ -19,13 +19,15 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
19
19
|
|
|
20
20
|
// src/picker/KitWalletPicker.tsx
|
|
21
21
|
var StellarWalletsKitAdapter = class {
|
|
22
|
-
constructor(walletId) {
|
|
22
|
+
constructor(walletId, meta) {
|
|
23
|
+
this.custody = "external";
|
|
23
24
|
this._address = null;
|
|
24
25
|
this.type = walletId;
|
|
26
|
+
this.meta = meta;
|
|
25
27
|
}
|
|
26
28
|
async isAvailable() {
|
|
27
29
|
try {
|
|
28
|
-
const supported = await stellarWalletsKit
|
|
30
|
+
const supported = await stellarWalletsKit.StellarWalletsKit.refreshSupportedWallets();
|
|
29
31
|
const wallet = supported.find((w) => w.id === String(this.type));
|
|
30
32
|
return wallet?.isAvailable ?? false;
|
|
31
33
|
} catch (err) {
|
|
@@ -34,8 +36,8 @@ var StellarWalletsKitAdapter = class {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
async connect() {
|
|
37
|
-
stellarWalletsKit
|
|
38
|
-
const { address } = await stellarWalletsKit
|
|
39
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
40
|
+
const { address } = await stellarWalletsKit.StellarWalletsKit.fetchAddress();
|
|
39
41
|
if (!address) {
|
|
40
42
|
throw new Error(`[StellarWalletsKit] Empty address returned for wallet "${this.type}"`);
|
|
41
43
|
}
|
|
@@ -44,7 +46,7 @@ var StellarWalletsKitAdapter = class {
|
|
|
44
46
|
}
|
|
45
47
|
async disconnect() {
|
|
46
48
|
try {
|
|
47
|
-
await stellarWalletsKit
|
|
49
|
+
await stellarWalletsKit.StellarWalletsKit.disconnect();
|
|
48
50
|
} finally {
|
|
49
51
|
this._address = null;
|
|
50
52
|
}
|
|
@@ -52,7 +54,7 @@ var StellarWalletsKitAdapter = class {
|
|
|
52
54
|
async getPublicKey() {
|
|
53
55
|
if (this._address) return this._address;
|
|
54
56
|
try {
|
|
55
|
-
const { address } = await stellarWalletsKit
|
|
57
|
+
const { address } = await stellarWalletsKit.StellarWalletsKit.getAddress();
|
|
56
58
|
this._address = address ?? null;
|
|
57
59
|
return this._address;
|
|
58
60
|
} catch {
|
|
@@ -65,15 +67,15 @@ var StellarWalletsKitAdapter = class {
|
|
|
65
67
|
`[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.`
|
|
66
68
|
);
|
|
67
69
|
}
|
|
68
|
-
stellarWalletsKit
|
|
69
|
-
const result = await stellarWalletsKit
|
|
70
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
71
|
+
const result = await stellarWalletsKit.StellarWalletsKit.signTransaction(xdr, {
|
|
70
72
|
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
71
73
|
});
|
|
72
74
|
return { signedTxXdr: result.signedTxXdr };
|
|
73
75
|
}
|
|
74
76
|
async signAuthEntry(entryXdr, options) {
|
|
75
|
-
stellarWalletsKit
|
|
76
|
-
const result = await stellarWalletsKit
|
|
77
|
+
stellarWalletsKit.StellarWalletsKit.setWallet(String(this.type));
|
|
78
|
+
const result = await stellarWalletsKit.StellarWalletsKit.signAuthEntry(entryXdr, {
|
|
77
79
|
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
78
80
|
});
|
|
79
81
|
return { signedAuthEntry: result.signedAuthEntry };
|
|
@@ -120,7 +122,7 @@ function ensureInit(options) {
|
|
|
120
122
|
"[StellarWalletsKit] `network` is required \u2014 pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init."
|
|
121
123
|
);
|
|
122
124
|
}
|
|
123
|
-
stellarWalletsKit
|
|
125
|
+
stellarWalletsKit.StellarWalletsKit.init({
|
|
124
126
|
network: options.network,
|
|
125
127
|
modules: options.modules ?? buildDefaultModules()
|
|
126
128
|
});
|
|
@@ -133,11 +135,16 @@ function getInitNetwork() {
|
|
|
133
135
|
}
|
|
134
136
|
return initNetwork;
|
|
135
137
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
function stellarWalletsKitAdapters(options) {
|
|
139
|
+
ensureInit(options);
|
|
140
|
+
const modules = options.modules ?? buildDefaultModules();
|
|
141
|
+
const wanted = options.picker?.wallets;
|
|
142
|
+
return modules.filter((m) => !wanted || wanted.includes(m.productId)).map(
|
|
143
|
+
(m) => new StellarWalletsKitAdapter(m.productId, {
|
|
144
|
+
label: options.picker?.labels?.[m.productId] ?? m.productName,
|
|
145
|
+
iconUrl: m.productIcon
|
|
146
|
+
})
|
|
147
|
+
);
|
|
141
148
|
}
|
|
142
149
|
var CONNECTING_STEPS = /* @__PURE__ */ new Set(["connecting_wallet", "authenticating_wallet", "authenticating"]);
|
|
143
150
|
function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }) {
|
|
@@ -149,7 +156,7 @@ function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }
|
|
|
149
156
|
if (network !== void 0) initOpts.network = network;
|
|
150
157
|
if (modules !== void 0) initOpts.modules = modules;
|
|
151
158
|
ensureInit(initOpts);
|
|
152
|
-
stellarWalletsKit
|
|
159
|
+
stellarWalletsKit.StellarWalletsKit.refreshSupportedWallets().then((list) => {
|
|
153
160
|
if (cancelled) return;
|
|
154
161
|
setWallets(list);
|
|
155
162
|
}).catch((err) => {
|
|
@@ -253,7 +260,7 @@ function buttonStyle(layout, disabled) {
|
|
|
253
260
|
return { ...base, flexDirection: "column", justifyContent: "center", textAlign: "center", minHeight: 92 };
|
|
254
261
|
}
|
|
255
262
|
function createStellarWalletsKitBundle(options) {
|
|
256
|
-
const
|
|
263
|
+
const walletAdapters = stellarWalletsKitAdapters(options);
|
|
257
264
|
const renderWallets = (slot) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
258
265
|
KitWalletPicker,
|
|
259
266
|
{
|
|
@@ -264,7 +271,7 @@ function createStellarWalletsKitBundle(options) {
|
|
|
264
271
|
...options.picker !== void 0 && { picker: options.picker }
|
|
265
272
|
}
|
|
266
273
|
);
|
|
267
|
-
return {
|
|
274
|
+
return { walletAdapters, renderWallets };
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
exports.KitWalletPicker = KitWalletPicker;
|
package/dist/picker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/StellarWalletsKitAdapter.ts","../src/factory.ts","../src/picker/KitWalletPicker.tsx","../src/picker/bundle.tsx"],"names":["StellarWalletsKit","AlbedoModule","BitgetModule","CactusLinkModule","FordefiModule","FreighterModule","HanaModule","HotWalletModule","KleverModule","LobstrModule","OneKeyModule","RabetModule","xBullModule","createLogger","useState","useRef","useEffect","useMemo","jsx","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,2BAAN,MAAwD;AAAA,EAI7D,YAAY,QAAA,EAAoB;AAFhC,IAAA,IAAA,CAAQ,QAAA,GAA0B,IAAA;AAGhC,IAAA,IAAA,CAAK,IAAA,GAAO,QAAA;AAAA,EACd;AAAA,EAEA,MAAM,WAAA,GAAgC;AAMpC,IAAA,IAAI;AACF,MAAA,MAAM,SAAA,GAAY,MAAMA,qCAAA,CAAkB,uBAAA,EAAwB;AAClE,MAAA,MAAM,MAAA,GAAS,SAAA,CAAU,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC/D,MAAA,OAAO,QAAQ,WAAA,IAAe,KAAA;AAAA,IAChC,SAAS,GAAA,EAAK;AACZ,MAAA,YAAA,GAAe,IAAA,CAAK,CAAA,kDAAA,EAAqD,IAAA,CAAK,IAAI,KAAK,GAAG,CAAA;AAC1F,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF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AU,SAAA,EAAW,QAAA,EAAU,SAAA,EAAW,EAAA,EAAG;AAC1G;ACzHO,SAAS,8BAA8B,OAAA,EAAmE;AAC/G,EAAA,MAAM,aAAA,GAAgB,kBAAkB,OAAO,CAAA;AAC/C,EAAA,MAAM,aAAA,GAAmC,CAAC,IAAA,qBACxCA,cAAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,SAAS,OAAA,CAAQ,OAAA;AAAA,MAChB,GAAI,OAAA,CAAQ,OAAA,KAAY,UAAa,EAAE,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAAA,MAChE,GAAI,OAAA,CAAQ,MAAA,KAAW,UAAa,EAAE,MAAA,EAAQ,QAAQ,MAAA;AAAO;AAAA,GAChE;AAEF,EAAA,OAAO,EAAE,eAAe,aAAA,EAAc;AACxC","file":"picker.js","sourcesContent":["import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n private _address: string | null = null;\n\n constructor(walletId: WalletId) {\n this.type = walletId;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n","import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapterResolver, type WalletId } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass\n * the result to `PollarClientConfig.walletAdapter` so Pollar can use any of\n * the kit's modules without `@pollar/core` having to depend on the kit.\n *\n * @example\n * ```ts\n * import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapter: stellarWalletsKit({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKit(options: StellarWalletsKitAdapterOptions): WalletAdapterResolver {\n return (id: WalletId) => {\n ensureInit(options);\n return new StellarWalletsKitAdapter(id);\n };\n}\n","'use client';\n\nimport { type ISupportedWallet, type ModuleInterface, type Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type { RenderWalletsProps } from '@pollar/react';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { ensureInit, getKitLogger, type KitPickerOptions } from '../factory';\n\nexport interface KitWalletPickerProps extends RenderWalletsProps {\n network?: Networks;\n modules?: ModuleInterface[];\n picker?: KitPickerOptions;\n}\n\nconst CONNECTING_STEPS = new Set(['connecting_wallet', 'authenticating_wallet', 'authenticating']);\n\nexport function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }: KitWalletPickerProps) {\n const [wallets, setWallets] = useState<ISupportedWallet[] | null>(null);\n const warnedRef = useRef<Set<string>>(new Set());\n\n useEffect(() => {\n let cancelled = false;\n const initOpts: { network?: Networks; modules?: ModuleInterface[] } = {};\n if (network !== undefined) initOpts.network = network;\n if (modules !== undefined) initOpts.modules = modules;\n ensureInit(initOpts);\n StellarWalletsKit.refreshSupportedWallets()\n .then((list) => {\n if (cancelled) return;\n setWallets(list);\n })\n .catch((err) => {\n getKitLogger().error('[KitWalletPicker] refreshSupportedWallets failed', err);\n if (!cancelled) setWallets([]);\n });\n return () => {\n cancelled = true;\n };\n }, [network, modules]);\n\n const filtered = useMemo(() => {\n if (!wallets) return null;\n const { wallets: allowedIds, order = 'as-given', showInstalledOnly = false, labels } = picker;\n\n const byId = new Map(wallets.map((w) => [w.id, w]));\n let result: ISupportedWallet[];\n\n if (allowedIds && allowedIds.length > 0) {\n // Build the base list in `allowedIds` order; warn once per unknown id.\n // A later `order` setting may re-sort this list.\n result = [];\n for (const id of allowedIds) {\n const w = byId.get(id);\n if (w) {\n result.push(w);\n } else if (!warnedRef.current.has(id)) {\n warnedRef.current.add(id);\n getKitLogger().warn(`[KitWalletPicker] wallet id \"${id}\" not present in the active kit modules — skipped`);\n }\n }\n } else {\n result = [...wallets];\n }\n\n if (showInstalledOnly) {\n result = result.filter((w) => w.isAvailable);\n }\n\n if (order === 'alphabetical') {\n result = [...result].sort((a, b) => labelOf(a, labels).localeCompare(labelOf(b, labels)));\n } else if (order === 'installed-first') {\n result = [...result].sort((a, b) => {\n if (a.isAvailable === b.isAvailable) return 0;\n return a.isAvailable ? -1 : 1;\n });\n }\n // 'as-given' keeps whatever order we built above.\n\n return result;\n }, [wallets, picker]);\n\n const isBusy = CONNECTING_STEPS.has(authState.step);\n const layout = picker.layout ?? 'grid';\n const theme = picker.theme;\n const rootStyle: CSSProperties = {\n display: layout === 'list' ? 'flex' : 'grid',\n flexDirection: layout === 'list' ? 'column' : undefined,\n gridTemplateColumns: layout === 'grid' ? 'repeat(auto-fill, minmax(140px, 1fr))' : undefined,\n gap: '0.5rem',\n width: '100%',\n ...(theme?.accent !== undefined && { ['--pollar-accent' as never]: theme.accent }),\n ...(theme?.mode === 'dark' && { colorScheme: 'dark' as const }),\n };\n\n // Still loading the wallet list.\n if (filtered === null) {\n return (\n <div role=\"status\" aria-busy=\"true\" style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n Loading wallets…\n </div>\n );\n }\n\n // Empty state: showInstalledOnly hid every wallet, or the filter list is empty.\n if (filtered.length === 0) {\n return (\n <div style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n {picker.showInstalledOnly\n ? 'No supported Stellar wallets detected. Install Freighter / xBull / Lobstr to continue.'\n : 'No wallets to show.'}\n </div>\n );\n }\n\n return (\n <div style={rootStyle}>\n {filtered.map((w) => {\n const label = labelOf(w, picker.labels);\n const disabled = isBusy || (picker.showInstalledOnly ? false : !w.isAvailable);\n return (\n <button\n key={w.id}\n type=\"button\"\n disabled={disabled}\n onClick={() => onConnect(w.id)}\n style={buttonStyle(layout, disabled)}\n title={!w.isAvailable && !picker.showInstalledOnly ? `${label} not detected` : label}\n >\n <img src={w.icon} alt=\"\" width={32} height={32} style={{ borderRadius: 6, opacity: w.isAvailable ? 1 : 0.5 }} />\n <span style={{ fontSize: '0.85rem', fontWeight: 500 }}>{label}</span>\n {!w.isAvailable && <span style={{ fontSize: '0.7rem', opacity: 0.6 }}>not installed</span>}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction labelOf(w: ISupportedWallet, labels: Record<string, string> | undefined): string {\n return labels?.[w.id] ?? w.name;\n}\n\nfunction buttonStyle(layout: 'grid' | 'list', disabled: boolean): CSSProperties {\n const base: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.55 : 1,\n background: 'transparent',\n border: '1px solid var(--pollar-border, #e5e7eb)',\n borderRadius: 'var(--pollar-buttons-border-radius, 6px)',\n color: 'var(--pollar-text, inherit)',\n padding: '0.6rem',\n gap: '0.6rem',\n };\n if (layout === 'list') {\n return { ...base, justifyContent: 'flex-start', width: '100%', height: 'var(--pollar-buttons-height, 44px)' };\n }\n return { ...base, flexDirection: 'column', justifyContent: 'center', textAlign: 'center', minHeight: 92 };\n}\n","'use client';\n\nimport type { WalletAdapterResolver } from '@pollar/core';\nimport type { RenderWalletsSlot } from '@pollar/react';\nimport { stellarWalletsKit, type StellarWalletsKitAdapterOptions } from '../factory';\nimport { KitWalletPicker } from './KitWalletPicker';\n\nexport interface StellarWalletsKitBundle {\n /** Pass to `PollarClientConfig.walletAdapter`. */\n walletAdapter: WalletAdapterResolver;\n /** Pass to `<PollarProvider ui={{ renderWallets }}>`. */\n renderWallets: RenderWalletsSlot;\n}\n\n/**\n * One-shot helper that builds both halves of the integration from a single\n * options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)\n * and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same\n * `network` / `modules` / `picker` opts power both, so the picker shows the\n * exact wallets that signing will actually work with.\n *\n * @example\n * ```tsx\n * import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const bundle = createStellarWalletsKitBundle({\n * network: Networks.PUBLIC,\n * picker: { wallets: ['xbull', 'lobstr', 'freighter'] },\n * });\n *\n * <PollarProvider\n * client={{ apiKey: '…', walletAdapter: bundle.walletAdapter }}\n * ui={{ renderWallets: bundle.renderWallets }}\n * />\n * ```\n */\nexport function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle {\n const walletAdapter = stellarWalletsKit(options);\n const renderWallets: RenderWalletsSlot = (slot) => (\n <KitWalletPicker\n onConnect={slot.onConnect}\n authState={slot.authState}\n network={options.network}\n {...(options.modules !== undefined && { modules: options.modules })}\n {...(options.picker !== undefined && { picker: options.picker })}\n />\n );\n return { walletAdapter, renderWallets };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/StellarWalletsKitAdapter.ts","../src/factory.ts","../src/picker/KitWalletPicker.tsx","../src/picker/bundle.tsx"],"names":["StellarWalletsKit","AlbedoModule","BitgetModule","CactusLinkModule","FordefiModule","FreighterModule","HanaModule","HotWalletModule","KleverModule","LobstrModule","OneKeyModule","RabetModule","xBullModule","createLogger","useState","useRef","useEffect","useMemo","jsx","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBO,IAAM,2BAAN,MAAwD;AAAA,EAM7D,WAAA,CAAY,UAAoB,IAAA,EAAyB;AAHzD,IAAA,IAAA,CAAS,OAAA,GAAU,UAAA;AACnB,IAAA,IAAA,CAAQ,QAAA,GAA0B,IAAA;AAGhC,IAAA,IAAA,CAAK,IAAA,GAAO,QAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AAAA,EAEA,MAAM,WAAA,GAAgC;AAMpC,IAAA,IAAI;AACF,MAAA,MAAM,SAAA,GAAY,MAAMA,mCAAA,CAAkB,uBAAA,EAAwB;AAClE,MAAA,MAAM,MAAA,GAAS,SAAA,CAAU,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC/D,MAAA,OAAO,QAAQ,WAAA,IAAe,KAAA;AAAA,IAChC,SAAS,GAAA,EAAK;AACZ,MAAA,YAAA,GAAe,IAAA,CAAK,CAAA,kDAAA,EAAqD,IAAA,CAAK,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EAAS,WAAW,IAAA,GAAO,CAAA;AAAA,IAC3B,UAAA,EAAY,aAAA;AAAA,IACZ,MAAA,EAAQ,yCAAA;AAAA,IACR,YAAA,EAAc,0CAAA;AAAA,IACd,KAAA,EAAO,6BAAA;AAAA,IACP,OAAA,EAAS,QAAA;AAAA,IACT,GAAA,EAAK;AAAA,GACP;AACA,EAAA,IAAI,WAAW,MAAA,EAAQ;AACrB,IAAA,OAAO,EAAE,GAAG,IAAA,EAAM,cAAA,EAAgB,cAAc,KAAA,EAAO,MAAA,EAAQ,QAAQ,oCAAA,EAAqC;AAAA,EAC9G;AACA,EAAA,OAAO,EAAE,GAAG,IAAA,EAAM,aAAA,EAAe,QAAA,EAAU,gBAAgB,QAAA,EAAU,SAAA,EAAW,QAAA,EAAU,SAAA,EAAW,EAAA,EAAG;AAC1G;ACzHO,SAAS,8BAA8B,OAAA,EAAmE;AAC/G,EAAA,MAAM,cAAA,GAAiB,0BAA0B,OAAO,CAAA;AACxD,EAAA,MAAM,aAAA,GAAmC,CAAC,IAAA,qBACxCA,cAAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,SAAS,OAAA,CAAQ,OAAA;AAAA,MAChB,GAAI,OAAA,CAAQ,OAAA,KAAY,UAAa,EAAE,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAAA,MAChE,GAAI,OAAA,CAAQ,MAAA,KAAW,UAAa,EAAE,MAAA,EAAQ,QAAQ,MAAA;AAAO;AAAA,GAChE;AAEF,EAAA,OAAO,EAAE,gBAAgB,aAAA,EAAc;AACzC","file":"picker.js","sourcesContent":["import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletAdapterMeta,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n readonly meta: WalletAdapterMeta;\n readonly custody = 'external' as const;\n private _address: string | null = null;\n\n constructor(walletId: WalletId, meta: WalletAdapterMeta) {\n this.type = walletId;\n this.meta = meta;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n","import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapter } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one\n * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter\n * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)\n * and `picker.labels` (overrides) are honored if provided.\n *\n * @example\n * ```ts\n * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[] {\n ensureInit(options);\n const modules = options.modules ?? buildDefaultModules();\n const wanted = options.picker?.wallets;\n return modules\n .filter((m) => !wanted || wanted.includes(m.productId))\n .map(\n (m) =>\n new StellarWalletsKitAdapter(m.productId, {\n label: options.picker?.labels?.[m.productId] ?? m.productName,\n iconUrl: m.productIcon,\n }),\n );\n}\n","'use client';\n\nimport { type ISupportedWallet, type ModuleInterface, type Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type { RenderWalletsProps } from '@pollar/react';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { ensureInit, getKitLogger, type KitPickerOptions } from '../factory';\n\nexport interface KitWalletPickerProps extends RenderWalletsProps {\n network?: Networks;\n modules?: ModuleInterface[];\n picker?: KitPickerOptions;\n}\n\nconst CONNECTING_STEPS = new Set(['connecting_wallet', 'authenticating_wallet', 'authenticating']);\n\nexport function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }: KitWalletPickerProps) {\n const [wallets, setWallets] = useState<ISupportedWallet[] | null>(null);\n const warnedRef = useRef<Set<string>>(new Set());\n\n useEffect(() => {\n let cancelled = false;\n const initOpts: { network?: Networks; modules?: ModuleInterface[] } = {};\n if (network !== undefined) initOpts.network = network;\n if (modules !== undefined) initOpts.modules = modules;\n ensureInit(initOpts);\n StellarWalletsKit.refreshSupportedWallets()\n .then((list) => {\n if (cancelled) return;\n setWallets(list);\n })\n .catch((err) => {\n getKitLogger().error('[KitWalletPicker] refreshSupportedWallets failed', err);\n if (!cancelled) setWallets([]);\n });\n return () => {\n cancelled = true;\n };\n }, [network, modules]);\n\n const filtered = useMemo(() => {\n if (!wallets) return null;\n const { wallets: allowedIds, order = 'as-given', showInstalledOnly = false, labels } = picker;\n\n const byId = new Map(wallets.map((w) => [w.id, w]));\n let result: ISupportedWallet[];\n\n if (allowedIds && allowedIds.length > 0) {\n // Build the base list in `allowedIds` order; warn once per unknown id.\n // A later `order` setting may re-sort this list.\n result = [];\n for (const id of allowedIds) {\n const w = byId.get(id);\n if (w) {\n result.push(w);\n } else if (!warnedRef.current.has(id)) {\n warnedRef.current.add(id);\n getKitLogger().warn(`[KitWalletPicker] wallet id \"${id}\" not present in the active kit modules — skipped`);\n }\n }\n } else {\n result = [...wallets];\n }\n\n if (showInstalledOnly) {\n result = result.filter((w) => w.isAvailable);\n }\n\n if (order === 'alphabetical') {\n result = [...result].sort((a, b) => labelOf(a, labels).localeCompare(labelOf(b, labels)));\n } else if (order === 'installed-first') {\n result = [...result].sort((a, b) => {\n if (a.isAvailable === b.isAvailable) return 0;\n return a.isAvailable ? -1 : 1;\n });\n }\n // 'as-given' keeps whatever order we built above.\n\n return result;\n }, [wallets, picker]);\n\n const isBusy = CONNECTING_STEPS.has(authState.step);\n const layout = picker.layout ?? 'grid';\n const theme = picker.theme;\n const rootStyle: CSSProperties = {\n display: layout === 'list' ? 'flex' : 'grid',\n flexDirection: layout === 'list' ? 'column' : undefined,\n gridTemplateColumns: layout === 'grid' ? 'repeat(auto-fill, minmax(140px, 1fr))' : undefined,\n gap: '0.5rem',\n width: '100%',\n ...(theme?.accent !== undefined && { ['--pollar-accent' as never]: theme.accent }),\n ...(theme?.mode === 'dark' && { colorScheme: 'dark' as const }),\n };\n\n // Still loading the wallet list.\n if (filtered === null) {\n return (\n <div role=\"status\" aria-busy=\"true\" style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n Loading wallets…\n </div>\n );\n }\n\n // Empty state: showInstalledOnly hid every wallet, or the filter list is empty.\n if (filtered.length === 0) {\n return (\n <div style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n {picker.showInstalledOnly\n ? 'No supported Stellar wallets detected. Install Freighter / xBull / Lobstr to continue.'\n : 'No wallets to show.'}\n </div>\n );\n }\n\n return (\n <div style={rootStyle}>\n {filtered.map((w) => {\n const label = labelOf(w, picker.labels);\n const disabled = isBusy || (picker.showInstalledOnly ? false : !w.isAvailable);\n return (\n <button\n key={w.id}\n type=\"button\"\n disabled={disabled}\n onClick={() => onConnect(w.id)}\n style={buttonStyle(layout, disabled)}\n title={!w.isAvailable && !picker.showInstalledOnly ? `${label} not detected` : label}\n >\n <img src={w.icon} alt=\"\" width={32} height={32} style={{ borderRadius: 6, opacity: w.isAvailable ? 1 : 0.5 }} />\n <span style={{ fontSize: '0.85rem', fontWeight: 500 }}>{label}</span>\n {!w.isAvailable && <span style={{ fontSize: '0.7rem', opacity: 0.6 }}>not installed</span>}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction labelOf(w: ISupportedWallet, labels: Record<string, string> | undefined): string {\n return labels?.[w.id] ?? w.name;\n}\n\nfunction buttonStyle(layout: 'grid' | 'list', disabled: boolean): CSSProperties {\n const base: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.55 : 1,\n background: 'transparent',\n border: '1px solid var(--pollar-border, #e5e7eb)',\n borderRadius: 'var(--pollar-buttons-border-radius, 6px)',\n color: 'var(--pollar-text, inherit)',\n padding: '0.6rem',\n gap: '0.6rem',\n };\n if (layout === 'list') {\n return { ...base, justifyContent: 'flex-start', width: '100%', height: 'var(--pollar-buttons-height, 44px)' };\n }\n return { ...base, flexDirection: 'column', justifyContent: 'center', textAlign: 'center', minHeight: 92 };\n}\n","'use client';\n\nimport type { WalletAdapter } from '@pollar/core';\nimport type { RenderWalletsSlot } from '@pollar/react';\nimport { stellarWalletsKitAdapters, type StellarWalletsKitAdapterOptions } from '../factory';\nimport { KitWalletPicker } from './KitWalletPicker';\n\nexport interface StellarWalletsKitBundle {\n /** Pass to `PollarClientConfig.walletAdapters`. */\n walletAdapters: WalletAdapter[];\n /** Pass to `<PollarProvider ui={{ renderWallets }}>`. */\n renderWallets: RenderWalletsSlot;\n}\n\n/**\n * One-shot helper that builds both halves of the integration from a single\n * options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)\n * and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same\n * `network` / `modules` / `picker` opts power both, so the picker shows the\n * exact wallets that signing will actually work with.\n *\n * @example\n * ```tsx\n * import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const bundle = createStellarWalletsKitBundle({\n * network: Networks.PUBLIC,\n * picker: { wallets: ['xbull', 'lobstr', 'freighter'] },\n * });\n *\n * <PollarProvider\n * client={{ apiKey: '…', walletAdapters: bundle.walletAdapters }}\n * ui={{ renderWallets: bundle.renderWallets }}\n * />\n * ```\n */\nexport function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle {\n const walletAdapters = stellarWalletsKitAdapters(options);\n const renderWallets: RenderWalletsSlot = (slot) => (\n <KitWalletPicker\n onConnect={slot.onConnect}\n authState={slot.authState}\n network={options.network}\n {...(options.modules !== undefined && { modules: options.modules })}\n {...(options.picker !== undefined && { picker: options.picker })}\n />\n );\n return { walletAdapters, renderWallets };\n}\n"]}
|
package/dist/picker.mjs
CHANGED
|
@@ -17,9 +17,11 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
17
17
|
|
|
18
18
|
// src/picker/KitWalletPicker.tsx
|
|
19
19
|
var StellarWalletsKitAdapter = class {
|
|
20
|
-
constructor(walletId) {
|
|
20
|
+
constructor(walletId, meta) {
|
|
21
|
+
this.custody = "external";
|
|
21
22
|
this._address = null;
|
|
22
23
|
this.type = walletId;
|
|
24
|
+
this.meta = meta;
|
|
23
25
|
}
|
|
24
26
|
async isAvailable() {
|
|
25
27
|
try {
|
|
@@ -131,11 +133,16 @@ function getInitNetwork() {
|
|
|
131
133
|
}
|
|
132
134
|
return initNetwork;
|
|
133
135
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
function stellarWalletsKitAdapters(options) {
|
|
137
|
+
ensureInit(options);
|
|
138
|
+
const modules = options.modules ?? buildDefaultModules();
|
|
139
|
+
const wanted = options.picker?.wallets;
|
|
140
|
+
return modules.filter((m) => !wanted || wanted.includes(m.productId)).map(
|
|
141
|
+
(m) => new StellarWalletsKitAdapter(m.productId, {
|
|
142
|
+
label: options.picker?.labels?.[m.productId] ?? m.productName,
|
|
143
|
+
iconUrl: m.productIcon
|
|
144
|
+
})
|
|
145
|
+
);
|
|
139
146
|
}
|
|
140
147
|
var CONNECTING_STEPS = /* @__PURE__ */ new Set(["connecting_wallet", "authenticating_wallet", "authenticating"]);
|
|
141
148
|
function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }) {
|
|
@@ -251,7 +258,7 @@ function buttonStyle(layout, disabled) {
|
|
|
251
258
|
return { ...base, flexDirection: "column", justifyContent: "center", textAlign: "center", minHeight: 92 };
|
|
252
259
|
}
|
|
253
260
|
function createStellarWalletsKitBundle(options) {
|
|
254
|
-
const
|
|
261
|
+
const walletAdapters = stellarWalletsKitAdapters(options);
|
|
255
262
|
const renderWallets = (slot) => /* @__PURE__ */ jsx(
|
|
256
263
|
KitWalletPicker,
|
|
257
264
|
{
|
|
@@ -262,7 +269,7 @@ function createStellarWalletsKitBundle(options) {
|
|
|
262
269
|
...options.picker !== void 0 && { picker: options.picker }
|
|
263
270
|
}
|
|
264
271
|
);
|
|
265
|
-
return {
|
|
272
|
+
return { walletAdapters, renderWallets };
|
|
266
273
|
}
|
|
267
274
|
|
|
268
275
|
export { KitWalletPicker, createStellarWalletsKitBundle };
|
package/dist/picker.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/StellarWalletsKitAdapter.ts","../src/factory.ts","../src/picker/KitWalletPicker.tsx","../src/picker/bundle.tsx"],"names":["StellarWalletsKit","jsx"],"mappings":";;;;;;;;;;;;;;;;;;AAkBO,IAAM,2BAAN,MAAwD;AAAA,EAI7D,YAAY,QAAA,EAAoB;AAFhC,IAAA,IAAA,CAAQ,QAAA,GAA0B,IAAA;AAGhC,IAAA,IAAA,CAAK,IAAA,GAAO,QAAA;AAAA,EACd;AAAA,EAEA,MAAM,WAAA,GAAgC;AAMpC,IAAA,IAAI;AACF,MAAA,MAAM,SAAA,GAAY,MAAM,iBAAA,CAAkB,uBAAA,EAAwB;AAClE,MAAA,MAAM,MAAA,GAAS,SAAA,CAAU,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,EAAA,KAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC/D,MAAA,OAAO,QAAQ,WAAA,IAAe,KAAA;AAAA,IAChC,SAAS,GAAA,EAAK;AACZ,MAAA,YAAA,GAAe,IAAA,CAAK,CAAA,kDAAA,EAAqD,IAAA,CAAK,IAAI,KAAK,GAAG,CAAA;AAC1F,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,GAA0C;AAC9C,IAAA,iBAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAM,kBAAkB,YAAA,EAAa;AACzD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,uDAAA,EAA0D,IAAA,CAAK,IAAI,CAAA,CAAA,CAAG,CAAA;AAAA,IACxF;AACA,IAAA,IAAA,CAAK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EAAS,QAAQ,OAAA,EAAQ;AAAA,MAChE,GAAI,OAAA,CAAQ,MAAA,KAAW,UAAa,EAAE,MAAA,EAAQ,QAAQ,MAAA;AAAO;AAAA,GAChE;AAEF,EAAA,OAAO,EAAE,eAAe,aAAA,EAAc;AACxC","file":"picker.mjs","sourcesContent":["import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n private _address: string | null = null;\n\n constructor(walletId: WalletId) {\n this.type = walletId;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n","import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapterResolver, type WalletId } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass\n * the result to `PollarClientConfig.walletAdapter` so Pollar can use any of\n * the kit's modules without `@pollar/core` having to depend on the kit.\n *\n * @example\n * ```ts\n * import { stellarWalletsKit } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapter: stellarWalletsKit({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKit(options: StellarWalletsKitAdapterOptions): WalletAdapterResolver {\n return (id: WalletId) => {\n ensureInit(options);\n return new StellarWalletsKitAdapter(id);\n };\n}\n","'use client';\n\nimport { type ISupportedWallet, type ModuleInterface, type Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type { RenderWalletsProps } from '@pollar/react';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { ensureInit, getKitLogger, type KitPickerOptions } from '../factory';\n\nexport interface KitWalletPickerProps extends RenderWalletsProps {\n network?: Networks;\n modules?: ModuleInterface[];\n picker?: KitPickerOptions;\n}\n\nconst CONNECTING_STEPS = new Set(['connecting_wallet', 'authenticating_wallet', 'authenticating']);\n\nexport function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }: KitWalletPickerProps) {\n const [wallets, setWallets] = useState<ISupportedWallet[] | null>(null);\n const warnedRef = useRef<Set<string>>(new Set());\n\n useEffect(() => {\n let cancelled = false;\n const initOpts: { network?: Networks; modules?: ModuleInterface[] } = {};\n if (network !== undefined) initOpts.network = network;\n if (modules !== undefined) initOpts.modules = modules;\n ensureInit(initOpts);\n StellarWalletsKit.refreshSupportedWallets()\n .then((list) => {\n if (cancelled) return;\n setWallets(list);\n })\n .catch((err) => {\n getKitLogger().error('[KitWalletPicker] refreshSupportedWallets failed', err);\n if (!cancelled) setWallets([]);\n });\n return () => {\n cancelled = true;\n };\n }, [network, modules]);\n\n const filtered = useMemo(() => {\n if (!wallets) return null;\n const { wallets: allowedIds, order = 'as-given', showInstalledOnly = false, labels } = picker;\n\n const byId = new Map(wallets.map((w) => [w.id, w]));\n let result: ISupportedWallet[];\n\n if (allowedIds && allowedIds.length > 0) {\n // Build the base list in `allowedIds` order; warn once per unknown id.\n // A later `order` setting may re-sort this list.\n result = [];\n for (const id of allowedIds) {\n const w = byId.get(id);\n if (w) {\n result.push(w);\n } else if (!warnedRef.current.has(id)) {\n warnedRef.current.add(id);\n getKitLogger().warn(`[KitWalletPicker] wallet id \"${id}\" not present in the active kit modules — skipped`);\n }\n }\n } else {\n result = [...wallets];\n }\n\n if (showInstalledOnly) {\n result = result.filter((w) => w.isAvailable);\n }\n\n if (order === 'alphabetical') {\n result = [...result].sort((a, b) => labelOf(a, labels).localeCompare(labelOf(b, labels)));\n } else if (order === 'installed-first') {\n result = [...result].sort((a, b) => {\n if (a.isAvailable === b.isAvailable) return 0;\n return a.isAvailable ? -1 : 1;\n });\n }\n // 'as-given' keeps whatever order we built above.\n\n return result;\n }, [wallets, picker]);\n\n const isBusy = CONNECTING_STEPS.has(authState.step);\n const layout = picker.layout ?? 'grid';\n const theme = picker.theme;\n const rootStyle: CSSProperties = {\n display: layout === 'list' ? 'flex' : 'grid',\n flexDirection: layout === 'list' ? 'column' : undefined,\n gridTemplateColumns: layout === 'grid' ? 'repeat(auto-fill, minmax(140px, 1fr))' : undefined,\n gap: '0.5rem',\n width: '100%',\n ...(theme?.accent !== undefined && { ['--pollar-accent' as never]: theme.accent }),\n ...(theme?.mode === 'dark' && { colorScheme: 'dark' as const }),\n };\n\n // Still loading the wallet list.\n if (filtered === null) {\n return (\n <div role=\"status\" aria-busy=\"true\" style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n Loading wallets…\n </div>\n );\n }\n\n // Empty state: showInstalledOnly hid every wallet, or the filter list is empty.\n if (filtered.length === 0) {\n return (\n <div style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n {picker.showInstalledOnly\n ? 'No supported Stellar wallets detected. Install Freighter / xBull / Lobstr to continue.'\n : 'No wallets to show.'}\n </div>\n );\n }\n\n return (\n <div style={rootStyle}>\n {filtered.map((w) => {\n const label = labelOf(w, picker.labels);\n const disabled = isBusy || (picker.showInstalledOnly ? false : !w.isAvailable);\n return (\n <button\n key={w.id}\n type=\"button\"\n disabled={disabled}\n onClick={() => onConnect(w.id)}\n style={buttonStyle(layout, disabled)}\n title={!w.isAvailable && !picker.showInstalledOnly ? `${label} not detected` : label}\n >\n <img src={w.icon} alt=\"\" width={32} height={32} style={{ borderRadius: 6, opacity: w.isAvailable ? 1 : 0.5 }} />\n <span style={{ fontSize: '0.85rem', fontWeight: 500 }}>{label}</span>\n {!w.isAvailable && <span style={{ fontSize: '0.7rem', opacity: 0.6 }}>not installed</span>}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction labelOf(w: ISupportedWallet, labels: Record<string, string> | undefined): string {\n return labels?.[w.id] ?? w.name;\n}\n\nfunction buttonStyle(layout: 'grid' | 'list', disabled: boolean): CSSProperties {\n const base: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.55 : 1,\n background: 'transparent',\n border: '1px solid var(--pollar-border, #e5e7eb)',\n borderRadius: 'var(--pollar-buttons-border-radius, 6px)',\n color: 'var(--pollar-text, inherit)',\n padding: '0.6rem',\n gap: '0.6rem',\n };\n if (layout === 'list') {\n return { ...base, justifyContent: 'flex-start', width: '100%', height: 'var(--pollar-buttons-height, 44px)' };\n }\n return { ...base, flexDirection: 'column', justifyContent: 'center', textAlign: 'center', minHeight: 92 };\n}\n","'use client';\n\nimport type { WalletAdapterResolver } from '@pollar/core';\nimport type { RenderWalletsSlot } from '@pollar/react';\nimport { stellarWalletsKit, type StellarWalletsKitAdapterOptions } from '../factory';\nimport { KitWalletPicker } from './KitWalletPicker';\n\nexport interface StellarWalletsKitBundle {\n /** Pass to `PollarClientConfig.walletAdapter`. */\n walletAdapter: WalletAdapterResolver;\n /** Pass to `<PollarProvider ui={{ renderWallets }}>`. */\n renderWallets: RenderWalletsSlot;\n}\n\n/**\n * One-shot helper that builds both halves of the integration from a single\n * options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)\n * and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same\n * `network` / `modules` / `picker` opts power both, so the picker shows the\n * exact wallets that signing will actually work with.\n *\n * @example\n * ```tsx\n * import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const bundle = createStellarWalletsKitBundle({\n * network: Networks.PUBLIC,\n * picker: { wallets: ['xbull', 'lobstr', 'freighter'] },\n * });\n *\n * <PollarProvider\n * client={{ apiKey: '…', walletAdapter: bundle.walletAdapter }}\n * ui={{ renderWallets: bundle.renderWallets }}\n * />\n * ```\n */\nexport function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle {\n const walletAdapter = stellarWalletsKit(options);\n const renderWallets: RenderWalletsSlot = (slot) => (\n <KitWalletPicker\n onConnect={slot.onConnect}\n authState={slot.authState}\n network={options.network}\n {...(options.modules !== undefined && { modules: options.modules })}\n {...(options.picker !== undefined && { picker: options.picker })}\n />\n );\n return { walletAdapter, renderWallets };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/StellarWalletsKitAdapter.ts","../src/factory.ts","../src/picker/KitWalletPicker.tsx","../src/picker/bundle.tsx"],"names":["Stellar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,CAAA;AACxD,EAAA,MAAM,aAAA,GAAmC,CAAC,IAAA,qBACxCC,GAAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,SAAS,OAAA,CAAQ,OAAA;AAAA,MAChB,GAAI,OAAA,CAAQ,OAAA,KAAY,UAAa,EAAE,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAAA,MAChE,GAAI,OAAA,CAAQ,MAAA,KAAW,UAAa,EAAE,MAAA,EAAQ,QAAQ,MAAA;AAAO;AAAA,GAChE;AAEF,EAAA,OAAO,EAAE,gBAAgB,aAAA,EAAc;AACzC","file":"picker.mjs","sourcesContent":["import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type {\n ConnectWalletResponse,\n SignAuthEntryOptions,\n SignAuthEntryResponse,\n SignTransactionOptions,\n SignTransactionResponse,\n WalletAdapter,\n WalletAdapterMeta,\n WalletId,\n} from '@pollar/core';\nimport { getInitNetwork, getKitLogger } from './factory';\n\n/**\n * Wraps Stellar Wallets Kit so it satisfies the `@pollar/core` `WalletAdapter`\n * contract. The kit is a global singleton — `setWallet` is called before every\n * operation so the correct module handles the request, which lets a single\n * `StellarWalletsKit.init(...)` cover many wallet modules.\n */\nexport class StellarWalletsKitAdapter implements WalletAdapter {\n readonly type: WalletId;\n readonly meta: WalletAdapterMeta;\n readonly custody = 'external' as const;\n private _address: string | null = null;\n\n constructor(walletId: WalletId, meta: WalletAdapterMeta) {\n this.type = walletId;\n this.meta = meta;\n }\n\n async isAvailable(): Promise<boolean> {\n // `refreshSupportedWallets()` probes every module's own `isAvailable()`\n // hook (modules promise <1000ms per the kit contract) and returns a\n // static snapshot. This avoids the old false-positive where we always\n // claimed availability and let `connect()` fail later — the picker / UI\n // can now short-circuit on `wallet_not_installed` immediately.\n try {\n const supported = await StellarWalletsKit.refreshSupportedWallets();\n const wallet = supported.find((w) => w.id === String(this.type));\n return wallet?.isAvailable ?? false;\n } catch (err) {\n getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for \"${this.type}\"`, err);\n return false;\n }\n }\n\n async connect(): Promise<ConnectWalletResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const { address } = await StellarWalletsKit.fetchAddress();\n if (!address) {\n throw new Error(`[StellarWalletsKit] Empty address returned for wallet \"${this.type}\"`);\n }\n this._address = address;\n return { address };\n }\n\n async disconnect(): Promise<void> {\n try {\n await StellarWalletsKit.disconnect();\n } finally {\n this._address = null;\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n if (this._address) return this._address;\n try {\n const { address } = await StellarWalletsKit.getAddress();\n this._address = address ?? null;\n return this._address;\n } catch {\n return null;\n }\n }\n\n async signTransaction(xdr: string, options?: SignTransactionOptions): Promise<SignTransactionResponse> {\n if (options?.networkPassphrase !== undefined && options.networkPassphrase !== getInitNetwork()) {\n throw new Error(\n `[StellarWalletsKit] networkPassphrase override \"${options.networkPassphrase}\" does not match the network configured at init (\"${getInitNetwork()}\"). The kit is a global singleton — configure one network at \\`stellarWalletsKit({ network })\\` and use that for every call.`,\n );\n }\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedTxXdr: result.signedTxXdr };\n }\n\n async signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse> {\n StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signAuthEntry(entryXdr, {\n ...(options?.accountToSign !== undefined && { address: options.accountToSign }),\n });\n return { signedAuthEntry: result.signedAuthEntry };\n }\n}\n","import { type ModuleInterface, Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';\nimport { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';\nimport { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';\nimport { FordefiModule } from '@creit.tech/stellar-wallets-kit/modules/fordefi';\nimport { FreighterModule } from '@creit.tech/stellar-wallets-kit/modules/freighter';\nimport { HanaModule } from '@creit.tech/stellar-wallets-kit/modules/hana';\nimport { HotWalletModule } from '@creit.tech/stellar-wallets-kit/modules/hotwallet';\nimport { KleverModule } from '@creit.tech/stellar-wallets-kit/modules/klever';\nimport { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';\nimport { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';\nimport { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';\nimport { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';\nimport { createLogger, type LogLevel, type PollarLogger, type WalletAdapter } from '@pollar/core';\nimport { StellarWalletsKitAdapter } from './StellarWalletsKitAdapter';\n\n/**\n * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on\n * `StellarWalletsKitAdapterOptions` so `createStellarWalletsKitBundle()` can\n * receive everything (network + modules + UI) in one call.\n */\nexport interface KitPickerOptions {\n /** Subset of wallet ids to show. Defaults to every wallet the kit reports. */\n wallets?: string[];\n /** Render order. Default `'as-given'` (the kit's own order). */\n order?: 'as-given' | 'installed-first' | 'alphabetical';\n /** Hide wallets whose `isAvailable` is false. Default `false`. */\n showInstalledOnly?: boolean;\n /** Per-wallet label overrides. Key = wallet id. */\n labels?: Record<string, string>;\n /** Visual layout. Default `'grid'`. */\n layout?: 'grid' | 'list';\n /** Theme passthrough — applied as CSS custom properties on the picker root. */\n theme?: { accent?: string; mode?: 'light' | 'dark' };\n}\n\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Required — there is no\n * default. The kit is a global singleton, so picking the network silently\n * for a consumer would risk signing real-looking transactions on the wrong\n * chain (testnet xdr signed on mainnet, etc.). Pass `Networks.TESTNET` or\n * `Networks.PUBLIC` explicitly.\n */\n network: Networks;\n /**\n * Wallet modules the kit should drive. Defaults to every module that works\n * out of the box (Albedo, Bitget, CactusLink, Fordefi, Freighter, Hana,\n * HotWallet, Klever, Lobstr, OneKey, Rabet, xBull). Pass an explicit list\n * to add Ledger / Trezor / WalletConnect — those need extra setup (a\n * Buffer polyfill for Ledger; constructor params for the other two) so we\n * don't auto-include them.\n *\n * Import modules from their kit subpaths so the bundle stays lean:\n * ```ts\n * import { WalletConnectModule } from '@creit.tech/stellar-wallets-kit/modules/wallet-connect';\n * ```\n */\n modules?: ModuleInterface[];\n /**\n * Picker-specific options. Only consumed by `<KitWalletPicker>` /\n * `createStellarWalletsKitBundle` (the `/picker` subpath). The resolver\n * itself ignores them.\n */\n picker?: KitPickerOptions;\n /**\n * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`\n * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global\n * singleton, this is set once at init.\n */\n logLevel?: LogLevel;\n /** Sink for logs. Defaults to the global `console`. */\n logger?: PollarLogger;\n}\n\nlet initialised = false;\nlet initNetwork: Networks | null = null;\nlet _log: PollarLogger = console;\n\n/** The kit's configured logger (set at init). Used by the adapter + picker. */\nexport function getKitLogger(): PollarLogger {\n return _log;\n}\n\n/** @internal — used by the `/picker` subpath. */\nexport function buildDefaultModules(): ModuleInterface[] {\n return [\n new AlbedoModule(),\n new BitgetModule(),\n new CactusLinkModule(),\n new FordefiModule(),\n new FreighterModule(),\n new HanaModule(),\n new HotWalletModule(),\n new KleverModule(),\n new LobstrModule(),\n new OneKeyModule(),\n new RabetModule(),\n new xBullModule(),\n ];\n}\n\n/**\n * @internal — used by the `/picker` subpath.\n *\n * Accepts `Partial<...>` because the picker may be mounted in a flow where\n * `stellarWalletsKit({ network })` has already initialised the kit elsewhere;\n * in that case the call no-ops and the missing `network` is fine. On the\n * first-time init path `network` is required and we throw if it's absent.\n */\nexport function ensureInit(options: Partial<StellarWalletsKitAdapterOptions>): void {\n if (options.logLevel !== undefined || options.logger !== undefined) {\n _log = createLogger(options.logLevel ?? 'info', options.logger);\n }\n if (initialised) {\n // The kit is a global singleton — a second call with a different network\n // would be silently ignored. Warn so the developer notices the\n // misconfiguration instead of debugging wrong-chain signatures later.\n if (options.network && options.network !== initNetwork) {\n _log.warn(\n `[StellarWalletsKit] Already initialised with network \"${initNetwork}\". Ignoring attempted reconfiguration to \"${options.network}\". The kit is a global singleton — reload the page to change networks.`,\n );\n }\n return;\n }\n if (!options.network) {\n throw new Error(\n '[StellarWalletsKit] `network` is required — pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init.',\n );\n }\n StellarWalletsKit.init({\n network: options.network,\n modules: options.modules ?? buildDefaultModules(),\n });\n initNetwork = options.network;\n initialised = true;\n}\n\n/** @internal — used by `StellarWalletsKitAdapter` to reject per-call network overrides that don't match init. */\nexport function getInitNetwork(): Networks {\n if (initNetwork === null) {\n throw new Error('[StellarWalletsKit] not initialised — call `stellarWalletsKit({ network })` first');\n }\n return initNetwork;\n}\n\n/**\n * Build the list of {@link WalletAdapter}s backed by Stellar Wallets Kit — one\n * per kit module — to pass to `PollarClientConfig.walletAdapters`. Each adapter\n * carries the module's name/icon as its button `meta`. `picker.wallets` (subset)\n * and `picker.labels` (overrides) are honored if provided.\n *\n * @example\n * ```ts\n * import { stellarWalletsKitAdapters } from '@pollar/stellar-wallets-kit-adapter';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const client = new PollarClient({\n * apiKey: '…',\n * walletAdapters: stellarWalletsKitAdapters({ network: Networks.PUBLIC }),\n * });\n * ```\n */\nexport function stellarWalletsKitAdapters(options: StellarWalletsKitAdapterOptions): WalletAdapter[] {\n ensureInit(options);\n const modules = options.modules ?? buildDefaultModules();\n const wanted = options.picker?.wallets;\n return modules\n .filter((m) => !wanted || wanted.includes(m.productId))\n .map(\n (m) =>\n new StellarWalletsKitAdapter(m.productId, {\n label: options.picker?.labels?.[m.productId] ?? m.productName,\n iconUrl: m.productIcon,\n }),\n );\n}\n","'use client';\n\nimport { type ISupportedWallet, type ModuleInterface, type Networks, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';\nimport type { RenderWalletsProps } from '@pollar/react';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { ensureInit, getKitLogger, type KitPickerOptions } from '../factory';\n\nexport interface KitWalletPickerProps extends RenderWalletsProps {\n network?: Networks;\n modules?: ModuleInterface[];\n picker?: KitPickerOptions;\n}\n\nconst CONNECTING_STEPS = new Set(['connecting_wallet', 'authenticating_wallet', 'authenticating']);\n\nexport function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }: KitWalletPickerProps) {\n const [wallets, setWallets] = useState<ISupportedWallet[] | null>(null);\n const warnedRef = useRef<Set<string>>(new Set());\n\n useEffect(() => {\n let cancelled = false;\n const initOpts: { network?: Networks; modules?: ModuleInterface[] } = {};\n if (network !== undefined) initOpts.network = network;\n if (modules !== undefined) initOpts.modules = modules;\n ensureInit(initOpts);\n StellarWalletsKit.refreshSupportedWallets()\n .then((list) => {\n if (cancelled) return;\n setWallets(list);\n })\n .catch((err) => {\n getKitLogger().error('[KitWalletPicker] refreshSupportedWallets failed', err);\n if (!cancelled) setWallets([]);\n });\n return () => {\n cancelled = true;\n };\n }, [network, modules]);\n\n const filtered = useMemo(() => {\n if (!wallets) return null;\n const { wallets: allowedIds, order = 'as-given', showInstalledOnly = false, labels } = picker;\n\n const byId = new Map(wallets.map((w) => [w.id, w]));\n let result: ISupportedWallet[];\n\n if (allowedIds && allowedIds.length > 0) {\n // Build the base list in `allowedIds` order; warn once per unknown id.\n // A later `order` setting may re-sort this list.\n result = [];\n for (const id of allowedIds) {\n const w = byId.get(id);\n if (w) {\n result.push(w);\n } else if (!warnedRef.current.has(id)) {\n warnedRef.current.add(id);\n getKitLogger().warn(`[KitWalletPicker] wallet id \"${id}\" not present in the active kit modules — skipped`);\n }\n }\n } else {\n result = [...wallets];\n }\n\n if (showInstalledOnly) {\n result = result.filter((w) => w.isAvailable);\n }\n\n if (order === 'alphabetical') {\n result = [...result].sort((a, b) => labelOf(a, labels).localeCompare(labelOf(b, labels)));\n } else if (order === 'installed-first') {\n result = [...result].sort((a, b) => {\n if (a.isAvailable === b.isAvailable) return 0;\n return a.isAvailable ? -1 : 1;\n });\n }\n // 'as-given' keeps whatever order we built above.\n\n return result;\n }, [wallets, picker]);\n\n const isBusy = CONNECTING_STEPS.has(authState.step);\n const layout = picker.layout ?? 'grid';\n const theme = picker.theme;\n const rootStyle: CSSProperties = {\n display: layout === 'list' ? 'flex' : 'grid',\n flexDirection: layout === 'list' ? 'column' : undefined,\n gridTemplateColumns: layout === 'grid' ? 'repeat(auto-fill, minmax(140px, 1fr))' : undefined,\n gap: '0.5rem',\n width: '100%',\n ...(theme?.accent !== undefined && { ['--pollar-accent' as never]: theme.accent }),\n ...(theme?.mode === 'dark' && { colorScheme: 'dark' as const }),\n };\n\n // Still loading the wallet list.\n if (filtered === null) {\n return (\n <div role=\"status\" aria-busy=\"true\" style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n Loading wallets…\n </div>\n );\n }\n\n // Empty state: showInstalledOnly hid every wallet, or the filter list is empty.\n if (filtered.length === 0) {\n return (\n <div style={{ padding: '1rem', textAlign: 'center', fontSize: '0.9rem' }}>\n {picker.showInstalledOnly\n ? 'No supported Stellar wallets detected. Install Freighter / xBull / Lobstr to continue.'\n : 'No wallets to show.'}\n </div>\n );\n }\n\n return (\n <div style={rootStyle}>\n {filtered.map((w) => {\n const label = labelOf(w, picker.labels);\n const disabled = isBusy || (picker.showInstalledOnly ? false : !w.isAvailable);\n return (\n <button\n key={w.id}\n type=\"button\"\n disabled={disabled}\n onClick={() => onConnect(w.id)}\n style={buttonStyle(layout, disabled)}\n title={!w.isAvailable && !picker.showInstalledOnly ? `${label} not detected` : label}\n >\n <img src={w.icon} alt=\"\" width={32} height={32} style={{ borderRadius: 6, opacity: w.isAvailable ? 1 : 0.5 }} />\n <span style={{ fontSize: '0.85rem', fontWeight: 500 }}>{label}</span>\n {!w.isAvailable && <span style={{ fontSize: '0.7rem', opacity: 0.6 }}>not installed</span>}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction labelOf(w: ISupportedWallet, labels: Record<string, string> | undefined): string {\n return labels?.[w.id] ?? w.name;\n}\n\nfunction buttonStyle(layout: 'grid' | 'list', disabled: boolean): CSSProperties {\n const base: CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.55 : 1,\n background: 'transparent',\n border: '1px solid var(--pollar-border, #e5e7eb)',\n borderRadius: 'var(--pollar-buttons-border-radius, 6px)',\n color: 'var(--pollar-text, inherit)',\n padding: '0.6rem',\n gap: '0.6rem',\n };\n if (layout === 'list') {\n return { ...base, justifyContent: 'flex-start', width: '100%', height: 'var(--pollar-buttons-height, 44px)' };\n }\n return { ...base, flexDirection: 'column', justifyContent: 'center', textAlign: 'center', minHeight: 92 };\n}\n","'use client';\n\nimport type { WalletAdapter } from '@pollar/core';\nimport type { RenderWalletsSlot } from '@pollar/react';\nimport { stellarWalletsKitAdapters, type StellarWalletsKitAdapterOptions } from '../factory';\nimport { KitWalletPicker } from './KitWalletPicker';\n\nexport interface StellarWalletsKitBundle {\n /** Pass to `PollarClientConfig.walletAdapters`. */\n walletAdapters: WalletAdapter[];\n /** Pass to `<PollarProvider ui={{ renderWallets }}>`. */\n renderWallets: RenderWalletsSlot;\n}\n\n/**\n * One-shot helper that builds both halves of the integration from a single\n * options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)\n * and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same\n * `network` / `modules` / `picker` opts power both, so the picker shows the\n * exact wallets that signing will actually work with.\n *\n * @example\n * ```tsx\n * import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';\n * import { Networks } from '@creit.tech/stellar-wallets-kit';\n *\n * const bundle = createStellarWalletsKitBundle({\n * network: Networks.PUBLIC,\n * picker: { wallets: ['xbull', 'lobstr', 'freighter'] },\n * });\n *\n * <PollarProvider\n * client={{ apiKey: '…', walletAdapters: bundle.walletAdapters }}\n * ui={{ renderWallets: bundle.renderWallets }}\n * />\n * ```\n */\nexport function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle {\n const walletAdapters = stellarWalletsKitAdapters(options);\n const renderWallets: RenderWalletsSlot = (slot) => (\n <KitWalletPicker\n onConnect={slot.onConnect}\n authState={slot.authState}\n network={options.network}\n {...(options.modules !== undefined && { modules: options.modules })}\n {...(options.picker !== undefined && { picker: options.picker })}\n />\n );\n return { walletAdapters, renderWallets };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pollar/stellar-wallets-kit-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-rc.8",
|
|
4
4
|
"description": "Stellar Wallets Kit adapter for @pollar/core — plug additional wallet modules (xBull, Lobstr, WalletConnect, hardware wallets…) into Pollar without bundling them into @pollar/core.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@creit.tech/stellar-wallets-kit": "^2.0.0",
|
|
45
|
-
"@pollar/core": "^0.
|
|
46
|
-
"@pollar/react": "^0.
|
|
45
|
+
"@pollar/core": "^0.10.0-rc.0",
|
|
46
|
+
"@pollar/react": "^0.10.0-rc.0",
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
48
48
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
49
49
|
},
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@pollar/core": "^0.
|
|
62
|
+
"@pollar/core": "^0.10.0-rc.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@creit.tech/stellar-wallets-kit": "^2.
|
|
66
|
-
"@eslint/js": "^
|
|
65
|
+
"@creit.tech/stellar-wallets-kit": "^2.3.0",
|
|
66
|
+
"@eslint/js": "^10.0.1",
|
|
67
67
|
"@pollar/react": "*",
|
|
68
68
|
"@types/react": "^18.0.0",
|
|
69
|
-
"eslint": "^
|
|
69
|
+
"eslint": "^10.5.0",
|
|
70
70
|
"react": "^18.0.0",
|
|
71
|
-
"tsup": "^8.
|
|
72
|
-
"typescript": "^
|
|
73
|
-
"typescript-eslint": "^8.
|
|
71
|
+
"tsup": "^8.5.1",
|
|
72
|
+
"typescript": "^6.0.3",
|
|
73
|
+
"typescript-eslint": "^8.61.0"
|
|
74
74
|
}
|
|
75
75
|
}
|