@turtleclub/hooks 0.5.0-beta.8 → 0.5.0-beta.9
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 +315 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +299 -95
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/index.ts +3 -0
- package/src/v2/streams/api.ts +13 -11
- package/src/v2/streams/hooks.ts +12 -9
- package/src/v2/streams/queries.ts +2 -2
- package/src/v2/streams/schemas.ts +6 -6
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.9",
|
|
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": "c54953f1302972ae44bb7079f29ed789e9709c7b"
|
|
58
58
|
}
|
package/src/v2/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { earnDepositsQueries } from "./earn-deposits/queries";
|
|
|
7
7
|
import { productsQueries } from "./products/queries";
|
|
8
8
|
import { ensoBalancesQueries } from "./enso-balances/queries";
|
|
9
9
|
import { widgetQueries } from "./widget/queries";
|
|
10
|
+
import { streamsQueries } from "./streams/queries";
|
|
10
11
|
import { supportedChainsQueries } from "./supported-chains/queries";
|
|
11
12
|
import { supportedTokensQueries } from "./supported-tokens/queries";
|
|
12
13
|
import { usersQueries } from "./users/queries";
|
|
@@ -21,6 +22,7 @@ export const queries = mergeQueryKeys(
|
|
|
21
22
|
productsQueries,
|
|
22
23
|
ensoBalancesQueries,
|
|
23
24
|
widgetQueries,
|
|
25
|
+
streamsQueries,
|
|
24
26
|
supportedChainsQueries,
|
|
25
27
|
supportedTokensQueries,
|
|
26
28
|
usersQueries
|
|
@@ -41,6 +43,7 @@ export * from "./widget";
|
|
|
41
43
|
export * from "./supported-chains";
|
|
42
44
|
export * from "./supported-tokens";
|
|
43
45
|
export * from "./geocheck";
|
|
46
|
+
export * from "./streams";
|
|
44
47
|
export * from "./swap";
|
|
45
48
|
export * from "./users";
|
|
46
49
|
|
package/src/v2/streams/api.ts
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
GetStreamsQuery,
|
|
4
4
|
getStreamsOutputSchema,
|
|
5
5
|
StreamsSchema,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
getStreamsSupportedChainsOutputSchema,
|
|
7
|
+
StreamsSupportedChainsResponse,
|
|
8
|
+
StreamSignatureRequestInput,
|
|
9
|
+
streamSignatureRequestOutputSchema,
|
|
10
|
+
StreamSignatureRequestOutput,
|
|
11
11
|
} from "./schemas";
|
|
12
12
|
|
|
13
13
|
export async function getStreams(query?: GetStreamsQuery): Promise<StreamsSchema["streams"]> {
|
|
@@ -30,10 +30,12 @@ export async function getStreams(query?: GetStreamsQuery): Promise<StreamsSchema
|
|
|
30
30
|
return result.data.streams;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export async function
|
|
33
|
+
export async function getStreamsSupportedChains(): Promise<
|
|
34
|
+
StreamsSupportedChainsResponse["chains"]
|
|
35
|
+
> {
|
|
34
36
|
const endpoint = "/streams/supported_chains";
|
|
35
37
|
const data = await apiClient.fetch(endpoint, { method: "GET" });
|
|
36
|
-
const result =
|
|
38
|
+
const result = getStreamsSupportedChainsOutputSchema.safeParse(data);
|
|
37
39
|
|
|
38
40
|
if (!result.success) {
|
|
39
41
|
throw new Error(`Failed to parse supported chains: ${result.error.message}`);
|
|
@@ -41,17 +43,17 @@ export async function getSupportedChains(): Promise<SupportedChainsResponse["cha
|
|
|
41
43
|
return result.data.chains;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export async function
|
|
46
|
+
export async function requestStreamSignature(
|
|
45
47
|
organizationId: string,
|
|
46
|
-
input:
|
|
47
|
-
): Promise<
|
|
48
|
+
input: StreamSignatureRequestInput
|
|
49
|
+
): Promise<StreamSignatureRequestOutput> {
|
|
48
50
|
const endpoint = `/streams/request_signature/${organizationId}`;
|
|
49
51
|
const data = await apiClient.fetch(endpoint, {
|
|
50
52
|
method: "POST",
|
|
51
53
|
body: input,
|
|
52
54
|
});
|
|
53
55
|
|
|
54
|
-
const result =
|
|
56
|
+
const result = streamSignatureRequestOutputSchema.safeParse(data);
|
|
55
57
|
if (!result.success) {
|
|
56
58
|
throw new Error(`Failed to parse signature response: ${result.error.message}`);
|
|
57
59
|
}
|
package/src/v2/streams/hooks.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useQuery, useMutation, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
2
2
|
import { createQueryOptions } from "../lib/query-config";
|
|
3
3
|
import { streamsQueries } from "./queries";
|
|
4
|
-
import {
|
|
4
|
+
import { requestStreamSignature } from "./api";
|
|
5
5
|
import {
|
|
6
6
|
GetStreamsQuery,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
StreamSignatureRequestInput,
|
|
8
|
+
StreamSignatureRequestOutput,
|
|
9
9
|
Stream,
|
|
10
|
-
|
|
10
|
+
StreamsSupportedChainsResponse,
|
|
11
11
|
} from "./schemas";
|
|
12
12
|
|
|
13
13
|
export interface UseStreamsOptions
|
|
@@ -20,24 +20,27 @@ export function useStreams({ query, ...options }: UseStreamsOptions = {}) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface UseStreamSupportedChainsOptions
|
|
23
|
-
extends Omit<
|
|
23
|
+
extends Omit<
|
|
24
|
+
UseQueryOptions<StreamsSupportedChainsResponse["chains"], Error>,
|
|
25
|
+
"queryKey" | "queryFn"
|
|
26
|
+
> {}
|
|
24
27
|
|
|
25
28
|
export function useStreamSupportedChains(options?: UseStreamSupportedChainsOptions) {
|
|
26
29
|
return useQuery(createQueryOptions(streamsQueries.supportedChains, options));
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
export function
|
|
32
|
+
export function useRequestStreamSignature(
|
|
30
33
|
options?: Omit<
|
|
31
34
|
UseMutationOptions<
|
|
32
|
-
|
|
35
|
+
StreamSignatureRequestOutput,
|
|
33
36
|
Error,
|
|
34
|
-
{ organizationId: string; data:
|
|
37
|
+
{ organizationId: string; data: StreamSignatureRequestInput }
|
|
35
38
|
>,
|
|
36
39
|
"mutationFn"
|
|
37
40
|
>
|
|
38
41
|
) {
|
|
39
42
|
return useMutation({
|
|
40
|
-
mutationFn: ({ organizationId, data }) =>
|
|
43
|
+
mutationFn: ({ organizationId, data }) => requestStreamSignature(organizationId, data),
|
|
41
44
|
...options,
|
|
42
45
|
});
|
|
43
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createQueryKeys } from "@lukemorales/query-key-factory";
|
|
2
|
-
import { getStreams,
|
|
2
|
+
import { getStreams, getStreamsSupportedChains } from "./api";
|
|
3
3
|
import { GetStreamsQuery } from "./schemas";
|
|
4
4
|
|
|
5
5
|
export const streamsQueries = createQueryKeys("streams", {
|
|
@@ -9,6 +9,6 @@ export const streamsQueries = createQueryKeys("streams", {
|
|
|
9
9
|
}),
|
|
10
10
|
supportedChains: {
|
|
11
11
|
queryKey: null,
|
|
12
|
-
queryFn: () =>
|
|
12
|
+
queryFn: () => getStreamsSupportedChains(),
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -53,7 +53,7 @@ export const getStreamsOutputSchema = z.object({
|
|
|
53
53
|
streams: z.array(streamSchema),
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
export const
|
|
56
|
+
export const getStreamsSupportedChainsOutputSchema = z.object({
|
|
57
57
|
success: z.boolean(),
|
|
58
58
|
chains: z.array(
|
|
59
59
|
z.object({
|
|
@@ -70,7 +70,7 @@ export const getSupportedChainsOutputSchema = z.object({
|
|
|
70
70
|
),
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
export const
|
|
73
|
+
export const streamSignatureRequestInputSchema = z.object({
|
|
74
74
|
campaignType: z.number(),
|
|
75
75
|
chainId: z.number(),
|
|
76
76
|
customArgs: z.intersection(
|
|
@@ -88,7 +88,7 @@ export const signatureRequestInputSchema = z.object({
|
|
|
88
88
|
walletAddress: z.string(),
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
export const
|
|
91
|
+
export const streamSignatureRequestOutputSchema = z.object({
|
|
92
92
|
success: z.boolean(),
|
|
93
93
|
message: z.string(),
|
|
94
94
|
txParams: z.object({
|
|
@@ -126,7 +126,7 @@ export const getStreamsQuerySchema = z.object({
|
|
|
126
126
|
|
|
127
127
|
export type Stream = z.infer<typeof streamSchema>;
|
|
128
128
|
export type StreamsSchema = z.infer<typeof getStreamsOutputSchema>;
|
|
129
|
-
export type
|
|
130
|
-
export type
|
|
131
|
-
export type
|
|
129
|
+
export type StreamsSupportedChainsResponse = z.infer<typeof getStreamsSupportedChainsOutputSchema>;
|
|
130
|
+
export type StreamSignatureRequestInput = z.infer<typeof streamSignatureRequestInputSchema>;
|
|
131
|
+
export type StreamSignatureRequestOutput = z.infer<typeof streamSignatureRequestOutputSchema>;
|
|
132
132
|
export type GetStreamsQuery = z.infer<typeof getStreamsQuerySchema>;
|