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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.cjs ADDED
@@ -0,0 +1,786 @@
1
+ 'use strict';
2
+
3
+ var useWallet$1 = require('@txnlab/use-wallet');
4
+ var solidStore = require('@tanstack/solid-store');
5
+
6
+ // src/index.tsx
7
+
8
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/dist/solid.js
9
+ var sharedConfig = {
10
+ context: void 0,
11
+ registry: void 0
12
+ };
13
+ function setHydrateContext(context) {
14
+ sharedConfig.context = context;
15
+ }
16
+ function nextHydrateContext() {
17
+ return {
18
+ ...sharedConfig.context,
19
+ id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
20
+ count: 0
21
+ };
22
+ }
23
+ var equalFn = (a, b) => a === b;
24
+ var signalOptions = {
25
+ equals: equalFn
26
+ };
27
+ var ERROR = null;
28
+ var runEffects = runQueue;
29
+ var STALE = 1;
30
+ var PENDING = 2;
31
+ var UNOWNED = {
32
+ owned: null,
33
+ cleanups: null,
34
+ context: null,
35
+ owner: null
36
+ };
37
+ var Owner = null;
38
+ var Transition = null;
39
+ var Scheduler = null;
40
+ var ExternalSourceConfig = null;
41
+ var Listener = null;
42
+ var Updates = null;
43
+ var Effects = null;
44
+ var ExecCount = 0;
45
+ function createSignal(value, options) {
46
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
47
+ const s = {
48
+ value,
49
+ observers: null,
50
+ observerSlots: null,
51
+ comparator: options.equals || void 0
52
+ };
53
+ const setter = (value2) => {
54
+ if (typeof value2 === "function") {
55
+ if (Transition && Transition.running && Transition.sources.has(s))
56
+ value2 = value2(s.tValue);
57
+ else
58
+ value2 = value2(s.value);
59
+ }
60
+ return writeSignal(s, value2);
61
+ };
62
+ return [readSignal.bind(s), setter];
63
+ }
64
+ function createRenderEffect(fn, value, options) {
65
+ const c = createComputation(fn, value, false, STALE);
66
+ if (Scheduler && Transition && Transition.running)
67
+ Updates.push(c);
68
+ else
69
+ updateComputation(c);
70
+ }
71
+ function createEffect(fn, value, options) {
72
+ runEffects = runUserEffects;
73
+ const c = createComputation(fn, value, false, STALE), s = SuspenseContext && useContext(SuspenseContext);
74
+ if (s)
75
+ c.suspense = s;
76
+ if (!options || !options.render)
77
+ c.user = true;
78
+ Effects ? Effects.push(c) : updateComputation(c);
79
+ }
80
+ function createMemo(fn, value, options) {
81
+ options = options ? Object.assign({}, signalOptions, options) : signalOptions;
82
+ const c = createComputation(fn, value, true, 0);
83
+ c.observers = null;
84
+ c.observerSlots = null;
85
+ c.comparator = options.equals || void 0;
86
+ if (Scheduler && Transition && Transition.running) {
87
+ c.tState = STALE;
88
+ Updates.push(c);
89
+ } else
90
+ updateComputation(c);
91
+ return readSignal.bind(c);
92
+ }
93
+ function untrack(fn) {
94
+ if (!ExternalSourceConfig && Listener === null)
95
+ return fn();
96
+ const listener = Listener;
97
+ Listener = null;
98
+ try {
99
+ if (ExternalSourceConfig)
100
+ return ExternalSourceConfig.untrack(fn);
101
+ return fn();
102
+ } finally {
103
+ Listener = listener;
104
+ }
105
+ }
106
+ function onMount(fn) {
107
+ createEffect(() => untrack(fn));
108
+ }
109
+ function onCleanup(fn) {
110
+ if (Owner === null)
111
+ ;
112
+ else if (Owner.cleanups === null)
113
+ Owner.cleanups = [fn];
114
+ else
115
+ Owner.cleanups.push(fn);
116
+ return fn;
117
+ }
118
+ function startTransition(fn) {
119
+ if (Transition && Transition.running) {
120
+ fn();
121
+ return Transition.done;
122
+ }
123
+ const l = Listener;
124
+ const o = Owner;
125
+ return Promise.resolve().then(() => {
126
+ Listener = l;
127
+ Owner = o;
128
+ let t;
129
+ if (Scheduler || SuspenseContext) {
130
+ t = Transition || (Transition = {
131
+ sources: /* @__PURE__ */ new Set(),
132
+ effects: [],
133
+ promises: /* @__PURE__ */ new Set(),
134
+ disposed: /* @__PURE__ */ new Set(),
135
+ queue: /* @__PURE__ */ new Set(),
136
+ running: true
137
+ });
138
+ t.done || (t.done = new Promise((res) => t.resolve = res));
139
+ t.running = true;
140
+ }
141
+ runUpdates(fn, false);
142
+ Listener = Owner = null;
143
+ return t ? t.done : void 0;
144
+ });
145
+ }
146
+ var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false);
147
+ function createContext(defaultValue, options) {
148
+ const id = Symbol("context");
149
+ return {
150
+ id,
151
+ Provider: createProvider(id),
152
+ defaultValue
153
+ };
154
+ }
155
+ function useContext(context) {
156
+ return Owner && Owner.context && Owner.context[context.id] !== void 0 ? Owner.context[context.id] : context.defaultValue;
157
+ }
158
+ function children(fn) {
159
+ const children2 = createMemo(fn);
160
+ const memo = createMemo(() => resolveChildren(children2()));
161
+ memo.toArray = () => {
162
+ const c = memo();
163
+ return Array.isArray(c) ? c : c != null ? [c] : [];
164
+ };
165
+ return memo;
166
+ }
167
+ var SuspenseContext;
168
+ function readSignal() {
169
+ const runningTransition = Transition && Transition.running;
170
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
171
+ if ((runningTransition ? this.tState : this.state) === STALE)
172
+ updateComputation(this);
173
+ else {
174
+ const updates = Updates;
175
+ Updates = null;
176
+ runUpdates(() => lookUpstream(this), false);
177
+ Updates = updates;
178
+ }
179
+ }
180
+ if (Listener) {
181
+ const sSlot = this.observers ? this.observers.length : 0;
182
+ if (!Listener.sources) {
183
+ Listener.sources = [this];
184
+ Listener.sourceSlots = [sSlot];
185
+ } else {
186
+ Listener.sources.push(this);
187
+ Listener.sourceSlots.push(sSlot);
188
+ }
189
+ if (!this.observers) {
190
+ this.observers = [Listener];
191
+ this.observerSlots = [Listener.sources.length - 1];
192
+ } else {
193
+ this.observers.push(Listener);
194
+ this.observerSlots.push(Listener.sources.length - 1);
195
+ }
196
+ }
197
+ if (runningTransition && Transition.sources.has(this))
198
+ return this.tValue;
199
+ return this.value;
200
+ }
201
+ function writeSignal(node, value, isComp) {
202
+ let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
203
+ if (!node.comparator || !node.comparator(current, value)) {
204
+ if (Transition) {
205
+ const TransitionRunning = Transition.running;
206
+ if (TransitionRunning || !isComp && Transition.sources.has(node)) {
207
+ Transition.sources.add(node);
208
+ node.tValue = value;
209
+ }
210
+ if (!TransitionRunning)
211
+ node.value = value;
212
+ } else
213
+ node.value = value;
214
+ if (node.observers && node.observers.length) {
215
+ runUpdates(() => {
216
+ for (let i = 0; i < node.observers.length; i += 1) {
217
+ const o = node.observers[i];
218
+ const TransitionRunning = Transition && Transition.running;
219
+ if (TransitionRunning && Transition.disposed.has(o))
220
+ continue;
221
+ if (TransitionRunning ? !o.tState : !o.state) {
222
+ if (o.pure)
223
+ Updates.push(o);
224
+ else
225
+ Effects.push(o);
226
+ if (o.observers)
227
+ markDownstream(o);
228
+ }
229
+ if (!TransitionRunning)
230
+ o.state = STALE;
231
+ else
232
+ o.tState = STALE;
233
+ }
234
+ if (Updates.length > 1e6) {
235
+ Updates = [];
236
+ if (false)
237
+ ;
238
+ throw new Error();
239
+ }
240
+ }, false);
241
+ }
242
+ }
243
+ return value;
244
+ }
245
+ function updateComputation(node) {
246
+ if (!node.fn)
247
+ return;
248
+ cleanNode(node);
249
+ const time = ExecCount;
250
+ runComputation(
251
+ node,
252
+ Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
253
+ time
254
+ );
255
+ if (Transition && !Transition.running && Transition.sources.has(node)) {
256
+ queueMicrotask(() => {
257
+ runUpdates(() => {
258
+ Transition && (Transition.running = true);
259
+ Listener = Owner = node;
260
+ runComputation(node, node.tValue, time);
261
+ Listener = Owner = null;
262
+ }, false);
263
+ });
264
+ }
265
+ }
266
+ function runComputation(node, value, time) {
267
+ let nextValue;
268
+ const owner = Owner, listener = Listener;
269
+ Listener = Owner = node;
270
+ try {
271
+ nextValue = node.fn(value);
272
+ } catch (err) {
273
+ if (node.pure) {
274
+ if (Transition && Transition.running) {
275
+ node.tState = STALE;
276
+ node.tOwned && node.tOwned.forEach(cleanNode);
277
+ node.tOwned = void 0;
278
+ } else {
279
+ node.state = STALE;
280
+ node.owned && node.owned.forEach(cleanNode);
281
+ node.owned = null;
282
+ }
283
+ }
284
+ node.updatedAt = time + 1;
285
+ return handleError(err);
286
+ } finally {
287
+ Listener = listener;
288
+ Owner = owner;
289
+ }
290
+ if (!node.updatedAt || node.updatedAt <= time) {
291
+ if (node.updatedAt != null && "observers" in node) {
292
+ writeSignal(node, nextValue, true);
293
+ } else if (Transition && Transition.running && node.pure) {
294
+ Transition.sources.add(node);
295
+ node.tValue = nextValue;
296
+ } else
297
+ node.value = nextValue;
298
+ node.updatedAt = time;
299
+ }
300
+ }
301
+ function createComputation(fn, init, pure, state = STALE, options) {
302
+ const c = {
303
+ fn,
304
+ state,
305
+ updatedAt: null,
306
+ owned: null,
307
+ sources: null,
308
+ sourceSlots: null,
309
+ cleanups: null,
310
+ value: init,
311
+ owner: Owner,
312
+ context: Owner ? Owner.context : null,
313
+ pure
314
+ };
315
+ if (Transition && Transition.running) {
316
+ c.state = 0;
317
+ c.tState = state;
318
+ }
319
+ if (Owner === null)
320
+ ;
321
+ else if (Owner !== UNOWNED) {
322
+ if (Transition && Transition.running && Owner.pure) {
323
+ if (!Owner.tOwned)
324
+ Owner.tOwned = [c];
325
+ else
326
+ Owner.tOwned.push(c);
327
+ } else {
328
+ if (!Owner.owned)
329
+ Owner.owned = [c];
330
+ else
331
+ Owner.owned.push(c);
332
+ }
333
+ }
334
+ if (ExternalSourceConfig && c.fn) {
335
+ const [track, trigger] = createSignal(void 0, {
336
+ equals: false
337
+ });
338
+ const ordinary = ExternalSourceConfig.factory(c.fn, trigger);
339
+ onCleanup(() => ordinary.dispose());
340
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
341
+ const inTransition = ExternalSourceConfig.factory(c.fn, triggerInTransition);
342
+ c.fn = (x) => {
343
+ track();
344
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
345
+ };
346
+ }
347
+ return c;
348
+ }
349
+ function runTop(node) {
350
+ const runningTransition = Transition && Transition.running;
351
+ if ((runningTransition ? node.tState : node.state) === 0)
352
+ return;
353
+ if ((runningTransition ? node.tState : node.state) === PENDING)
354
+ return lookUpstream(node);
355
+ if (node.suspense && untrack(node.suspense.inFallback))
356
+ return node.suspense.effects.push(node);
357
+ const ancestors = [node];
358
+ while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
359
+ if (runningTransition && Transition.disposed.has(node))
360
+ return;
361
+ if (runningTransition ? node.tState : node.state)
362
+ ancestors.push(node);
363
+ }
364
+ for (let i = ancestors.length - 1; i >= 0; i--) {
365
+ node = ancestors[i];
366
+ if (runningTransition) {
367
+ let top = node, prev = ancestors[i + 1];
368
+ while ((top = top.owner) && top !== prev) {
369
+ if (Transition.disposed.has(top))
370
+ return;
371
+ }
372
+ }
373
+ if ((runningTransition ? node.tState : node.state) === STALE) {
374
+ updateComputation(node);
375
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
376
+ const updates = Updates;
377
+ Updates = null;
378
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
379
+ Updates = updates;
380
+ }
381
+ }
382
+ }
383
+ function runUpdates(fn, init) {
384
+ if (Updates)
385
+ return fn();
386
+ let wait = false;
387
+ if (!init)
388
+ Updates = [];
389
+ if (Effects)
390
+ wait = true;
391
+ else
392
+ Effects = [];
393
+ ExecCount++;
394
+ try {
395
+ const res = fn();
396
+ completeUpdates(wait);
397
+ return res;
398
+ } catch (err) {
399
+ if (!wait)
400
+ Effects = null;
401
+ Updates = null;
402
+ handleError(err);
403
+ }
404
+ }
405
+ function completeUpdates(wait) {
406
+ if (Updates) {
407
+ if (Scheduler && Transition && Transition.running)
408
+ scheduleQueue(Updates);
409
+ else
410
+ runQueue(Updates);
411
+ Updates = null;
412
+ }
413
+ if (wait)
414
+ return;
415
+ let res;
416
+ if (Transition) {
417
+ if (!Transition.promises.size && !Transition.queue.size) {
418
+ const sources = Transition.sources;
419
+ const disposed = Transition.disposed;
420
+ Effects.push.apply(Effects, Transition.effects);
421
+ res = Transition.resolve;
422
+ for (const e2 of Effects) {
423
+ "tState" in e2 && (e2.state = e2.tState);
424
+ delete e2.tState;
425
+ }
426
+ Transition = null;
427
+ runUpdates(() => {
428
+ for (const d of disposed)
429
+ cleanNode(d);
430
+ for (const v of sources) {
431
+ v.value = v.tValue;
432
+ if (v.owned) {
433
+ for (let i = 0, len = v.owned.length; i < len; i++)
434
+ cleanNode(v.owned[i]);
435
+ }
436
+ if (v.tOwned)
437
+ v.owned = v.tOwned;
438
+ delete v.tValue;
439
+ delete v.tOwned;
440
+ v.tState = 0;
441
+ }
442
+ setTransPending(false);
443
+ }, false);
444
+ } else if (Transition.running) {
445
+ Transition.running = false;
446
+ Transition.effects.push.apply(Transition.effects, Effects);
447
+ Effects = null;
448
+ setTransPending(true);
449
+ return;
450
+ }
451
+ }
452
+ const e = Effects;
453
+ Effects = null;
454
+ if (e.length)
455
+ runUpdates(() => runEffects(e), false);
456
+ if (res)
457
+ res();
458
+ }
459
+ function runQueue(queue) {
460
+ for (let i = 0; i < queue.length; i++)
461
+ runTop(queue[i]);
462
+ }
463
+ function scheduleQueue(queue) {
464
+ for (let i = 0; i < queue.length; i++) {
465
+ const item = queue[i];
466
+ const tasks = Transition.queue;
467
+ if (!tasks.has(item)) {
468
+ tasks.add(item);
469
+ Scheduler(() => {
470
+ tasks.delete(item);
471
+ runUpdates(() => {
472
+ Transition.running = true;
473
+ runTop(item);
474
+ }, false);
475
+ Transition && (Transition.running = false);
476
+ });
477
+ }
478
+ }
479
+ }
480
+ function runUserEffects(queue) {
481
+ let i, userLength = 0;
482
+ for (i = 0; i < queue.length; i++) {
483
+ const e = queue[i];
484
+ if (!e.user)
485
+ runTop(e);
486
+ else
487
+ queue[userLength++] = e;
488
+ }
489
+ if (sharedConfig.context) {
490
+ if (sharedConfig.count) {
491
+ sharedConfig.effects || (sharedConfig.effects = []);
492
+ sharedConfig.effects.push(...queue.slice(0, userLength));
493
+ return;
494
+ } else if (sharedConfig.effects) {
495
+ queue = [...sharedConfig.effects, ...queue];
496
+ userLength += sharedConfig.effects.length;
497
+ delete sharedConfig.effects;
498
+ }
499
+ setHydrateContext();
500
+ }
501
+ for (i = 0; i < userLength; i++)
502
+ runTop(queue[i]);
503
+ }
504
+ function lookUpstream(node, ignore) {
505
+ const runningTransition = Transition && Transition.running;
506
+ if (runningTransition)
507
+ node.tState = 0;
508
+ else
509
+ node.state = 0;
510
+ for (let i = 0; i < node.sources.length; i += 1) {
511
+ const source = node.sources[i];
512
+ if (source.sources) {
513
+ const state = runningTransition ? source.tState : source.state;
514
+ if (state === STALE) {
515
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
516
+ runTop(source);
517
+ } else if (state === PENDING)
518
+ lookUpstream(source, ignore);
519
+ }
520
+ }
521
+ }
522
+ function markDownstream(node) {
523
+ const runningTransition = Transition && Transition.running;
524
+ for (let i = 0; i < node.observers.length; i += 1) {
525
+ const o = node.observers[i];
526
+ if (runningTransition ? !o.tState : !o.state) {
527
+ if (runningTransition)
528
+ o.tState = PENDING;
529
+ else
530
+ o.state = PENDING;
531
+ if (o.pure)
532
+ Updates.push(o);
533
+ else
534
+ Effects.push(o);
535
+ o.observers && markDownstream(o);
536
+ }
537
+ }
538
+ }
539
+ function cleanNode(node) {
540
+ let i;
541
+ if (node.sources) {
542
+ while (node.sources.length) {
543
+ const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
544
+ if (obs && obs.length) {
545
+ const n = obs.pop(), s = source.observerSlots.pop();
546
+ if (index < obs.length) {
547
+ n.sourceSlots[s] = index;
548
+ obs[index] = n;
549
+ source.observerSlots[index] = s;
550
+ }
551
+ }
552
+ }
553
+ }
554
+ if (Transition && Transition.running && node.pure) {
555
+ if (node.tOwned) {
556
+ for (i = node.tOwned.length - 1; i >= 0; i--)
557
+ cleanNode(node.tOwned[i]);
558
+ delete node.tOwned;
559
+ }
560
+ reset(node, true);
561
+ } else if (node.owned) {
562
+ for (i = node.owned.length - 1; i >= 0; i--)
563
+ cleanNode(node.owned[i]);
564
+ node.owned = null;
565
+ }
566
+ if (node.cleanups) {
567
+ for (i = node.cleanups.length - 1; i >= 0; i--)
568
+ node.cleanups[i]();
569
+ node.cleanups = null;
570
+ }
571
+ if (Transition && Transition.running)
572
+ node.tState = 0;
573
+ else
574
+ node.state = 0;
575
+ }
576
+ function reset(node, top) {
577
+ if (!top) {
578
+ node.tState = 0;
579
+ Transition.disposed.add(node);
580
+ }
581
+ if (node.owned) {
582
+ for (let i = 0; i < node.owned.length; i++)
583
+ reset(node.owned[i]);
584
+ }
585
+ }
586
+ function castError(err) {
587
+ if (err instanceof Error)
588
+ return err;
589
+ return new Error(typeof err === "string" ? err : "Unknown error", {
590
+ cause: err
591
+ });
592
+ }
593
+ function runErrors(err, fns, owner) {
594
+ try {
595
+ for (const f of fns)
596
+ f(err);
597
+ } catch (e) {
598
+ handleError(e, owner && owner.owner || null);
599
+ }
600
+ }
601
+ function handleError(err, owner = Owner) {
602
+ const fns = ERROR && owner && owner.context && owner.context[ERROR];
603
+ const error = castError(err);
604
+ if (!fns)
605
+ throw error;
606
+ if (Effects)
607
+ Effects.push({
608
+ fn() {
609
+ runErrors(error, fns, owner);
610
+ },
611
+ state: STALE
612
+ });
613
+ else
614
+ runErrors(error, fns, owner);
615
+ }
616
+ function resolveChildren(children2) {
617
+ if (typeof children2 === "function" && !children2.length)
618
+ return resolveChildren(children2());
619
+ if (Array.isArray(children2)) {
620
+ const results = [];
621
+ for (let i = 0; i < children2.length; i++) {
622
+ const result = resolveChildren(children2[i]);
623
+ Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
624
+ }
625
+ return results;
626
+ }
627
+ return children2;
628
+ }
629
+ function createProvider(id, options) {
630
+ return function provider(props) {
631
+ let res;
632
+ createRenderEffect(
633
+ () => res = untrack(() => {
634
+ Owner.context = {
635
+ ...Owner.context,
636
+ [id]: props.value
637
+ };
638
+ return children(() => props.children);
639
+ }),
640
+ void 0
641
+ );
642
+ return res;
643
+ };
644
+ }
645
+ var hydrationEnabled = false;
646
+ function createComponent(Comp, props) {
647
+ if (hydrationEnabled) {
648
+ if (sharedConfig.context) {
649
+ const c = sharedConfig.context;
650
+ setHydrateContext(nextHydrateContext());
651
+ const r = untrack(() => Comp(props || {}));
652
+ setHydrateContext(c);
653
+ return r;
654
+ }
655
+ }
656
+ return untrack(() => Comp(props || {}));
657
+ }
658
+
659
+ // ../../node_modules/.pnpm/solid-js@1.8.16/node_modules/solid-js/web/dist/web.js
660
+ var booleans = [
661
+ "allowfullscreen",
662
+ "async",
663
+ "autofocus",
664
+ "autoplay",
665
+ "checked",
666
+ "controls",
667
+ "default",
668
+ "disabled",
669
+ "formnovalidate",
670
+ "hidden",
671
+ "indeterminate",
672
+ "inert",
673
+ "ismap",
674
+ "loop",
675
+ "multiple",
676
+ "muted",
677
+ "nomodule",
678
+ "novalidate",
679
+ "open",
680
+ "playsinline",
681
+ "readonly",
682
+ "required",
683
+ "reversed",
684
+ "seamless",
685
+ "selected"
686
+ ];
687
+ /* @__PURE__ */ new Set([
688
+ "className",
689
+ "value",
690
+ "readOnly",
691
+ "formNoValidate",
692
+ "isMap",
693
+ "noModule",
694
+ "playsInline",
695
+ ...booleans
696
+ ]);
697
+
698
+ // src/WalletProvider.tsx
699
+ var WalletContext = createContext();
700
+ exports.WalletProvider = (props) => {
701
+ const store = () => props.manager;
702
+ onMount(async () => {
703
+ try {
704
+ await props.manager.resumeSessions();
705
+ } catch (error) {
706
+ console.error("Error resuming sessions:", error);
707
+ }
708
+ });
709
+ return createComponent(WalletContext.Provider, {
710
+ value: store,
711
+ get children() {
712
+ return props.children;
713
+ }
714
+ });
715
+ };
716
+ var useWalletManager = () => {
717
+ const manager = useContext(WalletContext);
718
+ if (!manager) {
719
+ throw new Error("useWalletManager must be used within a WalletProvider");
720
+ }
721
+ return manager();
722
+ };
723
+ function useWallet() {
724
+ const manager = createMemo(() => useWalletManager());
725
+ const walletStore = solidStore.useStore(manager().store, (state) => {
726
+ return state.wallets;
727
+ });
728
+ const walletState = (walletId) => walletStore()[walletId] || null;
729
+ const activeWalletId = solidStore.useStore(manager().store, (state) => {
730
+ return state.activeWallet;
731
+ });
732
+ const activeWallet = () => manager().getWallet(activeWalletId()) || null;
733
+ const activeWalletState = () => walletState(activeWalletId());
734
+ const activeWalletAccounts = () => activeWalletState()?.accounts ?? null;
735
+ const activeWalletAddresses = () => activeWalletAccounts()?.map((account) => account.address) ?? null;
736
+ const activeAccount = () => activeWalletState()?.activeAccount ?? null;
737
+ const activeAddress = () => activeAccount()?.address ?? null;
738
+ const isWalletActive = (walletId) => walletId === activeWalletId();
739
+ const isWalletConnected = (walletId) => !!walletState(walletId)?.accounts.length || false;
740
+ const activeNetworkState = createMemo(() => {
741
+ return solidStore.useStore(manager().store, (state) => state.activeNetwork);
742
+ });
743
+ const activeNetwork = () => activeNetworkState()();
744
+ const setActiveNetwork = (network) => manager().setActiveNetwork(network);
745
+ const algodClient = createMemo(() => manager().algodClient);
746
+ const signTransactions = (txnGroup, indexesToSign, returnGroup) => {
747
+ const wallet = activeWallet();
748
+ if (!wallet) {
749
+ throw new Error("No active wallet");
750
+ }
751
+ return wallet.signTransactions(txnGroup, indexesToSign, returnGroup);
752
+ };
753
+ const transactionSigner = (txnGroup, indexesToSign) => {
754
+ const wallet = activeWallet();
755
+ if (!wallet) {
756
+ throw new Error("No active wallet");
757
+ }
758
+ return wallet.transactionSigner(txnGroup, indexesToSign);
759
+ };
760
+ return {
761
+ activeWalletId,
762
+ walletStore,
763
+ algodClient,
764
+ activeNetwork,
765
+ activeWallet,
766
+ activeWalletAccounts,
767
+ activeWalletAddresses,
768
+ activeWalletState,
769
+ activeAccount,
770
+ activeAddress,
771
+ isWalletActive,
772
+ isWalletConnected,
773
+ setActiveNetwork,
774
+ signTransactions,
775
+ transactionSigner,
776
+ wallets: manager().wallets
777
+ };
778
+ }
779
+
780
+ exports.useWallet = useWallet;
781
+ Object.keys(useWallet$1).forEach(function (k) {
782
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
783
+ enumerable: true,
784
+ get: function () { return useWallet$1[k]; }
785
+ });
786
+ });