@pollar/stellar-wallets-kit-adapter 0.9.0-rc.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,6 +52,11 @@ Rabet, …) inside `LoginModal`, also pass the picker — see
52
52
 
53
53
  The kit is a global singleton. `stellarWalletsKit(...)` returns a resolver and `StellarWalletsKit.init(...)` is called once on the first `loginWallet` call.
54
54
 
55
+ > **0.9.0** — `connect()` resolves to `{ address }` only (the duplicate
56
+ > `publicKey` field is gone, matching the new `ConnectWalletResponse`). Requires
57
+ > `@pollar/core@^0.9.0` / `@pollar/react@^0.9.0`. Adds `logLevel` / `logger`
58
+ > options (set once at init — the kit is a global singleton).
59
+ >
55
60
  > **0.8.0** — `network` is **required**. The previous `Networks.TESTNET`
56
61
  > default was removed because the kit is a global singleton, and silently
57
62
  > picking testnet for the consumer risked signing real-looking transactions
@@ -254,7 +259,7 @@ import { StellarWalletsKitAdapter } from '@pollar/stellar-wallets-kit-adapter';
254
259
  StellarWalletsKit.init({ network: Networks.PUBLIC, modules: [new FreighterModule()] });
255
260
 
256
261
  const adapter = new StellarWalletsKitAdapter('freighter');
257
- const { publicKey } = await adapter.connect();
262
+ const { address } = await adapter.connect();
258
263
  ```
259
264
 
260
265
  ## Writing a custom resolver
@@ -1,5 +1,5 @@
1
1
  import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
2
- import { WalletAdapterResolver } from '@pollar/core';
2
+ import { LogLevel, PollarLogger, WalletAdapterResolver } from '@pollar/core';
3
3
 
4
4
  /**
5
5
  * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
@@ -52,6 +52,14 @@ interface StellarWalletsKitAdapterOptions {
52
52
  * itself ignores them.
53
53
  */
54
54
  picker?: KitPickerOptions;
55
+ /**
56
+ * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`
57
+ * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global
58
+ * singleton, this is set once at init.
59
+ */
60
+ logLevel?: LogLevel;
61
+ /** Sink for logs. Defaults to the global `console`. */
62
+ logger?: PollarLogger;
55
63
  }
56
64
  /**
57
65
  * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass
@@ -1,5 +1,5 @@
1
1
  import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
2
- import { WalletAdapterResolver } from '@pollar/core';
2
+ import { LogLevel, PollarLogger, WalletAdapterResolver } from '@pollar/core';
3
3
 
4
4
  /**
5
5
  * Options that shape `<KitWalletPicker>` (from the `/picker` subpath). Kept on
@@ -52,6 +52,14 @@ interface StellarWalletsKitAdapterOptions {
52
52
  * itself ignores them.
53
53
  */
54
54
  picker?: KitPickerOptions;
55
+ /**
56
+ * Minimum log severity. `silent` disables logging; otherwise `error` < `warn`
57
+ * < `info` < `debug`. Defaults to `'info'`. Since the kit is a global
58
+ * singleton, this is set once at init.
59
+ */
60
+ logLevel?: LogLevel;
61
+ /** Sink for logs. Defaults to the global `console`. */
62
+ logger?: PollarLogger;
55
63
  }
56
64
  /**
57
65
  * Build a {@link WalletAdapterResolver} backed by Stellar Wallets Kit. Pass
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WalletAdapter, WalletId, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
2
- export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKit } from './factory-D58ktBBa.mjs';
2
+ export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKit } from './factory-CR-sDzIv.mjs';
3
3
  import '@creit.tech/stellar-wallets-kit';
4
4
 
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WalletAdapter, WalletId, ConnectWalletResponse, SignTransactionOptions, SignTransactionResponse, SignAuthEntryOptions, SignAuthEntryResponse } from '@pollar/core';
2
- export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKit } from './factory-D58ktBBa.js';
2
+ export { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions, s as stellarWalletsKit } from './factory-CR-sDzIv.js';
3
3
  import '@creit.tech/stellar-wallets-kit';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -13,10 +13,15 @@ var lobstr = require('@creit.tech/stellar-wallets-kit/modules/lobstr');
13
13
  var onekey = require('@creit.tech/stellar-wallets-kit/modules/onekey');
14
14
  var rabet = require('@creit.tech/stellar-wallets-kit/modules/rabet');
15
15
  var xbull = require('@creit.tech/stellar-wallets-kit/modules/xbull');
16
+ var core = require('@pollar/core');
16
17
 
17
18
  // src/StellarWalletsKitAdapter.ts
18
19
  var initialised = false;
19
20
  var initNetwork = null;
21
+ var _log = console;
22
+ function getKitLogger() {
23
+ return _log;
24
+ }
20
25
  function buildDefaultModules() {
21
26
  return [
22
27
  new albedo.AlbedoModule(),
@@ -34,9 +39,12 @@ function buildDefaultModules() {
34
39
  ];
35
40
  }
36
41
  function ensureInit(options) {
42
+ if (options.logLevel !== void 0 || options.logger !== void 0) {
43
+ _log = core.createLogger(options.logLevel ?? "info", options.logger);
44
+ }
37
45
  if (initialised) {
38
46
  if (options.network && options.network !== initNetwork) {
39
- console.warn(
47
+ _log.warn(
40
48
  `[StellarWalletsKit] Already initialised with network "${initNetwork}". Ignoring attempted reconfiguration to "${options.network}". The kit is a global singleton \u2014 reload the page to change networks.`
41
49
  );
42
50
  }
@@ -79,7 +87,7 @@ var StellarWalletsKitAdapter = class {
79
87
  const wallet = supported.find((w) => w.id === String(this.type));
80
88
  return wallet?.isAvailable ?? false;
81
89
  } catch (err) {
82
- console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
90
+ getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
83
91
  return false;
84
92
  }
85
93
  }
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","StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AAG5B,SAAS,mBAAA,GAAyC;AACvD,EAAA,OAAO;AAAA,IACL,IAAIA,mBAAA,EAAa;AAAA,IACjB,IAAIC,mBAAA,EAAa;AAAA,IACjB,IAAIC,2BAAA,EAAiB;AAAA,IACrB,IAAIC,qBAAA,EAAc;AAAA,IAClB,IAAIC,yBAAA,EAAgB;AAAA,IACpB,IAAIC,eAAA,EAAW;AAAA,IACf,IAAIC,yBAAA,EAAgB;AAAA,IACpB,IAAIC,mBAAA,EAAa;AAAA,IACjB,IAAIC,mBAAA,EAAa;AAAA,IACjB,IAAIC,mBAAA,EAAa;AAAA,IACjB,IAAIC,iBAAA,EAAY;AAAA,IAChB,IAAIC,iBAAA;AAAY,GAClB;AACF;AAUO,SAAS,WAAW,OAAA,EAAyD;AAClF,EAAA,IAAI,WAAA,EAAa;AAIf,IAAA,IAAI,OAAA,CAAQ,OAAA,IAAW,OAAA,CAAQ,OAAA,KAAY,WAAA,EAAa;AACtD,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,CAAA,sDAAA,EAAyD,WAAW,CAAA,0CAAA,EAA6C,OAAA,CAAQ,OAAO,CAAA,2EAAA;AAAA,OAClI;AAAA,IACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,CAAC,QAAQ,OAAA,EAAS;AACpB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAAC,qCAAA,CAAkB,IAAA,CAAK;AAAA,IACrB,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,OAAA,EAAS,OAAA,CAAQ,OAAA,IAAW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AAA,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,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 type { WalletAdapterResolver, 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\nlet initialised = false;\nlet initNetwork: Networks | null = null;\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 (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 console.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 } 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 console.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;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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AAA,CAAc,QAAA,EAAkB,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"]}
package/dist/index.mjs CHANGED
@@ -11,10 +11,15 @@ import { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';
11
11
  import { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';
12
12
  import { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';
13
13
  import { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';
14
+ import { createLogger } from '@pollar/core';
14
15
 
15
16
  // src/StellarWalletsKitAdapter.ts
16
17
  var initialised = false;
17
18
  var initNetwork = null;
19
+ var _log = console;
20
+ function getKitLogger() {
21
+ return _log;
22
+ }
18
23
  function buildDefaultModules() {
19
24
  return [
20
25
  new AlbedoModule(),
@@ -32,9 +37,12 @@ function buildDefaultModules() {
32
37
  ];
33
38
  }
34
39
  function ensureInit(options) {
40
+ if (options.logLevel !== void 0 || options.logger !== void 0) {
41
+ _log = createLogger(options.logLevel ?? "info", options.logger);
42
+ }
35
43
  if (initialised) {
36
44
  if (options.network && options.network !== initNetwork) {
37
- console.warn(
45
+ _log.warn(
38
46
  `[StellarWalletsKit] Already initialised with network "${initNetwork}". Ignoring attempted reconfiguration to "${options.network}". The kit is a global singleton \u2014 reload the page to change networks.`
39
47
  );
40
48
  }
@@ -77,7 +85,7 @@ var StellarWalletsKitAdapter = class {
77
85
  const wallet = supported.find((w) => w.id === String(this.type));
78
86
  return wallet?.isAvailable ?? false;
79
87
  } catch (err) {
80
- console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
88
+ getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
81
89
  return false;
82
90
  }
83
91
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;AAmEA,IAAI,WAAA,GAAc,KAAA;AAClB,IAAI,WAAA,GAA+B,IAAA;AAG5B,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,IA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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 type { WalletAdapterResolver, 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\nlet initialised = false;\nlet initNetwork: Networks | null = null;\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 (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 console.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 } 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 console.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,OAAA,CAAQ,WAAW,MAAA,EAAW;AAClE,IAAA,IAAA,GAAO,YAAA,CAAa,OAAA,CAAQ,QAAA,IAAY,MAAA,EAAQ,QAAQ,MAAM,CAAA;AAAA,EAChE;AACA,EAAA,IAAI,WAAA,EAAa;AAIf,IAAA,IAAI,OAAA,CAAQ,OAAA,IAAW,OAAA,CAAQ,OAAA,KAAY,WAAA,EAAa;AACtD,MAAA,IAAA,CAAK,IAAA;AAAA,QACH,CAAA,sDAAA,EAAyD,WAAW,CAAA,0CAAA,EAA6C,OAAA,CAAQ,OAAO,CAAA,2EAAA;AAAA,OACl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AAA,EAAmD,OAAA,CAAQ,iBAAiB,CAAA,kDAAA,EAAqD,gBAAgB,CAAA,iIAAA;AAAA,OACnJ;AAAA,IACF;AACA,IAAAA,iBAAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,MAAA,GAAS,MAAMA,iBAAAA,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,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 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"]}
package/dist/picker.d.mts CHANGED
@@ -1,7 +1,7 @@
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-D58ktBBa.mjs';
4
+ import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-CR-sDzIv.mjs';
5
5
  import { WalletAdapterResolver } from '@pollar/core';
6
6
 
7
7
  interface KitWalletPickerProps extends RenderWalletsProps {
package/dist/picker.d.ts CHANGED
@@ -1,7 +1,7 @@
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-D58ktBBa.js';
4
+ import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-CR-sDzIv.js';
5
5
  import { WalletAdapterResolver } from '@pollar/core';
6
6
 
7
7
  interface KitWalletPickerProps extends RenderWalletsProps {
package/dist/picker.js CHANGED
@@ -14,6 +14,7 @@ var lobstr = require('@creit.tech/stellar-wallets-kit/modules/lobstr');
14
14
  var onekey = require('@creit.tech/stellar-wallets-kit/modules/onekey');
15
15
  var rabet = require('@creit.tech/stellar-wallets-kit/modules/rabet');
16
16
  var xbull = require('@creit.tech/stellar-wallets-kit/modules/xbull');
17
+ var core = require('@pollar/core');
17
18
  var jsxRuntime = require('react/jsx-runtime');
18
19
 
19
20
  // src/picker/KitWalletPicker.tsx
@@ -28,7 +29,7 @@ var StellarWalletsKitAdapter = class {
28
29
  const wallet = supported.find((w) => w.id === String(this.type));
29
30
  return wallet?.isAvailable ?? false;
30
31
  } catch (err) {
31
- console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
32
+ getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
32
33
  return false;
33
34
  }
34
35
  }
@@ -82,6 +83,10 @@ var StellarWalletsKitAdapter = class {
82
83
  // src/factory.ts
83
84
  var initialised = false;
84
85
  var initNetwork = null;
86
+ var _log = console;
87
+ function getKitLogger() {
88
+ return _log;
89
+ }
85
90
  function buildDefaultModules() {
86
91
  return [
87
92
  new albedo.AlbedoModule(),
@@ -99,9 +104,12 @@ function buildDefaultModules() {
99
104
  ];
100
105
  }
101
106
  function ensureInit(options) {
107
+ if (options.logLevel !== void 0 || options.logger !== void 0) {
108
+ _log = core.createLogger(options.logLevel ?? "info", options.logger);
109
+ }
102
110
  if (initialised) {
103
111
  if (options.network && options.network !== initNetwork) {
104
- console.warn(
112
+ _log.warn(
105
113
  `[StellarWalletsKit] Already initialised with network "${initNetwork}". Ignoring attempted reconfiguration to "${options.network}". The kit is a global singleton \u2014 reload the page to change networks.`
106
114
  );
107
115
  }
@@ -145,7 +153,7 @@ function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }
145
153
  if (cancelled) return;
146
154
  setWallets(list);
147
155
  }).catch((err) => {
148
- console.error("[KitWalletPicker] refreshSupportedWallets failed", err);
156
+ getKitLogger().error("[KitWalletPicker] refreshSupportedWallets failed", err);
149
157
  if (!cancelled) setWallets([]);
150
158
  });
151
159
  return () => {
@@ -165,7 +173,7 @@ function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }
165
173
  result.push(w);
166
174
  } else if (!warnedRef.current.has(id)) {
167
175
  warnedRef.current.add(id);
168
- console.warn(`[KitWalletPicker] wallet id "${id}" not present in the active kit modules \u2014 skipped`);
176
+ getKitLogger().warn(`[KitWalletPicker] wallet id "${id}" not present in the active kit modules \u2014 skipped`);
169
177
  }
170
178
  }
171
179
  } else {
@@ -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","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,OAAA,CAAQ,IAAA,CAAK,CAAA,kDAAA,EAAqD,IAAA,CAAK,IAAI,KAAK,GAAG,CAAA;AACnF,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,GAA0C;AAC9C,IAAAA,qCAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAC7C,IAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,MAAMA,sCAAkB,YAAA,EAAa;AACzD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,uDAAA,EAA0D,IAAA,CAAK,IA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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 } 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 console.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 type { WalletAdapterResolver, 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\nlet initialised = false;\nlet initNetwork: Networks | null = null;\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 (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 console.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, 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 console.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 console.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":";;;;;;;;;;;;;;;;;;;;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,CAA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AAW,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,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"]}
package/dist/picker.mjs CHANGED
@@ -12,6 +12,7 @@ import { LobstrModule } from '@creit.tech/stellar-wallets-kit/modules/lobstr';
12
12
  import { OneKeyModule } from '@creit.tech/stellar-wallets-kit/modules/onekey';
13
13
  import { RabetModule } from '@creit.tech/stellar-wallets-kit/modules/rabet';
14
14
  import { xBullModule } from '@creit.tech/stellar-wallets-kit/modules/xbull';
15
+ import { createLogger } from '@pollar/core';
15
16
  import { jsx, jsxs } from 'react/jsx-runtime';
16
17
 
17
18
  // src/picker/KitWalletPicker.tsx
@@ -26,7 +27,7 @@ var StellarWalletsKitAdapter = class {
26
27
  const wallet = supported.find((w) => w.id === String(this.type));
27
28
  return wallet?.isAvailable ?? false;
28
29
  } catch (err) {
29
- console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
30
+ getKitLogger().warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
30
31
  return false;
31
32
  }
32
33
  }
@@ -80,6 +81,10 @@ var StellarWalletsKitAdapter = class {
80
81
  // src/factory.ts
81
82
  var initialised = false;
82
83
  var initNetwork = null;
84
+ var _log = console;
85
+ function getKitLogger() {
86
+ return _log;
87
+ }
83
88
  function buildDefaultModules() {
84
89
  return [
85
90
  new AlbedoModule(),
@@ -97,9 +102,12 @@ function buildDefaultModules() {
97
102
  ];
98
103
  }
99
104
  function ensureInit(options) {
105
+ if (options.logLevel !== void 0 || options.logger !== void 0) {
106
+ _log = createLogger(options.logLevel ?? "info", options.logger);
107
+ }
100
108
  if (initialised) {
101
109
  if (options.network && options.network !== initNetwork) {
102
- console.warn(
110
+ _log.warn(
103
111
  `[StellarWalletsKit] Already initialised with network "${initNetwork}". Ignoring attempted reconfiguration to "${options.network}". The kit is a global singleton \u2014 reload the page to change networks.`
104
112
  );
105
113
  }
@@ -143,7 +151,7 @@ function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }
143
151
  if (cancelled) return;
144
152
  setWallets(list);
145
153
  }).catch((err) => {
146
- console.error("[KitWalletPicker] refreshSupportedWallets failed", err);
154
+ getKitLogger().error("[KitWalletPicker] refreshSupportedWallets failed", err);
147
155
  if (!cancelled) setWallets([]);
148
156
  });
149
157
  return () => {
@@ -163,7 +171,7 @@ function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }
163
171
  result.push(w);
164
172
  } else if (!warnedRef.current.has(id)) {
165
173
  warnedRef.current.add(id);
166
- console.warn(`[KitWalletPicker] wallet id "${id}" not present in the active kit modules \u2014 skipped`);
174
+ getKitLogger().warn(`[KitWalletPicker] wallet id "${id}" not present in the active kit modules \u2014 skipped`);
167
175
  }
168
176
  }
169
177
  } else {
@@ -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,EA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A,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,aAAA,GAAgB,kBAAkB,OAAO,CAAA;AAC/C,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,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 } 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 console.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 type { WalletAdapterResolver, 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\nlet initialised = false;\nlet initNetwork: Networks | null = null;\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 (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 console.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, 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 console.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 console.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","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,QAAA,GAAW,OAAA;AAChB,IAAA,OAAO,EAAE,OAAA,EAAQ;AAAA,EACnB;AAAA,EAEA,MAAM,UAAA,GAA4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AQ,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pollar/stellar-wallets-kit-adapter",
3
- "version": "0.9.0-rc.0",
3
+ "version": "0.9.0",
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.9.0-rc.0",
46
- "@pollar/react": "0.9.0-rc.0",
45
+ "@pollar/core": "^0.9.0",
46
+ "@pollar/react": "^0.9.0",
47
47
  "react": "^18.0.0 || ^19.0.0",
48
48
  "react-dom": "^18.0.0 || ^19.0.0"
49
49
  },
@@ -59,7 +59,7 @@
59
59
  }
60
60
  },
61
61
  "dependencies": {
62
- "@pollar/core": "0.9.0-rc.0"
62
+ "@pollar/core": "^0.9.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@creit.tech/stellar-wallets-kit": "^2.2.0",