@turtleclub/hooks 0.1.1-beta.0 → 0.2.0-beta.0
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 +36 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/hooks/endpoints/earn/index.ts +1 -0
- package/src/hooks/endpoints/earn/useCampaigns.ts +34 -0
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
defaultQueryClient: () => defaultQueryClient,
|
|
24
24
|
useConfig: () => useConfig,
|
|
25
|
+
useEarnCampaigns: () => useEarnCampaigns,
|
|
25
26
|
useEarnDeals: () => useEarnDeals,
|
|
26
27
|
useEarnRoute: () => useEarnRoute,
|
|
27
28
|
useEarnWalletBalances: () => useEarnWalletBalances,
|
|
@@ -204,13 +205,36 @@ function useSignup(options, { config, queryClient } = {}) {
|
|
|
204
205
|
return mutation;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
// src/hooks/endpoints/earn/
|
|
208
|
+
// src/hooks/endpoints/earn/useCampaigns.ts
|
|
208
209
|
var import_react_query9 = require("@tanstack/react-query");
|
|
209
210
|
var import_api9 = require("@turtleclub/api");
|
|
211
|
+
function useEarnCampaigns(options, { config, queryClient } = {}) {
|
|
212
|
+
const defaultConfig2 = useConfig();
|
|
213
|
+
const enabled = true;
|
|
214
|
+
const query = (0, import_react_query9.useQuery)({
|
|
215
|
+
queryKey: [
|
|
216
|
+
"earn-campaigns",
|
|
217
|
+
options?.idFilter,
|
|
218
|
+
options?.protocolFilter
|
|
219
|
+
],
|
|
220
|
+
queryFn: async () => {
|
|
221
|
+
return await (0, import_api9.earnCampaigns)(options || {}, config ?? defaultConfig2);
|
|
222
|
+
},
|
|
223
|
+
enabled,
|
|
224
|
+
staleTime: 60 * 1e3,
|
|
225
|
+
refetchInterval: 30 * 1e3,
|
|
226
|
+
refetchOnWindowFocus: true
|
|
227
|
+
}, queryClient ?? defaultQueryClient);
|
|
228
|
+
return query;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/hooks/endpoints/earn/useDeals.ts
|
|
232
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
233
|
+
var import_api10 = require("@turtleclub/api");
|
|
210
234
|
function useEarnDeals(options, { config, queryClient } = {}) {
|
|
211
235
|
const defaultConfig2 = useConfig();
|
|
212
236
|
const enabled = options !== void 0;
|
|
213
|
-
const query = (0,
|
|
237
|
+
const query = (0, import_react_query10.useQuery)({
|
|
214
238
|
queryKey: [
|
|
215
239
|
"earn-deals",
|
|
216
240
|
options?.campaignId,
|
|
@@ -220,7 +244,7 @@ function useEarnDeals(options, { config, queryClient } = {}) {
|
|
|
220
244
|
queryFn: async () => {
|
|
221
245
|
if (!enabled)
|
|
222
246
|
return null;
|
|
223
|
-
return await (0,
|
|
247
|
+
return await (0, import_api10.earnDeals)(options, config ?? defaultConfig2);
|
|
224
248
|
},
|
|
225
249
|
enabled,
|
|
226
250
|
staleTime: 60 * 1e3,
|
|
@@ -231,12 +255,12 @@ function useEarnDeals(options, { config, queryClient } = {}) {
|
|
|
231
255
|
}
|
|
232
256
|
|
|
233
257
|
// src/hooks/endpoints/earn/useRoute.ts
|
|
234
|
-
var
|
|
235
|
-
var
|
|
258
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
259
|
+
var import_api11 = require("@turtleclub/api");
|
|
236
260
|
function useEarnRoute(options, { config, queryClient } = {}) {
|
|
237
261
|
const defaultConfig2 = useConfig();
|
|
238
262
|
const enabled = options !== void 0;
|
|
239
|
-
const query = (0,
|
|
263
|
+
const query = (0, import_react_query11.useQuery)({
|
|
240
264
|
queryKey: [
|
|
241
265
|
"earnRoute",
|
|
242
266
|
options?.user,
|
|
@@ -249,7 +273,7 @@ function useEarnRoute(options, { config, queryClient } = {}) {
|
|
|
249
273
|
queryFn: async () => {
|
|
250
274
|
if (!enabled)
|
|
251
275
|
return null;
|
|
252
|
-
return await (0,
|
|
276
|
+
return await (0, import_api11.earnRoute)(options, config ?? defaultConfig2);
|
|
253
277
|
},
|
|
254
278
|
enabled,
|
|
255
279
|
staleTime: 2 * 60 * 1e3,
|
|
@@ -262,17 +286,17 @@ function useEarnRoute(options, { config, queryClient } = {}) {
|
|
|
262
286
|
}
|
|
263
287
|
|
|
264
288
|
// src/hooks/endpoints/earn/useWalletBalances.ts
|
|
265
|
-
var
|
|
266
|
-
var
|
|
289
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
290
|
+
var import_api12 = require("@turtleclub/api");
|
|
267
291
|
function useEarnWalletBalances(options, { config, queryClient } = {}) {
|
|
268
292
|
const defaultConfig2 = useConfig();
|
|
269
293
|
const enabled = options !== void 0;
|
|
270
|
-
const query = (0,
|
|
294
|
+
const query = (0, import_react_query12.useQuery)(
|
|
271
295
|
{
|
|
272
296
|
queryKey: ["earnWalletBalances", options?.chain, options?.user],
|
|
273
297
|
queryFn: async () => {
|
|
274
298
|
if (!enabled) return null;
|
|
275
|
-
return await (0,
|
|
299
|
+
return await (0, import_api12.earnWalletBalances)(options, config ?? defaultConfig2);
|
|
276
300
|
},
|
|
277
301
|
enabled,
|
|
278
302
|
staleTime: 30 * 1e3,
|
|
@@ -287,6 +311,7 @@ function useEarnWalletBalances(options, { config, queryClient } = {}) {
|
|
|
287
311
|
0 && (module.exports = {
|
|
288
312
|
defaultQueryClient,
|
|
289
313
|
useConfig,
|
|
314
|
+
useEarnCampaigns,
|
|
290
315
|
useEarnDeals,
|
|
291
316
|
useEarnRoute,
|
|
292
317
|
useEarnWalletBalances,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/useConfig.ts","../src/hooks/client.ts","../src/hooks/endpoints/useOrganizations.ts","../src/hooks/endpoints/useExists.ts","../src/hooks/endpoints/useOrganizationDeals.ts","../src/hooks/endpoints/useOrganizationsDeals.ts","../src/hooks/endpoints/usePrepareSignup.ts","../src/hooks/endpoints/useProjectTvl.ts","../src/hooks/endpoints/useSignup.ts","../src/hooks/endpoints/earn/useDeals.ts","../src/hooks/endpoints/earn/useRoute.ts","../src/hooks/endpoints/earn/useWalletBalances.ts"],"sourcesContent":["// TODO: delete - prerelease trigger\n// Hooks\nexport * from \"./hooks/useConfig\";\nexport * from \"./hooks/client\";\n\n// Endpoint hooks\nexport * from \"./hooks/endpoints/useOrganizations\";\nexport * from \"./hooks/endpoints/useExists\";\nexport * from \"./hooks/endpoints/useOrganizationDeals\";\nexport * from \"./hooks/endpoints/useOrganizationsDeals\";\nexport * from \"./hooks/endpoints/usePrepareSignup\";\nexport * from \"./hooks/endpoints/useProjectTvl\";\nexport * from \"./hooks/endpoints/useSignup\";\n\n// Earn hooks\nexport * from \"./hooks/endpoints/earn\";\n","import type { Config } from \"@turtleclub/api\";\nimport { defaultConfig } from \"@turtleclub/api\";\n\nexport function useConfig(): Config {\n // Placeholder implementation - in real app this would use TurtleProvider context\n return defaultConfig;\n}\n","import { createSyncStoragePersister } from \"@tanstack/query-sync-storage-persister\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClient } from \"@tanstack/react-query-persist-client\";\n\nexport const defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// Only persist on client side\nif (typeof window !== 'undefined') {\n const localStoragePersister = createSyncStoragePersister({\n storage: window.localStorage,\n key: \"turtle-sdk\",\n });\n\n persistQueryClient({\n queryClient: defaultQueryClient,\n persister: localStoragePersister,\n });\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organization, type OrganizationResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizations({\n config,\n queryClient,\n}: UseOrganizationsOptions = {}): UseQueryResult<OrganizationResponse | null> {\n const defaultConfig = useConfig();\n\n const query = useQuery(\n {\n queryKey: [\"organizations\"],\n queryFn: async () => {\n return await organization(config ?? defaultConfig);\n },\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, exists, type ExistsOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseExistsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useExists(\n options?: ExistsOptions,\n { config, queryClient }: UseExistsOptions = {},\n): UseQueryResult<boolean | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"exists\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await exists(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationDeals, type OrganizationDealsOptions, type OrganizationDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationDeals(\n options?: OrganizationDealsOptions,\n { config, queryClient }: UseOrganizationDealsOptions = {},\n): UseQueryResult<OrganizationDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationDeals\", options?.organizationId],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationsDeals, type OrganizationsDealsOptions, type OrganizationsDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationsDeals(\n options?: OrganizationsDealsOptions,\n { config, queryClient }: UseOrganizationsDealsOptions = {},\n): UseQueryResult<OrganizationsDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationsDeals\", options?.organizationIds],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationsDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n throwOnError: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, prepareSignup, type PrepareSignupOptions, type PrepareSignupResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UsePrepareSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function usePrepareSignup(\n options?: PrepareSignupOptions,\n { config, queryClient }: UsePrepareSignupOptions = {},\n): UseQueryResult<PrepareSignupResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"prepareSignup\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await prepareSignup(options, config ?? defaultConfig);\n },\n enabled,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, projectTvl, type ProjectTvlOptions, type ProjectTvlResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseProjectTvlOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useProjectTvl(\n options?: ProjectTvlOptions,\n { config, queryClient }: UseProjectTvlOptions = {},\n): UseQueryResult<ProjectTvlResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"projectTvl\", options?.projects],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await projectTvl(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 7 * 60 * 1000,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import {\n type QueryClient,\n useMutation,\n type UseMutationResult,\n useQuery,\n} from \"@tanstack/react-query\";\nimport { type Config, signup, type SignupOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useSignup(\n options?: Omit<SignupOptions, \"signature\">,\n { config, queryClient }: UseSignupOptions = {}\n): UseMutationResult<boolean | null, Error, string, unknown> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const mutation = useMutation(\n {\n mutationFn: async (signature: string) => {\n if (!enabled) return null;\n\n return await signup({ ...options, signature }, config ?? defaultConfig);\n },\n },\n queryClient ?? defaultQueryClient\n );\n\n return mutation;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnDeals, type EarnDealsOptions, type EarnDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnDeals(\n options?: EarnDealsOptions,\n { config, queryClient }: UseEarnDealsOptions = {},\n): UseQueryResult<EarnDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earn-deals\",\n options?.campaignId,\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnRoute, type EarnRouteOptions, type EarnRouteResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnRouteOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnRoute(\n options?: EarnRouteOptions,\n { config, queryClient }: UseEarnRouteOptions = {},\n): UseQueryResult<EarnRouteResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earnRoute\",\n options?.user,\n options?.chain,\n options?.slippage,\n options?.tokenIn,\n options?.tokenOut,\n options?.amount,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnRoute(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000, // 2 minutes - longer stale time for transaction stability\n refetchInterval: false, // Disable automatic refetch to prevent transaction state reset\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport {\n type Config,\n earnWalletBalances,\n type EarnWalletBalancesOptions,\n type EarnWalletBalancesResponse,\n} from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnWalletBalancesOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnWalletBalances(\n options?: EarnWalletBalancesOptions,\n { config, queryClient }: UseEarnWalletBalancesOptions = {}\n): UseQueryResult<EarnWalletBalancesResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery(\n {\n queryKey: [\"earnWalletBalances\", options?.chain, options?.user],\n queryFn: async () => {\n if (!enabled) return null;\n\n return await earnWalletBalances(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 30 * 1000,\n refetchInterval: 15 * 1000,\n refetchOnWindowFocus: true,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAA8B;AAEvB,SAAS,YAAoB;AAElC,SAAO;AACT;;;ACNA,0CAA2C;AAC3C,yBAA4B;AAC5B,wCAAmC;AAE5B,IAAM,qBAAqB,IAAI,+BAAY;AAAA,EAChD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF,CAAC;AAGD,IAAI,OAAO,WAAW,aAAa;AACjC,QAAM,4BAAwB,gEAA2B;AAAA,IACvD,SAAS,OAAO;AAAA,IAChB,KAAK;AAAA,EACP,CAAC;AAED,4DAAmB;AAAA,IACjB,aAAa;AAAA,IACb,WAAW;AAAA,EACb,CAAC;AACH;;;ACvBA,IAAAA,sBAAgE;AAChE,IAAAC,cAAqE;AAS9D,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,IAA6B,CAAC,GAAgD;AAC5E,QAAMC,iBAAgB,UAAU;AAEhC,QAAM,YAAQ;AAAA,IACZ;AAAA,MACE,UAAU,CAAC,eAAe;AAAA,MAC1B,SAAS,YAAY;AACnB,eAAO,UAAM,0BAAa,UAAUA,cAAa;AAAA,MACnD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AAI,CAAC;AACH,eAAO;AAET,aAAO,UAAM,wBAAU,SAAS,UAAUA,cAAa;AAAA,IACzD;AAAA,IACA;AAAA,IACA,WAAW,IAAI,KAAK;AAAA;AAAA,IACpB,iBAAiB;AAAA;AAAA,IACjB,sBAAsB;AAAA,EACxB,GAAG,eAAe,kBAAkB;AAEpC,SAAO;AACT;;;ACxCA,IAAAC,uBAAgE;AAChE,IAAAC,eAKO;AASA,SAAS,sBACd,SACA,EAAE,QAAQ,YAAY,IAAkC,CAAC,GACN;AACnD,QAAMC,iBAAgB,UAAU;AAChC,QAAM,UAAU,YAAY;AAE5B,QAAM,YAAQ;AAAA,IACZ;AAAA,MACE,UAAU,CAAC,sBAAsB,SAAS,OAAO,SAAS,IAAI;AAAA,MAC9D,SAAS,YAAY;AACnB,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,UAAM,iCAAmB,SAAS,UAAUA,cAAa;AAAA,MAClE;AAAA,MACA;AAAA,MACA,WAAW,KAAK;AAAA,MAChB,iBAAiB,KAAK;AAAA,MACtB,sBAAsB;AAAA,IACxB;AAAA,IACA,eAAe;AAAA,EACjB;AAEA,SAAO;AACT;","names":["import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useConfig.ts","../src/hooks/client.ts","../src/hooks/endpoints/useOrganizations.ts","../src/hooks/endpoints/useExists.ts","../src/hooks/endpoints/useOrganizationDeals.ts","../src/hooks/endpoints/useOrganizationsDeals.ts","../src/hooks/endpoints/usePrepareSignup.ts","../src/hooks/endpoints/useProjectTvl.ts","../src/hooks/endpoints/useSignup.ts","../src/hooks/endpoints/earn/useCampaigns.ts","../src/hooks/endpoints/earn/useDeals.ts","../src/hooks/endpoints/earn/useRoute.ts","../src/hooks/endpoints/earn/useWalletBalances.ts"],"sourcesContent":["// TODO: delete - prerelease trigger\n// Hooks\nexport * from \"./hooks/useConfig\";\nexport * from \"./hooks/client\";\n\n// Endpoint hooks\nexport * from \"./hooks/endpoints/useOrganizations\";\nexport * from \"./hooks/endpoints/useExists\";\nexport * from \"./hooks/endpoints/useOrganizationDeals\";\nexport * from \"./hooks/endpoints/useOrganizationsDeals\";\nexport * from \"./hooks/endpoints/usePrepareSignup\";\nexport * from \"./hooks/endpoints/useProjectTvl\";\nexport * from \"./hooks/endpoints/useSignup\";\n\n// Earn hooks\nexport * from \"./hooks/endpoints/earn\";\n","import type { Config } from \"@turtleclub/api\";\nimport { defaultConfig } from \"@turtleclub/api\";\n\nexport function useConfig(): Config {\n // Placeholder implementation - in real app this would use TurtleProvider context\n return defaultConfig;\n}\n","import { createSyncStoragePersister } from \"@tanstack/query-sync-storage-persister\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClient } from \"@tanstack/react-query-persist-client\";\n\nexport const defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// Only persist on client side\nif (typeof window !== 'undefined') {\n const localStoragePersister = createSyncStoragePersister({\n storage: window.localStorage,\n key: \"turtle-sdk\",\n });\n\n persistQueryClient({\n queryClient: defaultQueryClient,\n persister: localStoragePersister,\n });\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organization, type OrganizationResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizations({\n config,\n queryClient,\n}: UseOrganizationsOptions = {}): UseQueryResult<OrganizationResponse | null> {\n const defaultConfig = useConfig();\n\n const query = useQuery(\n {\n queryKey: [\"organizations\"],\n queryFn: async () => {\n return await organization(config ?? defaultConfig);\n },\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, exists, type ExistsOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseExistsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useExists(\n options?: ExistsOptions,\n { config, queryClient }: UseExistsOptions = {},\n): UseQueryResult<boolean | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"exists\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await exists(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationDeals, type OrganizationDealsOptions, type OrganizationDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationDeals(\n options?: OrganizationDealsOptions,\n { config, queryClient }: UseOrganizationDealsOptions = {},\n): UseQueryResult<OrganizationDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationDeals\", options?.organizationId],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationsDeals, type OrganizationsDealsOptions, type OrganizationsDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationsDeals(\n options?: OrganizationsDealsOptions,\n { config, queryClient }: UseOrganizationsDealsOptions = {},\n): UseQueryResult<OrganizationsDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationsDeals\", options?.organizationIds],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationsDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n throwOnError: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, prepareSignup, type PrepareSignupOptions, type PrepareSignupResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UsePrepareSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function usePrepareSignup(\n options?: PrepareSignupOptions,\n { config, queryClient }: UsePrepareSignupOptions = {},\n): UseQueryResult<PrepareSignupResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"prepareSignup\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await prepareSignup(options, config ?? defaultConfig);\n },\n enabled,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, projectTvl, type ProjectTvlOptions, type ProjectTvlResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseProjectTvlOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useProjectTvl(\n options?: ProjectTvlOptions,\n { config, queryClient }: UseProjectTvlOptions = {},\n): UseQueryResult<ProjectTvlResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"projectTvl\", options?.projects],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await projectTvl(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 7 * 60 * 1000,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import {\n type QueryClient,\n useMutation,\n type UseMutationResult,\n useQuery,\n} from \"@tanstack/react-query\";\nimport { type Config, signup, type SignupOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useSignup(\n options?: Omit<SignupOptions, \"signature\">,\n { config, queryClient }: UseSignupOptions = {}\n): UseMutationResult<boolean | null, Error, string, unknown> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const mutation = useMutation(\n {\n mutationFn: async (signature: string) => {\n if (!enabled) return null;\n\n return await signup({ ...options, signature }, config ?? defaultConfig);\n },\n },\n queryClient ?? defaultQueryClient\n );\n\n return mutation;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnCampaigns, type EarnCampaignsOptions, type EarnCampaignWithVaults } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnCampaignsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnCampaigns(\n options?: EarnCampaignsOptions,\n { config, queryClient }: UseEarnCampaignsOptions = {},\n): UseQueryResult<EarnCampaignWithVaults[] | null> {\n const defaultConfig = useConfig();\n const enabled = true; // Always enabled for campaigns\n\n const query = useQuery({\n queryKey: [\n \"earn-campaigns\",\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n return await earnCampaigns(options || {}, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnDeals, type EarnDealsOptions, type EarnDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnDeals(\n options?: EarnDealsOptions,\n { config, queryClient }: UseEarnDealsOptions = {},\n): UseQueryResult<EarnDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earn-deals\",\n options?.campaignId,\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnRoute, type EarnRouteOptions, type EarnRouteResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnRouteOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnRoute(\n options?: EarnRouteOptions,\n { config, queryClient }: UseEarnRouteOptions = {},\n): UseQueryResult<EarnRouteResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earnRoute\",\n options?.user,\n options?.chain,\n options?.slippage,\n options?.tokenIn,\n options?.tokenOut,\n options?.amount,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnRoute(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000, // 2 minutes - longer stale time for transaction stability\n refetchInterval: false, // Disable automatic refetch to prevent transaction state reset\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport {\n type Config,\n earnWalletBalances,\n type EarnWalletBalancesOptions,\n type EarnWalletBalancesResponse,\n} from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnWalletBalancesOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnWalletBalances(\n options?: EarnWalletBalancesOptions,\n { config, queryClient }: UseEarnWalletBalancesOptions = {}\n): UseQueryResult<EarnWalletBalancesResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery(\n {\n queryKey: [\"earnWalletBalances\", options?.chain, options?.user],\n queryFn: async () => {\n if (!enabled) return null;\n\n return await earnWalletBalances(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 30 * 1000,\n refetchInterval: 15 * 1000,\n refetchOnWindowFocus: true,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAA8B;AAEvB,SAAS,YAAoB;AAElC,SAAO;AACT;;;ACNA,0CAA2C;AAC3C,yBAA4B;AAC5B,wCAAmC;AAE5B,IAAM,qBAAqB,IAAI,+BAAY;AAAA,EAChD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,E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AS,sBACd,SACA,EAAE,QAAQ,YAAY,IAAkC,CAAC,GACN;AACnD,QAAMC,iBAAgB,UAAU;AAChC,QAAM,UAAU,YAAY;AAE5B,QAAM,YAAQ;AAAA,IACZ;AAAA,MACE,UAAU,CAAC,sBAAsB,SAAS,OAAO,SAAS,IAAI;AAAA,MAC9D,SAAS,YAAY;AACnB,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,UAAM,iCAAmB,SAAS,UAAUA,cAAa;AAAA,MAClE;AAAA,MACA;AAAA,MACA,WAAW,KAAK;AAAA,MAChB,iBAAiB,KAAK;AAAA,MACtB,sBAAsB;AAAA,IACxB;AAAA,IACA,eAAe;AAAA,EACjB;AAEA,SAAO;AACT;","names":["import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig","import_react_query","import_api","defaultConfig"]}
|
package/dist/index.js
CHANGED
|
@@ -169,13 +169,36 @@ function useSignup(options, { config, queryClient } = {}) {
|
|
|
169
169
|
return mutation;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
// src/hooks/endpoints/earn/
|
|
172
|
+
// src/hooks/endpoints/earn/useCampaigns.ts
|
|
173
173
|
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
174
|
+
import { earnCampaigns } from "@turtleclub/api";
|
|
175
|
+
function useEarnCampaigns(options, { config, queryClient } = {}) {
|
|
176
|
+
const defaultConfig2 = useConfig();
|
|
177
|
+
const enabled = true;
|
|
178
|
+
const query = useQuery8({
|
|
179
|
+
queryKey: [
|
|
180
|
+
"earn-campaigns",
|
|
181
|
+
options?.idFilter,
|
|
182
|
+
options?.protocolFilter
|
|
183
|
+
],
|
|
184
|
+
queryFn: async () => {
|
|
185
|
+
return await earnCampaigns(options || {}, config ?? defaultConfig2);
|
|
186
|
+
},
|
|
187
|
+
enabled,
|
|
188
|
+
staleTime: 60 * 1e3,
|
|
189
|
+
refetchInterval: 30 * 1e3,
|
|
190
|
+
refetchOnWindowFocus: true
|
|
191
|
+
}, queryClient ?? defaultQueryClient);
|
|
192
|
+
return query;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/hooks/endpoints/earn/useDeals.ts
|
|
196
|
+
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
174
197
|
import { earnDeals } from "@turtleclub/api";
|
|
175
198
|
function useEarnDeals(options, { config, queryClient } = {}) {
|
|
176
199
|
const defaultConfig2 = useConfig();
|
|
177
200
|
const enabled = options !== void 0;
|
|
178
|
-
const query =
|
|
201
|
+
const query = useQuery9({
|
|
179
202
|
queryKey: [
|
|
180
203
|
"earn-deals",
|
|
181
204
|
options?.campaignId,
|
|
@@ -196,12 +219,12 @@ function useEarnDeals(options, { config, queryClient } = {}) {
|
|
|
196
219
|
}
|
|
197
220
|
|
|
198
221
|
// src/hooks/endpoints/earn/useRoute.ts
|
|
199
|
-
import { useQuery as
|
|
222
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
200
223
|
import { earnRoute } from "@turtleclub/api";
|
|
201
224
|
function useEarnRoute(options, { config, queryClient } = {}) {
|
|
202
225
|
const defaultConfig2 = useConfig();
|
|
203
226
|
const enabled = options !== void 0;
|
|
204
|
-
const query =
|
|
227
|
+
const query = useQuery10({
|
|
205
228
|
queryKey: [
|
|
206
229
|
"earnRoute",
|
|
207
230
|
options?.user,
|
|
@@ -227,14 +250,14 @@ function useEarnRoute(options, { config, queryClient } = {}) {
|
|
|
227
250
|
}
|
|
228
251
|
|
|
229
252
|
// src/hooks/endpoints/earn/useWalletBalances.ts
|
|
230
|
-
import { useQuery as
|
|
253
|
+
import { useQuery as useQuery11 } from "@tanstack/react-query";
|
|
231
254
|
import {
|
|
232
255
|
earnWalletBalances
|
|
233
256
|
} from "@turtleclub/api";
|
|
234
257
|
function useEarnWalletBalances(options, { config, queryClient } = {}) {
|
|
235
258
|
const defaultConfig2 = useConfig();
|
|
236
259
|
const enabled = options !== void 0;
|
|
237
|
-
const query =
|
|
260
|
+
const query = useQuery11(
|
|
238
261
|
{
|
|
239
262
|
queryKey: ["earnWalletBalances", options?.chain, options?.user],
|
|
240
263
|
queryFn: async () => {
|
|
@@ -253,6 +276,7 @@ function useEarnWalletBalances(options, { config, queryClient } = {}) {
|
|
|
253
276
|
export {
|
|
254
277
|
defaultQueryClient,
|
|
255
278
|
useConfig,
|
|
279
|
+
useEarnCampaigns,
|
|
256
280
|
useEarnDeals,
|
|
257
281
|
useEarnRoute,
|
|
258
282
|
useEarnWalletBalances,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useConfig.ts","../src/hooks/client.ts","../src/hooks/endpoints/useOrganizations.ts","../src/hooks/endpoints/useExists.ts","../src/hooks/endpoints/useOrganizationDeals.ts","../src/hooks/endpoints/useOrganizationsDeals.ts","../src/hooks/endpoints/usePrepareSignup.ts","../src/hooks/endpoints/useProjectTvl.ts","../src/hooks/endpoints/useSignup.ts","../src/hooks/endpoints/earn/useDeals.ts","../src/hooks/endpoints/earn/useRoute.ts","../src/hooks/endpoints/earn/useWalletBalances.ts"],"sourcesContent":["import type { Config } from \"@turtleclub/api\";\nimport { defaultConfig } from \"@turtleclub/api\";\n\nexport function useConfig(): Config {\n // Placeholder implementation - in real app this would use TurtleProvider context\n return defaultConfig;\n}\n","import { createSyncStoragePersister } from \"@tanstack/query-sync-storage-persister\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClient } from \"@tanstack/react-query-persist-client\";\n\nexport const defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// Only persist on client side\nif (typeof window !== 'undefined') {\n const localStoragePersister = createSyncStoragePersister({\n storage: window.localStorage,\n key: \"turtle-sdk\",\n });\n\n persistQueryClient({\n queryClient: defaultQueryClient,\n persister: localStoragePersister,\n });\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organization, type OrganizationResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizations({\n config,\n queryClient,\n}: UseOrganizationsOptions = {}): UseQueryResult<OrganizationResponse | null> {\n const defaultConfig = useConfig();\n\n const query = useQuery(\n {\n queryKey: [\"organizations\"],\n queryFn: async () => {\n return await organization(config ?? defaultConfig);\n },\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, exists, type ExistsOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseExistsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useExists(\n options?: ExistsOptions,\n { config, queryClient }: UseExistsOptions = {},\n): UseQueryResult<boolean | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"exists\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await exists(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationDeals, type OrganizationDealsOptions, type OrganizationDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationDeals(\n options?: OrganizationDealsOptions,\n { config, queryClient }: UseOrganizationDealsOptions = {},\n): UseQueryResult<OrganizationDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationDeals\", options?.organizationId],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationsDeals, type OrganizationsDealsOptions, type OrganizationsDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationsDeals(\n options?: OrganizationsDealsOptions,\n { config, queryClient }: UseOrganizationsDealsOptions = {},\n): UseQueryResult<OrganizationsDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationsDeals\", options?.organizationIds],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationsDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n throwOnError: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, prepareSignup, type PrepareSignupOptions, type PrepareSignupResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UsePrepareSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function usePrepareSignup(\n options?: PrepareSignupOptions,\n { config, queryClient }: UsePrepareSignupOptions = {},\n): UseQueryResult<PrepareSignupResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"prepareSignup\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await prepareSignup(options, config ?? defaultConfig);\n },\n enabled,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, projectTvl, type ProjectTvlOptions, type ProjectTvlResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseProjectTvlOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useProjectTvl(\n options?: ProjectTvlOptions,\n { config, queryClient }: UseProjectTvlOptions = {},\n): UseQueryResult<ProjectTvlResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"projectTvl\", options?.projects],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await projectTvl(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 7 * 60 * 1000,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import {\n type QueryClient,\n useMutation,\n type UseMutationResult,\n useQuery,\n} from \"@tanstack/react-query\";\nimport { type Config, signup, type SignupOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useSignup(\n options?: Omit<SignupOptions, \"signature\">,\n { config, queryClient }: UseSignupOptions = {}\n): UseMutationResult<boolean | null, Error, string, unknown> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const mutation = useMutation(\n {\n mutationFn: async (signature: string) => {\n if (!enabled) return null;\n\n return await signup({ ...options, signature }, config ?? defaultConfig);\n },\n },\n queryClient ?? defaultQueryClient\n );\n\n return mutation;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnDeals, type EarnDealsOptions, type EarnDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnDeals(\n options?: EarnDealsOptions,\n { config, queryClient }: UseEarnDealsOptions = {},\n): UseQueryResult<EarnDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earn-deals\",\n options?.campaignId,\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnRoute, type EarnRouteOptions, type EarnRouteResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnRouteOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnRoute(\n options?: EarnRouteOptions,\n { config, queryClient }: UseEarnRouteOptions = {},\n): UseQueryResult<EarnRouteResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earnRoute\",\n options?.user,\n options?.chain,\n options?.slippage,\n options?.tokenIn,\n options?.tokenOut,\n options?.amount,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnRoute(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000, // 2 minutes - longer stale time for transaction stability\n refetchInterval: false, // Disable automatic refetch to prevent transaction state reset\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport {\n type Config,\n earnWalletBalances,\n type EarnWalletBalancesOptions,\n type EarnWalletBalancesResponse,\n} from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnWalletBalancesOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnWalletBalances(\n options?: EarnWalletBalancesOptions,\n { config, queryClient }: UseEarnWalletBalancesOptions = {}\n): UseQueryResult<EarnWalletBalancesResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery(\n {\n queryKey: [\"earnWalletBalances\", options?.chain, options?.user],\n queryFn: async () => {\n if (!enabled) return null;\n\n return await earnWalletBalances(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 30 * 1000,\n refetchInterval: 15 * 1000,\n refetchOnWindowFocus: true,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n"],"mappings":";AACA,SAAS,qBAAqB;AAEvB,SAAS,YAAoB;AAElC,SAAO;AACT;;;ACNA,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAE5B,IAAM,qBAAqB,IAAI,YAAY;AAAA,EAChD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF,CAAC;AAGD,IAAI,OAAO,WAAW,aAAa;AACjC,QAAM,wBAAwB,2BAA2B;AAAA,IACvD,SAAS,OAAO;AAAA,IAChB,KAAK;AAAA,EACP,CAAC;AAED,qBAAmB;AAAA,IACjB,aAAa;AAAA,IACb,WAAW;AAAA,EACb,CAAC;AACH;;;ACvBA,SAA2B,gBAAqC;AAChE,SAAsB,oBAA+C;AAS9D,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,IAA6B,CAAC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U;AAChC,QAAM,UAAU,YAAY;AAE5B,QAAM,QAAQC,UAAS;AAAA,IACrB,UAAU;AAAA,MACR;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,IACA,SAAS,YAAY;AACnB,UAAI,CAAC;AACH,eAAO;AAET,aAAO,MAAM,UAAU,SAAS,UAAUD,cAAa;AAAA,IACzD;AAAA,IACA;AAAA,IACA,WAAW,IAAI,KAAK;AAAA;AAAA,IACpB,iBAAiB;AAAA;AAAA,IACjB,sBAAsB;AAAA,EACxB,GAAG,eAAe,kBAAkB;AAEpC,SAAO;AACT;;;ACxCA,SAA2B,YAAAE,kBAAqC;AAChE;AAAA,EAEE;AAAA,OAGK;AASA,SAAS,sBACd,SACA,EAAE,QAAQ,YAAY,IAAkC,CAAC,GACN;AACnD,QAAMC,iBAAgB,UAAU;AAChC,QAAM,UAAU,YAAY;AAE5B,QAAM,QAAQC;AAAA,IACZ;AAAA,MACE,UAAU,CAAC,sBAAsB,SAAS,OAAO,SAAS,IAAI;AAAA,MAC9D,SAAS,YAAY;AACnB,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,MAAM,mBAAmB,SAAS,UAAUD,cAAa;AAAA,MAClE;AAAA,MACA;AAAA,MACA,WAAW,KAAK;AAAA,MAChB,iBAAiB,KAAK;AAAA,MACtB,sBAAsB;AAAA,IACxB;AAAA,IACA,eAAe;AAAA,EACjB;AAEA,SAAO;AACT;","names":["defaultConfig","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","defaultConfig","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useConfig.ts","../src/hooks/client.ts","../src/hooks/endpoints/useOrganizations.ts","../src/hooks/endpoints/useExists.ts","../src/hooks/endpoints/useOrganizationDeals.ts","../src/hooks/endpoints/useOrganizationsDeals.ts","../src/hooks/endpoints/usePrepareSignup.ts","../src/hooks/endpoints/useProjectTvl.ts","../src/hooks/endpoints/useSignup.ts","../src/hooks/endpoints/earn/useCampaigns.ts","../src/hooks/endpoints/earn/useDeals.ts","../src/hooks/endpoints/earn/useRoute.ts","../src/hooks/endpoints/earn/useWalletBalances.ts"],"sourcesContent":["import type { Config } from \"@turtleclub/api\";\nimport { defaultConfig } from \"@turtleclub/api\";\n\nexport function useConfig(): Config {\n // Placeholder implementation - in real app this would use TurtleProvider context\n return defaultConfig;\n}\n","import { createSyncStoragePersister } from \"@tanstack/query-sync-storage-persister\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { persistQueryClient } from \"@tanstack/react-query-persist-client\";\n\nexport const defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n },\n },\n});\n\n// Only persist on client side\nif (typeof window !== 'undefined') {\n const localStoragePersister = createSyncStoragePersister({\n storage: window.localStorage,\n key: \"turtle-sdk\",\n });\n\n persistQueryClient({\n queryClient: defaultQueryClient,\n persister: localStoragePersister,\n });\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organization, type OrganizationResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizations({\n config,\n queryClient,\n}: UseOrganizationsOptions = {}): UseQueryResult<OrganizationResponse | null> {\n const defaultConfig = useConfig();\n\n const query = useQuery(\n {\n queryKey: [\"organizations\"],\n queryFn: async () => {\n return await organization(config ?? defaultConfig);\n },\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, exists, type ExistsOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseExistsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useExists(\n options?: ExistsOptions,\n { config, queryClient }: UseExistsOptions = {},\n): UseQueryResult<boolean | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"exists\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await exists(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationDeals, type OrganizationDealsOptions, type OrganizationDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationDeals(\n options?: OrganizationDealsOptions,\n { config, queryClient }: UseOrganizationDealsOptions = {},\n): UseQueryResult<OrganizationDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationDeals\", options?.organizationId],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, organizationsDeals, type OrganizationsDealsOptions, type OrganizationsDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseOrganizationsDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useOrganizationsDeals(\n options?: OrganizationsDealsOptions,\n { config, queryClient }: UseOrganizationsDealsOptions = {},\n): UseQueryResult<OrganizationsDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"organizationsDeals\", options?.organizationIds],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await organizationsDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000,\n refetchInterval: 1 * 60 * 1000,\n throwOnError: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, prepareSignup, type PrepareSignupOptions, type PrepareSignupResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UsePrepareSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function usePrepareSignup(\n options?: PrepareSignupOptions,\n { config, queryClient }: UsePrepareSignupOptions = {},\n): UseQueryResult<PrepareSignupResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"prepareSignup\", options?.user],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await prepareSignup(options, config ?? defaultConfig);\n },\n enabled,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, projectTvl, type ProjectTvlOptions, type ProjectTvlResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseProjectTvlOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useProjectTvl(\n options?: ProjectTvlOptions,\n { config, queryClient }: UseProjectTvlOptions = {},\n): UseQueryResult<ProjectTvlResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\"projectTvl\", options?.projects],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await projectTvl(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 7 * 60 * 1000,\n refetchInterval: 5 * 60 * 1000,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import {\n type QueryClient,\n useMutation,\n type UseMutationResult,\n useQuery,\n} from \"@tanstack/react-query\";\nimport { type Config, signup, type SignupOptions } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../client\";\nimport { useConfig } from \"../useConfig\";\n\nexport interface UseSignupOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useSignup(\n options?: Omit<SignupOptions, \"signature\">,\n { config, queryClient }: UseSignupOptions = {}\n): UseMutationResult<boolean | null, Error, string, unknown> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const mutation = useMutation(\n {\n mutationFn: async (signature: string) => {\n if (!enabled) return null;\n\n return await signup({ ...options, signature }, config ?? defaultConfig);\n },\n },\n queryClient ?? defaultQueryClient\n );\n\n return mutation;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnCampaigns, type EarnCampaignsOptions, type EarnCampaignWithVaults } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnCampaignsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnCampaigns(\n options?: EarnCampaignsOptions,\n { config, queryClient }: UseEarnCampaignsOptions = {},\n): UseQueryResult<EarnCampaignWithVaults[] | null> {\n const defaultConfig = useConfig();\n const enabled = true; // Always enabled for campaigns\n\n const query = useQuery({\n queryKey: [\n \"earn-campaigns\",\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n return await earnCampaigns(options || {}, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnDeals, type EarnDealsOptions, type EarnDealsResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"@/hooks/client\";\nimport { useConfig } from \"@/hooks/useConfig\";\n\nexport interface UseEarnDealsOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnDeals(\n options?: EarnDealsOptions,\n { config, queryClient }: UseEarnDealsOptions = {},\n): UseQueryResult<EarnDealsResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earn-deals\",\n options?.campaignId,\n options?.idFilter,\n options?.protocolFilter,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnDeals(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 60 * 1000,\n refetchInterval: 30 * 1000,\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { type Config, earnRoute, type EarnRouteOptions, type EarnRouteResponse } from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnRouteOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnRoute(\n options?: EarnRouteOptions,\n { config, queryClient }: UseEarnRouteOptions = {},\n): UseQueryResult<EarnRouteResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery({\n queryKey: [\n \"earnRoute\",\n options?.user,\n options?.chain,\n options?.slippage,\n options?.tokenIn,\n options?.tokenOut,\n options?.amount,\n ],\n queryFn: async () => {\n if (!enabled)\n return null;\n\n return await earnRoute(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 2 * 60 * 1000, // 2 minutes - longer stale time for transaction stability\n refetchInterval: false, // Disable automatic refetch to prevent transaction state reset\n refetchOnWindowFocus: true,\n }, queryClient ?? defaultQueryClient);\n\n return query;\n}\n","import { type QueryClient, useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport {\n type Config,\n earnWalletBalances,\n type EarnWalletBalancesOptions,\n type EarnWalletBalancesResponse,\n} from \"@turtleclub/api\";\nimport { defaultQueryClient } from \"../../client\";\nimport { useConfig } from \"../../useConfig\";\n\nexport interface UseEarnWalletBalancesOptions {\n config?: Config;\n queryClient?: QueryClient;\n}\n\nexport function useEarnWalletBalances(\n options?: EarnWalletBalancesOptions,\n { config, queryClient }: UseEarnWalletBalancesOptions = {}\n): UseQueryResult<EarnWalletBalancesResponse | null> {\n const defaultConfig = useConfig();\n const enabled = options !== undefined;\n\n const query = useQuery(\n {\n queryKey: [\"earnWalletBalances\", options?.chain, options?.user],\n queryFn: async () => {\n if (!enabled) return null;\n\n return await earnWalletBalances(options, config ?? defaultConfig);\n },\n enabled,\n staleTime: 30 * 1000,\n refetchInterval: 15 * 1000,\n refetchOnWindowFocus: true,\n },\n queryClient ?? defaultQueryClient\n );\n\n return query;\n}\n"],"mappings":";AACA,SAAS,qBAAqB;AAEvB,SAAS,YAAoB;AAElC,SAAO;AACT;;;ACNA,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAE5B,IAAM,qBAAqB,IAAI,YAAY;AAAA,EAChD,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF,CAAC;AAGD,IAAI,OAAO,WAAW,aAAa;AACjC,QAAM,wBAAwB,2BAA2B;AAAA,IACvD,SAAS,OAAO;AAAA,IAChB,KAAK;AAAA,EACP,CAAC;AAED,qBAAmB;AAAA,IACjB,aAAa;AAAA,IACb,WAAW;AAAA,EACb,CAAC;AACH;;;ACvBA,SAA2B,gBAAqC;AAChE,SAAsB,oBAA+C;AA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O,SAAS,IAAI;AAAA,MAC9D,SAAS,YAAY;AACnB,YAAI,CAAC,QAAS,QAAO;AAErB,eAAO,MAAM,mBAAmB,SAAS,UAAUD,cAAa;AAAA,MAClE;AAAA,MACA;AAAA,MACA,WAAW,KAAK;AAAA,MAChB,iBAAiB,KAAK;AAAA,MACtB,sBAAsB;AAAA,IACxB;AAAA,IACA,eAAe;AAAA,EACjB;AAEA,SAAO;AACT;","names":["defaultConfig","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","defaultConfig","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery","useQuery","defaultConfig","useQuery"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turtleclub/hooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@tanstack/query-sync-storage-persister": "^5.55.3",
|
|
30
30
|
"@tanstack/react-query": "^5.55.3",
|
|
31
31
|
"@tanstack/react-query-persist-client": "^5.55.3",
|
|
32
|
-
"@turtleclub/api": "0.
|
|
33
|
-
"@turtleclub/chains": "0.1.1
|
|
34
|
-
"@turtleclub/utils": "0.1.1
|
|
32
|
+
"@turtleclub/api": "0.2.0-beta.0",
|
|
33
|
+
"@turtleclub/chains": "0.1.1",
|
|
34
|
+
"@turtleclub/utils": "0.1.1",
|
|
35
35
|
"@wagmi/core": "^2.17.2",
|
|
36
36
|
"react": "^19.1.0",
|
|
37
37
|
"wagmi": "^2.15.4",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7778980c05e971e49595f6bd65ee7c884b26fd0f"
|
|
52
52
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type QueryClient, useQuery, type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { type Config, earnCampaigns, type EarnCampaignsOptions, type EarnCampaignWithVaults } from "@turtleclub/api";
|
|
3
|
+
import { defaultQueryClient } from "@/hooks/client";
|
|
4
|
+
import { useConfig } from "@/hooks/useConfig";
|
|
5
|
+
|
|
6
|
+
export interface UseEarnCampaignsOptions {
|
|
7
|
+
config?: Config;
|
|
8
|
+
queryClient?: QueryClient;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useEarnCampaigns(
|
|
12
|
+
options?: EarnCampaignsOptions,
|
|
13
|
+
{ config, queryClient }: UseEarnCampaignsOptions = {},
|
|
14
|
+
): UseQueryResult<EarnCampaignWithVaults[] | null> {
|
|
15
|
+
const defaultConfig = useConfig();
|
|
16
|
+
const enabled = true; // Always enabled for campaigns
|
|
17
|
+
|
|
18
|
+
const query = useQuery({
|
|
19
|
+
queryKey: [
|
|
20
|
+
"earn-campaigns",
|
|
21
|
+
options?.idFilter,
|
|
22
|
+
options?.protocolFilter,
|
|
23
|
+
],
|
|
24
|
+
queryFn: async () => {
|
|
25
|
+
return await earnCampaigns(options || {}, config ?? defaultConfig);
|
|
26
|
+
},
|
|
27
|
+
enabled,
|
|
28
|
+
staleTime: 60 * 1000,
|
|
29
|
+
refetchInterval: 30 * 1000,
|
|
30
|
+
refetchOnWindowFocus: true,
|
|
31
|
+
}, queryClient ?? defaultQueryClient);
|
|
32
|
+
|
|
33
|
+
return query;
|
|
34
|
+
}
|