@turtleclub/hooks 0.5.0-beta.23 → 0.5.0-beta.25

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 CHANGED
@@ -80,6 +80,10 @@ __export(index_exports, {
80
80
  getPortfolioBalance: () => getPortfolioBalance,
81
81
  getProducts: () => getProducts,
82
82
  getSourcePriority: () => getSourcePriority,
83
+ getStreamWalletDetails: () => getStreamWalletDetails,
84
+ getStreamWalletDetailsResponseSchema: () => getStreamWalletDetailsResponseSchema,
85
+ getStreamWallets: () => getStreamWallets,
86
+ getStreamWalletsResponseSchema: () => getStreamWalletsResponseSchema,
83
87
  getStreams: () => getStreams,
84
88
  getStreamsOutputSchema: () => getStreamsOutputSchema,
85
89
  getStreamsQuerySchema: () => getStreamsQuerySchema,
@@ -123,6 +127,9 @@ __export(index_exports, {
123
127
  streamSchema: () => streamSchema,
124
128
  streamSignatureRequestInputSchema: () => streamSignatureRequestInputSchema,
125
129
  streamSignatureRequestOutputSchema: () => streamSignatureRequestOutputSchema,
130
+ streamWalletDetailsSchema: () => streamWalletDetailsSchema,
131
+ streamWalletSchema: () => streamWalletSchema,
132
+ streamWalletSnapshotSchema: () => streamWalletSnapshotSchema,
126
133
  streamsQueries: () => streamsQueries,
127
134
  submitCoverRequest: () => submitCoverRequest,
128
135
  submitCoverRequestResponseSchema: () => submitCoverRequestResponseSchema,
@@ -164,6 +171,8 @@ __export(index_exports, {
164
171
  useProducts: () => useProducts,
165
172
  useRequestStreamSignature: () => useRequestStreamSignature,
166
173
  useStreamSupportedChains: () => useStreamSupportedChains,
174
+ useStreamWalletDetails: () => useStreamWalletDetails,
175
+ useStreamWallets: () => useStreamWallets,
167
176
  useStreams: () => useStreams,
168
177
  useSubmitCoverRequest: () => useSubmitCoverRequest,
169
178
  useSupportedChains: () => useSupportedChains,
@@ -1199,6 +1208,29 @@ var getStreamsQuerySchema = import_zod10.z.object({
1199
1208
  withSnapshots: import_zod10.z.boolean().optional(),
1200
1209
  usersCount: import_zod10.z.boolean().optional()
1201
1210
  });
1211
+ var streamWalletSnapshotSchema = import_zod10.z.object({
1212
+ timestamp: import_zod10.z.string().datetime(),
1213
+ rewardsAccumulated: import_zod10.z.string(),
1214
+ rewardsAccumulatedBase: import_zod10.z.string(),
1215
+ createdAt: import_zod10.z.string().datetime(),
1216
+ updatedAt: import_zod10.z.string().datetime(),
1217
+ tvl: import_zod10.z.string().nullable().optional()
1218
+ });
1219
+ var streamWalletSchema = import_zod10.z.object({
1220
+ userAddress: import_zod10.z.string(),
1221
+ lastSnapshot: streamWalletSnapshotSchema
1222
+ });
1223
+ var getStreamWalletsResponseSchema = import_zod10.z.object({
1224
+ wallets: import_zod10.z.array(streamWalletSchema)
1225
+ });
1226
+ var streamWalletDetailsSchema = import_zod10.z.object({
1227
+ streamId: import_zod10.z.string(),
1228
+ userAddress: import_zod10.z.string(),
1229
+ snapshots: import_zod10.z.array(streamWalletSnapshotSchema)
1230
+ });
1231
+ var getStreamWalletDetailsResponseSchema = import_zod10.z.object({
1232
+ wallet: streamWalletDetailsSchema
1233
+ });
1202
1234
 
1203
1235
  // src/v2/streams/api.ts
1204
1236
  async function getStreams(query) {
@@ -1217,11 +1249,36 @@ async function getStreams(query) {
1217
1249
  "Zod Validation Error in getStreams:",
1218
1250
  JSON.stringify(result.error.format(), null, 2)
1219
1251
  );
1220
- console.error("Received Data:", data);
1221
1252
  throw new Error(`Failed to parse streams: ${result.error.message}`);
1222
1253
  }
1223
1254
  return result.data.streams;
1224
1255
  }
1256
+ async function getStreamWallets(streamId) {
1257
+ const endpoint = `/streams/${streamId}/wallets/`;
1258
+ const data = await apiClient.fetch(endpoint, { method: "GET" });
1259
+ const result = getStreamWalletsResponseSchema.safeParse(data);
1260
+ if (!result.success) {
1261
+ console.error(
1262
+ "Zod Validation Error in getStreamWallets:",
1263
+ JSON.stringify(result.error.format(), null, 2)
1264
+ );
1265
+ throw new Error(`Failed to parse stream wallets: ${result.error.message}`);
1266
+ }
1267
+ return result.data.wallets;
1268
+ }
1269
+ async function getStreamWalletDetails(streamId, userAddress) {
1270
+ const endpoint = `/streams/${streamId}/wallets/${userAddress}`;
1271
+ const data = await apiClient.fetch(endpoint, { method: "GET" });
1272
+ const result = getStreamWalletDetailsResponseSchema.safeParse(data);
1273
+ if (!result.success) {
1274
+ console.error(
1275
+ "Zod Validation Error in getStreamWalletDetails:",
1276
+ JSON.stringify(result.error.format(), null, 2)
1277
+ );
1278
+ throw new Error(`Failed to parse stream wallet details: ${result.error.message}`);
1279
+ }
1280
+ return result.data.wallet;
1281
+ }
1225
1282
  async function getStreamsSupportedChains() {
1226
1283
  const endpoint = "/streams/supported_chains";
1227
1284
  const data = await apiClient.fetch(endpoint, { method: "GET" });
@@ -1250,6 +1307,14 @@ var streamsQueries = (0, import_query_key_factory10.createQueryKeys)("streams",
1250
1307
  queryKey: [query ?? "all"],
1251
1308
  queryFn: () => getStreams(query)
1252
1309
  }),
1310
+ wallets: (streamId) => ({
1311
+ queryKey: [streamId],
1312
+ queryFn: () => getStreamWallets(streamId)
1313
+ }),
1314
+ walletDetails: (params) => ({
1315
+ queryKey: [params],
1316
+ queryFn: () => getStreamWalletDetails(params.streamId, params.userAddress)
1317
+ }),
1253
1318
  supportedChains: {
1254
1319
  queryKey: null,
1255
1320
  queryFn: () => getStreamsSupportedChains()
@@ -1621,7 +1686,7 @@ async function attributeAction(params) {
1621
1686
  const data = await apiClient.fetch(`/v1/actions/attribute/${actionId}`, {
1622
1687
  method: "POST",
1623
1688
  domain: "earn",
1624
- body: JSON.stringify({ txHash }),
1689
+ body: { txHash },
1625
1690
  headers: {
1626
1691
  "Content-Type": "application/json"
1627
1692
  }
@@ -2330,9 +2395,17 @@ function useGeocheck(options = {}) {
2330
2395
 
2331
2396
  // src/v2/streams/hooks.ts
2332
2397
  var import_react_query14 = require("@tanstack/react-query");
2333
- function useStreams({ query, ...options } = {}) {
2398
+ function useStreams(query, options) {
2334
2399
  return (0, import_react_query14.useQuery)(createQueryOptions(streamsQueries.list(query), options));
2335
2400
  }
2401
+ function useStreamWallets(streamId, options) {
2402
+ return (0, import_react_query14.useQuery)(createQueryOptions(streamsQueries.wallets(streamId), options));
2403
+ }
2404
+ function useStreamWalletDetails(streamId, userAddress, options) {
2405
+ return (0, import_react_query14.useQuery)(
2406
+ createQueryOptions(streamsQueries.walletDetails({ streamId, userAddress }), options)
2407
+ );
2408
+ }
2336
2409
  function useStreamSupportedChains(options) {
2337
2410
  return (0, import_react_query14.useQuery)(createQueryOptions(streamsQueries.supportedChains, options));
2338
2411
  }
@@ -2613,6 +2686,10 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
2613
2686
  getPortfolioBalance,
2614
2687
  getProducts,
2615
2688
  getSourcePriority,
2689
+ getStreamWalletDetails,
2690
+ getStreamWalletDetailsResponseSchema,
2691
+ getStreamWallets,
2692
+ getStreamWalletsResponseSchema,
2616
2693
  getStreams,
2617
2694
  getStreamsOutputSchema,
2618
2695
  getStreamsQuerySchema,
@@ -2656,6 +2733,9 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
2656
2733
  streamSchema,
2657
2734
  streamSignatureRequestInputSchema,
2658
2735
  streamSignatureRequestOutputSchema,
2736
+ streamWalletDetailsSchema,
2737
+ streamWalletSchema,
2738
+ streamWalletSnapshotSchema,
2659
2739
  streamsQueries,
2660
2740
  submitCoverRequest,
2661
2741
  submitCoverRequestResponseSchema,
@@ -2697,6 +2777,8 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
2697
2777
  useProducts,
2698
2778
  useRequestStreamSignature,
2699
2779
  useStreamSupportedChains,
2780
+ useStreamWalletDetails,
2781
+ useStreamWallets,
2700
2782
  useStreams,
2701
2783
  useSubmitCoverRequest,
2702
2784
  useSupportedChains,