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