@turtleclub/hooks 0.5.0-beta.13 → 0.5.0-beta.14
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 +106 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +97 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/covers/api.ts +23 -0
- package/src/v2/covers/hooks.ts +20 -0
- package/src/v2/covers/index.ts +13 -0
- package/src/v2/covers/schema.ts +20 -0
- package/src/v2/index.ts +5 -1
- package/src/v2/nfts/api.ts +25 -0
- package/src/v2/nfts/hooks.ts +24 -0
- package/src/v2/nfts/index.ts +13 -0
- package/src/v2/nfts/queries.ts +10 -0
- package/src/v2/nfts/schema.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1219,6 +1219,37 @@ var usersQueries = createQueryKeys13("users", {
|
|
|
1219
1219
|
})
|
|
1220
1220
|
});
|
|
1221
1221
|
|
|
1222
|
+
// src/v2/nfts/queries.ts
|
|
1223
|
+
import { createQueryKeys as createQueryKeys14 } from "@lukemorales/query-key-factory";
|
|
1224
|
+
|
|
1225
|
+
// src/v2/nfts/api.ts
|
|
1226
|
+
var LUMON_API_BASE_URL = "https://lumon.turtle.xyz";
|
|
1227
|
+
async function fetchUserNfts(userAddress, chain) {
|
|
1228
|
+
const endpoint = `${LUMON_API_BASE_URL}/query/token/erc721_portfolio`;
|
|
1229
|
+
const response = await fetch(endpoint, {
|
|
1230
|
+
method: "POST",
|
|
1231
|
+
headers: {
|
|
1232
|
+
"Content-Type": "application/json"
|
|
1233
|
+
},
|
|
1234
|
+
body: JSON.stringify({
|
|
1235
|
+
user: userAddress,
|
|
1236
|
+
chain
|
|
1237
|
+
})
|
|
1238
|
+
});
|
|
1239
|
+
if (!response.ok) {
|
|
1240
|
+
throw new Error("Failed to fetch user NFTs");
|
|
1241
|
+
}
|
|
1242
|
+
return response.json();
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// src/v2/nfts/queries.ts
|
|
1246
|
+
var nftsQueries = createQueryKeys14("nfts", {
|
|
1247
|
+
byUser: (userAddress, chain) => ({
|
|
1248
|
+
queryKey: [userAddress, chain],
|
|
1249
|
+
queryFn: () => fetchUserNfts(userAddress, chain)
|
|
1250
|
+
})
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1222
1253
|
// src/v2/earn-opportunities/hooks.ts
|
|
1223
1254
|
import { useQuery } from "@tanstack/react-query";
|
|
1224
1255
|
|
|
@@ -1595,8 +1626,8 @@ async function getPortfolioBalance(address, options) {
|
|
|
1595
1626
|
}
|
|
1596
1627
|
|
|
1597
1628
|
// src/v2/balance/queries.ts
|
|
1598
|
-
import { createQueryKeys as
|
|
1599
|
-
var balanceQueries =
|
|
1629
|
+
import { createQueryKeys as createQueryKeys15 } from "@lukemorales/query-key-factory";
|
|
1630
|
+
var balanceQueries = createQueryKeys15("balance", {
|
|
1600
1631
|
// Portfolio balance by address
|
|
1601
1632
|
portfolio: (address) => ({
|
|
1602
1633
|
queryKey: [address],
|
|
@@ -2175,6 +2206,61 @@ function useUserPortfolio({ userId, enabled = true }) {
|
|
|
2175
2206
|
});
|
|
2176
2207
|
}
|
|
2177
2208
|
|
|
2209
|
+
// src/v2/nfts/hooks.ts
|
|
2210
|
+
import { skipToken, useQuery as useQuery14 } from "@tanstack/react-query";
|
|
2211
|
+
function useUserNfts({ userAddress, chain, tokenAddress }) {
|
|
2212
|
+
return useQuery14(
|
|
2213
|
+
userAddress ? createQueryOptions(nftsQueries.byUser(userAddress, chain), {
|
|
2214
|
+
select: (data) => tokenAddress ? data.filter((nft) => nft.token.toLowerCase() === tokenAddress.toLowerCase()) : data
|
|
2215
|
+
}) : { queryKey: ["nfts", "byUser", "skip"], queryFn: skipToken }
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
// src/v2/covers/hooks.ts
|
|
2220
|
+
import { useMutation as useMutation5 } from "@tanstack/react-query";
|
|
2221
|
+
|
|
2222
|
+
// src/v2/covers/schema.ts
|
|
2223
|
+
import { z as z16 } from "zod";
|
|
2224
|
+
var coverRequestDataSchema = z16.object({
|
|
2225
|
+
protocolName: z16.string(),
|
|
2226
|
+
coverageAmount: z16.string(),
|
|
2227
|
+
periodDays: z16.number(),
|
|
2228
|
+
desiredApySacrifice: z16.string(),
|
|
2229
|
+
calculatedEstimatedPremium: z16.string(),
|
|
2230
|
+
tokenSymbol: z16.string()
|
|
2231
|
+
});
|
|
2232
|
+
var submitCoverRequestResponseSchema = z16.object({
|
|
2233
|
+
success: z16.boolean()
|
|
2234
|
+
});
|
|
2235
|
+
|
|
2236
|
+
// src/v2/covers/api.ts
|
|
2237
|
+
async function submitCoverRequest(data) {
|
|
2238
|
+
const response = await apiClient.fetch("/turtle/nexus-cover-requests", {
|
|
2239
|
+
method: "POST",
|
|
2240
|
+
body: data
|
|
2241
|
+
});
|
|
2242
|
+
const result = submitCoverRequestResponseSchema.safeParse(response);
|
|
2243
|
+
if (!result.success) {
|
|
2244
|
+
console.log("[ZOD ERROR]", result.error);
|
|
2245
|
+
throw new Error(`Failed to submit cover request due to an invalid server response.`);
|
|
2246
|
+
}
|
|
2247
|
+
return result.data;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// src/v2/covers/hooks.ts
|
|
2251
|
+
function useSubmitCoverRequest(options) {
|
|
2252
|
+
return useMutation5({
|
|
2253
|
+
mutationFn: submitCoverRequest,
|
|
2254
|
+
onSuccess: () => {
|
|
2255
|
+
options?.onSuccess?.("Cover request submitted successfully!");
|
|
2256
|
+
},
|
|
2257
|
+
onError: (error) => {
|
|
2258
|
+
console.error("[useSubmitCoverRequest]", error);
|
|
2259
|
+
options?.onError?.("Failed to submit Cover Request");
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2178
2264
|
// src/v2/lib/turtle-provider.tsx
|
|
2179
2265
|
import { useEffect, useMemo as useMemo9 } from "react";
|
|
2180
2266
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
@@ -2209,7 +2295,8 @@ var queries = mergeQueryKeys(
|
|
|
2209
2295
|
streamsQueries,
|
|
2210
2296
|
supportedChainsQueries,
|
|
2211
2297
|
supportedTokensQueries,
|
|
2212
|
-
usersQueries
|
|
2298
|
+
usersQueries,
|
|
2299
|
+
nftsQueries
|
|
2213
2300
|
);
|
|
2214
2301
|
export {
|
|
2215
2302
|
ApiError,
|
|
@@ -2226,6 +2313,7 @@ export {
|
|
|
2226
2313
|
chainSchema,
|
|
2227
2314
|
checkMembership,
|
|
2228
2315
|
checkMembershipResponseSchema,
|
|
2316
|
+
coverRequestDataSchema,
|
|
2229
2317
|
createAgreementRequestSchema,
|
|
2230
2318
|
createAgreementResponseSchema,
|
|
2231
2319
|
createClaimWithdrawInteraction,
|
|
@@ -2248,6 +2336,7 @@ export {
|
|
|
2248
2336
|
earnRouteResponseSchema,
|
|
2249
2337
|
ensoBalancesQueries,
|
|
2250
2338
|
ensoStep,
|
|
2339
|
+
fetchUserNfts,
|
|
2251
2340
|
filterBalancesByChains,
|
|
2252
2341
|
filterExcludedTokens,
|
|
2253
2342
|
filterNonZeroBalances,
|
|
@@ -2281,6 +2370,7 @@ export {
|
|
|
2281
2370
|
interactionResponseSchema,
|
|
2282
2371
|
lendingConfigSchema,
|
|
2283
2372
|
mergeBalancesByPriority,
|
|
2373
|
+
nftsQueries,
|
|
2284
2374
|
opportunitiesQueries,
|
|
2285
2375
|
opportunitySchema,
|
|
2286
2376
|
organizationSchema,
|
|
@@ -2304,6 +2394,8 @@ export {
|
|
|
2304
2394
|
streamSignatureRequestInputSchema,
|
|
2305
2395
|
streamSignatureRequestOutputSchema,
|
|
2306
2396
|
streamsQueries,
|
|
2397
|
+
submitCoverRequest,
|
|
2398
|
+
submitCoverRequestResponseSchema,
|
|
2307
2399
|
supportedChainsQueries,
|
|
2308
2400
|
supportedChainsResponseSchema,
|
|
2309
2401
|
supportedTokenSchema,
|
|
@@ -2337,6 +2429,7 @@ export {
|
|
|
2337
2429
|
useRequestStreamSignature,
|
|
2338
2430
|
useStreamSupportedChains,
|
|
2339
2431
|
useStreams,
|
|
2432
|
+
useSubmitCoverRequest,
|
|
2340
2433
|
useSupportedChains,
|
|
2341
2434
|
useSupportedTokens,
|
|
2342
2435
|
useSwapRoute,
|
|
@@ -2344,6 +2437,7 @@ export {
|
|
|
2344
2437
|
useUpdateProduct,
|
|
2345
2438
|
useUploadProductLogo,
|
|
2346
2439
|
useUserById,
|
|
2440
|
+
useUserNfts,
|
|
2347
2441
|
useUserPortfolio,
|
|
2348
2442
|
useWidgetOpportunities,
|
|
2349
2443
|
userEarningsSchema,
|