@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/dist/index.cjs +28 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/geocheck/hooks.ts +5 -4
- package/src/v2/lib/api-client.ts +1 -0
- package/src/v2/lib/turtle-provider.tsx +2 -1
- package/src/v2/streams/schemas.ts +24 -12
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.
|
|
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": "
|
|
57
|
+
"gitHead": "f7b206b904156b60fad200f803741d81d00cf71b"
|
|
58
58
|
}
|
package/src/v2/geocheck/hooks.ts
CHANGED
|
@@ -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
|
});
|
package/src/v2/lib/api-client.ts
CHANGED
|
@@ -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
|
|
5
|
+
const customArgsBaseSchema = z.object({
|
|
6
6
|
targetTokenId: z.string().uuid(),
|
|
7
|
-
targetToken: supportedTokenSchema.optional(),
|
|
8
7
|
});
|
|
9
8
|
|
|
10
|
-
//
|
|
11
|
-
const
|
|
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([
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
streamCustomArgsTokensPerUsdSchema,
|
|
144
|
+
streamCustomArgsAprSchema,
|
|
145
|
+
streamCustomArgsTokensPerDaySchema,
|
|
134
146
|
]),
|
|
135
147
|
endTimestamp: z.string().datetime().nullable(),
|
|
136
148
|
fee: feeSchema.nullable(),
|