@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.8",
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": "0b675d696684bba909e149eb26fb4bba7322a82e"
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
 
@@ -3,11 +3,11 @@ import {
3
3
  GetStreamsQuery,
4
4
  getStreamsOutputSchema,
5
5
  StreamsSchema,
6
- getSupportedChainsOutputSchema,
7
- SupportedChainsResponse,
8
- SignatureRequestInput,
9
- signatureRequestOutputSchema,
10
- SignatureRequestOutput,
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 getSupportedChains(): Promise<SupportedChainsResponse["chains"]> {
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 = getSupportedChainsOutputSchema.safeParse(data);
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 signatureRequest(
46
+ export async function requestStreamSignature(
45
47
  organizationId: string,
46
- input: SignatureRequestInput
47
- ): Promise<SignatureRequestOutput> {
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 = signatureRequestOutputSchema.safeParse(data);
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
  }
@@ -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 { signatureRequest } from "./api";
4
+ import { requestStreamSignature } from "./api";
5
5
  import {
6
6
  GetStreamsQuery,
7
- SignatureRequestInput,
8
- SignatureRequestOutput,
7
+ StreamSignatureRequestInput,
8
+ StreamSignatureRequestOutput,
9
9
  Stream,
10
- SupportedChainsResponse,
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<UseQueryOptions<SupportedChainsResponse["chains"], Error>, "queryKey" | "queryFn"> {}
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 useSignatureRequest(
32
+ export function useRequestStreamSignature(
30
33
  options?: Omit<
31
34
  UseMutationOptions<
32
- SignatureRequestOutput,
35
+ StreamSignatureRequestOutput,
33
36
  Error,
34
- { organizationId: string; data: SignatureRequestInput }
37
+ { organizationId: string; data: StreamSignatureRequestInput }
35
38
  >,
36
39
  "mutationFn"
37
40
  >
38
41
  ) {
39
42
  return useMutation({
40
- mutationFn: ({ organizationId, data }) => signatureRequest(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, getSupportedChains } from "./api";
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: () => getSupportedChains(),
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 getSupportedChainsOutputSchema = z.object({
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 signatureRequestInputSchema = z.object({
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 signatureRequestOutputSchema = z.object({
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 SupportedChainsResponse = z.infer<typeof getSupportedChainsOutputSchema>;
130
- export type SignatureRequestInput = z.infer<typeof signatureRequestInputSchema>;
131
- export type SignatureRequestOutput = z.infer<typeof signatureRequestOutputSchema>;
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>;