@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/LICENSE +21 -0
- package/README.md +246 -0
- package/dist/index.cjs +502 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +382 -0
- package/dist/index.d.ts +382 -0
- package/dist/index.js +465 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +743 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +554 -0
- package/dist/react.d.ts +554 -0
- package/dist/react.js +704 -0
- package/dist/react.js.map +1 -0
- package/package.json +78 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
// src/request.ts
|
|
2
|
+
var ZenlandGraphQLError = class extends Error {
|
|
3
|
+
errors;
|
|
4
|
+
constructor(message, errors) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "ZenlandGraphQLError";
|
|
7
|
+
this.errors = errors;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var ZenlandRequestError = class extends Error {
|
|
11
|
+
status;
|
|
12
|
+
statusText;
|
|
13
|
+
constructor(message, status, statusText) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "ZenlandRequestError";
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.statusText = statusText;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
async function graphqlRequest(baseUrl, document, variables, options) {
|
|
21
|
+
const endpoint = `${baseUrl}/graphql`;
|
|
22
|
+
const res = await fetch(endpoint, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: {
|
|
25
|
+
"content-type": "application/json"
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({ query: document, variables }),
|
|
28
|
+
signal: options?.signal,
|
|
29
|
+
cache: "no-store"
|
|
30
|
+
});
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
const text = await res.text().catch(() => "");
|
|
33
|
+
throw new ZenlandRequestError(
|
|
34
|
+
`Zenland request failed (${res.status} ${res.statusText})${text ? `: ${text}` : ""}`,
|
|
35
|
+
res.status,
|
|
36
|
+
res.statusText
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const json = await res.json();
|
|
40
|
+
if (json.errors?.length) {
|
|
41
|
+
throw new ZenlandGraphQLError(
|
|
42
|
+
json.errors.map((e) => e.message ?? "GraphQL error").join("; "),
|
|
43
|
+
json.errors
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (!json.data) {
|
|
47
|
+
throw new Error("Zenland response missing data.");
|
|
48
|
+
}
|
|
49
|
+
return json.data;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/queries.ts
|
|
53
|
+
var AGENT_QUERY = `
|
|
54
|
+
query Agent($id: String!) {
|
|
55
|
+
agent(id: $id) {
|
|
56
|
+
id
|
|
57
|
+
isActive
|
|
58
|
+
isAvailable
|
|
59
|
+
stablecoinDecimals
|
|
60
|
+
stablecoinToken
|
|
61
|
+
stablecoinStake
|
|
62
|
+
daoTokenStake
|
|
63
|
+
disputeFeeBps
|
|
64
|
+
assignmentFeeBps
|
|
65
|
+
description
|
|
66
|
+
contact
|
|
67
|
+
totalResolved
|
|
68
|
+
activeCases
|
|
69
|
+
registrationTime
|
|
70
|
+
lastEngagementTimestamp
|
|
71
|
+
totalEarnings
|
|
72
|
+
totalSlashed
|
|
73
|
+
cases(limit: 5, orderBy: "invitedAt", orderDirection: "desc") {
|
|
74
|
+
items {
|
|
75
|
+
id
|
|
76
|
+
escrow
|
|
77
|
+
invitedAt
|
|
78
|
+
resolvedAt
|
|
79
|
+
timedOut
|
|
80
|
+
escrowRef {
|
|
81
|
+
id
|
|
82
|
+
amount
|
|
83
|
+
token
|
|
84
|
+
state
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
totalCount
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
var AGENTS_QUERY = `
|
|
93
|
+
query Agents($where: agentFilter, $orderBy: String, $orderDirection: String, $limit: Int, $offset: Int) {
|
|
94
|
+
agents(where: $where, orderBy: $orderBy, orderDirection: $orderDirection, limit: $limit, offset: $offset) {
|
|
95
|
+
totalCount
|
|
96
|
+
items {
|
|
97
|
+
id
|
|
98
|
+
isActive
|
|
99
|
+
isAvailable
|
|
100
|
+
stablecoinDecimals
|
|
101
|
+
stablecoinStake
|
|
102
|
+
daoTokenStake
|
|
103
|
+
disputeFeeBps
|
|
104
|
+
assignmentFeeBps
|
|
105
|
+
description
|
|
106
|
+
contact
|
|
107
|
+
totalResolved
|
|
108
|
+
activeCases
|
|
109
|
+
registrationTime
|
|
110
|
+
lastEngagementTimestamp
|
|
111
|
+
totalEarnings
|
|
112
|
+
totalSlashed
|
|
113
|
+
}
|
|
114
|
+
pageInfo {
|
|
115
|
+
hasNextPage
|
|
116
|
+
hasPreviousPage
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
var ESCROW_QUERY = `
|
|
122
|
+
query escrow($id: String!) {
|
|
123
|
+
escrow(id: $id) {
|
|
124
|
+
id
|
|
125
|
+
buyer
|
|
126
|
+
seller
|
|
127
|
+
agent
|
|
128
|
+
amount
|
|
129
|
+
token
|
|
130
|
+
state
|
|
131
|
+
createdAt
|
|
132
|
+
sellerAcceptDeadline
|
|
133
|
+
buyerProtectionTime
|
|
134
|
+
termsHash
|
|
135
|
+
version
|
|
136
|
+
fundedAt
|
|
137
|
+
fulfilledAt
|
|
138
|
+
resolvedAt
|
|
139
|
+
agentInvitedAt
|
|
140
|
+
splitProposer
|
|
141
|
+
proposedBuyerBps
|
|
142
|
+
proposedSellerBps
|
|
143
|
+
buyerApprovedSplit
|
|
144
|
+
sellerApprovedSplit
|
|
145
|
+
agentFeeReceived
|
|
146
|
+
buyerReceived
|
|
147
|
+
sellerReceived
|
|
148
|
+
creationFee
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
var ESCROWS_QUERY = `
|
|
153
|
+
query escrows(
|
|
154
|
+
$limit: Int = 30
|
|
155
|
+
$offset: Int = 0
|
|
156
|
+
$orderBy: String = "createdAt"
|
|
157
|
+
$orderDirection: String = "desc"
|
|
158
|
+
$where: escrowFilter
|
|
159
|
+
) {
|
|
160
|
+
escrows(
|
|
161
|
+
limit: $limit
|
|
162
|
+
offset: $offset
|
|
163
|
+
orderBy: $orderBy
|
|
164
|
+
orderDirection: $orderDirection
|
|
165
|
+
where: $where
|
|
166
|
+
) {
|
|
167
|
+
items {
|
|
168
|
+
id
|
|
169
|
+
buyer
|
|
170
|
+
seller
|
|
171
|
+
agent
|
|
172
|
+
amount
|
|
173
|
+
token
|
|
174
|
+
state
|
|
175
|
+
createdAt
|
|
176
|
+
fundedAt
|
|
177
|
+
fulfilledAt
|
|
178
|
+
sellerAcceptDeadline
|
|
179
|
+
agentInvitedAt
|
|
180
|
+
buyerProtectionTime
|
|
181
|
+
splitProposer
|
|
182
|
+
buyerApprovedSplit
|
|
183
|
+
sellerApprovedSplit
|
|
184
|
+
proposedBuyerBps
|
|
185
|
+
proposedSellerBps
|
|
186
|
+
}
|
|
187
|
+
pageInfo {
|
|
188
|
+
hasNextPage
|
|
189
|
+
hasPreviousPage
|
|
190
|
+
}
|
|
191
|
+
totalCount
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
var PROTOCOL_STATS_QUERY = `
|
|
196
|
+
query protocolStats($id: String! = "global") {
|
|
197
|
+
protocolStats(id: $id) {
|
|
198
|
+
id
|
|
199
|
+
totalEscrowsCreated
|
|
200
|
+
totalVolumeEscrowed
|
|
201
|
+
totalFeesCollected
|
|
202
|
+
currentTVL
|
|
203
|
+
activeEscrowCount
|
|
204
|
+
totalAgentsRegistered
|
|
205
|
+
activeAgentsCount
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
var TRANSACTION_LOGS_QUERY = `
|
|
210
|
+
query transactionLogs(
|
|
211
|
+
$escrowAddress: String
|
|
212
|
+
$limit: Int
|
|
213
|
+
$offset: Int
|
|
214
|
+
$orderBy: String
|
|
215
|
+
$orderDirection: String
|
|
216
|
+
) {
|
|
217
|
+
transactionLogs(
|
|
218
|
+
where: { escrowAddress: $escrowAddress }
|
|
219
|
+
limit: $limit
|
|
220
|
+
offset: $offset
|
|
221
|
+
orderBy: $orderBy
|
|
222
|
+
orderDirection: $orderDirection
|
|
223
|
+
) {
|
|
224
|
+
items {
|
|
225
|
+
id
|
|
226
|
+
txHash
|
|
227
|
+
blockNumber
|
|
228
|
+
timestamp
|
|
229
|
+
eventName
|
|
230
|
+
contractAddress
|
|
231
|
+
contractType
|
|
232
|
+
escrowAddress
|
|
233
|
+
agentAddress
|
|
234
|
+
userAddress
|
|
235
|
+
eventData
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
`;
|
|
240
|
+
|
|
241
|
+
// src/domains/escrows.ts
|
|
242
|
+
var STATE_GROUPS = {
|
|
243
|
+
ACTIVE: ["PENDING", "ACTIVE", "FULFILLED"],
|
|
244
|
+
IN_DISPUTE: ["DISPUTED", "AGENT_INVITED"],
|
|
245
|
+
COMPLETED: ["RELEASED", "AGENT_RESOLVED", "REFUNDED", "SPLIT"]
|
|
246
|
+
};
|
|
247
|
+
function createEscrowsDomain(baseUrl) {
|
|
248
|
+
async function list(args) {
|
|
249
|
+
const where = {};
|
|
250
|
+
if (args?.buyer) where.buyer = args.buyer.toLowerCase();
|
|
251
|
+
if (args?.seller) where.seller = args.seller.toLowerCase();
|
|
252
|
+
if (args?.agent) where.agent = args.agent.toLowerCase();
|
|
253
|
+
if (args?.states && args.states.length > 0) {
|
|
254
|
+
where.state_in = args.states;
|
|
255
|
+
} else if (args?.state) {
|
|
256
|
+
where.state = args.state;
|
|
257
|
+
}
|
|
258
|
+
if (args?.user) {
|
|
259
|
+
const userLower = args.user.toLowerCase();
|
|
260
|
+
where.OR = [{ buyer: userLower }, { seller: userLower }, { agent: userLower }];
|
|
261
|
+
}
|
|
262
|
+
const variables = {
|
|
263
|
+
limit: args?.limit ?? 30,
|
|
264
|
+
offset: args?.offset ?? 0,
|
|
265
|
+
orderBy: args?.orderBy ?? "createdAt",
|
|
266
|
+
orderDirection: args?.orderDirection ?? "desc",
|
|
267
|
+
where: Object.keys(where).length > 0 ? where : void 0
|
|
268
|
+
};
|
|
269
|
+
const response = await graphqlRequest(
|
|
270
|
+
baseUrl,
|
|
271
|
+
ESCROWS_QUERY,
|
|
272
|
+
variables
|
|
273
|
+
);
|
|
274
|
+
return response.escrows;
|
|
275
|
+
}
|
|
276
|
+
async function getById(id) {
|
|
277
|
+
const variables = { id: id.toLowerCase() };
|
|
278
|
+
const response = await graphqlRequest(
|
|
279
|
+
baseUrl,
|
|
280
|
+
ESCROW_QUERY,
|
|
281
|
+
variables
|
|
282
|
+
);
|
|
283
|
+
return response.escrow;
|
|
284
|
+
}
|
|
285
|
+
async function getByUser(userAddress, args) {
|
|
286
|
+
return list({ ...args, user: userAddress });
|
|
287
|
+
}
|
|
288
|
+
async function getByStateGroup(stateGroup, args) {
|
|
289
|
+
return list({ ...args, states: [...STATE_GROUPS[stateGroup]] });
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
list,
|
|
293
|
+
getById,
|
|
294
|
+
getByUser,
|
|
295
|
+
getByStateGroup
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/domains/agents.ts
|
|
300
|
+
function createAgentsDomain(baseUrl) {
|
|
301
|
+
async function list(args) {
|
|
302
|
+
const where = {};
|
|
303
|
+
if (args?.onlyActive) where.isActive = true;
|
|
304
|
+
if (args?.onlyAvailable) where.isAvailable = true;
|
|
305
|
+
const variables = {
|
|
306
|
+
limit: args?.limit ?? 30,
|
|
307
|
+
offset: args?.offset ?? 0,
|
|
308
|
+
orderBy: args?.orderBy ?? "totalResolved",
|
|
309
|
+
orderDirection: args?.orderDirection ?? "desc",
|
|
310
|
+
where: Object.keys(where).length > 0 ? where : void 0
|
|
311
|
+
};
|
|
312
|
+
const response = await graphqlRequest(
|
|
313
|
+
baseUrl,
|
|
314
|
+
AGENTS_QUERY,
|
|
315
|
+
variables
|
|
316
|
+
);
|
|
317
|
+
return response.agents;
|
|
318
|
+
}
|
|
319
|
+
async function getById(id) {
|
|
320
|
+
const variables = { id: id.toLowerCase() };
|
|
321
|
+
const response = await graphqlRequest(
|
|
322
|
+
baseUrl,
|
|
323
|
+
AGENT_QUERY,
|
|
324
|
+
variables
|
|
325
|
+
);
|
|
326
|
+
return response.agent;
|
|
327
|
+
}
|
|
328
|
+
async function getAvailable(args) {
|
|
329
|
+
return list({ ...args, onlyActive: true, onlyAvailable: true });
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
list,
|
|
333
|
+
getById,
|
|
334
|
+
getAvailable
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/domains/protocol-stats.ts
|
|
339
|
+
function normalizeProtocolStats(raw) {
|
|
340
|
+
return {
|
|
341
|
+
id: raw.id,
|
|
342
|
+
totalEscrowsCreated: raw.totalEscrowsCreated,
|
|
343
|
+
totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
|
|
344
|
+
totalFeesCollected: BigInt(raw.totalFeesCollected),
|
|
345
|
+
currentTVL: BigInt(raw.currentTVL),
|
|
346
|
+
activeEscrowCount: raw.activeEscrowCount,
|
|
347
|
+
totalAgentsRegistered: raw.totalAgentsRegistered,
|
|
348
|
+
activeAgentsCount: raw.activeAgentsCount
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function createProtocolStatsDomain(baseUrl) {
|
|
352
|
+
async function get() {
|
|
353
|
+
const variables = { id: "global" };
|
|
354
|
+
const response = await graphqlRequest(
|
|
355
|
+
baseUrl,
|
|
356
|
+
PROTOCOL_STATS_QUERY,
|
|
357
|
+
variables
|
|
358
|
+
);
|
|
359
|
+
if (!response.protocolStats) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return normalizeProtocolStats(response.protocolStats);
|
|
363
|
+
}
|
|
364
|
+
async function getRaw() {
|
|
365
|
+
const variables = { id: "global" };
|
|
366
|
+
const response = await graphqlRequest(
|
|
367
|
+
baseUrl,
|
|
368
|
+
PROTOCOL_STATS_QUERY,
|
|
369
|
+
variables
|
|
370
|
+
);
|
|
371
|
+
return response.protocolStats;
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
get,
|
|
375
|
+
getRaw
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/domains/transaction-logs.ts
|
|
380
|
+
function createTransactionLogsDomain(baseUrl) {
|
|
381
|
+
async function list(args) {
|
|
382
|
+
const variables = {
|
|
383
|
+
escrowAddress: args?.escrowAddress?.toLowerCase(),
|
|
384
|
+
limit: args?.limit ?? 100,
|
|
385
|
+
offset: args?.offset ?? 0,
|
|
386
|
+
orderBy: args?.orderBy ?? "timestamp",
|
|
387
|
+
orderDirection: args?.orderDirection ?? "asc"
|
|
388
|
+
};
|
|
389
|
+
const response = await graphqlRequest(
|
|
390
|
+
baseUrl,
|
|
391
|
+
TRANSACTION_LOGS_QUERY,
|
|
392
|
+
variables
|
|
393
|
+
);
|
|
394
|
+
return response.transactionLogs.items;
|
|
395
|
+
}
|
|
396
|
+
async function getByEscrow(escrowAddress, args) {
|
|
397
|
+
return list({ ...args, escrowAddress });
|
|
398
|
+
}
|
|
399
|
+
function parseEventData(eventData) {
|
|
400
|
+
try {
|
|
401
|
+
return JSON.parse(eventData);
|
|
402
|
+
} catch {
|
|
403
|
+
return {};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return {
|
|
407
|
+
list,
|
|
408
|
+
getByEscrow,
|
|
409
|
+
parseEventData
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// src/client.ts
|
|
414
|
+
var DEFAULT_BASE_URL = "https://api.zen.land";
|
|
415
|
+
function createZenlandClient(config) {
|
|
416
|
+
const baseUrl = normalizeBaseUrl(config?.baseUrl ?? DEFAULT_BASE_URL);
|
|
417
|
+
return {
|
|
418
|
+
baseUrl,
|
|
419
|
+
escrows: createEscrowsDomain(baseUrl),
|
|
420
|
+
agents: createAgentsDomain(baseUrl),
|
|
421
|
+
protocolStats: createProtocolStatsDomain(baseUrl),
|
|
422
|
+
transactionLogs: createTransactionLogsDomain(baseUrl)
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function normalizeBaseUrl(url) {
|
|
426
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
427
|
+
}
|
|
428
|
+
var zenland = createZenlandClient();
|
|
429
|
+
|
|
430
|
+
// src/agents/eligibility.ts
|
|
431
|
+
var MAV_MULTIPLIER = 20n;
|
|
432
|
+
function computeAgentMavUsd(agent) {
|
|
433
|
+
return BigInt(agent.stablecoinStake) * MAV_MULTIPLIER;
|
|
434
|
+
}
|
|
435
|
+
function isAgentEligibleForEscrow(args) {
|
|
436
|
+
const requiredUsd = args.escrowAmount;
|
|
437
|
+
if (!args.agent) {
|
|
438
|
+
return { ok: false, reason: "NOT_REGISTERED", requiredUsd };
|
|
439
|
+
}
|
|
440
|
+
if (!args.agent.isActive) {
|
|
441
|
+
return { ok: false, reason: "NOT_ACTIVE", requiredUsd };
|
|
442
|
+
}
|
|
443
|
+
if (!args.agent.isAvailable) {
|
|
444
|
+
return { ok: false, reason: "NOT_AVAILABLE", requiredUsd };
|
|
445
|
+
}
|
|
446
|
+
const agentMavUsd = computeAgentMavUsd(args.agent);
|
|
447
|
+
if (agentMavUsd < requiredUsd) {
|
|
448
|
+
return { ok: false, reason: "INSUFFICIENT_MAV", agentMavUsd, requiredUsd };
|
|
449
|
+
}
|
|
450
|
+
return { ok: true, agentMavUsd, requiredUsd };
|
|
451
|
+
}
|
|
452
|
+
export {
|
|
453
|
+
STATE_GROUPS,
|
|
454
|
+
ZenlandGraphQLError,
|
|
455
|
+
ZenlandRequestError,
|
|
456
|
+
computeAgentMavUsd,
|
|
457
|
+
createAgentsDomain,
|
|
458
|
+
createEscrowsDomain,
|
|
459
|
+
createProtocolStatsDomain,
|
|
460
|
+
createTransactionLogsDomain,
|
|
461
|
+
createZenlandClient,
|
|
462
|
+
isAgentEligibleForEscrow,
|
|
463
|
+
zenland
|
|
464
|
+
};
|
|
465
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/request.ts","../src/queries.ts","../src/domains/escrows.ts","../src/domains/agents.ts","../src/domains/protocol-stats.ts","../src/domains/transaction-logs.ts","../src/client.ts","../src/agents/eligibility.ts"],"sourcesContent":["/**\n * GraphQL request utilities for the Zenland SDK\n */\n\ntype GraphQLErrorLike = {\n message?: string;\n [key: string]: unknown;\n};\n\ntype GraphQLResponse<TData> = {\n data?: TData;\n errors?: GraphQLErrorLike[];\n};\n\n/**\n * Error thrown when the indexer returns GraphQL errors\n */\nexport class ZenlandGraphQLError extends Error {\n public readonly errors: GraphQLErrorLike[];\n\n constructor(message: string, errors: GraphQLErrorLike[]) {\n super(message);\n this.name = \"ZenlandGraphQLError\";\n this.errors = errors;\n }\n}\n\n/**\n * Error thrown when the indexer request fails at the network/HTTP level\n */\nexport class ZenlandRequestError extends Error {\n public readonly status: number;\n public readonly statusText: string;\n\n constructor(message: string, status: number, statusText: string) {\n super(message);\n this.name = \"ZenlandRequestError\";\n this.status = status;\n this.statusText = statusText;\n }\n}\n\nexport interface GraphQLRequestOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Execute a GraphQL request against the Zenland indexer\n */\nexport async function graphqlRequest<TData, TVariables extends object | undefined>(\n baseUrl: string,\n document: string,\n variables?: TVariables,\n options?: GraphQLRequestOptions,\n): Promise<TData> {\n const endpoint = `${baseUrl}/graphql`;\n\n const res = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ query: document, variables }),\n signal: options?.signal,\n cache: \"no-store\",\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n throw new ZenlandRequestError(\n `Zenland request failed (${res.status} ${res.statusText})${text ? `: ${text}` : \"\"}`,\n res.status,\n res.statusText,\n );\n }\n\n const json = (await res.json()) as GraphQLResponse<TData>;\n\n if (json.errors?.length) {\n throw new ZenlandGraphQLError(\n json.errors.map((e) => e.message ?? \"GraphQL error\").join(\"; \"),\n json.errors,\n );\n }\n\n if (!json.data) {\n throw new Error(\"Zenland response missing data.\");\n }\n\n return json.data;\n}\n","/**\n * GraphQL query strings for the Zenland indexer.\n * These are compiled into the SDK to avoid runtime parsing.\n */\n\nexport const AGENT_QUERY = `\nquery Agent($id: String!) {\n agent(id: $id) {\n id\n isActive\n isAvailable\n stablecoinDecimals\n stablecoinToken\n stablecoinStake\n daoTokenStake\n disputeFeeBps\n assignmentFeeBps\n description\n contact\n totalResolved\n activeCases\n registrationTime\n lastEngagementTimestamp\n totalEarnings\n totalSlashed\n cases(limit: 5, orderBy: \"invitedAt\", orderDirection: \"desc\") {\n items {\n id\n escrow\n invitedAt\n resolvedAt\n timedOut\n escrowRef {\n id\n amount\n token\n state\n }\n }\n totalCount\n }\n }\n}\n`;\n\nexport const AGENTS_QUERY = `\nquery Agents($where: agentFilter, $orderBy: String, $orderDirection: String, $limit: Int, $offset: Int) {\n agents(where: $where, orderBy: $orderBy, orderDirection: $orderDirection, limit: $limit, offset: $offset) {\n totalCount\n items {\n id\n isActive\n isAvailable\n stablecoinDecimals\n stablecoinStake\n daoTokenStake\n disputeFeeBps\n assignmentFeeBps\n description\n contact\n totalResolved\n activeCases\n registrationTime\n lastEngagementTimestamp\n totalEarnings\n totalSlashed\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n }\n}\n`;\n\nexport const ESCROW_QUERY = `\nquery escrow($id: String!) {\n escrow(id: $id) {\n id\n buyer\n seller\n agent\n amount\n token\n state\n createdAt\n sellerAcceptDeadline\n buyerProtectionTime\n termsHash\n version\n fundedAt\n fulfilledAt\n resolvedAt\n agentInvitedAt\n splitProposer\n proposedBuyerBps\n proposedSellerBps\n buyerApprovedSplit\n sellerApprovedSplit\n agentFeeReceived\n buyerReceived\n sellerReceived\n creationFee\n }\n}\n`;\n\nexport const ESCROWS_QUERY = `\nquery escrows(\n $limit: Int = 30\n $offset: Int = 0\n $orderBy: String = \"createdAt\"\n $orderDirection: String = \"desc\"\n $where: escrowFilter\n) {\n escrows(\n limit: $limit\n offset: $offset\n orderBy: $orderBy\n orderDirection: $orderDirection\n where: $where\n ) {\n items {\n id\n buyer\n seller\n agent\n amount\n token\n state\n createdAt\n fundedAt\n fulfilledAt\n sellerAcceptDeadline\n agentInvitedAt\n buyerProtectionTime\n splitProposer\n buyerApprovedSplit\n sellerApprovedSplit\n proposedBuyerBps\n proposedSellerBps\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n }\n totalCount\n }\n}\n`;\n\nexport const PROTOCOL_STATS_QUERY = `\nquery protocolStats($id: String! = \"global\") {\n protocolStats(id: $id) {\n id\n totalEscrowsCreated\n totalVolumeEscrowed\n totalFeesCollected\n currentTVL\n activeEscrowCount\n totalAgentsRegistered\n activeAgentsCount\n }\n}\n`;\n\nexport const RECENT_ESCROWS_QUERY = `\nquery recentEscrows($limit: Int = 5) {\n escrows(\n limit: $limit\n orderBy: \"createdAt\"\n orderDirection: \"desc\"\n ) {\n items {\n id\n amount\n token\n state\n createdAt\n }\n }\n}\n`;\n\nexport const TRANSACTION_LOGS_QUERY = `\nquery transactionLogs(\n $escrowAddress: String\n $limit: Int\n $offset: Int\n $orderBy: String\n $orderDirection: String\n) {\n transactionLogs(\n where: { escrowAddress: $escrowAddress }\n limit: $limit\n offset: $offset\n orderBy: $orderBy\n orderDirection: $orderDirection\n ) {\n items {\n id\n txHash\n blockNumber\n timestamp\n eventName\n contractAddress\n contractType\n escrowAddress\n agentAddress\n userAddress\n eventData\n }\n }\n}\n`;\n","/**\n * Escrow domain module for the Zenland SDK\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { ESCROW_QUERY, ESCROWS_QUERY } from \"../queries\";\nimport type {\n GqlEscrow,\n GqlEscrowPage,\n GqlEscrowFilter,\n EscrowQueryResponse,\n EscrowsQueryResponse,\n} from \"../generated/types\";\n\n/** State groups for filtering escrows */\nexport const STATE_GROUPS = {\n ACTIVE: [\"PENDING\", \"ACTIVE\", \"FULFILLED\"] as const,\n IN_DISPUTE: [\"DISPUTED\", \"AGENT_INVITED\"] as const,\n COMPLETED: [\"RELEASED\", \"AGENT_RESOLVED\", \"REFUNDED\", \"SPLIT\"] as const,\n} as const;\n\nexport type StateGroup = keyof typeof STATE_GROUPS;\n\nexport interface ListEscrowsArgs {\n limit?: number;\n offset?: number;\n buyer?: string;\n seller?: string;\n agent?: string;\n /** Search across buyer, seller, or agent roles */\n user?: string;\n state?: string;\n /** Multiple states for group filtering */\n states?: string[];\n orderBy?: string;\n orderDirection?: \"asc\" | \"desc\";\n}\n\n/**\n * Creates escrow domain functions bound to a base URL\n */\nexport function createEscrowsDomain(baseUrl: string) {\n /**\n * List escrows with filtering and pagination\n */\n async function list(args?: ListEscrowsArgs): Promise<GqlEscrowPage> {\n const where: GqlEscrowFilter = {};\n\n // Role-specific filters\n if (args?.buyer) where.buyer = args.buyer.toLowerCase();\n if (args?.seller) where.seller = args.seller.toLowerCase();\n if (args?.agent) where.agent = args.agent.toLowerCase();\n\n // State filters - single or multiple\n if (args?.states && args.states.length > 0) {\n where.state_in = args.states;\n } else if (args?.state) {\n where.state = args.state;\n }\n\n // User filter: search across buyer, seller, or agent roles\n if (args?.user) {\n const userLower = args.user.toLowerCase();\n where.OR = [{ buyer: userLower }, { seller: userLower }, { agent: userLower }];\n }\n\n const variables = {\n limit: args?.limit ?? 30,\n offset: args?.offset ?? 0,\n orderBy: args?.orderBy ?? \"createdAt\",\n orderDirection: args?.orderDirection ?? \"desc\",\n where: Object.keys(where).length > 0 ? where : undefined,\n };\n\n const response = await graphqlRequest<EscrowsQueryResponse, typeof variables>(\n baseUrl,\n ESCROWS_QUERY,\n variables,\n );\n\n return response.escrows;\n }\n\n /**\n * Get a single escrow by ID (address)\n */\n async function getById(id: string): Promise<GqlEscrow | null> {\n const variables = { id: id.toLowerCase() };\n\n const response = await graphqlRequest<EscrowQueryResponse, typeof variables>(\n baseUrl,\n ESCROW_QUERY,\n variables,\n );\n\n return response.escrow;\n }\n\n /**\n * Get escrows for a specific user across all roles\n */\n async function getByUser(\n userAddress: string,\n args?: Omit<ListEscrowsArgs, \"user\" | \"buyer\" | \"seller\" | \"agent\">,\n ): Promise<GqlEscrowPage> {\n return list({ ...args, user: userAddress });\n }\n\n /**\n * Get escrows by state group\n */\n async function getByStateGroup(\n stateGroup: StateGroup,\n args?: Omit<ListEscrowsArgs, \"state\" | \"states\">,\n ): Promise<GqlEscrowPage> {\n return list({ ...args, states: [...STATE_GROUPS[stateGroup]] });\n }\n\n return {\n list,\n getById,\n getByUser,\n getByStateGroup,\n };\n}\n\nexport type EscrowsDomain = ReturnType<typeof createEscrowsDomain>;\n","/**\n * Agent domain module for the Zenland SDK\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { AGENT_QUERY, AGENTS_QUERY } from \"../queries\";\nimport type {\n GqlAgent,\n GqlAgentPage,\n GqlAgentFilter,\n AgentQueryResponse,\n AgentsQueryResponse,\n} from \"../generated/types\";\n\nexport interface ListAgentsArgs {\n limit?: number;\n offset?: number;\n onlyActive?: boolean;\n onlyAvailable?: boolean;\n orderBy?: string;\n orderDirection?: \"asc\" | \"desc\";\n}\n\n/**\n * Creates agent domain functions bound to a base URL\n */\nexport function createAgentsDomain(baseUrl: string) {\n /**\n * List agents with filtering and pagination\n */\n async function list(args?: ListAgentsArgs): Promise<GqlAgentPage> {\n const where: GqlAgentFilter = {};\n\n if (args?.onlyActive) where.isActive = true;\n if (args?.onlyAvailable) where.isAvailable = true;\n\n const variables = {\n limit: args?.limit ?? 30,\n offset: args?.offset ?? 0,\n orderBy: args?.orderBy ?? \"totalResolved\",\n orderDirection: args?.orderDirection ?? \"desc\",\n where: Object.keys(where).length > 0 ? where : undefined,\n };\n\n const response = await graphqlRequest<AgentsQueryResponse, typeof variables>(\n baseUrl,\n AGENTS_QUERY,\n variables,\n );\n\n return response.agents;\n }\n\n /**\n * Get a single agent by ID (address)\n */\n async function getById(id: string): Promise<GqlAgent | null> {\n const variables = { id: id.toLowerCase() };\n\n const response = await graphqlRequest<AgentQueryResponse, typeof variables>(\n baseUrl,\n AGENT_QUERY,\n variables,\n );\n\n return response.agent;\n }\n\n /**\n * Get all active and available agents\n */\n async function getAvailable(args?: Omit<ListAgentsArgs, \"onlyActive\" | \"onlyAvailable\">): Promise<GqlAgentPage> {\n return list({ ...args, onlyActive: true, onlyAvailable: true });\n }\n\n return {\n list,\n getById,\n getAvailable,\n };\n}\n\nexport type AgentsDomain = ReturnType<typeof createAgentsDomain>;\n","/**\n * Protocol Stats domain module for the Zenland SDK\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { PROTOCOL_STATS_QUERY } from \"../queries\";\nimport type { GqlProtocolStats, ProtocolStatsQueryResponse } from \"../generated/types\";\n\n/** Normalized protocol stats with BigInt values */\nexport interface ProtocolStats {\n id: string;\n totalEscrowsCreated: number;\n totalVolumeEscrowed: bigint;\n totalFeesCollected: bigint;\n currentTVL: bigint;\n activeEscrowCount: number;\n totalAgentsRegistered: number;\n activeAgentsCount: number;\n}\n\n/**\n * Convert raw GraphQL response to normalized ProtocolStats\n */\nfunction normalizeProtocolStats(raw: GqlProtocolStats): ProtocolStats {\n return {\n id: raw.id,\n totalEscrowsCreated: raw.totalEscrowsCreated,\n totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),\n totalFeesCollected: BigInt(raw.totalFeesCollected),\n currentTVL: BigInt(raw.currentTVL),\n activeEscrowCount: raw.activeEscrowCount,\n totalAgentsRegistered: raw.totalAgentsRegistered,\n activeAgentsCount: raw.activeAgentsCount,\n };\n}\n\n/**\n * Creates protocol stats domain functions bound to a base URL\n */\nexport function createProtocolStatsDomain(baseUrl: string) {\n /**\n * Fetch global protocol statistics\n */\n async function get(): Promise<ProtocolStats | null> {\n const variables = { id: \"global\" };\n\n const response = await graphqlRequest<ProtocolStatsQueryResponse, typeof variables>(\n baseUrl,\n PROTOCOL_STATS_QUERY,\n variables,\n );\n\n if (!response.protocolStats) {\n return null;\n }\n\n return normalizeProtocolStats(response.protocolStats);\n }\n\n /**\n * Fetch raw protocol statistics (without BigInt conversion)\n */\n async function getRaw(): Promise<GqlProtocolStats | null> {\n const variables = { id: \"global\" };\n\n const response = await graphqlRequest<ProtocolStatsQueryResponse, typeof variables>(\n baseUrl,\n PROTOCOL_STATS_QUERY,\n variables,\n );\n\n return response.protocolStats;\n }\n\n return {\n get,\n getRaw,\n };\n}\n\nexport type ProtocolStatsDomain = ReturnType<typeof createProtocolStatsDomain>;\n","/**\n * Transaction Logs domain module for the Zenland SDK\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { TRANSACTION_LOGS_QUERY } from \"../queries\";\nimport type { GqlTransactionLog, TransactionLogsQueryResponse } from \"../generated/types\";\n\nexport interface ListTransactionLogsArgs {\n escrowAddress?: string;\n limit?: number;\n offset?: number;\n orderBy?: string;\n orderDirection?: \"asc\" | \"desc\";\n}\n\n/**\n * Creates transaction logs domain functions bound to a base URL\n */\nexport function createTransactionLogsDomain(baseUrl: string) {\n /**\n * List transaction logs with filtering and pagination\n */\n async function list(args?: ListTransactionLogsArgs): Promise<GqlTransactionLog[]> {\n const variables = {\n escrowAddress: args?.escrowAddress?.toLowerCase(),\n limit: args?.limit ?? 100,\n offset: args?.offset ?? 0,\n orderBy: args?.orderBy ?? \"timestamp\",\n orderDirection: args?.orderDirection ?? \"asc\",\n };\n\n const response = await graphqlRequest<TransactionLogsQueryResponse, typeof variables>(\n baseUrl,\n TRANSACTION_LOGS_QUERY,\n variables,\n );\n\n return response.transactionLogs.items;\n }\n\n /**\n * Get transaction logs for a specific escrow\n */\n async function getByEscrow(\n escrowAddress: string,\n args?: Omit<ListTransactionLogsArgs, \"escrowAddress\">,\n ): Promise<GqlTransactionLog[]> {\n return list({ ...args, escrowAddress });\n }\n\n /**\n * Parse eventData JSON string from a transaction log\n */\n function parseEventData(eventData: string): Record<string, unknown> {\n try {\n return JSON.parse(eventData);\n } catch {\n return {};\n }\n }\n\n return {\n list,\n getByEscrow,\n parseEventData,\n };\n}\n\nexport type TransactionLogsDomain = ReturnType<typeof createTransactionLogsDomain>;\n","/**\n * Zenland SDK Client\n *\n * The main entry point for interacting with the Zenland indexer.\n */\n\nimport { createEscrowsDomain, type EscrowsDomain } from \"./domains/escrows\";\nimport { createAgentsDomain, type AgentsDomain } from \"./domains/agents\";\nimport { createProtocolStatsDomain, type ProtocolStatsDomain } from \"./domains/protocol-stats\";\nimport { createTransactionLogsDomain, type TransactionLogsDomain } from \"./domains/transaction-logs\";\n\n/** Default production indexer URL */\nconst DEFAULT_BASE_URL = \"https://api.zen.land\";\n\nexport interface ZenlandClientConfig {\n /** Base URL for the indexer API. Defaults to https://api.zen.land */\n baseUrl?: string;\n}\n\nexport interface ZenlandClient {\n /** The base URL being used by this client */\n readonly baseUrl: string;\n\n /** Escrow-related operations */\n readonly escrows: EscrowsDomain;\n\n /** Agent-related operations */\n readonly agents: AgentsDomain;\n\n /** Protocol statistics */\n readonly protocolStats: ProtocolStatsDomain;\n\n /** Transaction logs */\n readonly transactionLogs: TransactionLogsDomain;\n}\n\n/**\n * Create a new Zenland SDK client.\n *\n * @example\n * ```typescript\n * // Use production API (default)\n * const client = createZenlandClient();\n *\n * // Use custom endpoint (e.g., local development)\n * const client = createZenlandClient({ baseUrl: 'http://localhost:42069' });\n *\n * // Fetch escrows\n * const { items, totalCount } = await client.escrows.list({ limit: 10 });\n *\n * // Fetch a specific escrow\n * const escrow = await client.escrows.getById('0x...');\n *\n * // Fetch agents\n * const agents = await client.agents.list({ onlyActive: true });\n *\n * // Fetch protocol stats\n * const stats = await client.protocolStats.get();\n * ```\n */\nexport function createZenlandClient(config?: ZenlandClientConfig): ZenlandClient {\n const baseUrl = normalizeBaseUrl(config?.baseUrl ?? DEFAULT_BASE_URL);\n\n return {\n baseUrl,\n escrows: createEscrowsDomain(baseUrl),\n agents: createAgentsDomain(baseUrl),\n protocolStats: createProtocolStatsDomain(baseUrl),\n transactionLogs: createTransactionLogsDomain(baseUrl),\n };\n}\n\n/**\n * Normalize base URL by removing trailing slash\n */\nfunction normalizeBaseUrl(url: string): string {\n return url.endsWith(\"/\") ? url.slice(0, -1) : url;\n}\n\n/**\n * Default client instance using production API.\n * Use this for quick access without creating a new client.\n *\n * @example\n * ```typescript\n * import { zenland } from '@zenland/sdk';\n *\n * const escrows = await zenland.escrows.list();\n * ```\n */\nexport const zenland = createZenlandClient();\n","/**\n * Agent eligibility utilities.\n *\n * This is protocol/business logic (React-agnostic) and is safe to consume\n * from any app (interface, backend, bots, etc.).\n */\n\n/**\n * Minimal view of an Agent returned by the indexer.\n */\nexport type IndexerAgent = {\n id: string;\n isActive: boolean;\n isAvailable: boolean;\n stablecoinStake: bigint;\n stablecoinDecimals: number;\n registrationTime: bigint;\n activeCases: number;\n totalResolved: number;\n};\n\nexport type AgentEligibilityFailureReason =\n | \"NOT_REGISTERED\"\n | \"NOT_ACTIVE\"\n | \"NOT_AVAILABLE\"\n | \"INSUFFICIENT_MAV\";\n\nexport type AgentEligibilityResult =\n | {\n ok: true;\n agentMavUsd: bigint;\n requiredUsd: bigint;\n }\n | {\n ok: false;\n reason: AgentEligibilityFailureReason;\n agentMavUsd?: bigint;\n requiredUsd: bigint;\n };\n\n/**\n * MAV multiplier - how much MAV you get per dollar staked.\n * $1 stake * 20 = $20 MAV\n */\nconst MAV_MULTIPLIER = 20n;\n\n/**\n * Compute agent MAV from its stablecoin stake.\n *\n * Bigint-safe:\n * - stablecoinStake is in smallest units (stablecoinDecimals)\n * - return MAV in the same smallest units (stablecoinDecimals)\n */\nexport function computeAgentMavUsd(\n agent: Pick<IndexerAgent, \"stablecoinStake\" | \"stablecoinDecimals\">,\n): bigint {\n // decimals are not used in arithmetic; they’re carried for formatting.\n // MAV is a simple multiplier in the same units.\n return BigInt(agent.stablecoinStake) * MAV_MULTIPLIER;\n}\n\n/**\n * Evaluate whether an agent is eligible for a given escrow amount.\n *\n * NOTE: escrowAmount must be the escrow principal ONLY (fees excluded).\n */\nexport function isAgentEligibleForEscrow(args: {\n agent: IndexerAgent | null | undefined;\n escrowAmount: bigint;\n}): AgentEligibilityResult {\n const requiredUsd = args.escrowAmount;\n\n if (!args.agent) {\n return { ok: false, reason: \"NOT_REGISTERED\", requiredUsd };\n }\n\n if (!args.agent.isActive) {\n return { ok: false, reason: \"NOT_ACTIVE\", requiredUsd };\n }\n\n if (!args.agent.isAvailable) {\n return { ok: false, reason: \"NOT_AVAILABLE\", requiredUsd };\n }\n\n const agentMavUsd = computeAgentMavUsd(args.agent);\n\n if (agentMavUsd < requiredUsd) {\n return { ok: false, reason: \"INSUFFICIENT_MAV\", agentMavUsd, requiredUsd };\n }\n\n return { ok: true, agentMavUsd, requiredUsd };\n}\n"],"mappings":";AAiBO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7B;AAAA,EAEhB,YAAY,SAAiB,QAA4B;AACvD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAKO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7B;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,QAAgB,YAAoB;AAC/D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,aAAa;AAAA,EACpB;AACF;AASA,eAAsB,eACpB,SACA,UACA,WACA,SACgB;AAChB,QAAM,WAAW,GAAG,OAAO;AAE3B,QAAM,MAAM,MAAM,MAAM,UAAU;AAAA,IAChC,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAA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