@zenland/sdk 0.1.0

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/react.cjs ADDED
@@ -0,0 +1,743 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/react.ts
22
+ var react_exports = {};
23
+ __export(react_exports, {
24
+ STATE_GROUPS: () => STATE_GROUPS,
25
+ ZenlandProvider: () => ZenlandProvider,
26
+ createZenlandClient: () => createZenlandClient,
27
+ useAgent: () => useAgent,
28
+ useAgents: () => useAgents,
29
+ useEscrow: () => useEscrow,
30
+ useEscrows: () => useEscrows,
31
+ useGlobalStats: () => useGlobalStats,
32
+ useProtocolStats: () => useProtocolStats,
33
+ useRecentEscrows: () => useRecentEscrows,
34
+ useTransactionLogsByEscrow: () => useTransactionLogsByEscrow,
35
+ useUserStats: () => useUserStats,
36
+ useZenlandClient: () => useZenlandClient,
37
+ useZenlandClientOptional: () => useZenlandClientOptional
38
+ });
39
+ module.exports = __toCommonJS(react_exports);
40
+
41
+ // src/react/context.tsx
42
+ var import_react = require("react");
43
+
44
+ // src/request.ts
45
+ var ZenlandGraphQLError = class extends Error {
46
+ errors;
47
+ constructor(message, errors) {
48
+ super(message);
49
+ this.name = "ZenlandGraphQLError";
50
+ this.errors = errors;
51
+ }
52
+ };
53
+ var ZenlandRequestError = class extends Error {
54
+ status;
55
+ statusText;
56
+ constructor(message, status, statusText) {
57
+ super(message);
58
+ this.name = "ZenlandRequestError";
59
+ this.status = status;
60
+ this.statusText = statusText;
61
+ }
62
+ };
63
+ async function graphqlRequest(baseUrl, document, variables, options) {
64
+ const endpoint = `${baseUrl}/graphql`;
65
+ const res = await fetch(endpoint, {
66
+ method: "POST",
67
+ headers: {
68
+ "content-type": "application/json"
69
+ },
70
+ body: JSON.stringify({ query: document, variables }),
71
+ signal: options?.signal,
72
+ cache: "no-store"
73
+ });
74
+ if (!res.ok) {
75
+ const text = await res.text().catch(() => "");
76
+ throw new ZenlandRequestError(
77
+ `Zenland request failed (${res.status} ${res.statusText})${text ? `: ${text}` : ""}`,
78
+ res.status,
79
+ res.statusText
80
+ );
81
+ }
82
+ const json = await res.json();
83
+ if (json.errors?.length) {
84
+ throw new ZenlandGraphQLError(
85
+ json.errors.map((e) => e.message ?? "GraphQL error").join("; "),
86
+ json.errors
87
+ );
88
+ }
89
+ if (!json.data) {
90
+ throw new Error("Zenland response missing data.");
91
+ }
92
+ return json.data;
93
+ }
94
+
95
+ // src/queries.ts
96
+ var AGENT_QUERY = `
97
+ query Agent($id: String!) {
98
+ agent(id: $id) {
99
+ id
100
+ isActive
101
+ isAvailable
102
+ stablecoinDecimals
103
+ stablecoinToken
104
+ stablecoinStake
105
+ daoTokenStake
106
+ disputeFeeBps
107
+ assignmentFeeBps
108
+ description
109
+ contact
110
+ totalResolved
111
+ activeCases
112
+ registrationTime
113
+ lastEngagementTimestamp
114
+ totalEarnings
115
+ totalSlashed
116
+ cases(limit: 5, orderBy: "invitedAt", orderDirection: "desc") {
117
+ items {
118
+ id
119
+ escrow
120
+ invitedAt
121
+ resolvedAt
122
+ timedOut
123
+ escrowRef {
124
+ id
125
+ amount
126
+ token
127
+ state
128
+ }
129
+ }
130
+ totalCount
131
+ }
132
+ }
133
+ }
134
+ `;
135
+ var AGENTS_QUERY = `
136
+ query Agents($where: agentFilter, $orderBy: String, $orderDirection: String, $limit: Int, $offset: Int) {
137
+ agents(where: $where, orderBy: $orderBy, orderDirection: $orderDirection, limit: $limit, offset: $offset) {
138
+ totalCount
139
+ items {
140
+ id
141
+ isActive
142
+ isAvailable
143
+ stablecoinDecimals
144
+ stablecoinStake
145
+ daoTokenStake
146
+ disputeFeeBps
147
+ assignmentFeeBps
148
+ description
149
+ contact
150
+ totalResolved
151
+ activeCases
152
+ registrationTime
153
+ lastEngagementTimestamp
154
+ totalEarnings
155
+ totalSlashed
156
+ }
157
+ pageInfo {
158
+ hasNextPage
159
+ hasPreviousPage
160
+ }
161
+ }
162
+ }
163
+ `;
164
+ var ESCROW_QUERY = `
165
+ query escrow($id: String!) {
166
+ escrow(id: $id) {
167
+ id
168
+ buyer
169
+ seller
170
+ agent
171
+ amount
172
+ token
173
+ state
174
+ createdAt
175
+ sellerAcceptDeadline
176
+ buyerProtectionTime
177
+ termsHash
178
+ version
179
+ fundedAt
180
+ fulfilledAt
181
+ resolvedAt
182
+ agentInvitedAt
183
+ splitProposer
184
+ proposedBuyerBps
185
+ proposedSellerBps
186
+ buyerApprovedSplit
187
+ sellerApprovedSplit
188
+ agentFeeReceived
189
+ buyerReceived
190
+ sellerReceived
191
+ creationFee
192
+ }
193
+ }
194
+ `;
195
+ var ESCROWS_QUERY = `
196
+ query escrows(
197
+ $limit: Int = 30
198
+ $offset: Int = 0
199
+ $orderBy: String = "createdAt"
200
+ $orderDirection: String = "desc"
201
+ $where: escrowFilter
202
+ ) {
203
+ escrows(
204
+ limit: $limit
205
+ offset: $offset
206
+ orderBy: $orderBy
207
+ orderDirection: $orderDirection
208
+ where: $where
209
+ ) {
210
+ items {
211
+ id
212
+ buyer
213
+ seller
214
+ agent
215
+ amount
216
+ token
217
+ state
218
+ createdAt
219
+ fundedAt
220
+ fulfilledAt
221
+ sellerAcceptDeadline
222
+ agentInvitedAt
223
+ buyerProtectionTime
224
+ splitProposer
225
+ buyerApprovedSplit
226
+ sellerApprovedSplit
227
+ proposedBuyerBps
228
+ proposedSellerBps
229
+ }
230
+ pageInfo {
231
+ hasNextPage
232
+ hasPreviousPage
233
+ }
234
+ totalCount
235
+ }
236
+ }
237
+ `;
238
+ var PROTOCOL_STATS_QUERY = `
239
+ query protocolStats($id: String! = "global") {
240
+ protocolStats(id: $id) {
241
+ id
242
+ totalEscrowsCreated
243
+ totalVolumeEscrowed
244
+ totalFeesCollected
245
+ currentTVL
246
+ activeEscrowCount
247
+ totalAgentsRegistered
248
+ activeAgentsCount
249
+ }
250
+ }
251
+ `;
252
+ var TRANSACTION_LOGS_QUERY = `
253
+ query transactionLogs(
254
+ $escrowAddress: String
255
+ $limit: Int
256
+ $offset: Int
257
+ $orderBy: String
258
+ $orderDirection: String
259
+ ) {
260
+ transactionLogs(
261
+ where: { escrowAddress: $escrowAddress }
262
+ limit: $limit
263
+ offset: $offset
264
+ orderBy: $orderBy
265
+ orderDirection: $orderDirection
266
+ ) {
267
+ items {
268
+ id
269
+ txHash
270
+ blockNumber
271
+ timestamp
272
+ eventName
273
+ contractAddress
274
+ contractType
275
+ escrowAddress
276
+ agentAddress
277
+ userAddress
278
+ eventData
279
+ }
280
+ }
281
+ }
282
+ `;
283
+
284
+ // src/domains/escrows.ts
285
+ var STATE_GROUPS = {
286
+ ACTIVE: ["PENDING", "ACTIVE", "FULFILLED"],
287
+ IN_DISPUTE: ["DISPUTED", "AGENT_INVITED"],
288
+ COMPLETED: ["RELEASED", "AGENT_RESOLVED", "REFUNDED", "SPLIT"]
289
+ };
290
+ function createEscrowsDomain(baseUrl) {
291
+ async function list(args) {
292
+ const where = {};
293
+ if (args?.buyer) where.buyer = args.buyer.toLowerCase();
294
+ if (args?.seller) where.seller = args.seller.toLowerCase();
295
+ if (args?.agent) where.agent = args.agent.toLowerCase();
296
+ if (args?.states && args.states.length > 0) {
297
+ where.state_in = args.states;
298
+ } else if (args?.state) {
299
+ where.state = args.state;
300
+ }
301
+ if (args?.user) {
302
+ const userLower = args.user.toLowerCase();
303
+ where.OR = [{ buyer: userLower }, { seller: userLower }, { agent: userLower }];
304
+ }
305
+ const variables = {
306
+ limit: args?.limit ?? 30,
307
+ offset: args?.offset ?? 0,
308
+ orderBy: args?.orderBy ?? "createdAt",
309
+ orderDirection: args?.orderDirection ?? "desc",
310
+ where: Object.keys(where).length > 0 ? where : void 0
311
+ };
312
+ const response = await graphqlRequest(
313
+ baseUrl,
314
+ ESCROWS_QUERY,
315
+ variables
316
+ );
317
+ return response.escrows;
318
+ }
319
+ async function getById(id) {
320
+ const variables = { id: id.toLowerCase() };
321
+ const response = await graphqlRequest(
322
+ baseUrl,
323
+ ESCROW_QUERY,
324
+ variables
325
+ );
326
+ return response.escrow;
327
+ }
328
+ async function getByUser(userAddress, args) {
329
+ return list({ ...args, user: userAddress });
330
+ }
331
+ async function getByStateGroup(stateGroup, args) {
332
+ return list({ ...args, states: [...STATE_GROUPS[stateGroup]] });
333
+ }
334
+ return {
335
+ list,
336
+ getById,
337
+ getByUser,
338
+ getByStateGroup
339
+ };
340
+ }
341
+
342
+ // src/domains/agents.ts
343
+ function createAgentsDomain(baseUrl) {
344
+ async function list(args) {
345
+ const where = {};
346
+ if (args?.onlyActive) where.isActive = true;
347
+ if (args?.onlyAvailable) where.isAvailable = true;
348
+ const variables = {
349
+ limit: args?.limit ?? 30,
350
+ offset: args?.offset ?? 0,
351
+ orderBy: args?.orderBy ?? "totalResolved",
352
+ orderDirection: args?.orderDirection ?? "desc",
353
+ where: Object.keys(where).length > 0 ? where : void 0
354
+ };
355
+ const response = await graphqlRequest(
356
+ baseUrl,
357
+ AGENTS_QUERY,
358
+ variables
359
+ );
360
+ return response.agents;
361
+ }
362
+ async function getById(id) {
363
+ const variables = { id: id.toLowerCase() };
364
+ const response = await graphqlRequest(
365
+ baseUrl,
366
+ AGENT_QUERY,
367
+ variables
368
+ );
369
+ return response.agent;
370
+ }
371
+ async function getAvailable(args) {
372
+ return list({ ...args, onlyActive: true, onlyAvailable: true });
373
+ }
374
+ return {
375
+ list,
376
+ getById,
377
+ getAvailable
378
+ };
379
+ }
380
+
381
+ // src/domains/protocol-stats.ts
382
+ function normalizeProtocolStats(raw) {
383
+ return {
384
+ id: raw.id,
385
+ totalEscrowsCreated: raw.totalEscrowsCreated,
386
+ totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
387
+ totalFeesCollected: BigInt(raw.totalFeesCollected),
388
+ currentTVL: BigInt(raw.currentTVL),
389
+ activeEscrowCount: raw.activeEscrowCount,
390
+ totalAgentsRegistered: raw.totalAgentsRegistered,
391
+ activeAgentsCount: raw.activeAgentsCount
392
+ };
393
+ }
394
+ function createProtocolStatsDomain(baseUrl) {
395
+ async function get() {
396
+ const variables = { id: "global" };
397
+ const response = await graphqlRequest(
398
+ baseUrl,
399
+ PROTOCOL_STATS_QUERY,
400
+ variables
401
+ );
402
+ if (!response.protocolStats) {
403
+ return null;
404
+ }
405
+ return normalizeProtocolStats(response.protocolStats);
406
+ }
407
+ async function getRaw() {
408
+ const variables = { id: "global" };
409
+ const response = await graphqlRequest(
410
+ baseUrl,
411
+ PROTOCOL_STATS_QUERY,
412
+ variables
413
+ );
414
+ return response.protocolStats;
415
+ }
416
+ return {
417
+ get,
418
+ getRaw
419
+ };
420
+ }
421
+
422
+ // src/domains/transaction-logs.ts
423
+ function createTransactionLogsDomain(baseUrl) {
424
+ async function list(args) {
425
+ const variables = {
426
+ escrowAddress: args?.escrowAddress?.toLowerCase(),
427
+ limit: args?.limit ?? 100,
428
+ offset: args?.offset ?? 0,
429
+ orderBy: args?.orderBy ?? "timestamp",
430
+ orderDirection: args?.orderDirection ?? "asc"
431
+ };
432
+ const response = await graphqlRequest(
433
+ baseUrl,
434
+ TRANSACTION_LOGS_QUERY,
435
+ variables
436
+ );
437
+ return response.transactionLogs.items;
438
+ }
439
+ async function getByEscrow(escrowAddress, args) {
440
+ return list({ ...args, escrowAddress });
441
+ }
442
+ function parseEventData(eventData) {
443
+ try {
444
+ return JSON.parse(eventData);
445
+ } catch {
446
+ return {};
447
+ }
448
+ }
449
+ return {
450
+ list,
451
+ getByEscrow,
452
+ parseEventData
453
+ };
454
+ }
455
+
456
+ // src/client.ts
457
+ var DEFAULT_BASE_URL = "https://api.zen.land";
458
+ function createZenlandClient(config) {
459
+ const baseUrl = normalizeBaseUrl(config?.baseUrl ?? DEFAULT_BASE_URL);
460
+ return {
461
+ baseUrl,
462
+ escrows: createEscrowsDomain(baseUrl),
463
+ agents: createAgentsDomain(baseUrl),
464
+ protocolStats: createProtocolStatsDomain(baseUrl),
465
+ transactionLogs: createTransactionLogsDomain(baseUrl)
466
+ };
467
+ }
468
+ function normalizeBaseUrl(url) {
469
+ return url.endsWith("/") ? url.slice(0, -1) : url;
470
+ }
471
+ var zenland = createZenlandClient();
472
+
473
+ // src/react/context.tsx
474
+ var import_jsx_runtime = require("react/jsx-runtime");
475
+ var ZenlandContext = (0, import_react.createContext)(null);
476
+ function ZenlandProvider({ children, config }) {
477
+ const client = (0, import_react.useMemo)(() => createZenlandClient(config), [config]);
478
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ZenlandContext.Provider, { value: client, children });
479
+ }
480
+ function useZenlandClient() {
481
+ const context = (0, import_react.useContext)(ZenlandContext);
482
+ if (!context) {
483
+ throw new Error("useZenlandClient must be used within a ZenlandProvider");
484
+ }
485
+ return context;
486
+ }
487
+ function useZenlandClientOptional() {
488
+ const context = (0, import_react.useContext)(ZenlandContext);
489
+ return (0, import_react.useMemo)(() => context ?? createZenlandClient(), [context]);
490
+ }
491
+
492
+ // src/react/hooks/useEscrow.ts
493
+ var import_react_query = require("@tanstack/react-query");
494
+ function useEscrow(id, options) {
495
+ const client = useZenlandClientOptional();
496
+ return (0, import_react_query.useQuery)({
497
+ queryKey: ["zenland", "escrow", id],
498
+ queryFn: () => {
499
+ if (!id) return null;
500
+ return client.escrows.getById(id);
501
+ },
502
+ enabled: !!id && (options?.enabled ?? true)
503
+ });
504
+ }
505
+
506
+ // src/react/hooks/useEscrows.ts
507
+ var import_react_query2 = require("@tanstack/react-query");
508
+ function useEscrows(args) {
509
+ const client = useZenlandClientOptional();
510
+ const { address, role = "all", stateTab, enabled = true } = args ?? {};
511
+ const getStatesFromTab = () => {
512
+ if (!stateTab || stateTab === "all") {
513
+ return args?.states;
514
+ }
515
+ return [...STATE_GROUPS[stateTab]];
516
+ };
517
+ return (0, import_react_query2.useQuery)({
518
+ queryKey: ["zenland", "escrows", address, role, stateTab, args?.state, args?.states, args?.limit, args?.offset],
519
+ queryFn: async () => {
520
+ if (!address) {
521
+ return { items: [], totalCount: 0, pageInfo: { hasNextPage: false, hasPreviousPage: false } };
522
+ }
523
+ const states = getStatesFromTab();
524
+ return client.escrows.list({
525
+ limit: args?.limit,
526
+ offset: args?.offset,
527
+ buyer: role === "buyer" ? address : void 0,
528
+ seller: role === "seller" ? address : void 0,
529
+ agent: role === "agent" ? address : void 0,
530
+ user: role === "all" ? address : void 0,
531
+ state: args?.state,
532
+ states
533
+ });
534
+ },
535
+ enabled: !!address && enabled
536
+ });
537
+ }
538
+
539
+ // src/react/hooks/useAgent.ts
540
+ var import_react_query3 = require("@tanstack/react-query");
541
+ function useAgent(address, options) {
542
+ const client = useZenlandClientOptional();
543
+ return (0, import_react_query3.useQuery)({
544
+ queryKey: ["zenland", "agent", address],
545
+ queryFn: () => {
546
+ if (!address) return null;
547
+ return client.agents.getById(address);
548
+ },
549
+ enabled: !!address && (options?.enabled ?? true)
550
+ });
551
+ }
552
+
553
+ // src/react/hooks/useAgents.ts
554
+ var import_react_query4 = require("@tanstack/react-query");
555
+ function useAgents(args) {
556
+ const client = useZenlandClientOptional();
557
+ const { enabled = true, ...filterArgs } = args ?? {};
558
+ return (0, import_react_query4.useQuery)({
559
+ queryKey: ["zenland", "agents", filterArgs.onlyActive, filterArgs.onlyAvailable, filterArgs.limit, filterArgs.offset],
560
+ queryFn: () => client.agents.list(filterArgs),
561
+ enabled
562
+ });
563
+ }
564
+
565
+ // src/react/hooks/useProtocolStats.ts
566
+ var import_react_query5 = require("@tanstack/react-query");
567
+ function useProtocolStats(options) {
568
+ const client = useZenlandClientOptional();
569
+ return (0, import_react_query5.useQuery)({
570
+ queryKey: ["zenland", "protocolStats"],
571
+ queryFn: () => client.protocolStats.get(),
572
+ enabled: options?.enabled ?? true,
573
+ staleTime: options?.staleTime ?? 30 * 1e3,
574
+ // 30 seconds
575
+ refetchInterval: options?.refetchInterval ?? 60 * 1e3
576
+ // 1 minute
577
+ });
578
+ }
579
+
580
+ // src/react/hooks/useRecentEscrows.ts
581
+ var import_react_query6 = require("@tanstack/react-query");
582
+ function useRecentEscrows(options) {
583
+ const client = useZenlandClientOptional();
584
+ const limit = options?.limit ?? 5;
585
+ return (0, import_react_query6.useQuery)({
586
+ queryKey: ["zenland", "recentEscrows", limit],
587
+ queryFn: async () => {
588
+ const result = await client.escrows.list({
589
+ limit,
590
+ orderBy: "createdAt",
591
+ orderDirection: "desc"
592
+ });
593
+ return result.items;
594
+ },
595
+ enabled: options?.enabled ?? true,
596
+ staleTime: options?.staleTime ?? 15 * 1e3,
597
+ // 15 seconds
598
+ refetchInterval: options?.refetchInterval ?? 30 * 1e3
599
+ // 30 seconds
600
+ });
601
+ }
602
+
603
+ // src/react/hooks/useUserStats.ts
604
+ var import_react_query7 = require("@tanstack/react-query");
605
+ var ACTIVE_STATES = STATE_GROUPS.ACTIVE;
606
+ var DISPUTE_STATES = STATE_GROUPS.IN_DISPUTE;
607
+ var COMPLETED_STATES = STATE_GROUPS.COMPLETED;
608
+ var TVL_STATES = [...ACTIVE_STATES, ...DISPUTE_STATES];
609
+ async function fetchUserEscrowCount(client, userAddress, states) {
610
+ const userLower = userAddress.toLowerCase();
611
+ const result = await client.escrows.list({
612
+ limit: 1,
613
+ user: userLower,
614
+ states: [...states]
615
+ });
616
+ return result.totalCount;
617
+ }
618
+ async function fetchUserTVL(client, userAddress) {
619
+ const userLower = userAddress.toLowerCase();
620
+ const result = await client.escrows.list({
621
+ limit: 1e3,
622
+ user: userLower,
623
+ states: [...TVL_STATES]
624
+ });
625
+ return result.items.reduce((sum, escrow) => sum + BigInt(escrow.amount), BigInt(0));
626
+ }
627
+ async function fetchUserRecentEscrows(client, userAddress, limit = 5) {
628
+ const userLower = userAddress.toLowerCase();
629
+ const result = await client.escrows.list({
630
+ limit,
631
+ user: userLower
632
+ });
633
+ return result.items;
634
+ }
635
+ async function getUserDashboardStats(client, userAddress) {
636
+ const [activeCount, disputeCount, completedCount, tvl, recentEscrows] = await Promise.all([
637
+ fetchUserEscrowCount(client, userAddress, ACTIVE_STATES),
638
+ fetchUserEscrowCount(client, userAddress, DISPUTE_STATES),
639
+ fetchUserEscrowCount(client, userAddress, COMPLETED_STATES),
640
+ fetchUserTVL(client, userAddress),
641
+ fetchUserRecentEscrows(client, userAddress, 5)
642
+ ]);
643
+ return {
644
+ activeCount,
645
+ disputeCount,
646
+ completedCount,
647
+ tvl,
648
+ recentEscrows
649
+ };
650
+ }
651
+ async function getGlobalDashboardStats(client) {
652
+ const [activeCount, disputeCount, completedCount, recentEscrows] = await Promise.all([
653
+ fetchGlobalEscrowCount(client, [...ACTIVE_STATES]),
654
+ fetchGlobalEscrowCount(client, [...DISPUTE_STATES]),
655
+ fetchGlobalEscrowCount(client, [...COMPLETED_STATES]),
656
+ fetchGlobalRecentEscrows(client, 5)
657
+ ]);
658
+ return {
659
+ activeCount,
660
+ disputeCount,
661
+ completedCount,
662
+ tvl: null,
663
+ recentEscrows
664
+ };
665
+ }
666
+ async function fetchGlobalEscrowCount(client, states) {
667
+ const result = await client.escrows.list({
668
+ limit: 1,
669
+ states
670
+ });
671
+ return result.totalCount;
672
+ }
673
+ async function fetchGlobalRecentEscrows(client, limit = 5) {
674
+ const result = await client.escrows.list({ limit });
675
+ return result.items;
676
+ }
677
+ function useUserStats(userAddress) {
678
+ const client = useZenlandClientOptional();
679
+ return (0, import_react_query7.useQuery)({
680
+ queryKey: ["zenland", "userStats", userAddress],
681
+ queryFn: async () => {
682
+ if (!userAddress) return null;
683
+ return getUserDashboardStats(client, userAddress);
684
+ },
685
+ enabled: !!userAddress,
686
+ staleTime: 15 * 1e3,
687
+ refetchInterval: 30 * 1e3
688
+ });
689
+ }
690
+ function useGlobalStats() {
691
+ const client = useZenlandClientOptional();
692
+ return (0, import_react_query7.useQuery)({
693
+ queryKey: ["zenland", "globalStats"],
694
+ queryFn: () => getGlobalDashboardStats(client),
695
+ staleTime: 30 * 1e3,
696
+ refetchInterval: 60 * 1e3
697
+ });
698
+ }
699
+
700
+ // src/react/hooks/useTransactionLogsByEscrow.ts
701
+ var import_react_query8 = require("@tanstack/react-query");
702
+ function useTransactionLogsByEscrow(escrowAddress, options) {
703
+ const client = useZenlandClientOptional();
704
+ const addr = escrowAddress?.toLowerCase();
705
+ return (0, import_react_query8.useQuery)({
706
+ queryKey: [
707
+ "zenland",
708
+ "transactionLogs",
709
+ "escrow",
710
+ addr,
711
+ options?.list?.limit,
712
+ options?.list?.offset,
713
+ options?.list?.orderBy,
714
+ options?.list?.orderDirection
715
+ ],
716
+ queryFn: async () => {
717
+ if (!addr) return [];
718
+ return client.transactionLogs.getByEscrow(addr, options?.list);
719
+ },
720
+ enabled: !!addr && (options?.enabled ?? true),
721
+ staleTime: options?.staleTime ?? 3e4,
722
+ refetchInterval: options?.refetchInterval,
723
+ refetchOnWindowFocus: false
724
+ });
725
+ }
726
+ // Annotate the CommonJS export names for ESM import in node:
727
+ 0 && (module.exports = {
728
+ STATE_GROUPS,
729
+ ZenlandProvider,
730
+ createZenlandClient,
731
+ useAgent,
732
+ useAgents,
733
+ useEscrow,
734
+ useEscrows,
735
+ useGlobalStats,
736
+ useProtocolStats,
737
+ useRecentEscrows,
738
+ useTransactionLogsByEscrow,
739
+ useUserStats,
740
+ useZenlandClient,
741
+ useZenlandClientOptional
742
+ });
743
+ //# sourceMappingURL=react.cjs.map