@txnlab/use-wallet-solid 3.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.jsx ADDED
@@ -0,0 +1,3164 @@
1
+ import {
2
+ esm_default,
3
+ init_esm
4
+ } from "./chunk/NK6TZ2ZJ.jsx";
5
+ import "./chunk/2PWOQULK.jsx";
6
+ import "./chunk/PIH3UREM.jsx";
7
+
8
+ // ../../node_modules/.pnpm/@tanstack+store@0.3.1/node_modules/@tanstack/store/dist/esm/index.js
9
+ var Store = class {
10
+ constructor(initialState, options) {
11
+ this.listeners = /* @__PURE__ */ new Set();
12
+ this._batching = false;
13
+ this._flushing = 0;
14
+ this.subscribe = (listener) => {
15
+ var _a, _b;
16
+ this.listeners.add(listener);
17
+ const unsub = (_b = (_a = this.options) == null ? void 0 : _a.onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
18
+ return () => {
19
+ this.listeners.delete(listener);
20
+ unsub == null ? void 0 : unsub();
21
+ };
22
+ };
23
+ this.setState = (updater) => {
24
+ var _a, _b, _c;
25
+ const previous = this.state;
26
+ this.state = ((_a = this.options) == null ? void 0 : _a.updateFn) ? this.options.updateFn(previous)(updater) : updater(previous);
27
+ (_c = (_b = this.options) == null ? void 0 : _b.onUpdate) == null ? void 0 : _c.call(_b);
28
+ this._flush();
29
+ };
30
+ this._flush = () => {
31
+ if (this._batching)
32
+ return;
33
+ const flushId = ++this._flushing;
34
+ this.listeners.forEach((listener) => {
35
+ if (this._flushing !== flushId)
36
+ return;
37
+ listener();
38
+ });
39
+ };
40
+ this.batch = (cb) => {
41
+ if (this._batching)
42
+ return cb();
43
+ this._batching = true;
44
+ cb();
45
+ this._batching = false;
46
+ this._flush();
47
+ };
48
+ this.state = initialState;
49
+ this.options = options;
50
+ }
51
+ };
52
+
53
+ // ../use-wallet/dist/index.js
54
+ init_esm();
55
+ init_esm();
56
+ init_esm();
57
+ init_esm();
58
+ init_esm();
59
+ init_esm();
60
+ init_esm();
61
+ init_esm();
62
+ init_esm();
63
+ init_esm();
64
+ var NetworkId = /* @__PURE__ */ ((NetworkId2) => {
65
+ NetworkId2["MAINNET"] = "mainnet";
66
+ NetworkId2["TESTNET"] = "testnet";
67
+ NetworkId2["BETANET"] = "betanet";
68
+ NetworkId2["LOCALNET"] = "localnet";
69
+ return NetworkId2;
70
+ })(NetworkId || {});
71
+ function isValidNetworkId(networkId) {
72
+ return Object.values(NetworkId).includes(networkId);
73
+ }
74
+ function isNetworkConfigMap(config) {
75
+ const networkKeys = Object.values(NetworkId);
76
+ return Object.keys(config).some((key) => networkKeys.includes(key));
77
+ }
78
+ var nodeServerMap = {
79
+ [
80
+ "mainnet"
81
+ /* MAINNET */
82
+ ]: "https://mainnet-api.algonode.cloud",
83
+ [
84
+ "testnet"
85
+ /* TESTNET */
86
+ ]: "https://testnet-api.algonode.cloud",
87
+ [
88
+ "betanet"
89
+ /* BETANET */
90
+ ]: "https://betanet-api.algonode.cloud"
91
+ };
92
+ function createDefaultNetworkConfig() {
93
+ const localnetConfig = {
94
+ token: "a".repeat(64),
95
+ baseServer: "http://localhost",
96
+ port: 4001,
97
+ headers: {}
98
+ };
99
+ return Object.values(NetworkId).reduce((configMap, value) => {
100
+ const network = value;
101
+ const isLocalnet = network === "localnet";
102
+ configMap[network] = isLocalnet ? localnetConfig : {
103
+ token: "",
104
+ baseServer: nodeServerMap[network],
105
+ port: "",
106
+ headers: {}
107
+ };
108
+ return configMap;
109
+ }, {});
110
+ }
111
+ var caipChainId = {
112
+ [
113
+ "mainnet"
114
+ /* MAINNET */
115
+ ]: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k",
116
+ [
117
+ "testnet"
118
+ /* TESTNET */
119
+ ]: "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe",
120
+ [
121
+ "betanet"
122
+ /* BETANET */
123
+ ]: "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2"
124
+ };
125
+ var StorageAdapter = class {
126
+ static getItem(key) {
127
+ if (typeof window === "undefined") {
128
+ return null;
129
+ }
130
+ return localStorage.getItem(key);
131
+ }
132
+ static setItem(key, value) {
133
+ if (typeof window === "undefined") {
134
+ return;
135
+ }
136
+ localStorage.setItem(key, value);
137
+ }
138
+ };
139
+ var BaseWallet = class {
140
+ id;
141
+ metadata;
142
+ store;
143
+ getAlgodClient;
144
+ subscribe;
145
+ constructor({
146
+ id,
147
+ metadata,
148
+ store,
149
+ subscribe,
150
+ getAlgodClient
151
+ }) {
152
+ this.id = id;
153
+ this.store = store;
154
+ this.subscribe = subscribe;
155
+ this.getAlgodClient = getAlgodClient;
156
+ const ctor = this.constructor;
157
+ this.metadata = { ...ctor.defaultMetadata, ...metadata };
158
+ }
159
+ static defaultMetadata = { name: "Base Wallet", icon: "" };
160
+ setActive = () => {
161
+ console.info(`[Wallet] Set active wallet: ${this.id}`);
162
+ setActiveWallet(this.store, { walletId: this.id });
163
+ };
164
+ setActiveAccount = (account) => {
165
+ console.info(`[Wallet] Set active account: ${account}`);
166
+ setActiveAccount(this.store, {
167
+ walletId: this.id,
168
+ address: account
169
+ });
170
+ };
171
+ // ---------- Derived Properties ------------------------------------ //
172
+ get name() {
173
+ return this.id.toUpperCase();
174
+ }
175
+ get accounts() {
176
+ const state = this.store.state;
177
+ const walletState = state.wallets[this.id];
178
+ return walletState ? walletState.accounts : [];
179
+ }
180
+ get addresses() {
181
+ return this.accounts.map((account) => account.address);
182
+ }
183
+ get activeAccount() {
184
+ const state = this.store.state;
185
+ const walletState = state.wallets[this.id];
186
+ return walletState ? walletState.activeAccount : null;
187
+ }
188
+ get activeAddress() {
189
+ return this.activeAccount?.address ?? null;
190
+ }
191
+ get activeNetwork() {
192
+ const state = this.store.state;
193
+ return state.activeNetwork;
194
+ }
195
+ get isConnected() {
196
+ const state = this.store.state;
197
+ const walletState = state.wallets[this.id];
198
+ return walletState ? walletState.accounts.length > 0 : false;
199
+ }
200
+ get isActive() {
201
+ const state = this.store.state;
202
+ return state.activeWallet === this.id;
203
+ }
204
+ // ---------- Protected Methods ------------------------------------- //
205
+ onDisconnect() {
206
+ removeWallet(this.store, { walletId: this.id });
207
+ }
208
+ };
209
+ var WalletId = /* @__PURE__ */ ((WalletId2) => {
210
+ WalletId2["DEFLY"] = "defly";
211
+ WalletId2["EXODUS"] = "exodus";
212
+ WalletId2["KIBISIS"] = "kibisis";
213
+ WalletId2["KMD"] = "kmd";
214
+ WalletId2["LUTE"] = "lute";
215
+ WalletId2["MNEMONIC"] = "mnemonic";
216
+ WalletId2["PERA"] = "pera";
217
+ WalletId2["WALLETCONNECT"] = "walletconnect";
218
+ return WalletId2;
219
+ })(WalletId || {});
220
+ var icon = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjUuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMDAgMzAwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAzMDAgMzAwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6dXJsKCNTVkdJRF8xXyk7fQoJLnN0MXtmaWxsOnVybCgjU1ZHSURfMDAwMDAwNDM0MjYxNjcxNDAxMDY1ODIyNzAwMDAwMDIxMzA3Njg5MDYwNzMxMTM0ODRfKTt9Cgkuc3Qye2Zp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bG9yOiM4OTUyRkY7c3RvcC1vcGFjaXR5OjAuODciLz4KCQkJPHN0b3AgIG9mZnNldD0iMSIgc3R5bGU9InN0b3AtY29sb3I6I0RBQkRGRjtzdG9wLW9wYWNpdHk6MCIvPgoJCTwvbGluZWFyR3JhZGllbnQ+CgkJCgkJCTxyZWN0IHg9IjI1LjQiIHk9IjIzIiBzdHlsZT0iZmlsbDp1cmwoI1NWR0lEXzAwMDAwMTA5MDE5OTE4NTU3NzczMDUzNDIwMDAwMDE3NjAyNDA1OTA4MDY3MTIwMzAwXyk7IiB3aWR0aD0iMjQ3LjYiIGhlaWdodD0iMjU0Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg==";
221
+ var ExodusWallet = class extends BaseWallet {
222
+ client = null;
223
+ options;
224
+ store;
225
+ constructor({
226
+ id,
227
+ store,
228
+ subscribe,
229
+ getAlgodClient,
230
+ options = {},
231
+ metadata = {}
232
+ }) {
233
+ super({ id, metadata, getAlgodClient, store, subscribe });
234
+ this.options = options;
235
+ this.store = store;
236
+ }
237
+ static defaultMetadata = { name: "Exodus", icon };
238
+ async initializeClient() {
239
+ console.info("[ExodusWallet] Initializing client...");
240
+ if (typeof window === "undefined" || window.algorand === void 0) {
241
+ throw new Error("Exodus is not available.");
242
+ }
243
+ const client = window.algorand;
244
+ this.client = client;
245
+ return client;
246
+ }
247
+ connect = async () => {
248
+ console.info("[ExodusWallet] Connecting...");
249
+ try {
250
+ const client = this.client || await this.initializeClient();
251
+ const { accounts } = await client.enable(this.options);
252
+ if (accounts.length === 0) {
253
+ throw new Error("No accounts found!");
254
+ }
255
+ const walletAccounts = accounts.map((address, idx) => ({
256
+ name: `Exodus Wallet ${idx + 1}`,
257
+ address
258
+ }));
259
+ const activeAccount = walletAccounts[0];
260
+ addWallet(this.store, {
261
+ walletId: this.id,
262
+ wallet: {
263
+ accounts: walletAccounts,
264
+ activeAccount
265
+ }
266
+ });
267
+ return walletAccounts;
268
+ } catch (error) {
269
+ if (error.name === "UserRejectedRequestError") {
270
+ console.info("[ExodusWallet] Connection cancelled.");
271
+ } else {
272
+ console.error(`[ExodusWallet] Error connecting: ${error.message}`);
273
+ }
274
+ return [];
275
+ }
276
+ };
277
+ disconnect = async () => {
278
+ console.info("[ExodusWallet] Disconnecting...");
279
+ this.onDisconnect();
280
+ };
281
+ resumeSession = async () => {
282
+ try {
283
+ const state = this.store.state;
284
+ const walletState = state.wallets[this.id];
285
+ if (!walletState) {
286
+ return;
287
+ }
288
+ console.info("[ExodusWallet] Resuming session...");
289
+ const client = await this.initializeClient();
290
+ if (!client.isConnected) {
291
+ throw new Error("Exodus is not connected.");
292
+ }
293
+ } catch (error) {
294
+ console.error(`[ExodusWallet] Error resuming session: ${error.message}`);
295
+ this.onDisconnect();
296
+ }
297
+ };
298
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
299
+ if (!this.client) {
300
+ throw new Error("[ExodusWallet] Client not initialized!");
301
+ }
302
+ const txnsToSign = [];
303
+ const signedIndexes = [];
304
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
305
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
306
+ return esm_default.decodeObj(txn);
307
+ });
308
+ decodedObjects.forEach((txnObject, idx) => {
309
+ const isSigned = isSignedTxnObject(txnObject);
310
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
311
+ const txnBuffer = msgpackTxnGroup[idx];
312
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
313
+ const txnBase64 = byteArrayToBase64(txn.toByte());
314
+ if (shouldSign) {
315
+ txnsToSign.push({ txn: txnBase64 });
316
+ signedIndexes.push(idx);
317
+ } else {
318
+ txnsToSign.push({ txn: txnBase64, signers: [] });
319
+ }
320
+ });
321
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
322
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
323
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
324
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
325
+ signedTxns,
326
+ msgpackTxnGroup,
327
+ signedIndexes,
328
+ returnGroup
329
+ );
330
+ return txnGroupSigned;
331
+ };
332
+ transactionSigner = async (txnGroup, indexesToSign) => {
333
+ if (!this.client) {
334
+ throw new Error("[ExodusWallet] Client not initialized!");
335
+ }
336
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
337
+ const txnBase64 = byteArrayToBase64(txn.toByte());
338
+ if (indexesToSign.includes(idx)) {
339
+ acc.push({ txn: txnBase64 });
340
+ } else {
341
+ acc.push({ txn: txnBase64, signers: [] });
342
+ }
343
+ return acc;
344
+ }, []);
345
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
346
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
347
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
348
+ return signedTxns;
349
+ };
350
+ };
351
+ var ARC_0027_PREFIX = "arc0027";
352
+ var ARC_0027_CHANNEL_NAME = `${ARC_0027_PREFIX}:channel`;
353
+ var ARC_0027_ENABLE_REQUEST = `${ARC_0027_PREFIX}:enable:request`;
354
+ var ARC_0027_GET_PROVIDERS_REQUEST = `${ARC_0027_PREFIX}:get_providers:request`;
355
+ var ARC_0027_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
356
+ var ARC_0027_SIGN_TXNS_REQUEST = `${ARC_0027_PREFIX}:sign_txns:request`;
357
+ var UNKNOWN_ERROR = 4e3;
358
+ var METHOD_TIMED_OUT_ERROR = 4002;
359
+ var METHOD_NOT_SUPPORTED_ERROR = 4003;
360
+ var NETWORK_NOT_SUPPORTED_ERROR = 4004;
361
+ var DEFAULT_REQUEST_TIMEOUT = 18e4;
362
+ var LOWER_REQUEST_TIMEOUT = 750;
363
+ var icon2 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kY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jI3NzQ4LC0xLjk0NjIgLTIwLjMzMzcyLC0xNy4wNDQ2OSAtMjMuOTY2MzIsLTE4Ljk4ODggLTEuNTQyOTMsLTAuODI1NzUgLTMuNjAyMTIsLTIuMjc5NDMgLTQuNTc1OTYsLTMuMjMwMzkgLTMuNDkwNDEsLTMuNDA4MzYgLTIxLjgzNjgzLC0xMy4yMTIyNiAtMjUuMTAzOTcsLTEzLjQxNDk2IGwgLTMuMzMzMzMsLTAuMjA2ODEgLTAuMzM4MDEsMTg1IC0wLjMzODAyLDE4NC45OTk5NSBoIDI5LjMzODAxIDI5LjMzODAyIHoiCiAgICBmaWxsPSIjOGMwMTlhIiAvPgo8L3N2Zz4K";
364
+ function isResponseError(error) {
365
+ return typeof error === "object" && "code" in error && "message" in error;
366
+ }
367
+ var KibisisWallet = class _KibisisWallet extends BaseWallet {
368
+ methods = [];
369
+ store;
370
+ constructor({
371
+ id,
372
+ store,
373
+ subscribe,
374
+ getAlgodClient,
375
+ metadata = {}
376
+ }) {
377
+ super({ id, metadata, getAlgodClient, store, subscribe });
378
+ this.store = store;
379
+ }
380
+ static defaultMetadata = {
381
+ name: "Kibisis",
382
+ icon: icon2
383
+ };
384
+ static async sendRequestWithTimeout({
385
+ method,
386
+ params,
387
+ timeout,
388
+ reference
389
+ }) {
390
+ return new Promise((resolve, reject) => {
391
+ const channel = new BroadcastChannel(ARC_0027_CHANNEL_NAME);
392
+ const requestId = generateUuid();
393
+ let timer;
394
+ channel.onmessage = (message) => {
395
+ if (!message.data || message.data.requestId !== requestId) {
396
+ return;
397
+ }
398
+ window.clearTimeout(timer);
399
+ if (message.data.error) {
400
+ reject(message.data.error);
401
+ return channel.close();
402
+ }
403
+ resolve(message.data.result);
404
+ return channel.close();
405
+ };
406
+ timer = window.setTimeout(() => {
407
+ channel.close();
408
+ reject({
409
+ code: METHOD_TIMED_OUT_ERROR,
410
+ data: {
411
+ method
412
+ },
413
+ message: `No response from provider "${"kibisis".toUpperCase()}"`,
414
+ providerId: ARC_0027_PROVIDER_ID
415
+ });
416
+ }, timeout || DEFAULT_REQUEST_TIMEOUT);
417
+ channel.postMessage({
418
+ id: requestId,
419
+ params,
420
+ reference
421
+ });
422
+ });
423
+ }
424
+ /**
425
+ * Calls the enable method on the provider that returns the authorized accounts.
426
+ * @returns {Arc0027Account[]} the authorized accounts.
427
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
428
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
429
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
430
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
431
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
432
+ */
433
+ async enable() {
434
+ const method = "enable";
435
+ this.validateMethod(method);
436
+ const genesisHash = await this.getGenesisHash();
437
+ const result = await _KibisisWallet.sendRequestWithTimeout({
438
+ method,
439
+ params: {
440
+ genesisHash,
441
+ providerId: ARC_0027_PROVIDER_ID
442
+ },
443
+ reference: ARC_0027_ENABLE_REQUEST
444
+ });
445
+ if (!result) {
446
+ throw {
447
+ code: UNKNOWN_ERROR,
448
+ message: `Received response, but "${method}" request details were empty for provider "${this.name}"`,
449
+ providerId: ARC_0027_PROVIDER_ID
450
+ };
451
+ }
452
+ return result.accounts;
453
+ }
454
+ /**
455
+ * Gets the genesis hash of the algod client's configured network.
456
+ * @returns {string} the genesis hash
457
+ */
458
+ async getGenesisHash() {
459
+ const algodClient = this.getAlgodClient();
460
+ const version = await algodClient.versionsCheck().do();
461
+ const genesisHash = version.genesis_hash_b64;
462
+ return genesisHash;
463
+ }
464
+ /**
465
+ * Gets the provider information and updates the supported methods. This should be called
466
+ * before interacting with the provider to ensure methods are supported.
467
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
468
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
469
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
470
+ */
471
+ async getSupportedMethods() {
472
+ const genesisHash = await this.getGenesisHash();
473
+ const result = await _KibisisWallet.sendRequestWithTimeout({
474
+ method: "getProviders",
475
+ params: {
476
+ providerId: ARC_0027_PROVIDER_ID
477
+ },
478
+ reference: ARC_0027_GET_PROVIDERS_REQUEST,
479
+ timeout: LOWER_REQUEST_TIMEOUT
480
+ });
481
+ if (!result) {
482
+ throw {
483
+ code: UNKNOWN_ERROR,
484
+ message: `Received response, but provider details were empty for provider "${this.name}"`,
485
+ providerId: ARC_0027_PROVIDER_ID
486
+ };
487
+ }
488
+ const networkConfiguration = result.networks.find((value) => value.genesisHash === genesisHash);
489
+ if (!networkConfiguration) {
490
+ throw {
491
+ code: NETWORK_NOT_SUPPORTED_ERROR,
492
+ data: {
493
+ genesisHash
494
+ },
495
+ message: `Network "${this.activeNetwork}" not supported on provider "${this.name}"`,
496
+ providerId: ARC_0027_PROVIDER_ID
497
+ };
498
+ }
499
+ this.methods = networkConfiguration.methods;
500
+ }
501
+ /**
502
+ * Calls the signTxns methods to sign the supplied transactions.
503
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
504
+ * @returns {(string | null)[]} the authorized accounts.
505
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
506
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
507
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
508
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
509
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
510
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
511
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
512
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
513
+ */
514
+ async signTxns(txns) {
515
+ const method = "signTxns";
516
+ this.validateMethod(method);
517
+ const result = await _KibisisWallet.sendRequestWithTimeout({
518
+ method,
519
+ params: {
520
+ providerId: ARC_0027_PROVIDER_ID,
521
+ txns
522
+ },
523
+ reference: ARC_0027_SIGN_TXNS_REQUEST
524
+ });
525
+ if (!result) {
526
+ throw {
527
+ code: UNKNOWN_ERROR,
528
+ message: `Received response, but "${method}" request details were empty for provider "${this.name}"`,
529
+ providerId: ARC_0027_PROVIDER_ID
530
+ };
531
+ }
532
+ return result.stxns;
533
+ }
534
+ /**
535
+ * Validates whether a method is supported with the provider.
536
+ * @param {ProviderMethod} method - the method to validate.
537
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
538
+ */
539
+ validateMethod(method) {
540
+ if (!this.methods.includes(method)) {
541
+ throw {
542
+ code: METHOD_NOT_SUPPORTED_ERROR,
543
+ data: {
544
+ method
545
+ },
546
+ message: `"${method}" operation not supported on "${this.activeNetwork}" for provider "${this.name}"`,
547
+ providerId: ARC_0027_PROVIDER_ID
548
+ };
549
+ }
550
+ }
551
+ connect = async () => {
552
+ console.info("[KibisisWallet] Connecting...");
553
+ try {
554
+ await this.getSupportedMethods();
555
+ const accounts = await this.enable();
556
+ const walletAccounts = accounts.map(({ address, name }, idx) => ({
557
+ name: name || `Kibisis Wallet ${idx + 1}`,
558
+ address
559
+ }));
560
+ const activeAccount = walletAccounts[0];
561
+ addWallet(this.store, {
562
+ walletId: this.id,
563
+ wallet: {
564
+ accounts: walletAccounts,
565
+ activeAccount
566
+ }
567
+ });
568
+ return walletAccounts;
569
+ } catch (error) {
570
+ console.error(`[KibisisWallet] Error connecting: ${error.message}`);
571
+ return [];
572
+ }
573
+ };
574
+ disconnect = async () => {
575
+ console.info("[KibisisWallet] Disconnecting...");
576
+ this.onDisconnect();
577
+ };
578
+ resumeSession = () => {
579
+ return Promise.resolve();
580
+ };
581
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
582
+ try {
583
+ await this.getSupportedMethods();
584
+ const txnsToSign = [];
585
+ const signedIndexes = [];
586
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
587
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
588
+ return esm_default.decodeObj(txn);
589
+ });
590
+ decodedObjects.forEach((txnObject, idx) => {
591
+ const isSigned = isSignedTxnObject(txnObject);
592
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
593
+ const txnBuffer = msgpackTxnGroup[idx];
594
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
595
+ const txnBase64 = byteArrayToBase64(txn.toByte());
596
+ if (shouldSign) {
597
+ txnsToSign.push({ txn: txnBase64 });
598
+ signedIndexes.push(idx);
599
+ } else {
600
+ txnsToSign.push({ txn: txnBase64, signers: [] });
601
+ }
602
+ });
603
+ const signTxnsResult = await this.signTxns(txnsToSign);
604
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
605
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
606
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
607
+ signedTxns,
608
+ msgpackTxnGroup,
609
+ signedIndexes,
610
+ returnGroup
611
+ );
612
+ return txnGroupSigned;
613
+ } catch (error) {
614
+ console.error(
615
+ `[KibisisWallet] Error signing transactions: ` + (isResponseError(error) ? `${error.message} (code: ${error.code})` : error.message)
616
+ );
617
+ throw error;
618
+ }
619
+ };
620
+ transactionSigner = async (txnGroup, indexesToSign) => {
621
+ try {
622
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
623
+ const txnBase64 = byteArrayToBase64(txn.toByte());
624
+ if (indexesToSign.includes(idx)) {
625
+ acc.push({ txn: txnBase64 });
626
+ } else {
627
+ acc.push({ txn: txnBase64, signers: [] });
628
+ }
629
+ return acc;
630
+ }, []);
631
+ const signTxnsResult = await this.signTxns(txnsToSign);
632
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
633
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
634
+ return signedTxns;
635
+ } catch (error) {
636
+ console.error(
637
+ `[KibisisWallet] Error signing transactions: ` + (isResponseError(error) ? `${error.message} (code: ${error.code})` : error.message)
638
+ );
639
+ throw error;
640
+ }
641
+ };
642
+ };
643
+ var icon3 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MDkuODMgMjEwLjMzIj48dGV4dCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIDE2MS4zMSkiIHN0eWxlPSJmb250LWZhbWlseTpJQk1QbGV4U2Fucy1NZWRtLCAmYXBvcztJQk0gUGxleCBTYW5zJmFwb3M7OyBmb250LXNpemU6MTkwcHg7Ij48dHNwYW4geD0iMCIgeT0iMCI+S01EPC90c3Bhbj48L3RleHQ+PC9zdmc+";
644
+ var KmdWallet = class extends BaseWallet {
645
+ client = null;
646
+ options;
647
+ walletName;
648
+ walletId = "";
649
+ password = "";
650
+ store;
651
+ constructor({
652
+ id,
653
+ store,
654
+ subscribe,
655
+ getAlgodClient,
656
+ options,
657
+ metadata = {}
658
+ }) {
659
+ super({ id, metadata, getAlgodClient, store, subscribe });
660
+ const {
661
+ token = "a".repeat(64),
662
+ baseServer = "http://127.0.0.1",
663
+ port = 4002,
664
+ wallet = "unencrypted-default-wallet"
665
+ } = options || {};
666
+ this.options = { token, baseServer, port };
667
+ this.walletName = wallet;
668
+ this.store = store;
669
+ }
670
+ static defaultMetadata = { name: "KMD", icon: icon3 };
671
+ async initializeClient() {
672
+ console.info("[KmdWallet] Initializing client...");
673
+ const { token, baseServer, port } = this.options;
674
+ const client = new esm_default.Kmd(token, baseServer, port);
675
+ this.client = client;
676
+ return client;
677
+ }
678
+ connect = async () => {
679
+ console.info("[KmdWallet] Connecting...");
680
+ try {
681
+ if (!this.client) {
682
+ await this.initializeClient();
683
+ }
684
+ const walletId = this.walletId || await this.fetchWalletId();
685
+ const token = await this.fetchToken(walletId, this.getPassword());
686
+ const accounts = await this.fetchAccounts(token);
687
+ if (accounts.length === 0) {
688
+ throw new Error("No accounts found!");
689
+ }
690
+ const walletAccounts = accounts.map((address, idx) => ({
691
+ name: `KMD Wallet ${idx + 1}`,
692
+ address
693
+ }));
694
+ const activeAccount = walletAccounts[0];
695
+ addWallet(this.store, {
696
+ walletId: this.id,
697
+ wallet: {
698
+ accounts: walletAccounts,
699
+ activeAccount
700
+ }
701
+ });
702
+ await this.releaseToken(token);
703
+ return walletAccounts;
704
+ } catch (error) {
705
+ console.error("[KmdWallet] Error connecting:", error);
706
+ return [];
707
+ }
708
+ };
709
+ disconnect = async () => {
710
+ console.info("[KmdWallet] Disconnecting...");
711
+ this.onDisconnect();
712
+ };
713
+ resumeSession = async () => {
714
+ try {
715
+ const state = this.store.state;
716
+ const walletState = state.wallets[this.id];
717
+ if (!walletState) {
718
+ return;
719
+ }
720
+ console.info("[KmdWallet] Resuming session...");
721
+ await this.initializeClient();
722
+ } catch (error) {
723
+ console.error(`[KmdWallet] Error resuming session: ${error.message}`);
724
+ this.onDisconnect();
725
+ }
726
+ };
727
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
728
+ if (!this.client) {
729
+ throw new Error("[KmdWallet] Client not initialized!");
730
+ }
731
+ const walletId = this.walletId || await this.fetchWalletId();
732
+ const password = this.getPassword();
733
+ const token = await this.fetchToken(walletId, password);
734
+ const signTxnPromises = [];
735
+ const signedIndexes = [];
736
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
737
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
738
+ return esm_default.decodeObj(txn);
739
+ });
740
+ decodedObjects.forEach((txnObject, idx) => {
741
+ const isSigned = isSignedTxnObject(txnObject);
742
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
743
+ const txnBuffer = msgpackTxnGroup[idx];
744
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
745
+ if (shouldSign) {
746
+ signTxnPromises.push(this.client.signTransaction(token, password, txn));
747
+ signedIndexes.push(idx);
748
+ }
749
+ });
750
+ const signedTxns = await Promise.all(signTxnPromises);
751
+ await this.releaseToken(token);
752
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
753
+ signedTxns,
754
+ msgpackTxnGroup,
755
+ signedIndexes,
756
+ returnGroup
757
+ );
758
+ return txnGroupSigned;
759
+ };
760
+ transactionSigner = async (txnGroup, indexesToSign) => {
761
+ if (!this.client) {
762
+ throw new Error("[KmdWallet] Client not initialized!");
763
+ }
764
+ const walletId = this.walletId || await this.fetchWalletId();
765
+ const password = this.getPassword();
766
+ const token = await this.fetchToken(walletId, password);
767
+ const signTxnPromises = [];
768
+ txnGroup.forEach((txn, idx) => {
769
+ if (indexesToSign.includes(idx)) {
770
+ signTxnPromises.push(this.client.signTransaction(token, password, txn));
771
+ }
772
+ });
773
+ const signedTxns = await Promise.all(signTxnPromises);
774
+ return signedTxns;
775
+ };
776
+ async fetchWalletId() {
777
+ console.info("[KmdWallet] Fetching wallet data...");
778
+ if (!this.client) {
779
+ throw new Error("Client not initialized!");
780
+ }
781
+ const { wallets } = await this.client.listWallets();
782
+ const wallet = wallets.find((wallet2) => wallet2.name === this.walletName);
783
+ if (!wallet) {
784
+ throw new Error(`Wallet ${this.walletName} not found!`);
785
+ }
786
+ this.walletId = wallet.id;
787
+ return wallet.id;
788
+ }
789
+ async fetchToken(walletId, password) {
790
+ console.info("[KmdWallet] Fetching token...");
791
+ if (!this.client) {
792
+ throw new Error("Client not initialized!");
793
+ }
794
+ const { wallet_handle_token } = await this.client.initWalletHandle(
795
+ walletId,
796
+ password
797
+ );
798
+ return wallet_handle_token;
799
+ }
800
+ async fetchAccounts(token) {
801
+ console.info("[KmdWallet] Fetching accounts...");
802
+ if (!this.client) {
803
+ throw new Error("Client not initialized!");
804
+ }
805
+ const { addresses } = await this.client.listKeys(token);
806
+ return addresses;
807
+ }
808
+ async releaseToken(token) {
809
+ console.info("[KmdWallet] Releasing token...");
810
+ if (!this.client) {
811
+ throw new Error("Client not initialized!");
812
+ }
813
+ await this.client.releaseWalletHandle(token);
814
+ }
815
+ getPassword() {
816
+ if (this.password) {
817
+ return this.password;
818
+ }
819
+ const password = prompt("KMD password") || "";
820
+ this.password = password;
821
+ return password;
822
+ }
823
+ };
824
+ function isSignTxnsError(error) {
825
+ return error instanceof Error && "code" in error;
826
+ }
827
+ var svgIcon = `
828
+ <svg fill="#ab47bc" version="1.1" viewBox="0 0 1e3 1e3" xmlns="http://www.w3.org/2000/svg">
829
+ <path d="m708.49 604.22c-1.4434 0.0745-3.1495-0.29645-4.4397-0.9439-1.3774-0.69087-2.7586-1.9213-3.6501-3.1772-0.99228-1.3985-1.7378-3.3014-2.0311-4.9904-0.33364-1.92-0.21829-4.2204 0.23071-6.1167 0.51227-2.1618 1.6138-4.5296 2.8762-6.3571 1.4314-2.0747 3.535-4.1505 5.5871-5.6136 2.3137-1.648 5.3114-3.0703 8.033-3.8824 3.0387-0.90794 6.7097-1.3576 9.8803-1.2757 3.5102 0.0868 7.5298 0.85335 10.85 1.9967 3.6487 1.2571 7.6157 3.3634 10.733 5.6374 3.403 2.4814 6.8762 5.9359 9.4195 9.2928 2.7585 3.6421 5.2967 8.305 6.9078 12.58 1.7391 4.6113 2.9488 10.207 3.3251 15.12 0.40311 5.2743-0.0248 11.403-1.0977 16.582-1.151 5.5358-3.3952 11.705-6.0243 16.71-2.7996 5.3284-6.8947 10.99-11.044 15.352-4.4027 4.6272-10.217 9.2227-15.71 12.479-5.8105 3.4453-13.046 6.4589-19.57 8.2046-6.8814 1.8421-15.085 2.8458-22.208 2.7666-7.494-0.0744-16.088-1.3814-23.285-3.4703-7.5522-2.1935-15.879-5.9201-22.569-10.051-7.0069-4.3275-14.368-10.414-19.969-16.452-5.8527-6.3096-11.576-14.487-15.54-22.128-4.136-7.9708-7.6261-17.78-9.5-26.562-1.9518-9.1463-2.7495-19.962-2.2093-29.297 0.56311-9.7088 2.7361-20.773 5.8448-29.986 3.2286-9.5687 8.4395-20.053 14.078-28.43 5.8474-8.6867 13.927-17.748 21.856-24.586 8.2138-7.0821 18.756-13.932 28.546-18.601 10.126-4.8319 22.512-8.7987 33.552-10.797 11.408-2.0639 24.834-2.6556 36.384-1.6506 11.923 1.0382 25.458 4.087 36.69 8.2179 11.584 4.2613 24.229 10.957 34.288 18.104 10.368 7.3672 21.132 17.439 29.204 27.264 8.313 10.115 16.291 23.023 21.664 34.963 5.5266 12.281 9.9714 27.244 12.091 40.543 2.179 13.671 2.5659 29.71 1.0927 43.474-1.512 14.136-5.4366 30.142-10.591 43.391-5.2914 13.6-13.473 28.404-22.133 40.149-8.8847 12.047-20.949 24.513-32.671 33.822-12.016 9.5423-27.291 18.649-41.38 24.724-14.435 6.2239-31.976 11.147-47.535 13.388-15.931 2.295-34.584 2.476-50.561 0.53458-16.351-1.9848-34.826-6.7838-50.094-12.964-15.616-6.3215-32.58-15.987-46.008-26.16-13.728-10.401-27.896-24.46-38.439-38.077-10.773-13.917-21.009-31.555-27.785-47.799-6.9211-16.587-12.322-36.707-14.683-54.525-2.2001-14.805-6.9646-31.487-12.954-45.204-5.8408-13.373-14.573-27.859-23.704-39.242-8.8966-11.09-20.796-22.49-32.282-30.868-11.184-8.1571-25.267-15.843-38.195-20.789-12.577-4.8147-27.759-8.4462-41.158-9.801-13.026-1.3166-28.194-0.86079-41.11 1.2795-12.546 2.0786-26.65 6.3651-38.212 11.659-11.222 5.1382-23.343 12.741-32.826 20.643-9.1934 7.6619-18.6 17.858-25.462 27.665-6.6459 9.5-12.846 21.424-16.763 32.336-3.79 10.559-6.5473 23.271-7.4269 34.454-0.84963 10.813-0.18976 23.368 1.8369 34.023 1.9566 10.287 5.765 21.814 10.364 31.222 4.435 9.0723 10.909 18.827 17.582 26.407 6.4257 7.2985 14.92 14.713 23.047 20.055 7.8149 5.1356 17.581 9.8513 26.475 12.736 8.5427 2.7679 18.784 4.6496 27.754 5.0524 8.5981 0.38699 18.542-0.48002 26.934-2.3941 8.029-1.8316 16.98-5.1633 24.231-9.0682 6.9236-3.7292 14.314-9.0762 19.989-14.521 5.4078-5.1872 10.83-11.981 14.647-18.43 3.6302-6.13 6.8629-13.737 8.7091-20.617 1.7496-6.5234 2.7573-14.296 2.6794-21.051-0.0745-6.3861-1.1461-13.719-2.9528-19.845-1.7021-5.7735-4.5573-12.152-7.7714-17.239-3.0202-4.7805-7.2421-9.8078-11.46-13.572-3.9472-3.5221-9.0433-6.9541-13.812-9.2425-4.4423-2.1314-9.8936-3.8813-14.756-4.6802-4.5084-0.74172-9.8158-0.87692-14.35-0.30759-4.1782 0.52466-8.9071 1.8039-12.757 3.5114-3.5284 1.5634-7.3369 3.9445-10.25 6.4761-2.6502 2.3043-5.3192 5.4037-7.1534 8.3986-1.656 2.7044-3.102 6.1103-3.8349 9.195-0.65861 2.7626-0.9253 6.0706-0.65366 8.8966 0.24063 2.509 0.98608 5.3679 2.0668 7.646 0.95259 2.0072 2.4523 4.1452 4.0686 5.6691 1.417 1.3365 3.3516 2.587 5.1805 3.2579 1.6097 0.59286 3.6302 0.89676 5.3377 0.73676 1.5331-0.1439 3.2895-0.72436 4.577-1.5715 1.2068-0.79382 2.381-2.0865 3.0373-3.3726 0.65491-1.2876 1.8301-2.5803 3.0372-3.3741 1.2861-0.84593 3.0426-1.4274 4.577-1.5714 1.7075-0.16001 3.7267 0.14759 5.3363 0.73676 1.829 0.67102 3.7649 1.9214 5.1819 3.2577 1.6164 1.524 3.1165 3.662 4.0686 5.6692 1.0803 2.2778 1.825 5.1369 2.0668 7.6459 0.2704 2.8272 2e-3 6.1352-0.65366 8.8966-0.73426 3.0861-2.1803 6.4904-3.8364 9.1949-1.8329 2.9952-4.503 6.0944-7.1533 8.3988-2.9131 2.5316-6.7216 4.9124-10.249 6.4759-3.8508 1.7075-8.5783 2.9871-12.758 3.5114-4.5322 0.56684-9.8407 0.43411-14.348-0.30635-4.8636-0.80003-10.313-2.55-14.758-4.6813-4.7698-2.2887-9.8646-5.7207-13.812-9.2425-4.219-3.7635-8.4396-8.7909-11.46-13.572-3.2155-5.0881-6.0705-11.466-7.7727-17.239-1.8064-6.1259-2.8788-13.459-2.9528-19.845-0.0745-6.7545 0.92904-14.527 2.6808-21.051 1.8461-6.88 5.0776-14.486 8.7077-20.617 3.8191-6.4483 9.2413-13.242 14.648-18.429 5.6744-5.4447 13.064-10.792 19.989-14.521 7.2498-3.905 16.201-7.2366 24.231-9.0683 8.3908-1.9134 18.335-2.7811 26.934-2.3941 8.9705 0.4031 19.21 2.2846 27.753 5.0536 8.8964 2.8828 18.661 7.5985 26.476 12.736 8.1267 5.3403 16.622 12.756 23.048 20.054 6.6727 7.5798 13.146 17.335 17.582 26.407 4.5981 9.4076 8.4066 20.934 10.364 31.222 2.0258 10.654 2.6873 23.21 1.8371 34.023-0.8794 11.185-3.6369 23.895-7.4268 34.454-3.9169 10.913-10.117 22.836-16.763 32.337-6.8604 9.8062-16.268 20.002-25.462 27.665-9.4814 7.9024-21.602 15.504-32.823 20.643-11.563 5.2943-25.668 9.5806-38.214 11.659-12.914 2.1406-28.084 2.5962-41.11 1.2795-13.398-1.355-28.58-4.9864-41.158-9.7998-12.927-4.9482-27.011-12.634-38.195-20.791-11.487-8.3775-23.385-19.778-32.282-30.868-9.132-11.382-17.862-25.869-23.703-39.242-5.9911-13.717-10.755-30.399-12.955-45.204-2.2562-15.177-2.5054-32.96-0.72188-48.198 1.8276-15.613 6.335-33.265 12.173-47.86 5.9781-14.944 15.148-31.188 24.817-44.054 9.8948-13.167 23.289-26.769 36.275-36.9 13.282-10.364 30.135-20.223 45.659-26.765 15.87-6.6887 35.129-11.93 52.195-14.252 17.438-2.3715 37.834-2.4152 55.286-0.16248 17.827 2.3003 37.951 7.6829 54.563 14.547 13.923 5.4961 30.751 9.7114 45.625 11.382 14.502 1.6283 31.412 1.31 45.837-0.9067 14.052-2.1603 29.875-6.7638 42.874-12.522 12.656-5.6071 26.355-13.962 37.102-22.683 10.457-8.4858 21.195-19.818 29.066-30.743 7.6526-10.623 14.843-23.987 19.447-36.243 4.4716-11.905 7.8124-26.262 9.009-38.923 1.1609-12.288 0.63878-26.585-1.4646-38.748-2.039-11.792-6.1657-25.037-11.229-35.882-4.9033-10.506-12.131-21.839-19.622-30.686-7.2498-8.5611-16.88-17.304-26.125-23.659-8.9375-6.1419-20.143-11.848-30.382-15.42-9.887-3.4493-21.774-5.9148-32.222-6.6358-10.075-0.69459-21.759 0.0373-31.658 2.0231-9.5342 1.9148-20.203 5.5636-28.892 9.9319-8.3552 4.1993-17.321 10.298-24.266 16.561-6.6689 6.0137-13.419 13.941-18.254 21.507-4.6325 7.2539-8.8543 16.298-11.392 24.523-2.4286 7.8692-4.0197 17.288-4.2628 25.52-0.23069 7.8598 0.70453 16.933 2.5817 24.57 1.7881 7.2776 4.9614 15.37 8.6351 21.902 3.4943 6.208 8.4648 12.81 13.501 17.85 4.7737 4.7778 11.002 9.537 16.89 12.846 5.5674 3.1284 12.455 5.8672 18.663 7.366 5.8513 1.4118 12.802 2.1288 18.816 1.8884 5.6494-0.22452 12.113-1.3667 17.483-3.1389 5.0234-1.6573 10.543-4.354 14.91-7.3396 4.0672-2.7824 8.3076-6.6292 11.432-10.44 2.8958-3.5324 5.6651-8.0619 7.4387-12.272 1.6361-3.881 2.892-8.6153 3.3396-12.804 0.41056-3.8376 0.25055-8.3262-0.48495-12.114-0.67104-3.448-2.0205-7.3093-3.6962-10.395-1.5146-2.7864-3.7411-5.7404-6.0454-7.918-2.0641-1.9506-4.7949-3.8376-7.3779-5.0156-2.2938-1.0468-5.1422-1.8304-7.6551-2.0323-2.2134-0.17984-4.8162 0.0496-6.9437 0.68838-1.8658 0.55939-3.9167 1.6097-5.4128 2.8578-1.3166 1.0989-2.5908 2.6952-3.3054 4.2547-0.64374 1.3998-1.0183 3.2116-0.92776 4.7488 0.0745 1.4422 0.6152 3.1059 1.4024 4.3169 0.78637 1.2118 1.3192 2.8749 1.4037 4.3182 0.0745 1.537-0.2865 3.3489-0.92778 4.7486-0.71442 1.5583-1.9901 3.1548-3.3068 4.2535-1.4946 1.2493-3.5454 2.2991-5.4115 2.8591-2.1273 0.63628-4.7302 0.867-6.9436 0.68839-2.5129-0.20343-5.3614-0.98607-7.6551-2.0337-2.5842-1.1783-5.3152-3.0635-7.3779-5.0141-2.3057-2.1775-4.5308-5.1329-6.0455-7.9181-1.6771-3.0861-3.0267-6.9486-3.6961-10.395-0.738-3.7888-0.89305-8.2773-0.48498-12.115 0.44653-4.1874 1.7035-8.9215 3.3384-12.803 1.7749-4.2101 4.5441-8.7407 7.4401-12.273 3.1244-3.8112 7.3646-7.6566 11.432-10.439 4.3656-2.9871 9.887-5.6837 14.91-7.341 5.3693-1.7708 11.833-2.913 17.483-3.1377 6.0152-0.24063 12.965 0.47505 18.816 1.8884 6.2079 1.499 13.096 4.2364 18.663 7.3661 5.8883 3.3092 12.115 8.0685 16.89 12.846 5.0353 5.0391 10.007 11.641 13.5 17.85 3.6751 6.5302 6.847 14.624 8.6364 21.899 1.8779 7.6367 2.8128 16.71 2.5803 24.571-0.24187 8.2324-1.8329 17.649-4.2613 25.519-2.5381 8.2243-6.7598 17.27-11.394 24.523-4.8334 7.568-11.584 15.496-18.253 21.509-6.9448 6.262-15.911 12.36-24.268 16.561-8.6878 4.3671-19.357 8.0172-28.891 9.932-9.9003 1.9886-21.586 2.7176-31.658 2.023-10.447-0.72188-22.335-3.1866-32.222-6.6358-10.241-3.5734-21.444-9.2781-30.383-15.421-9.2468-6.3531-18.874-15.096-26.127-23.659-7.4915-8.8477-14.718-20.179-19.622-30.685-5.0616-10.844-9.1883-24.09-11.227-35.883-2.1024-12.162-2.6253-26.46-1.4644-38.747 1.1969-12.66 4.536-27.018 9.0088-38.923 4.6048-12.256 11.794-25.62 19.447-36.243 7.8717-10.926 18.608-22.257 29.065-30.743 10.749-8.7223 24.446-17.076 37.102-22.683 12.999-5.7589 28.822-10.364 42.875-12.524 14.423-2.2172 31.333-2.5354 45.837-0.90668 14.874 1.6705 31.703 5.8857 45.625 11.383 14.271 5.6346 29.795 14.31 42.102 23.475 12.607 9.3891 25.642 22.119 35.361 34.473 9.9529 12.649 19.436 28.713 25.744 43.52 6.4562 15.152 11.538 33.552 13.82 49.864 2.3333 16.685 2.4456 36.209 0.34853 52.925-2.1434 17.088-7.234 36.388-13.757 52.327-6.6648 16.287-16.825 33.972-27.502 47.961-10.906 14.287-25.629 29.023-39.879 39.979-11.721 9.3085-23.787 21.774-32.671 33.822-8.6602 11.744-16.841 26.548-22.133 40.147-5.1554 13.251-9.0788 29.256-10.591 43.392-1.4724 13.764-1.0865 29.804 1.0927 43.474 2.1209 13.298 6.5657 28.262 12.092 40.543 5.372 11.938 13.351 24.848 21.663 34.963 8.0738 9.825 18.837 19.896 29.204 27.263 10.061 7.1496 22.706 13.845 34.289 18.106 11.233 4.1308 24.767 7.18 36.689 8.218 11.551 1.0047 24.977 0.41179 36.385-1.6508 11.04-1.9981 23.426-5.9663 33.552-10.797 9.7879-4.6695 20.332-11.519 28.545-18.601 7.9312-6.8377 16.01-15.899 21.857-24.586 5.6387-8.3775 10.85-18.862 14.078-28.43 3.1087-9.2135 5.2822-20.278 5.8435-29.986 0.54081-9.3363-0.25674-20.151-2.2078-29.297-1.874-8.7816-5.3642-18.59-9.5001-26.562-3.9656-7.6393-9.6876-15.818-15.541-22.128-5.6005-6.0376-12.962-12.125-19.968-16.452-6.6925-4.1307-15.017-7.8587-22.569-10.051-7.1971-2.0892-15.792-3.3885-23.285-3.4705-7.1231-0.0745-15.326 0.92406-22.207 2.7664-6.5263 1.7458-13.76 4.7594-19.57 8.2047-5.4936 3.2565-11.309 7.8518-15.71 12.479-4.1492 4.3617-8.2455 10.022-11.045 15.352-2.6291 5.0048-4.8728 11.174-6.023 16.71-1.0766 5.1792-1.5013 11.308-1.0964 16.582 0.37706 4.9138 1.5859 10.509 3.3237 15.12 1.6125 4.2745 4.1507 8.9374 6.9092 12.58 2.5434 3.3568 6.015 6.8113 9.4195 9.2928 3.1178 2.274 7.0846 4.3803 10.733 5.6374 3.3199 1.1436 7.3396 1.9056 10.85 1.9967 3.1707 0.0745 6.8418-0.36962 9.8804-1.2756 2.7216-0.81242 5.7193-2.2345 8.0316-3.8824 2.0535-1.4646 4.1558-3.5391 5.5885-5.6138 1.2624-1.8276 2.3639-4.1967 2.8762-6.3571 0.44901-1.8964 0.56434-4.1967 0.2307-6.1167-0.2952-1.689-1.0394-3.5919-2.031-4.9903-0.89181-1.2561-2.2739-2.4867-3.6501-3.1774-1.2914-0.64869-2.9962-1.0196-4.4397-0.94389z" stroke-width=".13206" />
830
+ </svg>
831
+ `;
832
+ var LuteWallet = class extends BaseWallet {
833
+ client = null;
834
+ options;
835
+ store;
836
+ constructor({
837
+ id,
838
+ store,
839
+ subscribe,
840
+ getAlgodClient,
841
+ options,
842
+ metadata = {}
843
+ }) {
844
+ super({ id, metadata, getAlgodClient, store, subscribe });
845
+ if (!options?.siteName) {
846
+ throw new Error("[LuteWallet] Missing required option: siteName");
847
+ }
848
+ this.options = options;
849
+ this.store = store;
850
+ }
851
+ static defaultMetadata = {
852
+ name: "Lute",
853
+ icon: `data:image/svg+xml;base64,${btoa(svgIcon.trim())}`
854
+ };
855
+ async initializeClient() {
856
+ console.info("[LuteWallet] Initializing client...");
857
+ const module = await import("./main.esm/3Z2KJMX5.jsx");
858
+ const LuteConnect = module.default;
859
+ const client = new LuteConnect(this.options.siteName);
860
+ this.client = client;
861
+ return client;
862
+ }
863
+ async getGenesisId() {
864
+ const algodClient = this.getAlgodClient();
865
+ const genesis = await algodClient.genesis().do();
866
+ const genesisId = `${genesis.network}-${genesis.id}`;
867
+ return genesisId;
868
+ }
869
+ connect = async () => {
870
+ console.info("[LuteWallet] Connecting...");
871
+ try {
872
+ const client = this.client || await this.initializeClient();
873
+ const genesisId = await this.getGenesisId();
874
+ const accounts = await client.connect(genesisId);
875
+ if (accounts.length === 0) {
876
+ throw new Error("No accounts found!");
877
+ }
878
+ const walletAccounts = accounts.map((address, idx) => ({
879
+ name: `Lute Wallet ${idx + 1}`,
880
+ address
881
+ }));
882
+ const activeAccount = walletAccounts[0];
883
+ addWallet(this.store, {
884
+ walletId: this.id,
885
+ wallet: {
886
+ accounts: walletAccounts,
887
+ activeAccount
888
+ }
889
+ });
890
+ return walletAccounts;
891
+ } catch (error) {
892
+ console.error(`[LuteWallet] Error connecting: ${error.message}`);
893
+ return [];
894
+ }
895
+ };
896
+ disconnect = async () => {
897
+ console.info("[LuteWallet] Disconnecting...");
898
+ this.onDisconnect();
899
+ };
900
+ resumeSession = async () => {
901
+ try {
902
+ const state = this.store.state;
903
+ const walletState = state.wallets[this.id];
904
+ if (!walletState) {
905
+ return;
906
+ }
907
+ console.info("[LuteWallet] Resuming session...");
908
+ await this.initializeClient();
909
+ } catch (error) {
910
+ console.error(`[LuteWallet] Error resuming session: ${error.message}`);
911
+ this.onDisconnect();
912
+ }
913
+ };
914
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
915
+ try {
916
+ if (!this.client) {
917
+ throw new Error("[LuteWallet] Client not initialized!");
918
+ }
919
+ const txnsToSign = [];
920
+ const signedIndexes = [];
921
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
922
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
923
+ return esm_default.decodeObj(txn);
924
+ });
925
+ decodedObjects.forEach((txnObject, idx) => {
926
+ const isSigned = isSignedTxnObject(txnObject);
927
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
928
+ const txnBuffer = msgpackTxnGroup[idx];
929
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
930
+ const txnBase64 = byteArrayToBase64(txn.toByte());
931
+ if (shouldSign) {
932
+ txnsToSign.push({ txn: txnBase64 });
933
+ signedIndexes.push(idx);
934
+ } else {
935
+ txnsToSign.push({ txn: txnBase64, signers: [] });
936
+ }
937
+ });
938
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
939
+ const signedTxns = signTxnsResult.filter(Boolean);
940
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
941
+ signedTxns,
942
+ msgpackTxnGroup,
943
+ signedIndexes,
944
+ returnGroup
945
+ );
946
+ return txnGroupSigned;
947
+ } catch (error) {
948
+ console.error(
949
+ `[LuteWallet] Error signing transactions: ` + (isSignTxnsError(error) ? `${error.message} (code: ${error.code})` : error.message)
950
+ );
951
+ throw error;
952
+ }
953
+ };
954
+ transactionSigner = async (txnGroup, indexesToSign) => {
955
+ try {
956
+ if (!this.client) {
957
+ throw new Error("[LuteWallet] Client not initialized!");
958
+ }
959
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
960
+ const txnBase64 = byteArrayToBase64(txn.toByte());
961
+ if (indexesToSign.includes(idx)) {
962
+ acc.push({ txn: txnBase64 });
963
+ } else {
964
+ acc.push({ txn: txnBase64, signers: [] });
965
+ }
966
+ return acc;
967
+ }, []);
968
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
969
+ const signedTxns = signTxnsResult.filter(Boolean);
970
+ return signedTxns;
971
+ } catch (error) {
972
+ console.error(
973
+ `[LuteWallet] Error signing transactions: ` + (isSignTxnsError(error) ? `${error.message} (code: ${error.code})` : error.message)
974
+ );
975
+ throw error;
976
+ }
977
+ };
978
+ };
979
+ var icon4 = `data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e %3c!-- Generated by Pixelmator Pro 3.2.2 --%3e %3csvg width='409' height='210' viewBox='0 0 409 210' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctext id='MNEMONIC' xml:space='preserve' x='0' y='129' font-family='Helvetica' font-size='72' fill='black'%3eMNEMONIC%3c/text%3e%3c/svg%3e`;
980
+ var MnemonicWallet = class extends BaseWallet {
981
+ account = null;
982
+ options;
983
+ store;
984
+ constructor({
985
+ id,
986
+ store,
987
+ subscribe,
988
+ getAlgodClient,
989
+ options,
990
+ metadata = {}
991
+ }) {
992
+ super({ id, metadata, getAlgodClient, store, subscribe });
993
+ const { persistToStorage = false } = options || {};
994
+ this.options = { persistToStorage };
995
+ this.store = store;
996
+ }
997
+ static defaultMetadata = { name: "Mnemonic", icon: icon4 };
998
+ // @todo: Show explicit security warning if persistToStorage is true
999
+ // @todo: Save/load mnemonic from storage if persistToStorage is true
1000
+ // @todo: Throw error with link to docs if using mainnet
1001
+ initializeAccount() {
1002
+ const mnemonic = prompt("Enter 25-word mnemonic passphrase:");
1003
+ if (!mnemonic) {
1004
+ this.account = null;
1005
+ throw new Error("No mnemonic provided");
1006
+ }
1007
+ const account = esm_default.mnemonicToSecretKey(mnemonic);
1008
+ this.account = account;
1009
+ return account;
1010
+ }
1011
+ connect = async () => {
1012
+ console.info("[MnemonicWallet] Connecting...");
1013
+ try {
1014
+ const account = this.initializeAccount();
1015
+ const walletAccount = {
1016
+ name: "Mnemonic Account",
1017
+ address: account.addr
1018
+ };
1019
+ addWallet(this.store, {
1020
+ walletId: this.id,
1021
+ wallet: {
1022
+ accounts: [walletAccount],
1023
+ activeAccount: walletAccount
1024
+ }
1025
+ });
1026
+ return [walletAccount];
1027
+ } catch (error) {
1028
+ console.error("[MnemonicWallet] Error connecting:", error);
1029
+ throw error;
1030
+ }
1031
+ };
1032
+ disconnect = async () => {
1033
+ console.info("[MnemonicWallet] Disconnecting...");
1034
+ try {
1035
+ this.account = null;
1036
+ this.onDisconnect();
1037
+ } catch (error) {
1038
+ console.error(error);
1039
+ }
1040
+ };
1041
+ resumeSession = async () => {
1042
+ const state = this.store.state;
1043
+ const walletState = state.wallets[this.id];
1044
+ if (walletState) {
1045
+ try {
1046
+ this.account = null;
1047
+ this.onDisconnect();
1048
+ } catch (error) {
1049
+ console.error(error);
1050
+ }
1051
+ }
1052
+ };
1053
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1054
+ if (!this.account) {
1055
+ throw new Error("[MnemonicWallet] Client not initialized!");
1056
+ }
1057
+ const txnGroupSigned = [];
1058
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1059
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1060
+ return esm_default.decodeObj(txn);
1061
+ });
1062
+ decodedObjects.forEach((txnObject, idx) => {
1063
+ const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
1064
+ const isSigned = isSignedTxnObject(txnObject);
1065
+ const canSign = !isSigned && esm_default.encodeAddress(txnObject.snd) === this.account.addr;
1066
+ const shouldSign = isIndexMatch && canSign;
1067
+ if (shouldSign) {
1068
+ const txn = esm_default.Transaction.from_obj_for_encoding(txnObject);
1069
+ const signedTxn = txn.signTxn(this.account.sk);
1070
+ txnGroupSigned.push(signedTxn);
1071
+ } else if (returnGroup) {
1072
+ txnGroupSigned.push(msgpackTxnGroup[idx]);
1073
+ }
1074
+ });
1075
+ return Promise.resolve(txnGroupSigned);
1076
+ };
1077
+ transactionSigner = async (txnGroup, indexesToSign) => {
1078
+ if (!this.account) {
1079
+ throw new Error("[MnemonicWallet] Account not initialized!");
1080
+ }
1081
+ const signedTxns = [];
1082
+ for (const index of indexesToSign) {
1083
+ const txnToSign = txnGroup[index];
1084
+ if (txnToSign) {
1085
+ signedTxns.push(txnToSign.signTxn(this.account.sk));
1086
+ }
1087
+ }
1088
+ return Promise.resolve(signedTxns);
1089
+ };
1090
+ };
1091
+ var icon5 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNzcgMTg3Ij48cmVjdCB4PSItMTEuMzgiIHk9Ii0yNS45NyIgd2lkdGg9IjIwMC4wMiIgaGVpZ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44My0yLjg3LDguNy0zLjA4LDE3LjU4LS40NloiIHN0eWxlPSJmaWxsOiMxYzFjMWM7Ii8+PHBhdGggZD0iTTcxLjY0LDk3LjcxYy0yLjA4LTIuMTUtOC44OCwuOTgtMTUuMiw2Ljk5LTYuMzIsNi4wMS05Ljc2LDEyLjYzLTcuNjksMTQuNzgsMi4wOCwyLjE1LDguODgtLjk4LDE1LjItNi45OSw2LjMyLTYuMDEsOS43Ni0xMi42Myw3LjY5LTE0Ljc4WiIgc3R5bGU9ImZpbGw6IzFjMWMxYzsiLz48L3N2Zz4=";
1092
+ var PeraWallet = class extends BaseWallet {
1093
+ client = null;
1094
+ options;
1095
+ store;
1096
+ constructor({
1097
+ id,
1098
+ store,
1099
+ subscribe,
1100
+ getAlgodClient,
1101
+ options = {},
1102
+ metadata = {}
1103
+ }) {
1104
+ super({ id, metadata, getAlgodClient, store, subscribe });
1105
+ this.options = options;
1106
+ this.store = store;
1107
+ }
1108
+ static defaultMetadata = { name: "Pera", icon: icon5 };
1109
+ async initializeClient() {
1110
+ console.info("[PeraWallet] Initializing client...");
1111
+ const module = await import("./dist/Y3EB35O7.jsx");
1112
+ const PeraWalletConnect = module.default ? module.default.PeraWalletConnect : module.PeraWalletConnect;
1113
+ const client = new PeraWalletConnect(this.options);
1114
+ client.connector?.on("disconnect", this.onDisconnect);
1115
+ this.client = client;
1116
+ return client;
1117
+ }
1118
+ connect = async () => {
1119
+ console.info("[PeraWallet] Connecting...");
1120
+ try {
1121
+ const client = this.client || await this.initializeClient();
1122
+ const accounts = await client.connect();
1123
+ if (accounts.length === 0) {
1124
+ throw new Error("No accounts found!");
1125
+ }
1126
+ const walletAccounts = accounts.map((address, idx) => ({
1127
+ name: `Pera Wallet ${idx + 1}`,
1128
+ address
1129
+ }));
1130
+ const activeAccount = walletAccounts[0];
1131
+ addWallet(this.store, {
1132
+ walletId: this.id,
1133
+ wallet: {
1134
+ accounts: walletAccounts,
1135
+ activeAccount
1136
+ }
1137
+ });
1138
+ return walletAccounts;
1139
+ } catch (error) {
1140
+ if (error?.data?.type !== "CONNECT_MODAL_CLOSED") {
1141
+ console.error(`[PeraWallet] Error connecting: ${error.message}`);
1142
+ } else {
1143
+ console.info("[PeraWallet] Connection cancelled.");
1144
+ }
1145
+ return [];
1146
+ }
1147
+ };
1148
+ disconnect = async () => {
1149
+ console.info("[PeraWallet] Disconnecting...");
1150
+ try {
1151
+ await this.client?.disconnect();
1152
+ this.onDisconnect();
1153
+ } catch (error) {
1154
+ console.error(error);
1155
+ }
1156
+ };
1157
+ resumeSession = async () => {
1158
+ try {
1159
+ const state = this.store.state;
1160
+ const walletState = state.wallets[this.id];
1161
+ if (!walletState) {
1162
+ return;
1163
+ }
1164
+ console.info("[PeraWallet] Resuming session...");
1165
+ const client = this.client || await this.initializeClient();
1166
+ const accounts = await client.reconnectSession();
1167
+ if (accounts.length === 0) {
1168
+ throw new Error("[PeraWallet] No accounts found!");
1169
+ }
1170
+ const walletAccounts = accounts.map((address, idx) => ({
1171
+ name: `Pera Wallet ${idx + 1}`,
1172
+ address
1173
+ }));
1174
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1175
+ if (!match) {
1176
+ console.warn(`[PeraWallet] Session accounts mismatch, updating accounts`);
1177
+ setAccounts(this.store, {
1178
+ walletId: this.id,
1179
+ accounts: walletAccounts
1180
+ });
1181
+ }
1182
+ } catch (error) {
1183
+ console.error(`[PeraWallet] Error resuming session: ${error.message}`);
1184
+ this.onDisconnect();
1185
+ }
1186
+ };
1187
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1188
+ if (!this.client) {
1189
+ throw new Error("[PeraWallet] Client not initialized!");
1190
+ }
1191
+ const txnsToSign = [];
1192
+ const signedIndexes = [];
1193
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1194
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1195
+ return esm_default.decodeObj(txn);
1196
+ });
1197
+ decodedObjects.forEach((txnObject, idx) => {
1198
+ const isSigned = isSignedTxnObject(txnObject);
1199
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1200
+ const txnBuffer = msgpackTxnGroup[idx];
1201
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1202
+ if (shouldSign) {
1203
+ txnsToSign.push({ txn });
1204
+ signedIndexes.push(idx);
1205
+ } else {
1206
+ txnsToSign.push({ txn, signers: [] });
1207
+ }
1208
+ });
1209
+ const signedTxns = await this.client.signTransaction([txnsToSign]);
1210
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1211
+ signedTxns,
1212
+ msgpackTxnGroup,
1213
+ signedIndexes,
1214
+ returnGroup
1215
+ );
1216
+ return txnGroupSigned;
1217
+ };
1218
+ transactionSigner = async (txnGroup, indexesToSign) => {
1219
+ if (!this.client) {
1220
+ throw new Error("[PeraWallet] Client not initialized!");
1221
+ }
1222
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1223
+ if (indexesToSign.includes(idx)) {
1224
+ acc.push({ txn });
1225
+ } else {
1226
+ acc.push({ txn, signers: [] });
1227
+ }
1228
+ return acc;
1229
+ }, []);
1230
+ const signTxnsResult = await this.client.signTransaction([txnsToSign]);
1231
+ return signTxnsResult;
1232
+ };
1233
+ };
1234
+ var icon6 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNDgwIDQ4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDgwIDQ4MDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiMzMzk2RkY7fQo8L3N0eWxlPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMTI2LjYsMTY4YzYyLjYtNjEuMywxNjQuMi02MS4zLDIyNi44LDBsNy41LDcuNGMzLjEsMy4xLDMuMSw4LDAsMTEuMWwtMjUuOCwyNS4yYy0xLjYsMS41LTQuMSwxLjUtNS43LDAKCWwtMTAuNC0xMC4yYy00My43LTQyLjgtMTE0LjUtNDIuOC0xNTguMiwwbC0xMS4xLDEwLjljLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMjUuOC0yNS4yYy0zLjEtMy4xLTMuMS04LDAtMTEuMUwxMjYuNiwxNjh6CgkgTTQwNi43LDIyMC4ybDIyLjksMjIuNWMzLjEsMy4xLDMuMSw4LDAsMTEuMUwzMjYuMiwzNTUuMWMtMy4xLDMuMS04LjIsMy4xLTExLjMsMGwtNzMuNC03MS45Yy0wLjgtMC44LTIuMS0wLjgtMi44LDBsLTczLjQsNzEuOQoJYy0zLjEsMy4xLTguMiwzLjEtMTEuMywwTDUwLjMsMjUzLjhjLTMuMS0zLjEtMy4xLTgsMC0xMS4xbDIyLjktMjIuNWMzLjEtMy4xLDguMi0zLjEsMTEuMywwbDczLjQsNzEuOWMwLjgsMC44LDIuMSwwLjgsMi44LDAKCWw3My40LTcxLjljMy4xLTMuMSw4LjItMy4xLDExLjMsMGw3My40LDcxLjljMC44LDAuOCwyLjEsMC44LDIuOCwwbDczLjQtNzEuOUMzOTguNSwyMTcuMSw0MDMuNiwyMTcuMSw0MDYuNywyMjAuMkw0MDYuNywyMjAuMnoiLz4KPC9zdmc+Cg==";
1235
+ var WalletConnect = class extends BaseWallet {
1236
+ client = null;
1237
+ options;
1238
+ modal = null;
1239
+ modalOptions;
1240
+ session = null;
1241
+ chains;
1242
+ store;
1243
+ constructor({
1244
+ id,
1245
+ store,
1246
+ subscribe,
1247
+ getAlgodClient,
1248
+ options,
1249
+ metadata = {}
1250
+ }) {
1251
+ super({ id, metadata, getAlgodClient, store, subscribe });
1252
+ if (!options?.projectId) {
1253
+ throw new Error("[WalletConnect] Missing required option: projectId");
1254
+ }
1255
+ const {
1256
+ projectId,
1257
+ relayUrl = "wss://relay.walletconnect.com",
1258
+ metadata: _metadata,
1259
+ ...modalOptions
1260
+ } = options;
1261
+ this.options = {
1262
+ projectId,
1263
+ relayUrl,
1264
+ ..._metadata
1265
+ };
1266
+ this.modalOptions = modalOptions;
1267
+ this.chains = Object.values(caipChainId);
1268
+ this.store = store;
1269
+ }
1270
+ static defaultMetadata = { name: "WalletConnect", icon: icon6 };
1271
+ async initializeClient() {
1272
+ console.info("[WalletConnect] Initializing client...");
1273
+ const SignClient = (await import("./index.es/F3DWLLSH.jsx")).SignClient;
1274
+ const client = await SignClient.init(this.options);
1275
+ client.on("session_event", (args) => {
1276
+ console.log("[WalletConnect] EVENT", "session_event", args);
1277
+ });
1278
+ client.on("session_update", ({ topic, params }) => {
1279
+ console.log("[WalletConnect] EVENT", "session_update", { topic, params });
1280
+ const { namespaces } = params;
1281
+ const session = client.session.get(topic);
1282
+ const updatedSession = { ...session, namespaces };
1283
+ this.onSessionConnected(updatedSession);
1284
+ });
1285
+ client.on("session_delete", () => {
1286
+ console.log("[WalletConnect] EVENT", "session_delete");
1287
+ this.session = null;
1288
+ });
1289
+ this.client = client;
1290
+ return client;
1291
+ }
1292
+ async initializeModal() {
1293
+ console.info("[WalletConnect] Initializing modal...");
1294
+ const WalletConnectModal = (await import("./dist/5CZLQJ23.jsx")).WalletConnectModal;
1295
+ const modal = new WalletConnectModal({
1296
+ projectId: this.options.projectId,
1297
+ chains: this.chains,
1298
+ ...this.modalOptions
1299
+ });
1300
+ modal.subscribeModal(
1301
+ (state) => console.info(`[WalletConnect] Modal ${state.open ? "open" : "closed"}`)
1302
+ );
1303
+ this.modal = modal;
1304
+ return modal;
1305
+ }
1306
+ onSessionConnected(session) {
1307
+ const caipAccounts = session.namespaces.algorand.accounts;
1308
+ if (!caipAccounts.length) {
1309
+ throw new Error("No accounts found!");
1310
+ }
1311
+ const accounts = [...new Set(caipAccounts.map((account) => account.split(":").pop()))];
1312
+ const walletAccounts = accounts.map((address, idx) => ({
1313
+ name: `WalletConnect ${idx + 1}`,
1314
+ address
1315
+ }));
1316
+ const state = this.store.state;
1317
+ const walletState = state.wallets[this.id];
1318
+ if (!walletState) {
1319
+ addWallet(this.store, {
1320
+ walletId: this.id,
1321
+ wallet: {
1322
+ accounts: walletAccounts,
1323
+ activeAccount: walletAccounts[0]
1324
+ }
1325
+ });
1326
+ } else {
1327
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1328
+ if (!match) {
1329
+ console.warn(`[WalletConnect] Session accounts mismatch, updating accounts`);
1330
+ setAccounts(this.store, {
1331
+ walletId: this.id,
1332
+ accounts: walletAccounts
1333
+ });
1334
+ }
1335
+ }
1336
+ this.session = session;
1337
+ return walletAccounts;
1338
+ }
1339
+ connect = async () => {
1340
+ console.info("[WalletConnect] Connecting...");
1341
+ try {
1342
+ const client = this.client || await this.initializeClient();
1343
+ const modal = this.modal || await this.initializeModal();
1344
+ const requiredNamespaces = {
1345
+ algorand: {
1346
+ chains: this.chains,
1347
+ methods: ["algo_signTxn"],
1348
+ events: []
1349
+ }
1350
+ };
1351
+ const { uri, approval } = await client.connect({ requiredNamespaces });
1352
+ if (!uri) {
1353
+ throw new Error("No URI found");
1354
+ }
1355
+ await modal.openModal({ uri });
1356
+ const session = await approval();
1357
+ const walletAccounts = this.onSessionConnected(session);
1358
+ return walletAccounts;
1359
+ } catch (error) {
1360
+ console.error(`[WalletConnect] Error connecting: ${error.message}`);
1361
+ return [];
1362
+ } finally {
1363
+ this.modal?.closeModal();
1364
+ }
1365
+ };
1366
+ disconnect = async () => {
1367
+ console.info("[WalletConnect] Disconnecting...");
1368
+ try {
1369
+ if (this.client && this.session) {
1370
+ await this.client.disconnect({
1371
+ topic: this.session.topic,
1372
+ reason: {
1373
+ message: "User disconnected.",
1374
+ code: 6e3
1375
+ }
1376
+ });
1377
+ }
1378
+ this.onDisconnect();
1379
+ } catch (error) {
1380
+ console.error(error);
1381
+ }
1382
+ };
1383
+ resumeSession = async () => {
1384
+ try {
1385
+ const state = this.store.state;
1386
+ const walletState = state.wallets[this.id];
1387
+ if (!walletState) {
1388
+ return;
1389
+ }
1390
+ console.info("[WalletConnect] Resuming session...");
1391
+ const client = this.client || await this.initializeClient();
1392
+ if (client.session.length) {
1393
+ const lastKeyIndex = client.session.keys.length - 1;
1394
+ const restoredSession = client.session.get(client.session.keys[lastKeyIndex]);
1395
+ this.onSessionConnected(restoredSession);
1396
+ }
1397
+ } catch (error) {
1398
+ console.error(`[WalletConnect] Error resuming session: ${error.message}`);
1399
+ this.onDisconnect();
1400
+ }
1401
+ };
1402
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1403
+ if (!this.client) {
1404
+ throw new Error("[WalletConnect] Client not initialized!");
1405
+ }
1406
+ if (!this.session) {
1407
+ throw new Error("[WalletConnect] Session is not connected");
1408
+ }
1409
+ if (this.activeNetwork === "localnet") {
1410
+ throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
1411
+ }
1412
+ const txnsToSign = [];
1413
+ const signedIndexes = [];
1414
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1415
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1416
+ return esm_default.decodeObj(txn);
1417
+ });
1418
+ decodedObjects.forEach((txnObject, idx) => {
1419
+ const isSigned = isSignedTxnObject(txnObject);
1420
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1421
+ const txnBuffer = msgpackTxnGroup[idx];
1422
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1423
+ const txnBase64 = byteArrayToBase64(txn.toByte());
1424
+ if (shouldSign) {
1425
+ txnsToSign.push({ txn: txnBase64 });
1426
+ signedIndexes.push(idx);
1427
+ } else {
1428
+ txnsToSign.push({ txn: txnBase64, signers: [] });
1429
+ }
1430
+ });
1431
+ const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]);
1432
+ const signTxnsResult = await this.client.request({
1433
+ chainId: caipChainId[this.activeNetwork],
1434
+ topic: this.session.topic,
1435
+ request
1436
+ });
1437
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
1438
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
1439
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1440
+ signedTxns,
1441
+ msgpackTxnGroup,
1442
+ signedIndexes,
1443
+ returnGroup
1444
+ );
1445
+ return txnGroupSigned;
1446
+ };
1447
+ transactionSigner = async (txnGroup, indexesToSign) => {
1448
+ if (!this.client) {
1449
+ throw new Error("[WalletConnect] Client not initialized!");
1450
+ }
1451
+ if (!this.session) {
1452
+ throw new Error("[WalletConnect] Session is not connected");
1453
+ }
1454
+ if (this.activeNetwork === "localnet") {
1455
+ throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
1456
+ }
1457
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1458
+ const txnBase64 = byteArrayToBase64(txn.toByte());
1459
+ if (indexesToSign.includes(idx)) {
1460
+ acc.push({ txn: txnBase64 });
1461
+ } else {
1462
+ acc.push({ txn: txnBase64, signers: [] });
1463
+ }
1464
+ return acc;
1465
+ }, []);
1466
+ const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]);
1467
+ const signTxnsResult = await this.client.request({
1468
+ chainId: caipChainId[this.activeNetwork],
1469
+ topic: this.session.topic,
1470
+ request
1471
+ });
1472
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
1473
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
1474
+ return signedTxns;
1475
+ };
1476
+ };
1477
+ function createWalletMap() {
1478
+ return {
1479
+ [
1480
+ "defly"
1481
+ /* DEFLY */
1482
+ ]: DeflyWallet,
1483
+ [
1484
+ "exodus"
1485
+ /* EXODUS */
1486
+ ]: ExodusWallet,
1487
+ [
1488
+ "kibisis"
1489
+ /* KIBISIS */
1490
+ ]: KibisisWallet,
1491
+ [
1492
+ "kmd"
1493
+ /* KMD */
1494
+ ]: KmdWallet,
1495
+ [
1496
+ "lute"
1497
+ /* LUTE */
1498
+ ]: LuteWallet,
1499
+ [
1500
+ "mnemonic"
1501
+ /* MNEMONIC */
1502
+ ]: MnemonicWallet,
1503
+ [
1504
+ "pera"
1505
+ /* PERA */
1506
+ ]: PeraWallet,
1507
+ [
1508
+ "walletconnect"
1509
+ /* WALLETCONNECT */
1510
+ ]: WalletConnect
1511
+ };
1512
+ }
1513
+ function compareAccounts(accounts, compareTo) {
1514
+ const addresses = new Set(accounts.map((account) => account.address));
1515
+ const compareAddresses = new Set(compareTo.map((account) => account.address));
1516
+ if (addresses.size !== compareAddresses.size) {
1517
+ return false;
1518
+ }
1519
+ for (const address of addresses) {
1520
+ if (!compareAddresses.has(address)) {
1521
+ return false;
1522
+ }
1523
+ }
1524
+ return true;
1525
+ }
1526
+ function base64ToByteArray(blob) {
1527
+ return stringToByteArray(atob(blob));
1528
+ }
1529
+ function byteArrayToBase64(array) {
1530
+ return btoa(byteArrayToString(array));
1531
+ }
1532
+ function stringToByteArray(str) {
1533
+ const array = new Uint8Array(str.length);
1534
+ for (let i = 0; i < str.length; i++) {
1535
+ array[i] = str.charCodeAt(i);
1536
+ }
1537
+ return array;
1538
+ }
1539
+ function byteArrayToString(array) {
1540
+ let result = "";
1541
+ for (let i = 0; i < array.length; i++) {
1542
+ result += String.fromCharCode(array[i]);
1543
+ }
1544
+ return result;
1545
+ }
1546
+ function isTransaction(item) {
1547
+ if (Array.isArray(item)) {
1548
+ return item.every(
1549
+ (elem) => typeof elem === "object" && elem !== null && "genesisID" in elem && typeof elem.genesisID === "string"
1550
+ );
1551
+ } else {
1552
+ return typeof item === "object" && item !== null && "genesisID" in item && typeof item.genesisID === "string";
1553
+ }
1554
+ }
1555
+ function isSignedTxnObject(item) {
1556
+ return item.txn !== void 0;
1557
+ }
1558
+ function normalizeTxnGroup(txnGroup) {
1559
+ if (!txnGroup[0]) {
1560
+ throw new Error("Empty transaction group!");
1561
+ }
1562
+ const isTransactionType = isTransaction(txnGroup[0]);
1563
+ if (isTransactionType) {
1564
+ const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
1565
+ return transactionGroup.map((txn) => {
1566
+ return esm_default.encodeUnsignedTransaction(txn);
1567
+ });
1568
+ } else {
1569
+ const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
1570
+ return transactionGroup;
1571
+ }
1572
+ }
1573
+ function shouldSignTxnObject(txnObject, addresses, indexesToSign, idx) {
1574
+ const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
1575
+ const isSigned = isSignedTxnObject(txnObject);
1576
+ const canSign = !isSigned && addresses.includes(esm_default.encodeAddress(txnObject.snd));
1577
+ const shouldSign = isIndexMatch && canSign;
1578
+ return shouldSign;
1579
+ }
1580
+ function mergeSignedTxnsWithGroup(signedTxns, txnGroup, signedIndexes, returnGroup) {
1581
+ return txnGroup.reduce((acc, txn, i) => {
1582
+ if (signedIndexes.includes(i)) {
1583
+ const signedByUser = signedTxns.shift();
1584
+ signedByUser && acc.push(signedByUser);
1585
+ } else if (returnGroup) {
1586
+ acc.push(txnGroup[i]);
1587
+ }
1588
+ return acc;
1589
+ }, []);
1590
+ }
1591
+ function getPayloadId() {
1592
+ const date = Date.now() * Math.pow(10, 3);
1593
+ const extra = Math.floor(Math.random() * Math.pow(10, 3));
1594
+ return date + extra;
1595
+ }
1596
+ function formatJsonRpcRequest(method, params) {
1597
+ return {
1598
+ id: getPayloadId(),
1599
+ jsonrpc: "2.0",
1600
+ method,
1601
+ params
1602
+ };
1603
+ }
1604
+ function deepMerge(target, source) {
1605
+ const isObject = (obj) => obj && typeof obj === "object";
1606
+ if (!isObject(target) || !isObject(source)) {
1607
+ throw new Error("Target and source must be objects");
1608
+ }
1609
+ Object.keys(source).forEach((key) => {
1610
+ const targetValue = target[key];
1611
+ const sourceValue = source[key];
1612
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
1613
+ target[key] = targetValue.concat(sourceValue);
1614
+ } else if (isObject(targetValue) && isObject(sourceValue)) {
1615
+ target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
1616
+ } else {
1617
+ target[key] = sourceValue;
1618
+ }
1619
+ });
1620
+ return target;
1621
+ }
1622
+ function generateUuid() {
1623
+ if (window.crypto.randomUUID) {
1624
+ return window.crypto.randomUUID();
1625
+ }
1626
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (value) => {
1627
+ const valueAsNumber = parseInt(value);
1628
+ return (valueAsNumber ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> valueAsNumber / 4).toString(16);
1629
+ });
1630
+ }
1631
+ var icon7 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxuczpzZXJpZj0iaHR0cDovL3d3dy5zZXJpZi5jb20vIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjI7Ij4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjEwMjQiLz4KICAgIDxnIHRyYW5zZm9ybT0ibWF0cml4KDEuNjgyMDksMCwwLDEuNjgyMDksMjI2LjM2OCwyMTIuODE4KSI+CiAgICAgICAgPHBhdGggZD0iTTMyNy4wNDksMjgwLjE5MkwxNjkuNTI0LDEzTDEyLDI4MC4xOTJMMTY5LjUyNCwxODkuMDg0TDMyNy4wNDksMjgwLjE5MloiIHN0eWxlPSJmaWxsOndoaXRlO2ZpbGwtcnVsZTpub256ZXJvOyIvPgogICAgPC9nPgogICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMS42ODIwOSwwLDAsMS42ODIwOSwyMjYuMzY4LDIxMi44MTgpIj4KICAgICAgICA8cGF0aCBkPSJNMjk5LjU0NiwzMDdMMTY5LjUyNSwyMzguNDczTDM5LjUwNCwzMDdMMTY5LjUyNSwyNjQuNjdMMjk5LjU0NiwzMDdaIiBzdHlsZT0iZmlsbDp3aGl0ZTtmaWxsLXJ1bGU6bm9uemVybzsiLz4KICAgIDwvZz4KPC9zdmc+Cg==";
1632
+ var DeflyWallet = class extends BaseWallet {
1633
+ client = null;
1634
+ options;
1635
+ store;
1636
+ constructor({
1637
+ id,
1638
+ store,
1639
+ subscribe,
1640
+ getAlgodClient,
1641
+ options = {},
1642
+ metadata = {}
1643
+ }) {
1644
+ super({ id, metadata, getAlgodClient, store, subscribe });
1645
+ this.options = options;
1646
+ this.store = store;
1647
+ }
1648
+ static defaultMetadata = { name: "Defly", icon: icon7 };
1649
+ async initializeClient() {
1650
+ console.info("[DeflyWallet] Initializing client...");
1651
+ const module = await import("./dist/ONNQ4WBY.jsx");
1652
+ const DeflyWalletConnect = module.default ? module.default.DeflyWalletConnect : module.DeflyWalletConnect;
1653
+ const client = new DeflyWalletConnect(this.options);
1654
+ client.connector?.on("disconnect", this.onDisconnect);
1655
+ this.client = client;
1656
+ return client;
1657
+ }
1658
+ connect = async () => {
1659
+ console.info("[DeflyWallet] Connecting...");
1660
+ try {
1661
+ const client = this.client || await this.initializeClient();
1662
+ const accounts = await client.connect();
1663
+ if (accounts.length === 0) {
1664
+ throw new Error("No accounts found!");
1665
+ }
1666
+ const walletAccounts = accounts.map((address, idx) => ({
1667
+ name: `Defly Wallet ${idx + 1}`,
1668
+ address
1669
+ }));
1670
+ const activeAccount = walletAccounts[0];
1671
+ addWallet(this.store, {
1672
+ walletId: this.id,
1673
+ wallet: {
1674
+ accounts: walletAccounts,
1675
+ activeAccount
1676
+ }
1677
+ });
1678
+ return walletAccounts;
1679
+ } catch (error) {
1680
+ if (error?.data?.type !== "CONNECT_MODAL_CLOSED") {
1681
+ console.error(`[DeflyWallet] Error connecting: ${error.message}`);
1682
+ } else {
1683
+ console.info("[DeflyWallet] Connection cancelled.");
1684
+ }
1685
+ return [];
1686
+ }
1687
+ };
1688
+ disconnect = async () => {
1689
+ console.info("[DeflyWallet] Disconnecting...");
1690
+ try {
1691
+ await this.client?.disconnect();
1692
+ this.onDisconnect();
1693
+ } catch (error) {
1694
+ console.error(error);
1695
+ }
1696
+ };
1697
+ resumeSession = async () => {
1698
+ try {
1699
+ const state = this.store.state;
1700
+ const walletState = state.wallets[this.id];
1701
+ if (!walletState) {
1702
+ return;
1703
+ }
1704
+ console.info("[DeflyWallet] Resuming session...");
1705
+ const client = this.client || await this.initializeClient();
1706
+ const accounts = await client.reconnectSession();
1707
+ if (accounts.length === 0) {
1708
+ throw new Error("[DeflyWallet] No accounts found!");
1709
+ }
1710
+ const walletAccounts = accounts.map((address, idx) => ({
1711
+ name: `Defly Wallet ${idx + 1}`,
1712
+ address
1713
+ }));
1714
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1715
+ if (!match) {
1716
+ console.warn(`[DeflyWallet] Session accounts mismatch, updating accounts`);
1717
+ setAccounts(this.store, {
1718
+ walletId: this.id,
1719
+ accounts: walletAccounts
1720
+ });
1721
+ }
1722
+ } catch (error) {
1723
+ console.error(`[DeflyWallet] Error resuming session: ${error.message}`);
1724
+ this.onDisconnect();
1725
+ }
1726
+ };
1727
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1728
+ if (!this.client) {
1729
+ throw new Error("[DeflyWallet] Client not initialized!");
1730
+ }
1731
+ const txnsToSign = [];
1732
+ const signedIndexes = [];
1733
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1734
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1735
+ return esm_default.decodeObj(txn);
1736
+ });
1737
+ decodedObjects.forEach((txnObject, idx) => {
1738
+ const isSigned = isSignedTxnObject(txnObject);
1739
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1740
+ const txnBuffer = msgpackTxnGroup[idx];
1741
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1742
+ if (shouldSign) {
1743
+ txnsToSign.push({ txn });
1744
+ signedIndexes.push(idx);
1745
+ } else {
1746
+ txnsToSign.push({ txn, signers: [] });
1747
+ }
1748
+ });
1749
+ const signedTxns = await this.client.signTransaction([txnsToSign]);
1750
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1751
+ signedTxns,
1752
+ msgpackTxnGroup,
1753
+ signedIndexes,
1754
+ returnGroup
1755
+ );
1756
+ return txnGroupSigned;
1757
+ };
1758
+ transactionSigner = async (txnGroup, indexesToSign) => {
1759
+ if (!this.client) {
1760
+ throw new Error("[DeflyWallet] Client not initialized!");
1761
+ }
1762
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1763
+ if (indexesToSign.includes(idx)) {
1764
+ acc.push({ txn });
1765
+ } else {
1766
+ acc.push({ txn, signers: [] });
1767
+ }
1768
+ return acc;
1769
+ }, []);
1770
+ const signTxnsResult = await this.client.signTransaction([txnsToSign]);
1771
+ return signTxnsResult;
1772
+ };
1773
+ };
1774
+ var defaultState = {
1775
+ wallets: {},
1776
+ activeWallet: null,
1777
+ activeNetwork: "testnet"
1778
+ /* TESTNET */
1779
+ };
1780
+ var LOCAL_STORAGE_KEY = "@txnlab/use-wallet:v3";
1781
+ function addWallet(store, { walletId, wallet }) {
1782
+ store.setState((state) => {
1783
+ const newWallets = {
1784
+ ...state.wallets,
1785
+ [walletId]: wallet
1786
+ };
1787
+ return {
1788
+ ...state,
1789
+ wallets: newWallets,
1790
+ activeWallet: walletId
1791
+ };
1792
+ });
1793
+ }
1794
+ function removeWallet(store, { walletId }) {
1795
+ store.setState((state) => {
1796
+ const newWallets = { ...state.wallets };
1797
+ delete newWallets[walletId];
1798
+ return {
1799
+ ...state,
1800
+ wallets: newWallets,
1801
+ activeWallet: state.activeWallet === walletId ? null : state.activeWallet
1802
+ };
1803
+ });
1804
+ }
1805
+ function setActiveWallet(store, { walletId }) {
1806
+ store.setState((state) => {
1807
+ return {
1808
+ ...state,
1809
+ activeWallet: walletId
1810
+ };
1811
+ });
1812
+ }
1813
+ function setActiveAccount(store, { walletId, address }) {
1814
+ store.setState((state) => {
1815
+ const wallet = state.wallets[walletId];
1816
+ if (!wallet) {
1817
+ return state;
1818
+ }
1819
+ const activeAccount = wallet.accounts.find((a) => a.address === address);
1820
+ if (!activeAccount) {
1821
+ return state;
1822
+ }
1823
+ const newWallets = {
1824
+ ...state.wallets,
1825
+ [walletId]: {
1826
+ ...wallet,
1827
+ activeAccount
1828
+ }
1829
+ };
1830
+ return {
1831
+ ...state,
1832
+ wallets: newWallets
1833
+ };
1834
+ });
1835
+ }
1836
+ function setAccounts(store, { walletId, accounts }) {
1837
+ store.setState((state) => {
1838
+ const wallet = state.wallets[walletId];
1839
+ if (!wallet) {
1840
+ return state;
1841
+ }
1842
+ const isActiveAccountConnected = accounts.some(
1843
+ (account) => account.address === wallet.activeAccount?.address
1844
+ );
1845
+ const activeAccount = isActiveAccountConnected ? wallet.activeAccount : accounts[0] || null;
1846
+ const newWallet = {
1847
+ ...wallet,
1848
+ accounts,
1849
+ activeAccount
1850
+ };
1851
+ const newWallets = {
1852
+ ...state.wallets,
1853
+ [walletId]: newWallet
1854
+ };
1855
+ return {
1856
+ ...state,
1857
+ wallets: newWallets
1858
+ };
1859
+ });
1860
+ }
1861
+ function setActiveNetwork(store, { networkId }) {
1862
+ store.setState((state) => {
1863
+ return {
1864
+ ...state,
1865
+ activeNetwork: networkId
1866
+ };
1867
+ });
1868
+ }
1869
+ function isValidWalletId(walletId) {
1870
+ return Object.values(WalletId).includes(walletId);
1871
+ }
1872
+ function isValidWalletAccount(account) {
1873
+ return typeof account === "object" && account !== null && typeof account.name === "string" && typeof account.address === "string";
1874
+ }
1875
+ function isValidWalletState(wallet) {
1876
+ return typeof wallet === "object" && wallet !== null && Array.isArray(wallet.accounts) && wallet.accounts.every(isValidWalletAccount) && (wallet.activeAccount === null || isValidWalletAccount(wallet.activeAccount));
1877
+ }
1878
+ function isValidState(state) {
1879
+ if (!state || typeof state !== "object")
1880
+ return false;
1881
+ if (typeof state.wallets !== "object")
1882
+ return false;
1883
+ for (const [walletId, wallet] of Object.entries(state.wallets)) {
1884
+ if (!isValidWalletId(walletId) || !isValidWalletState(wallet))
1885
+ return false;
1886
+ }
1887
+ if (state.activeWallet !== null && !isValidWalletId(state.activeWallet))
1888
+ return false;
1889
+ if (!isValidNetworkId(state.activeNetwork))
1890
+ return false;
1891
+ return true;
1892
+ }
1893
+ var WalletManager = class {
1894
+ _clients = /* @__PURE__ */ new Map();
1895
+ networkConfig;
1896
+ algodClient;
1897
+ store;
1898
+ subscribe;
1899
+ constructor({ wallets = [], network = "testnet", algod = {} } = {}) {
1900
+ const initialState = this.loadPersistedState() || {
1901
+ ...defaultState,
1902
+ activeNetwork: network
1903
+ };
1904
+ this.store = new Store(initialState, {
1905
+ onUpdate: () => this.savePersistedState()
1906
+ });
1907
+ this.savePersistedState();
1908
+ this.subscribe = (callback) => {
1909
+ const unsubscribe = this.store.subscribe(() => {
1910
+ callback(this.store.state);
1911
+ });
1912
+ return unsubscribe;
1913
+ };
1914
+ this.networkConfig = this.initNetworkConfig(network, algod);
1915
+ this.algodClient = this.createAlgodClient(this.networkConfig[network]);
1916
+ this.initializeWallets(wallets);
1917
+ }
1918
+ // ---------- Store ------------------------------------------------- //
1919
+ loadPersistedState() {
1920
+ try {
1921
+ const serializedState = StorageAdapter.getItem(LOCAL_STORAGE_KEY);
1922
+ if (serializedState === null) {
1923
+ return null;
1924
+ }
1925
+ const parsedState = JSON.parse(serializedState);
1926
+ if (!isValidState(parsedState)) {
1927
+ console.warn("[Store] Parsed state:", parsedState);
1928
+ throw new Error("Persisted state is invalid");
1929
+ }
1930
+ return parsedState;
1931
+ } catch (error) {
1932
+ console.error(`[Store] Could not load state from local storage: ${error.message}`);
1933
+ return null;
1934
+ }
1935
+ }
1936
+ savePersistedState() {
1937
+ try {
1938
+ const state = this.store.state;
1939
+ const serializedState = JSON.stringify(state);
1940
+ StorageAdapter.setItem(LOCAL_STORAGE_KEY, serializedState);
1941
+ } catch (error) {
1942
+ console.error("[Store] Could not save state to local storage:", error);
1943
+ }
1944
+ }
1945
+ // ---------- Wallets ----------------------------------------------- //
1946
+ initializeWallets(walletsConfig) {
1947
+ console.info("[Manager] Initializing wallets...");
1948
+ for (const walletConfig of walletsConfig) {
1949
+ let walletId;
1950
+ let walletOptions;
1951
+ let walletMetadata;
1952
+ if (typeof walletConfig === "string") {
1953
+ walletId = walletConfig;
1954
+ } else {
1955
+ const { id, options, metadata } = walletConfig;
1956
+ walletId = id;
1957
+ walletOptions = options;
1958
+ walletMetadata = metadata;
1959
+ }
1960
+ const walletMap = createWalletMap();
1961
+ const WalletClass = walletMap[walletId];
1962
+ if (!WalletClass) {
1963
+ console.error(`[Manager] Wallet not found: ${walletId}`);
1964
+ continue;
1965
+ }
1966
+ const walletInstance = new WalletClass({
1967
+ id: walletId,
1968
+ metadata: walletMetadata,
1969
+ options: walletOptions,
1970
+ getAlgodClient: this.getAlgodClient,
1971
+ store: this.store,
1972
+ subscribe: this.subscribe
1973
+ });
1974
+ this._clients.set(walletId, walletInstance);
1975
+ console.info(`[Manager] \u2705 Initialized ${walletId}`);
1976
+ }
1977
+ const state = this.store.state;
1978
+ const connectedWallets = Object.keys(state.wallets);
1979
+ for (const walletId of connectedWallets) {
1980
+ if (!this._clients.has(walletId)) {
1981
+ console.warn(`[Manager] Connected wallet not found: ${walletId}`);
1982
+ removeWallet(this.store, { walletId });
1983
+ }
1984
+ }
1985
+ if (state.activeWallet && !this._clients.has(state.activeWallet)) {
1986
+ console.warn(`[Manager] Active wallet not found: ${state.activeWallet}`);
1987
+ setActiveWallet(this.store, { walletId: null });
1988
+ }
1989
+ }
1990
+ get wallets() {
1991
+ return [...this._clients.values()];
1992
+ }
1993
+ getWallet(walletId) {
1994
+ return this._clients.get(walletId);
1995
+ }
1996
+ async resumeSessions() {
1997
+ const promises = this.wallets.map((wallet) => wallet?.resumeSession());
1998
+ await Promise.all(promises);
1999
+ }
2000
+ // ---------- Network ----------------------------------------------- //
2001
+ initNetworkConfig(network, config) {
2002
+ console.info("[Manager] Initializing network...");
2003
+ let networkConfig = createDefaultNetworkConfig();
2004
+ if (isNetworkConfigMap(config)) {
2005
+ networkConfig = deepMerge(networkConfig, config);
2006
+ } else {
2007
+ networkConfig[network] = deepMerge(networkConfig[network], config);
2008
+ }
2009
+ console.info("[Manager] Algodv2 config:", networkConfig);
2010
+ return networkConfig;
2011
+ }
2012
+ createAlgodClient(config) {
2013
+ console.info(`[Manager] Creating Algodv2 client for ${this.activeNetwork}...`);
2014
+ const { token = "", baseServer, port = "", headers = {} } = config;
2015
+ return new esm_default.Algodv2(token, baseServer, port, headers);
2016
+ }
2017
+ getAlgodClient = () => {
2018
+ return this.algodClient;
2019
+ };
2020
+ setActiveNetwork = (networkId) => {
2021
+ setActiveNetwork(this.store, { networkId });
2022
+ this.algodClient = this.createAlgodClient(this.networkConfig[networkId]);
2023
+ };
2024
+ get activeNetwork() {
2025
+ return this.store.state.activeNetwork;
2026
+ }
2027
+ // ---------- Active Wallet ----------------------------------------- //
2028
+ get activeWallet() {
2029
+ const state = this.store.state;
2030
+ const activeWallet = this.wallets.find((wallet) => wallet.id === state.activeWallet);
2031
+ if (!activeWallet) {
2032
+ return null;
2033
+ }
2034
+ return activeWallet;
2035
+ }
2036
+ get activeWalletAccounts() {
2037
+ if (!this.activeWallet) {
2038
+ return null;
2039
+ }
2040
+ return this.activeWallet.accounts;
2041
+ }
2042
+ get activeWalletAddresses() {
2043
+ if (!this.activeWallet) {
2044
+ return null;
2045
+ }
2046
+ return this.activeWallet.accounts.map((account) => account.address);
2047
+ }
2048
+ get activeAccount() {
2049
+ if (!this.activeWallet) {
2050
+ return null;
2051
+ }
2052
+ return this.activeWallet.activeAccount;
2053
+ }
2054
+ get activeAddress() {
2055
+ if (!this.activeAccount) {
2056
+ return null;
2057
+ }
2058
+ return this.activeAccount.address;
2059
+ }
2060
+ // ---------- Sign Transactions ------------------------------------- //
2061
+ get signTransactions() {
2062
+ if (!this.activeWallet) {
2063
+ throw new Error("[Manager] No active wallet found!");
2064
+ }
2065
+ return this.activeWallet.signTransactions;
2066
+ }
2067
+ /**
2068
+ * A function which can sign transactions from an atomic transaction group. The logic will be
2069
+ * specific to each wallet, but the function will always return a promise that resolves to an
2070
+ * array of encoded signed transactions matching the length of the indexesToSign array.
2071
+ *
2072
+ * @see https://github.com/algorand/js-algorand-sdk/blob/v2.6.0/src/signer.ts#L7-L18
2073
+ *
2074
+ * @param txnGroup - The atomic group containing transactions to be signed
2075
+ * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed
2076
+ * @returns A promise which resolves an array of encoded signed transactions. The length of the
2077
+ * array will be the same as the length of indexesToSign, and each index i in the array
2078
+ * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
2079
+ */
2080
+ get transactionSigner() {
2081
+ if (!this.activeWallet) {
2082
+ throw new Error("[Manager] No active wallet found!");
2083
+ }
2084
+ return this.activeWallet.transactionSigner;
2085
+ }
2086
+ };
2087
+
2088
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/solid.js
2089
+ var sharedConfig = {
2090
+ context: void 0,
2091
+ registry: void 0
2092
+ };
2093
+ function setHydrateContext(context) {
2094
+ sharedConfig.context = context;
2095
+ }
2096
+ var equalFn = (a, b) => a === b;
2097
+ var $PROXY = Symbol("solid-proxy");
2098
+ var $TRACK = Symbol("solid-track");
2099
+ var $DEVCOMP = Symbol("solid-dev-component");
2100
+ var signalOptions = {
2101
+ equals: equalFn
2102
+ };
2103
+ var ERROR = null;
2104
+ var runEffects = runQueue;
2105
+ var STALE = 1;
2106
+ var PENDING = 2;
2107
+ var UNOWNED = {
2108
+ owned: null,
2109
+ cleanups: null,
2110
+ context: null,
2111
+ owner: null
2112
+ };
2113
+ var Owner = null;
2114
+ var Transition = null;
2115
+ var Scheduler = null;
2116
+ var ExternalSourceConfig = null;
2117
+ var Listener = null;
2118
+ var Updates = null;
2119
+ var Effects = null;
2120
+ var ExecCount = 0;
2121
+ function createSignal(value, options) {
2122
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
2123
+ const s = {
2124
+ value,
2125
+ observers: null,
2126
+ observerSlots: null,
2127
+ comparator: options.equals || void 0
2128
+ };
2129
+ const setter = (value2) => {
2130
+ if (typeof value2 === "function") {
2131
+ if (Transition && Transition.running && Transition.sources.has(s))
2132
+ value2 = value2(s.tValue);
2133
+ else
2134
+ value2 = value2(s.value);
2135
+ }
2136
+ return writeSignal(s, value2);
2137
+ };
2138
+ return [readSignal.bind(s), setter];
2139
+ }
2140
+ function createRenderEffect(fn, value, options) {
2141
+ const c = createComputation(fn, value, false, STALE);
2142
+ if (Scheduler && Transition && Transition.running)
2143
+ Updates.push(c);
2144
+ else
2145
+ updateComputation(c);
2146
+ }
2147
+ function createEffect(fn, value, options) {
2148
+ runEffects = runUserEffects;
2149
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
2150
+ if (s)
2151
+ c.suspense = s;
2152
+ if (!options || !options.render)
2153
+ c.user = true;
2154
+ Effects ? Effects.push(c) : updateComputation(c);
2155
+ }
2156
+ function createMemo(fn, value, options) {
2157
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
2158
+ const c = createComputation(fn, value, true, 0);
2159
+ c.observers = null;
2160
+ c.observerSlots = null;
2161
+ c.comparator = options.equals || void 0;
2162
+ if (Scheduler && Transition && Transition.running) {
2163
+ c.tState = STALE;
2164
+ Updates.push(c);
2165
+ } else
2166
+ updateComputation(c);
2167
+ return readSignal.bind(c);
2168
+ }
2169
+ function batch(fn) {
2170
+ return runUpdates(fn, false);
2171
+ }
2172
+ function untrack(fn) {
2173
+ if (!ExternalSourceConfig && Listener === null)
2174
+ return fn();
2175
+ const listener = Listener;
2176
+ Listener = null;
2177
+ try {
2178
+ if (ExternalSourceConfig)
2179
+ return ExternalSourceConfig.untrack(fn);
2180
+ return fn();
2181
+ } finally {
2182
+ Listener = listener;
2183
+ }
2184
+ }
2185
+ function onMount(fn) {
2186
+ createEffect(() => untrack(fn));
2187
+ }
2188
+ function onCleanup(fn) {
2189
+ if (Owner === null)
2190
+ ;
2191
+ else if (Owner.cleanups === null)
2192
+ Owner.cleanups = [fn];
2193
+ else
2194
+ Owner.cleanups.push(fn);
2195
+ return fn;
2196
+ }
2197
+ function getListener() {
2198
+ return Listener;
2199
+ }
2200
+ function startTransition(fn) {
2201
+ if (Transition && Transition.running) {
2202
+ fn();
2203
+ return Transition.done;
2204
+ }
2205
+ const l = Listener;
2206
+ const o = Owner;
2207
+ return Promise.resolve().then(() => {
2208
+ Listener = l;
2209
+ Owner = o;
2210
+ let t;
2211
+ if (Scheduler || SuspenseContext) {
2212
+ t = Transition || (Transition = {
2213
+ sources: /* @__PURE__ */ new Set(),
2214
+ effects: [],
2215
+ promises: /* @__PURE__ */ new Set(),
2216
+ disposed: /* @__PURE__ */ new Set(),
2217
+ queue: /* @__PURE__ */ new Set(),
2218
+ running: true
2219
+ });
2220
+ t.done || (t.done = new Promise((res) => t.resolve = res));
2221
+ t.running = true;
2222
+ }
2223
+ runUpdates(fn, false);
2224
+ Listener = Owner = null;
2225
+ return t ? t.done : void 0;
2226
+ });
2227
+ }
2228
+ var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
2229
+ function createContext(defaultValue, options) {
2230
+ const id = Symbol("context");
2231
+ return {
2232
+ id,
2233
+ Provider: createProvider(id),
2234
+ defaultValue
2235
+ };
2236
+ }
2237
+ function useContext(context) {
2238
+ return Owner && Owner.context && Owner.context[context.id] !== void 0 ? Owner.context[context.id] : context.defaultValue;
2239
+ }
2240
+ function children(fn) {
2241
+ const children2 = createMemo(fn);
2242
+ const memo = createMemo(() => resolveChildren(children2()));
2243
+ memo.toArray = () => {
2244
+ const c = memo();
2245
+ return Array.isArray(c) ? c : c != null ? [c] : [];
2246
+ };
2247
+ return memo;
2248
+ }
2249
+ var SuspenseContext;
2250
+ function readSignal() {
2251
+ const runningTransition = Transition && Transition.running;
2252
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
2253
+ if ((runningTransition ? this.tState : this.state) === STALE)
2254
+ updateComputation(this);
2255
+ else {
2256
+ const updates = Updates;
2257
+ Updates = null;
2258
+ runUpdates(() => lookUpstream(this), false);
2259
+ Updates = updates;
2260
+ }
2261
+ }
2262
+ if (Listener) {
2263
+ const sSlot = this.observers ? this.observers.length : 0;
2264
+ if (!Listener.sources) {
2265
+ Listener.sources = [this];
2266
+ Listener.sourceSlots = [sSlot];
2267
+ } else {
2268
+ Listener.sources.push(this);
2269
+ Listener.sourceSlots.push(sSlot);
2270
+ }
2271
+ if (!this.observers) {
2272
+ this.observers = [Listener];
2273
+ this.observerSlots = [Listener.sources.length - 1];
2274
+ } else {
2275
+ this.observers.push(Listener);
2276
+ this.observerSlots.push(Listener.sources.length - 1);
2277
+ }
2278
+ }
2279
+ if (runningTransition && Transition.sources.has(this))
2280
+ return this.tValue;
2281
+ return this.value;
2282
+ }
2283
+ function writeSignal(node, value, isComp) {
2284
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
2285
+ if (!node.comparator || !node.comparator(current, value)) {
2286
+ if (Transition) {
2287
+ const TransitionRunning = Transition.running;
2288
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
2289
+ Transition.sources.add(node);
2290
+ node.tValue = value;
2291
+ }
2292
+ if (!TransitionRunning)
2293
+ node.value = value;
2294
+ } else
2295
+ node.value = value;
2296
+ if (node.observers && node.observers.length) {
2297
+ runUpdates(() => {
2298
+ for (let i = 0; i < node.observers.length; i += 1) {
2299
+ const o = node.observers[i];
2300
+ const TransitionRunning = Transition && Transition.running;
2301
+ if (TransitionRunning && Transition.disposed.has(o))
2302
+ continue;
2303
+ if (TransitionRunning ? !o.tState : !o.state) {
2304
+ if (o.pure)
2305
+ Updates.push(o);
2306
+ else
2307
+ Effects.push(o);
2308
+ if (o.observers)
2309
+ markDownstream(o);
2310
+ }
2311
+ if (!TransitionRunning)
2312
+ o.state = STALE;
2313
+ else
2314
+ o.tState = STALE;
2315
+ }
2316
+ if (Updates.length > 1e6) {
2317
+ Updates = [];
2318
+ if (false)
2319
+ ;
2320
+ throw new Error();
2321
+ }
2322
+ }, false);
2323
+ }
2324
+ }
2325
+ return value;
2326
+ }
2327
+ function updateComputation(node) {
2328
+ if (!node.fn)
2329
+ return;
2330
+ cleanNode(node);
2331
+ const time = ExecCount;
2332
+ runComputation(
2333
+ node,
2334
+ Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
2335
+ time
2336
+ );
2337
+ if (Transition && !Transition.running && Transition.sources.has(node)) {
2338
+ queueMicrotask(() => {
2339
+ runUpdates(() => {
2340
+ Transition && (Transition.running = true);
2341
+ Listener = Owner = node;
2342
+ runComputation(node, node.tValue, time);
2343
+ Listener = Owner = null;
2344
+ }, false);
2345
+ });
2346
+ }
2347
+ }
2348
+ function runComputation(node, value, time) {
2349
+ let nextValue;
2350
+ const owner = Owner, listener = Listener;
2351
+ Listener = Owner = node;
2352
+ try {
2353
+ nextValue = node.fn(value);
2354
+ } catch (err) {
2355
+ if (node.pure) {
2356
+ if (Transition && Transition.running) {
2357
+ node.tState = STALE;
2358
+ node.tOwned && node.tOwned.forEach(cleanNode);
2359
+ node.tOwned = void 0;
2360
+ } else {
2361
+ node.state = STALE;
2362
+ node.owned && node.owned.forEach(cleanNode);
2363
+ node.owned = null;
2364
+ }
2365
+ }
2366
+ node.updatedAt = time + 1;
2367
+ return handleError(err);
2368
+ } finally {
2369
+ Listener = listener;
2370
+ Owner = owner;
2371
+ }
2372
+ if (!node.updatedAt || node.updatedAt <= time) {
2373
+ if (node.updatedAt != null && "observers" in node) {
2374
+ writeSignal(node, nextValue, true);
2375
+ } else if (Transition && Transition.running && node.pure) {
2376
+ Transition.sources.add(node);
2377
+ node.tValue = nextValue;
2378
+ } else
2379
+ node.value = nextValue;
2380
+ node.updatedAt = time;
2381
+ }
2382
+ }
2383
+ function createComputation(fn, init, pure, state = STALE, options) {
2384
+ const c = {
2385
+ fn,
2386
+ state,
2387
+ updatedAt: null,
2388
+ owned: null,
2389
+ sources: null,
2390
+ sourceSlots: null,
2391
+ cleanups: null,
2392
+ value: init,
2393
+ owner: Owner,
2394
+ context: Owner ? Owner.context : null,
2395
+ pure
2396
+ };
2397
+ if (Transition && Transition.running) {
2398
+ c.state = 0;
2399
+ c.tState = state;
2400
+ }
2401
+ if (Owner === null)
2402
+ ;
2403
+ else if (Owner !== UNOWNED) {
2404
+ if (Transition && Transition.running && Owner.pure) {
2405
+ if (!Owner.tOwned)
2406
+ Owner.tOwned = [c];
2407
+ else
2408
+ Owner.tOwned.push(c);
2409
+ } else {
2410
+ if (!Owner.owned)
2411
+ Owner.owned = [c];
2412
+ else
2413
+ Owner.owned.push(c);
2414
+ }
2415
+ }
2416
+ if (ExternalSourceConfig && c.fn) {
2417
+ const [track, trigger] = createSignal(void 0, {
2418
+ equals: false
2419
+ });
2420
+ const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
2421
+ onCleanup(() => ordinary.dispose());
2422
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
2423
+ const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
2424
+ c.fn = (x) => {
2425
+ track();
2426
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
2427
+ };
2428
+ }
2429
+ return c;
2430
+ }
2431
+ function runTop(node) {
2432
+ const runningTransition = Transition && Transition.running;
2433
+ if ((runningTransition ? node.tState : node.state) === 0)
2434
+ return;
2435
+ if ((runningTransition ? node.tState : node.state) === PENDING)
2436
+ return lookUpstream(node);
2437
+ if (node.suspense && untrack(node.suspense.inFallback))
2438
+ return node.suspense.effects.push(node);
2439
+ const ancestors = [node];
2440
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
2441
+ if (runningTransition && Transition.disposed.has(node))
2442
+ return;
2443
+ if (runningTransition ? node.tState : node.state)
2444
+ ancestors.push(node);
2445
+ }
2446
+ for (let i = ancestors.length - 1; i >= 0; i--) {
2447
+ node = ancestors[i];
2448
+ if (runningTransition) {
2449
+ let top = node, prev = ancestors[i + 1];
2450
+ while ((top = top.owner) && top !== prev) {
2451
+ if (Transition.disposed.has(top))
2452
+ return;
2453
+ }
2454
+ }
2455
+ if ((runningTransition ? node.tState : node.state) === STALE) {
2456
+ updateComputation(node);
2457
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
2458
+ const updates = Updates;
2459
+ Updates = null;
2460
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
2461
+ Updates = updates;
2462
+ }
2463
+ }
2464
+ }
2465
+ function runUpdates(fn, init) {
2466
+ if (Updates)
2467
+ return fn();
2468
+ let wait = false;
2469
+ if (!init)
2470
+ Updates = [];
2471
+ if (Effects)
2472
+ wait = true;
2473
+ else
2474
+ Effects = [];
2475
+ ExecCount++;
2476
+ try {
2477
+ const res = fn();
2478
+ completeUpdates(wait);
2479
+ return res;
2480
+ } catch (err) {
2481
+ if (!wait)
2482
+ Effects = null;
2483
+ Updates = null;
2484
+ handleError(err);
2485
+ }
2486
+ }
2487
+ function completeUpdates(wait) {
2488
+ if (Updates) {
2489
+ if (Scheduler && Transition && Transition.running)
2490
+ scheduleQueue(Updates);
2491
+ else
2492
+ runQueue(Updates);
2493
+ Updates = null;
2494
+ }
2495
+ if (wait)
2496
+ return;
2497
+ let res;
2498
+ if (Transition) {
2499
+ if (!Transition.promises.size && !Transition.queue.size) {
2500
+ const sources = Transition.sources;
2501
+ const disposed = Transition.disposed;
2502
+ Effects.push.apply(Effects, Transition.effects);
2503
+ res = Transition.resolve;
2504
+ for (const e2 of Effects) {
2505
+ "tState" in e2 && (e2.state = e2.tState);
2506
+ delete e2.tState;
2507
+ }
2508
+ Transition = null;
2509
+ runUpdates(() => {
2510
+ for (const d of disposed)
2511
+ cleanNode(d);
2512
+ for (const v of sources) {
2513
+ v.value = v.tValue;
2514
+ if (v.owned) {
2515
+ for (let i = 0, len = v.owned.length; i < len; i++)
2516
+ cleanNode(v.owned[i]);
2517
+ }
2518
+ if (v.tOwned)
2519
+ v.owned = v.tOwned;
2520
+ delete v.tValue;
2521
+ delete v.tOwned;
2522
+ v.tState = 0;
2523
+ }
2524
+ setTransPending(false);
2525
+ }, false);
2526
+ } else if (Transition.running) {
2527
+ Transition.running = false;
2528
+ Transition.effects.push.apply(Transition.effects, Effects);
2529
+ Effects = null;
2530
+ setTransPending(true);
2531
+ return;
2532
+ }
2533
+ }
2534
+ const e = Effects;
2535
+ Effects = null;
2536
+ if (e.length)
2537
+ runUpdates(() => runEffects(e), false);
2538
+ if (res)
2539
+ res();
2540
+ }
2541
+ function runQueue(queue) {
2542
+ for (let i = 0; i < queue.length; i++)
2543
+ runTop(queue[i]);
2544
+ }
2545
+ function scheduleQueue(queue) {
2546
+ for (let i = 0; i < queue.length; i++) {
2547
+ const item = queue[i];
2548
+ const tasks = Transition.queue;
2549
+ if (!tasks.has(item)) {
2550
+ tasks.add(item);
2551
+ Scheduler(() => {
2552
+ tasks.delete(item);
2553
+ runUpdates(() => {
2554
+ Transition.running = true;
2555
+ runTop(item);
2556
+ }, false);
2557
+ Transition && (Transition.running = false);
2558
+ });
2559
+ }
2560
+ }
2561
+ }
2562
+ function runUserEffects(queue) {
2563
+ let i, userLength = 0;
2564
+ for (i = 0; i < queue.length; i++) {
2565
+ const e = queue[i];
2566
+ if (!e.user)
2567
+ runTop(e);
2568
+ else
2569
+ queue[userLength++] = e;
2570
+ }
2571
+ if (sharedConfig.context) {
2572
+ if (sharedConfig.count) {
2573
+ sharedConfig.effects || (sharedConfig.effects = []);
2574
+ sharedConfig.effects.push(...queue.slice(0, userLength));
2575
+ return;
2576
+ } else if (sharedConfig.effects) {
2577
+ queue = [...sharedConfig.effects, ...queue];
2578
+ userLength += sharedConfig.effects.length;
2579
+ delete sharedConfig.effects;
2580
+ }
2581
+ setHydrateContext();
2582
+ }
2583
+ for (i = 0; i < userLength; i++)
2584
+ runTop(queue[i]);
2585
+ }
2586
+ function lookUpstream(node, ignore) {
2587
+ const runningTransition = Transition && Transition.running;
2588
+ if (runningTransition)
2589
+ node.tState = 0;
2590
+ else
2591
+ node.state = 0;
2592
+ for (let i = 0; i < node.sources.length; i += 1) {
2593
+ const source = node.sources[i];
2594
+ if (source.sources) {
2595
+ const state = runningTransition ? source.tState : source.state;
2596
+ if (state === STALE) {
2597
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
2598
+ runTop(source);
2599
+ } else if (state === PENDING)
2600
+ lookUpstream(source, ignore);
2601
+ }
2602
+ }
2603
+ }
2604
+ function markDownstream(node) {
2605
+ const runningTransition = Transition && Transition.running;
2606
+ for (let i = 0; i < node.observers.length; i += 1) {
2607
+ const o = node.observers[i];
2608
+ if (runningTransition ? !o.tState : !o.state) {
2609
+ if (runningTransition)
2610
+ o.tState = PENDING;
2611
+ else
2612
+ o.state = PENDING;
2613
+ if (o.pure)
2614
+ Updates.push(o);
2615
+ else
2616
+ Effects.push(o);
2617
+ o.observers && markDownstream(o);
2618
+ }
2619
+ }
2620
+ }
2621
+ function cleanNode(node) {
2622
+ let i;
2623
+ if (node.sources) {
2624
+ while (node.sources.length) {
2625
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
2626
+ if (obs && obs.length) {
2627
+ const n = obs.pop(), s = source.observerSlots.pop();
2628
+ if (index < obs.length) {
2629
+ n.sourceSlots[s] = index;
2630
+ obs[index] = n;
2631
+ source.observerSlots[index] = s;
2632
+ }
2633
+ }
2634
+ }
2635
+ }
2636
+ if (Transition && Transition.running && node.pure) {
2637
+ if (node.tOwned) {
2638
+ for (i = node.tOwned.length - 1; i >= 0; i--)
2639
+ cleanNode(node.tOwned[i]);
2640
+ delete node.tOwned;
2641
+ }
2642
+ reset(node, true);
2643
+ } else if (node.owned) {
2644
+ for (i = node.owned.length - 1; i >= 0; i--)
2645
+ cleanNode(node.owned[i]);
2646
+ node.owned = null;
2647
+ }
2648
+ if (node.cleanups) {
2649
+ for (i = node.cleanups.length - 1; i >= 0; i--)
2650
+ node.cleanups[i]();
2651
+ node.cleanups = null;
2652
+ }
2653
+ if (Transition && Transition.running)
2654
+ node.tState = 0;
2655
+ else
2656
+ node.state = 0;
2657
+ }
2658
+ function reset(node, top) {
2659
+ if (!top) {
2660
+ node.tState = 0;
2661
+ Transition.disposed.add(node);
2662
+ }
2663
+ if (node.owned) {
2664
+ for (let i = 0; i < node.owned.length; i++)
2665
+ reset(node.owned[i]);
2666
+ }
2667
+ }
2668
+ function castError(err) {
2669
+ if (err instanceof Error)
2670
+ return err;
2671
+ return new Error(typeof err === "string" ? err : "Unknown error", {
2672
+ cause: err
2673
+ });
2674
+ }
2675
+ function runErrors(err, fns, owner) {
2676
+ try {
2677
+ for (const f of fns)
2678
+ f(err);
2679
+ } catch (e) {
2680
+ handleError(e, owner && owner.owner || null);
2681
+ }
2682
+ }
2683
+ function handleError(err, owner = Owner) {
2684
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
2685
+ const error = castError(err);
2686
+ if (!fns)
2687
+ throw error;
2688
+ if (Effects)
2689
+ Effects.push({
2690
+ fn() {
2691
+ runErrors(error, fns, owner);
2692
+ },
2693
+ state: STALE
2694
+ });
2695
+ else
2696
+ runErrors(error, fns, owner);
2697
+ }
2698
+ function resolveChildren(children2) {
2699
+ if (typeof children2 === "function" && !children2.length)
2700
+ return resolveChildren(children2());
2701
+ if (Array.isArray(children2)) {
2702
+ const results = [];
2703
+ for (let i = 0; i < children2.length; i++) {
2704
+ const result = resolveChildren(children2[i]);
2705
+ Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
2706
+ }
2707
+ return results;
2708
+ }
2709
+ return children2;
2710
+ }
2711
+ function createProvider(id, options) {
2712
+ return function provider(props) {
2713
+ let res;
2714
+ createRenderEffect(
2715
+ () => res = untrack(() => {
2716
+ Owner.context = {
2717
+ ...Owner.context,
2718
+ [id]: props.value
2719
+ };
2720
+ return children(() => props.children);
2721
+ }),
2722
+ void 0
2723
+ );
2724
+ return res;
2725
+ };
2726
+ }
2727
+ var FALLBACK = Symbol("fallback");
2728
+ var SuspenseListContext = createContext();
2729
+
2730
+ // src/WalletProvider.tsx
2731
+ var WalletContext = createContext();
2732
+ var WalletProvider = (props) => {
2733
+ const store = () => props.manager;
2734
+ onMount(async () => {
2735
+ try {
2736
+ await props.manager.resumeSessions();
2737
+ } catch (error) {
2738
+ console.error("Error resuming sessions:", error);
2739
+ }
2740
+ });
2741
+ return <WalletContext.Provider value={store}>{props.children}</WalletContext.Provider>;
2742
+ };
2743
+ var useWalletManager = () => {
2744
+ const manager = useContext(WalletContext);
2745
+ if (!manager) {
2746
+ throw new Error("useWalletManager must be used within a WalletProvider");
2747
+ }
2748
+ return manager();
2749
+ };
2750
+
2751
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/store/dist/store.js
2752
+ var $RAW = Symbol("store-raw");
2753
+ var $NODE = Symbol("store-node");
2754
+ var $HAS = Symbol("store-has");
2755
+ var $SELF = Symbol("store-self");
2756
+ function wrap$1(value) {
2757
+ let p = value[$PROXY];
2758
+ if (!p) {
2759
+ Object.defineProperty(value, $PROXY, {
2760
+ value: p = new Proxy(value, proxyTraps$1)
2761
+ });
2762
+ if (!Array.isArray(value)) {
2763
+ const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
2764
+ for (let i = 0, l = keys.length; i < l; i++) {
2765
+ const prop = keys[i];
2766
+ if (desc[prop].get) {
2767
+ Object.defineProperty(value, prop, {
2768
+ enumerable: desc[prop].enumerable,
2769
+ get: desc[prop].get.bind(p)
2770
+ });
2771
+ }
2772
+ }
2773
+ }
2774
+ }
2775
+ return p;
2776
+ }
2777
+ function isWrappable(obj) {
2778
+ let proto;
2779
+ return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
2780
+ }
2781
+ function unwrap(item, set = /* @__PURE__ */ new Set()) {
2782
+ let result, unwrapped, v, prop;
2783
+ if (result = item != null && item[$RAW])
2784
+ return result;
2785
+ if (!isWrappable(item) || set.has(item))
2786
+ return item;
2787
+ if (Array.isArray(item)) {
2788
+ if (Object.isFrozen(item))
2789
+ item = item.slice(0);
2790
+ else
2791
+ set.add(item);
2792
+ for (let i = 0, l = item.length; i < l; i++) {
2793
+ v = item[i];
2794
+ if ((unwrapped = unwrap(v, set)) !== v)
2795
+ item[i] = unwrapped;
2796
+ }
2797
+ } else {
2798
+ if (Object.isFrozen(item))
2799
+ item = Object.assign({}, item);
2800
+ else
2801
+ set.add(item);
2802
+ const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
2803
+ for (let i = 0, l = keys.length; i < l; i++) {
2804
+ prop = keys[i];
2805
+ if (desc[prop].get)
2806
+ continue;
2807
+ v = item[prop];
2808
+ if ((unwrapped = unwrap(v, set)) !== v)
2809
+ item[prop] = unwrapped;
2810
+ }
2811
+ }
2812
+ return item;
2813
+ }
2814
+ function getNodes(target, symbol) {
2815
+ let nodes = target[symbol];
2816
+ if (!nodes)
2817
+ Object.defineProperty(target, symbol, {
2818
+ value: nodes = /* @__PURE__ */ Object.create(null)
2819
+ });
2820
+ return nodes;
2821
+ }
2822
+ function getNode(nodes, property, value) {
2823
+ if (nodes[property])
2824
+ return nodes[property];
2825
+ const [s, set] = createSignal(value, {
2826
+ equals: false,
2827
+ internal: true
2828
+ });
2829
+ s.$ = set;
2830
+ return nodes[property] = s;
2831
+ }
2832
+ function proxyDescriptor$1(target, property) {
2833
+ const desc = Reflect.getOwnPropertyDescriptor(target, property);
2834
+ if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
2835
+ return desc;
2836
+ delete desc.value;
2837
+ delete desc.writable;
2838
+ desc.get = () => target[$PROXY][property];
2839
+ return desc;
2840
+ }
2841
+ function trackSelf(target) {
2842
+ getListener() && getNode(getNodes(target, $NODE), $SELF)();
2843
+ }
2844
+ function ownKeys(target) {
2845
+ trackSelf(target);
2846
+ return Reflect.ownKeys(target);
2847
+ }
2848
+ var proxyTraps$1 = {
2849
+ get(target, property, receiver) {
2850
+ if (property === $RAW)
2851
+ return target;
2852
+ if (property === $PROXY)
2853
+ return receiver;
2854
+ if (property === $TRACK) {
2855
+ trackSelf(target);
2856
+ return receiver;
2857
+ }
2858
+ const nodes = getNodes(target, $NODE);
2859
+ const tracked = nodes[property];
2860
+ let value = tracked ? tracked() : target[property];
2861
+ if (property === $NODE || property === $HAS || property === "__proto__")
2862
+ return value;
2863
+ if (!tracked) {
2864
+ const desc = Object.getOwnPropertyDescriptor(target, property);
2865
+ if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get))
2866
+ value = getNode(nodes, property, value)();
2867
+ }
2868
+ return isWrappable(value) ? wrap$1(value) : value;
2869
+ },
2870
+ has(target, property) {
2871
+ if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__")
2872
+ return true;
2873
+ getListener() && getNode(getNodes(target, $HAS), property)();
2874
+ return property in target;
2875
+ },
2876
+ set() {
2877
+ return true;
2878
+ },
2879
+ deleteProperty() {
2880
+ return true;
2881
+ },
2882
+ ownKeys,
2883
+ getOwnPropertyDescriptor: proxyDescriptor$1
2884
+ };
2885
+ function setProperty(state, property, value, deleting = false) {
2886
+ if (!deleting && state[property] === value)
2887
+ return;
2888
+ const prev = state[property], len = state.length;
2889
+ if (value === void 0) {
2890
+ delete state[property];
2891
+ if (state[$HAS] && state[$HAS][property] && prev !== void 0)
2892
+ state[$HAS][property].$();
2893
+ } else {
2894
+ state[property] = value;
2895
+ if (state[$HAS] && state[$HAS][property] && prev === void 0)
2896
+ state[$HAS][property].$();
2897
+ }
2898
+ let nodes = getNodes(state, $NODE), node;
2899
+ if (node = getNode(nodes, property, prev))
2900
+ node.$(() => value);
2901
+ if (Array.isArray(state) && state.length !== len) {
2902
+ for (let i = state.length; i < len; i++)
2903
+ (node = nodes[i]) && node.$();
2904
+ (node = getNode(nodes, "length", len)) && node.$(state.length);
2905
+ }
2906
+ (node = nodes[$SELF]) && node.$();
2907
+ }
2908
+ function mergeStoreNode(state, value) {
2909
+ const keys = Object.keys(value);
2910
+ for (let i = 0; i < keys.length; i += 1) {
2911
+ const key = keys[i];
2912
+ setProperty(state, key, value[key]);
2913
+ }
2914
+ }
2915
+ function updateArray(current, next) {
2916
+ if (typeof next === "function")
2917
+ next = next(current);
2918
+ next = unwrap(next);
2919
+ if (Array.isArray(next)) {
2920
+ if (current === next)
2921
+ return;
2922
+ let i = 0, len = next.length;
2923
+ for (; i < len; i++) {
2924
+ const value = next[i];
2925
+ if (current[i] !== value)
2926
+ setProperty(current, i, value);
2927
+ }
2928
+ setProperty(current, "length", len);
2929
+ } else
2930
+ mergeStoreNode(current, next);
2931
+ }
2932
+ function updatePath(current, path, traversed = []) {
2933
+ let part, prev = current;
2934
+ if (path.length > 1) {
2935
+ part = path.shift();
2936
+ const partType = typeof part, isArray = Array.isArray(current);
2937
+ if (Array.isArray(part)) {
2938
+ for (let i = 0; i < part.length; i++) {
2939
+ updatePath(current, [part[i]].concat(path), traversed);
2940
+ }
2941
+ return;
2942
+ } else if (isArray && partType === "function") {
2943
+ for (let i = 0; i < current.length; i++) {
2944
+ if (part(current[i], i))
2945
+ updatePath(current, [i].concat(path), traversed);
2946
+ }
2947
+ return;
2948
+ } else if (isArray && partType === "object") {
2949
+ const { from = 0, to = current.length - 1, by = 1 } = part;
2950
+ for (let i = from; i <= to; i += by) {
2951
+ updatePath(current, [i].concat(path), traversed);
2952
+ }
2953
+ return;
2954
+ } else if (path.length > 1) {
2955
+ updatePath(current[part], path, [part].concat(traversed));
2956
+ return;
2957
+ }
2958
+ prev = current[part];
2959
+ traversed = [part].concat(traversed);
2960
+ }
2961
+ let value = path[0];
2962
+ if (typeof value === "function") {
2963
+ value = value(prev, traversed);
2964
+ if (value === prev)
2965
+ return;
2966
+ }
2967
+ if (part === void 0 && value == void 0)
2968
+ return;
2969
+ value = unwrap(value);
2970
+ if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
2971
+ mergeStoreNode(prev, value);
2972
+ } else
2973
+ setProperty(current, part, value);
2974
+ }
2975
+ function createStore(...[store, options]) {
2976
+ const unwrappedStore = unwrap(store || {});
2977
+ const isArray = Array.isArray(unwrappedStore);
2978
+ const wrappedStore = wrap$1(unwrappedStore);
2979
+ function setStore(...args) {
2980
+ batch(() => {
2981
+ isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
2982
+ });
2983
+ }
2984
+ return [wrappedStore, setStore];
2985
+ }
2986
+ var $ROOT = Symbol("store-root");
2987
+ function applyState(target, parent, property, merge, key) {
2988
+ const previous = parent[property];
2989
+ if (target === previous)
2990
+ return;
2991
+ const isArray = Array.isArray(target);
2992
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
2993
+ setProperty(parent, property, target);
2994
+ return;
2995
+ }
2996
+ if (isArray) {
2997
+ if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
2998
+ let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
2999
+ for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start] && target[start] && previous[start][key] === target[start][key]); start++) {
3000
+ applyState(target[start], previous, start, merge, key);
3001
+ }
3002
+ const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
3003
+ for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
3004
+ temp[newEnd] = previous[end];
3005
+ }
3006
+ if (start > newEnd || start > end) {
3007
+ for (j = start; j <= newEnd; j++)
3008
+ setProperty(previous, j, target[j]);
3009
+ for (; j < target.length; j++) {
3010
+ setProperty(previous, j, temp[j]);
3011
+ applyState(target[j], previous, j, merge, key);
3012
+ }
3013
+ if (previous.length > target.length)
3014
+ setProperty(previous, "length", target.length);
3015
+ return;
3016
+ }
3017
+ newIndicesNext = new Array(newEnd + 1);
3018
+ for (j = newEnd; j >= start; j--) {
3019
+ item = target[j];
3020
+ keyVal = key && item ? item[key] : item;
3021
+ i = newIndices.get(keyVal);
3022
+ newIndicesNext[j] = i === void 0 ? -1 : i;
3023
+ newIndices.set(keyVal, j);
3024
+ }
3025
+ for (i = start; i <= end; i++) {
3026
+ item = previous[i];
3027
+ keyVal = key && item ? item[key] : item;
3028
+ j = newIndices.get(keyVal);
3029
+ if (j !== void 0 && j !== -1) {
3030
+ temp[j] = previous[i];
3031
+ j = newIndicesNext[j];
3032
+ newIndices.set(keyVal, j);
3033
+ }
3034
+ }
3035
+ for (j = start; j < target.length; j++) {
3036
+ if (j in temp) {
3037
+ setProperty(previous, j, temp[j]);
3038
+ applyState(target[j], previous, j, merge, key);
3039
+ } else
3040
+ setProperty(previous, j, target[j]);
3041
+ }
3042
+ } else {
3043
+ for (let i = 0, len = target.length; i < len; i++) {
3044
+ applyState(target[i], previous, i, merge, key);
3045
+ }
3046
+ }
3047
+ if (previous.length > target.length)
3048
+ setProperty(previous, "length", target.length);
3049
+ return;
3050
+ }
3051
+ const targetKeys = Object.keys(target);
3052
+ for (let i = 0, len = targetKeys.length; i < len; i++) {
3053
+ applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
3054
+ }
3055
+ const previousKeys = Object.keys(previous);
3056
+ for (let i = 0, len = previousKeys.length; i < len; i++) {
3057
+ if (target[previousKeys[i]] === void 0)
3058
+ setProperty(previous, previousKeys[i], void 0);
3059
+ }
3060
+ }
3061
+ function reconcile(value, options = {}) {
3062
+ const { merge, key = "id" } = options, v = unwrap(value);
3063
+ return (state) => {
3064
+ if (!isWrappable(state) || !isWrappable(v))
3065
+ return v;
3066
+ const res = applyState(
3067
+ v,
3068
+ {
3069
+ [$ROOT]: state
3070
+ },
3071
+ $ROOT,
3072
+ merge,
3073
+ key
3074
+ );
3075
+ return res === void 0 ? state : res;
3076
+ };
3077
+ }
3078
+
3079
+ // ../../node_modules/.pnpm/@tanstack+solid-store@0.3.1_solid-js@1.8.16/node_modules/@tanstack/solid-store/dist/esm/index.js
3080
+ function useStore(store, selector = (d) => d) {
3081
+ const [slice, setSlice] = createStore({
3082
+ value: selector(store.state)
3083
+ });
3084
+ const unsub = store.subscribe(() => {
3085
+ const newValue = selector(store.state);
3086
+ setSlice("value", reconcile(newValue));
3087
+ });
3088
+ onCleanup(() => {
3089
+ unsub();
3090
+ });
3091
+ return () => slice.value;
3092
+ }
3093
+
3094
+ // src/useWallet.ts
3095
+ function useWallet() {
3096
+ const manager = createMemo(() => useWalletManager());
3097
+ const walletStore = useStore(manager().store, (state) => {
3098
+ return state.wallets;
3099
+ });
3100
+ const walletState = (walletId) => walletStore()[walletId] || null;
3101
+ const activeWalletId = useStore(manager().store, (state) => {
3102
+ return state.activeWallet;
3103
+ });
3104
+ const activeWallet = () => manager().getWallet(activeWalletId()) || null;
3105
+ const activeWalletState = () => walletState(activeWalletId());
3106
+ const activeWalletAccounts = () => activeWalletState()?.accounts ?? null;
3107
+ const activeWalletAddresses = () => activeWalletAccounts()?.map((account) => account.address) ?? null;
3108
+ const activeAccount = () => activeWalletState()?.activeAccount ?? null;
3109
+ const activeAddress = () => activeAccount()?.address ?? null;
3110
+ const isWalletActive = (walletId) => walletId === activeWalletId();
3111
+ const isWalletConnected = (walletId) => !!walletState(walletId)?.accounts.length || false;
3112
+ const activeNetworkState = createMemo(() => {
3113
+ return useStore(manager().store, (state) => state.activeNetwork);
3114
+ });
3115
+ const activeNetwork = () => activeNetworkState()();
3116
+ const setActiveNetwork2 = (network) => manager().setActiveNetwork(network);
3117
+ const algodClient = createMemo(() => manager().algodClient);
3118
+ const signTransactions = (txnGroup, indexesToSign, returnGroup) => {
3119
+ if (!activeWallet) {
3120
+ throw new Error("No active wallet");
3121
+ }
3122
+ return activeWallet()?.signTransactions(txnGroup, indexesToSign, returnGroup);
3123
+ };
3124
+ const transactionSigner = (txnGroup, indexesToSign) => {
3125
+ if (!activeWallet) {
3126
+ throw new Error("No active wallet");
3127
+ }
3128
+ return activeWallet()?.transactionSigner(txnGroup, indexesToSign);
3129
+ };
3130
+ return {
3131
+ activeWalletId,
3132
+ walletStore,
3133
+ algodClient,
3134
+ activeNetwork,
3135
+ activeWallet,
3136
+ activeWalletAccounts,
3137
+ activeWalletAddresses,
3138
+ activeWalletState,
3139
+ activeAccount,
3140
+ activeAddress,
3141
+ isWalletActive,
3142
+ isWalletConnected,
3143
+ setActiveNetwork: setActiveNetwork2,
3144
+ signTransactions,
3145
+ transactionSigner,
3146
+ wallets: manager().wallets
3147
+ };
3148
+ }
3149
+ export {
3150
+ BaseWallet,
3151
+ DeflyWallet,
3152
+ ExodusWallet,
3153
+ KmdWallet,
3154
+ MnemonicWallet,
3155
+ NetworkId,
3156
+ PeraWallet,
3157
+ StorageAdapter,
3158
+ WalletConnect,
3159
+ WalletId,
3160
+ WalletManager,
3161
+ WalletProvider,
3162
+ defaultState,
3163
+ useWallet
3164
+ };