@cordystackx/cordy_minikit 0.3.0 → 0.3.2

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.
Files changed (54) hide show
  1. package/README.md +15 -88
  2. package/dist/chains/base__sepolia.d.ts +43 -0
  3. package/dist/chains/base__sepolia.d.ts.map +1 -0
  4. package/dist/chains/base__sepolia.js +30 -0
  5. package/dist/chains/core.d.ts +40 -0
  6. package/dist/chains/core.d.ts.map +1 -0
  7. package/dist/chains/core.js +27 -0
  8. package/dist/chains/index.d.ts +3 -0
  9. package/dist/chains/index.d.ts.map +1 -0
  10. package/dist/chains/index.js +3 -0
  11. package/dist/client__provider.d.ts +5 -0
  12. package/dist/client__provider.d.ts.map +1 -0
  13. package/dist/client__provider.jsx +9 -0
  14. package/dist/components/Connect_wallet_bt.d.ts +2 -0
  15. package/dist/components/Connect_wallet_bt.d.ts.map +1 -0
  16. package/dist/components/Connect_wallet_bt.jsx +11 -0
  17. package/dist/components/UI_Comp.d.ts +2 -0
  18. package/dist/components/UI_Comp.d.ts.map +1 -0
  19. package/dist/components/UI_Comp.jsx +69 -0
  20. package/dist/components/index.d.ts +3 -0
  21. package/dist/components/index.d.ts.map +1 -0
  22. package/dist/components/index.js +2 -0
  23. package/dist/config/ERC20_ABI.json +26 -0
  24. package/dist/config/Image.json +3 -0
  25. package/dist/config/walletConfig.d.ts +3 -0
  26. package/dist/config/walletConfig.d.ts.map +1 -0
  27. package/dist/config/walletConfig.js +16 -0
  28. package/dist/controllers/Disconnect.d.ts +2 -0
  29. package/dist/controllers/Disconnect.d.ts.map +1 -0
  30. package/dist/controllers/Disconnect.jsx +5 -0
  31. package/dist/controllers/Get_Balance.d.ts +2 -0
  32. package/dist/controllers/Get_Balance.d.ts.map +1 -0
  33. package/dist/controllers/Get_Balance.jsx +16 -0
  34. package/dist/controllers/Transactions.d.ts +2 -0
  35. package/dist/controllers/Transactions.d.ts.map +1 -0
  36. package/dist/controllers/Transactions.jsx +31 -0
  37. package/dist/controllers/WagmiButton.d.ts +8 -0
  38. package/dist/controllers/WagmiButton.d.ts.map +1 -0
  39. package/dist/controllers/WagmiButton.jsx +46 -0
  40. package/dist/controllers/index.d.ts +5 -0
  41. package/dist/controllers/index.d.ts.map +1 -0
  42. package/dist/controllers/index.js +4 -0
  43. package/dist/css/index.d.ts +4 -0
  44. package/dist/css/index.d.ts.map +1 -0
  45. package/dist/css/index.js +3 -0
  46. package/dist/index.d.ts +4 -24
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +6 -2321
  49. package/dist/tsconfig.tsbuildinfo +1 -0
  50. package/dist/wagmi__providers.d.ts +11 -0
  51. package/dist/wagmi__providers.d.ts.map +1 -0
  52. package/dist/wagmi__providers.jsx +28 -0
  53. package/package.json +38 -21
  54. package/dist/index.css +0 -132
package/dist/index.js CHANGED
@@ -1,2321 +1,6 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // index.ts
30
- var index_exports = {};
31
- __export(index_exports, {
32
- ConnectWalletBT: () => ConnectWalletBT,
33
- CordyStackTrans: () => CordyStackTrans,
34
- Disconnect: () => Disconnect,
35
- ProvidersClientWrapper: () => WalletProviders,
36
- UI_Comp: () => UI_Comp,
37
- WalletButton: () => WalletButton,
38
- getTokenBalance: () => getTokenBalance
39
- });
40
- module.exports = __toCommonJS(index_exports);
41
-
42
- // wagmi__providers.tsx
43
- var import_react3 = require("react");
44
-
45
- // node_modules/@tanstack/query-core/build/modern/subscribable.js
46
- var Subscribable = class {
47
- constructor() {
48
- this.listeners = /* @__PURE__ */ new Set();
49
- this.subscribe = this.subscribe.bind(this);
50
- }
51
- subscribe(listener) {
52
- this.listeners.add(listener);
53
- this.onSubscribe();
54
- return () => {
55
- this.listeners.delete(listener);
56
- this.onUnsubscribe();
57
- };
58
- }
59
- hasListeners() {
60
- return this.listeners.size > 0;
61
- }
62
- onSubscribe() {
63
- }
64
- onUnsubscribe() {
65
- }
66
- };
67
-
68
- // node_modules/@tanstack/query-core/build/modern/timeoutManager.js
69
- var defaultTimeoutProvider = {
70
- // We need the wrapper function syntax below instead of direct references to
71
- // global setTimeout etc.
72
- //
73
- // BAD: `setTimeout: setTimeout`
74
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
75
- //
76
- // If we use direct references here, then anything that wants to spy on or
77
- // replace the global setTimeout (like tests) won't work since we'll already
78
- // have a hard reference to the original implementation at the time when this
79
- // file was imported.
80
- setTimeout: (callback, delay) => setTimeout(callback, delay),
81
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
82
- setInterval: (callback, delay) => setInterval(callback, delay),
83
- clearInterval: (intervalId) => clearInterval(intervalId)
84
- };
85
- var TimeoutManager = class {
86
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
87
- // type at app boot; and if we leave that type, then any new timer provider
88
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
89
- //
90
- // We settle for type safety for the TimeoutProvider type, and accept that
91
- // this class is unsafe internally to allow for extension.
92
- #provider = defaultTimeoutProvider;
93
- #providerCalled = false;
94
- setTimeoutProvider(provider) {
95
- if (process.env.NODE_ENV !== "production") {
96
- if (this.#providerCalled && provider !== this.#provider) {
97
- console.error(
98
- `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
99
- { previous: this.#provider, provider }
100
- );
101
- }
102
- }
103
- this.#provider = provider;
104
- if (process.env.NODE_ENV !== "production") {
105
- this.#providerCalled = false;
106
- }
107
- }
108
- setTimeout(callback, delay) {
109
- if (process.env.NODE_ENV !== "production") {
110
- this.#providerCalled = true;
111
- }
112
- return this.#provider.setTimeout(callback, delay);
113
- }
114
- clearTimeout(timeoutId) {
115
- this.#provider.clearTimeout(timeoutId);
116
- }
117
- setInterval(callback, delay) {
118
- if (process.env.NODE_ENV !== "production") {
119
- this.#providerCalled = true;
120
- }
121
- return this.#provider.setInterval(callback, delay);
122
- }
123
- clearInterval(intervalId) {
124
- this.#provider.clearInterval(intervalId);
125
- }
126
- };
127
- var timeoutManager = new TimeoutManager();
128
- function systemSetTimeoutZero(callback) {
129
- setTimeout(callback, 0);
130
- }
131
-
132
- // node_modules/@tanstack/query-core/build/modern/utils.js
133
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
134
- function noop() {
135
- }
136
- function functionalUpdate(updater, input) {
137
- return typeof updater === "function" ? updater(input) : updater;
138
- }
139
- function isValidTimeout(value) {
140
- return typeof value === "number" && value >= 0 && value !== Infinity;
141
- }
142
- function timeUntilStale(updatedAt, staleTime) {
143
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
144
- }
145
- function resolveStaleTime(staleTime, query) {
146
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
147
- }
148
- function resolveEnabled(enabled, query) {
149
- return typeof enabled === "function" ? enabled(query) : enabled;
150
- }
151
- function matchQuery(filters, query) {
152
- const {
153
- type = "all",
154
- exact,
155
- fetchStatus,
156
- predicate,
157
- queryKey,
158
- stale
159
- } = filters;
160
- if (queryKey) {
161
- if (exact) {
162
- if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
163
- return false;
164
- }
165
- } else if (!partialMatchKey(query.queryKey, queryKey)) {
166
- return false;
167
- }
168
- }
169
- if (type !== "all") {
170
- const isActive = query.isActive();
171
- if (type === "active" && !isActive) {
172
- return false;
173
- }
174
- if (type === "inactive" && isActive) {
175
- return false;
176
- }
177
- }
178
- if (typeof stale === "boolean" && query.isStale() !== stale) {
179
- return false;
180
- }
181
- if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
182
- return false;
183
- }
184
- if (predicate && !predicate(query)) {
185
- return false;
186
- }
187
- return true;
188
- }
189
- function matchMutation(filters, mutation) {
190
- const { exact, status, predicate, mutationKey } = filters;
191
- if (mutationKey) {
192
- if (!mutation.options.mutationKey) {
193
- return false;
194
- }
195
- if (exact) {
196
- if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
197
- return false;
198
- }
199
- } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
200
- return false;
201
- }
202
- }
203
- if (status && mutation.state.status !== status) {
204
- return false;
205
- }
206
- if (predicate && !predicate(mutation)) {
207
- return false;
208
- }
209
- return true;
210
- }
211
- function hashQueryKeyByOptions(queryKey, options) {
212
- const hashFn = options?.queryKeyHashFn || hashKey;
213
- return hashFn(queryKey);
214
- }
215
- function hashKey(queryKey) {
216
- return JSON.stringify(
217
- queryKey,
218
- (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
219
- result[key] = val[key];
220
- return result;
221
- }, {}) : val
222
- );
223
- }
224
- function partialMatchKey(a, b) {
225
- if (a === b) {
226
- return true;
227
- }
228
- if (typeof a !== typeof b) {
229
- return false;
230
- }
231
- if (a && b && typeof a === "object" && typeof b === "object") {
232
- return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
233
- }
234
- return false;
235
- }
236
- var hasOwn = Object.prototype.hasOwnProperty;
237
- function replaceEqualDeep(a, b) {
238
- if (a === b) {
239
- return a;
240
- }
241
- const array = isPlainArray(a) && isPlainArray(b);
242
- if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
243
- const aItems = array ? a : Object.keys(a);
244
- const aSize = aItems.length;
245
- const bItems = array ? b : Object.keys(b);
246
- const bSize = bItems.length;
247
- const copy = array ? new Array(bSize) : {};
248
- let equalItems = 0;
249
- for (let i = 0; i < bSize; i++) {
250
- const key = array ? i : bItems[i];
251
- const aItem = a[key];
252
- const bItem = b[key];
253
- if (aItem === bItem) {
254
- copy[key] = aItem;
255
- if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
256
- continue;
257
- }
258
- if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
259
- copy[key] = bItem;
260
- continue;
261
- }
262
- const v = replaceEqualDeep(aItem, bItem);
263
- copy[key] = v;
264
- if (v === aItem) equalItems++;
265
- }
266
- return aSize === bSize && equalItems === aSize ? a : copy;
267
- }
268
- function isPlainArray(value) {
269
- return Array.isArray(value) && value.length === Object.keys(value).length;
270
- }
271
- function isPlainObject(o) {
272
- if (!hasObjectPrototype(o)) {
273
- return false;
274
- }
275
- const ctor = o.constructor;
276
- if (ctor === void 0) {
277
- return true;
278
- }
279
- const prot = ctor.prototype;
280
- if (!hasObjectPrototype(prot)) {
281
- return false;
282
- }
283
- if (!prot.hasOwnProperty("isPrototypeOf")) {
284
- return false;
285
- }
286
- if (Object.getPrototypeOf(o) !== Object.prototype) {
287
- return false;
288
- }
289
- return true;
290
- }
291
- function hasObjectPrototype(o) {
292
- return Object.prototype.toString.call(o) === "[object Object]";
293
- }
294
- function sleep(timeout) {
295
- return new Promise((resolve) => {
296
- timeoutManager.setTimeout(resolve, timeout);
297
- });
298
- }
299
- function replaceData(prevData, data, options) {
300
- if (typeof options.structuralSharing === "function") {
301
- return options.structuralSharing(prevData, data);
302
- } else if (options.structuralSharing !== false) {
303
- if (process.env.NODE_ENV !== "production") {
304
- try {
305
- return replaceEqualDeep(prevData, data);
306
- } catch (error) {
307
- console.error(
308
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
309
- );
310
- throw error;
311
- }
312
- }
313
- return replaceEqualDeep(prevData, data);
314
- }
315
- return data;
316
- }
317
- function addToEnd(items, item, max = 0) {
318
- const newItems = [...items, item];
319
- return max && newItems.length > max ? newItems.slice(1) : newItems;
320
- }
321
- function addToStart(items, item, max = 0) {
322
- const newItems = [item, ...items];
323
- return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
324
- }
325
- var skipToken = Symbol();
326
- function ensureQueryFn(options, fetchOptions) {
327
- if (process.env.NODE_ENV !== "production") {
328
- if (options.queryFn === skipToken) {
329
- console.error(
330
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
331
- );
332
- }
333
- }
334
- if (!options.queryFn && fetchOptions?.initialPromise) {
335
- return () => fetchOptions.initialPromise;
336
- }
337
- if (!options.queryFn || options.queryFn === skipToken) {
338
- return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
339
- }
340
- return options.queryFn;
341
- }
342
-
343
- // node_modules/@tanstack/query-core/build/modern/focusManager.js
344
- var FocusManager = class extends Subscribable {
345
- #focused;
346
- #cleanup;
347
- #setup;
348
- constructor() {
349
- super();
350
- this.#setup = (onFocus) => {
351
- if (!isServer && window.addEventListener) {
352
- const listener = () => onFocus();
353
- window.addEventListener("visibilitychange", listener, false);
354
- return () => {
355
- window.removeEventListener("visibilitychange", listener);
356
- };
357
- }
358
- return;
359
- };
360
- }
361
- onSubscribe() {
362
- if (!this.#cleanup) {
363
- this.setEventListener(this.#setup);
364
- }
365
- }
366
- onUnsubscribe() {
367
- if (!this.hasListeners()) {
368
- this.#cleanup?.();
369
- this.#cleanup = void 0;
370
- }
371
- }
372
- setEventListener(setup) {
373
- this.#setup = setup;
374
- this.#cleanup?.();
375
- this.#cleanup = setup((focused) => {
376
- if (typeof focused === "boolean") {
377
- this.setFocused(focused);
378
- } else {
379
- this.onFocus();
380
- }
381
- });
382
- }
383
- setFocused(focused) {
384
- const changed = this.#focused !== focused;
385
- if (changed) {
386
- this.#focused = focused;
387
- this.onFocus();
388
- }
389
- }
390
- onFocus() {
391
- const isFocused = this.isFocused();
392
- this.listeners.forEach((listener) => {
393
- listener(isFocused);
394
- });
395
- }
396
- isFocused() {
397
- if (typeof this.#focused === "boolean") {
398
- return this.#focused;
399
- }
400
- return globalThis.document?.visibilityState !== "hidden";
401
- }
402
- };
403
- var focusManager = new FocusManager();
404
-
405
- // node_modules/@tanstack/query-core/build/modern/thenable.js
406
- function pendingThenable() {
407
- let resolve;
408
- let reject;
409
- const thenable = new Promise((_resolve, _reject) => {
410
- resolve = _resolve;
411
- reject = _reject;
412
- });
413
- thenable.status = "pending";
414
- thenable.catch(() => {
415
- });
416
- function finalize(data) {
417
- Object.assign(thenable, data);
418
- delete thenable.resolve;
419
- delete thenable.reject;
420
- }
421
- thenable.resolve = (value) => {
422
- finalize({
423
- status: "fulfilled",
424
- value
425
- });
426
- resolve(value);
427
- };
428
- thenable.reject = (reason) => {
429
- finalize({
430
- status: "rejected",
431
- reason
432
- });
433
- reject(reason);
434
- };
435
- return thenable;
436
- }
437
-
438
- // node_modules/@tanstack/query-core/build/modern/notifyManager.js
439
- var defaultScheduler = systemSetTimeoutZero;
440
- function createNotifyManager() {
441
- let queue = [];
442
- let transactions = 0;
443
- let notifyFn = (callback) => {
444
- callback();
445
- };
446
- let batchNotifyFn = (callback) => {
447
- callback();
448
- };
449
- let scheduleFn = defaultScheduler;
450
- const schedule = (callback) => {
451
- if (transactions) {
452
- queue.push(callback);
453
- } else {
454
- scheduleFn(() => {
455
- notifyFn(callback);
456
- });
457
- }
458
- };
459
- const flush = () => {
460
- const originalQueue = queue;
461
- queue = [];
462
- if (originalQueue.length) {
463
- scheduleFn(() => {
464
- batchNotifyFn(() => {
465
- originalQueue.forEach((callback) => {
466
- notifyFn(callback);
467
- });
468
- });
469
- });
470
- }
471
- };
472
- return {
473
- batch: (callback) => {
474
- let result;
475
- transactions++;
476
- try {
477
- result = callback();
478
- } finally {
479
- transactions--;
480
- if (!transactions) {
481
- flush();
482
- }
483
- }
484
- return result;
485
- },
486
- /**
487
- * All calls to the wrapped function will be batched.
488
- */
489
- batchCalls: (callback) => {
490
- return (...args) => {
491
- schedule(() => {
492
- callback(...args);
493
- });
494
- };
495
- },
496
- schedule,
497
- /**
498
- * Use this method to set a custom notify function.
499
- * This can be used to for example wrap notifications with `React.act` while running tests.
500
- */
501
- setNotifyFunction: (fn) => {
502
- notifyFn = fn;
503
- },
504
- /**
505
- * Use this method to set a custom function to batch notifications together into a single tick.
506
- * By default React Query will use the batch function provided by ReactDOM or React Native.
507
- */
508
- setBatchNotifyFunction: (fn) => {
509
- batchNotifyFn = fn;
510
- },
511
- setScheduler: (fn) => {
512
- scheduleFn = fn;
513
- }
514
- };
515
- }
516
- var notifyManager = createNotifyManager();
517
-
518
- // node_modules/@tanstack/query-core/build/modern/onlineManager.js
519
- var OnlineManager = class extends Subscribable {
520
- #online = true;
521
- #cleanup;
522
- #setup;
523
- constructor() {
524
- super();
525
- this.#setup = (onOnline) => {
526
- if (!isServer && window.addEventListener) {
527
- const onlineListener = () => onOnline(true);
528
- const offlineListener = () => onOnline(false);
529
- window.addEventListener("online", onlineListener, false);
530
- window.addEventListener("offline", offlineListener, false);
531
- return () => {
532
- window.removeEventListener("online", onlineListener);
533
- window.removeEventListener("offline", offlineListener);
534
- };
535
- }
536
- return;
537
- };
538
- }
539
- onSubscribe() {
540
- if (!this.#cleanup) {
541
- this.setEventListener(this.#setup);
542
- }
543
- }
544
- onUnsubscribe() {
545
- if (!this.hasListeners()) {
546
- this.#cleanup?.();
547
- this.#cleanup = void 0;
548
- }
549
- }
550
- setEventListener(setup) {
551
- this.#setup = setup;
552
- this.#cleanup?.();
553
- this.#cleanup = setup(this.setOnline.bind(this));
554
- }
555
- setOnline(online) {
556
- const changed = this.#online !== online;
557
- if (changed) {
558
- this.#online = online;
559
- this.listeners.forEach((listener) => {
560
- listener(online);
561
- });
562
- }
563
- }
564
- isOnline() {
565
- return this.#online;
566
- }
567
- };
568
- var onlineManager = new OnlineManager();
569
-
570
- // node_modules/@tanstack/query-core/build/modern/retryer.js
571
- function defaultRetryDelay(failureCount) {
572
- return Math.min(1e3 * 2 ** failureCount, 3e4);
573
- }
574
- function canFetch(networkMode) {
575
- return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
576
- }
577
- var CancelledError = class extends Error {
578
- constructor(options) {
579
- super("CancelledError");
580
- this.revert = options?.revert;
581
- this.silent = options?.silent;
582
- }
583
- };
584
- function createRetryer(config2) {
585
- let isRetryCancelled = false;
586
- let failureCount = 0;
587
- let continueFn;
588
- const thenable = pendingThenable();
589
- const isResolved = () => thenable.status !== "pending";
590
- const cancel = (cancelOptions) => {
591
- if (!isResolved()) {
592
- const error = new CancelledError(cancelOptions);
593
- reject(error);
594
- config2.onCancel?.(error);
595
- }
596
- };
597
- const cancelRetry = () => {
598
- isRetryCancelled = true;
599
- };
600
- const continueRetry = () => {
601
- isRetryCancelled = false;
602
- };
603
- const canContinue = () => focusManager.isFocused() && (config2.networkMode === "always" || onlineManager.isOnline()) && config2.canRun();
604
- const canStart = () => canFetch(config2.networkMode) && config2.canRun();
605
- const resolve = (value) => {
606
- if (!isResolved()) {
607
- continueFn?.();
608
- thenable.resolve(value);
609
- }
610
- };
611
- const reject = (value) => {
612
- if (!isResolved()) {
613
- continueFn?.();
614
- thenable.reject(value);
615
- }
616
- };
617
- const pause = () => {
618
- return new Promise((continueResolve) => {
619
- continueFn = (value) => {
620
- if (isResolved() || canContinue()) {
621
- continueResolve(value);
622
- }
623
- };
624
- config2.onPause?.();
625
- }).then(() => {
626
- continueFn = void 0;
627
- if (!isResolved()) {
628
- config2.onContinue?.();
629
- }
630
- });
631
- };
632
- const run = () => {
633
- if (isResolved()) {
634
- return;
635
- }
636
- let promiseOrValue;
637
- const initialPromise = failureCount === 0 ? config2.initialPromise : void 0;
638
- try {
639
- promiseOrValue = initialPromise ?? config2.fn();
640
- } catch (error) {
641
- promiseOrValue = Promise.reject(error);
642
- }
643
- Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
644
- if (isResolved()) {
645
- return;
646
- }
647
- const retry = config2.retry ?? (isServer ? 0 : 3);
648
- const retryDelay = config2.retryDelay ?? defaultRetryDelay;
649
- const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
650
- const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
651
- if (isRetryCancelled || !shouldRetry) {
652
- reject(error);
653
- return;
654
- }
655
- failureCount++;
656
- config2.onFail?.(failureCount, error);
657
- sleep(delay).then(() => {
658
- return canContinue() ? void 0 : pause();
659
- }).then(() => {
660
- if (isRetryCancelled) {
661
- reject(error);
662
- } else {
663
- run();
664
- }
665
- });
666
- });
667
- };
668
- return {
669
- promise: thenable,
670
- status: () => thenable.status,
671
- cancel,
672
- continue: () => {
673
- continueFn?.();
674
- return thenable;
675
- },
676
- cancelRetry,
677
- continueRetry,
678
- canStart,
679
- start: () => {
680
- if (canStart()) {
681
- run();
682
- } else {
683
- pause().then(run);
684
- }
685
- return thenable;
686
- }
687
- };
688
- }
689
-
690
- // node_modules/@tanstack/query-core/build/modern/removable.js
691
- var Removable = class {
692
- #gcTimeout;
693
- destroy() {
694
- this.clearGcTimeout();
695
- }
696
- scheduleGc() {
697
- this.clearGcTimeout();
698
- if (isValidTimeout(this.gcTime)) {
699
- this.#gcTimeout = timeoutManager.setTimeout(() => {
700
- this.optionalRemove();
701
- }, this.gcTime);
702
- }
703
- }
704
- updateGcTime(newGcTime) {
705
- this.gcTime = Math.max(
706
- this.gcTime || 0,
707
- newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
708
- );
709
- }
710
- clearGcTimeout() {
711
- if (this.#gcTimeout) {
712
- timeoutManager.clearTimeout(this.#gcTimeout);
713
- this.#gcTimeout = void 0;
714
- }
715
- }
716
- };
717
-
718
- // node_modules/@tanstack/query-core/build/modern/query.js
719
- var Query = class extends Removable {
720
- #initialState;
721
- #revertState;
722
- #cache;
723
- #client;
724
- #retryer;
725
- #defaultOptions;
726
- #abortSignalConsumed;
727
- constructor(config2) {
728
- super();
729
- this.#abortSignalConsumed = false;
730
- this.#defaultOptions = config2.defaultOptions;
731
- this.setOptions(config2.options);
732
- this.observers = [];
733
- this.#client = config2.client;
734
- this.#cache = this.#client.getQueryCache();
735
- this.queryKey = config2.queryKey;
736
- this.queryHash = config2.queryHash;
737
- this.#initialState = getDefaultState(this.options);
738
- this.state = config2.state ?? this.#initialState;
739
- this.scheduleGc();
740
- }
741
- get meta() {
742
- return this.options.meta;
743
- }
744
- get promise() {
745
- return this.#retryer?.promise;
746
- }
747
- setOptions(options) {
748
- this.options = { ...this.#defaultOptions, ...options };
749
- this.updateGcTime(this.options.gcTime);
750
- if (this.state && this.state.data === void 0) {
751
- const defaultState = getDefaultState(this.options);
752
- if (defaultState.data !== void 0) {
753
- this.setData(defaultState.data, {
754
- updatedAt: defaultState.dataUpdatedAt,
755
- manual: true
756
- });
757
- this.#initialState = defaultState;
758
- }
759
- }
760
- }
761
- optionalRemove() {
762
- if (!this.observers.length && this.state.fetchStatus === "idle") {
763
- this.#cache.remove(this);
764
- }
765
- }
766
- setData(newData, options) {
767
- const data = replaceData(this.state.data, newData, this.options);
768
- this.#dispatch({
769
- data,
770
- type: "success",
771
- dataUpdatedAt: options?.updatedAt,
772
- manual: options?.manual
773
- });
774
- return data;
775
- }
776
- setState(state, setStateOptions) {
777
- this.#dispatch({ type: "setState", state, setStateOptions });
778
- }
779
- cancel(options) {
780
- const promise = this.#retryer?.promise;
781
- this.#retryer?.cancel(options);
782
- return promise ? promise.then(noop).catch(noop) : Promise.resolve();
783
- }
784
- destroy() {
785
- super.destroy();
786
- this.cancel({ silent: true });
787
- }
788
- reset() {
789
- this.destroy();
790
- this.setState(this.#initialState);
791
- }
792
- isActive() {
793
- return this.observers.some(
794
- (observer) => resolveEnabled(observer.options.enabled, this) !== false
795
- );
796
- }
797
- isDisabled() {
798
- if (this.getObserversCount() > 0) {
799
- return !this.isActive();
800
- }
801
- return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
802
- }
803
- isStatic() {
804
- if (this.getObserversCount() > 0) {
805
- return this.observers.some(
806
- (observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
807
- );
808
- }
809
- return false;
810
- }
811
- isStale() {
812
- if (this.getObserversCount() > 0) {
813
- return this.observers.some(
814
- (observer) => observer.getCurrentResult().isStale
815
- );
816
- }
817
- return this.state.data === void 0 || this.state.isInvalidated;
818
- }
819
- isStaleByTime(staleTime = 0) {
820
- if (this.state.data === void 0) {
821
- return true;
822
- }
823
- if (staleTime === "static") {
824
- return false;
825
- }
826
- if (this.state.isInvalidated) {
827
- return true;
828
- }
829
- return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
830
- }
831
- onFocus() {
832
- const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
833
- observer?.refetch({ cancelRefetch: false });
834
- this.#retryer?.continue();
835
- }
836
- onOnline() {
837
- const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
838
- observer?.refetch({ cancelRefetch: false });
839
- this.#retryer?.continue();
840
- }
841
- addObserver(observer) {
842
- if (!this.observers.includes(observer)) {
843
- this.observers.push(observer);
844
- this.clearGcTimeout();
845
- this.#cache.notify({ type: "observerAdded", query: this, observer });
846
- }
847
- }
848
- removeObserver(observer) {
849
- if (this.observers.includes(observer)) {
850
- this.observers = this.observers.filter((x) => x !== observer);
851
- if (!this.observers.length) {
852
- if (this.#retryer) {
853
- if (this.#abortSignalConsumed) {
854
- this.#retryer.cancel({ revert: true });
855
- } else {
856
- this.#retryer.cancelRetry();
857
- }
858
- }
859
- this.scheduleGc();
860
- }
861
- this.#cache.notify({ type: "observerRemoved", query: this, observer });
862
- }
863
- }
864
- getObserversCount() {
865
- return this.observers.length;
866
- }
867
- invalidate() {
868
- if (!this.state.isInvalidated) {
869
- this.#dispatch({ type: "invalidate" });
870
- }
871
- }
872
- async fetch(options, fetchOptions) {
873
- if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
874
- // re-start the fetch; there is a chance that the query is still in a
875
- // pending state when that happens
876
- this.#retryer?.status() !== "rejected") {
877
- if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
878
- this.cancel({ silent: true });
879
- } else if (this.#retryer) {
880
- this.#retryer.continueRetry();
881
- return this.#retryer.promise;
882
- }
883
- }
884
- if (options) {
885
- this.setOptions(options);
886
- }
887
- if (!this.options.queryFn) {
888
- const observer = this.observers.find((x) => x.options.queryFn);
889
- if (observer) {
890
- this.setOptions(observer.options);
891
- }
892
- }
893
- if (process.env.NODE_ENV !== "production") {
894
- if (!Array.isArray(this.options.queryKey)) {
895
- console.error(
896
- `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`
897
- );
898
- }
899
- }
900
- const abortController = new AbortController();
901
- const addSignalProperty = (object) => {
902
- Object.defineProperty(object, "signal", {
903
- enumerable: true,
904
- get: () => {
905
- this.#abortSignalConsumed = true;
906
- return abortController.signal;
907
- }
908
- });
909
- };
910
- const fetchFn = () => {
911
- const queryFn = ensureQueryFn(this.options, fetchOptions);
912
- const createQueryFnContext = () => {
913
- const queryFnContext2 = {
914
- client: this.#client,
915
- queryKey: this.queryKey,
916
- meta: this.meta
917
- };
918
- addSignalProperty(queryFnContext2);
919
- return queryFnContext2;
920
- };
921
- const queryFnContext = createQueryFnContext();
922
- this.#abortSignalConsumed = false;
923
- if (this.options.persister) {
924
- return this.options.persister(
925
- queryFn,
926
- queryFnContext,
927
- this
928
- );
929
- }
930
- return queryFn(queryFnContext);
931
- };
932
- const createFetchContext = () => {
933
- const context2 = {
934
- fetchOptions,
935
- options: this.options,
936
- queryKey: this.queryKey,
937
- client: this.#client,
938
- state: this.state,
939
- fetchFn
940
- };
941
- addSignalProperty(context2);
942
- return context2;
943
- };
944
- const context = createFetchContext();
945
- this.options.behavior?.onFetch(context, this);
946
- this.#revertState = this.state;
947
- if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
948
- this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
949
- }
950
- this.#retryer = createRetryer({
951
- initialPromise: fetchOptions?.initialPromise,
952
- fn: context.fetchFn,
953
- onCancel: (error) => {
954
- if (error instanceof CancelledError && error.revert) {
955
- this.setState({
956
- ...this.#revertState,
957
- fetchStatus: "idle"
958
- });
959
- }
960
- abortController.abort();
961
- },
962
- onFail: (failureCount, error) => {
963
- this.#dispatch({ type: "failed", failureCount, error });
964
- },
965
- onPause: () => {
966
- this.#dispatch({ type: "pause" });
967
- },
968
- onContinue: () => {
969
- this.#dispatch({ type: "continue" });
970
- },
971
- retry: context.options.retry,
972
- retryDelay: context.options.retryDelay,
973
- networkMode: context.options.networkMode,
974
- canRun: () => true
975
- });
976
- try {
977
- const data = await this.#retryer.start();
978
- if (data === void 0) {
979
- if (process.env.NODE_ENV !== "production") {
980
- console.error(
981
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
982
- );
983
- }
984
- throw new Error(`${this.queryHash} data is undefined`);
985
- }
986
- this.setData(data);
987
- this.#cache.config.onSuccess?.(data, this);
988
- this.#cache.config.onSettled?.(
989
- data,
990
- this.state.error,
991
- this
992
- );
993
- return data;
994
- } catch (error) {
995
- if (error instanceof CancelledError) {
996
- if (error.silent) {
997
- return this.#retryer.promise;
998
- } else if (error.revert) {
999
- if (this.state.data === void 0) {
1000
- throw error;
1001
- }
1002
- return this.state.data;
1003
- }
1004
- }
1005
- this.#dispatch({
1006
- type: "error",
1007
- error
1008
- });
1009
- this.#cache.config.onError?.(
1010
- error,
1011
- this
1012
- );
1013
- this.#cache.config.onSettled?.(
1014
- this.state.data,
1015
- error,
1016
- this
1017
- );
1018
- throw error;
1019
- } finally {
1020
- this.scheduleGc();
1021
- }
1022
- }
1023
- #dispatch(action) {
1024
- const reducer = (state) => {
1025
- switch (action.type) {
1026
- case "failed":
1027
- return {
1028
- ...state,
1029
- fetchFailureCount: action.failureCount,
1030
- fetchFailureReason: action.error
1031
- };
1032
- case "pause":
1033
- return {
1034
- ...state,
1035
- fetchStatus: "paused"
1036
- };
1037
- case "continue":
1038
- return {
1039
- ...state,
1040
- fetchStatus: "fetching"
1041
- };
1042
- case "fetch":
1043
- return {
1044
- ...state,
1045
- ...fetchState(state.data, this.options),
1046
- fetchMeta: action.meta ?? null
1047
- };
1048
- case "success":
1049
- const newState = {
1050
- ...state,
1051
- data: action.data,
1052
- dataUpdateCount: state.dataUpdateCount + 1,
1053
- dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
1054
- error: null,
1055
- isInvalidated: false,
1056
- status: "success",
1057
- ...!action.manual && {
1058
- fetchStatus: "idle",
1059
- fetchFailureCount: 0,
1060
- fetchFailureReason: null
1061
- }
1062
- };
1063
- this.#revertState = action.manual ? newState : void 0;
1064
- return newState;
1065
- case "error":
1066
- const error = action.error;
1067
- return {
1068
- ...state,
1069
- error,
1070
- errorUpdateCount: state.errorUpdateCount + 1,
1071
- errorUpdatedAt: Date.now(),
1072
- fetchFailureCount: state.fetchFailureCount + 1,
1073
- fetchFailureReason: error,
1074
- fetchStatus: "idle",
1075
- status: "error"
1076
- };
1077
- case "invalidate":
1078
- return {
1079
- ...state,
1080
- isInvalidated: true
1081
- };
1082
- case "setState":
1083
- return {
1084
- ...state,
1085
- ...action.state
1086
- };
1087
- }
1088
- };
1089
- this.state = reducer(this.state);
1090
- notifyManager.batch(() => {
1091
- this.observers.forEach((observer) => {
1092
- observer.onQueryUpdate();
1093
- });
1094
- this.#cache.notify({ query: this, type: "updated", action });
1095
- });
1096
- }
1097
- };
1098
- function fetchState(data, options) {
1099
- return {
1100
- fetchFailureCount: 0,
1101
- fetchFailureReason: null,
1102
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1103
- ...data === void 0 && {
1104
- error: null,
1105
- status: "pending"
1106
- }
1107
- };
1108
- }
1109
- function getDefaultState(options) {
1110
- const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
1111
- const hasData = data !== void 0;
1112
- const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
1113
- return {
1114
- data,
1115
- dataUpdateCount: 0,
1116
- dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
1117
- error: null,
1118
- errorUpdateCount: 0,
1119
- errorUpdatedAt: 0,
1120
- fetchFailureCount: 0,
1121
- fetchFailureReason: null,
1122
- fetchMeta: null,
1123
- isInvalidated: false,
1124
- status: hasData ? "success" : "pending",
1125
- fetchStatus: "idle"
1126
- };
1127
- }
1128
-
1129
- // node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
1130
- function infiniteQueryBehavior(pages) {
1131
- return {
1132
- onFetch: (context, query) => {
1133
- const options = context.options;
1134
- const direction = context.fetchOptions?.meta?.fetchMore?.direction;
1135
- const oldPages = context.state.data?.pages || [];
1136
- const oldPageParams = context.state.data?.pageParams || [];
1137
- let result = { pages: [], pageParams: [] };
1138
- let currentPage = 0;
1139
- const fetchFn = async () => {
1140
- let cancelled = false;
1141
- const addSignalProperty = (object) => {
1142
- Object.defineProperty(object, "signal", {
1143
- enumerable: true,
1144
- get: () => {
1145
- if (context.signal.aborted) {
1146
- cancelled = true;
1147
- } else {
1148
- context.signal.addEventListener("abort", () => {
1149
- cancelled = true;
1150
- });
1151
- }
1152
- return context.signal;
1153
- }
1154
- });
1155
- };
1156
- const queryFn = ensureQueryFn(context.options, context.fetchOptions);
1157
- const fetchPage = async (data, param, previous) => {
1158
- if (cancelled) {
1159
- return Promise.reject();
1160
- }
1161
- if (param == null && data.pages.length) {
1162
- return Promise.resolve(data);
1163
- }
1164
- const createQueryFnContext = () => {
1165
- const queryFnContext2 = {
1166
- client: context.client,
1167
- queryKey: context.queryKey,
1168
- pageParam: param,
1169
- direction: previous ? "backward" : "forward",
1170
- meta: context.options.meta
1171
- };
1172
- addSignalProperty(queryFnContext2);
1173
- return queryFnContext2;
1174
- };
1175
- const queryFnContext = createQueryFnContext();
1176
- const page = await queryFn(queryFnContext);
1177
- const { maxPages } = context.options;
1178
- const addTo = previous ? addToStart : addToEnd;
1179
- return {
1180
- pages: addTo(data.pages, page, maxPages),
1181
- pageParams: addTo(data.pageParams, param, maxPages)
1182
- };
1183
- };
1184
- if (direction && oldPages.length) {
1185
- const previous = direction === "backward";
1186
- const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
1187
- const oldData = {
1188
- pages: oldPages,
1189
- pageParams: oldPageParams
1190
- };
1191
- const param = pageParamFn(options, oldData);
1192
- result = await fetchPage(oldData, param, previous);
1193
- } else {
1194
- const remainingPages = pages ?? oldPages.length;
1195
- do {
1196
- const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
1197
- if (currentPage > 0 && param == null) {
1198
- break;
1199
- }
1200
- result = await fetchPage(result, param);
1201
- currentPage++;
1202
- } while (currentPage < remainingPages);
1203
- }
1204
- return result;
1205
- };
1206
- if (context.options.persister) {
1207
- context.fetchFn = () => {
1208
- return context.options.persister?.(
1209
- fetchFn,
1210
- {
1211
- client: context.client,
1212
- queryKey: context.queryKey,
1213
- meta: context.options.meta,
1214
- signal: context.signal
1215
- },
1216
- query
1217
- );
1218
- };
1219
- } else {
1220
- context.fetchFn = fetchFn;
1221
- }
1222
- }
1223
- };
1224
- }
1225
- function getNextPageParam(options, { pages, pageParams }) {
1226
- const lastIndex = pages.length - 1;
1227
- return pages.length > 0 ? options.getNextPageParam(
1228
- pages[lastIndex],
1229
- pages,
1230
- pageParams[lastIndex],
1231
- pageParams
1232
- ) : void 0;
1233
- }
1234
- function getPreviousPageParam(options, { pages, pageParams }) {
1235
- return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
1236
- }
1237
-
1238
- // node_modules/@tanstack/query-core/build/modern/mutation.js
1239
- var Mutation = class extends Removable {
1240
- #client;
1241
- #observers;
1242
- #mutationCache;
1243
- #retryer;
1244
- constructor(config2) {
1245
- super();
1246
- this.#client = config2.client;
1247
- this.mutationId = config2.mutationId;
1248
- this.#mutationCache = config2.mutationCache;
1249
- this.#observers = [];
1250
- this.state = config2.state || getDefaultState2();
1251
- this.setOptions(config2.options);
1252
- this.scheduleGc();
1253
- }
1254
- setOptions(options) {
1255
- this.options = options;
1256
- this.updateGcTime(this.options.gcTime);
1257
- }
1258
- get meta() {
1259
- return this.options.meta;
1260
- }
1261
- addObserver(observer) {
1262
- if (!this.#observers.includes(observer)) {
1263
- this.#observers.push(observer);
1264
- this.clearGcTimeout();
1265
- this.#mutationCache.notify({
1266
- type: "observerAdded",
1267
- mutation: this,
1268
- observer
1269
- });
1270
- }
1271
- }
1272
- removeObserver(observer) {
1273
- this.#observers = this.#observers.filter((x) => x !== observer);
1274
- this.scheduleGc();
1275
- this.#mutationCache.notify({
1276
- type: "observerRemoved",
1277
- mutation: this,
1278
- observer
1279
- });
1280
- }
1281
- optionalRemove() {
1282
- if (!this.#observers.length) {
1283
- if (this.state.status === "pending") {
1284
- this.scheduleGc();
1285
- } else {
1286
- this.#mutationCache.remove(this);
1287
- }
1288
- }
1289
- }
1290
- continue() {
1291
- return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
1292
- this.execute(this.state.variables);
1293
- }
1294
- async execute(variables) {
1295
- const onContinue = () => {
1296
- this.#dispatch({ type: "continue" });
1297
- };
1298
- const mutationFnContext = {
1299
- client: this.#client,
1300
- meta: this.options.meta,
1301
- mutationKey: this.options.mutationKey
1302
- };
1303
- this.#retryer = createRetryer({
1304
- fn: () => {
1305
- if (!this.options.mutationFn) {
1306
- return Promise.reject(new Error("No mutationFn found"));
1307
- }
1308
- return this.options.mutationFn(variables, mutationFnContext);
1309
- },
1310
- onFail: (failureCount, error) => {
1311
- this.#dispatch({ type: "failed", failureCount, error });
1312
- },
1313
- onPause: () => {
1314
- this.#dispatch({ type: "pause" });
1315
- },
1316
- onContinue,
1317
- retry: this.options.retry ?? 0,
1318
- retryDelay: this.options.retryDelay,
1319
- networkMode: this.options.networkMode,
1320
- canRun: () => this.#mutationCache.canRun(this)
1321
- });
1322
- const restored = this.state.status === "pending";
1323
- const isPaused = !this.#retryer.canStart();
1324
- try {
1325
- if (restored) {
1326
- onContinue();
1327
- } else {
1328
- this.#dispatch({ type: "pending", variables, isPaused });
1329
- await this.#mutationCache.config.onMutate?.(
1330
- variables,
1331
- this,
1332
- mutationFnContext
1333
- );
1334
- const context = await this.options.onMutate?.(
1335
- variables,
1336
- mutationFnContext
1337
- );
1338
- if (context !== this.state.context) {
1339
- this.#dispatch({
1340
- type: "pending",
1341
- context,
1342
- variables,
1343
- isPaused
1344
- });
1345
- }
1346
- }
1347
- const data = await this.#retryer.start();
1348
- await this.#mutationCache.config.onSuccess?.(
1349
- data,
1350
- variables,
1351
- this.state.context,
1352
- this,
1353
- mutationFnContext
1354
- );
1355
- await this.options.onSuccess?.(
1356
- data,
1357
- variables,
1358
- this.state.context,
1359
- mutationFnContext
1360
- );
1361
- await this.#mutationCache.config.onSettled?.(
1362
- data,
1363
- null,
1364
- this.state.variables,
1365
- this.state.context,
1366
- this,
1367
- mutationFnContext
1368
- );
1369
- await this.options.onSettled?.(
1370
- data,
1371
- null,
1372
- variables,
1373
- this.state.context,
1374
- mutationFnContext
1375
- );
1376
- this.#dispatch({ type: "success", data });
1377
- return data;
1378
- } catch (error) {
1379
- try {
1380
- await this.#mutationCache.config.onError?.(
1381
- error,
1382
- variables,
1383
- this.state.context,
1384
- this,
1385
- mutationFnContext
1386
- );
1387
- await this.options.onError?.(
1388
- error,
1389
- variables,
1390
- this.state.context,
1391
- mutationFnContext
1392
- );
1393
- await this.#mutationCache.config.onSettled?.(
1394
- void 0,
1395
- error,
1396
- this.state.variables,
1397
- this.state.context,
1398
- this,
1399
- mutationFnContext
1400
- );
1401
- await this.options.onSettled?.(
1402
- void 0,
1403
- error,
1404
- variables,
1405
- this.state.context,
1406
- mutationFnContext
1407
- );
1408
- throw error;
1409
- } finally {
1410
- this.#dispatch({ type: "error", error });
1411
- }
1412
- } finally {
1413
- this.#mutationCache.runNext(this);
1414
- }
1415
- }
1416
- #dispatch(action) {
1417
- const reducer = (state) => {
1418
- switch (action.type) {
1419
- case "failed":
1420
- return {
1421
- ...state,
1422
- failureCount: action.failureCount,
1423
- failureReason: action.error
1424
- };
1425
- case "pause":
1426
- return {
1427
- ...state,
1428
- isPaused: true
1429
- };
1430
- case "continue":
1431
- return {
1432
- ...state,
1433
- isPaused: false
1434
- };
1435
- case "pending":
1436
- return {
1437
- ...state,
1438
- context: action.context,
1439
- data: void 0,
1440
- failureCount: 0,
1441
- failureReason: null,
1442
- error: null,
1443
- isPaused: action.isPaused,
1444
- status: "pending",
1445
- variables: action.variables,
1446
- submittedAt: Date.now()
1447
- };
1448
- case "success":
1449
- return {
1450
- ...state,
1451
- data: action.data,
1452
- failureCount: 0,
1453
- failureReason: null,
1454
- error: null,
1455
- status: "success",
1456
- isPaused: false
1457
- };
1458
- case "error":
1459
- return {
1460
- ...state,
1461
- data: void 0,
1462
- error: action.error,
1463
- failureCount: state.failureCount + 1,
1464
- failureReason: action.error,
1465
- isPaused: false,
1466
- status: "error"
1467
- };
1468
- }
1469
- };
1470
- this.state = reducer(this.state);
1471
- notifyManager.batch(() => {
1472
- this.#observers.forEach((observer) => {
1473
- observer.onMutationUpdate(action);
1474
- });
1475
- this.#mutationCache.notify({
1476
- mutation: this,
1477
- type: "updated",
1478
- action
1479
- });
1480
- });
1481
- }
1482
- };
1483
- function getDefaultState2() {
1484
- return {
1485
- context: void 0,
1486
- data: void 0,
1487
- error: null,
1488
- failureCount: 0,
1489
- failureReason: null,
1490
- isPaused: false,
1491
- status: "idle",
1492
- variables: void 0,
1493
- submittedAt: 0
1494
- };
1495
- }
1496
-
1497
- // node_modules/@tanstack/query-core/build/modern/mutationCache.js
1498
- var MutationCache = class extends Subscribable {
1499
- constructor(config2 = {}) {
1500
- super();
1501
- this.config = config2;
1502
- this.#mutations = /* @__PURE__ */ new Set();
1503
- this.#scopes = /* @__PURE__ */ new Map();
1504
- this.#mutationId = 0;
1505
- }
1506
- #mutations;
1507
- #scopes;
1508
- #mutationId;
1509
- build(client, options, state) {
1510
- const mutation = new Mutation({
1511
- client,
1512
- mutationCache: this,
1513
- mutationId: ++this.#mutationId,
1514
- options: client.defaultMutationOptions(options),
1515
- state
1516
- });
1517
- this.add(mutation);
1518
- return mutation;
1519
- }
1520
- add(mutation) {
1521
- this.#mutations.add(mutation);
1522
- const scope = scopeFor(mutation);
1523
- if (typeof scope === "string") {
1524
- const scopedMutations = this.#scopes.get(scope);
1525
- if (scopedMutations) {
1526
- scopedMutations.push(mutation);
1527
- } else {
1528
- this.#scopes.set(scope, [mutation]);
1529
- }
1530
- }
1531
- this.notify({ type: "added", mutation });
1532
- }
1533
- remove(mutation) {
1534
- if (this.#mutations.delete(mutation)) {
1535
- const scope = scopeFor(mutation);
1536
- if (typeof scope === "string") {
1537
- const scopedMutations = this.#scopes.get(scope);
1538
- if (scopedMutations) {
1539
- if (scopedMutations.length > 1) {
1540
- const index = scopedMutations.indexOf(mutation);
1541
- if (index !== -1) {
1542
- scopedMutations.splice(index, 1);
1543
- }
1544
- } else if (scopedMutations[0] === mutation) {
1545
- this.#scopes.delete(scope);
1546
- }
1547
- }
1548
- }
1549
- }
1550
- this.notify({ type: "removed", mutation });
1551
- }
1552
- canRun(mutation) {
1553
- const scope = scopeFor(mutation);
1554
- if (typeof scope === "string") {
1555
- const mutationsWithSameScope = this.#scopes.get(scope);
1556
- const firstPendingMutation = mutationsWithSameScope?.find(
1557
- (m) => m.state.status === "pending"
1558
- );
1559
- return !firstPendingMutation || firstPendingMutation === mutation;
1560
- } else {
1561
- return true;
1562
- }
1563
- }
1564
- runNext(mutation) {
1565
- const scope = scopeFor(mutation);
1566
- if (typeof scope === "string") {
1567
- const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);
1568
- return foundMutation?.continue() ?? Promise.resolve();
1569
- } else {
1570
- return Promise.resolve();
1571
- }
1572
- }
1573
- clear() {
1574
- notifyManager.batch(() => {
1575
- this.#mutations.forEach((mutation) => {
1576
- this.notify({ type: "removed", mutation });
1577
- });
1578
- this.#mutations.clear();
1579
- this.#scopes.clear();
1580
- });
1581
- }
1582
- getAll() {
1583
- return Array.from(this.#mutations);
1584
- }
1585
- find(filters) {
1586
- const defaultedFilters = { exact: true, ...filters };
1587
- return this.getAll().find(
1588
- (mutation) => matchMutation(defaultedFilters, mutation)
1589
- );
1590
- }
1591
- findAll(filters = {}) {
1592
- return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1593
- }
1594
- notify(event) {
1595
- notifyManager.batch(() => {
1596
- this.listeners.forEach((listener) => {
1597
- listener(event);
1598
- });
1599
- });
1600
- }
1601
- resumePausedMutations() {
1602
- const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1603
- return notifyManager.batch(
1604
- () => Promise.all(
1605
- pausedMutations.map((mutation) => mutation.continue().catch(noop))
1606
- )
1607
- );
1608
- }
1609
- };
1610
- function scopeFor(mutation) {
1611
- return mutation.options.scope?.id;
1612
- }
1613
-
1614
- // node_modules/@tanstack/query-core/build/modern/queryCache.js
1615
- var QueryCache = class extends Subscribable {
1616
- constructor(config2 = {}) {
1617
- super();
1618
- this.config = config2;
1619
- this.#queries = /* @__PURE__ */ new Map();
1620
- }
1621
- #queries;
1622
- build(client, options, state) {
1623
- const queryKey = options.queryKey;
1624
- const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
1625
- let query = this.get(queryHash);
1626
- if (!query) {
1627
- query = new Query({
1628
- client,
1629
- queryKey,
1630
- queryHash,
1631
- options: client.defaultQueryOptions(options),
1632
- state,
1633
- defaultOptions: client.getQueryDefaults(queryKey)
1634
- });
1635
- this.add(query);
1636
- }
1637
- return query;
1638
- }
1639
- add(query) {
1640
- if (!this.#queries.has(query.queryHash)) {
1641
- this.#queries.set(query.queryHash, query);
1642
- this.notify({
1643
- type: "added",
1644
- query
1645
- });
1646
- }
1647
- }
1648
- remove(query) {
1649
- const queryInMap = this.#queries.get(query.queryHash);
1650
- if (queryInMap) {
1651
- query.destroy();
1652
- if (queryInMap === query) {
1653
- this.#queries.delete(query.queryHash);
1654
- }
1655
- this.notify({ type: "removed", query });
1656
- }
1657
- }
1658
- clear() {
1659
- notifyManager.batch(() => {
1660
- this.getAll().forEach((query) => {
1661
- this.remove(query);
1662
- });
1663
- });
1664
- }
1665
- get(queryHash) {
1666
- return this.#queries.get(queryHash);
1667
- }
1668
- getAll() {
1669
- return [...this.#queries.values()];
1670
- }
1671
- find(filters) {
1672
- const defaultedFilters = { exact: true, ...filters };
1673
- return this.getAll().find(
1674
- (query) => matchQuery(defaultedFilters, query)
1675
- );
1676
- }
1677
- findAll(filters = {}) {
1678
- const queries = this.getAll();
1679
- return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1680
- }
1681
- notify(event) {
1682
- notifyManager.batch(() => {
1683
- this.listeners.forEach((listener) => {
1684
- listener(event);
1685
- });
1686
- });
1687
- }
1688
- onFocus() {
1689
- notifyManager.batch(() => {
1690
- this.getAll().forEach((query) => {
1691
- query.onFocus();
1692
- });
1693
- });
1694
- }
1695
- onOnline() {
1696
- notifyManager.batch(() => {
1697
- this.getAll().forEach((query) => {
1698
- query.onOnline();
1699
- });
1700
- });
1701
- }
1702
- };
1703
-
1704
- // node_modules/@tanstack/query-core/build/modern/queryClient.js
1705
- var QueryClient = class {
1706
- #queryCache;
1707
- #mutationCache;
1708
- #defaultOptions;
1709
- #queryDefaults;
1710
- #mutationDefaults;
1711
- #mountCount;
1712
- #unsubscribeFocus;
1713
- #unsubscribeOnline;
1714
- constructor(config2 = {}) {
1715
- this.#queryCache = config2.queryCache || new QueryCache();
1716
- this.#mutationCache = config2.mutationCache || new MutationCache();
1717
- this.#defaultOptions = config2.defaultOptions || {};
1718
- this.#queryDefaults = /* @__PURE__ */ new Map();
1719
- this.#mutationDefaults = /* @__PURE__ */ new Map();
1720
- this.#mountCount = 0;
1721
- }
1722
- mount() {
1723
- this.#mountCount++;
1724
- if (this.#mountCount !== 1) return;
1725
- this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
1726
- if (focused) {
1727
- await this.resumePausedMutations();
1728
- this.#queryCache.onFocus();
1729
- }
1730
- });
1731
- this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
1732
- if (online) {
1733
- await this.resumePausedMutations();
1734
- this.#queryCache.onOnline();
1735
- }
1736
- });
1737
- }
1738
- unmount() {
1739
- this.#mountCount--;
1740
- if (this.#mountCount !== 0) return;
1741
- this.#unsubscribeFocus?.();
1742
- this.#unsubscribeFocus = void 0;
1743
- this.#unsubscribeOnline?.();
1744
- this.#unsubscribeOnline = void 0;
1745
- }
1746
- isFetching(filters) {
1747
- return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
1748
- }
1749
- isMutating(filters) {
1750
- return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
1751
- }
1752
- /**
1753
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
1754
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1755
- *
1756
- * Hint: Do not use this function inside a component, because it won't receive updates.
1757
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1758
- */
1759
- getQueryData(queryKey) {
1760
- const options = this.defaultQueryOptions({ queryKey });
1761
- return this.#queryCache.get(options.queryHash)?.state.data;
1762
- }
1763
- ensureQueryData(options) {
1764
- const defaultedOptions = this.defaultQueryOptions(options);
1765
- const query = this.#queryCache.build(this, defaultedOptions);
1766
- const cachedData = query.state.data;
1767
- if (cachedData === void 0) {
1768
- return this.fetchQuery(options);
1769
- }
1770
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
1771
- void this.prefetchQuery(defaultedOptions);
1772
- }
1773
- return Promise.resolve(cachedData);
1774
- }
1775
- getQueriesData(filters) {
1776
- return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
1777
- const data = state.data;
1778
- return [queryKey, data];
1779
- });
1780
- }
1781
- setQueryData(queryKey, updater, options) {
1782
- const defaultedOptions = this.defaultQueryOptions({ queryKey });
1783
- const query = this.#queryCache.get(
1784
- defaultedOptions.queryHash
1785
- );
1786
- const prevData = query?.state.data;
1787
- const data = functionalUpdate(updater, prevData);
1788
- if (data === void 0) {
1789
- return void 0;
1790
- }
1791
- return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
1792
- }
1793
- setQueriesData(filters, updater, options) {
1794
- return notifyManager.batch(
1795
- () => this.#queryCache.findAll(filters).map(({ queryKey }) => [
1796
- queryKey,
1797
- this.setQueryData(queryKey, updater, options)
1798
- ])
1799
- );
1800
- }
1801
- getQueryState(queryKey) {
1802
- const options = this.defaultQueryOptions({ queryKey });
1803
- return this.#queryCache.get(
1804
- options.queryHash
1805
- )?.state;
1806
- }
1807
- removeQueries(filters) {
1808
- const queryCache = this.#queryCache;
1809
- notifyManager.batch(() => {
1810
- queryCache.findAll(filters).forEach((query) => {
1811
- queryCache.remove(query);
1812
- });
1813
- });
1814
- }
1815
- resetQueries(filters, options) {
1816
- const queryCache = this.#queryCache;
1817
- return notifyManager.batch(() => {
1818
- queryCache.findAll(filters).forEach((query) => {
1819
- query.reset();
1820
- });
1821
- return this.refetchQueries(
1822
- {
1823
- type: "active",
1824
- ...filters
1825
- },
1826
- options
1827
- );
1828
- });
1829
- }
1830
- cancelQueries(filters, cancelOptions = {}) {
1831
- const defaultedCancelOptions = { revert: true, ...cancelOptions };
1832
- const promises = notifyManager.batch(
1833
- () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
1834
- );
1835
- return Promise.all(promises).then(noop).catch(noop);
1836
- }
1837
- invalidateQueries(filters, options = {}) {
1838
- return notifyManager.batch(() => {
1839
- this.#queryCache.findAll(filters).forEach((query) => {
1840
- query.invalidate();
1841
- });
1842
- if (filters?.refetchType === "none") {
1843
- return Promise.resolve();
1844
- }
1845
- return this.refetchQueries(
1846
- {
1847
- ...filters,
1848
- type: filters?.refetchType ?? filters?.type ?? "active"
1849
- },
1850
- options
1851
- );
1852
- });
1853
- }
1854
- refetchQueries(filters, options = {}) {
1855
- const fetchOptions = {
1856
- ...options,
1857
- cancelRefetch: options.cancelRefetch ?? true
1858
- };
1859
- const promises = notifyManager.batch(
1860
- () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
1861
- let promise = query.fetch(void 0, fetchOptions);
1862
- if (!fetchOptions.throwOnError) {
1863
- promise = promise.catch(noop);
1864
- }
1865
- return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
1866
- })
1867
- );
1868
- return Promise.all(promises).then(noop);
1869
- }
1870
- fetchQuery(options) {
1871
- const defaultedOptions = this.defaultQueryOptions(options);
1872
- if (defaultedOptions.retry === void 0) {
1873
- defaultedOptions.retry = false;
1874
- }
1875
- const query = this.#queryCache.build(this, defaultedOptions);
1876
- return query.isStaleByTime(
1877
- resolveStaleTime(defaultedOptions.staleTime, query)
1878
- ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
1879
- }
1880
- prefetchQuery(options) {
1881
- return this.fetchQuery(options).then(noop).catch(noop);
1882
- }
1883
- fetchInfiniteQuery(options) {
1884
- options.behavior = infiniteQueryBehavior(options.pages);
1885
- return this.fetchQuery(options);
1886
- }
1887
- prefetchInfiniteQuery(options) {
1888
- return this.fetchInfiniteQuery(options).then(noop).catch(noop);
1889
- }
1890
- ensureInfiniteQueryData(options) {
1891
- options.behavior = infiniteQueryBehavior(options.pages);
1892
- return this.ensureQueryData(options);
1893
- }
1894
- resumePausedMutations() {
1895
- if (onlineManager.isOnline()) {
1896
- return this.#mutationCache.resumePausedMutations();
1897
- }
1898
- return Promise.resolve();
1899
- }
1900
- getQueryCache() {
1901
- return this.#queryCache;
1902
- }
1903
- getMutationCache() {
1904
- return this.#mutationCache;
1905
- }
1906
- getDefaultOptions() {
1907
- return this.#defaultOptions;
1908
- }
1909
- setDefaultOptions(options) {
1910
- this.#defaultOptions = options;
1911
- }
1912
- setQueryDefaults(queryKey, options) {
1913
- this.#queryDefaults.set(hashKey(queryKey), {
1914
- queryKey,
1915
- defaultOptions: options
1916
- });
1917
- }
1918
- getQueryDefaults(queryKey) {
1919
- const defaults = [...this.#queryDefaults.values()];
1920
- const result = {};
1921
- defaults.forEach((queryDefault) => {
1922
- if (partialMatchKey(queryKey, queryDefault.queryKey)) {
1923
- Object.assign(result, queryDefault.defaultOptions);
1924
- }
1925
- });
1926
- return result;
1927
- }
1928
- setMutationDefaults(mutationKey, options) {
1929
- this.#mutationDefaults.set(hashKey(mutationKey), {
1930
- mutationKey,
1931
- defaultOptions: options
1932
- });
1933
- }
1934
- getMutationDefaults(mutationKey) {
1935
- const defaults = [...this.#mutationDefaults.values()];
1936
- const result = {};
1937
- defaults.forEach((queryDefault) => {
1938
- if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
1939
- Object.assign(result, queryDefault.defaultOptions);
1940
- }
1941
- });
1942
- return result;
1943
- }
1944
- defaultQueryOptions(options) {
1945
- if (options._defaulted) {
1946
- return options;
1947
- }
1948
- const defaultedOptions = {
1949
- ...this.#defaultOptions.queries,
1950
- ...this.getQueryDefaults(options.queryKey),
1951
- ...options,
1952
- _defaulted: true
1953
- };
1954
- if (!defaultedOptions.queryHash) {
1955
- defaultedOptions.queryHash = hashQueryKeyByOptions(
1956
- defaultedOptions.queryKey,
1957
- defaultedOptions
1958
- );
1959
- }
1960
- if (defaultedOptions.refetchOnReconnect === void 0) {
1961
- defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
1962
- }
1963
- if (defaultedOptions.throwOnError === void 0) {
1964
- defaultedOptions.throwOnError = !!defaultedOptions.suspense;
1965
- }
1966
- if (!defaultedOptions.networkMode && defaultedOptions.persister) {
1967
- defaultedOptions.networkMode = "offlineFirst";
1968
- }
1969
- if (defaultedOptions.queryFn === skipToken) {
1970
- defaultedOptions.enabled = false;
1971
- }
1972
- return defaultedOptions;
1973
- }
1974
- defaultMutationOptions(options) {
1975
- if (options?._defaulted) {
1976
- return options;
1977
- }
1978
- return {
1979
- ...this.#defaultOptions.mutations,
1980
- ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
1981
- ...options,
1982
- _defaulted: true
1983
- };
1984
- }
1985
- clear() {
1986
- this.#queryCache.clear();
1987
- this.#mutationCache.clear();
1988
- }
1989
- };
1990
-
1991
- // node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
1992
- var React = __toESM(require("react"), 1);
1993
- var import_jsx_runtime = require("react/jsx-runtime");
1994
- var QueryClientContext = React.createContext(
1995
- void 0
1996
- );
1997
- var QueryClientProvider = ({
1998
- client,
1999
- children
2000
- }) => {
2001
- React.useEffect(() => {
2002
- client.mount();
2003
- return () => {
2004
- client.unmount();
2005
- };
2006
- }, [client]);
2007
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, { value: client, children });
2008
- };
2009
-
2010
- // wagmi__providers.tsx
2011
- var import_wagmi6 = require("wagmi");
2012
-
2013
- // config/walletConfig.ts
2014
- var import_wagmi = require("wagmi");
2015
- var import_chains = require("wagmi/chains");
2016
- var import_connectors = require("wagmi/connectors");
2017
-
2018
- // chains/core.ts
2019
- var import_viem = require("viem");
2020
-
2021
- // chains/base__sepolia.ts
2022
- var import_viem2 = require("viem");
2023
- function BaseSepolia() {
2024
- const baseSepolia = (0, import_viem2.defineChain)({
2025
- id: 84532,
2026
- name: "Base Sepolia",
2027
- network: "base-sepolia",
2028
- nativeCurrency: {
2029
- name: "Base Sepolia Ether",
2030
- symbol: "ETH",
2031
- decimals: 18
2032
- },
2033
- rpcUrls: {
2034
- default: {
2035
- http: [
2036
- process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || ""
2037
- ]
2038
- },
2039
- public: {
2040
- http: [
2041
- process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || ""
2042
- ]
2043
- }
2044
- },
2045
- blockExplorers: {
2046
- default: { name: "Basescan", url: "https://sepolia.basescan.org" }
2047
- },
2048
- testnet: true
2049
- });
2050
- return baseSepolia;
2051
- }
2052
-
2053
- // config/walletConfig.ts
2054
- var projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
2055
- var config = (0, import_wagmi.createConfig)({
2056
- chains: [import_chains.mainnet, import_chains.base, BaseSepolia()],
2057
- connectors: [
2058
- (0, import_connectors.walletConnect)({ projectId })
2059
- ],
2060
- transports: {
2061
- [import_chains.mainnet.id]: (0, import_wagmi.http)(),
2062
- [import_chains.base.id]: (0, import_wagmi.http)(),
2063
- [BaseSepolia().id]: (0, import_wagmi.http)()
2064
- }
2065
- });
2066
-
2067
- // config/Image.json
2068
- var Image_default = {
2069
- logo: "https://cordy-stack-x.vercel.app/logo.svg"
2070
- };
2071
-
2072
- // controllers/WagmiButton.tsx
2073
- var import_react = __toESM(require("react"));
2074
- var import_wagmi2 = require("wagmi");
2075
- var import_jsx_runtime2 = require("react/jsx-runtime");
2076
- function WalletButton({
2077
- onStatusChange
2078
- }) {
2079
- const { connectors, connectAsync, status } = (0, import_wagmi2.useConnect)();
2080
- const [pendingConnector, setPendingConnector] = import_react.default.useState(null);
2081
- const [errorMsg, setErrorMsg] = import_react.default.useState();
2082
- const isPending = status === "pending";
2083
- (0, import_react.useEffect)(() => {
2084
- if (onStatusChange) {
2085
- onStatusChange({
2086
- isPending,
2087
- error: errorMsg
2088
- });
2089
- }
2090
- }, [isPending, errorMsg, onStatusChange]);
2091
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: connectors.map((connector) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2092
- WalletOption,
2093
- {
2094
- connector,
2095
- onClick: async () => {
2096
- setPendingConnector(connector);
2097
- setErrorMsg(void 0);
2098
- try {
2099
- await connectAsync({ connector });
2100
- } catch (err) {
2101
- setErrorMsg(err?.message || "Connection failed");
2102
- } finally {
2103
- setPendingConnector(null);
2104
- }
2105
- },
2106
- isPending: pendingConnector?.uid === connector.uid && isPending
2107
- }
2108
- ) }, connector.uid)) });
2109
- }
2110
- function WalletOption({
2111
- connector,
2112
- onClick,
2113
- isPending
2114
- }) {
2115
- const [ready, setReady] = import_react.default.useState(false);
2116
- import_react.default.useEffect(() => {
2117
- (async () => {
2118
- const provider = await connector.getProvider();
2119
- setReady(!!provider);
2120
- })();
2121
- }, [connector]);
2122
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { disabled: !ready || isPending, onClick, children: isPending ? "Connecting..." : connector.name });
2123
- }
2124
-
2125
- // controllers/Disconnect.tsx
2126
- var import_wagmi3 = require("wagmi");
2127
- var import_jsx_runtime3 = require("react/jsx-runtime");
2128
- function Disconnect() {
2129
- const { disconnect } = (0, import_wagmi3.useDisconnect)();
2130
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { onClick: () => disconnect(), children: "Disconnect" });
2131
- }
2132
-
2133
- // controllers/Transactions.tsx
2134
- var import_ethers = require("ethers");
2135
-
2136
- // config/ERC20_ABI.json
2137
- var ERC20_ABI_default = [
2138
- {
2139
- constant: true,
2140
- inputs: [{ name: "owner", type: "address" }],
2141
- name: "balanceOf",
2142
- outputs: [{ name: "balance", type: "uint256" }],
2143
- type: "function"
2144
- },
2145
- {
2146
- constant: false,
2147
- inputs: [
2148
- { name: "to", type: "address" },
2149
- { name: "value", type: "uint256" }
2150
- ],
2151
- name: "transfer",
2152
- outputs: [{ name: "", type: "bool" }],
2153
- type: "function"
2154
- },
2155
- {
2156
- constant: true,
2157
- inputs: [],
2158
- name: "decimals",
2159
- outputs: [{ name: "", type: "uint8" }],
2160
- type: "function"
2161
- }
2162
- ];
2163
-
2164
- // controllers/Transactions.tsx
2165
- var tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
2166
- var platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
2167
- async function CordyStackTrans(address, cost) {
2168
- if (!address) return alert("Address Not Found");
2169
- try {
2170
- const provider = new import_ethers.ethers.BrowserProvider(window.ethereum);
2171
- const signer = await provider.getSigner();
2172
- const tokenContract = new import_ethers.ethers.Contract(tokenAddress, ERC20_ABI_default, signer);
2173
- const decimals = 18;
2174
- const amount = (0, import_ethers.parseUnits)(String(cost), decimals);
2175
- const balance = await tokenContract.balanceOf(await signer.getAddress());
2176
- if (balance < amount) {
2177
- return alert("Insuficient Funds");
2178
- }
2179
- const tx = await tokenContract.transfer(platformAddress, amount);
2180
- const receipt = await tx.wait();
2181
- if (receipt) {
2182
- return alert("Transactions Complete");
2183
- } else {
2184
- return alert("Transaction Failed");
2185
- }
2186
- } catch (err) {
2187
- console.error(err);
2188
- }
2189
- }
2190
-
2191
- // controllers/Get_Balance.tsx
2192
- var import_ethers2 = require("ethers");
2193
- async function getTokenBalance(address, tokenAddress2) {
2194
- if (!address) return "0";
2195
- try {
2196
- const provider = new import_ethers2.ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA);
2197
- const contract = new import_ethers2.ethers.Contract(tokenAddress2, ERC20_ABI_default, provider);
2198
- const balance = await contract.balanceOf(address);
2199
- return import_ethers2.ethers.formatUnits(balance, 18);
2200
- } catch (err) {
2201
- console.error("Error fetching token balance:", err);
2202
- return "0";
2203
- }
2204
- }
2205
-
2206
- // components/UI_Comp.tsx
2207
- var import_wagmi4 = require("wagmi");
2208
- var import_fa = require("react-icons/fa");
2209
- var import_react2 = require("react");
2210
- var import_jsx_runtime4 = require("react/jsx-runtime");
2211
- function UI_Comp() {
2212
- const { closeModal } = useWalletModal();
2213
- const { isConnected, address } = (0, import_wagmi4.useAccount)();
2214
- const [loading, setLoading] = (0, import_react2.useState)(false);
2215
- const [errorMsg, setErrorMsg] = (0, import_react2.useState)();
2216
- const [balance, setBalance] = (0, import_react2.useState)("");
2217
- (0, import_react2.useEffect)(() => {
2218
- Get_Balance();
2219
- }, [balance]);
2220
- const Get_Balance = async () => {
2221
- if (!address || !process.env.NEXT_PUBLIC_TOKENADDRESS) {
2222
- throw new Error("Address or token address is undefined");
2223
- }
2224
- const balance2 = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
2225
- setBalance(balance2);
2226
- return;
2227
- };
2228
- if (isConnected) {
2229
- if (balance === "") {
2230
- Get_Balance();
2231
- }
2232
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "container", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "connector", children: [
2233
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "closed", onClick: closeModal, children: "\u2715" }),
2234
- isConnected && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "info", children: balance ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
2235
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fa.FaUser, { size: 70 }),
2236
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { color: "#0f0" }, children: "Connected" }),
2237
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: { color: "#0ff" }, children: [
2238
- "Balance: ",
2239
- Number(balance).toFixed(2),
2240
- " ",
2241
- process.env.NEXT_PUBLIC_SYMBOL
2242
- ] }),
2243
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { color: "#ff0" }, children: address })
2244
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: { color: "var(--foreground_wagmi)" }, children: "Loading balance..." }) }),
2245
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Disconnect, {}),
2246
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })
2247
- ] }) });
2248
- }
2249
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "container", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "connector", children: [
2250
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "closed", onClick: closeModal, children: "\u2715" }),
2251
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: Image_default.logo, width: 50, height: 50 }),
2252
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { children: "Cordy MiniKit" }),
2253
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
2254
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: loading ? "Loading..." : "" }),
2255
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2256
- WalletButton,
2257
- {
2258
- onStatusChange: ({ isPending, error }) => {
2259
- setLoading(isPending);
2260
- setErrorMsg(error);
2261
- }
2262
- }
2263
- ),
2264
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: errorMsg })
2265
- ] }),
2266
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })
2267
- ] }) });
2268
- }
2269
-
2270
- // components/Connect_wallet_bt.tsx
2271
- var import_wagmi5 = require("wagmi");
2272
- var import_jsx_runtime5 = require("react/jsx-runtime");
2273
- function ConnectWalletBT() {
2274
- const { openModal } = useWalletModal();
2275
- const { isConnected, address } = (0, import_wagmi5.useAccount)();
2276
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2277
- "button",
2278
- {
2279
- className: "button__button",
2280
- onClick: openModal,
2281
- children: isConnected ? `Connected ${address}` : "Connect Wallet"
2282
- }
2283
- );
2284
- }
2285
-
2286
- // wagmi__providers.tsx
2287
- var import_jsx_runtime6 = require("react/jsx-runtime");
2288
- var WalletContext = (0, import_react3.createContext)(null);
2289
- var queryClient = new QueryClient();
2290
- function WalletProviders({ children }) {
2291
- const [open, setOpen] = (0, import_react3.useState)(false);
2292
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2293
- WalletContext.Provider,
2294
- {
2295
- value: {
2296
- openModal: () => setOpen(true),
2297
- closeModal: () => setOpen(false)
2298
- },
2299
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_wagmi6.WagmiProvider, { config, children: [
2300
- children,
2301
- open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UI_Comp, {}),
2302
- " "
2303
- ] })
2304
- }
2305
- ) });
2306
- }
2307
- function useWalletModal() {
2308
- const ctx = (0, import_react3.useContext)(WalletContext);
2309
- if (!ctx) throw new Error("Wrap in <WalletProviders>");
2310
- return ctx;
2311
- }
2312
- // Annotate the CommonJS export names for ESM import in node:
2313
- 0 && (module.exports = {
2314
- ConnectWalletBT,
2315
- CordyStackTrans,
2316
- Disconnect,
2317
- ProvidersClientWrapper,
2318
- UI_Comp,
2319
- WalletButton,
2320
- getTokenBalance
2321
- });
1
+ // Clients
2
+ export { default as ProvidersClientWrapper } from "./client__provider";
3
+ //Components
4
+ export * from "./components";
5
+ //Controllers
6
+ export * from "./controllers";