@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/index.mjs ADDED
@@ -0,0 +1,3109 @@
1
+ import { init_esm, esm_default } from './chunk/4NZZSEHL.mjs';
2
+ import './chunk/A4QL3JBU.mjs';
3
+ import './chunk/YXEL5RAT.mjs';
4
+
5
+ // ../../node_modules/.pnpm/@tanstack+store@0.3.1/node_modules/@tanstack/store/dist/esm/index.js
6
+ var Store = class {
7
+ constructor(initialState, options) {
8
+ this.listeners = /* @__PURE__ */ new Set();
9
+ this._batching = false;
10
+ this._flushing = 0;
11
+ this.subscribe = (listener) => {
12
+ var _a, _b;
13
+ this.listeners.add(listener);
14
+ const unsub = (_b = (_a = this.options) == null ? void 0 : _a.onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
15
+ return () => {
16
+ this.listeners.delete(listener);
17
+ unsub == null ? void 0 : unsub();
18
+ };
19
+ };
20
+ this.setState = (updater) => {
21
+ var _a, _b, _c;
22
+ const previous = this.state;
23
+ this.state = ((_a = this.options) == null ? void 0 : _a.updateFn) ? this.options.updateFn(previous)(updater) : updater(previous);
24
+ (_c = (_b = this.options) == null ? void 0 : _b.onUpdate) == null ? void 0 : _c.call(_b);
25
+ this._flush();
26
+ };
27
+ this._flush = () => {
28
+ if (this._batching)
29
+ return;
30
+ const flushId = ++this._flushing;
31
+ this.listeners.forEach((listener) => {
32
+ if (this._flushing !== flushId)
33
+ return;
34
+ listener();
35
+ });
36
+ };
37
+ this.batch = (cb) => {
38
+ if (this._batching)
39
+ return cb();
40
+ this._batching = true;
41
+ cb();
42
+ this._batching = false;
43
+ this._flush();
44
+ };
45
+ this.state = initialState;
46
+ this.options = options;
47
+ }
48
+ };
49
+
50
+ // ../use-wallet/dist/index.js
51
+ init_esm();
52
+ init_esm();
53
+ init_esm();
54
+ init_esm();
55
+ init_esm();
56
+ init_esm();
57
+ init_esm();
58
+ init_esm();
59
+ init_esm();
60
+ init_esm();
61
+ var NetworkId = /* @__PURE__ */ ((NetworkId2) => {
62
+ NetworkId2["MAINNET"] = "mainnet";
63
+ NetworkId2["TESTNET"] = "testnet";
64
+ NetworkId2["BETANET"] = "betanet";
65
+ NetworkId2["LOCALNET"] = "localnet";
66
+ return NetworkId2;
67
+ })(NetworkId || {});
68
+ function isValidNetworkId(networkId) {
69
+ return Object.values(NetworkId).includes(networkId);
70
+ }
71
+ function isNetworkConfigMap(config) {
72
+ const networkKeys = Object.values(NetworkId);
73
+ return Object.keys(config).some((key) => networkKeys.includes(key));
74
+ }
75
+ var nodeServerMap = {
76
+ [
77
+ "mainnet"
78
+ /* MAINNET */
79
+ ]: "https://mainnet-api.algonode.cloud",
80
+ [
81
+ "testnet"
82
+ /* TESTNET */
83
+ ]: "https://testnet-api.algonode.cloud",
84
+ [
85
+ "betanet"
86
+ /* BETANET */
87
+ ]: "https://betanet-api.algonode.cloud"
88
+ };
89
+ function createDefaultNetworkConfig() {
90
+ const localnetConfig = {
91
+ token: "a".repeat(64),
92
+ baseServer: "http://localhost",
93
+ port: 4001,
94
+ headers: {}
95
+ };
96
+ return Object.values(NetworkId).reduce((configMap, value) => {
97
+ const network = value;
98
+ const isLocalnet = network === "localnet";
99
+ configMap[network] = isLocalnet ? localnetConfig : {
100
+ token: "",
101
+ baseServer: nodeServerMap[network],
102
+ port: "",
103
+ headers: {}
104
+ };
105
+ return configMap;
106
+ }, {});
107
+ }
108
+ var caipChainId = {
109
+ [
110
+ "mainnet"
111
+ /* MAINNET */
112
+ ]: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k",
113
+ [
114
+ "testnet"
115
+ /* TESTNET */
116
+ ]: "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe",
117
+ [
118
+ "betanet"
119
+ /* BETANET */
120
+ ]: "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2"
121
+ };
122
+ var StorageAdapter = class {
123
+ static getItem(key) {
124
+ if (typeof window === "undefined") {
125
+ return null;
126
+ }
127
+ return localStorage.getItem(key);
128
+ }
129
+ static setItem(key, value) {
130
+ if (typeof window === "undefined") {
131
+ return;
132
+ }
133
+ localStorage.setItem(key, value);
134
+ }
135
+ };
136
+ var BaseWallet = class {
137
+ id;
138
+ metadata;
139
+ store;
140
+ getAlgodClient;
141
+ subscribe;
142
+ constructor({
143
+ id,
144
+ metadata,
145
+ store,
146
+ subscribe,
147
+ getAlgodClient
148
+ }) {
149
+ this.id = id;
150
+ this.store = store;
151
+ this.subscribe = subscribe;
152
+ this.getAlgodClient = getAlgodClient;
153
+ const ctor = this.constructor;
154
+ this.metadata = { ...ctor.defaultMetadata, ...metadata };
155
+ }
156
+ static defaultMetadata = { name: "Base Wallet", icon: "" };
157
+ setActive = () => {
158
+ setActiveWallet(this.store, { walletId: this.id });
159
+ };
160
+ setActiveAccount = (account) => {
161
+ setActiveAccount(this.store, {
162
+ walletId: this.id,
163
+ address: account
164
+ });
165
+ };
166
+ // ---------- Derived Properties ------------------------------------ //
167
+ get name() {
168
+ return this.id.toUpperCase();
169
+ }
170
+ get accounts() {
171
+ const state = this.store.state;
172
+ const walletState = state.wallets[this.id];
173
+ return walletState ? walletState.accounts : [];
174
+ }
175
+ get addresses() {
176
+ return this.accounts.map((account) => account.address);
177
+ }
178
+ get activeAccount() {
179
+ const state = this.store.state;
180
+ const walletState = state.wallets[this.id];
181
+ return walletState ? walletState.activeAccount : null;
182
+ }
183
+ get activeAddress() {
184
+ return this.activeAccount?.address ?? null;
185
+ }
186
+ get activeNetwork() {
187
+ const state = this.store.state;
188
+ return state.activeNetwork;
189
+ }
190
+ get isConnected() {
191
+ const state = this.store.state;
192
+ const walletState = state.wallets[this.id];
193
+ return walletState ? walletState.accounts.length > 0 : false;
194
+ }
195
+ get isActive() {
196
+ const state = this.store.state;
197
+ return state.activeWallet === this.id;
198
+ }
199
+ // ---------- Protected Methods ------------------------------------- //
200
+ onDisconnect() {
201
+ removeWallet(this.store, { walletId: this.id });
202
+ }
203
+ };
204
+ var WalletId = /* @__PURE__ */ ((WalletId2) => {
205
+ WalletId2["DEFLY"] = "defly";
206
+ WalletId2["EXODUS"] = "exodus";
207
+ WalletId2["KIBISIS"] = "kibisis";
208
+ WalletId2["KMD"] = "kmd";
209
+ WalletId2["LUTE"] = "lute";
210
+ WalletId2["MNEMONIC"] = "mnemonic";
211
+ WalletId2["PERA"] = "pera";
212
+ WalletId2["WALLETCONNECT"] = "walletconnect";
213
+ return WalletId2;
214
+ })(WalletId || {});
215
+ var icon = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjUuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMDAgMzAwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAzMDAgMzAwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6dXJsKCNTVkdJRF8xXyk7fQoJLnN0MXtmaWxsOnVybCgjU1ZHSURfMDAwMDAwNDM0MjYxNjcxNDAxMDY1ODIyNzAwMDAwMDIxMzA3Njg5MDYwNzMxMTM0ODRfKTt9Cgkuc3Qye2ZpbGw6dXJsKCNTVkdJRF8wMDAwMDEwMjUxOTMxNjAxNTI3NjU4MTY0MDAwMDAxNjI3NDExMjM4MzE3NTY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N0b3AtY29sb3I6I0RBQkRGRjtzdG9wLW9wYWNpdHk6MCIvPgoJCTwvbGluZWFyR3JhZGllbnQ+CgkJCgkJCTxyZWN0IHg9IjI1LjQiIHk9IjIzIiBzdHlsZT0iZmlsbDp1cmwoI1NWR0lEXzAwMDAwMTA5MDE5OTE4NTU3NzczMDUzNDIwMDAwMDE3NjAyNDA1OTA4MDY3MTIwMzAwXyk7IiB3aWR0aD0iMjQ3LjYiIGhlaWdodD0iMjU0Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg==";
216
+ var ExodusWallet = class extends BaseWallet {
217
+ client = null;
218
+ options;
219
+ store;
220
+ constructor({
221
+ id,
222
+ store,
223
+ subscribe,
224
+ getAlgodClient,
225
+ options = {},
226
+ metadata = {}
227
+ }) {
228
+ super({ id, metadata, getAlgodClient, store, subscribe });
229
+ this.options = options;
230
+ this.store = store;
231
+ }
232
+ static defaultMetadata = { name: "Exodus", icon };
233
+ async initializeClient() {
234
+ if (typeof window === "undefined" || window.algorand === void 0) {
235
+ throw new Error("Exodus is not available.");
236
+ }
237
+ const client = window.algorand;
238
+ this.client = client;
239
+ return client;
240
+ }
241
+ connect = async () => {
242
+ try {
243
+ const client = this.client || await this.initializeClient();
244
+ const { accounts } = await client.enable(this.options);
245
+ if (accounts.length === 0) {
246
+ throw new Error("No accounts found!");
247
+ }
248
+ const walletAccounts = accounts.map((address, idx) => ({
249
+ name: `Exodus Wallet ${idx + 1}`,
250
+ address
251
+ }));
252
+ const activeAccount = walletAccounts[0];
253
+ addWallet(this.store, {
254
+ walletId: this.id,
255
+ wallet: {
256
+ accounts: walletAccounts,
257
+ activeAccount
258
+ }
259
+ });
260
+ return walletAccounts;
261
+ } catch (error) {
262
+ if (error.name === "UserRejectedRequestError") ;
263
+ return [];
264
+ }
265
+ };
266
+ disconnect = async () => {
267
+ this.onDisconnect();
268
+ };
269
+ resumeSession = async () => {
270
+ try {
271
+ const state = this.store.state;
272
+ const walletState = state.wallets[this.id];
273
+ if (!walletState) {
274
+ return;
275
+ }
276
+ const client = await this.initializeClient();
277
+ if (!client.isConnected) {
278
+ throw new Error("Exodus is not connected.");
279
+ }
280
+ } catch (error) {
281
+ this.onDisconnect();
282
+ }
283
+ };
284
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
285
+ if (!this.client) {
286
+ throw new Error("[ExodusWallet] Client not initialized!");
287
+ }
288
+ const txnsToSign = [];
289
+ const signedIndexes = [];
290
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
291
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
292
+ return esm_default.decodeObj(txn);
293
+ });
294
+ decodedObjects.forEach((txnObject, idx) => {
295
+ const isSigned = isSignedTxnObject(txnObject);
296
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
297
+ const txnBuffer = msgpackTxnGroup[idx];
298
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
299
+ const txnBase64 = byteArrayToBase64(txn.toByte());
300
+ if (shouldSign) {
301
+ txnsToSign.push({ txn: txnBase64 });
302
+ signedIndexes.push(idx);
303
+ } else {
304
+ txnsToSign.push({ txn: txnBase64, signers: [] });
305
+ }
306
+ });
307
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
308
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
309
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
310
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
311
+ signedTxns,
312
+ msgpackTxnGroup,
313
+ signedIndexes,
314
+ returnGroup
315
+ );
316
+ return txnGroupSigned;
317
+ };
318
+ transactionSigner = async (txnGroup, indexesToSign) => {
319
+ if (!this.client) {
320
+ throw new Error("[ExodusWallet] Client not initialized!");
321
+ }
322
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
323
+ const txnBase64 = byteArrayToBase64(txn.toByte());
324
+ if (indexesToSign.includes(idx)) {
325
+ acc.push({ txn: txnBase64 });
326
+ } else {
327
+ acc.push({ txn: txnBase64, signers: [] });
328
+ }
329
+ return acc;
330
+ }, []);
331
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
332
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
333
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
334
+ return signedTxns;
335
+ };
336
+ };
337
+ var ARC_0027_PREFIX = "arc0027";
338
+ var ARC_0027_CHANNEL_NAME = `${ARC_0027_PREFIX}:channel`;
339
+ var ARC_0027_ENABLE_REQUEST = `${ARC_0027_PREFIX}:enable:request`;
340
+ var ARC_0027_GET_PROVIDERS_REQUEST = `${ARC_0027_PREFIX}:get_providers:request`;
341
+ var ARC_0027_PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
342
+ var ARC_0027_SIGN_TXNS_REQUEST = `${ARC_0027_PREFIX}:sign_txns:request`;
343
+ var UNKNOWN_ERROR = 4e3;
344
+ var METHOD_TIMED_OUT_ERROR = 4002;
345
+ var METHOD_NOT_SUPPORTED_ERROR = 4003;
346
+ var NETWORK_NOT_SUPPORTED_ERROR = 4004;
347
+ var DEFAULT_REQUEST_TIMEOUT = 18e4;
348
+ var LOWER_REQUEST_TIMEOUT = 750;
349
+ var icon2 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnMiIKICAgdmlld0JveD0iMCAwIDEzNjUuMzMzMyAxMzY1LjMzMzMiCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGgKICAgIGQ9Im0gNjY3Ljk5OTk4LDEwNDguNjY2MiBjIDAsLTY0LjE2Njk4IC0wLjYyMDQ0LC0xMjguODE2OTggLTEuMzc4NzcsLTE0My42NjY3IC0yLjgxMTA3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5NSBoIDI5LjMzODAxIDI5LjMzODAyIHoiCiAgICBmaWxsPSIjOGMwMTlhIiAvPgo8L3N2Zz4K";
350
+ var KibisisWallet = class _KibisisWallet extends BaseWallet {
351
+ methods = [];
352
+ store;
353
+ constructor({
354
+ id,
355
+ store,
356
+ subscribe,
357
+ getAlgodClient,
358
+ metadata = {}
359
+ }) {
360
+ super({ id, metadata, getAlgodClient, store, subscribe });
361
+ this.store = store;
362
+ }
363
+ static defaultMetadata = {
364
+ name: "Kibisis",
365
+ icon: icon2
366
+ };
367
+ static async sendRequestWithTimeout({
368
+ method,
369
+ params,
370
+ timeout,
371
+ reference
372
+ }) {
373
+ return new Promise((resolve, reject) => {
374
+ const channel = new BroadcastChannel(ARC_0027_CHANNEL_NAME);
375
+ const requestId = generateUuid();
376
+ let timer;
377
+ channel.onmessage = (message) => {
378
+ if (!message.data || message.data.requestId !== requestId) {
379
+ return;
380
+ }
381
+ window.clearTimeout(timer);
382
+ if (message.data.error) {
383
+ reject(message.data.error);
384
+ return channel.close();
385
+ }
386
+ resolve(message.data.result);
387
+ return channel.close();
388
+ };
389
+ timer = window.setTimeout(() => {
390
+ channel.close();
391
+ reject({
392
+ code: METHOD_TIMED_OUT_ERROR,
393
+ data: {
394
+ method
395
+ },
396
+ message: `No response from provider "${"kibisis".toUpperCase()}"`,
397
+ providerId: ARC_0027_PROVIDER_ID
398
+ });
399
+ }, timeout || DEFAULT_REQUEST_TIMEOUT);
400
+ channel.postMessage({
401
+ id: requestId,
402
+ params,
403
+ reference
404
+ });
405
+ });
406
+ }
407
+ /**
408
+ * Calls the enable method on the provider that returns the authorized accounts.
409
+ * @returns {Arc0027Account[]} the authorized accounts.
410
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
411
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
412
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
413
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
414
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
415
+ */
416
+ async enable() {
417
+ const method = "enable";
418
+ this.validateMethod(method);
419
+ const genesisHash = await this.getGenesisHash();
420
+ const result = await _KibisisWallet.sendRequestWithTimeout({
421
+ method,
422
+ params: {
423
+ genesisHash,
424
+ providerId: ARC_0027_PROVIDER_ID
425
+ },
426
+ reference: ARC_0027_ENABLE_REQUEST
427
+ });
428
+ if (!result) {
429
+ throw {
430
+ code: UNKNOWN_ERROR,
431
+ message: `Received response, but "${method}" request details were empty for provider "${this.name}"`,
432
+ providerId: ARC_0027_PROVIDER_ID
433
+ };
434
+ }
435
+ return result.accounts;
436
+ }
437
+ /**
438
+ * Gets the genesis hash of the algod client's configured network.
439
+ * @returns {string} the genesis hash
440
+ */
441
+ async getGenesisHash() {
442
+ const algodClient = this.getAlgodClient();
443
+ const version = await algodClient.versionsCheck().do();
444
+ const genesisHash = version.genesis_hash_b64;
445
+ return genesisHash;
446
+ }
447
+ /**
448
+ * Gets the provider information and updates the supported methods. This should be called
449
+ * before interacting with the provider to ensure methods are supported.
450
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
451
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
452
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
453
+ */
454
+ async getSupportedMethods() {
455
+ const genesisHash = await this.getGenesisHash();
456
+ const result = await _KibisisWallet.sendRequestWithTimeout({
457
+ method: "getProviders",
458
+ params: {
459
+ providerId: ARC_0027_PROVIDER_ID
460
+ },
461
+ reference: ARC_0027_GET_PROVIDERS_REQUEST,
462
+ timeout: LOWER_REQUEST_TIMEOUT
463
+ });
464
+ if (!result) {
465
+ throw {
466
+ code: UNKNOWN_ERROR,
467
+ message: `Received response, but provider details were empty for provider "${this.name}"`,
468
+ providerId: ARC_0027_PROVIDER_ID
469
+ };
470
+ }
471
+ const networkConfiguration = result.networks.find((value) => value.genesisHash === genesisHash);
472
+ if (!networkConfiguration) {
473
+ throw {
474
+ code: NETWORK_NOT_SUPPORTED_ERROR,
475
+ data: {
476
+ genesisHash
477
+ },
478
+ message: `Network "${this.activeNetwork}" not supported on provider "${this.name}"`,
479
+ providerId: ARC_0027_PROVIDER_ID
480
+ };
481
+ }
482
+ this.methods = networkConfiguration.methods;
483
+ }
484
+ /**
485
+ * Calls the signTxns methods to sign the supplied transactions.
486
+ * @param {Arc0001SignTxns[]} txns - the unsigned or signed transactions as defined in ARC-0001.
487
+ * @returns {(string | null)[]} the authorized accounts.
488
+ * @throws {INVALID_INPUT_ERROR} if computed group ID for the txns does not match the assigned group ID.
489
+ * @throws {INVALID_GROUP_ID_ERROR} if the unsigned txns is malformed or not conforming to ARC-0001.
490
+ * @throws {METHOD_CANCELED_ERROR} if the method was cancelled by the user.
491
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
492
+ * @throws {METHOD_TIMED_OUT_ERROR} if the method timed out by lack of response.
493
+ * @throws {NETWORK_NOT_SUPPORTED_ERROR} if the network is not supported for the configured network.
494
+ * @throws {UNAUTHORIZED_SIGNER_ERROR} if a signer in the request is not authorized by the provider.
495
+ * @throws {UNKNOWN_ERROR} if the response result was empty.
496
+ */
497
+ async signTxns(txns) {
498
+ const method = "signTxns";
499
+ this.validateMethod(method);
500
+ const result = await _KibisisWallet.sendRequestWithTimeout({
501
+ method,
502
+ params: {
503
+ providerId: ARC_0027_PROVIDER_ID,
504
+ txns
505
+ },
506
+ reference: ARC_0027_SIGN_TXNS_REQUEST
507
+ });
508
+ if (!result) {
509
+ throw {
510
+ code: UNKNOWN_ERROR,
511
+ message: `Received response, but "${method}" request details were empty for provider "${this.name}"`,
512
+ providerId: ARC_0027_PROVIDER_ID
513
+ };
514
+ }
515
+ return result.stxns;
516
+ }
517
+ /**
518
+ * Validates whether a method is supported with the provider.
519
+ * @param {ProviderMethod} method - the method to validate.
520
+ * @throws {METHOD_NOT_SUPPORTED_ERROR} if the method is not supported for the configured network.
521
+ */
522
+ validateMethod(method) {
523
+ if (!this.methods.includes(method)) {
524
+ throw {
525
+ code: METHOD_NOT_SUPPORTED_ERROR,
526
+ data: {
527
+ method
528
+ },
529
+ message: `"${method}" operation not supported on "${this.activeNetwork}" for provider "${this.name}"`,
530
+ providerId: ARC_0027_PROVIDER_ID
531
+ };
532
+ }
533
+ }
534
+ connect = async () => {
535
+ try {
536
+ await this.getSupportedMethods();
537
+ const accounts = await this.enable();
538
+ const walletAccounts = accounts.map(({ address, name }, idx) => ({
539
+ name: name || `Kibisis Wallet ${idx + 1}`,
540
+ address
541
+ }));
542
+ const activeAccount = walletAccounts[0];
543
+ addWallet(this.store, {
544
+ walletId: this.id,
545
+ wallet: {
546
+ accounts: walletAccounts,
547
+ activeAccount
548
+ }
549
+ });
550
+ return walletAccounts;
551
+ } catch (error) {
552
+ return [];
553
+ }
554
+ };
555
+ disconnect = async () => {
556
+ this.onDisconnect();
557
+ };
558
+ resumeSession = () => {
559
+ return Promise.resolve();
560
+ };
561
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
562
+ try {
563
+ await this.getSupportedMethods();
564
+ const txnsToSign = [];
565
+ const signedIndexes = [];
566
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
567
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
568
+ return esm_default.decodeObj(txn);
569
+ });
570
+ decodedObjects.forEach((txnObject, idx) => {
571
+ const isSigned = isSignedTxnObject(txnObject);
572
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
573
+ const txnBuffer = msgpackTxnGroup[idx];
574
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
575
+ const txnBase64 = byteArrayToBase64(txn.toByte());
576
+ if (shouldSign) {
577
+ txnsToSign.push({ txn: txnBase64 });
578
+ signedIndexes.push(idx);
579
+ } else {
580
+ txnsToSign.push({ txn: txnBase64, signers: [] });
581
+ }
582
+ });
583
+ const signTxnsResult = await this.signTxns(txnsToSign);
584
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
585
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
586
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
587
+ signedTxns,
588
+ msgpackTxnGroup,
589
+ signedIndexes,
590
+ returnGroup
591
+ );
592
+ return txnGroupSigned;
593
+ } catch (error) {
594
+ throw error;
595
+ }
596
+ };
597
+ transactionSigner = async (txnGroup, indexesToSign) => {
598
+ try {
599
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
600
+ const txnBase64 = byteArrayToBase64(txn.toByte());
601
+ if (indexesToSign.includes(idx)) {
602
+ acc.push({ txn: txnBase64 });
603
+ } else {
604
+ acc.push({ txn: txnBase64, signers: [] });
605
+ }
606
+ return acc;
607
+ }, []);
608
+ const signTxnsResult = await this.signTxns(txnsToSign);
609
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
610
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
611
+ return signedTxns;
612
+ } catch (error) {
613
+ throw error;
614
+ }
615
+ };
616
+ };
617
+ var icon3 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0MDkuODMgMjEwLjMzIj48dGV4dCB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIDE2MS4zMSkiIHN0eWxlPSJmb250LWZhbWlseTpJQk1QbGV4U2Fucy1NZWRtLCAmYXBvcztJQk0gUGxleCBTYW5zJmFwb3M7OyBmb250LXNpemU6MTkwcHg7Ij48dHNwYW4geD0iMCIgeT0iMCI+S01EPC90c3Bhbj48L3RleHQ+PC9zdmc+";
618
+ var KmdWallet = class extends BaseWallet {
619
+ client = null;
620
+ options;
621
+ walletName;
622
+ walletId = "";
623
+ password = "";
624
+ store;
625
+ constructor({
626
+ id,
627
+ store,
628
+ subscribe,
629
+ getAlgodClient,
630
+ options,
631
+ metadata = {}
632
+ }) {
633
+ super({ id, metadata, getAlgodClient, store, subscribe });
634
+ const {
635
+ token = "a".repeat(64),
636
+ baseServer = "http://127.0.0.1",
637
+ port = 4002,
638
+ wallet = "unencrypted-default-wallet"
639
+ } = options || {};
640
+ this.options = { token, baseServer, port };
641
+ this.walletName = wallet;
642
+ this.store = store;
643
+ }
644
+ static defaultMetadata = { name: "KMD", icon: icon3 };
645
+ async initializeClient() {
646
+ const { token, baseServer, port } = this.options;
647
+ const client = new esm_default.Kmd(token, baseServer, port);
648
+ this.client = client;
649
+ return client;
650
+ }
651
+ connect = async () => {
652
+ try {
653
+ if (!this.client) {
654
+ await this.initializeClient();
655
+ }
656
+ const walletId = this.walletId || await this.fetchWalletId();
657
+ const token = await this.fetchToken(walletId, this.getPassword());
658
+ const accounts = await this.fetchAccounts(token);
659
+ if (accounts.length === 0) {
660
+ throw new Error("No accounts found!");
661
+ }
662
+ const walletAccounts = accounts.map((address, idx) => ({
663
+ name: `KMD Wallet ${idx + 1}`,
664
+ address
665
+ }));
666
+ const activeAccount = walletAccounts[0];
667
+ addWallet(this.store, {
668
+ walletId: this.id,
669
+ wallet: {
670
+ accounts: walletAccounts,
671
+ activeAccount
672
+ }
673
+ });
674
+ await this.releaseToken(token);
675
+ return walletAccounts;
676
+ } catch (error) {
677
+ return [];
678
+ }
679
+ };
680
+ disconnect = async () => {
681
+ this.onDisconnect();
682
+ };
683
+ resumeSession = async () => {
684
+ try {
685
+ const state = this.store.state;
686
+ const walletState = state.wallets[this.id];
687
+ if (!walletState) {
688
+ return;
689
+ }
690
+ await this.initializeClient();
691
+ } catch (error) {
692
+ this.onDisconnect();
693
+ }
694
+ };
695
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
696
+ if (!this.client) {
697
+ throw new Error("[KmdWallet] Client not initialized!");
698
+ }
699
+ const walletId = this.walletId || await this.fetchWalletId();
700
+ const password = this.getPassword();
701
+ const token = await this.fetchToken(walletId, password);
702
+ const signTxnPromises = [];
703
+ const signedIndexes = [];
704
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
705
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
706
+ return esm_default.decodeObj(txn);
707
+ });
708
+ decodedObjects.forEach((txnObject, idx) => {
709
+ const isSigned = isSignedTxnObject(txnObject);
710
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
711
+ const txnBuffer = msgpackTxnGroup[idx];
712
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
713
+ if (shouldSign) {
714
+ signTxnPromises.push(this.client.signTransaction(token, password, txn));
715
+ signedIndexes.push(idx);
716
+ }
717
+ });
718
+ const signedTxns = await Promise.all(signTxnPromises);
719
+ await this.releaseToken(token);
720
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
721
+ signedTxns,
722
+ msgpackTxnGroup,
723
+ signedIndexes,
724
+ returnGroup
725
+ );
726
+ return txnGroupSigned;
727
+ };
728
+ transactionSigner = async (txnGroup, indexesToSign) => {
729
+ if (!this.client) {
730
+ throw new Error("[KmdWallet] Client not initialized!");
731
+ }
732
+ const walletId = this.walletId || await this.fetchWalletId();
733
+ const password = this.getPassword();
734
+ const token = await this.fetchToken(walletId, password);
735
+ const signTxnPromises = [];
736
+ txnGroup.forEach((txn, idx) => {
737
+ if (indexesToSign.includes(idx)) {
738
+ signTxnPromises.push(this.client.signTransaction(token, password, txn));
739
+ }
740
+ });
741
+ const signedTxns = await Promise.all(signTxnPromises);
742
+ return signedTxns;
743
+ };
744
+ async fetchWalletId() {
745
+ if (!this.client) {
746
+ throw new Error("Client not initialized!");
747
+ }
748
+ const { wallets } = await this.client.listWallets();
749
+ const wallet = wallets.find((wallet2) => wallet2.name === this.walletName);
750
+ if (!wallet) {
751
+ throw new Error(`Wallet ${this.walletName} not found!`);
752
+ }
753
+ this.walletId = wallet.id;
754
+ return wallet.id;
755
+ }
756
+ async fetchToken(walletId, password) {
757
+ if (!this.client) {
758
+ throw new Error("Client not initialized!");
759
+ }
760
+ const { wallet_handle_token } = await this.client.initWalletHandle(
761
+ walletId,
762
+ password
763
+ );
764
+ return wallet_handle_token;
765
+ }
766
+ async fetchAccounts(token) {
767
+ if (!this.client) {
768
+ throw new Error("Client not initialized!");
769
+ }
770
+ const { addresses } = await this.client.listKeys(token);
771
+ return addresses;
772
+ }
773
+ async releaseToken(token) {
774
+ if (!this.client) {
775
+ throw new Error("Client not initialized!");
776
+ }
777
+ await this.client.releaseWalletHandle(token);
778
+ }
779
+ getPassword() {
780
+ if (this.password) {
781
+ return this.password;
782
+ }
783
+ const password = prompt("KMD password") || "";
784
+ this.password = password;
785
+ return password;
786
+ }
787
+ };
788
+ var svgIcon = `
789
+ <svg fill="#ab47bc" version="1.1" viewBox="0 0 1e3 1e3" xmlns="http://www.w3.org/2000/svg">
790
+ <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" />
791
+ </svg>
792
+ `;
793
+ var LuteWallet = class extends BaseWallet {
794
+ client = null;
795
+ options;
796
+ store;
797
+ constructor({
798
+ id,
799
+ store,
800
+ subscribe,
801
+ getAlgodClient,
802
+ options,
803
+ metadata = {}
804
+ }) {
805
+ super({ id, metadata, getAlgodClient, store, subscribe });
806
+ if (!options?.siteName) {
807
+ throw new Error("[LuteWallet] Missing required option: siteName");
808
+ }
809
+ this.options = options;
810
+ this.store = store;
811
+ }
812
+ static defaultMetadata = {
813
+ name: "Lute",
814
+ icon: `data:image/svg+xml;base64,${btoa(svgIcon.trim())}`
815
+ };
816
+ async initializeClient() {
817
+ const module = await import('./main.esm/VQKMPFEL.mjs');
818
+ const LuteConnect = module.default;
819
+ const client = new LuteConnect(this.options.siteName);
820
+ this.client = client;
821
+ return client;
822
+ }
823
+ async getGenesisId() {
824
+ const algodClient = this.getAlgodClient();
825
+ const genesis = await algodClient.genesis().do();
826
+ const genesisId = `${genesis.network}-${genesis.id}`;
827
+ return genesisId;
828
+ }
829
+ connect = async () => {
830
+ try {
831
+ const client = this.client || await this.initializeClient();
832
+ const genesisId = await this.getGenesisId();
833
+ const accounts = await client.connect(genesisId);
834
+ if (accounts.length === 0) {
835
+ throw new Error("No accounts found!");
836
+ }
837
+ const walletAccounts = accounts.map((address, idx) => ({
838
+ name: `Lute Wallet ${idx + 1}`,
839
+ address
840
+ }));
841
+ const activeAccount = walletAccounts[0];
842
+ addWallet(this.store, {
843
+ walletId: this.id,
844
+ wallet: {
845
+ accounts: walletAccounts,
846
+ activeAccount
847
+ }
848
+ });
849
+ return walletAccounts;
850
+ } catch (error) {
851
+ return [];
852
+ }
853
+ };
854
+ disconnect = async () => {
855
+ this.onDisconnect();
856
+ };
857
+ resumeSession = async () => {
858
+ try {
859
+ const state = this.store.state;
860
+ const walletState = state.wallets[this.id];
861
+ if (!walletState) {
862
+ return;
863
+ }
864
+ await this.initializeClient();
865
+ } catch (error) {
866
+ this.onDisconnect();
867
+ }
868
+ };
869
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
870
+ try {
871
+ if (!this.client) {
872
+ throw new Error("[LuteWallet] Client not initialized!");
873
+ }
874
+ const txnsToSign = [];
875
+ const signedIndexes = [];
876
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
877
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
878
+ return esm_default.decodeObj(txn);
879
+ });
880
+ decodedObjects.forEach((txnObject, idx) => {
881
+ const isSigned = isSignedTxnObject(txnObject);
882
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
883
+ const txnBuffer = msgpackTxnGroup[idx];
884
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
885
+ const txnBase64 = byteArrayToBase64(txn.toByte());
886
+ if (shouldSign) {
887
+ txnsToSign.push({ txn: txnBase64 });
888
+ signedIndexes.push(idx);
889
+ } else {
890
+ txnsToSign.push({ txn: txnBase64, signers: [] });
891
+ }
892
+ });
893
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
894
+ const signedTxns = signTxnsResult.filter(Boolean);
895
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
896
+ signedTxns,
897
+ msgpackTxnGroup,
898
+ signedIndexes,
899
+ returnGroup
900
+ );
901
+ return txnGroupSigned;
902
+ } catch (error) {
903
+ throw error;
904
+ }
905
+ };
906
+ transactionSigner = async (txnGroup, indexesToSign) => {
907
+ try {
908
+ if (!this.client) {
909
+ throw new Error("[LuteWallet] Client not initialized!");
910
+ }
911
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
912
+ const txnBase64 = byteArrayToBase64(txn.toByte());
913
+ if (indexesToSign.includes(idx)) {
914
+ acc.push({ txn: txnBase64 });
915
+ } else {
916
+ acc.push({ txn: txnBase64, signers: [] });
917
+ }
918
+ return acc;
919
+ }, []);
920
+ const signTxnsResult = await this.client.signTxns(txnsToSign);
921
+ const signedTxns = signTxnsResult.filter(Boolean);
922
+ return signedTxns;
923
+ } catch (error) {
924
+ throw error;
925
+ }
926
+ };
927
+ };
928
+ 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`;
929
+ var MnemonicWallet = class extends BaseWallet {
930
+ account = null;
931
+ options;
932
+ store;
933
+ constructor({
934
+ id,
935
+ store,
936
+ subscribe,
937
+ getAlgodClient,
938
+ options,
939
+ metadata = {}
940
+ }) {
941
+ super({ id, metadata, getAlgodClient, store, subscribe });
942
+ const { persistToStorage = false } = options || {};
943
+ this.options = { persistToStorage };
944
+ this.store = store;
945
+ }
946
+ static defaultMetadata = { name: "Mnemonic", icon: icon4 };
947
+ // @todo: Show explicit security warning if persistToStorage is true
948
+ // @todo: Save/load mnemonic from storage if persistToStorage is true
949
+ // @todo: Throw error with link to docs if using mainnet
950
+ initializeAccount() {
951
+ const mnemonic = prompt("Enter 25-word mnemonic passphrase:");
952
+ if (!mnemonic) {
953
+ this.account = null;
954
+ throw new Error("No mnemonic provided");
955
+ }
956
+ const account = esm_default.mnemonicToSecretKey(mnemonic);
957
+ this.account = account;
958
+ return account;
959
+ }
960
+ connect = async () => {
961
+ try {
962
+ const account = this.initializeAccount();
963
+ const walletAccount = {
964
+ name: "Mnemonic Account",
965
+ address: account.addr
966
+ };
967
+ addWallet(this.store, {
968
+ walletId: this.id,
969
+ wallet: {
970
+ accounts: [walletAccount],
971
+ activeAccount: walletAccount
972
+ }
973
+ });
974
+ return [walletAccount];
975
+ } catch (error) {
976
+ throw error;
977
+ }
978
+ };
979
+ disconnect = async () => {
980
+ try {
981
+ this.account = null;
982
+ this.onDisconnect();
983
+ } catch (error) {
984
+ }
985
+ };
986
+ resumeSession = async () => {
987
+ const state = this.store.state;
988
+ const walletState = state.wallets[this.id];
989
+ if (walletState) {
990
+ try {
991
+ this.account = null;
992
+ this.onDisconnect();
993
+ } catch (error) {
994
+ }
995
+ }
996
+ };
997
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
998
+ if (!this.account) {
999
+ throw new Error("[MnemonicWallet] Client not initialized!");
1000
+ }
1001
+ const txnGroupSigned = [];
1002
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1003
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1004
+ return esm_default.decodeObj(txn);
1005
+ });
1006
+ decodedObjects.forEach((txnObject, idx) => {
1007
+ const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
1008
+ const isSigned = isSignedTxnObject(txnObject);
1009
+ const canSign = !isSigned && esm_default.encodeAddress(txnObject.snd) === this.account.addr;
1010
+ const shouldSign = isIndexMatch && canSign;
1011
+ if (shouldSign) {
1012
+ const txn = esm_default.Transaction.from_obj_for_encoding(txnObject);
1013
+ const signedTxn = txn.signTxn(this.account.sk);
1014
+ txnGroupSigned.push(signedTxn);
1015
+ } else if (returnGroup) {
1016
+ txnGroupSigned.push(msgpackTxnGroup[idx]);
1017
+ }
1018
+ });
1019
+ return Promise.resolve(txnGroupSigned);
1020
+ };
1021
+ transactionSigner = async (txnGroup, indexesToSign) => {
1022
+ if (!this.account) {
1023
+ throw new Error("[MnemonicWallet] Account not initialized!");
1024
+ }
1025
+ const signedTxns = [];
1026
+ for (const index of indexesToSign) {
1027
+ const txnToSign = txnGroup[index];
1028
+ if (txnToSign) {
1029
+ signedTxns.push(txnToSign.signTxn(this.account.sk));
1030
+ }
1031
+ }
1032
+ return Promise.resolve(signedTxns);
1033
+ };
1034
+ };
1035
+ var icon5 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNzcgMTg3Ij48cmVjdCB4PSItMTEuMzgiIHk9Ii0yNS45NyIgd2lkdGg9IjIwMC4wMiIgaGVpZ2h0PSIyMzEuNTMiIHN0eWxlPSJmaWxsOiNmZTU7Ii8+PHBhdGggZD0iTTk0LjA1LDU5LjYxYzIuMDUsOC40OCwxLjM2LDE1Ljk0LTEuNTUsMTYuNjYtMi45LC43Mi02LjkxLTUuNTctOC45Ni0xNC4wNS0yLjA1LTguNDgtMS4zNi0xNS45NCwxLjU1LTE2LjY2LDIuOS0uNzIsNi45MSw1LjU3LDguOTYsMTQuMDVaIiBzdHlsZT0iZmlsbDojMWMxYzFjOyIvPjxwYXRoIGQ9Ik0xMjcuODUsNjYuOWMtNC41My00LjgxLTEzLj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allet = class extends BaseWallet {
1037
+ client = null;
1038
+ options;
1039
+ store;
1040
+ constructor({
1041
+ id,
1042
+ store,
1043
+ subscribe,
1044
+ getAlgodClient,
1045
+ options = {},
1046
+ metadata = {}
1047
+ }) {
1048
+ super({ id, metadata, getAlgodClient, store, subscribe });
1049
+ this.options = options;
1050
+ this.store = store;
1051
+ }
1052
+ static defaultMetadata = { name: "Pera", icon: icon5 };
1053
+ async initializeClient() {
1054
+ const module = await import('./dist/RJ6UCT74.mjs');
1055
+ const PeraWalletConnect = module.default ? module.default.PeraWalletConnect : module.PeraWalletConnect;
1056
+ const client = new PeraWalletConnect(this.options);
1057
+ client.connector?.on("disconnect", this.onDisconnect);
1058
+ this.client = client;
1059
+ return client;
1060
+ }
1061
+ connect = async () => {
1062
+ try {
1063
+ const client = this.client || await this.initializeClient();
1064
+ const accounts = await client.connect();
1065
+ if (accounts.length === 0) {
1066
+ throw new Error("No accounts found!");
1067
+ }
1068
+ const walletAccounts = accounts.map((address, idx) => ({
1069
+ name: `Pera Wallet ${idx + 1}`,
1070
+ address
1071
+ }));
1072
+ const activeAccount = walletAccounts[0];
1073
+ addWallet(this.store, {
1074
+ walletId: this.id,
1075
+ wallet: {
1076
+ accounts: walletAccounts,
1077
+ activeAccount
1078
+ }
1079
+ });
1080
+ return walletAccounts;
1081
+ } catch (error) {
1082
+ if (error?.data?.type !== "CONNECT_MODAL_CLOSED") ;
1083
+ return [];
1084
+ }
1085
+ };
1086
+ disconnect = async () => {
1087
+ try {
1088
+ await this.client?.disconnect();
1089
+ this.onDisconnect();
1090
+ } catch (error) {
1091
+ }
1092
+ };
1093
+ resumeSession = async () => {
1094
+ try {
1095
+ const state = this.store.state;
1096
+ const walletState = state.wallets[this.id];
1097
+ if (!walletState) {
1098
+ return;
1099
+ }
1100
+ const client = this.client || await this.initializeClient();
1101
+ const accounts = await client.reconnectSession();
1102
+ if (accounts.length === 0) {
1103
+ throw new Error("[PeraWallet] No accounts found!");
1104
+ }
1105
+ const walletAccounts = accounts.map((address, idx) => ({
1106
+ name: `Pera Wallet ${idx + 1}`,
1107
+ address
1108
+ }));
1109
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1110
+ if (!match) {
1111
+ setAccounts(this.store, {
1112
+ walletId: this.id,
1113
+ accounts: walletAccounts
1114
+ });
1115
+ }
1116
+ } catch (error) {
1117
+ this.onDisconnect();
1118
+ }
1119
+ };
1120
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1121
+ if (!this.client) {
1122
+ throw new Error("[PeraWallet] Client not initialized!");
1123
+ }
1124
+ const txnsToSign = [];
1125
+ const signedIndexes = [];
1126
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1127
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1128
+ return esm_default.decodeObj(txn);
1129
+ });
1130
+ decodedObjects.forEach((txnObject, idx) => {
1131
+ const isSigned = isSignedTxnObject(txnObject);
1132
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1133
+ const txnBuffer = msgpackTxnGroup[idx];
1134
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1135
+ if (shouldSign) {
1136
+ txnsToSign.push({ txn });
1137
+ signedIndexes.push(idx);
1138
+ } else {
1139
+ txnsToSign.push({ txn, signers: [] });
1140
+ }
1141
+ });
1142
+ const signedTxns = await this.client.signTransaction([txnsToSign]);
1143
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1144
+ signedTxns,
1145
+ msgpackTxnGroup,
1146
+ signedIndexes,
1147
+ returnGroup
1148
+ );
1149
+ return txnGroupSigned;
1150
+ };
1151
+ transactionSigner = async (txnGroup, indexesToSign) => {
1152
+ if (!this.client) {
1153
+ throw new Error("[PeraWallet] Client not initialized!");
1154
+ }
1155
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1156
+ if (indexesToSign.includes(idx)) {
1157
+ acc.push({ txn });
1158
+ } else {
1159
+ acc.push({ txn, signers: [] });
1160
+ }
1161
+ return acc;
1162
+ }, []);
1163
+ const signTxnsResult = await this.client.signTransaction([txnsToSign]);
1164
+ return signTxnsResult;
1165
+ };
1166
+ };
1167
+ var icon6 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNDgwIDQ4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDgwIDQ4MDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiMzMzk2RkY7fQo8L3N0eWxlPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMTI2LjYsMTY4YzYyLjYtNjEuMywxNjQuMi02MS4zLDIyNi44LDBsNy41LDcuNGMzLjEsMy4xLDMuMSw4LDAsMTEuMWwtMjUuOCwyNS4yYy0xLjYsMS41LTQuMSwxLjUtNS43LDAKCWwtMTAuNC0xMC4yYy00My43LTQyLjgtMTE0LjUtNDIuOC0xNTguMiwwbC0xMS4xLDEwLjljLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMjUuOC0yNS4yYy0zLjEtMy4xLTMuMS04LDAtMTEuMUwxMjYuNiwxNjh6CgkgTTQwNi43LDIyMC4ybDIyLjksMjIuNWMzLjEsMy4xLDMuMSw4LDAsMTEuMUwzMjYuMiwzNTUuMWMtMy4xLDMuMS04LjIsMy4xLTExLjMsMGwtNzMuNC03MS45Yy0wLjgtMC44LTIuMS0wLjgtMi44LDBsLTczLjQsNzEuOQoJYy0zLjEsMy4xLTguMiwzLjEtMTEuMywwTDUwLjMsMjUzLjhjLTMuMS0zLjEtMy4xLTgsMC0xMS4xbDIyLjktMjIuNWMzLjEtMy4xLDguMi0zLjEsMTEuMywwbDczLjQsNzEuOWMwLjgsMC44LDIuMSwwLjgsMi44LDAKCWw3My40LTcxLjljMy4xLTMuMSw4LjItMy4xLDExLjMsMGw3My40LDcxLjljMC44LDAuOCwyLjEsMC44LDIuOCwwbDczLjQtNzEuOUMzOTguNSwyMTcuMSw0MDMuNiwyMTcuMSw0MDYuNywyMjAuMkw0MDYuNywyMjAuMnoiLz4KPC9zdmc+Cg==";
1168
+ var WalletConnect = class extends BaseWallet {
1169
+ client = null;
1170
+ options;
1171
+ modal = null;
1172
+ modalOptions;
1173
+ session = null;
1174
+ chains;
1175
+ store;
1176
+ constructor({
1177
+ id,
1178
+ store,
1179
+ subscribe,
1180
+ getAlgodClient,
1181
+ options,
1182
+ metadata = {}
1183
+ }) {
1184
+ super({ id, metadata, getAlgodClient, store, subscribe });
1185
+ if (!options?.projectId) {
1186
+ throw new Error("[WalletConnect] Missing required option: projectId");
1187
+ }
1188
+ const {
1189
+ projectId,
1190
+ relayUrl = "wss://relay.walletconnect.com",
1191
+ metadata: _metadata,
1192
+ ...modalOptions
1193
+ } = options;
1194
+ this.options = {
1195
+ projectId,
1196
+ relayUrl,
1197
+ ..._metadata
1198
+ };
1199
+ this.modalOptions = modalOptions;
1200
+ this.chains = Object.values(caipChainId);
1201
+ this.store = store;
1202
+ }
1203
+ static defaultMetadata = { name: "WalletConnect", icon: icon6 };
1204
+ async initializeClient() {
1205
+ const SignClient = (await import('./index.es/RVXGNQBK.mjs')).SignClient;
1206
+ const client = await SignClient.init(this.options);
1207
+ client.on("session_event", (args) => {
1208
+ });
1209
+ client.on("session_update", ({ topic, params }) => {
1210
+ const { namespaces } = params;
1211
+ const session = client.session.get(topic);
1212
+ const updatedSession = { ...session, namespaces };
1213
+ this.onSessionConnected(updatedSession);
1214
+ });
1215
+ client.on("session_delete", () => {
1216
+ this.session = null;
1217
+ });
1218
+ this.client = client;
1219
+ return client;
1220
+ }
1221
+ async initializeModal() {
1222
+ const WalletConnectModal = (await import('./dist/TLV6C2JZ.mjs')).WalletConnectModal;
1223
+ const modal = new WalletConnectModal({
1224
+ projectId: this.options.projectId,
1225
+ chains: this.chains,
1226
+ ...this.modalOptions
1227
+ });
1228
+ modal.subscribeModal(
1229
+ (state) => void 0
1230
+ );
1231
+ this.modal = modal;
1232
+ return modal;
1233
+ }
1234
+ onSessionConnected(session) {
1235
+ const caipAccounts = session.namespaces.algorand.accounts;
1236
+ if (!caipAccounts.length) {
1237
+ throw new Error("No accounts found!");
1238
+ }
1239
+ const accounts = [...new Set(caipAccounts.map((account) => account.split(":").pop()))];
1240
+ const walletAccounts = accounts.map((address, idx) => ({
1241
+ name: `WalletConnect ${idx + 1}`,
1242
+ address
1243
+ }));
1244
+ const state = this.store.state;
1245
+ const walletState = state.wallets[this.id];
1246
+ if (!walletState) {
1247
+ addWallet(this.store, {
1248
+ walletId: this.id,
1249
+ wallet: {
1250
+ accounts: walletAccounts,
1251
+ activeAccount: walletAccounts[0]
1252
+ }
1253
+ });
1254
+ } else {
1255
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1256
+ if (!match) {
1257
+ setAccounts(this.store, {
1258
+ walletId: this.id,
1259
+ accounts: walletAccounts
1260
+ });
1261
+ }
1262
+ }
1263
+ this.session = session;
1264
+ return walletAccounts;
1265
+ }
1266
+ connect = async () => {
1267
+ try {
1268
+ const client = this.client || await this.initializeClient();
1269
+ const modal = this.modal || await this.initializeModal();
1270
+ const requiredNamespaces = {
1271
+ algorand: {
1272
+ chains: this.chains,
1273
+ methods: ["algo_signTxn"],
1274
+ events: []
1275
+ }
1276
+ };
1277
+ const { uri, approval } = await client.connect({ requiredNamespaces });
1278
+ if (!uri) {
1279
+ throw new Error("No URI found");
1280
+ }
1281
+ await modal.openModal({ uri });
1282
+ const session = await approval();
1283
+ const walletAccounts = this.onSessionConnected(session);
1284
+ return walletAccounts;
1285
+ } catch (error) {
1286
+ return [];
1287
+ } finally {
1288
+ this.modal?.closeModal();
1289
+ }
1290
+ };
1291
+ disconnect = async () => {
1292
+ try {
1293
+ if (this.client && this.session) {
1294
+ await this.client.disconnect({
1295
+ topic: this.session.topic,
1296
+ reason: {
1297
+ message: "User disconnected.",
1298
+ code: 6e3
1299
+ }
1300
+ });
1301
+ }
1302
+ this.onDisconnect();
1303
+ } catch (error) {
1304
+ }
1305
+ };
1306
+ resumeSession = async () => {
1307
+ try {
1308
+ const state = this.store.state;
1309
+ const walletState = state.wallets[this.id];
1310
+ if (!walletState) {
1311
+ return;
1312
+ }
1313
+ const client = this.client || await this.initializeClient();
1314
+ if (client.session.length) {
1315
+ const lastKeyIndex = client.session.keys.length - 1;
1316
+ const restoredSession = client.session.get(client.session.keys[lastKeyIndex]);
1317
+ this.onSessionConnected(restoredSession);
1318
+ }
1319
+ } catch (error) {
1320
+ this.onDisconnect();
1321
+ }
1322
+ };
1323
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1324
+ if (!this.client) {
1325
+ throw new Error("[WalletConnect] Client not initialized!");
1326
+ }
1327
+ if (!this.session) {
1328
+ throw new Error("[WalletConnect] Session is not connected");
1329
+ }
1330
+ if (this.activeNetwork === "localnet") {
1331
+ throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
1332
+ }
1333
+ const txnsToSign = [];
1334
+ const signedIndexes = [];
1335
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1336
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1337
+ return esm_default.decodeObj(txn);
1338
+ });
1339
+ decodedObjects.forEach((txnObject, idx) => {
1340
+ const isSigned = isSignedTxnObject(txnObject);
1341
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1342
+ const txnBuffer = msgpackTxnGroup[idx];
1343
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1344
+ const txnBase64 = byteArrayToBase64(txn.toByte());
1345
+ if (shouldSign) {
1346
+ txnsToSign.push({ txn: txnBase64 });
1347
+ signedIndexes.push(idx);
1348
+ } else {
1349
+ txnsToSign.push({ txn: txnBase64, signers: [] });
1350
+ }
1351
+ });
1352
+ const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]);
1353
+ const signTxnsResult = await this.client.request({
1354
+ chainId: caipChainId[this.activeNetwork],
1355
+ topic: this.session.topic,
1356
+ request
1357
+ });
1358
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
1359
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
1360
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1361
+ signedTxns,
1362
+ msgpackTxnGroup,
1363
+ signedIndexes,
1364
+ returnGroup
1365
+ );
1366
+ return txnGroupSigned;
1367
+ };
1368
+ transactionSigner = async (txnGroup, indexesToSign) => {
1369
+ if (!this.client) {
1370
+ throw new Error("[WalletConnect] Client not initialized!");
1371
+ }
1372
+ if (!this.session) {
1373
+ throw new Error("[WalletConnect] Session is not connected");
1374
+ }
1375
+ if (this.activeNetwork === "localnet") {
1376
+ throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
1377
+ }
1378
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1379
+ const txnBase64 = byteArrayToBase64(txn.toByte());
1380
+ if (indexesToSign.includes(idx)) {
1381
+ acc.push({ txn: txnBase64 });
1382
+ } else {
1383
+ acc.push({ txn: txnBase64, signers: [] });
1384
+ }
1385
+ return acc;
1386
+ }, []);
1387
+ const request = formatJsonRpcRequest("algo_signTxn", [txnsToSign]);
1388
+ const signTxnsResult = await this.client.request({
1389
+ chainId: caipChainId[this.activeNetwork],
1390
+ topic: this.session.topic,
1391
+ request
1392
+ });
1393
+ const signedTxnsBase64 = signTxnsResult.filter(Boolean);
1394
+ const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
1395
+ return signedTxns;
1396
+ };
1397
+ };
1398
+ function createWalletMap() {
1399
+ return {
1400
+ [
1401
+ "defly"
1402
+ /* DEFLY */
1403
+ ]: DeflyWallet,
1404
+ [
1405
+ "exodus"
1406
+ /* EXODUS */
1407
+ ]: ExodusWallet,
1408
+ [
1409
+ "kibisis"
1410
+ /* KIBISIS */
1411
+ ]: KibisisWallet,
1412
+ [
1413
+ "kmd"
1414
+ /* KMD */
1415
+ ]: KmdWallet,
1416
+ [
1417
+ "lute"
1418
+ /* LUTE */
1419
+ ]: LuteWallet,
1420
+ [
1421
+ "mnemonic"
1422
+ /* MNEMONIC */
1423
+ ]: MnemonicWallet,
1424
+ [
1425
+ "pera"
1426
+ /* PERA */
1427
+ ]: PeraWallet,
1428
+ [
1429
+ "walletconnect"
1430
+ /* WALLETCONNECT */
1431
+ ]: WalletConnect
1432
+ };
1433
+ }
1434
+ function compareAccounts(accounts, compareTo) {
1435
+ const addresses = new Set(accounts.map((account) => account.address));
1436
+ const compareAddresses = new Set(compareTo.map((account) => account.address));
1437
+ if (addresses.size !== compareAddresses.size) {
1438
+ return false;
1439
+ }
1440
+ for (const address of addresses) {
1441
+ if (!compareAddresses.has(address)) {
1442
+ return false;
1443
+ }
1444
+ }
1445
+ return true;
1446
+ }
1447
+ function base64ToByteArray(blob) {
1448
+ return stringToByteArray(atob(blob));
1449
+ }
1450
+ function byteArrayToBase64(array) {
1451
+ return btoa(byteArrayToString(array));
1452
+ }
1453
+ function stringToByteArray(str) {
1454
+ const array = new Uint8Array(str.length);
1455
+ for (let i = 0; i < str.length; i++) {
1456
+ array[i] = str.charCodeAt(i);
1457
+ }
1458
+ return array;
1459
+ }
1460
+ function byteArrayToString(array) {
1461
+ let result = "";
1462
+ for (let i = 0; i < array.length; i++) {
1463
+ result += String.fromCharCode(array[i]);
1464
+ }
1465
+ return result;
1466
+ }
1467
+ function isTransaction(item) {
1468
+ if (Array.isArray(item)) {
1469
+ return item.every(
1470
+ (elem) => typeof elem === "object" && elem !== null && "genesisID" in elem && typeof elem.genesisID === "string"
1471
+ );
1472
+ } else {
1473
+ return typeof item === "object" && item !== null && "genesisID" in item && typeof item.genesisID === "string";
1474
+ }
1475
+ }
1476
+ function isSignedTxnObject(item) {
1477
+ return item.txn !== void 0;
1478
+ }
1479
+ function normalizeTxnGroup(txnGroup) {
1480
+ if (!txnGroup[0]) {
1481
+ throw new Error("Empty transaction group!");
1482
+ }
1483
+ const isTransactionType = isTransaction(txnGroup[0]);
1484
+ if (isTransactionType) {
1485
+ const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
1486
+ return transactionGroup.map((txn) => {
1487
+ return esm_default.encodeUnsignedTransaction(txn);
1488
+ });
1489
+ } else {
1490
+ const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
1491
+ return transactionGroup;
1492
+ }
1493
+ }
1494
+ function shouldSignTxnObject(txnObject, addresses, indexesToSign, idx) {
1495
+ const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
1496
+ const isSigned = isSignedTxnObject(txnObject);
1497
+ const canSign = !isSigned && addresses.includes(esm_default.encodeAddress(txnObject.snd));
1498
+ const shouldSign = isIndexMatch && canSign;
1499
+ return shouldSign;
1500
+ }
1501
+ function mergeSignedTxnsWithGroup(signedTxns, txnGroup, signedIndexes, returnGroup) {
1502
+ return txnGroup.reduce((acc, txn, i) => {
1503
+ if (signedIndexes.includes(i)) {
1504
+ const signedByUser = signedTxns.shift();
1505
+ signedByUser && acc.push(signedByUser);
1506
+ } else if (returnGroup) {
1507
+ acc.push(txnGroup[i]);
1508
+ }
1509
+ return acc;
1510
+ }, []);
1511
+ }
1512
+ function getPayloadId() {
1513
+ const date = Date.now() * Math.pow(10, 3);
1514
+ const extra = Math.floor(Math.random() * Math.pow(10, 3));
1515
+ return date + extra;
1516
+ }
1517
+ function formatJsonRpcRequest(method, params) {
1518
+ return {
1519
+ id: getPayloadId(),
1520
+ jsonrpc: "2.0",
1521
+ method,
1522
+ params
1523
+ };
1524
+ }
1525
+ function deepMerge(target, source) {
1526
+ const isObject = (obj) => obj && typeof obj === "object";
1527
+ if (!isObject(target) || !isObject(source)) {
1528
+ throw new Error("Target and source must be objects");
1529
+ }
1530
+ Object.keys(source).forEach((key) => {
1531
+ const targetValue = target[key];
1532
+ const sourceValue = source[key];
1533
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
1534
+ target[key] = targetValue.concat(sourceValue);
1535
+ } else if (isObject(targetValue) && isObject(sourceValue)) {
1536
+ target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
1537
+ } else {
1538
+ target[key] = sourceValue;
1539
+ }
1540
+ });
1541
+ return target;
1542
+ }
1543
+ function generateUuid() {
1544
+ if (window.crypto.randomUUID) {
1545
+ return window.crypto.randomUUID();
1546
+ }
1547
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (value) => {
1548
+ const valueAsNumber = parseInt(value);
1549
+ return (valueAsNumber ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> valueAsNumber / 4).toString(16);
1550
+ });
1551
+ }
1552
+ var icon7 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxuczpzZXJpZj0iaHR0cDovL3d3dy5zZXJpZi5jb20vIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjI7Ij4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjEwMjQiLz4KICAgIDxnIHRyYW5zZm9ybT0ibWF0cml4KDEuNjgyMDksMCwwLDEuNjgyMDksMjI2LjM2OCwyMTIuODE4KSI+CiAgICAgICAgPHBhdGggZD0iTTMyNy4wNDksMjgwLjE5MkwxNjkuNTI0LDEzTDEyLDI4MC4xOTJMMTY5LjUyNCwxODkuMDg0TDMyNy4wNDksMjgwLjE5MloiIHN0eWxlPSJmaWxsOndoaXRlO2ZpbGwtcnVsZTpub256ZXJvOyIvPgogICAgPC9nPgogICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMS42ODIwOSwwLDAsMS42ODIwOSwyMjYuMzY4LDIxMi44MTgpIj4KICAgICAgICA8cGF0aCBkPSJNMjk5LjU0NiwzMDdMMTY5LjUyNSwyMzguNDczTDM5LjUwNCwzMDdMMTY5LjUyNSwyNjQuNjdMMjk5LjU0NiwzMDdaIiBzdHlsZT0iZmlsbDp3aGl0ZTtmaWxsLXJ1bGU6bm9uemVybzsiLz4KICAgIDwvZz4KPC9zdmc+Cg==";
1553
+ var DeflyWallet = class extends BaseWallet {
1554
+ client = null;
1555
+ options;
1556
+ store;
1557
+ constructor({
1558
+ id,
1559
+ store,
1560
+ subscribe,
1561
+ getAlgodClient,
1562
+ options = {},
1563
+ metadata = {}
1564
+ }) {
1565
+ super({ id, metadata, getAlgodClient, store, subscribe });
1566
+ this.options = options;
1567
+ this.store = store;
1568
+ }
1569
+ static defaultMetadata = { name: "Defly", icon: icon7 };
1570
+ async initializeClient() {
1571
+ const module = await import('./dist/4VXEBRHF.mjs');
1572
+ const DeflyWalletConnect = module.default ? module.default.DeflyWalletConnect : module.DeflyWalletConnect;
1573
+ const client = new DeflyWalletConnect(this.options);
1574
+ client.connector?.on("disconnect", this.onDisconnect);
1575
+ this.client = client;
1576
+ return client;
1577
+ }
1578
+ connect = async () => {
1579
+ try {
1580
+ const client = this.client || await this.initializeClient();
1581
+ const accounts = await client.connect();
1582
+ if (accounts.length === 0) {
1583
+ throw new Error("No accounts found!");
1584
+ }
1585
+ const walletAccounts = accounts.map((address, idx) => ({
1586
+ name: `Defly Wallet ${idx + 1}`,
1587
+ address
1588
+ }));
1589
+ const activeAccount = walletAccounts[0];
1590
+ addWallet(this.store, {
1591
+ walletId: this.id,
1592
+ wallet: {
1593
+ accounts: walletAccounts,
1594
+ activeAccount
1595
+ }
1596
+ });
1597
+ return walletAccounts;
1598
+ } catch (error) {
1599
+ if (error?.data?.type !== "CONNECT_MODAL_CLOSED") ;
1600
+ return [];
1601
+ }
1602
+ };
1603
+ disconnect = async () => {
1604
+ try {
1605
+ await this.client?.disconnect();
1606
+ this.onDisconnect();
1607
+ } catch (error) {
1608
+ }
1609
+ };
1610
+ resumeSession = async () => {
1611
+ try {
1612
+ const state = this.store.state;
1613
+ const walletState = state.wallets[this.id];
1614
+ if (!walletState) {
1615
+ return;
1616
+ }
1617
+ const client = this.client || await this.initializeClient();
1618
+ const accounts = await client.reconnectSession();
1619
+ if (accounts.length === 0) {
1620
+ throw new Error("[DeflyWallet] No accounts found!");
1621
+ }
1622
+ const walletAccounts = accounts.map((address, idx) => ({
1623
+ name: `Defly Wallet ${idx + 1}`,
1624
+ address
1625
+ }));
1626
+ const match = compareAccounts(walletAccounts, walletState.accounts);
1627
+ if (!match) {
1628
+ setAccounts(this.store, {
1629
+ walletId: this.id,
1630
+ accounts: walletAccounts
1631
+ });
1632
+ }
1633
+ } catch (error) {
1634
+ this.onDisconnect();
1635
+ }
1636
+ };
1637
+ signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
1638
+ if (!this.client) {
1639
+ throw new Error("[DeflyWallet] Client not initialized!");
1640
+ }
1641
+ const txnsToSign = [];
1642
+ const signedIndexes = [];
1643
+ const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
1644
+ const decodedObjects = msgpackTxnGroup.map((txn) => {
1645
+ return esm_default.decodeObj(txn);
1646
+ });
1647
+ decodedObjects.forEach((txnObject, idx) => {
1648
+ const isSigned = isSignedTxnObject(txnObject);
1649
+ const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
1650
+ const txnBuffer = msgpackTxnGroup[idx];
1651
+ const txn = isSigned ? esm_default.decodeSignedTransaction(txnBuffer).txn : esm_default.decodeUnsignedTransaction(txnBuffer);
1652
+ if (shouldSign) {
1653
+ txnsToSign.push({ txn });
1654
+ signedIndexes.push(idx);
1655
+ } else {
1656
+ txnsToSign.push({ txn, signers: [] });
1657
+ }
1658
+ });
1659
+ const signedTxns = await this.client.signTransaction([txnsToSign]);
1660
+ const txnGroupSigned = mergeSignedTxnsWithGroup(
1661
+ signedTxns,
1662
+ msgpackTxnGroup,
1663
+ signedIndexes,
1664
+ returnGroup
1665
+ );
1666
+ return txnGroupSigned;
1667
+ };
1668
+ transactionSigner = async (txnGroup, indexesToSign) => {
1669
+ if (!this.client) {
1670
+ throw new Error("[DeflyWallet] Client not initialized!");
1671
+ }
1672
+ const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
1673
+ if (indexesToSign.includes(idx)) {
1674
+ acc.push({ txn });
1675
+ } else {
1676
+ acc.push({ txn, signers: [] });
1677
+ }
1678
+ return acc;
1679
+ }, []);
1680
+ const signTxnsResult = await this.client.signTransaction([txnsToSign]);
1681
+ return signTxnsResult;
1682
+ };
1683
+ };
1684
+ var defaultState = {
1685
+ wallets: {},
1686
+ activeWallet: null,
1687
+ activeNetwork: "testnet"
1688
+ /* TESTNET */
1689
+ };
1690
+ var LOCAL_STORAGE_KEY = "@txnlab/use-wallet:v3";
1691
+ function addWallet(store, { walletId, wallet }) {
1692
+ store.setState((state) => {
1693
+ const newWallets = {
1694
+ ...state.wallets,
1695
+ [walletId]: wallet
1696
+ };
1697
+ return {
1698
+ ...state,
1699
+ wallets: newWallets,
1700
+ activeWallet: walletId
1701
+ };
1702
+ });
1703
+ }
1704
+ function removeWallet(store, { walletId }) {
1705
+ store.setState((state) => {
1706
+ const newWallets = { ...state.wallets };
1707
+ delete newWallets[walletId];
1708
+ return {
1709
+ ...state,
1710
+ wallets: newWallets,
1711
+ activeWallet: state.activeWallet === walletId ? null : state.activeWallet
1712
+ };
1713
+ });
1714
+ }
1715
+ function setActiveWallet(store, { walletId }) {
1716
+ store.setState((state) => {
1717
+ return {
1718
+ ...state,
1719
+ activeWallet: walletId
1720
+ };
1721
+ });
1722
+ }
1723
+ function setActiveAccount(store, { walletId, address }) {
1724
+ store.setState((state) => {
1725
+ const wallet = state.wallets[walletId];
1726
+ if (!wallet) {
1727
+ return state;
1728
+ }
1729
+ const activeAccount = wallet.accounts.find((a) => a.address === address);
1730
+ if (!activeAccount) {
1731
+ return state;
1732
+ }
1733
+ const newWallets = {
1734
+ ...state.wallets,
1735
+ [walletId]: {
1736
+ ...wallet,
1737
+ activeAccount
1738
+ }
1739
+ };
1740
+ return {
1741
+ ...state,
1742
+ wallets: newWallets
1743
+ };
1744
+ });
1745
+ }
1746
+ function setAccounts(store, { walletId, accounts }) {
1747
+ store.setState((state) => {
1748
+ const wallet = state.wallets[walletId];
1749
+ if (!wallet) {
1750
+ return state;
1751
+ }
1752
+ const isActiveAccountConnected = accounts.some(
1753
+ (account) => account.address === wallet.activeAccount?.address
1754
+ );
1755
+ const activeAccount = isActiveAccountConnected ? wallet.activeAccount : accounts[0] || null;
1756
+ const newWallet = {
1757
+ ...wallet,
1758
+ accounts,
1759
+ activeAccount
1760
+ };
1761
+ const newWallets = {
1762
+ ...state.wallets,
1763
+ [walletId]: newWallet
1764
+ };
1765
+ return {
1766
+ ...state,
1767
+ wallets: newWallets
1768
+ };
1769
+ });
1770
+ }
1771
+ function setActiveNetwork(store, { networkId }) {
1772
+ store.setState((state) => {
1773
+ return {
1774
+ ...state,
1775
+ activeNetwork: networkId
1776
+ };
1777
+ });
1778
+ }
1779
+ function isValidWalletId(walletId) {
1780
+ return Object.values(WalletId).includes(walletId);
1781
+ }
1782
+ function isValidWalletAccount(account) {
1783
+ return typeof account === "object" && account !== null && typeof account.name === "string" && typeof account.address === "string";
1784
+ }
1785
+ function isValidWalletState(wallet) {
1786
+ return typeof wallet === "object" && wallet !== null && Array.isArray(wallet.accounts) && wallet.accounts.every(isValidWalletAccount) && (wallet.activeAccount === null || isValidWalletAccount(wallet.activeAccount));
1787
+ }
1788
+ function isValidState(state) {
1789
+ if (!state || typeof state !== "object")
1790
+ return false;
1791
+ if (typeof state.wallets !== "object")
1792
+ return false;
1793
+ for (const [walletId, wallet] of Object.entries(state.wallets)) {
1794
+ if (!isValidWalletId(walletId) || !isValidWalletState(wallet))
1795
+ return false;
1796
+ }
1797
+ if (state.activeWallet !== null && !isValidWalletId(state.activeWallet))
1798
+ return false;
1799
+ if (!isValidNetworkId(state.activeNetwork))
1800
+ return false;
1801
+ return true;
1802
+ }
1803
+ var WalletManager = class {
1804
+ _clients = /* @__PURE__ */ new Map();
1805
+ networkConfig;
1806
+ algodClient;
1807
+ store;
1808
+ subscribe;
1809
+ constructor({ wallets = [], network = "testnet", algod = {} } = {}) {
1810
+ const initialState = this.loadPersistedState() || {
1811
+ ...defaultState,
1812
+ activeNetwork: network
1813
+ };
1814
+ this.store = new Store(initialState, {
1815
+ onUpdate: () => this.savePersistedState()
1816
+ });
1817
+ this.savePersistedState();
1818
+ this.subscribe = (callback) => {
1819
+ const unsubscribe = this.store.subscribe(() => {
1820
+ callback(this.store.state);
1821
+ });
1822
+ return unsubscribe;
1823
+ };
1824
+ this.networkConfig = this.initNetworkConfig(network, algod);
1825
+ this.algodClient = this.createAlgodClient(this.networkConfig[network]);
1826
+ this.initializeWallets(wallets);
1827
+ }
1828
+ // ---------- Store ------------------------------------------------- //
1829
+ loadPersistedState() {
1830
+ try {
1831
+ const serializedState = StorageAdapter.getItem(LOCAL_STORAGE_KEY);
1832
+ if (serializedState === null) {
1833
+ return null;
1834
+ }
1835
+ const parsedState = JSON.parse(serializedState);
1836
+ if (!isValidState(parsedState)) {
1837
+ throw new Error("Persisted state is invalid");
1838
+ }
1839
+ return parsedState;
1840
+ } catch (error) {
1841
+ return null;
1842
+ }
1843
+ }
1844
+ savePersistedState() {
1845
+ try {
1846
+ const state = this.store.state;
1847
+ const serializedState = JSON.stringify(state);
1848
+ StorageAdapter.setItem(LOCAL_STORAGE_KEY, serializedState);
1849
+ } catch (error) {
1850
+ }
1851
+ }
1852
+ // ---------- Wallets ----------------------------------------------- //
1853
+ initializeWallets(walletsConfig) {
1854
+ for (const walletConfig of walletsConfig) {
1855
+ let walletId;
1856
+ let walletOptions;
1857
+ let walletMetadata;
1858
+ if (typeof walletConfig === "string") {
1859
+ walletId = walletConfig;
1860
+ } else {
1861
+ const { id, options, metadata } = walletConfig;
1862
+ walletId = id;
1863
+ walletOptions = options;
1864
+ walletMetadata = metadata;
1865
+ }
1866
+ const walletMap = createWalletMap();
1867
+ const WalletClass = walletMap[walletId];
1868
+ if (!WalletClass) {
1869
+ continue;
1870
+ }
1871
+ const walletInstance = new WalletClass({
1872
+ id: walletId,
1873
+ metadata: walletMetadata,
1874
+ options: walletOptions,
1875
+ getAlgodClient: this.getAlgodClient,
1876
+ store: this.store,
1877
+ subscribe: this.subscribe
1878
+ });
1879
+ this._clients.set(walletId, walletInstance);
1880
+ }
1881
+ const state = this.store.state;
1882
+ const connectedWallets = Object.keys(state.wallets);
1883
+ for (const walletId of connectedWallets) {
1884
+ if (!this._clients.has(walletId)) {
1885
+ removeWallet(this.store, { walletId });
1886
+ }
1887
+ }
1888
+ if (state.activeWallet && !this._clients.has(state.activeWallet)) {
1889
+ setActiveWallet(this.store, { walletId: null });
1890
+ }
1891
+ }
1892
+ get wallets() {
1893
+ return [...this._clients.values()];
1894
+ }
1895
+ getWallet(walletId) {
1896
+ return this._clients.get(walletId);
1897
+ }
1898
+ async resumeSessions() {
1899
+ const promises = this.wallets.map((wallet) => wallet?.resumeSession());
1900
+ await Promise.all(promises);
1901
+ }
1902
+ // ---------- Network ----------------------------------------------- //
1903
+ initNetworkConfig(network, config) {
1904
+ let networkConfig = createDefaultNetworkConfig();
1905
+ if (isNetworkConfigMap(config)) {
1906
+ networkConfig = deepMerge(networkConfig, config);
1907
+ } else {
1908
+ networkConfig[network] = deepMerge(networkConfig[network], config);
1909
+ }
1910
+ return networkConfig;
1911
+ }
1912
+ createAlgodClient(config) {
1913
+ const { token = "", baseServer, port = "", headers = {} } = config;
1914
+ return new esm_default.Algodv2(token, baseServer, port, headers);
1915
+ }
1916
+ getAlgodClient = () => {
1917
+ return this.algodClient;
1918
+ };
1919
+ setActiveNetwork = (networkId) => {
1920
+ setActiveNetwork(this.store, { networkId });
1921
+ this.algodClient = this.createAlgodClient(this.networkConfig[networkId]);
1922
+ };
1923
+ get activeNetwork() {
1924
+ return this.store.state.activeNetwork;
1925
+ }
1926
+ // ---------- Active Wallet ----------------------------------------- //
1927
+ get activeWallet() {
1928
+ const state = this.store.state;
1929
+ const activeWallet = this.wallets.find((wallet) => wallet.id === state.activeWallet);
1930
+ if (!activeWallet) {
1931
+ return null;
1932
+ }
1933
+ return activeWallet;
1934
+ }
1935
+ get activeWalletAccounts() {
1936
+ if (!this.activeWallet) {
1937
+ return null;
1938
+ }
1939
+ return this.activeWallet.accounts;
1940
+ }
1941
+ get activeWalletAddresses() {
1942
+ if (!this.activeWallet) {
1943
+ return null;
1944
+ }
1945
+ return this.activeWallet.accounts.map((account) => account.address);
1946
+ }
1947
+ get activeAccount() {
1948
+ if (!this.activeWallet) {
1949
+ return null;
1950
+ }
1951
+ return this.activeWallet.activeAccount;
1952
+ }
1953
+ get activeAddress() {
1954
+ if (!this.activeAccount) {
1955
+ return null;
1956
+ }
1957
+ return this.activeAccount.address;
1958
+ }
1959
+ // ---------- Sign Transactions ------------------------------------- //
1960
+ get signTransactions() {
1961
+ if (!this.activeWallet) {
1962
+ throw new Error("[Manager] No active wallet found!");
1963
+ }
1964
+ return this.activeWallet.signTransactions;
1965
+ }
1966
+ /**
1967
+ * A function which can sign transactions from an atomic transaction group. The logic will be
1968
+ * specific to each wallet, but the function will always return a promise that resolves to an
1969
+ * array of encoded signed transactions matching the length of the indexesToSign array.
1970
+ *
1971
+ * @see https://github.com/algorand/js-algorand-sdk/blob/v2.6.0/src/signer.ts#L7-L18
1972
+ *
1973
+ * @param txnGroup - The atomic group containing transactions to be signed
1974
+ * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed
1975
+ * @returns A promise which resolves an array of encoded signed transactions. The length of the
1976
+ * array will be the same as the length of indexesToSign, and each index i in the array
1977
+ * corresponds to the signed transaction from txnGroup[indexesToSign[i]]
1978
+ */
1979
+ get transactionSigner() {
1980
+ if (!this.activeWallet) {
1981
+ throw new Error("[Manager] No active wallet found!");
1982
+ }
1983
+ return this.activeWallet.transactionSigner;
1984
+ }
1985
+ };
1986
+
1987
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/solid.js
1988
+ var sharedConfig = {
1989
+ context: void 0,
1990
+ registry: void 0
1991
+ };
1992
+ function setHydrateContext(context) {
1993
+ sharedConfig.context = context;
1994
+ }
1995
+ function nextHydrateContext() {
1996
+ return {
1997
+ ...sharedConfig.context,
1998
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
1999
+ count: 0
2000
+ };
2001
+ }
2002
+ var equalFn = (a, b) => a === b;
2003
+ var $PROXY = Symbol("solid-proxy");
2004
+ var $TRACK = Symbol("solid-track");
2005
+ var signalOptions = {
2006
+ equals: equalFn
2007
+ };
2008
+ var ERROR = null;
2009
+ var runEffects = runQueue;
2010
+ var STALE = 1;
2011
+ var PENDING = 2;
2012
+ var UNOWNED = {
2013
+ owned: null,
2014
+ cleanups: null,
2015
+ context: null,
2016
+ owner: null
2017
+ };
2018
+ var Owner = null;
2019
+ var Transition = null;
2020
+ var Scheduler = null;
2021
+ var ExternalSourceConfig = null;
2022
+ var Listener = null;
2023
+ var Updates = null;
2024
+ var Effects = null;
2025
+ var ExecCount = 0;
2026
+ function createSignal(value, options) {
2027
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
2028
+ const s = {
2029
+ value,
2030
+ observers: null,
2031
+ observerSlots: null,
2032
+ comparator: options.equals || void 0
2033
+ };
2034
+ const setter = (value2) => {
2035
+ if (typeof value2 === "function") {
2036
+ if (Transition && Transition.running && Transition.sources.has(s))
2037
+ value2 = value2(s.tValue);
2038
+ else
2039
+ value2 = value2(s.value);
2040
+ }
2041
+ return writeSignal(s, value2);
2042
+ };
2043
+ return [readSignal.bind(s), setter];
2044
+ }
2045
+ function createRenderEffect(fn, value, options) {
2046
+ const c = createComputation(fn, value, false, STALE);
2047
+ if (Scheduler && Transition && Transition.running)
2048
+ Updates.push(c);
2049
+ else
2050
+ updateComputation(c);
2051
+ }
2052
+ function createEffect(fn, value, options) {
2053
+ runEffects = runUserEffects;
2054
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
2055
+ if (s)
2056
+ c.suspense = s;
2057
+ if (!options || !options.render)
2058
+ c.user = true;
2059
+ Effects ? Effects.push(c) : updateComputation(c);
2060
+ }
2061
+ function createMemo(fn, value, options) {
2062
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
2063
+ const c = createComputation(fn, value, true, 0);
2064
+ c.observers = null;
2065
+ c.observerSlots = null;
2066
+ c.comparator = options.equals || void 0;
2067
+ if (Scheduler && Transition && Transition.running) {
2068
+ c.tState = STALE;
2069
+ Updates.push(c);
2070
+ } else
2071
+ updateComputation(c);
2072
+ return readSignal.bind(c);
2073
+ }
2074
+ function batch(fn) {
2075
+ return runUpdates(fn, false);
2076
+ }
2077
+ function untrack(fn) {
2078
+ if (!ExternalSourceConfig && Listener === null)
2079
+ return fn();
2080
+ const listener = Listener;
2081
+ Listener = null;
2082
+ try {
2083
+ if (ExternalSourceConfig)
2084
+ return ExternalSourceConfig.untrack(fn);
2085
+ return fn();
2086
+ } finally {
2087
+ Listener = listener;
2088
+ }
2089
+ }
2090
+ function onMount(fn) {
2091
+ createEffect(() => untrack(fn));
2092
+ }
2093
+ function onCleanup(fn) {
2094
+ if (Owner === null)
2095
+ ;
2096
+ else if (Owner.cleanups === null)
2097
+ Owner.cleanups = [fn];
2098
+ else
2099
+ Owner.cleanups.push(fn);
2100
+ return fn;
2101
+ }
2102
+ function getListener() {
2103
+ return Listener;
2104
+ }
2105
+ function startTransition(fn) {
2106
+ if (Transition && Transition.running) {
2107
+ fn();
2108
+ return Transition.done;
2109
+ }
2110
+ const l = Listener;
2111
+ const o = Owner;
2112
+ return Promise.resolve().then(() => {
2113
+ Listener = l;
2114
+ Owner = o;
2115
+ let t;
2116
+ if (Scheduler || SuspenseContext) {
2117
+ t = Transition || (Transition = {
2118
+ sources: /* @__PURE__ */ new Set(),
2119
+ effects: [],
2120
+ promises: /* @__PURE__ */ new Set(),
2121
+ disposed: /* @__PURE__ */ new Set(),
2122
+ queue: /* @__PURE__ */ new Set(),
2123
+ running: true
2124
+ });
2125
+ t.done || (t.done = new Promise((res) => t.resolve = res));
2126
+ t.running = true;
2127
+ }
2128
+ runUpdates(fn, false);
2129
+ Listener = Owner = null;
2130
+ return t ? t.done : void 0;
2131
+ });
2132
+ }
2133
+ var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
2134
+ function createContext(defaultValue, options) {
2135
+ const id = Symbol("context");
2136
+ return {
2137
+ id,
2138
+ Provider: createProvider(id),
2139
+ defaultValue
2140
+ };
2141
+ }
2142
+ function useContext(context) {
2143
+ return Owner && Owner.context && Owner.context[context.id] !== void 0 ? Owner.context[context.id] : context.defaultValue;
2144
+ }
2145
+ function children(fn) {
2146
+ const children2 = createMemo(fn);
2147
+ const memo = createMemo(() => resolveChildren(children2()));
2148
+ memo.toArray = () => {
2149
+ const c = memo();
2150
+ return Array.isArray(c) ? c : c != null ? [c] : [];
2151
+ };
2152
+ return memo;
2153
+ }
2154
+ var SuspenseContext;
2155
+ function readSignal() {
2156
+ const runningTransition = Transition && Transition.running;
2157
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
2158
+ if ((runningTransition ? this.tState : this.state) === STALE)
2159
+ updateComputation(this);
2160
+ else {
2161
+ const updates = Updates;
2162
+ Updates = null;
2163
+ runUpdates(() => lookUpstream(this), false);
2164
+ Updates = updates;
2165
+ }
2166
+ }
2167
+ if (Listener) {
2168
+ const sSlot = this.observers ? this.observers.length : 0;
2169
+ if (!Listener.sources) {
2170
+ Listener.sources = [this];
2171
+ Listener.sourceSlots = [sSlot];
2172
+ } else {
2173
+ Listener.sources.push(this);
2174
+ Listener.sourceSlots.push(sSlot);
2175
+ }
2176
+ if (!this.observers) {
2177
+ this.observers = [Listener];
2178
+ this.observerSlots = [Listener.sources.length - 1];
2179
+ } else {
2180
+ this.observers.push(Listener);
2181
+ this.observerSlots.push(Listener.sources.length - 1);
2182
+ }
2183
+ }
2184
+ if (runningTransition && Transition.sources.has(this))
2185
+ return this.tValue;
2186
+ return this.value;
2187
+ }
2188
+ function writeSignal(node, value, isComp) {
2189
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
2190
+ if (!node.comparator || !node.comparator(current, value)) {
2191
+ if (Transition) {
2192
+ const TransitionRunning = Transition.running;
2193
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
2194
+ Transition.sources.add(node);
2195
+ node.tValue = value;
2196
+ }
2197
+ if (!TransitionRunning)
2198
+ node.value = value;
2199
+ } else
2200
+ node.value = value;
2201
+ if (node.observers && node.observers.length) {
2202
+ runUpdates(() => {
2203
+ for (let i = 0; i < node.observers.length; i += 1) {
2204
+ const o = node.observers[i];
2205
+ const TransitionRunning = Transition && Transition.running;
2206
+ if (TransitionRunning && Transition.disposed.has(o))
2207
+ continue;
2208
+ if (TransitionRunning ? !o.tState : !o.state) {
2209
+ if (o.pure)
2210
+ Updates.push(o);
2211
+ else
2212
+ Effects.push(o);
2213
+ if (o.observers)
2214
+ markDownstream(o);
2215
+ }
2216
+ if (!TransitionRunning)
2217
+ o.state = STALE;
2218
+ else
2219
+ o.tState = STALE;
2220
+ }
2221
+ if (Updates.length > 1e6) {
2222
+ Updates = [];
2223
+ if (false)
2224
+ ;
2225
+ throw new Error();
2226
+ }
2227
+ }, false);
2228
+ }
2229
+ }
2230
+ return value;
2231
+ }
2232
+ function updateComputation(node) {
2233
+ if (!node.fn)
2234
+ return;
2235
+ cleanNode(node);
2236
+ const time = ExecCount;
2237
+ runComputation(
2238
+ node,
2239
+ Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
2240
+ time
2241
+ );
2242
+ if (Transition && !Transition.running && Transition.sources.has(node)) {
2243
+ queueMicrotask(() => {
2244
+ runUpdates(() => {
2245
+ Transition && (Transition.running = true);
2246
+ Listener = Owner = node;
2247
+ runComputation(node, node.tValue, time);
2248
+ Listener = Owner = null;
2249
+ }, false);
2250
+ });
2251
+ }
2252
+ }
2253
+ function runComputation(node, value, time) {
2254
+ let nextValue;
2255
+ const owner = Owner, listener = Listener;
2256
+ Listener = Owner = node;
2257
+ try {
2258
+ nextValue = node.fn(value);
2259
+ } catch (err) {
2260
+ if (node.pure) {
2261
+ if (Transition && Transition.running) {
2262
+ node.tState = STALE;
2263
+ node.tOwned && node.tOwned.forEach(cleanNode);
2264
+ node.tOwned = void 0;
2265
+ } else {
2266
+ node.state = STALE;
2267
+ node.owned && node.owned.forEach(cleanNode);
2268
+ node.owned = null;
2269
+ }
2270
+ }
2271
+ node.updatedAt = time + 1;
2272
+ return handleError(err);
2273
+ } finally {
2274
+ Listener = listener;
2275
+ Owner = owner;
2276
+ }
2277
+ if (!node.updatedAt || node.updatedAt <= time) {
2278
+ if (node.updatedAt != null && "observers" in node) {
2279
+ writeSignal(node, nextValue, true);
2280
+ } else if (Transition && Transition.running && node.pure) {
2281
+ Transition.sources.add(node);
2282
+ node.tValue = nextValue;
2283
+ } else
2284
+ node.value = nextValue;
2285
+ node.updatedAt = time;
2286
+ }
2287
+ }
2288
+ function createComputation(fn, init, pure, state = STALE, options) {
2289
+ const c = {
2290
+ fn,
2291
+ state,
2292
+ updatedAt: null,
2293
+ owned: null,
2294
+ sources: null,
2295
+ sourceSlots: null,
2296
+ cleanups: null,
2297
+ value: init,
2298
+ owner: Owner,
2299
+ context: Owner ? Owner.context : null,
2300
+ pure
2301
+ };
2302
+ if (Transition && Transition.running) {
2303
+ c.state = 0;
2304
+ c.tState = state;
2305
+ }
2306
+ if (Owner === null)
2307
+ ;
2308
+ else if (Owner !== UNOWNED) {
2309
+ if (Transition && Transition.running && Owner.pure) {
2310
+ if (!Owner.tOwned)
2311
+ Owner.tOwned = [c];
2312
+ else
2313
+ Owner.tOwned.push(c);
2314
+ } else {
2315
+ if (!Owner.owned)
2316
+ Owner.owned = [c];
2317
+ else
2318
+ Owner.owned.push(c);
2319
+ }
2320
+ }
2321
+ if (ExternalSourceConfig && c.fn) {
2322
+ const [track, trigger] = createSignal(void 0, {
2323
+ equals: false
2324
+ });
2325
+ const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
2326
+ onCleanup(() => ordinary.dispose());
2327
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
2328
+ const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
2329
+ c.fn = (x) => {
2330
+ track();
2331
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
2332
+ };
2333
+ }
2334
+ return c;
2335
+ }
2336
+ function runTop(node) {
2337
+ const runningTransition = Transition && Transition.running;
2338
+ if ((runningTransition ? node.tState : node.state) === 0)
2339
+ return;
2340
+ if ((runningTransition ? node.tState : node.state) === PENDING)
2341
+ return lookUpstream(node);
2342
+ if (node.suspense && untrack(node.suspense.inFallback))
2343
+ return node.suspense.effects.push(node);
2344
+ const ancestors = [node];
2345
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
2346
+ if (runningTransition && Transition.disposed.has(node))
2347
+ return;
2348
+ if (runningTransition ? node.tState : node.state)
2349
+ ancestors.push(node);
2350
+ }
2351
+ for (let i = ancestors.length - 1; i >= 0; i--) {
2352
+ node = ancestors[i];
2353
+ if (runningTransition) {
2354
+ let top = node, prev = ancestors[i + 1];
2355
+ while ((top = top.owner) && top !== prev) {
2356
+ if (Transition.disposed.has(top))
2357
+ return;
2358
+ }
2359
+ }
2360
+ if ((runningTransition ? node.tState : node.state) === STALE) {
2361
+ updateComputation(node);
2362
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
2363
+ const updates = Updates;
2364
+ Updates = null;
2365
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
2366
+ Updates = updates;
2367
+ }
2368
+ }
2369
+ }
2370
+ function runUpdates(fn, init) {
2371
+ if (Updates)
2372
+ return fn();
2373
+ let wait = false;
2374
+ if (!init)
2375
+ Updates = [];
2376
+ if (Effects)
2377
+ wait = true;
2378
+ else
2379
+ Effects = [];
2380
+ ExecCount++;
2381
+ try {
2382
+ const res = fn();
2383
+ completeUpdates(wait);
2384
+ return res;
2385
+ } catch (err) {
2386
+ if (!wait)
2387
+ Effects = null;
2388
+ Updates = null;
2389
+ handleError(err);
2390
+ }
2391
+ }
2392
+ function completeUpdates(wait) {
2393
+ if (Updates) {
2394
+ if (Scheduler && Transition && Transition.running)
2395
+ scheduleQueue(Updates);
2396
+ else
2397
+ runQueue(Updates);
2398
+ Updates = null;
2399
+ }
2400
+ if (wait)
2401
+ return;
2402
+ let res;
2403
+ if (Transition) {
2404
+ if (!Transition.promises.size && !Transition.queue.size) {
2405
+ const sources = Transition.sources;
2406
+ const disposed = Transition.disposed;
2407
+ Effects.push.apply(Effects, Transition.effects);
2408
+ res = Transition.resolve;
2409
+ for (const e2 of Effects) {
2410
+ "tState" in e2 && (e2.state = e2.tState);
2411
+ delete e2.tState;
2412
+ }
2413
+ Transition = null;
2414
+ runUpdates(() => {
2415
+ for (const d of disposed)
2416
+ cleanNode(d);
2417
+ for (const v of sources) {
2418
+ v.value = v.tValue;
2419
+ if (v.owned) {
2420
+ for (let i = 0, len = v.owned.length; i < len; i++)
2421
+ cleanNode(v.owned[i]);
2422
+ }
2423
+ if (v.tOwned)
2424
+ v.owned = v.tOwned;
2425
+ delete v.tValue;
2426
+ delete v.tOwned;
2427
+ v.tState = 0;
2428
+ }
2429
+ setTransPending(false);
2430
+ }, false);
2431
+ } else if (Transition.running) {
2432
+ Transition.running = false;
2433
+ Transition.effects.push.apply(Transition.effects, Effects);
2434
+ Effects = null;
2435
+ setTransPending(true);
2436
+ return;
2437
+ }
2438
+ }
2439
+ const e = Effects;
2440
+ Effects = null;
2441
+ if (e.length)
2442
+ runUpdates(() => runEffects(e), false);
2443
+ if (res)
2444
+ res();
2445
+ }
2446
+ function runQueue(queue) {
2447
+ for (let i = 0; i < queue.length; i++)
2448
+ runTop(queue[i]);
2449
+ }
2450
+ function scheduleQueue(queue) {
2451
+ for (let i = 0; i < queue.length; i++) {
2452
+ const item = queue[i];
2453
+ const tasks = Transition.queue;
2454
+ if (!tasks.has(item)) {
2455
+ tasks.add(item);
2456
+ Scheduler(() => {
2457
+ tasks.delete(item);
2458
+ runUpdates(() => {
2459
+ Transition.running = true;
2460
+ runTop(item);
2461
+ }, false);
2462
+ Transition && (Transition.running = false);
2463
+ });
2464
+ }
2465
+ }
2466
+ }
2467
+ function runUserEffects(queue) {
2468
+ let i, userLength = 0;
2469
+ for (i = 0; i < queue.length; i++) {
2470
+ const e = queue[i];
2471
+ if (!e.user)
2472
+ runTop(e);
2473
+ else
2474
+ queue[userLength++] = e;
2475
+ }
2476
+ if (sharedConfig.context) {
2477
+ if (sharedConfig.count) {
2478
+ sharedConfig.effects || (sharedConfig.effects = []);
2479
+ sharedConfig.effects.push(...queue.slice(0, userLength));
2480
+ return;
2481
+ } else if (sharedConfig.effects) {
2482
+ queue = [...sharedConfig.effects, ...queue];
2483
+ userLength += sharedConfig.effects.length;
2484
+ delete sharedConfig.effects;
2485
+ }
2486
+ setHydrateContext();
2487
+ }
2488
+ for (i = 0; i < userLength; i++)
2489
+ runTop(queue[i]);
2490
+ }
2491
+ function lookUpstream(node, ignore) {
2492
+ const runningTransition = Transition && Transition.running;
2493
+ if (runningTransition)
2494
+ node.tState = 0;
2495
+ else
2496
+ node.state = 0;
2497
+ for (let i = 0; i < node.sources.length; i += 1) {
2498
+ const source = node.sources[i];
2499
+ if (source.sources) {
2500
+ const state = runningTransition ? source.tState : source.state;
2501
+ if (state === STALE) {
2502
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
2503
+ runTop(source);
2504
+ } else if (state === PENDING)
2505
+ lookUpstream(source, ignore);
2506
+ }
2507
+ }
2508
+ }
2509
+ function markDownstream(node) {
2510
+ const runningTransition = Transition && Transition.running;
2511
+ for (let i = 0; i < node.observers.length; i += 1) {
2512
+ const o = node.observers[i];
2513
+ if (runningTransition ? !o.tState : !o.state) {
2514
+ if (runningTransition)
2515
+ o.tState = PENDING;
2516
+ else
2517
+ o.state = PENDING;
2518
+ if (o.pure)
2519
+ Updates.push(o);
2520
+ else
2521
+ Effects.push(o);
2522
+ o.observers && markDownstream(o);
2523
+ }
2524
+ }
2525
+ }
2526
+ function cleanNode(node) {
2527
+ let i;
2528
+ if (node.sources) {
2529
+ while (node.sources.length) {
2530
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
2531
+ if (obs && obs.length) {
2532
+ const n = obs.pop(), s = source.observerSlots.pop();
2533
+ if (index < obs.length) {
2534
+ n.sourceSlots[s] = index;
2535
+ obs[index] = n;
2536
+ source.observerSlots[index] = s;
2537
+ }
2538
+ }
2539
+ }
2540
+ }
2541
+ if (Transition && Transition.running && node.pure) {
2542
+ if (node.tOwned) {
2543
+ for (i = node.tOwned.length - 1; i >= 0; i--)
2544
+ cleanNode(node.tOwned[i]);
2545
+ delete node.tOwned;
2546
+ }
2547
+ reset(node, true);
2548
+ } else if (node.owned) {
2549
+ for (i = node.owned.length - 1; i >= 0; i--)
2550
+ cleanNode(node.owned[i]);
2551
+ node.owned = null;
2552
+ }
2553
+ if (node.cleanups) {
2554
+ for (i = node.cleanups.length - 1; i >= 0; i--)
2555
+ node.cleanups[i]();
2556
+ node.cleanups = null;
2557
+ }
2558
+ if (Transition && Transition.running)
2559
+ node.tState = 0;
2560
+ else
2561
+ node.state = 0;
2562
+ }
2563
+ function reset(node, top) {
2564
+ if (!top) {
2565
+ node.tState = 0;
2566
+ Transition.disposed.add(node);
2567
+ }
2568
+ if (node.owned) {
2569
+ for (let i = 0; i < node.owned.length; i++)
2570
+ reset(node.owned[i]);
2571
+ }
2572
+ }
2573
+ function castError(err) {
2574
+ if (err instanceof Error)
2575
+ return err;
2576
+ return new Error(typeof err === "string" ? err : "Unknown error", {
2577
+ cause: err
2578
+ });
2579
+ }
2580
+ function runErrors(err, fns, owner) {
2581
+ try {
2582
+ for (const f of fns)
2583
+ f(err);
2584
+ } catch (e) {
2585
+ handleError(e, owner && owner.owner || null);
2586
+ }
2587
+ }
2588
+ function handleError(err, owner = Owner) {
2589
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
2590
+ const error = castError(err);
2591
+ if (!fns)
2592
+ throw error;
2593
+ if (Effects)
2594
+ Effects.push({
2595
+ fn() {
2596
+ runErrors(error, fns, owner);
2597
+ },
2598
+ state: STALE
2599
+ });
2600
+ else
2601
+ runErrors(error, fns, owner);
2602
+ }
2603
+ function resolveChildren(children2) {
2604
+ if (typeof children2 === "function" && !children2.length)
2605
+ return resolveChildren(children2());
2606
+ if (Array.isArray(children2)) {
2607
+ const results = [];
2608
+ for (let i = 0; i < children2.length; i++) {
2609
+ const result = resolveChildren(children2[i]);
2610
+ Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
2611
+ }
2612
+ return results;
2613
+ }
2614
+ return children2;
2615
+ }
2616
+ function createProvider(id, options) {
2617
+ return function provider(props) {
2618
+ let res;
2619
+ createRenderEffect(
2620
+ () => res = untrack(() => {
2621
+ Owner.context = {
2622
+ ...Owner.context,
2623
+ [id]: props.value
2624
+ };
2625
+ return children(() => props.children);
2626
+ }),
2627
+ void 0
2628
+ );
2629
+ return res;
2630
+ };
2631
+ }
2632
+ var hydrationEnabled = false;
2633
+ function createComponent(Comp, props) {
2634
+ if (hydrationEnabled) {
2635
+ if (sharedConfig.context) {
2636
+ const c = sharedConfig.context;
2637
+ setHydrateContext(nextHydrateContext());
2638
+ const r = untrack(() => Comp(props || {}));
2639
+ setHydrateContext(c);
2640
+ return r;
2641
+ }
2642
+ }
2643
+ return untrack(() => Comp(props || {}));
2644
+ }
2645
+
2646
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/web/dist/web.js
2647
+ var booleans = [
2648
+ "allowfullscreen",
2649
+ "async",
2650
+ "autofocus",
2651
+ "autoplay",
2652
+ "checked",
2653
+ "controls",
2654
+ "default",
2655
+ "disabled",
2656
+ "formnovalidate",
2657
+ "hidden",
2658
+ "indeterminate",
2659
+ "inert",
2660
+ "ismap",
2661
+ "loop",
2662
+ "multiple",
2663
+ "muted",
2664
+ "nomodule",
2665
+ "novalidate",
2666
+ "open",
2667
+ "playsinline",
2668
+ "readonly",
2669
+ "required",
2670
+ "reversed",
2671
+ "seamless",
2672
+ "selected"
2673
+ ];
2674
+ /* @__PURE__ */ new Set([
2675
+ "className",
2676
+ "value",
2677
+ "readOnly",
2678
+ "formNoValidate",
2679
+ "isMap",
2680
+ "noModule",
2681
+ "playsInline",
2682
+ ...booleans
2683
+ ]);
2684
+
2685
+ // src/WalletProvider.tsx
2686
+ var WalletContext = createContext();
2687
+ var WalletProvider = (props) => {
2688
+ const store = () => props.manager;
2689
+ onMount(async () => {
2690
+ try {
2691
+ await props.manager.resumeSessions();
2692
+ } catch (error) {
2693
+ }
2694
+ });
2695
+ return createComponent(WalletContext.Provider, {
2696
+ value: store,
2697
+ get children() {
2698
+ return props.children;
2699
+ }
2700
+ });
2701
+ };
2702
+ var useWalletManager = () => {
2703
+ const manager = useContext(WalletContext);
2704
+ if (!manager) {
2705
+ throw new Error("useWalletManager must be used within a WalletProvider");
2706
+ }
2707
+ return manager();
2708
+ };
2709
+
2710
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/store/dist/store.js
2711
+ var $RAW = Symbol("store-raw");
2712
+ var $NODE = Symbol("store-node");
2713
+ var $HAS = Symbol("store-has");
2714
+ var $SELF = Symbol("store-self");
2715
+ function wrap$1(value) {
2716
+ let p = value[$PROXY];
2717
+ if (!p) {
2718
+ Object.defineProperty(value, $PROXY, {
2719
+ value: p = new Proxy(value, proxyTraps$1)
2720
+ });
2721
+ if (!Array.isArray(value)) {
2722
+ const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
2723
+ for (let i = 0, l = keys.length; i < l; i++) {
2724
+ const prop = keys[i];
2725
+ if (desc[prop].get) {
2726
+ Object.defineProperty(value, prop, {
2727
+ enumerable: desc[prop].enumerable,
2728
+ get: desc[prop].get.bind(p)
2729
+ });
2730
+ }
2731
+ }
2732
+ }
2733
+ }
2734
+ return p;
2735
+ }
2736
+ function isWrappable(obj) {
2737
+ let proto;
2738
+ return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
2739
+ }
2740
+ function unwrap(item, set = /* @__PURE__ */ new Set()) {
2741
+ let result, unwrapped, v, prop;
2742
+ if (result = item != null && item[$RAW])
2743
+ return result;
2744
+ if (!isWrappable(item) || set.has(item))
2745
+ return item;
2746
+ if (Array.isArray(item)) {
2747
+ if (Object.isFrozen(item))
2748
+ item = item.slice(0);
2749
+ else
2750
+ set.add(item);
2751
+ for (let i = 0, l = item.length; i < l; i++) {
2752
+ v = item[i];
2753
+ if ((unwrapped = unwrap(v, set)) !== v)
2754
+ item[i] = unwrapped;
2755
+ }
2756
+ } else {
2757
+ if (Object.isFrozen(item))
2758
+ item = Object.assign({}, item);
2759
+ else
2760
+ set.add(item);
2761
+ const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
2762
+ for (let i = 0, l = keys.length; i < l; i++) {
2763
+ prop = keys[i];
2764
+ if (desc[prop].get)
2765
+ continue;
2766
+ v = item[prop];
2767
+ if ((unwrapped = unwrap(v, set)) !== v)
2768
+ item[prop] = unwrapped;
2769
+ }
2770
+ }
2771
+ return item;
2772
+ }
2773
+ function getNodes(target, symbol) {
2774
+ let nodes = target[symbol];
2775
+ if (!nodes)
2776
+ Object.defineProperty(target, symbol, {
2777
+ value: nodes = /* @__PURE__ */ Object.create(null)
2778
+ });
2779
+ return nodes;
2780
+ }
2781
+ function getNode(nodes, property, value) {
2782
+ if (nodes[property])
2783
+ return nodes[property];
2784
+ const [s, set] = createSignal(value, {
2785
+ equals: false,
2786
+ internal: true
2787
+ });
2788
+ s.$ = set;
2789
+ return nodes[property] = s;
2790
+ }
2791
+ function proxyDescriptor$1(target, property) {
2792
+ const desc = Reflect.getOwnPropertyDescriptor(target, property);
2793
+ if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
2794
+ return desc;
2795
+ delete desc.value;
2796
+ delete desc.writable;
2797
+ desc.get = () => target[$PROXY][property];
2798
+ return desc;
2799
+ }
2800
+ function trackSelf(target) {
2801
+ getListener() && getNode(getNodes(target, $NODE), $SELF)();
2802
+ }
2803
+ function ownKeys(target) {
2804
+ trackSelf(target);
2805
+ return Reflect.ownKeys(target);
2806
+ }
2807
+ var proxyTraps$1 = {
2808
+ get(target, property, receiver) {
2809
+ if (property === $RAW)
2810
+ return target;
2811
+ if (property === $PROXY)
2812
+ return receiver;
2813
+ if (property === $TRACK) {
2814
+ trackSelf(target);
2815
+ return receiver;
2816
+ }
2817
+ const nodes = getNodes(target, $NODE);
2818
+ const tracked = nodes[property];
2819
+ let value = tracked ? tracked() : target[property];
2820
+ if (property === $NODE || property === $HAS || property === "__proto__")
2821
+ return value;
2822
+ if (!tracked) {
2823
+ const desc = Object.getOwnPropertyDescriptor(target, property);
2824
+ if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get))
2825
+ value = getNode(nodes, property, value)();
2826
+ }
2827
+ return isWrappable(value) ? wrap$1(value) : value;
2828
+ },
2829
+ has(target, property) {
2830
+ if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__")
2831
+ return true;
2832
+ getListener() && getNode(getNodes(target, $HAS), property)();
2833
+ return property in target;
2834
+ },
2835
+ set() {
2836
+ return true;
2837
+ },
2838
+ deleteProperty() {
2839
+ return true;
2840
+ },
2841
+ ownKeys,
2842
+ getOwnPropertyDescriptor: proxyDescriptor$1
2843
+ };
2844
+ function setProperty(state, property, value, deleting = false) {
2845
+ if (!deleting && state[property] === value)
2846
+ return;
2847
+ const prev = state[property], len = state.length;
2848
+ if (value === void 0) {
2849
+ delete state[property];
2850
+ if (state[$HAS] && state[$HAS][property] && prev !== void 0)
2851
+ state[$HAS][property].$();
2852
+ } else {
2853
+ state[property] = value;
2854
+ if (state[$HAS] && state[$HAS][property] && prev === void 0)
2855
+ state[$HAS][property].$();
2856
+ }
2857
+ let nodes = getNodes(state, $NODE), node;
2858
+ if (node = getNode(nodes, property, prev))
2859
+ node.$(() => value);
2860
+ if (Array.isArray(state) && state.length !== len) {
2861
+ for (let i = state.length; i < len; i++)
2862
+ (node = nodes[i]) && node.$();
2863
+ (node = getNode(nodes, "length", len)) && node.$(state.length);
2864
+ }
2865
+ (node = nodes[$SELF]) && node.$();
2866
+ }
2867
+ function mergeStoreNode(state, value) {
2868
+ const keys = Object.keys(value);
2869
+ for (let i = 0; i < keys.length; i += 1) {
2870
+ const key = keys[i];
2871
+ setProperty(state, key, value[key]);
2872
+ }
2873
+ }
2874
+ function updateArray(current, next) {
2875
+ if (typeof next === "function")
2876
+ next = next(current);
2877
+ next = unwrap(next);
2878
+ if (Array.isArray(next)) {
2879
+ if (current === next)
2880
+ return;
2881
+ let i = 0, len = next.length;
2882
+ for (; i < len; i++) {
2883
+ const value = next[i];
2884
+ if (current[i] !== value)
2885
+ setProperty(current, i, value);
2886
+ }
2887
+ setProperty(current, "length", len);
2888
+ } else
2889
+ mergeStoreNode(current, next);
2890
+ }
2891
+ function updatePath(current, path, traversed = []) {
2892
+ let part, prev = current;
2893
+ if (path.length > 1) {
2894
+ part = path.shift();
2895
+ const partType = typeof part, isArray = Array.isArray(current);
2896
+ if (Array.isArray(part)) {
2897
+ for (let i = 0; i < part.length; i++) {
2898
+ updatePath(current, [part[i]].concat(path), traversed);
2899
+ }
2900
+ return;
2901
+ } else if (isArray && partType === "function") {
2902
+ for (let i = 0; i < current.length; i++) {
2903
+ if (part(current[i], i))
2904
+ updatePath(current, [i].concat(path), traversed);
2905
+ }
2906
+ return;
2907
+ } else if (isArray && partType === "object") {
2908
+ const { from = 0, to = current.length - 1, by = 1 } = part;
2909
+ for (let i = from; i <= to; i += by) {
2910
+ updatePath(current, [i].concat(path), traversed);
2911
+ }
2912
+ return;
2913
+ } else if (path.length > 1) {
2914
+ updatePath(current[part], path, [part].concat(traversed));
2915
+ return;
2916
+ }
2917
+ prev = current[part];
2918
+ traversed = [part].concat(traversed);
2919
+ }
2920
+ let value = path[0];
2921
+ if (typeof value === "function") {
2922
+ value = value(prev, traversed);
2923
+ if (value === prev)
2924
+ return;
2925
+ }
2926
+ if (part === void 0 && value == void 0)
2927
+ return;
2928
+ value = unwrap(value);
2929
+ if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
2930
+ mergeStoreNode(prev, value);
2931
+ } else
2932
+ setProperty(current, part, value);
2933
+ }
2934
+ function createStore(...[store, options]) {
2935
+ const unwrappedStore = unwrap(store || {});
2936
+ const isArray = Array.isArray(unwrappedStore);
2937
+ const wrappedStore = wrap$1(unwrappedStore);
2938
+ function setStore(...args) {
2939
+ batch(() => {
2940
+ isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
2941
+ });
2942
+ }
2943
+ return [wrappedStore, setStore];
2944
+ }
2945
+ var $ROOT = Symbol("store-root");
2946
+ function applyState(target, parent, property, merge, key) {
2947
+ const previous = parent[property];
2948
+ if (target === previous)
2949
+ return;
2950
+ const isArray = Array.isArray(target);
2951
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {
2952
+ setProperty(parent, property, target);
2953
+ return;
2954
+ }
2955
+ if (isArray) {
2956
+ if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {
2957
+ let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
2958
+ 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++) {
2959
+ applyState(target[start], previous, start, merge, key);
2960
+ }
2961
+ const temp = new Array(target.length), newIndices = /* @__PURE__ */ new Map();
2962
+ 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--) {
2963
+ temp[newEnd] = previous[end];
2964
+ }
2965
+ if (start > newEnd || start > end) {
2966
+ for (j = start; j <= newEnd; j++)
2967
+ setProperty(previous, j, target[j]);
2968
+ for (; j < target.length; j++) {
2969
+ setProperty(previous, j, temp[j]);
2970
+ applyState(target[j], previous, j, merge, key);
2971
+ }
2972
+ if (previous.length > target.length)
2973
+ setProperty(previous, "length", target.length);
2974
+ return;
2975
+ }
2976
+ newIndicesNext = new Array(newEnd + 1);
2977
+ for (j = newEnd; j >= start; j--) {
2978
+ item = target[j];
2979
+ keyVal = key && item ? item[key] : item;
2980
+ i = newIndices.get(keyVal);
2981
+ newIndicesNext[j] = i === void 0 ? -1 : i;
2982
+ newIndices.set(keyVal, j);
2983
+ }
2984
+ for (i = start; i <= end; i++) {
2985
+ item = previous[i];
2986
+ keyVal = key && item ? item[key] : item;
2987
+ j = newIndices.get(keyVal);
2988
+ if (j !== void 0 && j !== -1) {
2989
+ temp[j] = previous[i];
2990
+ j = newIndicesNext[j];
2991
+ newIndices.set(keyVal, j);
2992
+ }
2993
+ }
2994
+ for (j = start; j < target.length; j++) {
2995
+ if (j in temp) {
2996
+ setProperty(previous, j, temp[j]);
2997
+ applyState(target[j], previous, j, merge, key);
2998
+ } else
2999
+ setProperty(previous, j, target[j]);
3000
+ }
3001
+ } else {
3002
+ for (let i = 0, len = target.length; i < len; i++) {
3003
+ applyState(target[i], previous, i, merge, key);
3004
+ }
3005
+ }
3006
+ if (previous.length > target.length)
3007
+ setProperty(previous, "length", target.length);
3008
+ return;
3009
+ }
3010
+ const targetKeys = Object.keys(target);
3011
+ for (let i = 0, len = targetKeys.length; i < len; i++) {
3012
+ applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);
3013
+ }
3014
+ const previousKeys = Object.keys(previous);
3015
+ for (let i = 0, len = previousKeys.length; i < len; i++) {
3016
+ if (target[previousKeys[i]] === void 0)
3017
+ setProperty(previous, previousKeys[i], void 0);
3018
+ }
3019
+ }
3020
+ function reconcile(value, options = {}) {
3021
+ const { merge, key = "id" } = options, v = unwrap(value);
3022
+ return (state) => {
3023
+ if (!isWrappable(state) || !isWrappable(v))
3024
+ return v;
3025
+ const res = applyState(
3026
+ v,
3027
+ {
3028
+ [$ROOT]: state
3029
+ },
3030
+ $ROOT,
3031
+ merge,
3032
+ key
3033
+ );
3034
+ return res === void 0 ? state : res;
3035
+ };
3036
+ }
3037
+
3038
+ // ../../node_modules/.pnpm/@tanstack+solid-store@0.3.1_solid-js@1.8.16/node_modules/@tanstack/solid-store/dist/esm/index.js
3039
+ function useStore(store, selector = (d) => d) {
3040
+ const [slice, setSlice] = createStore({
3041
+ value: selector(store.state)
3042
+ });
3043
+ const unsub = store.subscribe(() => {
3044
+ const newValue = selector(store.state);
3045
+ setSlice("value", reconcile(newValue));
3046
+ });
3047
+ onCleanup(() => {
3048
+ unsub();
3049
+ });
3050
+ return () => slice.value;
3051
+ }
3052
+
3053
+ // src/useWallet.ts
3054
+ function useWallet() {
3055
+ const manager = createMemo(() => useWalletManager());
3056
+ const walletStore = useStore(manager().store, (state) => {
3057
+ return state.wallets;
3058
+ });
3059
+ const walletState = (walletId) => walletStore()[walletId] || null;
3060
+ const activeWalletId = useStore(manager().store, (state) => {
3061
+ return state.activeWallet;
3062
+ });
3063
+ const activeWallet = () => manager().getWallet(activeWalletId()) || null;
3064
+ const activeWalletState = () => walletState(activeWalletId());
3065
+ const activeWalletAccounts = () => activeWalletState()?.accounts ?? null;
3066
+ const activeWalletAddresses = () => activeWalletAccounts()?.map((account) => account.address) ?? null;
3067
+ const activeAccount = () => activeWalletState()?.activeAccount ?? null;
3068
+ const activeAddress = () => activeAccount()?.address ?? null;
3069
+ const isWalletActive = (walletId) => walletId === activeWalletId();
3070
+ const isWalletConnected = (walletId) => !!walletState(walletId)?.accounts.length || false;
3071
+ const activeNetworkState = createMemo(() => {
3072
+ return useStore(manager().store, (state) => state.activeNetwork);
3073
+ });
3074
+ const activeNetwork = () => activeNetworkState()();
3075
+ const setActiveNetwork2 = (network) => manager().setActiveNetwork(network);
3076
+ const algodClient = createMemo(() => manager().algodClient);
3077
+ const signTransactions = (txnGroup, indexesToSign, returnGroup) => {
3078
+ if (!activeWallet) {
3079
+ throw new Error("No active wallet");
3080
+ }
3081
+ return activeWallet()?.signTransactions(txnGroup, indexesToSign, returnGroup);
3082
+ };
3083
+ const transactionSigner = (txnGroup, indexesToSign) => {
3084
+ if (!activeWallet) {
3085
+ throw new Error("No active wallet");
3086
+ }
3087
+ return activeWallet()?.transactionSigner(txnGroup, indexesToSign);
3088
+ };
3089
+ return {
3090
+ activeWalletId,
3091
+ walletStore,
3092
+ algodClient,
3093
+ activeNetwork,
3094
+ activeWallet,
3095
+ activeWalletAccounts,
3096
+ activeWalletAddresses,
3097
+ activeWalletState,
3098
+ activeAccount,
3099
+ activeAddress,
3100
+ isWalletActive,
3101
+ isWalletConnected,
3102
+ setActiveNetwork: setActiveNetwork2,
3103
+ signTransactions,
3104
+ transactionSigner,
3105
+ wallets: manager().wallets
3106
+ };
3107
+ }
3108
+
3109
+ export { BaseWallet, DeflyWallet, ExodusWallet, KmdWallet, MnemonicWallet, NetworkId, PeraWallet, StorageAdapter, WalletConnect, WalletId, WalletManager, WalletProvider, defaultState, useWallet };