@pollar/stellar-wallets-kit-adapter 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -28
- package/dist/factory-D58ktBBa.d.mts +74 -0
- package/dist/factory-D58ktBBa.d.ts +74 -0
- package/dist/index.d.mts +4 -41
- package/dist/index.d.ts +4 -41
- package/dist/index.js +63 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -36
- package/dist/index.mjs.map +1 -1
- package/dist/picker.d.mts +45 -0
- package/dist/picker.d.ts +45 -0
- package/dist/picker.js +265 -0
- package/dist/picker.js.map +1 -0
- package/dist/picker.mjs +262 -0
- package/dist/picker.mjs.map +1 -0
- package/package.json +29 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StellarWalletsKit
|
|
1
|
+
import { StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';
|
|
2
2
|
import { AlbedoModule } from '@creit.tech/stellar-wallets-kit/modules/albedo';
|
|
3
3
|
import { BitgetModule } from '@creit.tech/stellar-wallets-kit/modules/bitget';
|
|
4
4
|
import { CactusLinkModule } from '@creit.tech/stellar-wallets-kit/modules/cactuslink';
|
|
@@ -12,6 +12,59 @@ 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
14
|
|
|
15
|
+
// src/StellarWalletsKitAdapter.ts
|
|
16
|
+
var initialised = false;
|
|
17
|
+
var initNetwork = null;
|
|
18
|
+
function buildDefaultModules() {
|
|
19
|
+
return [
|
|
20
|
+
new AlbedoModule(),
|
|
21
|
+
new BitgetModule(),
|
|
22
|
+
new CactusLinkModule(),
|
|
23
|
+
new FordefiModule(),
|
|
24
|
+
new FreighterModule(),
|
|
25
|
+
new HanaModule(),
|
|
26
|
+
new HotWalletModule(),
|
|
27
|
+
new KleverModule(),
|
|
28
|
+
new LobstrModule(),
|
|
29
|
+
new OneKeyModule(),
|
|
30
|
+
new RabetModule(),
|
|
31
|
+
new xBullModule()
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function ensureInit(options) {
|
|
35
|
+
if (initialised) {
|
|
36
|
+
if (options.network && options.network !== initNetwork) {
|
|
37
|
+
console.warn(
|
|
38
|
+
`[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
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!options.network) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"[StellarWalletsKit] `network` is required \u2014 pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
StellarWalletsKit.init({
|
|
49
|
+
network: options.network,
|
|
50
|
+
modules: options.modules ?? buildDefaultModules()
|
|
51
|
+
});
|
|
52
|
+
initNetwork = options.network;
|
|
53
|
+
initialised = true;
|
|
54
|
+
}
|
|
55
|
+
function getInitNetwork() {
|
|
56
|
+
if (initNetwork === null) {
|
|
57
|
+
throw new Error("[StellarWalletsKit] not initialised \u2014 call `stellarWalletsKit({ network })` first");
|
|
58
|
+
}
|
|
59
|
+
return initNetwork;
|
|
60
|
+
}
|
|
61
|
+
function stellarWalletsKit(options) {
|
|
62
|
+
return (id) => {
|
|
63
|
+
ensureInit(options);
|
|
64
|
+
return new StellarWalletsKitAdapter(id);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
15
68
|
// src/StellarWalletsKitAdapter.ts
|
|
16
69
|
var StellarWalletsKitAdapter = class {
|
|
17
70
|
constructor(walletId) {
|
|
@@ -20,9 +73,11 @@ var StellarWalletsKitAdapter = class {
|
|
|
20
73
|
}
|
|
21
74
|
async isAvailable() {
|
|
22
75
|
try {
|
|
23
|
-
StellarWalletsKit.
|
|
24
|
-
|
|
25
|
-
|
|
76
|
+
const supported = await StellarWalletsKit.refreshSupportedWallets();
|
|
77
|
+
const wallet = supported.find((w) => w.id === String(this.type));
|
|
78
|
+
return wallet?.isAvailable ?? false;
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
|
|
26
81
|
return false;
|
|
27
82
|
}
|
|
28
83
|
}
|
|
@@ -53,9 +108,13 @@ var StellarWalletsKitAdapter = class {
|
|
|
53
108
|
}
|
|
54
109
|
}
|
|
55
110
|
async signTransaction(xdr, options) {
|
|
111
|
+
if (options?.networkPassphrase !== void 0 && options.networkPassphrase !== getInitNetwork()) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`[StellarWalletsKit] networkPassphrase override "${options.networkPassphrase}" does not match the network configured at init ("${getInitNetwork()}"). The kit is a global singleton \u2014 configure one network at \`stellarWalletsKit({ network })\` and use that for every call.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
56
116
|
StellarWalletsKit.setWallet(String(this.type));
|
|
57
117
|
const result = await StellarWalletsKit.signTransaction(xdr, {
|
|
58
|
-
...options?.networkPassphrase !== void 0 && { networkPassphrase: options.networkPassphrase },
|
|
59
118
|
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
60
119
|
});
|
|
61
120
|
return { signedTxXdr: result.signedTxXdr };
|
|
@@ -68,37 +127,6 @@ var StellarWalletsKitAdapter = class {
|
|
|
68
127
|
return { signedAuthEntry: result.signedAuthEntry };
|
|
69
128
|
}
|
|
70
129
|
};
|
|
71
|
-
var initialised = false;
|
|
72
|
-
function buildDefaultModules() {
|
|
73
|
-
return [
|
|
74
|
-
new AlbedoModule(),
|
|
75
|
-
new BitgetModule(),
|
|
76
|
-
new CactusLinkModule(),
|
|
77
|
-
new FordefiModule(),
|
|
78
|
-
new FreighterModule(),
|
|
79
|
-
new HanaModule(),
|
|
80
|
-
new HotWalletModule(),
|
|
81
|
-
new KleverModule(),
|
|
82
|
-
new LobstrModule(),
|
|
83
|
-
new OneKeyModule(),
|
|
84
|
-
new RabetModule(),
|
|
85
|
-
new xBullModule()
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
function ensureInit(options) {
|
|
89
|
-
if (initialised) return;
|
|
90
|
-
StellarWalletsKit.init({
|
|
91
|
-
network: options.network ?? Networks.TESTNET,
|
|
92
|
-
modules: options.modules ?? buildDefaultModules()
|
|
93
|
-
});
|
|
94
|
-
initialised = true;
|
|
95
|
-
}
|
|
96
|
-
function stellarWalletsKit(options = {}) {
|
|
97
|
-
return (id) => {
|
|
98
|
-
ensureInit(options);
|
|
99
|
-
return new StellarWalletsKitAdapter(id);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
130
|
|
|
103
131
|
export { StellarWalletsKitAdapter, stellarWalletsKit };
|
|
104
132
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/StellarWalletsKitAdapter.ts","../src/factory.ts"],"names":["StellarWalletsKit"],"mappings":";;;;;;;;;;;;;;;AAiBO,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;AACpC,IAAA,IAAI;AACF,MAAA,iBAAA,CAAkB,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAC,CAAA;AAK7C,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,OAAA,GAA0C;AAC9C,IAAA,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AAAoB,GACjD,CAAA;AACD,EAAA,WAAA,GAAc,IAAA;AAChB;AAkBO,SAAS,iBAAA,CAAkB,OAAA,GAA2C,EAAC,EAA0B;AACtG,EAAA,OAAO,CAAC,EAAA,KAAiB;AACvB,IAAA,UAAA,CAAW,OAAO,CAAA;AAClB,IAAA,OAAO,IAAI,yBAAyB,EAAE,CAAA;AAAA,EACxC,CAAA;AACF","file":"index.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';\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 try {\n StellarWalletsKit.setWallet(String(this.type));\n // The kit doesn't expose a top-level `isAvailable`; once the module is\n // selected, attempting an address fetch is the cheapest probe — but it\n // can pop UI on some wallets. Return true and let `connect()` surface\n // the real availability error if any.\n return true;\n } catch {\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, publicKey: 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 StellarWalletsKit.setWallet(String(this.type));\n const result = await StellarWalletsKit.signTransaction(xdr, {\n ...(options?.networkPassphrase !== undefined && { networkPassphrase: options.networkPassphrase }),\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\nexport interface StellarWalletsKitAdapterOptions {\n /**\n * Stellar network the kit will use for signing. Defaults to `Networks.TESTNET`.\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\nlet initialised = false;\n\nfunction 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\nfunction ensureInit(options: StellarWalletsKitAdapterOptions): void {\n if (initialised) return;\n StellarWalletsKit.init({\n network: options.network ?? Networks.TESTNET,\n modules: options.modules ?? buildDefaultModules(),\n });\n initialised = true;\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/factory.ts","../src/StellarWalletsKitAdapter.ts"],"names":["StellarWalletsKit"],"mappings":";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AAA,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 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, publicKey: 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"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
3
|
+
import { RenderWalletsProps, RenderWalletsSlot } from '@pollar/react';
|
|
4
|
+
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-D58ktBBa.mjs';
|
|
5
|
+
import { WalletAdapterResolver } from '@pollar/core';
|
|
6
|
+
|
|
7
|
+
interface KitWalletPickerProps extends RenderWalletsProps {
|
|
8
|
+
network?: Networks;
|
|
9
|
+
modules?: ModuleInterface[];
|
|
10
|
+
picker?: KitPickerOptions;
|
|
11
|
+
}
|
|
12
|
+
declare function KitWalletPicker({ onConnect, authState, network, modules, picker }: KitWalletPickerProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
interface StellarWalletsKitBundle {
|
|
15
|
+
/** Pass to `PollarClientConfig.walletAdapter`. */
|
|
16
|
+
walletAdapter: WalletAdapterResolver;
|
|
17
|
+
/** Pass to `<PollarProvider ui={{ renderWallets }}>`. */
|
|
18
|
+
renderWallets: RenderWalletsSlot;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One-shot helper that builds both halves of the integration from a single
|
|
22
|
+
* options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)
|
|
23
|
+
* and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same
|
|
24
|
+
* `network` / `modules` / `picker` opts power both, so the picker shows the
|
|
25
|
+
* exact wallets that signing will actually work with.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';
|
|
30
|
+
* import { Networks } from '@creit.tech/stellar-wallets-kit';
|
|
31
|
+
*
|
|
32
|
+
* const bundle = createStellarWalletsKitBundle({
|
|
33
|
+
* network: Networks.PUBLIC,
|
|
34
|
+
* picker: { wallets: ['xbull', 'lobstr', 'freighter'] },
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* <PollarProvider
|
|
38
|
+
* client={{ apiKey: '…', walletAdapter: bundle.walletAdapter }}
|
|
39
|
+
* ui={{ renderWallets: bundle.renderWallets }}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle;
|
|
44
|
+
|
|
45
|
+
export { KitWalletPicker, type KitWalletPickerProps, type StellarWalletsKitBundle, createStellarWalletsKitBundle };
|
package/dist/picker.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Networks, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
|
|
3
|
+
import { RenderWalletsProps, RenderWalletsSlot } from '@pollar/react';
|
|
4
|
+
import { K as KitPickerOptions, S as StellarWalletsKitAdapterOptions } from './factory-D58ktBBa.js';
|
|
5
|
+
import { WalletAdapterResolver } from '@pollar/core';
|
|
6
|
+
|
|
7
|
+
interface KitWalletPickerProps extends RenderWalletsProps {
|
|
8
|
+
network?: Networks;
|
|
9
|
+
modules?: ModuleInterface[];
|
|
10
|
+
picker?: KitPickerOptions;
|
|
11
|
+
}
|
|
12
|
+
declare function KitWalletPicker({ onConnect, authState, network, modules, picker }: KitWalletPickerProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
interface StellarWalletsKitBundle {
|
|
15
|
+
/** Pass to `PollarClientConfig.walletAdapter`. */
|
|
16
|
+
walletAdapter: WalletAdapterResolver;
|
|
17
|
+
/** Pass to `<PollarProvider ui={{ renderWallets }}>`. */
|
|
18
|
+
renderWallets: RenderWalletsSlot;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One-shot helper that builds both halves of the integration from a single
|
|
22
|
+
* options object: the `walletAdapter` (a `WalletAdapterResolver` for the SDK)
|
|
23
|
+
* and `renderWallets` (a slot for `<PollarProvider ui={{ ... }}>`). The same
|
|
24
|
+
* `network` / `modules` / `picker` opts power both, so the picker shows the
|
|
25
|
+
* exact wallets that signing will actually work with.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { createStellarWalletsKitBundle } from '@pollar/stellar-wallets-kit-adapter/picker';
|
|
30
|
+
* import { Networks } from '@creit.tech/stellar-wallets-kit';
|
|
31
|
+
*
|
|
32
|
+
* const bundle = createStellarWalletsKitBundle({
|
|
33
|
+
* network: Networks.PUBLIC,
|
|
34
|
+
* picker: { wallets: ['xbull', 'lobstr', 'freighter'] },
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* <PollarProvider
|
|
38
|
+
* client={{ apiKey: '…', walletAdapter: bundle.walletAdapter }}
|
|
39
|
+
* ui={{ renderWallets: bundle.renderWallets }}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function createStellarWalletsKitBundle(options: StellarWalletsKitAdapterOptions): StellarWalletsKitBundle;
|
|
44
|
+
|
|
45
|
+
export { KitWalletPicker, type KitWalletPickerProps, type StellarWalletsKitBundle, createStellarWalletsKitBundle };
|
package/dist/picker.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stellarWalletsKit$1 = require('@creit.tech/stellar-wallets-kit');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var albedo = require('@creit.tech/stellar-wallets-kit/modules/albedo');
|
|
6
|
+
var bitget = require('@creit.tech/stellar-wallets-kit/modules/bitget');
|
|
7
|
+
var cactuslink = require('@creit.tech/stellar-wallets-kit/modules/cactuslink');
|
|
8
|
+
var fordefi = require('@creit.tech/stellar-wallets-kit/modules/fordefi');
|
|
9
|
+
var freighter = require('@creit.tech/stellar-wallets-kit/modules/freighter');
|
|
10
|
+
var hana = require('@creit.tech/stellar-wallets-kit/modules/hana');
|
|
11
|
+
var hotwallet = require('@creit.tech/stellar-wallets-kit/modules/hotwallet');
|
|
12
|
+
var klever = require('@creit.tech/stellar-wallets-kit/modules/klever');
|
|
13
|
+
var lobstr = require('@creit.tech/stellar-wallets-kit/modules/lobstr');
|
|
14
|
+
var onekey = require('@creit.tech/stellar-wallets-kit/modules/onekey');
|
|
15
|
+
var rabet = require('@creit.tech/stellar-wallets-kit/modules/rabet');
|
|
16
|
+
var xbull = require('@creit.tech/stellar-wallets-kit/modules/xbull');
|
|
17
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
18
|
+
|
|
19
|
+
// src/picker/KitWalletPicker.tsx
|
|
20
|
+
var StellarWalletsKitAdapter = class {
|
|
21
|
+
constructor(walletId) {
|
|
22
|
+
this._address = null;
|
|
23
|
+
this.type = walletId;
|
|
24
|
+
}
|
|
25
|
+
async isAvailable() {
|
|
26
|
+
try {
|
|
27
|
+
const supported = await stellarWalletsKit$1.StellarWalletsKit.refreshSupportedWallets();
|
|
28
|
+
const wallet = supported.find((w) => w.id === String(this.type));
|
|
29
|
+
return wallet?.isAvailable ?? false;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.warn(`[StellarWalletsKit] isAvailable probe failed for "${this.type}"`, err);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async connect() {
|
|
36
|
+
stellarWalletsKit$1.StellarWalletsKit.setWallet(String(this.type));
|
|
37
|
+
const { address } = await stellarWalletsKit$1.StellarWalletsKit.fetchAddress();
|
|
38
|
+
if (!address) {
|
|
39
|
+
throw new Error(`[StellarWalletsKit] Empty address returned for wallet "${this.type}"`);
|
|
40
|
+
}
|
|
41
|
+
this._address = address;
|
|
42
|
+
return { address, publicKey: address };
|
|
43
|
+
}
|
|
44
|
+
async disconnect() {
|
|
45
|
+
try {
|
|
46
|
+
await stellarWalletsKit$1.StellarWalletsKit.disconnect();
|
|
47
|
+
} finally {
|
|
48
|
+
this._address = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async getPublicKey() {
|
|
52
|
+
if (this._address) return this._address;
|
|
53
|
+
try {
|
|
54
|
+
const { address } = await stellarWalletsKit$1.StellarWalletsKit.getAddress();
|
|
55
|
+
this._address = address ?? null;
|
|
56
|
+
return this._address;
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async signTransaction(xdr, options) {
|
|
62
|
+
if (options?.networkPassphrase !== void 0 && options.networkPassphrase !== getInitNetwork()) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`[StellarWalletsKit] networkPassphrase override "${options.networkPassphrase}" does not match the network configured at init ("${getInitNetwork()}"). The kit is a global singleton \u2014 configure one network at \`stellarWalletsKit({ network })\` and use that for every call.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
stellarWalletsKit$1.StellarWalletsKit.setWallet(String(this.type));
|
|
68
|
+
const result = await stellarWalletsKit$1.StellarWalletsKit.signTransaction(xdr, {
|
|
69
|
+
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
70
|
+
});
|
|
71
|
+
return { signedTxXdr: result.signedTxXdr };
|
|
72
|
+
}
|
|
73
|
+
async signAuthEntry(entryXdr, options) {
|
|
74
|
+
stellarWalletsKit$1.StellarWalletsKit.setWallet(String(this.type));
|
|
75
|
+
const result = await stellarWalletsKit$1.StellarWalletsKit.signAuthEntry(entryXdr, {
|
|
76
|
+
...options?.accountToSign !== void 0 && { address: options.accountToSign }
|
|
77
|
+
});
|
|
78
|
+
return { signedAuthEntry: result.signedAuthEntry };
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/factory.ts
|
|
83
|
+
var initialised = false;
|
|
84
|
+
var initNetwork = null;
|
|
85
|
+
function buildDefaultModules() {
|
|
86
|
+
return [
|
|
87
|
+
new albedo.AlbedoModule(),
|
|
88
|
+
new bitget.BitgetModule(),
|
|
89
|
+
new cactuslink.CactusLinkModule(),
|
|
90
|
+
new fordefi.FordefiModule(),
|
|
91
|
+
new freighter.FreighterModule(),
|
|
92
|
+
new hana.HanaModule(),
|
|
93
|
+
new hotwallet.HotWalletModule(),
|
|
94
|
+
new klever.KleverModule(),
|
|
95
|
+
new lobstr.LobstrModule(),
|
|
96
|
+
new onekey.OneKeyModule(),
|
|
97
|
+
new rabet.RabetModule(),
|
|
98
|
+
new xbull.xBullModule()
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
function ensureInit(options) {
|
|
102
|
+
if (initialised) {
|
|
103
|
+
if (options.network && options.network !== initNetwork) {
|
|
104
|
+
console.warn(
|
|
105
|
+
`[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
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!options.network) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
"[StellarWalletsKit] `network` is required \u2014 pass `Networks.TESTNET` or `Networks.PUBLIC` to `stellarWalletsKit({ network })`. The kit is a global singleton, so the network has to be chosen explicitly at init."
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
stellarWalletsKit$1.StellarWalletsKit.init({
|
|
116
|
+
network: options.network,
|
|
117
|
+
modules: options.modules ?? buildDefaultModules()
|
|
118
|
+
});
|
|
119
|
+
initNetwork = options.network;
|
|
120
|
+
initialised = true;
|
|
121
|
+
}
|
|
122
|
+
function getInitNetwork() {
|
|
123
|
+
if (initNetwork === null) {
|
|
124
|
+
throw new Error("[StellarWalletsKit] not initialised \u2014 call `stellarWalletsKit({ network })` first");
|
|
125
|
+
}
|
|
126
|
+
return initNetwork;
|
|
127
|
+
}
|
|
128
|
+
function stellarWalletsKit(options) {
|
|
129
|
+
return (id) => {
|
|
130
|
+
ensureInit(options);
|
|
131
|
+
return new StellarWalletsKitAdapter(id);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
var CONNECTING_STEPS = /* @__PURE__ */ new Set(["connecting_wallet", "authenticating_wallet", "authenticating"]);
|
|
135
|
+
function KitWalletPicker({ onConnect, authState, network, modules, picker = {} }) {
|
|
136
|
+
const [wallets, setWallets] = react.useState(null);
|
|
137
|
+
const warnedRef = react.useRef(/* @__PURE__ */ new Set());
|
|
138
|
+
react.useEffect(() => {
|
|
139
|
+
let cancelled = false;
|
|
140
|
+
const initOpts = {};
|
|
141
|
+
if (network !== void 0) initOpts.network = network;
|
|
142
|
+
if (modules !== void 0) initOpts.modules = modules;
|
|
143
|
+
ensureInit(initOpts);
|
|
144
|
+
stellarWalletsKit$1.StellarWalletsKit.refreshSupportedWallets().then((list) => {
|
|
145
|
+
if (cancelled) return;
|
|
146
|
+
setWallets(list);
|
|
147
|
+
}).catch((err) => {
|
|
148
|
+
console.error("[KitWalletPicker] refreshSupportedWallets failed", err);
|
|
149
|
+
if (!cancelled) setWallets([]);
|
|
150
|
+
});
|
|
151
|
+
return () => {
|
|
152
|
+
cancelled = true;
|
|
153
|
+
};
|
|
154
|
+
}, [network, modules]);
|
|
155
|
+
const filtered = react.useMemo(() => {
|
|
156
|
+
if (!wallets) return null;
|
|
157
|
+
const { wallets: allowedIds, order = "as-given", showInstalledOnly = false, labels } = picker;
|
|
158
|
+
const byId = new Map(wallets.map((w) => [w.id, w]));
|
|
159
|
+
let result;
|
|
160
|
+
if (allowedIds && allowedIds.length > 0) {
|
|
161
|
+
result = [];
|
|
162
|
+
for (const id of allowedIds) {
|
|
163
|
+
const w = byId.get(id);
|
|
164
|
+
if (w) {
|
|
165
|
+
result.push(w);
|
|
166
|
+
} else if (!warnedRef.current.has(id)) {
|
|
167
|
+
warnedRef.current.add(id);
|
|
168
|
+
console.warn(`[KitWalletPicker] wallet id "${id}" not present in the active kit modules \u2014 skipped`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
result = [...wallets];
|
|
173
|
+
}
|
|
174
|
+
if (showInstalledOnly) {
|
|
175
|
+
result = result.filter((w) => w.isAvailable);
|
|
176
|
+
}
|
|
177
|
+
if (order === "alphabetical") {
|
|
178
|
+
result = [...result].sort((a, b) => labelOf(a, labels).localeCompare(labelOf(b, labels)));
|
|
179
|
+
} else if (order === "installed-first") {
|
|
180
|
+
result = [...result].sort((a, b) => {
|
|
181
|
+
if (a.isAvailable === b.isAvailable) return 0;
|
|
182
|
+
return a.isAvailable ? -1 : 1;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}, [wallets, picker]);
|
|
187
|
+
const isBusy = CONNECTING_STEPS.has(authState.step);
|
|
188
|
+
const layout = picker.layout ?? "grid";
|
|
189
|
+
const theme = picker.theme;
|
|
190
|
+
const rootStyle = {
|
|
191
|
+
display: layout === "list" ? "flex" : "grid",
|
|
192
|
+
flexDirection: layout === "list" ? "column" : void 0,
|
|
193
|
+
gridTemplateColumns: layout === "grid" ? "repeat(auto-fill, minmax(140px, 1fr))" : void 0,
|
|
194
|
+
gap: "0.5rem",
|
|
195
|
+
width: "100%",
|
|
196
|
+
...theme?.accent !== void 0 && { ["--pollar-accent"]: theme.accent },
|
|
197
|
+
...theme?.mode === "dark" && { colorScheme: "dark" }
|
|
198
|
+
};
|
|
199
|
+
if (filtered === null) {
|
|
200
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "status", "aria-busy": "true", style: { padding: "1rem", textAlign: "center", fontSize: "0.9rem" }, children: "Loading wallets\u2026" });
|
|
201
|
+
}
|
|
202
|
+
if (filtered.length === 0) {
|
|
203
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "1rem", textAlign: "center", fontSize: "0.9rem" }, children: picker.showInstalledOnly ? "No supported Stellar wallets detected. Install Freighter / xBull / Lobstr to continue." : "No wallets to show." });
|
|
204
|
+
}
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: rootStyle, children: filtered.map((w) => {
|
|
206
|
+
const label = labelOf(w, picker.labels);
|
|
207
|
+
const disabled = isBusy || (picker.showInstalledOnly ? false : !w.isAvailable);
|
|
208
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
disabled,
|
|
213
|
+
onClick: () => onConnect(w.id),
|
|
214
|
+
style: buttonStyle(layout, disabled),
|
|
215
|
+
title: !w.isAvailable && !picker.showInstalledOnly ? `${label} not detected` : label,
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: w.icon, alt: "", width: 32, height: 32, style: { borderRadius: 6, opacity: w.isAvailable ? 1 : 0.5 } }),
|
|
218
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "0.85rem", fontWeight: 500 }, children: label }),
|
|
219
|
+
!w.isAvailable && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "0.7rem", opacity: 0.6 }, children: "not installed" })
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
w.id
|
|
223
|
+
);
|
|
224
|
+
}) });
|
|
225
|
+
}
|
|
226
|
+
function labelOf(w, labels) {
|
|
227
|
+
return labels?.[w.id] ?? w.name;
|
|
228
|
+
}
|
|
229
|
+
function buttonStyle(layout, disabled) {
|
|
230
|
+
const base = {
|
|
231
|
+
display: "flex",
|
|
232
|
+
alignItems: "center",
|
|
233
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
234
|
+
opacity: disabled ? 0.55 : 1,
|
|
235
|
+
background: "transparent",
|
|
236
|
+
border: "1px solid var(--pollar-border, #e5e7eb)",
|
|
237
|
+
borderRadius: "var(--pollar-buttons-border-radius, 6px)",
|
|
238
|
+
color: "var(--pollar-text, inherit)",
|
|
239
|
+
padding: "0.6rem",
|
|
240
|
+
gap: "0.6rem"
|
|
241
|
+
};
|
|
242
|
+
if (layout === "list") {
|
|
243
|
+
return { ...base, justifyContent: "flex-start", width: "100%", height: "var(--pollar-buttons-height, 44px)" };
|
|
244
|
+
}
|
|
245
|
+
return { ...base, flexDirection: "column", justifyContent: "center", textAlign: "center", minHeight: 92 };
|
|
246
|
+
}
|
|
247
|
+
function createStellarWalletsKitBundle(options) {
|
|
248
|
+
const walletAdapter = stellarWalletsKit(options);
|
|
249
|
+
const renderWallets = (slot) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
250
|
+
KitWalletPicker,
|
|
251
|
+
{
|
|
252
|
+
onConnect: slot.onConnect,
|
|
253
|
+
authState: slot.authState,
|
|
254
|
+
network: options.network,
|
|
255
|
+
...options.modules !== void 0 && { modules: options.modules },
|
|
256
|
+
...options.picker !== void 0 && { picker: options.picker }
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
return { walletAdapter, renderWallets };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
exports.KitWalletPicker = KitWalletPicker;
|
|
263
|
+
exports.createStellarWalletsKitBundle = createStellarWalletsKitBundle;
|
|
264
|
+
//# sourceMappingURL=picker.js.map
|
|
265
|
+
//# sourceMappingURL=picker.js.map
|
|
@@ -0,0 +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,C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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 } 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, publicKey: 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 // Honor `as-given` order from the allowedIds; warn once for unknowns.\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"]}
|