@turtleclub/hooks 0.5.0-beta.92 → 0.5.0-beta.94

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.92",
4
+ "version": "0.5.0-beta.94",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "3747ed0a64d2549922c70d6fca65afd0b92dd7a7"
57
+ "gitHead": "f7b206b904156b60fad200f803741d81d00cf71b"
58
58
  }
@@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
2
2
  import type { UseQueryResult } from "@tanstack/react-query";
3
3
  import { geocheckQueries } from "./queries";
4
4
  import { queryDefaults } from "../lib/query-config";
5
+ import { apiClient } from "../lib/api-client";
5
6
  import type { GeoCheckResponse } from "./schema";
6
7
 
7
8
  export interface UseGeocheckOptions {
@@ -21,15 +22,15 @@ export interface UseGeocheckOptions {
21
22
  * if (!geocheck?.canInteract) return <div>Service not available in your region</div>;
22
23
  * ```
23
24
  */
24
- export function useGeocheck(
25
- options: UseGeocheckOptions = {}
26
- ): UseQueryResult<GeoCheckResponse> {
25
+ export function useGeocheck(options: UseGeocheckOptions = {}): UseQueryResult<GeoCheckResponse> {
27
26
  const { enabled = true, staleTime, gcTime } = options;
27
+ const { disableGeocheck } = apiClient.getConfig();
28
28
 
29
29
  return useQuery({
30
30
  ...geocheckQueries.check,
31
31
  ...queryDefaults,
32
- enabled,
32
+ enabled: enabled && !disableGeocheck,
33
+ ...(disableGeocheck && { initialData: { canInteract: true } }),
33
34
  staleTime: staleTime ?? 5 * 60 * 1000, // 5 minutes
34
35
  gcTime: gcTime ?? 10 * 60 * 1000, // 10 minutes
35
36
  });
@@ -9,6 +9,7 @@ export interface ApiClientConfig {
9
9
  getToken?: () => string | null;
10
10
  earnApiKey?: string;
11
11
  debug?: boolean;
12
+ disableGeocheck?: boolean;
12
13
  }
13
14
 
14
15
  export interface ApiClientOptions extends Omit<RequestInit, "body"> {
@@ -36,8 +36,9 @@ export function TurtleHooksProvider({
36
36
  getToken,
37
37
  earnApiKey,
38
38
  debug,
39
+ disableGeocheck,
39
40
  }: TurtleHooksProviderProps) {
40
- apiClient.configure({ apiUrl, earnUrl, getToken, earnApiKey, debug });
41
+ apiClient.configure({ apiUrl, earnUrl, getToken, earnApiKey, debug, disableGeocheck });
41
42
 
42
43
  return <>{children}</>;
43
44
  }
@@ -2,24 +2,32 @@ import { z } from "zod";
2
2
  import { organizationSchema } from "../organizations";
3
3
  import { supportedTokenSchema } from "../supported-tokens";
4
4
 
5
- const customArgsRequiredFieldsSchema = z.object({
5
+ const customArgsBaseSchema = z.object({
6
6
  targetTokenId: z.string().uuid(),
7
- targetToken: supportedTokenSchema.optional(),
8
7
  });
9
8
 
10
- // --- Shared & Base Schemas ---
11
- const customArgsTokensPerUsdSchema = customArgsRequiredFieldsSchema.extend({
9
+ // Schemes for SNAPSHOTS (without targetToken)
10
+ const snapshotCustomArgsTokensPerUsdSchema = customArgsBaseSchema.extend({
12
11
  tokensPerUSD: z.string(),
13
12
  });
14
-
15
- const customArgsAprSchema = customArgsRequiredFieldsSchema.extend({
13
+ const snapshotCustomArgsAprSchema = customArgsBaseSchema.extend({
16
14
  apr: z.string(),
17
15
  });
18
-
19
- const customArgsTokensPerDaySchema = customArgsRequiredFieldsSchema.extend({
16
+ const snapshotCustomArgsTokensPerDaySchema = customArgsBaseSchema.extend({
20
17
  tokensPerDay: z.string(),
21
18
  });
22
19
 
20
+ // Schemes for STREAM (with mandatory targetToken)
21
+ const streamCustomArgsTokensPerUsdSchema = snapshotCustomArgsTokensPerUsdSchema.extend({
22
+ targetToken: supportedTokenSchema,
23
+ });
24
+ const streamCustomArgsAprSchema = snapshotCustomArgsAprSchema.extend({
25
+ targetToken: supportedTokenSchema,
26
+ });
27
+ const streamCustomArgsTokensPerDaySchema = snapshotCustomArgsTokensPerDaySchema.extend({
28
+ targetToken: supportedTokenSchema,
29
+ });
30
+
23
31
  export const snapshotSchema = z.object({
24
32
  amountBase: z.string(),
25
33
  amountDistributed: z.string(),
@@ -36,7 +44,11 @@ export const snapshotSchema = z.object({
36
44
  turtleNetTvl: z.string().nullable().optional(),
37
45
  customMetrics: z.record(z.unknown()).optional(),
38
46
  customArgs: z
39
- .union([customArgsTokensPerUsdSchema, customArgsAprSchema, customArgsTokensPerDaySchema])
47
+ .union([
48
+ snapshotCustomArgsTokensPerUsdSchema,
49
+ snapshotCustomArgsAprSchema,
50
+ snapshotCustomArgsTokensPerDaySchema,
51
+ ])
40
52
  .optional(),
41
53
  });
42
54
 
@@ -128,9 +140,9 @@ export const streamSchema = z.object({
128
140
  createdAt: z.string().datetime(),
129
141
  creationConfirmedAt: z.string().datetime().nullable(),
130
142
  customArgs: z.union([
131
- customArgsTokensPerUsdSchema,
132
- customArgsAprSchema,
133
- customArgsTokensPerDaySchema,
143
+ streamCustomArgsTokensPerUsdSchema,
144
+ streamCustomArgsAprSchema,
145
+ streamCustomArgsTokensPerDaySchema,
134
146
  ]),
135
147
  endTimestamp: z.string().datetime().nullable(),
136
148
  fee: feeSchema.nullable(),