@turtleclub/hooks 0.5.0-beta.98 → 0.5.0-beta.99
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 +71 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +65 -78
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/v2/covers/api.ts +66 -66
- package/src/v2/covers/hooks.ts +38 -38
- package/src/v2/covers/index.ts +16 -16
- package/src/v2/covers/schema.ts +42 -42
- package/src/v2/nfts/api.ts +25 -25
- package/src/v2/nfts/hooks.ts +26 -26
- package/src/v2/nfts/index.ts +13 -13
- package/src/v2/nfts/queries.ts +10 -10
- package/src/v2/nfts/schema.ts +12 -12
- package/src/v2/streams/api.ts +8 -30
- package/src/v2/streams/hooks.ts +6 -26
- package/src/v2/streams/mutations.ts +3 -16
- package/src/v2/streams/schemas.ts +67 -50
package/src/v2/streams/hooks.ts
CHANGED
|
@@ -6,11 +6,9 @@ import {
|
|
|
6
6
|
DeleteStreamOutput,
|
|
7
7
|
DeleteStreamInput,
|
|
8
8
|
GetStreamsQuery,
|
|
9
|
-
PauseStreamSnapshotComputationInput,
|
|
10
|
-
PauseStreamSnapshotComputationOutput,
|
|
11
|
-
StopStreamInput,
|
|
12
|
-
StopStreamOutput,
|
|
13
9
|
Stream,
|
|
10
|
+
UpdateStreamInput,
|
|
11
|
+
UpdateStreamOutput,
|
|
14
12
|
StreamsSupportedChainsResponse,
|
|
15
13
|
StreamWallet,
|
|
16
14
|
StreamWalletDetails,
|
|
@@ -44,17 +42,8 @@ export type UseStreamSupportedChainsOptions = Omit<
|
|
|
44
42
|
"queryKey" | "queryFn"
|
|
45
43
|
>;
|
|
46
44
|
|
|
47
|
-
export type
|
|
48
|
-
UseMutationOptions<
|
|
49
|
-
PauseStreamSnapshotComputationOutput,
|
|
50
|
-
Error,
|
|
51
|
-
PauseStreamSnapshotComputationInput
|
|
52
|
-
>,
|
|
53
|
-
"mutationFn"
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
export type UseStopStreamOptions = Omit<
|
|
57
|
-
UseMutationOptions<StopStreamOutput, Error, StopStreamInput>,
|
|
45
|
+
export type UseUpdateStreamOptions = Omit<
|
|
46
|
+
UseMutationOptions<UpdateStreamOutput, Error, UpdateStreamInput>,
|
|
58
47
|
"mutationFn"
|
|
59
48
|
>;
|
|
60
49
|
|
|
@@ -113,18 +102,9 @@ export function useStreamSupportedChains({
|
|
|
113
102
|
return useQuery(createQueryOptions(streamsQueries.supportedChains, options));
|
|
114
103
|
}
|
|
115
104
|
|
|
116
|
-
export function
|
|
117
|
-
options?: UsePauseStreamSnapshotComputationOptions
|
|
118
|
-
) {
|
|
119
|
-
return useMutation({
|
|
120
|
-
mutationFn: streamsMutations.pauseSnapshotComputation,
|
|
121
|
-
...options,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function useStopStream(options?: UseStopStreamOptions) {
|
|
105
|
+
export function useUpdateStream(options?: UseUpdateStreamOptions) {
|
|
126
106
|
return useMutation({
|
|
127
|
-
mutationFn: streamsMutations.
|
|
107
|
+
mutationFn: streamsMutations.update,
|
|
128
108
|
...options,
|
|
129
109
|
});
|
|
130
110
|
}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { deleteStream,
|
|
2
|
-
import {
|
|
3
|
-
DeleteStreamInput,
|
|
4
|
-
PauseStreamSnapshotComputationInput,
|
|
5
|
-
StopStreamInput,
|
|
6
|
-
} from "./schemas";
|
|
1
|
+
import { deleteStream, updateStream } from "./api";
|
|
2
|
+
import { DeleteStreamInput, UpdateStreamInput } from "./schemas";
|
|
7
3
|
|
|
8
4
|
export const streamsMutations = {
|
|
9
|
-
|
|
10
|
-
pauseStreamSnapshotComputation(input.organizationId, {
|
|
11
|
-
streamId: input.streamId,
|
|
12
|
-
snapshotComputationPaused: input.snapshotComputationPaused,
|
|
13
|
-
}),
|
|
14
|
-
stop: (input: StopStreamInput) =>
|
|
15
|
-
stopStream(input.organizationId, {
|
|
16
|
-
streamId: input.streamId,
|
|
17
|
-
stopStream: input.stopStream,
|
|
18
|
-
}),
|
|
5
|
+
update: ({ organizationId, ...body }: UpdateStreamInput) => updateStream(organizationId, body),
|
|
19
6
|
deleteStream: (input: DeleteStreamInput) => deleteStream(input.organizationId, input.streamId),
|
|
20
7
|
};
|
|
@@ -17,6 +17,12 @@ const snapshotCustomArgsTokensPerDaySchema = customArgsBaseSchema.extend({
|
|
|
17
17
|
tokensPerDay: z.string(),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
const snapshotCustomArgsSchema = z.union([
|
|
21
|
+
snapshotCustomArgsTokensPerUsdSchema,
|
|
22
|
+
snapshotCustomArgsAprSchema,
|
|
23
|
+
snapshotCustomArgsTokensPerDaySchema,
|
|
24
|
+
]);
|
|
25
|
+
|
|
20
26
|
// Schemes for STREAM (with mandatory targetToken)
|
|
21
27
|
const streamCustomArgsTokensPerUsdSchema = snapshotCustomArgsTokensPerUsdSchema.extend({
|
|
22
28
|
targetToken: supportedTokenSchema,
|
|
@@ -28,6 +34,32 @@ const streamCustomArgsTokensPerDaySchema = snapshotCustomArgsTokensPerDaySchema.
|
|
|
28
34
|
targetToken: supportedTokenSchema,
|
|
29
35
|
});
|
|
30
36
|
|
|
37
|
+
const streamCustomArgsSchema = z.union([
|
|
38
|
+
streamCustomArgsTokensPerUsdSchema,
|
|
39
|
+
streamCustomArgsAprSchema,
|
|
40
|
+
streamCustomArgsTokensPerDaySchema,
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const updateStreamCustomArgsBaseSchema = z.object({
|
|
44
|
+
targetTokenId: z.string().uuid().optional(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const updateStreamCustomArgsTokensPerUsdSchema = updateStreamCustomArgsBaseSchema.extend({
|
|
48
|
+
tokensPerUSD: z.string(),
|
|
49
|
+
});
|
|
50
|
+
const updateStreamCustomArgsAprSchema = updateStreamCustomArgsBaseSchema.extend({
|
|
51
|
+
apr: z.string(),
|
|
52
|
+
});
|
|
53
|
+
const updateStreamCustomArgsTokensPerDaySchema = updateStreamCustomArgsBaseSchema.extend({
|
|
54
|
+
tokensPerDay: z.string(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const updateStreamCustomArgsSchema = z.union([
|
|
58
|
+
updateStreamCustomArgsTokensPerUsdSchema,
|
|
59
|
+
updateStreamCustomArgsAprSchema,
|
|
60
|
+
updateStreamCustomArgsTokensPerDaySchema,
|
|
61
|
+
]);
|
|
62
|
+
|
|
31
63
|
export const snapshotSchema = z.object({
|
|
32
64
|
amountBase: z.string(),
|
|
33
65
|
amountDistributed: z.string(),
|
|
@@ -43,13 +75,7 @@ export const snapshotSchema = z.object({
|
|
|
43
75
|
turtleTvl: z.string().nullable().optional(),
|
|
44
76
|
turtleNetTvl: z.string().nullable().optional(),
|
|
45
77
|
customMetrics: z.record(z.unknown()).optional(),
|
|
46
|
-
customArgs:
|
|
47
|
-
.union([
|
|
48
|
-
snapshotCustomArgsTokensPerUsdSchema,
|
|
49
|
-
snapshotCustomArgsAprSchema,
|
|
50
|
-
snapshotCustomArgsTokensPerDaySchema,
|
|
51
|
-
])
|
|
52
|
-
.optional(),
|
|
78
|
+
customArgs: snapshotCustomArgsSchema.optional(),
|
|
53
79
|
});
|
|
54
80
|
|
|
55
81
|
export const streamPointSchema = z.object({
|
|
@@ -139,11 +165,7 @@ export const streamSchema = z.object({
|
|
|
139
165
|
contractAddress: z.string().nullable(),
|
|
140
166
|
createdAt: z.string().datetime(),
|
|
141
167
|
creationConfirmedAt: z.string().datetime().nullable(),
|
|
142
|
-
customArgs:
|
|
143
|
-
streamCustomArgsTokensPerUsdSchema,
|
|
144
|
-
streamCustomArgsAprSchema,
|
|
145
|
-
streamCustomArgsTokensPerDaySchema,
|
|
146
|
-
]),
|
|
168
|
+
customArgs: streamCustomArgsSchema,
|
|
147
169
|
endTimestamp: z.string().datetime().nullable(),
|
|
148
170
|
fee: feeSchema.nullable(),
|
|
149
171
|
hashCommitmentPaused: z.boolean(),
|
|
@@ -204,16 +226,7 @@ export const getStreamsSupportedChainsOutputSchema = z.object({
|
|
|
204
226
|
export const streamSignatureRequestInputSchema = z.object({
|
|
205
227
|
adapters: adaptersSchema,
|
|
206
228
|
chainId: z.number().nullable(),
|
|
207
|
-
customArgs:
|
|
208
|
-
z.object({
|
|
209
|
-
targetTokenId: z.string().uuid(),
|
|
210
|
-
}),
|
|
211
|
-
z.union([
|
|
212
|
-
z.object({ tokensPerUSD: z.string() }),
|
|
213
|
-
z.object({ apr: z.string() }),
|
|
214
|
-
z.object({ tokensPerDay: z.string() }),
|
|
215
|
-
])
|
|
216
|
-
),
|
|
229
|
+
customArgs: snapshotCustomArgsSchema,
|
|
217
230
|
endTimestamp: z.string().nullable(),
|
|
218
231
|
pointId: z.string().uuid().nullable(),
|
|
219
232
|
rewardToken: z.string().nullable(),
|
|
@@ -305,40 +318,52 @@ export const getStreamWalletDetailsResponseSchema = z.object({
|
|
|
305
318
|
wallet: streamWalletDetailsSchema,
|
|
306
319
|
});
|
|
307
320
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
321
|
+
const updateStreamMutableFieldsSchema = z.object({
|
|
322
|
+
customArgs: updateStreamCustomArgsSchema.optional(),
|
|
323
|
+
snapshotComputationPaused: z.boolean().optional(),
|
|
324
|
+
merkleTreeComputationPaused: z.boolean().optional(),
|
|
325
|
+
hashCommitmentPaused: z.boolean().optional(),
|
|
326
|
+
stopStream: z.boolean().optional(),
|
|
327
|
+
endTimestamp: z.string().datetime().nullable().optional(),
|
|
328
|
+
setNilEndTimestamp: z.boolean().optional(),
|
|
312
329
|
});
|
|
313
330
|
|
|
314
|
-
|
|
331
|
+
const updateStreamFieldsSchema = z.object({
|
|
315
332
|
streamId: z.string().uuid(),
|
|
316
|
-
snapshotComputationPaused: z.boolean(),
|
|
317
333
|
});
|
|
318
334
|
|
|
319
|
-
|
|
335
|
+
const updateStreamBodyBaseSchema = updateStreamFieldsSchema.merge(updateStreamMutableFieldsSchema);
|
|
336
|
+
|
|
337
|
+
type UpdateStreamMutableFields = z.infer<typeof updateStreamMutableFieldsSchema>;
|
|
338
|
+
|
|
339
|
+
const hasUpdateStreamFields = (input: UpdateStreamMutableFields) => {
|
|
340
|
+
return Object.values(input).some((value) => value !== undefined);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const updateStreamBodySchema = updateStreamBodyBaseSchema.refine(
|
|
344
|
+
({ streamId: _streamId, ...updateFields }: z.infer<typeof updateStreamBodyBaseSchema>) =>
|
|
345
|
+
hasUpdateStreamFields(updateFields),
|
|
346
|
+
{
|
|
347
|
+
message: "At least one stream update field must be provided",
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
const updateStreamInputBaseSchema = updateStreamBodyBaseSchema.extend({
|
|
320
352
|
organizationId: z.string().uuid(),
|
|
321
|
-
streamId: z.string().uuid(),
|
|
322
|
-
stopStream: z.boolean(),
|
|
323
353
|
});
|
|
324
354
|
|
|
325
|
-
export const
|
|
326
|
-
streamId: z.string().uuid(),
|
|
327
|
-
stopStream: z.boolean(),
|
|
328
|
-
});
|
|
355
|
+
export const updateStreamInputSchema = updateStreamInputBaseSchema;
|
|
329
356
|
|
|
330
357
|
export const deleteStreamInputSchema = z.object({
|
|
331
358
|
organizationId: z.string().uuid(),
|
|
332
359
|
streamId: z.string().uuid(),
|
|
333
360
|
});
|
|
334
361
|
|
|
335
|
-
const updateStreamOutputSchema = z.object({
|
|
362
|
+
export const updateStreamOutputSchema = z.object({
|
|
336
363
|
success: z.boolean(),
|
|
337
364
|
message: z.string(),
|
|
338
365
|
});
|
|
339
366
|
|
|
340
|
-
export const pauseStreamSnapshotComputationOutputSchema = updateStreamOutputSchema;
|
|
341
|
-
export const stopStreamOutputSchema = updateStreamOutputSchema;
|
|
342
367
|
export const deleteStreamOutputSchema = updateStreamOutputSchema;
|
|
343
368
|
|
|
344
369
|
// --- Types ---
|
|
@@ -358,17 +383,9 @@ export type StreamWallet = z.infer<typeof streamWalletSchema>;
|
|
|
358
383
|
export type StreamWalletDetails = z.infer<typeof streamWalletDetailsSchema>;
|
|
359
384
|
export type PaginationSchema = z.infer<typeof paginationSchema>;
|
|
360
385
|
export type GetStreamsWalletsQuery = z.infer<typeof getStreamWalletsQuerySchema>;
|
|
361
|
-
export type
|
|
362
|
-
|
|
363
|
-
>;
|
|
364
|
-
export type
|
|
365
|
-
typeof pauseStreamSnapshotComputationBodySchema
|
|
366
|
-
>;
|
|
367
|
-
export type PauseStreamSnapshotComputationOutput = z.infer<
|
|
368
|
-
typeof pauseStreamSnapshotComputationOutputSchema
|
|
369
|
-
>;
|
|
370
|
-
export type StopStreamInput = z.infer<typeof stopStreamInputSchema>;
|
|
371
|
-
export type StopStreamBody = z.infer<typeof stopStreamBodySchema>;
|
|
372
|
-
export type StopStreamOutput = z.infer<typeof stopStreamOutputSchema>;
|
|
386
|
+
export type UpdateStreamCustomArgs = z.infer<typeof updateStreamCustomArgsSchema>;
|
|
387
|
+
export type UpdateStreamInput = z.infer<typeof updateStreamInputSchema>;
|
|
388
|
+
export type UpdateStreamBody = z.infer<typeof updateStreamBodySchema>;
|
|
389
|
+
export type UpdateStreamOutput = z.infer<typeof updateStreamOutputSchema>;
|
|
373
390
|
export type DeleteStreamInput = z.infer<typeof deleteStreamInputSchema>;
|
|
374
391
|
export type DeleteStreamOutput = z.infer<typeof deleteStreamOutputSchema>;
|