@turtleclub/hooks 0.3.0-beta.2 → 0.3.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +41 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/hooks/endpoints/index.ts +1 -0
- package/src/hooks/endpoints/useGeocheck.ts +28 -0
- package/src/index.ts +1 -0
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/dist-5BFEDBYI.js +0 -130
- package/dist/dist-5BFEDBYI.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,140 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// ../../node_modules/idb-keyval/dist/index.js
|
|
34
|
-
var dist_exports = {};
|
|
35
|
-
__export(dist_exports, {
|
|
36
|
-
clear: () => clear,
|
|
37
|
-
createStore: () => createStore,
|
|
38
|
-
del: () => del,
|
|
39
|
-
delMany: () => delMany,
|
|
40
|
-
entries: () => entries,
|
|
41
|
-
get: () => get,
|
|
42
|
-
getMany: () => getMany,
|
|
43
|
-
keys: () => keys2,
|
|
44
|
-
promisifyRequest: () => promisifyRequest,
|
|
45
|
-
set: () => set,
|
|
46
|
-
setMany: () => setMany,
|
|
47
|
-
update: () => update,
|
|
48
|
-
values: () => values
|
|
49
|
-
});
|
|
50
|
-
function promisifyRequest(request) {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
request.oncomplete = request.onsuccess = () => resolve(request.result);
|
|
53
|
-
request.onabort = request.onerror = () => reject(request.error);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function createStore(dbName, storeName) {
|
|
57
|
-
const request = indexedDB.open(dbName);
|
|
58
|
-
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
|
|
59
|
-
const dbp = promisifyRequest(request);
|
|
60
|
-
return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));
|
|
61
|
-
}
|
|
62
|
-
function defaultGetStore() {
|
|
63
|
-
if (!defaultGetStoreFunc) {
|
|
64
|
-
defaultGetStoreFunc = createStore("keyval-store", "keyval");
|
|
65
|
-
}
|
|
66
|
-
return defaultGetStoreFunc;
|
|
67
|
-
}
|
|
68
|
-
function get(key, customStore = defaultGetStore()) {
|
|
69
|
-
return customStore("readonly", (store) => promisifyRequest(store.get(key)));
|
|
70
|
-
}
|
|
71
|
-
function set(key, value, customStore = defaultGetStore()) {
|
|
72
|
-
return customStore("readwrite", (store) => {
|
|
73
|
-
store.put(value, key);
|
|
74
|
-
return promisifyRequest(store.transaction);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function setMany(entries2, customStore = defaultGetStore()) {
|
|
78
|
-
return customStore("readwrite", (store) => {
|
|
79
|
-
entries2.forEach((entry) => store.put(entry[1], entry[0]));
|
|
80
|
-
return promisifyRequest(store.transaction);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function getMany(keys3, customStore = defaultGetStore()) {
|
|
84
|
-
return customStore("readonly", (store) => Promise.all(keys3.map((key) => promisifyRequest(store.get(key)))));
|
|
85
|
-
}
|
|
86
|
-
function update(key, updater, customStore = defaultGetStore()) {
|
|
87
|
-
return customStore("readwrite", (store) => (
|
|
88
|
-
// Need to create the promise manually.
|
|
89
|
-
// If I try to chain promises, the transaction closes in browsers
|
|
90
|
-
// that use a promise polyfill (IE10/11).
|
|
91
|
-
new Promise((resolve, reject) => {
|
|
92
|
-
store.get(key).onsuccess = function() {
|
|
93
|
-
try {
|
|
94
|
-
store.put(updater(this.result), key);
|
|
95
|
-
resolve(promisifyRequest(store.transaction));
|
|
96
|
-
} catch (err) {
|
|
97
|
-
reject(err);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
})
|
|
101
|
-
));
|
|
102
|
-
}
|
|
103
|
-
function del(key, customStore = defaultGetStore()) {
|
|
104
|
-
return customStore("readwrite", (store) => {
|
|
105
|
-
store.delete(key);
|
|
106
|
-
return promisifyRequest(store.transaction);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function delMany(keys3, customStore = defaultGetStore()) {
|
|
110
|
-
return customStore("readwrite", (store) => {
|
|
111
|
-
keys3.forEach((key) => store.delete(key));
|
|
112
|
-
return promisifyRequest(store.transaction);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function clear(customStore = defaultGetStore()) {
|
|
116
|
-
return customStore("readwrite", (store) => {
|
|
117
|
-
store.clear();
|
|
118
|
-
return promisifyRequest(store.transaction);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function eachCursor(store, callback) {
|
|
122
|
-
store.openCursor().onsuccess = function() {
|
|
123
|
-
if (!this.result)
|
|
124
|
-
return;
|
|
125
|
-
callback(this.result);
|
|
126
|
-
this.result.continue();
|
|
127
|
-
};
|
|
128
|
-
return promisifyRequest(store.transaction);
|
|
129
|
-
}
|
|
130
|
-
function keys2(customStore = defaultGetStore()) {
|
|
131
|
-
return customStore("readonly", (store) => {
|
|
132
|
-
if (store.getAllKeys) {
|
|
133
|
-
return promisifyRequest(store.getAllKeys());
|
|
134
|
-
}
|
|
135
|
-
const items = [];
|
|
136
|
-
return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function values(customStore = defaultGetStore()) {
|
|
140
|
-
return customStore("readonly", (store) => {
|
|
141
|
-
if (store.getAll) {
|
|
142
|
-
return promisifyRequest(store.getAll());
|
|
143
|
-
}
|
|
144
|
-
const items = [];
|
|
145
|
-
return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function entries(customStore = defaultGetStore()) {
|
|
149
|
-
return customStore("readonly", (store) => {
|
|
150
|
-
if (store.getAll && store.getAllKeys) {
|
|
151
|
-
return Promise.all([
|
|
152
|
-
promisifyRequest(store.getAllKeys()),
|
|
153
|
-
promisifyRequest(store.getAll())
|
|
154
|
-
]).then(([keys3, values2]) => keys3.map((key, i) => [key, values2[i]]));
|
|
155
|
-
}
|
|
156
|
-
const items = [];
|
|
157
|
-
return customStore("readonly", (store2) => eachCursor(store2, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
var defaultGetStoreFunc;
|
|
161
|
-
var init_dist = __esm({
|
|
162
|
-
"../../node_modules/idb-keyval/dist/index.js"() {
|
|
163
|
-
"use strict";
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
30
|
// src/index.ts
|
|
168
31
|
var index_exports = {};
|
|
169
32
|
__export(index_exports, {
|
|
@@ -175,6 +38,7 @@ __export(index_exports, {
|
|
|
175
38
|
useEarnRoute: () => useEarnRoute,
|
|
176
39
|
useEarnWalletBalances: () => useEarnWalletBalances,
|
|
177
40
|
useExists: () => useExists,
|
|
41
|
+
useGeocheck: () => useGeocheck,
|
|
178
42
|
useIndexerTvl: () => useIndexerTvl,
|
|
179
43
|
useOrganizationDeals: () => useOrganizationDeals,
|
|
180
44
|
useOrganizations: () => useOrganizations,
|
|
@@ -559,6 +423,26 @@ function usePartnerDeals(options, { config, queryClient } = {}) {
|
|
|
559
423
|
return query2;
|
|
560
424
|
}
|
|
561
425
|
|
|
426
|
+
// src/hooks/endpoints/useGeocheck.ts
|
|
427
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
428
|
+
var import_api16 = require("@turtleclub/api");
|
|
429
|
+
function useGeocheck({ config, queryClient } = {}) {
|
|
430
|
+
const defaultConfig2 = useConfig();
|
|
431
|
+
const query2 = (0, import_react_query16.useQuery)({
|
|
432
|
+
queryKey: ["geocheck"],
|
|
433
|
+
queryFn: async () => {
|
|
434
|
+
return await (0, import_api16.geocheck)(config ?? defaultConfig2);
|
|
435
|
+
},
|
|
436
|
+
staleTime: 5 * 60 * 1e3,
|
|
437
|
+
// 5 minutes
|
|
438
|
+
gcTime: 10 * 60 * 1e3,
|
|
439
|
+
// 10 minutes
|
|
440
|
+
refetchOnWindowFocus: false,
|
|
441
|
+
retry: 1
|
|
442
|
+
}, queryClient ?? defaultQueryClient);
|
|
443
|
+
return query2;
|
|
444
|
+
}
|
|
445
|
+
|
|
562
446
|
// src/campaigns-v2/index.ts
|
|
563
447
|
var campaigns_v2_exports = {};
|
|
564
448
|
__export(campaigns_v2_exports, {
|
|
@@ -592,13 +476,13 @@ __export(campaigns_v2_exports, {
|
|
|
592
476
|
var import_react3 = require("react");
|
|
593
477
|
var import_wagmi = require("wagmi");
|
|
594
478
|
var import_viem3 = require("viem");
|
|
595
|
-
var
|
|
479
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
596
480
|
|
|
597
481
|
// src/campaigns-v2/useCampaign.ts
|
|
598
482
|
var import_react2 = require("react");
|
|
599
483
|
|
|
600
484
|
// src/campaigns-v2/api/builder/hooks.ts
|
|
601
|
-
var
|
|
485
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
602
486
|
var import_react = require("react");
|
|
603
487
|
var import_lodash = __toESM(require("lodash"), 1);
|
|
604
488
|
var appVersion = typeof __COMMIT_HASH__ !== "undefined" ? __COMMIT_HASH__ : "default-version";
|
|
@@ -608,7 +492,7 @@ function buildHooks(map, defaults = {}) {
|
|
|
608
492
|
const hookItem = map[key];
|
|
609
493
|
const rawKey = key;
|
|
610
494
|
result[key] = function(...args) {
|
|
611
|
-
return (0,
|
|
495
|
+
return (0, import_react_query17.useQuery)(
|
|
612
496
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
613
497
|
(0, import_react.useMemo)(
|
|
614
498
|
() => query(hookItem, rawKey, defaults, args),
|
|
@@ -620,7 +504,7 @@ function buildHooks(map, defaults = {}) {
|
|
|
620
504
|
}
|
|
621
505
|
const multicall = {
|
|
622
506
|
multicall(list) {
|
|
623
|
-
return (0,
|
|
507
|
+
return (0, import_react_query17.useQueries)({
|
|
624
508
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
625
509
|
queries: (0, import_react.useMemo)(() => list.map(([rawKey, ...args]) => query(map[rawKey], rawKey, defaults, args)), [list])
|
|
626
510
|
});
|
|
@@ -685,6 +569,10 @@ function isReadonlyArray(value) {
|
|
|
685
569
|
return Array.isArray(value);
|
|
686
570
|
}
|
|
687
571
|
|
|
572
|
+
// src/campaigns-v2/utils/cn.ts
|
|
573
|
+
var import_clsx = require("clsx");
|
|
574
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
575
|
+
|
|
688
576
|
// src/campaigns-v2/utils/debank.ts
|
|
689
577
|
var import_chains = require("wagmi/chains");
|
|
690
578
|
|
|
@@ -768,7 +656,7 @@ function keys(obj) {
|
|
|
768
656
|
var idbKeyval = null;
|
|
769
657
|
if (typeof navigator === "undefined" || !navigator.userAgent.includes("Brave")) {
|
|
770
658
|
try {
|
|
771
|
-
|
|
659
|
+
import("idb-keyval").then((module2) => {
|
|
772
660
|
idbKeyval = module2;
|
|
773
661
|
}).catch((err) => {
|
|
774
662
|
console.warn("[Storage] Failed to load idb-keyval:", err);
|
|
@@ -827,7 +715,7 @@ var import_zustand = require("zustand");
|
|
|
827
715
|
var import_middleware = require("zustand/middleware");
|
|
828
716
|
var useAuthTokensStore = (0, import_zustand.create)()(
|
|
829
717
|
(0, import_middleware.persist)(
|
|
830
|
-
(
|
|
718
|
+
(set, get) => ({
|
|
831
719
|
tokens: null,
|
|
832
720
|
currentAddress: null,
|
|
833
721
|
setTokens: (address, tokens) => {
|
|
@@ -839,29 +727,29 @@ var useAuthTokensStore = (0, import_zustand.create)()(
|
|
|
839
727
|
refreshToken: tokens.refreshToken,
|
|
840
728
|
refreshTokenExpiresAt
|
|
841
729
|
};
|
|
842
|
-
|
|
730
|
+
set({
|
|
843
731
|
tokens: authTokens,
|
|
844
732
|
currentAddress: address.toLowerCase()
|
|
845
733
|
});
|
|
846
734
|
},
|
|
847
735
|
getTokens: () => {
|
|
848
|
-
return
|
|
736
|
+
return get().tokens;
|
|
849
737
|
},
|
|
850
738
|
clearTokens: () => {
|
|
851
|
-
|
|
739
|
+
set({
|
|
852
740
|
tokens: null,
|
|
853
741
|
currentAddress: null
|
|
854
742
|
});
|
|
855
743
|
},
|
|
856
744
|
isAuthenticated: () => {
|
|
857
|
-
return
|
|
745
|
+
return get().tokens !== null;
|
|
858
746
|
},
|
|
859
747
|
getAccessToken: () => {
|
|
860
|
-
const { tokens } =
|
|
748
|
+
const { tokens } = get();
|
|
861
749
|
return tokens?.accessToken || null;
|
|
862
750
|
},
|
|
863
751
|
getRefreshToken: () => {
|
|
864
|
-
const { tokens } =
|
|
752
|
+
const { tokens } = get();
|
|
865
753
|
return tokens?.refreshToken || null;
|
|
866
754
|
}
|
|
867
755
|
}),
|
|
@@ -4122,7 +4010,7 @@ function useEvmCampaignPositions({
|
|
|
4122
4010
|
isLoading,
|
|
4123
4011
|
error: queryError,
|
|
4124
4012
|
refetch: refetchUserPositions
|
|
4125
|
-
} = (0,
|
|
4013
|
+
} = (0, import_react_query18.useQuery)({
|
|
4126
4014
|
queryKey: ["positions", userAddress, campaignName, configs?.length],
|
|
4127
4015
|
queryFn: async () => {
|
|
4128
4016
|
if (!configs || !prices) {
|
|
@@ -4381,7 +4269,7 @@ function useEvmCampaignPositions({
|
|
|
4381
4269
|
|
|
4382
4270
|
// src/campaigns-v2/useTonCampaignPositions.ts
|
|
4383
4271
|
var import_react4 = require("react");
|
|
4384
|
-
var
|
|
4272
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
4385
4273
|
var import_ton = require("@ton/ton");
|
|
4386
4274
|
function useTonCampaignPositions({
|
|
4387
4275
|
campaignName,
|
|
@@ -4404,7 +4292,7 @@ function useTonCampaignPositions({
|
|
|
4404
4292
|
isLoading,
|
|
4405
4293
|
error: queryError,
|
|
4406
4294
|
refetch: refetchUserPositions
|
|
4407
|
-
} = (0,
|
|
4295
|
+
} = (0, import_react_query19.useQuery)({
|
|
4408
4296
|
queryKey: ["ton-positions", userAddress, campaignName, tonVaults.length],
|
|
4409
4297
|
queryFn: async () => {
|
|
4410
4298
|
if (!userAddress || tonVaults.length === 0) {
|
|
@@ -4540,6 +4428,7 @@ function useUserCampaignPositions({
|
|
|
4540
4428
|
useEarnRoute,
|
|
4541
4429
|
useEarnWalletBalances,
|
|
4542
4430
|
useExists,
|
|
4431
|
+
useGeocheck,
|
|
4543
4432
|
useIndexerTvl,
|
|
4544
4433
|
useOrganizationDeals,
|
|
4545
4434
|
useOrganizations,
|