@turtleclub/hooks 0.5.0-beta.97 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.97",
4
+ "version": "0.5.0-beta.99",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -27,24 +27,24 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@lukemorales/query-key-factory": "^1.3.4",
30
- "@tanstack/query-sync-storage-persister": "^5.55.3",
31
- "@tanstack/react-query-persist-client": "^5.55.3",
32
- "@turtleclub/chains": "0.3.0",
33
- "@turtleclub/utils": "0.4.0-beta.0",
34
- "@wagmi/core": "^2.17.2",
35
- "clsx": "^2.1.1",
30
+ "@tanstack/query-sync-storage-persister": "catalog:",
31
+ "@tanstack/react-query-persist-client": "catalog:",
32
+ "@turtleclub/chains": "0.3.1-beta.0",
33
+ "@turtleclub/utils": "0.4.0-beta.1",
34
+ "@wagmi/core": "catalog:",
35
+ "clsx": "catalog:",
36
36
  "lodash": "^4.17.21",
37
- "tailwind-merge": "^2.5.5",
37
+ "tailwind-merge": "catalog:",
38
38
  "tslog": "^4.9.3",
39
- "viem": "^2.22.7",
40
- "zod": "^3.25.17",
41
- "zustand": "^5.0.3"
39
+ "viem": "catalog:",
40
+ "zod": "catalog:",
41
+ "zustand": "catalog:"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/lodash": "^4.17.17",
45
- "@types/react": "^19.1.5",
45
+ "@types/react": "catalog:",
46
46
  "tsup": "^8.5.0",
47
- "typescript": "^5.8.3"
47
+ "typescript": "catalog:"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@tanstack/react-query": "^5.55.3",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "103e26a0d2f6b4679c7d6a78c9b02041098aa4bd"
57
+ "gitHead": "51dfb4bcde9a62c00d35b790afc9121a2f58e7f3"
58
58
  }
@@ -1,66 +1,66 @@
1
- import { apiClient } from "../lib/api-client";
2
- import type { CoverRequestData, SubmitCoverRequestResponse, CheckCoverRequestResponse, SubmitCoverPurchaseData, SubmitCoverPurchaseResponse } from "./schema";
3
- import { submitCoverRequestResponseSchema, checkCoverRequestResponseSchema, submitCoverPurchaseResponseSchema } from "./schema";
4
-
5
- // POST /turtle/nexus-cover-requests
6
- export async function submitCoverRequest(
7
- data: CoverRequestData
8
- ): Promise<SubmitCoverRequestResponse> {
9
- const response = await apiClient.fetch("/turtle/nexus-cover-requests", {
10
- method: "POST",
11
- body: data,
12
- });
13
-
14
- const result = submitCoverRequestResponseSchema.safeParse(response);
15
-
16
- if (!result.success) {
17
- console.error("[ZOD ERROR]", result.error);
18
- throw new Error(`Failed to submit cover request due to an invalid server response.`);
19
- }
20
-
21
- return result.data;
22
- }
23
-
24
- // POST /turtle/nexus-cover-purchases
25
- export async function submitCoverPurchase(
26
- data: SubmitCoverPurchaseData
27
- ): Promise<SubmitCoverPurchaseResponse> {
28
- const response = await apiClient.fetch("/turtle/nexus-cover-purchases", {
29
- method: "POST",
30
- body: data,
31
- });
32
-
33
- const result = submitCoverPurchaseResponseSchema.safeParse(response);
34
-
35
- if (!result.success) {
36
- console.error("[ZOD ERROR]", result.error);
37
- throw new Error("Failed to submit cover purchase tracking due to an invalid server response.");
38
- }
39
-
40
- return result.data;
41
- }
42
-
43
- // GET /turtle/nexus-cover-requests?protocolName=X
44
- export async function checkCoverRequest({
45
- protocolName,
46
- }: {
47
- protocolName: string;
48
- }): Promise<CheckCoverRequestResponse> {
49
- const params = new URLSearchParams();
50
- params.append("protocolName", protocolName);
51
-
52
- const response = await apiClient.fetch(
53
- `/turtle/nexus-cover-requests?${params.toString()}`,
54
- { method: "GET" }
55
- );
56
-
57
- const result = checkCoverRequestResponseSchema.safeParse(response);
58
-
59
- if (!result.success) {
60
- console.log("[ZOD ERROR]", result.error);
61
- throw new Error("Failed to check cover request due to an invalid server response.");
62
- }
63
-
64
- return result.data;
65
- }
66
-
1
+ import { apiClient } from "../lib/api-client";
2
+ import type { CoverRequestData, SubmitCoverRequestResponse, CheckCoverRequestResponse, SubmitCoverPurchaseData, SubmitCoverPurchaseResponse } from "./schema";
3
+ import { submitCoverRequestResponseSchema, checkCoverRequestResponseSchema, submitCoverPurchaseResponseSchema } from "./schema";
4
+
5
+ // POST /turtle/nexus-cover-requests
6
+ export async function submitCoverRequest(
7
+ data: CoverRequestData
8
+ ): Promise<SubmitCoverRequestResponse> {
9
+ const response = await apiClient.fetch("/turtle/nexus-cover-requests", {
10
+ method: "POST",
11
+ body: data,
12
+ });
13
+
14
+ const result = submitCoverRequestResponseSchema.safeParse(response);
15
+
16
+ if (!result.success) {
17
+ console.error("[ZOD ERROR]", result.error);
18
+ throw new Error(`Failed to submit cover request due to an invalid server response.`);
19
+ }
20
+
21
+ return result.data;
22
+ }
23
+
24
+ // POST /turtle/nexus-cover-purchases
25
+ export async function submitCoverPurchase(
26
+ data: SubmitCoverPurchaseData
27
+ ): Promise<SubmitCoverPurchaseResponse> {
28
+ const response = await apiClient.fetch("/turtle/nexus-cover-purchases", {
29
+ method: "POST",
30
+ body: data,
31
+ });
32
+
33
+ const result = submitCoverPurchaseResponseSchema.safeParse(response);
34
+
35
+ if (!result.success) {
36
+ console.error("[ZOD ERROR]", result.error);
37
+ throw new Error("Failed to submit cover purchase tracking due to an invalid server response.");
38
+ }
39
+
40
+ return result.data;
41
+ }
42
+
43
+ // GET /turtle/nexus-cover-requests?protocolName=X
44
+ export async function checkCoverRequest({
45
+ protocolName,
46
+ }: {
47
+ protocolName: string;
48
+ }): Promise<CheckCoverRequestResponse> {
49
+ const params = new URLSearchParams();
50
+ params.append("protocolName", protocolName);
51
+
52
+ const response = await apiClient.fetch(
53
+ `/turtle/nexus-cover-requests?${params.toString()}`,
54
+ { method: "GET" }
55
+ );
56
+
57
+ const result = checkCoverRequestResponseSchema.safeParse(response);
58
+
59
+ if (!result.success) {
60
+ console.log("[ZOD ERROR]", result.error);
61
+ throw new Error("Failed to check cover request due to an invalid server response.");
62
+ }
63
+
64
+ return result.data;
65
+ }
66
+
@@ -1,38 +1,38 @@
1
- import { useMutation, useQuery } from "@tanstack/react-query";
2
- import { submitCoverRequest } from "./api";
3
- import { coversQueries } from "./queries";
4
- import { queryDefaults } from "../lib/query-config";
5
-
6
- export interface UseSubmitCoverRequestOptions {
7
- onSuccess?: (message: string) => void;
8
- onError?: (message: string) => void;
9
- }
10
-
11
- export function useSubmitCoverRequest(options?: UseSubmitCoverRequestOptions) {
12
- return useMutation({
13
- mutationFn: submitCoverRequest,
14
- onSuccess: () => {
15
- options?.onSuccess?.("Cover request submitted successfully!");
16
- },
17
- onError: (error) => {
18
- console.error("[useSubmitCoverRequest]", error);
19
- options?.onError?.("Failed to submit Cover Request");
20
- },
21
- });
22
- }
23
-
24
- export interface UseCheckCoverRequestOptions {
25
- protocolName: string;
26
- enabled?: boolean;
27
- }
28
-
29
- export function useCheckCoverRequest({
30
- protocolName,
31
- enabled,
32
- }: UseCheckCoverRequestOptions) {
33
- return useQuery({
34
- ...coversQueries.check(protocolName),
35
- ...queryDefaults,
36
- enabled: enabled ?? !!protocolName,
37
- });
38
- }
1
+ import { useMutation, useQuery } from "@tanstack/react-query";
2
+ import { submitCoverRequest } from "./api";
3
+ import { coversQueries } from "./queries";
4
+ import { queryDefaults } from "../lib/query-config";
5
+
6
+ export interface UseSubmitCoverRequestOptions {
7
+ onSuccess?: (message: string) => void;
8
+ onError?: (message: string) => void;
9
+ }
10
+
11
+ export function useSubmitCoverRequest(options?: UseSubmitCoverRequestOptions) {
12
+ return useMutation({
13
+ mutationFn: submitCoverRequest,
14
+ onSuccess: () => {
15
+ options?.onSuccess?.("Cover request submitted successfully!");
16
+ },
17
+ onError: (error) => {
18
+ console.error("[useSubmitCoverRequest]", error);
19
+ options?.onError?.("Failed to submit Cover Request");
20
+ },
21
+ });
22
+ }
23
+
24
+ export interface UseCheckCoverRequestOptions {
25
+ protocolName: string;
26
+ enabled?: boolean;
27
+ }
28
+
29
+ export function useCheckCoverRequest({
30
+ protocolName,
31
+ enabled,
32
+ }: UseCheckCoverRequestOptions) {
33
+ return useQuery({
34
+ ...coversQueries.check(protocolName),
35
+ ...queryDefaults,
36
+ enabled: enabled ?? !!protocolName,
37
+ });
38
+ }
@@ -1,16 +1,16 @@
1
- // Hooks
2
- export { useSubmitCoverRequest, useCheckCoverRequest } from "./hooks";
3
- export type { UseSubmitCoverRequestOptions, UseCheckCoverRequestOptions } from "./hooks";
4
-
5
- // Queries
6
- export { coversQueries } from "./queries";
7
-
8
- // API functions
9
- export { submitCoverRequest, checkCoverRequest, submitCoverPurchase } from "./api";
10
-
11
- // Schemas
12
- export { coverRequestDataSchema, submitCoverRequestResponseSchema, checkCoverRequestResponseSchema, submitCoverPurchaseDataSchema, submitCoverPurchaseResponseSchema } from "./schema";
13
-
14
- // Types
15
- export type { CoverRequestData, SubmitCoverRequestResponse, CheckCoverRequestResponse, SubmitCoverPurchaseData, SubmitCoverPurchaseResponse } from "./schema";
16
-
1
+ // Hooks
2
+ export { useSubmitCoverRequest, useCheckCoverRequest } from "./hooks";
3
+ export type { UseSubmitCoverRequestOptions, UseCheckCoverRequestOptions } from "./hooks";
4
+
5
+ // Queries
6
+ export { coversQueries } from "./queries";
7
+
8
+ // API functions
9
+ export { submitCoverRequest, checkCoverRequest, submitCoverPurchase } from "./api";
10
+
11
+ // Schemas
12
+ export { coverRequestDataSchema, submitCoverRequestResponseSchema, checkCoverRequestResponseSchema, submitCoverPurchaseDataSchema, submitCoverPurchaseResponseSchema } from "./schema";
13
+
14
+ // Types
15
+ export type { CoverRequestData, SubmitCoverRequestResponse, CheckCoverRequestResponse, SubmitCoverPurchaseData, SubmitCoverPurchaseResponse } from "./schema";
16
+
@@ -1,42 +1,42 @@
1
- import { z } from "zod";
2
-
3
- export const coverRequestDataSchema = z.object({
4
- protocolName: z.string(),
5
- coverageAmount: z.string(),
6
- periodDays: z.number(),
7
- desiredApySacrifice: z.string(),
8
- calculatedEstimatedPremium: z.string(),
9
- tokenSymbol: z.string(),
10
- });
11
-
12
-
13
- export const submitCoverRequestResponseSchema = z.object({
14
- success: z.boolean(),
15
- });
16
-
17
-
18
- export const checkCoverRequestResponseSchema = z.object({
19
- canSubmit: z.boolean(),
20
- existingRequest: coverRequestDataSchema.nullable(),
21
- });
22
-
23
- export type CoverRequestData = z.infer<typeof coverRequestDataSchema>;
24
- export type SubmitCoverRequestResponse = z.infer<typeof submitCoverRequestResponseSchema>;
25
- export type CheckCoverRequestResponse = z.infer<typeof checkCoverRequestResponseSchema>;
26
-
27
- // --- Nexus Cover Purchase Tracking ---
28
-
29
- export const submitCoverPurchaseDataSchema = z.object({
30
- walletAddress: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address"),
31
- txHash: z.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid transaction hash"),
32
- });
33
-
34
- export const submitCoverPurchaseResponseSchema = z.object({
35
- success: z.boolean(),
36
- message: z.string(),
37
- id: z.string(),
38
- });
39
-
40
- export type SubmitCoverPurchaseData = z.infer<typeof submitCoverPurchaseDataSchema>;
41
- export type SubmitCoverPurchaseResponse = z.infer<typeof submitCoverPurchaseResponseSchema>;
42
-
1
+ import { z } from "zod";
2
+
3
+ export const coverRequestDataSchema = z.object({
4
+ protocolName: z.string(),
5
+ coverageAmount: z.string(),
6
+ periodDays: z.number(),
7
+ desiredApySacrifice: z.string(),
8
+ calculatedEstimatedPremium: z.string(),
9
+ tokenSymbol: z.string(),
10
+ });
11
+
12
+
13
+ export const submitCoverRequestResponseSchema = z.object({
14
+ success: z.boolean(),
15
+ });
16
+
17
+
18
+ export const checkCoverRequestResponseSchema = z.object({
19
+ canSubmit: z.boolean(),
20
+ existingRequest: coverRequestDataSchema.nullable(),
21
+ });
22
+
23
+ export type CoverRequestData = z.infer<typeof coverRequestDataSchema>;
24
+ export type SubmitCoverRequestResponse = z.infer<typeof submitCoverRequestResponseSchema>;
25
+ export type CheckCoverRequestResponse = z.infer<typeof checkCoverRequestResponseSchema>;
26
+
27
+ // --- Nexus Cover Purchase Tracking ---
28
+
29
+ export const submitCoverPurchaseDataSchema = z.object({
30
+ walletAddress: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address"),
31
+ txHash: z.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid transaction hash"),
32
+ });
33
+
34
+ export const submitCoverPurchaseResponseSchema = z.object({
35
+ success: z.boolean(),
36
+ message: z.string(),
37
+ id: z.string(),
38
+ });
39
+
40
+ export type SubmitCoverPurchaseData = z.infer<typeof submitCoverPurchaseDataSchema>;
41
+ export type SubmitCoverPurchaseResponse = z.infer<typeof submitCoverPurchaseResponseSchema>;
42
+
@@ -1,25 +1,25 @@
1
- import type { UserNft } from "./schema";
2
-
3
-
4
- const LUMON_API_BASE_URL = "https://lumon.turtle.xyz";
5
-
6
- export async function fetchUserNfts(userAddress: string, chain: number): Promise<UserNft[]> {
7
- const endpoint = `${LUMON_API_BASE_URL}/query/token/erc721_portfolio`;
8
- const response = await fetch(endpoint, {
9
- method: "POST",
10
- headers: {
11
- "Content-Type": "application/json",
12
- },
13
- body: JSON.stringify({
14
- user: userAddress,
15
- chain,
16
- }),
17
- });
18
-
19
- if (!response.ok) {
20
- throw new Error("Failed to fetch user NFTs");
21
- }
22
-
23
- return response.json();
24
- }
25
-
1
+ import type { UserNft } from "./schema";
2
+
3
+
4
+ const LUMON_API_BASE_URL = "https://lumon.turtle.xyz";
5
+
6
+ export async function fetchUserNfts(userAddress: string, chain: number): Promise<UserNft[]> {
7
+ const endpoint = `${LUMON_API_BASE_URL}/query/token/erc721_portfolio`;
8
+ const response = await fetch(endpoint, {
9
+ method: "POST",
10
+ headers: {
11
+ "Content-Type": "application/json",
12
+ },
13
+ body: JSON.stringify({
14
+ user: userAddress,
15
+ chain,
16
+ }),
17
+ });
18
+
19
+ if (!response.ok) {
20
+ throw new Error("Failed to fetch user NFTs");
21
+ }
22
+
23
+ return response.json();
24
+ }
25
+
@@ -1,26 +1,26 @@
1
- import { skipToken, useQuery } from "@tanstack/react-query";
2
- import { createQueryOptions } from "../lib/query-config";
3
- import { nftsQueries } from "./queries";
4
- import type { UserNft } from "./schema";
5
-
6
- export interface UseUserNftsOptions {
7
- userAddress: string | undefined;
8
- chain: number;
9
- tokenAddress?: string;
10
- refetchInterval?: number | false;
11
- }
12
-
13
- export function useUserNfts({ userAddress, chain, tokenAddress, refetchInterval }: UseUserNftsOptions) {
14
- return useQuery(
15
- userAddress
16
- ? createQueryOptions(nftsQueries.byUser(userAddress, chain), {
17
- select: (data: UserNft[]) =>
18
- tokenAddress
19
- ? data.filter((nft) => nft.token.toLowerCase() === tokenAddress.toLowerCase())
20
- : data,
21
- refetchInterval,
22
- })
23
- : { queryKey: ["nfts", "byUser", "skip"], queryFn: skipToken }
24
- );
25
- }
26
-
1
+ import { skipToken, useQuery } from "@tanstack/react-query";
2
+ import { createQueryOptions } from "../lib/query-config";
3
+ import { nftsQueries } from "./queries";
4
+ import type { UserNft } from "./schema";
5
+
6
+ export interface UseUserNftsOptions {
7
+ userAddress: string | undefined;
8
+ chain: number;
9
+ tokenAddress?: string;
10
+ refetchInterval?: number | false;
11
+ }
12
+
13
+ export function useUserNfts({ userAddress, chain, tokenAddress, refetchInterval }: UseUserNftsOptions) {
14
+ return useQuery(
15
+ userAddress
16
+ ? createQueryOptions(nftsQueries.byUser(userAddress, chain), {
17
+ select: (data: UserNft[]) =>
18
+ tokenAddress
19
+ ? data.filter((nft) => nft.token.toLowerCase() === tokenAddress.toLowerCase())
20
+ : data,
21
+ refetchInterval,
22
+ })
23
+ : { queryKey: ["nfts", "byUser", "skip"], queryFn: skipToken }
24
+ );
25
+ }
26
+
@@ -1,13 +1,13 @@
1
- // Hooks
2
- export { useUserNfts } from "./hooks";
3
- export type { UseUserNftsOptions } from "./hooks";
4
-
5
- // Query keys
6
- export { nftsQueries } from "./queries";
7
-
8
- // API functions
9
- export { fetchUserNfts } from "./api";
10
-
11
- // Types
12
- export type { UserNft, UserNftsFilters } from "./schema";
13
-
1
+ // Hooks
2
+ export { useUserNfts } from "./hooks";
3
+ export type { UseUserNftsOptions } from "./hooks";
4
+
5
+ // Query keys
6
+ export { nftsQueries } from "./queries";
7
+
8
+ // API functions
9
+ export { fetchUserNfts } from "./api";
10
+
11
+ // Types
12
+ export type { UserNft, UserNftsFilters } from "./schema";
13
+
@@ -1,10 +1,10 @@
1
- import { createQueryKeys } from "@lukemorales/query-key-factory";
2
- import { fetchUserNfts } from "./api";
3
-
4
- export const nftsQueries = createQueryKeys("nfts", {
5
- byUser: (userAddress: string, chain: number) => ({
6
- queryKey: [userAddress, chain],
7
- queryFn: () => fetchUserNfts(userAddress, chain),
8
- }),
9
- });
10
-
1
+ import { createQueryKeys } from "@lukemorales/query-key-factory";
2
+ import { fetchUserNfts } from "./api";
3
+
4
+ export const nftsQueries = createQueryKeys("nfts", {
5
+ byUser: (userAddress: string, chain: number) => ({
6
+ queryKey: [userAddress, chain],
7
+ queryFn: () => fetchUserNfts(userAddress, chain),
8
+ }),
9
+ });
10
+
@@ -1,12 +1,12 @@
1
- export interface UserNft {
2
- user: string;
3
- chain: number;
4
- token: string;
5
- token_id: string;
6
- last_transfer: string;
7
- }
8
-
9
- export interface UserNftsFilters {
10
- tokenAddress?: string;
11
- }
12
-
1
+ export interface UserNft {
2
+ user: string;
3
+ chain: number;
4
+ token: string;
5
+ token_id: string;
6
+ last_transfer: string;
7
+ }
8
+
9
+ export interface UserNftsFilters {
10
+ tokenAddress?: string;
11
+ }
12
+
@@ -12,7 +12,7 @@ export const organizationSchema = z.object({
12
12
  z.object({
13
13
  id: z.string().uuid(),
14
14
  permissionId: z.string().uuid(),
15
- status: z.enum(["revoked", "approved"]),
15
+ status: z.enum(["pending", "approved", "rejected", "revoked"]),
16
16
  permissionName: z.string(),
17
17
  })
18
18
  )
@@ -20,12 +20,9 @@ import {
20
20
  CreateStreamPointBody,
21
21
  CreateStreamPointOutput,
22
22
  createStreamPointOutputSchema,
23
- PauseStreamSnapshotComputationBody,
24
- PauseStreamSnapshotComputationOutput,
25
- pauseStreamSnapshotComputationOutputSchema,
26
- StopStreamBody,
27
- StopStreamOutput,
28
- stopStreamOutputSchema,
23
+ UpdateStreamBody,
24
+ UpdateStreamOutput,
25
+ updateStreamOutputSchema,
29
26
  DeleteStreamOutput,
30
27
  deleteStreamOutputSchema,
31
28
  } from "./schemas";
@@ -167,39 +164,20 @@ export async function requestStreamSignature(
167
164
  return result.data;
168
165
  }
169
166
 
170
- export async function pauseStreamSnapshotComputation(
167
+ export async function updateStream(
171
168
  organizationId: string,
172
- body: PauseStreamSnapshotComputationBody
173
- ): Promise<PauseStreamSnapshotComputationOutput> {
169
+ body: UpdateStreamBody
170
+ ): Promise<UpdateStreamOutput> {
174
171
  const endpoint = `/streams/${organizationId}`;
175
172
  const data = await apiClient.fetch(endpoint, {
176
173
  method: "PATCH",
177
174
  body,
178
175
  });
179
176
 
180
- const result = pauseStreamSnapshotComputationOutputSchema.safeParse(data);
177
+ const result = updateStreamOutputSchema.safeParse(data);
181
178
 
182
179
  if (!result.success) {
183
- throw new Error(`Failed to parse pause stream snapshot response: ${result.error.message}`);
184
- }
185
-
186
- return result.data;
187
- }
188
-
189
- export async function stopStream(
190
- organizationId: string,
191
- body: StopStreamBody
192
- ): Promise<StopStreamOutput> {
193
- const endpoint = `/streams/${organizationId}`;
194
- const data = await apiClient.fetch(endpoint, {
195
- method: "PATCH",
196
- body,
197
- });
198
-
199
- const result = stopStreamOutputSchema.safeParse(data);
200
-
201
- if (!result.success) {
202
- throw new Error(`Failed to parse stop stream response: ${result.error.message}`);
180
+ throw new Error(`Failed to parse update stream response: ${result.error.message}`);
203
181
  }
204
182
 
205
183
  return result.data;