@zenland/sdk 0.1.0 → 0.1.1
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 +8 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +8 -5
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +15 -2
- package/dist/react.d.ts +15 -2
- package/dist/react.js +8 -5
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -229,9 +229,10 @@ query escrows(
|
|
|
229
229
|
}
|
|
230
230
|
`;
|
|
231
231
|
var PROTOCOL_STATS_QUERY = `
|
|
232
|
-
query protocolStats($id: String! = "
|
|
232
|
+
query protocolStats($id: String! = "mainnet") {
|
|
233
233
|
protocolStats(id: $id) {
|
|
234
234
|
id
|
|
235
|
+
chainId
|
|
235
236
|
totalEscrowsCreated
|
|
236
237
|
totalVolumeEscrowed
|
|
237
238
|
totalFeesCollected
|
|
@@ -372,9 +373,11 @@ function createAgentsDomain(baseUrl) {
|
|
|
372
373
|
}
|
|
373
374
|
|
|
374
375
|
// src/domains/protocol-stats.ts
|
|
376
|
+
var DEFAULT_STATS_ID = "mainnet";
|
|
375
377
|
function normalizeProtocolStats(raw) {
|
|
376
378
|
return {
|
|
377
379
|
id: raw.id,
|
|
380
|
+
chainId: raw.chainId,
|
|
378
381
|
totalEscrowsCreated: raw.totalEscrowsCreated,
|
|
379
382
|
totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
|
|
380
383
|
totalFeesCollected: BigInt(raw.totalFeesCollected),
|
|
@@ -385,8 +388,8 @@ function normalizeProtocolStats(raw) {
|
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
390
|
function createProtocolStatsDomain(baseUrl) {
|
|
388
|
-
async function get() {
|
|
389
|
-
const variables = { id:
|
|
391
|
+
async function get(options) {
|
|
392
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
390
393
|
const response = await graphqlRequest(
|
|
391
394
|
baseUrl,
|
|
392
395
|
PROTOCOL_STATS_QUERY,
|
|
@@ -397,8 +400,8 @@ function createProtocolStatsDomain(baseUrl) {
|
|
|
397
400
|
}
|
|
398
401
|
return normalizeProtocolStats(response.protocolStats);
|
|
399
402
|
}
|
|
400
|
-
async function getRaw() {
|
|
401
|
-
const variables = { id:
|
|
403
|
+
async function getRaw(options) {
|
|
404
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
402
405
|
const response = await graphqlRequest(
|
|
403
406
|
baseUrl,
|
|
404
407
|
PROTOCOL_STATS_QUERY,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../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 * @zenland/sdk\n *\n * Official SDK for interacting with the Zenland escrow protocol indexer.\n *\n * @example\n * ```typescript\n * import { createZenlandClient, zenland } from '@zenland/sdk';\n *\n * // Use the default client (production API)\n * const escrows = await zenland.escrows.list();\n *\n * // Or create a custom client\n * const client = createZenlandClient({ baseUrl: 'http://localhost:42069' });\n * const agents = await client.agents.list({ onlyActive: true });\n * ```\n */\n\n// Main client\nexport { createZenlandClient, zenland } from \"./client\";\nexport type { ZenlandClient, ZenlandClientConfig } from \"./client\";\n\n// Domain modules (for advanced usage)\nexport {\n createEscrowsDomain,\n createAgentsDomain,\n createProtocolStatsDomain,\n createTransactionLogsDomain,\n STATE_GROUPS,\n} from \"./domains\";\nexport type {\n EscrowsDomain,\n AgentsDomain,\n ProtocolStatsDomain,\n TransactionLogsDomain,\n ListEscrowsArgs,\n ListAgentsArgs,\n ListTransactionLogsArgs,\n StateGroup,\n ProtocolStats,\n} from \"./domains\";\n\n// Types\nexport type {\n // GraphQL types\n GqlAgent,\n GqlAgentCase,\n GqlAgentCasePage,\n GqlAgentPage,\n GqlAgentFilter,\n GqlEscrow,\n GqlEscrowPage,\n GqlEscrowFilter,\n GqlProtocolStats,\n GqlTransactionLog,\n GqlTransactionLogPage,\n GqlTransactionLogFilter,\n GqlPageInfo,\n BigIntScalar,\n Maybe,\n InputMaybe,\n} from \"./generated/types\";\n\n// Protocol / business-logic utilities\nexport {\n computeAgentMavUsd,\n isAgentEligibleForEscrow,\n} from \"./agents/eligibility\";\nexport type {\n IndexerAgent,\n AgentEligibilityFailureReason,\n AgentEligibilityResult,\n} from \"./agents/eligibility\";\n\n// Errors\nexport { ZenlandGraphQLError, ZenlandRequestError } from \"./request\";\n","/**\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,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,QAA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C3C,IAAM,iBAAiB;AAShB,SAAS,mBACd,OACQ;AAGR,SAAO,OAAO,MAAM,eAAe,IAAI;AACzC;AAOO,SAAS,yBAAyB,MAGd;AACzB,QAAM,cAAc,KAAK;AAEzB,MAAI,CAAC,KAAK,OAAO;AACf,WAAO,EAAE,IAAI,OAAO,QAAQ,kBAAkB,YAAY;AAAA,EAC5D;AAEA,MAAI,CAAC,KAAK,MAAM,UAAU;AACxB,WAAO,EAAE,IAAI,OAAO,QAAQ,cAAc,YAAY;AAAA,EACxD;AAEA,MAAI,CAAC,KAAK,MAAM,aAAa;AAC3B,WAAO,EAAE,IAAI,OAAO,QAAQ,iBAAiB,YAAY;AAAA,EAC3D;AAEA,QAAM,cAAc,mBAAmB,KAAK,KAAK;AAEjD,MAAI,cAAc,aAAa;AAC7B,WAAO,EAAE,IAAI,OAAO,QAAQ,oBAAoB,aAAa,YAAY;AAAA,EAC3E;AAEA,SAAO,EAAE,IAAI,MAAM,aAAa,YAAY;AAC9C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../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 * @zenland/sdk\n *\n * Official SDK for interacting with the Zenland escrow protocol indexer.\n *\n * @example\n * ```typescript\n * import { createZenlandClient, zenland } from '@zenland/sdk';\n *\n * // Use the default client (production API)\n * const escrows = await zenland.escrows.list();\n *\n * // Or create a custom client\n * const client = createZenlandClient({ baseUrl: 'http://localhost:42069' });\n * const agents = await client.agents.list({ onlyActive: true });\n * ```\n */\n\n// Main client\nexport { createZenlandClient, zenland } from \"./client\";\nexport type { ZenlandClient, ZenlandClientConfig } from \"./client\";\n\n// Domain modules (for advanced usage)\nexport {\n createEscrowsDomain,\n createAgentsDomain,\n createProtocolStatsDomain,\n createTransactionLogsDomain,\n STATE_GROUPS,\n} from \"./domains\";\nexport type {\n EscrowsDomain,\n AgentsDomain,\n ProtocolStatsDomain,\n TransactionLogsDomain,\n ListEscrowsArgs,\n ListAgentsArgs,\n ListTransactionLogsArgs,\n StateGroup,\n ProtocolStats,\n} from \"./domains\";\n\n// Types\nexport type {\n // GraphQL types\n GqlAgent,\n GqlAgentCase,\n GqlAgentCasePage,\n GqlAgentPage,\n GqlAgentFilter,\n GqlEscrow,\n GqlEscrowPage,\n GqlEscrowFilter,\n GqlProtocolStats,\n GqlTransactionLog,\n GqlTransactionLogPage,\n GqlTransactionLogFilter,\n GqlPageInfo,\n BigIntScalar,\n Maybe,\n InputMaybe,\n} from \"./generated/types\";\n\n// Protocol / business-logic utilities\nexport {\n computeAgentMavUsd,\n isAgentEligibleForEscrow,\n} from \"./agents/eligibility\";\nexport type {\n IndexerAgent,\n AgentEligibilityFailureReason,\n AgentEligibilityResult,\n} from \"./agents/eligibility\";\n\n// Errors\nexport { ZenlandGraphQLError, ZenlandRequestError } from \"./request\";\n","/**\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! = \"mainnet\") {\n protocolStats(id: $id) {\n id\n chainId\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 * Stats are tracked per-chain. By default, mainnet stats are returned\n * for production UI. Use chainId parameter to query other networks.\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { PROTOCOL_STATS_QUERY } from \"../queries\";\nimport type { GqlProtocolStats, ProtocolStatsQueryResponse } from \"../generated/types\";\n\n/** Default stats ID for production (Ethereum mainnet) */\nconst DEFAULT_STATS_ID = \"mainnet\";\n\n/** Normalized protocol stats with BigInt values */\nexport interface ProtocolStats {\n id: string;\n chainId?: number;\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 chainId: (raw as any).chainId,\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\nexport interface GetProtocolStatsOptions {\n /** \n * Stats ID to query. Defaults to \"mainnet\".\n * Use \"sepolia\" for testnet stats.\n */\n statsId?: string;\n}\n\n/**\n * Creates protocol stats domain functions bound to a base URL\n */\nexport function createProtocolStatsDomain(baseUrl: string) {\n /**\n * Fetch protocol statistics for a specific chain.\n * Defaults to mainnet for production use.\n * \n * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function get(options?: GetProtocolStatsOptions): Promise<ProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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 * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function getRaw(options?: GetProtocolStatsOptions): Promise<GqlProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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,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YAAY;AAAA,EAC3E;AAEA,SAAO,EAAE,IAAI,MAAM,aAAa,YAAY;AAC9C;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -110,6 +110,8 @@ interface GqlEscrowFilter {
|
|
|
110
110
|
}
|
|
111
111
|
interface GqlProtocolStats {
|
|
112
112
|
id: string;
|
|
113
|
+
/** Chain ID (1 for mainnet, 11155111 for sepolia) */
|
|
114
|
+
chainId: number;
|
|
113
115
|
totalEscrowsCreated: number;
|
|
114
116
|
totalVolumeEscrowed: BigIntScalar;
|
|
115
117
|
totalFeesCollected: BigIntScalar;
|
|
@@ -205,11 +207,15 @@ type AgentsDomain = ReturnType<typeof createAgentsDomain>;
|
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
* Protocol Stats domain module for the Zenland SDK
|
|
210
|
+
*
|
|
211
|
+
* Stats are tracked per-chain. By default, mainnet stats are returned
|
|
212
|
+
* for production UI. Use chainId parameter to query other networks.
|
|
208
213
|
*/
|
|
209
214
|
|
|
210
215
|
/** Normalized protocol stats with BigInt values */
|
|
211
216
|
interface ProtocolStats {
|
|
212
217
|
id: string;
|
|
218
|
+
chainId?: number;
|
|
213
219
|
totalEscrowsCreated: number;
|
|
214
220
|
totalVolumeEscrowed: bigint;
|
|
215
221
|
totalFeesCollected: bigint;
|
|
@@ -218,12 +224,19 @@ interface ProtocolStats {
|
|
|
218
224
|
totalAgentsRegistered: number;
|
|
219
225
|
activeAgentsCount: number;
|
|
220
226
|
}
|
|
227
|
+
interface GetProtocolStatsOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Stats ID to query. Defaults to "mainnet".
|
|
230
|
+
* Use "sepolia" for testnet stats.
|
|
231
|
+
*/
|
|
232
|
+
statsId?: string;
|
|
233
|
+
}
|
|
221
234
|
/**
|
|
222
235
|
* Creates protocol stats domain functions bound to a base URL
|
|
223
236
|
*/
|
|
224
237
|
declare function createProtocolStatsDomain(baseUrl: string): {
|
|
225
|
-
get: () => Promise<ProtocolStats | null>;
|
|
226
|
-
getRaw: () => Promise<GqlProtocolStats | null>;
|
|
238
|
+
get: (options?: GetProtocolStatsOptions) => Promise<ProtocolStats | null>;
|
|
239
|
+
getRaw: (options?: GetProtocolStatsOptions) => Promise<GqlProtocolStats | null>;
|
|
227
240
|
};
|
|
228
241
|
type ProtocolStatsDomain = ReturnType<typeof createProtocolStatsDomain>;
|
|
229
242
|
|
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ interface GqlEscrowFilter {
|
|
|
110
110
|
}
|
|
111
111
|
interface GqlProtocolStats {
|
|
112
112
|
id: string;
|
|
113
|
+
/** Chain ID (1 for mainnet, 11155111 for sepolia) */
|
|
114
|
+
chainId: number;
|
|
113
115
|
totalEscrowsCreated: number;
|
|
114
116
|
totalVolumeEscrowed: BigIntScalar;
|
|
115
117
|
totalFeesCollected: BigIntScalar;
|
|
@@ -205,11 +207,15 @@ type AgentsDomain = ReturnType<typeof createAgentsDomain>;
|
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
* Protocol Stats domain module for the Zenland SDK
|
|
210
|
+
*
|
|
211
|
+
* Stats are tracked per-chain. By default, mainnet stats are returned
|
|
212
|
+
* for production UI. Use chainId parameter to query other networks.
|
|
208
213
|
*/
|
|
209
214
|
|
|
210
215
|
/** Normalized protocol stats with BigInt values */
|
|
211
216
|
interface ProtocolStats {
|
|
212
217
|
id: string;
|
|
218
|
+
chainId?: number;
|
|
213
219
|
totalEscrowsCreated: number;
|
|
214
220
|
totalVolumeEscrowed: bigint;
|
|
215
221
|
totalFeesCollected: bigint;
|
|
@@ -218,12 +224,19 @@ interface ProtocolStats {
|
|
|
218
224
|
totalAgentsRegistered: number;
|
|
219
225
|
activeAgentsCount: number;
|
|
220
226
|
}
|
|
227
|
+
interface GetProtocolStatsOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Stats ID to query. Defaults to "mainnet".
|
|
230
|
+
* Use "sepolia" for testnet stats.
|
|
231
|
+
*/
|
|
232
|
+
statsId?: string;
|
|
233
|
+
}
|
|
221
234
|
/**
|
|
222
235
|
* Creates protocol stats domain functions bound to a base URL
|
|
223
236
|
*/
|
|
224
237
|
declare function createProtocolStatsDomain(baseUrl: string): {
|
|
225
|
-
get: () => Promise<ProtocolStats | null>;
|
|
226
|
-
getRaw: () => Promise<GqlProtocolStats | null>;
|
|
238
|
+
get: (options?: GetProtocolStatsOptions) => Promise<ProtocolStats | null>;
|
|
239
|
+
getRaw: (options?: GetProtocolStatsOptions) => Promise<GqlProtocolStats | null>;
|
|
227
240
|
};
|
|
228
241
|
type ProtocolStatsDomain = ReturnType<typeof createProtocolStatsDomain>;
|
|
229
242
|
|
package/dist/index.js
CHANGED
|
@@ -193,9 +193,10 @@ query escrows(
|
|
|
193
193
|
}
|
|
194
194
|
`;
|
|
195
195
|
var PROTOCOL_STATS_QUERY = `
|
|
196
|
-
query protocolStats($id: String! = "
|
|
196
|
+
query protocolStats($id: String! = "mainnet") {
|
|
197
197
|
protocolStats(id: $id) {
|
|
198
198
|
id
|
|
199
|
+
chainId
|
|
199
200
|
totalEscrowsCreated
|
|
200
201
|
totalVolumeEscrowed
|
|
201
202
|
totalFeesCollected
|
|
@@ -336,9 +337,11 @@ function createAgentsDomain(baseUrl) {
|
|
|
336
337
|
}
|
|
337
338
|
|
|
338
339
|
// src/domains/protocol-stats.ts
|
|
340
|
+
var DEFAULT_STATS_ID = "mainnet";
|
|
339
341
|
function normalizeProtocolStats(raw) {
|
|
340
342
|
return {
|
|
341
343
|
id: raw.id,
|
|
344
|
+
chainId: raw.chainId,
|
|
342
345
|
totalEscrowsCreated: raw.totalEscrowsCreated,
|
|
343
346
|
totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
|
|
344
347
|
totalFeesCollected: BigInt(raw.totalFeesCollected),
|
|
@@ -349,8 +352,8 @@ function normalizeProtocolStats(raw) {
|
|
|
349
352
|
};
|
|
350
353
|
}
|
|
351
354
|
function createProtocolStatsDomain(baseUrl) {
|
|
352
|
-
async function get() {
|
|
353
|
-
const variables = { id:
|
|
355
|
+
async function get(options) {
|
|
356
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
354
357
|
const response = await graphqlRequest(
|
|
355
358
|
baseUrl,
|
|
356
359
|
PROTOCOL_STATS_QUERY,
|
|
@@ -361,8 +364,8 @@ function createProtocolStatsDomain(baseUrl) {
|
|
|
361
364
|
}
|
|
362
365
|
return normalizeProtocolStats(response.protocolStats);
|
|
363
366
|
}
|
|
364
|
-
async function getRaw() {
|
|
365
|
-
const variables = { id:
|
|
367
|
+
async function getRaw(options) {
|
|
368
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
366
369
|
const response = await graphqlRequest(
|
|
367
370
|
baseUrl,
|
|
368
371
|
PROTOCOL_STATS_QUERY,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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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S,GAAG,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI;AAChD;AAaO,IAAM,UAAU,oBAAoB;;;AC9C3C,IAAM,iBAAiB;AAShB,SAAS,mBACd,OACQ;AAGR,SAAO,OAAO,MAAM,eAAe,IAAI;AACzC;AAOO,SAAS,yBAAyB,MAGd;AACzB,QAAM,cAAc,KAAK;AAEzB,MAAI,CAAC,KAAK,OAAO;AACf,WAAO,EAAE,IAAI,OAAO,QAAQ,kBAAkB,YAAY;AAAA,EAC5D;AAEA,MAAI,CAAC,KAAK,MAAM,UAAU;AACxB,WAAO,EAAE,IAAI,OAAO,QAAQ,cAAc,YAAY;AAAA,EACxD;AAEA,MAAI,CAAC,KAAK,MAAM,aAAa;AAC3B,WAAO,EAAE,IAAI,OAAO,QAAQ,iBAAiB,YAAY;AAAA,EAC3D;AAEA,QAAM,cAAc,mBAAmB,KAAK,KAAK;AAEjD,MAAI,cAAc,aAAa;AAC7B,WAAO,EAAE,IAAI,OAAO,QAAQ,oBAAoB,aAAa,YAAY;AAAA,EAC3E;AAEA,SAAO,EAAE,IAAI,MAAM,aAAa,YAAY;AAC9C;","names":[]}
|
|
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! = \"mainnet\") {\n protocolStats(id: $id) {\n id\n chainId\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 * Stats are tracked per-chain. By default, mainnet stats are returned\n * for production UI. Use chainId parameter to query other networks.\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { PROTOCOL_STATS_QUERY } from \"../queries\";\nimport type { GqlProtocolStats, ProtocolStatsQueryResponse } from \"../generated/types\";\n\n/** Default stats ID for production (Ethereum mainnet) */\nconst DEFAULT_STATS_ID = \"mainnet\";\n\n/** Normalized protocol stats with BigInt values */\nexport interface ProtocolStats {\n id: string;\n chainId?: number;\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 chainId: (raw as any).chainId,\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\nexport interface GetProtocolStatsOptions {\n /** \n * Stats ID to query. Defaults to \"mainnet\".\n * Use \"sepolia\" for testnet stats.\n */\n statsId?: string;\n}\n\n/**\n * Creates protocol stats domain functions bound to a base URL\n */\nexport function createProtocolStatsDomain(baseUrl: string) {\n /**\n * Fetch protocol statistics for a specific chain.\n * Defaults to mainnet for production use.\n * \n * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function get(options?: GetProtocolStatsOptions): Promise<ProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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 * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function getRaw(options?: GetProtocolStatsOptions): Promise<GqlProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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,UAAU,EAAE,OAAO,UAAU,UAAU,CAAC;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,OAAO;AAAA,EACT,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,EAAE;AAC5C,UAAM,IAAI;AAAA,MACR,2BAA2B,IAAI,MAAM,IAAI,IAAI,UAAU,IAAI,OAAO,KAAK,IAAI,KAAK,EAAE;AAAA,MAClF,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,EACF;AAEA,QA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,YAAY;AAAA,EAC3D;AAEA,QAAM,cAAc,mBAAmB,KAAK,KAAK;AAEjD,MAAI,cAAc,aAAa;AAC7B,WAAO,EAAE,IAAI,OAAO,QAAQ,oBAAoB,aAAa,YAAY;AAAA,EAC3E;AAEA,SAAO,EAAE,IAAI,MAAM,aAAa,YAAY;AAC9C;","names":[]}
|
package/dist/react.cjs
CHANGED
|
@@ -236,9 +236,10 @@ query escrows(
|
|
|
236
236
|
}
|
|
237
237
|
`;
|
|
238
238
|
var PROTOCOL_STATS_QUERY = `
|
|
239
|
-
query protocolStats($id: String! = "
|
|
239
|
+
query protocolStats($id: String! = "mainnet") {
|
|
240
240
|
protocolStats(id: $id) {
|
|
241
241
|
id
|
|
242
|
+
chainId
|
|
242
243
|
totalEscrowsCreated
|
|
243
244
|
totalVolumeEscrowed
|
|
244
245
|
totalFeesCollected
|
|
@@ -379,9 +380,11 @@ function createAgentsDomain(baseUrl) {
|
|
|
379
380
|
}
|
|
380
381
|
|
|
381
382
|
// src/domains/protocol-stats.ts
|
|
383
|
+
var DEFAULT_STATS_ID = "mainnet";
|
|
382
384
|
function normalizeProtocolStats(raw) {
|
|
383
385
|
return {
|
|
384
386
|
id: raw.id,
|
|
387
|
+
chainId: raw.chainId,
|
|
385
388
|
totalEscrowsCreated: raw.totalEscrowsCreated,
|
|
386
389
|
totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
|
|
387
390
|
totalFeesCollected: BigInt(raw.totalFeesCollected),
|
|
@@ -392,8 +395,8 @@ function normalizeProtocolStats(raw) {
|
|
|
392
395
|
};
|
|
393
396
|
}
|
|
394
397
|
function createProtocolStatsDomain(baseUrl) {
|
|
395
|
-
async function get() {
|
|
396
|
-
const variables = { id:
|
|
398
|
+
async function get(options) {
|
|
399
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
397
400
|
const response = await graphqlRequest(
|
|
398
401
|
baseUrl,
|
|
399
402
|
PROTOCOL_STATS_QUERY,
|
|
@@ -404,8 +407,8 @@ function createProtocolStatsDomain(baseUrl) {
|
|
|
404
407
|
}
|
|
405
408
|
return normalizeProtocolStats(response.protocolStats);
|
|
406
409
|
}
|
|
407
|
-
async function getRaw() {
|
|
408
|
-
const variables = { id:
|
|
410
|
+
async function getRaw(options) {
|
|
411
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
409
412
|
const response = await graphqlRequest(
|
|
410
413
|
baseUrl,
|
|
411
414
|
PROTOCOL_STATS_QUERY,
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts","../src/react/context.tsx","../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/react/hooks/useEscrow.ts","../src/react/hooks/useEscrows.ts","../src/react/hooks/useAgent.ts","../src/react/hooks/useAgents.ts","../src/react/hooks/useProtocolStats.ts","../src/react/hooks/useRecentEscrows.ts","../src/react/hooks/useUserStats.ts","../src/react/hooks/useTransactionLogsByEscrow.ts"],"sourcesContent":["/**\n * @zenland/sdk/react\n *\n * React hooks and components for the Zenland SDK.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider, useEscrows, useAgent } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <MyComponent />\n * </ZenlandProvider>\n * );\n * }\n *\n * function MyComponent() {\n * const { data: escrows } = useEscrows({ address: '0x...' });\n * const { data: agent } = useAgent('0x...');\n * // ...\n * }\n * ```\n */\n\n// Context and provider\nexport { ZenlandProvider, useZenlandClient, useZenlandClientOptional } from \"./react/context\";\nexport type { ZenlandProviderProps } from \"./react/context\";\n\n// Hooks\nexport {\n useEscrow,\n useEscrows,\n useAgent,\n useAgents,\n useProtocolStats,\n useUserStats,\n useGlobalStats,\n useTransactionLogsByEscrow,\n useRecentEscrows,\n STATE_GROUPS,\n} from \"./react/hooks\";\nexport type {\n UseEscrowOptions,\n UseEscrowsArgs,\n EscrowRole,\n EscrowStateTab,\n UseAgentOptions,\n UseAgentsArgs,\n UseProtocolStatsOptions,\n UseRecentEscrowsOptions,\n UserDashboardStats,\n UseTransactionLogsByEscrowOptions,\n ProtocolStats,\n} from \"./react/hooks\";\n\n// Re-export types from core for convenience\nexport type {\n GqlAgent,\n GqlAgentPage,\n GqlEscrow,\n GqlEscrowPage,\n GqlProtocolStats,\n GqlTransactionLog,\n GqlPageInfo,\n} from \"./generated/types\";\n\n// Re-export client for advanced usage\nexport { createZenlandClient } from \"./client\";\nexport type { ZenlandClient, ZenlandClientConfig } from \"./client\";\n","\"use client\";\n\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport { createZenlandClient, type ZenlandClient, type ZenlandClientConfig } from \"../client\";\n\nconst ZenlandContext = createContext<ZenlandClient | null>(null);\n\nexport interface ZenlandProviderProps {\n children: ReactNode;\n /** Optional configuration for the SDK client */\n config?: ZenlandClientConfig;\n}\n\n/**\n * Provider component for the Zenland SDK.\n *\n * Wrap your app with this provider to use the React hooks.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <YourApp />\n * </ZenlandProvider>\n * );\n * }\n *\n * // With custom config\n * <ZenlandProvider config={{ baseUrl: 'http://localhost:42069' }}>\n * <YourApp />\n * </ZenlandProvider>\n * ```\n */\nexport function ZenlandProvider({ children, config }: ZenlandProviderProps) {\n const client = useMemo(() => createZenlandClient(config), [config]);\n\n return <ZenlandContext.Provider value={client}>{children}</ZenlandContext.Provider>;\n}\n\n/**\n * Hook to access the Zenland SDK client.\n *\n * Must be used within a ZenlandProvider.\n *\n * @example\n * ```tsx\n * import { useZenlandClient } from '@zenland/sdk/react';\n *\n * function MyComponent() {\n * const client = useZenlandClient();\n * // Use client.escrows, client.agents, etc.\n * }\n * ```\n */\nexport function useZenlandClient(): ZenlandClient {\n const context = useContext(ZenlandContext);\n if (!context) {\n throw new Error(\"useZenlandClient must be used within a ZenlandProvider\");\n }\n return context;\n}\n\n/**\n * Hook to access the Zenland SDK client, creating a default one if not in a provider.\n *\n * This is useful for components that might be used outside of a ZenlandProvider.\n */\nexport function useZenlandClientOptional(): ZenlandClient {\n const context = useContext(ZenlandContext);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => context ?? createZenlandClient(), [context]);\n}\n","/**\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","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single escrow by ID.\n *\n * @example\n * ```tsx\n * import { useEscrow } from '@zenland/sdk/react';\n *\n * function EscrowDetail({ id }: { id: string }) {\n * const { data: escrow, isLoading, error } = useEscrow(id);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!escrow) return <div>Escrow not found</div>;\n *\n * return <div>{escrow.state}</div>;\n * }\n * ```\n */\nexport function useEscrow(id: string | undefined, options?: UseEscrowOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlEscrow | null>({\n queryKey: [\"zenland\", \"escrow\", id],\n queryFn: () => {\n if (!id) return null;\n return client.escrows.getById(id);\n },\n enabled: !!id && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS, type StateGroup } from \"../../domains/escrows\";\nimport type { GqlEscrowPage } from \"../../generated/types\";\n\nexport type EscrowRole = \"all\" | \"buyer\" | \"seller\" | \"agent\";\nexport type EscrowStateTab = \"all\" | StateGroup;\n\nexport interface UseEscrowsArgs {\n /** User address to filter by */\n address?: string;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Filter by role (requires address) */\n role?: EscrowRole;\n /** Filter by state group */\n stateTab?: EscrowStateTab;\n /** Filter by specific state */\n state?: string;\n /** Filter by multiple states */\n states?: string[];\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch escrows with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useEscrows } from '@zenland/sdk/react';\n *\n * function MyEscrows({ address }: { address: string }) {\n * const { data, isLoading } = useEscrows({\n * address,\n * role: 'buyer',\n * stateTab: 'ACTIVE',\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(escrow => (\n * <li key={escrow.id}>{escrow.state}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useEscrows(args?: UseEscrowsArgs) {\n const client = useZenlandClientOptional();\n const { address, role = \"all\", stateTab, enabled = true } = args ?? {};\n\n // Determine states to filter based on stateTab\n const getStatesFromTab = (): string[] | undefined => {\n if (!stateTab || stateTab === \"all\") {\n return args?.states;\n }\n return [...STATE_GROUPS[stateTab]];\n };\n\n return useQuery<GqlEscrowPage>({\n queryKey: [\"zenland\", \"escrows\", address, role, stateTab, args?.state, args?.states, args?.limit, args?.offset],\n queryFn: async () => {\n if (!address) {\n return { items: [], totalCount: 0, pageInfo: { hasNextPage: false, hasPreviousPage: false } };\n }\n\n const states = getStatesFromTab();\n\n return client.escrows.list({\n limit: args?.limit,\n offset: args?.offset,\n buyer: role === \"buyer\" ? address : undefined,\n seller: role === \"seller\" ? address : undefined,\n agent: role === \"agent\" ? address : undefined,\n user: role === \"all\" ? address : undefined,\n state: args?.state,\n states,\n });\n },\n enabled: !!address && enabled,\n });\n}\n\n// Re-export for convenience\nexport { STATE_GROUPS } from \"../../domains/escrows\";\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgent } from \"../../generated/types\";\n\nexport interface UseAgentOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single agent by address.\n *\n * @example\n * ```tsx\n * import { useAgent } from '@zenland/sdk/react';\n *\n * function AgentProfile({ address }: { address: string }) {\n * const { data: agent, isLoading, error } = useAgent(address);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!agent) return <div>Agent not found</div>;\n *\n * return <div>{agent.description}</div>;\n * }\n * ```\n */\nexport function useAgent(address: string | undefined, options?: UseAgentOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlAgent | null>({\n queryKey: [\"zenland\", \"agent\", address],\n queryFn: () => {\n if (!address) return null;\n return client.agents.getById(address);\n },\n enabled: !!address && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgentPage } from \"../../generated/types\";\n\nexport interface UseAgentsArgs {\n /** Only return active agents */\n onlyActive?: boolean;\n /** Only return available agents */\n onlyAvailable?: boolean;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch agents with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useAgents } from '@zenland/sdk/react';\n *\n * function AgentList() {\n * const { data, isLoading } = useAgents({ onlyActive: true });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(agent => (\n * <li key={agent.id}>{agent.description}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useAgents(args?: UseAgentsArgs) {\n const client = useZenlandClientOptional();\n const { enabled = true, ...filterArgs } = args ?? {};\n\n return useQuery<GqlAgentPage>({\n queryKey: [\"zenland\", \"agents\", filterArgs.onlyActive, filterArgs.onlyAvailable, filterArgs.limit, filterArgs.offset],\n queryFn: () => client.agents.list(filterArgs),\n enabled,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { ProtocolStats } from \"../../domains/protocol-stats\";\n\nexport interface UseProtocolStatsOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 60s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch global protocol statistics.\n *\n * @example\n * ```tsx\n * import { useProtocolStats } from '@zenland/sdk/react';\n *\n * function ProtocolOverview() {\n * const { data: stats, isLoading } = useProtocolStats();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!stats) return <div>Stats not available</div>;\n *\n * return (\n * <div>\n * <p>Total Escrows: {stats.totalEscrowsCreated}</p>\n * <p>TVL: {stats.currentTVL.toString()}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProtocolStats(options?: UseProtocolStatsOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<ProtocolStats | null>({\n queryKey: [\"zenland\", \"protocolStats\"],\n queryFn: () => client.protocolStats.get(),\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 30 * 1000, // 30 seconds\n refetchInterval: options?.refetchInterval ?? 60 * 1000, // 1 minute\n });\n}\n\nexport type { ProtocolStats };\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseRecentEscrowsOptions {\n /** Number of escrows to fetch (default: 5) */\n limit?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 15s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 30s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch recent escrows for activity feeds.\n *\n * @example\n * ```tsx\n * import { useRecentEscrows } from '@zenland/sdk/react';\n *\n * function ActivityFeed() {\n * const { data: escrows, isLoading } = useRecentEscrows({ limit: 10 });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {escrows?.map(escrow => (\n * <li key={escrow.id}>\n * {escrow.state} - {escrow.amount}\n * </li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useRecentEscrows(options?: UseRecentEscrowsOptions) {\n const client = useZenlandClientOptional();\n const limit = options?.limit ?? 5;\n\n return useQuery<GqlEscrow[]>({\n queryKey: [\"zenland\", \"recentEscrows\", limit],\n queryFn: async () => {\n const result = await client.escrows.list({\n limit,\n orderBy: \"createdAt\",\n orderDirection: \"desc\",\n });\n return result.items;\n },\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 15 * 1000, // 15 seconds\n refetchInterval: options?.refetchInterval ?? 30 * 1000, // 30 seconds\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS } from \"../../domains/escrows\";\nimport type { GqlEscrow, ZenlandClient } from \"../../index\";\n\n/** State groups for categorization */\nconst ACTIVE_STATES = STATE_GROUPS.ACTIVE;\nconst DISPUTE_STATES = STATE_GROUPS.IN_DISPUTE;\nconst COMPLETED_STATES = STATE_GROUPS.COMPLETED;\nconst TVL_STATES = [...ACTIVE_STATES, ...DISPUTE_STATES] as const;\n\nexport interface UserDashboardStats {\n activeCount: number;\n disputeCount: number;\n completedCount: number;\n tvl: bigint;\n recentEscrows: GqlEscrow[];\n}\n\n/**\n * Fetch count of escrows for a user filtered by states.\n */\nasync function fetchUserEscrowCount(\n client: ZenlandClient,\n userAddress: string,\n states: readonly string[],\n): Promise<number> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1,\n user: userLower,\n states: [...states],\n });\n\n return result.totalCount;\n}\n\n/**\n * Fetch user's escrows that contribute to TVL and calculate sum.\n */\nasync function fetchUserTVL(client: ZenlandClient, userAddress: string): Promise<bigint> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1000,\n user: userLower,\n states: [...TVL_STATES],\n });\n\n return result.items.reduce((sum, escrow) => sum + BigInt(escrow.amount), BigInt(0));\n}\n\n/**\n * Fetch user's recent escrows for dashboard display.\n */\nasync function fetchUserRecentEscrows(\n client: ZenlandClient,\n userAddress: string,\n limit: number = 5,\n): Promise<GqlEscrow[]> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit,\n user: userLower,\n });\n\n return result.items;\n}\n\n/**\n * Fetch all user dashboard stats in parallel.\n */\nasync function getUserDashboardStats(\n client: ZenlandClient,\n userAddress: string,\n): Promise<UserDashboardStats> {\n const [activeCount, disputeCount, completedCount, tvl, recentEscrows] = await Promise.all([\n fetchUserEscrowCount(client, userAddress, ACTIVE_STATES),\n fetchUserEscrowCount(client, userAddress, DISPUTE_STATES),\n fetchUserEscrowCount(client, userAddress, COMPLETED_STATES),\n fetchUserTVL(client, userAddress),\n fetchUserRecentEscrows(client, userAddress, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl,\n recentEscrows,\n };\n}\n\n/**\n * Fetch global dashboard stats.\n */\nasync function getGlobalDashboardStats(\n client: ZenlandClient,\n): Promise<Omit<UserDashboardStats, \"tvl\"> & { tvl: null }> {\n const [activeCount, disputeCount, completedCount, recentEscrows] = await Promise.all([\n fetchGlobalEscrowCount(client, [...ACTIVE_STATES]),\n fetchGlobalEscrowCount(client, [...DISPUTE_STATES]),\n fetchGlobalEscrowCount(client, [...COMPLETED_STATES]),\n fetchGlobalRecentEscrows(client, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl: null,\n recentEscrows,\n };\n}\n\nasync function fetchGlobalEscrowCount(client: ZenlandClient, states: string[]): Promise<number> {\n const result = await client.escrows.list({\n limit: 1,\n states,\n });\n return result.totalCount;\n}\n\nasync function fetchGlobalRecentEscrows(client: ZenlandClient, limit: number = 5): Promise<GqlEscrow[]> {\n const result = await client.escrows.list({ limit });\n return result.items;\n}\n\n/**\n * Hook to fetch user-specific dashboard statistics.\n */\nexport function useUserStats(userAddress: string | undefined) {\n const client = useZenlandClientOptional();\n return useQuery<UserDashboardStats | null>({\n queryKey: [\"zenland\", \"userStats\", userAddress],\n queryFn: async () => {\n if (!userAddress) return null;\n return getUserDashboardStats(client, userAddress);\n },\n enabled: !!userAddress,\n staleTime: 15 * 1000,\n refetchInterval: 30 * 1000,\n });\n}\n\n/**\n * Hook to fetch global dashboard statistics.\n */\nexport function useGlobalStats() {\n const client = useZenlandClientOptional();\n return useQuery({\n queryKey: [\"zenland\", \"globalStats\"],\n queryFn: () => getGlobalDashboardStats(client),\n staleTime: 30 * 1000,\n refetchInterval: 60 * 1000,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlTransactionLog } from \"../../generated/types\";\nimport type { ListTransactionLogsArgs } from \"../../domains/transaction-logs\";\n\nexport interface UseTransactionLogsByEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds */\n refetchInterval?: number;\n /** Transaction log list options */\n list?: Omit<ListTransactionLogsArgs, \"escrowAddress\">;\n}\n\n/**\n * Hook to fetch transaction logs for a specific escrow.\n */\nexport function useTransactionLogsByEscrow(\n escrowAddress: string | undefined | null,\n options?: UseTransactionLogsByEscrowOptions,\n) {\n const client = useZenlandClientOptional();\n const addr = escrowAddress?.toLowerCase();\n\n return useQuery<GqlTransactionLog[]>({\n queryKey: [\n \"zenland\",\n \"transactionLogs\",\n \"escrow\",\n addr,\n options?.list?.limit,\n options?.list?.offset,\n options?.list?.orderBy,\n options?.list?.orderDirection,\n ],\n queryFn: async () => {\n if (!addr) return [];\n return client.transactionLogs.getByEscrow(addr, options?.list);\n },\n enabled: !!addr && (options?.enabled ?? true),\n staleTime: options?.staleTime ?? 30_000,\n refetchInterval: options?.refetchInterval,\n refetchOnWindowFocus: false,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA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xB,CAAC;AACH;;;AC9JA,IAAAC,sBAAyB;AAmBlB,SAAS,2BACd,eACA,SACA;AACA,QAAM,SAAS,yBAAyB;AACxC,QAAM,OAAO,eAAe,YAAY;AAExC,aAAO,8BAA8B;AAAA,IACnC,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,SAAS,YAAY;AACnB,UAAI,CAAC,KAAM,QAAO,CAAC;AACnB,aAAO,OAAO,gBAAgB,YAAY,MAAM,SAAS,IAAI;AAAA,IAC/D;AAAA,IACA,SAAS,CAAC,CAAC,SAAS,SAAS,WAAW;AAAA,IACxC,WAAW,SAAS,aAAa;AAAA,IACjC,iBAAiB,SAAS;AAAA,IAC1B,sBAAsB;AAAA,EACxB,CAAC;AACH;","names":["import_react_query","import_react_query","import_react_query","import_react_query","import_react_query","import_react_query","import_react_query"]}
|
|
1
|
+
{"version":3,"sources":["../src/react.ts","../src/react/context.tsx","../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/react/hooks/useEscrow.ts","../src/react/hooks/useEscrows.ts","../src/react/hooks/useAgent.ts","../src/react/hooks/useAgents.ts","../src/react/hooks/useProtocolStats.ts","../src/react/hooks/useRecentEscrows.ts","../src/react/hooks/useUserStats.ts","../src/react/hooks/useTransactionLogsByEscrow.ts"],"sourcesContent":["/**\n * @zenland/sdk/react\n *\n * React hooks and components for the Zenland SDK.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider, useEscrows, useAgent } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <MyComponent />\n * </ZenlandProvider>\n * );\n * }\n *\n * function MyComponent() {\n * const { data: escrows } = useEscrows({ address: '0x...' });\n * const { data: agent } = useAgent('0x...');\n * // ...\n * }\n * ```\n */\n\n// Context and provider\nexport { ZenlandProvider, useZenlandClient, useZenlandClientOptional } from \"./react/context\";\nexport type { ZenlandProviderProps } from \"./react/context\";\n\n// Hooks\nexport {\n useEscrow,\n useEscrows,\n useAgent,\n useAgents,\n useProtocolStats,\n useUserStats,\n useGlobalStats,\n useTransactionLogsByEscrow,\n useRecentEscrows,\n STATE_GROUPS,\n} from \"./react/hooks\";\nexport type {\n UseEscrowOptions,\n UseEscrowsArgs,\n EscrowRole,\n EscrowStateTab,\n UseAgentOptions,\n UseAgentsArgs,\n UseProtocolStatsOptions,\n UseRecentEscrowsOptions,\n UserDashboardStats,\n UseTransactionLogsByEscrowOptions,\n ProtocolStats,\n} from \"./react/hooks\";\n\n// Re-export types from core for convenience\nexport type {\n GqlAgent,\n GqlAgentPage,\n GqlEscrow,\n GqlEscrowPage,\n GqlProtocolStats,\n GqlTransactionLog,\n GqlPageInfo,\n} from \"./generated/types\";\n\n// Re-export client for advanced usage\nexport { createZenlandClient } from \"./client\";\nexport type { ZenlandClient, ZenlandClientConfig } from \"./client\";\n","\"use client\";\n\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport { createZenlandClient, type ZenlandClient, type ZenlandClientConfig } from \"../client\";\n\nconst ZenlandContext = createContext<ZenlandClient | null>(null);\n\nexport interface ZenlandProviderProps {\n children: ReactNode;\n /** Optional configuration for the SDK client */\n config?: ZenlandClientConfig;\n}\n\n/**\n * Provider component for the Zenland SDK.\n *\n * Wrap your app with this provider to use the React hooks.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <YourApp />\n * </ZenlandProvider>\n * );\n * }\n *\n * // With custom config\n * <ZenlandProvider config={{ baseUrl: 'http://localhost:42069' }}>\n * <YourApp />\n * </ZenlandProvider>\n * ```\n */\nexport function ZenlandProvider({ children, config }: ZenlandProviderProps) {\n const client = useMemo(() => createZenlandClient(config), [config]);\n\n return <ZenlandContext.Provider value={client}>{children}</ZenlandContext.Provider>;\n}\n\n/**\n * Hook to access the Zenland SDK client.\n *\n * Must be used within a ZenlandProvider.\n *\n * @example\n * ```tsx\n * import { useZenlandClient } from '@zenland/sdk/react';\n *\n * function MyComponent() {\n * const client = useZenlandClient();\n * // Use client.escrows, client.agents, etc.\n * }\n * ```\n */\nexport function useZenlandClient(): ZenlandClient {\n const context = useContext(ZenlandContext);\n if (!context) {\n throw new Error(\"useZenlandClient must be used within a ZenlandProvider\");\n }\n return context;\n}\n\n/**\n * Hook to access the Zenland SDK client, creating a default one if not in a provider.\n *\n * This is useful for components that might be used outside of a ZenlandProvider.\n */\nexport function useZenlandClientOptional(): ZenlandClient {\n const context = useContext(ZenlandContext);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => context ?? createZenlandClient(), [context]);\n}\n","/**\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! = \"mainnet\") {\n protocolStats(id: $id) {\n id\n chainId\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 * Stats are tracked per-chain. By default, mainnet stats are returned\n * for production UI. Use chainId parameter to query other networks.\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { PROTOCOL_STATS_QUERY } from \"../queries\";\nimport type { GqlProtocolStats, ProtocolStatsQueryResponse } from \"../generated/types\";\n\n/** Default stats ID for production (Ethereum mainnet) */\nconst DEFAULT_STATS_ID = \"mainnet\";\n\n/** Normalized protocol stats with BigInt values */\nexport interface ProtocolStats {\n id: string;\n chainId?: number;\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 chainId: (raw as any).chainId,\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\nexport interface GetProtocolStatsOptions {\n /** \n * Stats ID to query. Defaults to \"mainnet\".\n * Use \"sepolia\" for testnet stats.\n */\n statsId?: string;\n}\n\n/**\n * Creates protocol stats domain functions bound to a base URL\n */\nexport function createProtocolStatsDomain(baseUrl: string) {\n /**\n * Fetch protocol statistics for a specific chain.\n * Defaults to mainnet for production use.\n * \n * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function get(options?: GetProtocolStatsOptions): Promise<ProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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 * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function getRaw(options?: GetProtocolStatsOptions): Promise<GqlProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single escrow by ID.\n *\n * @example\n * ```tsx\n * import { useEscrow } from '@zenland/sdk/react';\n *\n * function EscrowDetail({ id }: { id: string }) {\n * const { data: escrow, isLoading, error } = useEscrow(id);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!escrow) return <div>Escrow not found</div>;\n *\n * return <div>{escrow.state}</div>;\n * }\n * ```\n */\nexport function useEscrow(id: string | undefined, options?: UseEscrowOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlEscrow | null>({\n queryKey: [\"zenland\", \"escrow\", id],\n queryFn: () => {\n if (!id) return null;\n return client.escrows.getById(id);\n },\n enabled: !!id && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS, type StateGroup } from \"../../domains/escrows\";\nimport type { GqlEscrowPage } from \"../../generated/types\";\n\nexport type EscrowRole = \"all\" | \"buyer\" | \"seller\" | \"agent\";\nexport type EscrowStateTab = \"all\" | StateGroup;\n\nexport interface UseEscrowsArgs {\n /** User address to filter by */\n address?: string;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Filter by role (requires address) */\n role?: EscrowRole;\n /** Filter by state group */\n stateTab?: EscrowStateTab;\n /** Filter by specific state */\n state?: string;\n /** Filter by multiple states */\n states?: string[];\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch escrows with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useEscrows } from '@zenland/sdk/react';\n *\n * function MyEscrows({ address }: { address: string }) {\n * const { data, isLoading } = useEscrows({\n * address,\n * role: 'buyer',\n * stateTab: 'ACTIVE',\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(escrow => (\n * <li key={escrow.id}>{escrow.state}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useEscrows(args?: UseEscrowsArgs) {\n const client = useZenlandClientOptional();\n const { address, role = \"all\", stateTab, enabled = true } = args ?? {};\n\n // Determine states to filter based on stateTab\n const getStatesFromTab = (): string[] | undefined => {\n if (!stateTab || stateTab === \"all\") {\n return args?.states;\n }\n return [...STATE_GROUPS[stateTab]];\n };\n\n return useQuery<GqlEscrowPage>({\n queryKey: [\"zenland\", \"escrows\", address, role, stateTab, args?.state, args?.states, args?.limit, args?.offset],\n queryFn: async () => {\n if (!address) {\n return { items: [], totalCount: 0, pageInfo: { hasNextPage: false, hasPreviousPage: false } };\n }\n\n const states = getStatesFromTab();\n\n return client.escrows.list({\n limit: args?.limit,\n offset: args?.offset,\n buyer: role === \"buyer\" ? address : undefined,\n seller: role === \"seller\" ? address : undefined,\n agent: role === \"agent\" ? address : undefined,\n user: role === \"all\" ? address : undefined,\n state: args?.state,\n states,\n });\n },\n enabled: !!address && enabled,\n });\n}\n\n// Re-export for convenience\nexport { STATE_GROUPS } from \"../../domains/escrows\";\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgent } from \"../../generated/types\";\n\nexport interface UseAgentOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single agent by address.\n *\n * @example\n * ```tsx\n * import { useAgent } from '@zenland/sdk/react';\n *\n * function AgentProfile({ address }: { address: string }) {\n * const { data: agent, isLoading, error } = useAgent(address);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!agent) return <div>Agent not found</div>;\n *\n * return <div>{agent.description}</div>;\n * }\n * ```\n */\nexport function useAgent(address: string | undefined, options?: UseAgentOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlAgent | null>({\n queryKey: [\"zenland\", \"agent\", address],\n queryFn: () => {\n if (!address) return null;\n return client.agents.getById(address);\n },\n enabled: !!address && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgentPage } from \"../../generated/types\";\n\nexport interface UseAgentsArgs {\n /** Only return active agents */\n onlyActive?: boolean;\n /** Only return available agents */\n onlyAvailable?: boolean;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch agents with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useAgents } from '@zenland/sdk/react';\n *\n * function AgentList() {\n * const { data, isLoading } = useAgents({ onlyActive: true });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(agent => (\n * <li key={agent.id}>{agent.description}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useAgents(args?: UseAgentsArgs) {\n const client = useZenlandClientOptional();\n const { enabled = true, ...filterArgs } = args ?? {};\n\n return useQuery<GqlAgentPage>({\n queryKey: [\"zenland\", \"agents\", filterArgs.onlyActive, filterArgs.onlyAvailable, filterArgs.limit, filterArgs.offset],\n queryFn: () => client.agents.list(filterArgs),\n enabled,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { ProtocolStats } from \"../../domains/protocol-stats\";\n\nexport interface UseProtocolStatsOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 60s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch global protocol statistics.\n *\n * @example\n * ```tsx\n * import { useProtocolStats } from '@zenland/sdk/react';\n *\n * function ProtocolOverview() {\n * const { data: stats, isLoading } = useProtocolStats();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!stats) return <div>Stats not available</div>;\n *\n * return (\n * <div>\n * <p>Total Escrows: {stats.totalEscrowsCreated}</p>\n * <p>TVL: {stats.currentTVL.toString()}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProtocolStats(options?: UseProtocolStatsOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<ProtocolStats | null>({\n queryKey: [\"zenland\", \"protocolStats\"],\n queryFn: () => client.protocolStats.get(),\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 30 * 1000, // 30 seconds\n refetchInterval: options?.refetchInterval ?? 60 * 1000, // 1 minute\n });\n}\n\nexport type { ProtocolStats };\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseRecentEscrowsOptions {\n /** Number of escrows to fetch (default: 5) */\n limit?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 15s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 30s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch recent escrows for activity feeds.\n *\n * @example\n * ```tsx\n * import { useRecentEscrows } from '@zenland/sdk/react';\n *\n * function ActivityFeed() {\n * const { data: escrows, isLoading } = useRecentEscrows({ limit: 10 });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {escrows?.map(escrow => (\n * <li key={escrow.id}>\n * {escrow.state} - {escrow.amount}\n * </li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useRecentEscrows(options?: UseRecentEscrowsOptions) {\n const client = useZenlandClientOptional();\n const limit = options?.limit ?? 5;\n\n return useQuery<GqlEscrow[]>({\n queryKey: [\"zenland\", \"recentEscrows\", limit],\n queryFn: async () => {\n const result = await client.escrows.list({\n limit,\n orderBy: \"createdAt\",\n orderDirection: \"desc\",\n });\n return result.items;\n },\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 15 * 1000, // 15 seconds\n refetchInterval: options?.refetchInterval ?? 30 * 1000, // 30 seconds\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS } from \"../../domains/escrows\";\nimport type { GqlEscrow, ZenlandClient } from \"../../index\";\n\n/** State groups for categorization */\nconst ACTIVE_STATES = STATE_GROUPS.ACTIVE;\nconst DISPUTE_STATES = STATE_GROUPS.IN_DISPUTE;\nconst COMPLETED_STATES = STATE_GROUPS.COMPLETED;\nconst TVL_STATES = [...ACTIVE_STATES, ...DISPUTE_STATES] as const;\n\nexport interface UserDashboardStats {\n activeCount: number;\n disputeCount: number;\n completedCount: number;\n tvl: bigint;\n recentEscrows: GqlEscrow[];\n}\n\n/**\n * Fetch count of escrows for a user filtered by states.\n */\nasync function fetchUserEscrowCount(\n client: ZenlandClient,\n userAddress: string,\n states: readonly string[],\n): Promise<number> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1,\n user: userLower,\n states: [...states],\n });\n\n return result.totalCount;\n}\n\n/**\n * Fetch user's escrows that contribute to TVL and calculate sum.\n */\nasync function fetchUserTVL(client: ZenlandClient, userAddress: string): Promise<bigint> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1000,\n user: userLower,\n states: [...TVL_STATES],\n });\n\n return result.items.reduce((sum, escrow) => sum + BigInt(escrow.amount), BigInt(0));\n}\n\n/**\n * Fetch user's recent escrows for dashboard display.\n */\nasync function fetchUserRecentEscrows(\n client: ZenlandClient,\n userAddress: string,\n limit: number = 5,\n): Promise<GqlEscrow[]> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit,\n user: userLower,\n });\n\n return result.items;\n}\n\n/**\n * Fetch all user dashboard stats in parallel.\n */\nasync function getUserDashboardStats(\n client: ZenlandClient,\n userAddress: string,\n): Promise<UserDashboardStats> {\n const [activeCount, disputeCount, completedCount, tvl, recentEscrows] = await Promise.all([\n fetchUserEscrowCount(client, userAddress, ACTIVE_STATES),\n fetchUserEscrowCount(client, userAddress, DISPUTE_STATES),\n fetchUserEscrowCount(client, userAddress, COMPLETED_STATES),\n fetchUserTVL(client, userAddress),\n fetchUserRecentEscrows(client, userAddress, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl,\n recentEscrows,\n };\n}\n\n/**\n * Fetch global dashboard stats.\n */\nasync function getGlobalDashboardStats(\n client: ZenlandClient,\n): Promise<Omit<UserDashboardStats, \"tvl\"> & { tvl: null }> {\n const [activeCount, disputeCount, completedCount, recentEscrows] = await Promise.all([\n fetchGlobalEscrowCount(client, [...ACTIVE_STATES]),\n fetchGlobalEscrowCount(client, [...DISPUTE_STATES]),\n fetchGlobalEscrowCount(client, [...COMPLETED_STATES]),\n fetchGlobalRecentEscrows(client, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl: null,\n recentEscrows,\n };\n}\n\nasync function fetchGlobalEscrowCount(client: ZenlandClient, states: string[]): Promise<number> {\n const result = await client.escrows.list({\n limit: 1,\n states,\n });\n return result.totalCount;\n}\n\nasync function fetchGlobalRecentEscrows(client: ZenlandClient, limit: number = 5): Promise<GqlEscrow[]> {\n const result = await client.escrows.list({ limit });\n return result.items;\n}\n\n/**\n * Hook to fetch user-specific dashboard statistics.\n */\nexport function useUserStats(userAddress: string | undefined) {\n const client = useZenlandClientOptional();\n return useQuery<UserDashboardStats | null>({\n queryKey: [\"zenland\", \"userStats\", userAddress],\n queryFn: async () => {\n if (!userAddress) return null;\n return getUserDashboardStats(client, userAddress);\n },\n enabled: !!userAddress,\n staleTime: 15 * 1000,\n refetchInterval: 30 * 1000,\n });\n}\n\n/**\n * Hook to fetch global dashboard statistics.\n */\nexport function useGlobalStats() {\n const client = useZenlandClientOptional();\n return useQuery({\n queryKey: [\"zenland\", \"globalStats\"],\n queryFn: () => getGlobalDashboardStats(client),\n staleTime: 30 * 1000,\n refetchInterval: 60 * 1000,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlTransactionLog } from \"../../generated/types\";\nimport type { ListTransactionLogsArgs } from \"../../domains/transaction-logs\";\n\nexport interface UseTransactionLogsByEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds */\n refetchInterval?: number;\n /** Transaction log list options */\n list?: Omit<ListTransactionLogsArgs, \"escrowAddress\">;\n}\n\n/**\n * Hook to fetch transaction logs for a specific escrow.\n */\nexport function useTransactionLogsByEscrow(\n escrowAddress: string | undefined | null,\n options?: UseTransactionLogsByEscrowOptions,\n) {\n const client = useZenlandClientOptional();\n const addr = escrowAddress?.toLowerCase();\n\n return useQuery<GqlTransactionLog[]>({\n queryKey: [\n \"zenland\",\n \"transactionLogs\",\n \"escrow\",\n addr,\n options?.list?.limit,\n options?.list?.offset,\n options?.list?.orderBy,\n options?.list?.orderDirection,\n ],\n queryFn: async () => {\n if (!addr) return [];\n return client.transactionLogs.getByEscrow(addr, options?.list);\n },\n enabled: !!addr && (options?.enabled ?? true),\n staleTime: options?.staleTime ?? 30_000,\n refetchInterval: options?.refetchInterval,\n refetchOnWindowFocus: false,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAmE;;;ACe5D,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,e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B,aAAO,OAAO,gBAAgB,YAAY,MAAM,SAAS,IAAI;AAAA,IAC/D;AAAA,IACA,SAAS,CAAC,CAAC,SAAS,SAAS,WAAW;AAAA,IACxC,WAAW,SAAS,aAAa;AAAA,IACjC,iBAAiB,SAAS;AAAA,IAC1B,sBAAsB;AAAA,EACxB,CAAC;AACH;","names":["import_react_query","import_react_query","import_react_query","import_react_query","import_react_query","import_react_query","import_react_query"]}
|
package/dist/react.d.cts
CHANGED
|
@@ -93,6 +93,8 @@ interface GqlEscrowPage {
|
|
|
93
93
|
}
|
|
94
94
|
interface GqlProtocolStats {
|
|
95
95
|
id: string;
|
|
96
|
+
/** Chain ID (1 for mainnet, 11155111 for sepolia) */
|
|
97
|
+
chainId: number;
|
|
96
98
|
totalEscrowsCreated: number;
|
|
97
99
|
totalVolumeEscrowed: BigIntScalar;
|
|
98
100
|
totalFeesCollected: BigIntScalar;
|
|
@@ -175,11 +177,15 @@ type AgentsDomain = ReturnType<typeof createAgentsDomain>;
|
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* Protocol Stats domain module for the Zenland SDK
|
|
180
|
+
*
|
|
181
|
+
* Stats are tracked per-chain. By default, mainnet stats are returned
|
|
182
|
+
* for production UI. Use chainId parameter to query other networks.
|
|
178
183
|
*/
|
|
179
184
|
|
|
180
185
|
/** Normalized protocol stats with BigInt values */
|
|
181
186
|
interface ProtocolStats {
|
|
182
187
|
id: string;
|
|
188
|
+
chainId?: number;
|
|
183
189
|
totalEscrowsCreated: number;
|
|
184
190
|
totalVolumeEscrowed: bigint;
|
|
185
191
|
totalFeesCollected: bigint;
|
|
@@ -188,12 +194,19 @@ interface ProtocolStats {
|
|
|
188
194
|
totalAgentsRegistered: number;
|
|
189
195
|
activeAgentsCount: number;
|
|
190
196
|
}
|
|
197
|
+
interface GetProtocolStatsOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Stats ID to query. Defaults to "mainnet".
|
|
200
|
+
* Use "sepolia" for testnet stats.
|
|
201
|
+
*/
|
|
202
|
+
statsId?: string;
|
|
203
|
+
}
|
|
191
204
|
/**
|
|
192
205
|
* Creates protocol stats domain functions bound to a base URL
|
|
193
206
|
*/
|
|
194
207
|
declare function createProtocolStatsDomain(baseUrl: string): {
|
|
195
|
-
get: () => Promise<ProtocolStats | null>;
|
|
196
|
-
getRaw: () => Promise<GqlProtocolStats | null>;
|
|
208
|
+
get: (options?: GetProtocolStatsOptions) => Promise<ProtocolStats | null>;
|
|
209
|
+
getRaw: (options?: GetProtocolStatsOptions) => Promise<GqlProtocolStats | null>;
|
|
197
210
|
};
|
|
198
211
|
type ProtocolStatsDomain = ReturnType<typeof createProtocolStatsDomain>;
|
|
199
212
|
|
package/dist/react.d.ts
CHANGED
|
@@ -93,6 +93,8 @@ interface GqlEscrowPage {
|
|
|
93
93
|
}
|
|
94
94
|
interface GqlProtocolStats {
|
|
95
95
|
id: string;
|
|
96
|
+
/** Chain ID (1 for mainnet, 11155111 for sepolia) */
|
|
97
|
+
chainId: number;
|
|
96
98
|
totalEscrowsCreated: number;
|
|
97
99
|
totalVolumeEscrowed: BigIntScalar;
|
|
98
100
|
totalFeesCollected: BigIntScalar;
|
|
@@ -175,11 +177,15 @@ type AgentsDomain = ReturnType<typeof createAgentsDomain>;
|
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* Protocol Stats domain module for the Zenland SDK
|
|
180
|
+
*
|
|
181
|
+
* Stats are tracked per-chain. By default, mainnet stats are returned
|
|
182
|
+
* for production UI. Use chainId parameter to query other networks.
|
|
178
183
|
*/
|
|
179
184
|
|
|
180
185
|
/** Normalized protocol stats with BigInt values */
|
|
181
186
|
interface ProtocolStats {
|
|
182
187
|
id: string;
|
|
188
|
+
chainId?: number;
|
|
183
189
|
totalEscrowsCreated: number;
|
|
184
190
|
totalVolumeEscrowed: bigint;
|
|
185
191
|
totalFeesCollected: bigint;
|
|
@@ -188,12 +194,19 @@ interface ProtocolStats {
|
|
|
188
194
|
totalAgentsRegistered: number;
|
|
189
195
|
activeAgentsCount: number;
|
|
190
196
|
}
|
|
197
|
+
interface GetProtocolStatsOptions {
|
|
198
|
+
/**
|
|
199
|
+
* Stats ID to query. Defaults to "mainnet".
|
|
200
|
+
* Use "sepolia" for testnet stats.
|
|
201
|
+
*/
|
|
202
|
+
statsId?: string;
|
|
203
|
+
}
|
|
191
204
|
/**
|
|
192
205
|
* Creates protocol stats domain functions bound to a base URL
|
|
193
206
|
*/
|
|
194
207
|
declare function createProtocolStatsDomain(baseUrl: string): {
|
|
195
|
-
get: () => Promise<ProtocolStats | null>;
|
|
196
|
-
getRaw: () => Promise<GqlProtocolStats | null>;
|
|
208
|
+
get: (options?: GetProtocolStatsOptions) => Promise<ProtocolStats | null>;
|
|
209
|
+
getRaw: (options?: GetProtocolStatsOptions) => Promise<GqlProtocolStats | null>;
|
|
197
210
|
};
|
|
198
211
|
type ProtocolStatsDomain = ReturnType<typeof createProtocolStatsDomain>;
|
|
199
212
|
|
package/dist/react.js
CHANGED
|
@@ -198,9 +198,10 @@ query escrows(
|
|
|
198
198
|
}
|
|
199
199
|
`;
|
|
200
200
|
var PROTOCOL_STATS_QUERY = `
|
|
201
|
-
query protocolStats($id: String! = "
|
|
201
|
+
query protocolStats($id: String! = "mainnet") {
|
|
202
202
|
protocolStats(id: $id) {
|
|
203
203
|
id
|
|
204
|
+
chainId
|
|
204
205
|
totalEscrowsCreated
|
|
205
206
|
totalVolumeEscrowed
|
|
206
207
|
totalFeesCollected
|
|
@@ -341,9 +342,11 @@ function createAgentsDomain(baseUrl) {
|
|
|
341
342
|
}
|
|
342
343
|
|
|
343
344
|
// src/domains/protocol-stats.ts
|
|
345
|
+
var DEFAULT_STATS_ID = "mainnet";
|
|
344
346
|
function normalizeProtocolStats(raw) {
|
|
345
347
|
return {
|
|
346
348
|
id: raw.id,
|
|
349
|
+
chainId: raw.chainId,
|
|
347
350
|
totalEscrowsCreated: raw.totalEscrowsCreated,
|
|
348
351
|
totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
|
|
349
352
|
totalFeesCollected: BigInt(raw.totalFeesCollected),
|
|
@@ -354,8 +357,8 @@ function normalizeProtocolStats(raw) {
|
|
|
354
357
|
};
|
|
355
358
|
}
|
|
356
359
|
function createProtocolStatsDomain(baseUrl) {
|
|
357
|
-
async function get() {
|
|
358
|
-
const variables = { id:
|
|
360
|
+
async function get(options) {
|
|
361
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
359
362
|
const response = await graphqlRequest(
|
|
360
363
|
baseUrl,
|
|
361
364
|
PROTOCOL_STATS_QUERY,
|
|
@@ -366,8 +369,8 @@ function createProtocolStatsDomain(baseUrl) {
|
|
|
366
369
|
}
|
|
367
370
|
return normalizeProtocolStats(response.protocolStats);
|
|
368
371
|
}
|
|
369
|
-
async function getRaw() {
|
|
370
|
-
const variables = { id:
|
|
372
|
+
async function getRaw(options) {
|
|
373
|
+
const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
|
|
371
374
|
const response = await graphqlRequest(
|
|
372
375
|
baseUrl,
|
|
373
376
|
PROTOCOL_STATS_QUERY,
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/context.tsx","../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/react/hooks/useEscrow.ts","../src/react/hooks/useEscrows.ts","../src/react/hooks/useAgent.ts","../src/react/hooks/useAgents.ts","../src/react/hooks/useProtocolStats.ts","../src/react/hooks/useRecentEscrows.ts","../src/react/hooks/useUserStats.ts","../src/react/hooks/useTransactionLogsByEscrow.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport { createZenlandClient, type ZenlandClient, type ZenlandClientConfig } from \"../client\";\n\nconst ZenlandContext = createContext<ZenlandClient | null>(null);\n\nexport interface ZenlandProviderProps {\n children: ReactNode;\n /** Optional configuration for the SDK client */\n config?: ZenlandClientConfig;\n}\n\n/**\n * Provider component for the Zenland SDK.\n *\n * Wrap your app with this provider to use the React hooks.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <YourApp />\n * </ZenlandProvider>\n * );\n * }\n *\n * // With custom config\n * <ZenlandProvider config={{ baseUrl: 'http://localhost:42069' }}>\n * <YourApp />\n * </ZenlandProvider>\n * ```\n */\nexport function ZenlandProvider({ children, config }: ZenlandProviderProps) {\n const client = useMemo(() => createZenlandClient(config), [config]);\n\n return <ZenlandContext.Provider value={client}>{children}</ZenlandContext.Provider>;\n}\n\n/**\n * Hook to access the Zenland SDK client.\n *\n * Must be used within a ZenlandProvider.\n *\n * @example\n * ```tsx\n * import { useZenlandClient } from '@zenland/sdk/react';\n *\n * function MyComponent() {\n * const client = useZenlandClient();\n * // Use client.escrows, client.agents, etc.\n * }\n * ```\n */\nexport function useZenlandClient(): ZenlandClient {\n const context = useContext(ZenlandContext);\n if (!context) {\n throw new Error(\"useZenlandClient must be used within a ZenlandProvider\");\n }\n return context;\n}\n\n/**\n * Hook to access the Zenland SDK client, creating a default one if not in a provider.\n *\n * This is useful for components that might be used outside of a ZenlandProvider.\n */\nexport function useZenlandClientOptional(): ZenlandClient {\n const context = useContext(ZenlandContext);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => context ?? createZenlandClient(), [context]);\n}\n","/**\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","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single escrow by ID.\n *\n * @example\n * ```tsx\n * import { useEscrow } from '@zenland/sdk/react';\n *\n * function EscrowDetail({ id }: { id: string }) {\n * const { data: escrow, isLoading, error } = useEscrow(id);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!escrow) return <div>Escrow not found</div>;\n *\n * return <div>{escrow.state}</div>;\n * }\n * ```\n */\nexport function useEscrow(id: string | undefined, options?: UseEscrowOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlEscrow | null>({\n queryKey: [\"zenland\", \"escrow\", id],\n queryFn: () => {\n if (!id) return null;\n return client.escrows.getById(id);\n },\n enabled: !!id && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS, type StateGroup } from \"../../domains/escrows\";\nimport type { GqlEscrowPage } from \"../../generated/types\";\n\nexport type EscrowRole = \"all\" | \"buyer\" | \"seller\" | \"agent\";\nexport type EscrowStateTab = \"all\" | StateGroup;\n\nexport interface UseEscrowsArgs {\n /** User address to filter by */\n address?: string;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Filter by role (requires address) */\n role?: EscrowRole;\n /** Filter by state group */\n stateTab?: EscrowStateTab;\n /** Filter by specific state */\n state?: string;\n /** Filter by multiple states */\n states?: string[];\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch escrows with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useEscrows } from '@zenland/sdk/react';\n *\n * function MyEscrows({ address }: { address: string }) {\n * const { data, isLoading } = useEscrows({\n * address,\n * role: 'buyer',\n * stateTab: 'ACTIVE',\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(escrow => (\n * <li key={escrow.id}>{escrow.state}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useEscrows(args?: UseEscrowsArgs) {\n const client = useZenlandClientOptional();\n const { address, role = \"all\", stateTab, enabled = true } = args ?? {};\n\n // Determine states to filter based on stateTab\n const getStatesFromTab = (): string[] | undefined => {\n if (!stateTab || stateTab === \"all\") {\n return args?.states;\n }\n return [...STATE_GROUPS[stateTab]];\n };\n\n return useQuery<GqlEscrowPage>({\n queryKey: [\"zenland\", \"escrows\", address, role, stateTab, args?.state, args?.states, args?.limit, args?.offset],\n queryFn: async () => {\n if (!address) {\n return { items: [], totalCount: 0, pageInfo: { hasNextPage: false, hasPreviousPage: false } };\n }\n\n const states = getStatesFromTab();\n\n return client.escrows.list({\n limit: args?.limit,\n offset: args?.offset,\n buyer: role === \"buyer\" ? address : undefined,\n seller: role === \"seller\" ? address : undefined,\n agent: role === \"agent\" ? address : undefined,\n user: role === \"all\" ? address : undefined,\n state: args?.state,\n states,\n });\n },\n enabled: !!address && enabled,\n });\n}\n\n// Re-export for convenience\nexport { STATE_GROUPS } from \"../../domains/escrows\";\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgent } from \"../../generated/types\";\n\nexport interface UseAgentOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single agent by address.\n *\n * @example\n * ```tsx\n * import { useAgent } from '@zenland/sdk/react';\n *\n * function AgentProfile({ address }: { address: string }) {\n * const { data: agent, isLoading, error } = useAgent(address);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!agent) return <div>Agent not found</div>;\n *\n * return <div>{agent.description}</div>;\n * }\n * ```\n */\nexport function useAgent(address: string | undefined, options?: UseAgentOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlAgent | null>({\n queryKey: [\"zenland\", \"agent\", address],\n queryFn: () => {\n if (!address) return null;\n return client.agents.getById(address);\n },\n enabled: !!address && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgentPage } from \"../../generated/types\";\n\nexport interface UseAgentsArgs {\n /** Only return active agents */\n onlyActive?: boolean;\n /** Only return available agents */\n onlyAvailable?: boolean;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch agents with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useAgents } from '@zenland/sdk/react';\n *\n * function AgentList() {\n * const { data, isLoading } = useAgents({ onlyActive: true });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(agent => (\n * <li key={agent.id}>{agent.description}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useAgents(args?: UseAgentsArgs) {\n const client = useZenlandClientOptional();\n const { enabled = true, ...filterArgs } = args ?? {};\n\n return useQuery<GqlAgentPage>({\n queryKey: [\"zenland\", \"agents\", filterArgs.onlyActive, filterArgs.onlyAvailable, filterArgs.limit, filterArgs.offset],\n queryFn: () => client.agents.list(filterArgs),\n enabled,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { ProtocolStats } from \"../../domains/protocol-stats\";\n\nexport interface UseProtocolStatsOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 60s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch global protocol statistics.\n *\n * @example\n * ```tsx\n * import { useProtocolStats } from '@zenland/sdk/react';\n *\n * function ProtocolOverview() {\n * const { data: stats, isLoading } = useProtocolStats();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!stats) return <div>Stats not available</div>;\n *\n * return (\n * <div>\n * <p>Total Escrows: {stats.totalEscrowsCreated}</p>\n * <p>TVL: {stats.currentTVL.toString()}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProtocolStats(options?: UseProtocolStatsOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<ProtocolStats | null>({\n queryKey: [\"zenland\", \"protocolStats\"],\n queryFn: () => client.protocolStats.get(),\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 30 * 1000, // 30 seconds\n refetchInterval: options?.refetchInterval ?? 60 * 1000, // 1 minute\n });\n}\n\nexport type { ProtocolStats };\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseRecentEscrowsOptions {\n /** Number of escrows to fetch (default: 5) */\n limit?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 15s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 30s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch recent escrows for activity feeds.\n *\n * @example\n * ```tsx\n * import { useRecentEscrows } from '@zenland/sdk/react';\n *\n * function ActivityFeed() {\n * const { data: escrows, isLoading } = useRecentEscrows({ limit: 10 });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {escrows?.map(escrow => (\n * <li key={escrow.id}>\n * {escrow.state} - {escrow.amount}\n * </li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useRecentEscrows(options?: UseRecentEscrowsOptions) {\n const client = useZenlandClientOptional();\n const limit = options?.limit ?? 5;\n\n return useQuery<GqlEscrow[]>({\n queryKey: [\"zenland\", \"recentEscrows\", limit],\n queryFn: async () => {\n const result = await client.escrows.list({\n limit,\n orderBy: \"createdAt\",\n orderDirection: \"desc\",\n });\n return result.items;\n },\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 15 * 1000, // 15 seconds\n refetchInterval: options?.refetchInterval ?? 30 * 1000, // 30 seconds\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS } from \"../../domains/escrows\";\nimport type { GqlEscrow, ZenlandClient } from \"../../index\";\n\n/** State groups for categorization */\nconst ACTIVE_STATES = STATE_GROUPS.ACTIVE;\nconst DISPUTE_STATES = STATE_GROUPS.IN_DISPUTE;\nconst COMPLETED_STATES = STATE_GROUPS.COMPLETED;\nconst TVL_STATES = [...ACTIVE_STATES, ...DISPUTE_STATES] as const;\n\nexport interface UserDashboardStats {\n activeCount: number;\n disputeCount: number;\n completedCount: number;\n tvl: bigint;\n recentEscrows: GqlEscrow[];\n}\n\n/**\n * Fetch count of escrows for a user filtered by states.\n */\nasync function fetchUserEscrowCount(\n client: ZenlandClient,\n userAddress: string,\n states: readonly string[],\n): Promise<number> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1,\n user: userLower,\n states: [...states],\n });\n\n return result.totalCount;\n}\n\n/**\n * Fetch user's escrows that contribute to TVL and calculate sum.\n */\nasync function fetchUserTVL(client: ZenlandClient, userAddress: string): Promise<bigint> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1000,\n user: userLower,\n states: [...TVL_STATES],\n });\n\n return result.items.reduce((sum, escrow) => sum + BigInt(escrow.amount), BigInt(0));\n}\n\n/**\n * Fetch user's recent escrows for dashboard display.\n */\nasync function fetchUserRecentEscrows(\n client: ZenlandClient,\n userAddress: string,\n limit: number = 5,\n): Promise<GqlEscrow[]> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit,\n user: userLower,\n });\n\n return result.items;\n}\n\n/**\n * Fetch all user dashboard stats in parallel.\n */\nasync function getUserDashboardStats(\n client: ZenlandClient,\n userAddress: string,\n): Promise<UserDashboardStats> {\n const [activeCount, disputeCount, completedCount, tvl, recentEscrows] = await Promise.all([\n fetchUserEscrowCount(client, userAddress, ACTIVE_STATES),\n fetchUserEscrowCount(client, userAddress, DISPUTE_STATES),\n fetchUserEscrowCount(client, userAddress, COMPLETED_STATES),\n fetchUserTVL(client, userAddress),\n fetchUserRecentEscrows(client, userAddress, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl,\n recentEscrows,\n };\n}\n\n/**\n * Fetch global dashboard stats.\n */\nasync function getGlobalDashboardStats(\n client: ZenlandClient,\n): Promise<Omit<UserDashboardStats, \"tvl\"> & { tvl: null }> {\n const [activeCount, disputeCount, completedCount, recentEscrows] = await Promise.all([\n fetchGlobalEscrowCount(client, [...ACTIVE_STATES]),\n fetchGlobalEscrowCount(client, [...DISPUTE_STATES]),\n fetchGlobalEscrowCount(client, [...COMPLETED_STATES]),\n fetchGlobalRecentEscrows(client, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl: null,\n recentEscrows,\n };\n}\n\nasync function fetchGlobalEscrowCount(client: ZenlandClient, states: string[]): Promise<number> {\n const result = await client.escrows.list({\n limit: 1,\n states,\n });\n return result.totalCount;\n}\n\nasync function fetchGlobalRecentEscrows(client: ZenlandClient, limit: number = 5): Promise<GqlEscrow[]> {\n const result = await client.escrows.list({ limit });\n return result.items;\n}\n\n/**\n * Hook to fetch user-specific dashboard statistics.\n */\nexport function useUserStats(userAddress: string | undefined) {\n const client = useZenlandClientOptional();\n return useQuery<UserDashboardStats | null>({\n queryKey: [\"zenland\", \"userStats\", userAddress],\n queryFn: async () => {\n if (!userAddress) return null;\n return getUserDashboardStats(client, userAddress);\n },\n enabled: !!userAddress,\n staleTime: 15 * 1000,\n refetchInterval: 30 * 1000,\n });\n}\n\n/**\n * Hook to fetch global dashboard statistics.\n */\nexport function useGlobalStats() {\n const client = useZenlandClientOptional();\n return useQuery({\n queryKey: [\"zenland\", \"globalStats\"],\n queryFn: () => getGlobalDashboardStats(client),\n staleTime: 30 * 1000,\n refetchInterval: 60 * 1000,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlTransactionLog } from \"../../generated/types\";\nimport type { ListTransactionLogsArgs } from \"../../domains/transaction-logs\";\n\nexport interface UseTransactionLogsByEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds */\n refetchInterval?: number;\n /** Transaction log list options */\n list?: Omit<ListTransactionLogsArgs, \"escrowAddress\">;\n}\n\n/**\n * Hook to fetch transaction logs for a specific escrow.\n */\nexport function useTransactionLogsByEscrow(\n escrowAddress: string | undefined | null,\n options?: UseTransactionLogsByEscrowOptions,\n) {\n const client = useZenlandClientOptional();\n const addr = escrowAddress?.toLowerCase();\n\n return useQuery<GqlTransactionLog[]>({\n queryKey: [\n \"zenland\",\n \"transactionLogs\",\n \"escrow\",\n addr,\n options?.list?.limit,\n options?.list?.offset,\n options?.list?.orderBy,\n options?.list?.orderDirection,\n ],\n queryFn: async () => {\n if (!addr) return [];\n return client.transactionLogs.getByEscrow(addr, options?.list);\n },\n enabled: !!addr && (options?.enabled ?? true),\n staleTime: options?.staleTime ?? 30_000,\n refetchInterval: options?.refetchInterval,\n refetchOnWindowFocus: false,\n });\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,YAAY,eAA+B;;;ACe5D,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,UAAU,EAAE,OAAO,UAAU,UAAU,CAA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AAM,OAAO,QAAQ,KAAK,EAAE,MAAM,CAAC;AAClD,SAAO,OAAO;AAChB;AAKO,SAAS,aAAa,aAAiC;AAC5D,QAAM,SAAS,yBAAyB;AACxC,SAAOC,UAAoC;AAAA,IACzC,UAAU,CAAC,WAAW,aAAa,WAAW;AAAA,IAC9C,SAAS,YAAY;AACnB,UAAI,CAAC,YAAa,QAAO;AACzB,aAAO,sBAAsB,QAAQ,WAAW;AAAA,IAClD;AAAA,IACA,SAAS,CAAC,CAAC;AAAA,IACX,WAAW,KAAK;AAAA,IAChB,iBAAiB,KAAK;AAAA,EACxB,CAAC;AACH;AAKO,SAAS,iBAAiB;AAC/B,QAAM,SAAS,yBAAyB;AACxC,SAAOA,UAAS;AAAA,IACd,UAAU,CAAC,WAAW,aAAa;AAAA,IACnC,SAAS,MAAM,wBAAwB,MAAM;AAAA,IAC7C,WAAW,KAAK;AAAA,IAChB,iBAAiB,KAAK;AAAA,EACxB,CAAC;AACH;;;AC9JA,SAAS,YAAAC,iBAAgB;AAmBlB,SAAS,2BACd,eACA,SACA;AACA,QAAM,SAAS,yBAAyB;AACxC,QAAM,OAAO,eAAe,YAAY;AAExC,SAAOC,UAA8B;AAAA,IACnC,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,SAAS,YAAY;AACnB,UAAI,CAAC,KAAM,QAAO,CAAC;AACnB,aAAO,OAAO,gBAAgB,YAAY,MAAM,SAAS,IAAI;AAAA,IAC/D;AAAA,IACA,SAAS,CAAC,CAAC,SAAS,SAAS,WAAW;AAAA,IACxC,WAAW,SAAS,aAAa;AAAA,IACjC,iBAAiB,SAAS;AAAA,IAC1B,sBAAsB;AAAA,EACxB,CAAC;AACH;","names":["useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery"]}
|
|
1
|
+
{"version":3,"sources":["../src/react/context.tsx","../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/react/hooks/useEscrow.ts","../src/react/hooks/useEscrows.ts","../src/react/hooks/useAgent.ts","../src/react/hooks/useAgents.ts","../src/react/hooks/useProtocolStats.ts","../src/react/hooks/useRecentEscrows.ts","../src/react/hooks/useUserStats.ts","../src/react/hooks/useTransactionLogsByEscrow.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport { createZenlandClient, type ZenlandClient, type ZenlandClientConfig } from \"../client\";\n\nconst ZenlandContext = createContext<ZenlandClient | null>(null);\n\nexport interface ZenlandProviderProps {\n children: ReactNode;\n /** Optional configuration for the SDK client */\n config?: ZenlandClientConfig;\n}\n\n/**\n * Provider component for the Zenland SDK.\n *\n * Wrap your app with this provider to use the React hooks.\n *\n * @example\n * ```tsx\n * import { ZenlandProvider } from '@zenland/sdk/react';\n *\n * function App() {\n * return (\n * <ZenlandProvider>\n * <YourApp />\n * </ZenlandProvider>\n * );\n * }\n *\n * // With custom config\n * <ZenlandProvider config={{ baseUrl: 'http://localhost:42069' }}>\n * <YourApp />\n * </ZenlandProvider>\n * ```\n */\nexport function ZenlandProvider({ children, config }: ZenlandProviderProps) {\n const client = useMemo(() => createZenlandClient(config), [config]);\n\n return <ZenlandContext.Provider value={client}>{children}</ZenlandContext.Provider>;\n}\n\n/**\n * Hook to access the Zenland SDK client.\n *\n * Must be used within a ZenlandProvider.\n *\n * @example\n * ```tsx\n * import { useZenlandClient } from '@zenland/sdk/react';\n *\n * function MyComponent() {\n * const client = useZenlandClient();\n * // Use client.escrows, client.agents, etc.\n * }\n * ```\n */\nexport function useZenlandClient(): ZenlandClient {\n const context = useContext(ZenlandContext);\n if (!context) {\n throw new Error(\"useZenlandClient must be used within a ZenlandProvider\");\n }\n return context;\n}\n\n/**\n * Hook to access the Zenland SDK client, creating a default one if not in a provider.\n *\n * This is useful for components that might be used outside of a ZenlandProvider.\n */\nexport function useZenlandClientOptional(): ZenlandClient {\n const context = useContext(ZenlandContext);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => context ?? createZenlandClient(), [context]);\n}\n","/**\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! = \"mainnet\") {\n protocolStats(id: $id) {\n id\n chainId\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 * Stats are tracked per-chain. By default, mainnet stats are returned\n * for production UI. Use chainId parameter to query other networks.\n */\n\nimport { graphqlRequest } from \"../request\";\nimport { PROTOCOL_STATS_QUERY } from \"../queries\";\nimport type { GqlProtocolStats, ProtocolStatsQueryResponse } from \"../generated/types\";\n\n/** Default stats ID for production (Ethereum mainnet) */\nconst DEFAULT_STATS_ID = \"mainnet\";\n\n/** Normalized protocol stats with BigInt values */\nexport interface ProtocolStats {\n id: string;\n chainId?: number;\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 chainId: (raw as any).chainId,\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\nexport interface GetProtocolStatsOptions {\n /** \n * Stats ID to query. Defaults to \"mainnet\".\n * Use \"sepolia\" for testnet stats.\n */\n statsId?: string;\n}\n\n/**\n * Creates protocol stats domain functions bound to a base URL\n */\nexport function createProtocolStatsDomain(baseUrl: string) {\n /**\n * Fetch protocol statistics for a specific chain.\n * Defaults to mainnet for production use.\n * \n * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function get(options?: GetProtocolStatsOptions): Promise<ProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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 * @param options - Optional parameters\n * @param options.statsId - Stats ID to query (default: \"mainnet\")\n */\n async function getRaw(options?: GetProtocolStatsOptions): Promise<GqlProtocolStats | null> {\n const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };\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","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single escrow by ID.\n *\n * @example\n * ```tsx\n * import { useEscrow } from '@zenland/sdk/react';\n *\n * function EscrowDetail({ id }: { id: string }) {\n * const { data: escrow, isLoading, error } = useEscrow(id);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!escrow) return <div>Escrow not found</div>;\n *\n * return <div>{escrow.state}</div>;\n * }\n * ```\n */\nexport function useEscrow(id: string | undefined, options?: UseEscrowOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlEscrow | null>({\n queryKey: [\"zenland\", \"escrow\", id],\n queryFn: () => {\n if (!id) return null;\n return client.escrows.getById(id);\n },\n enabled: !!id && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS, type StateGroup } from \"../../domains/escrows\";\nimport type { GqlEscrowPage } from \"../../generated/types\";\n\nexport type EscrowRole = \"all\" | \"buyer\" | \"seller\" | \"agent\";\nexport type EscrowStateTab = \"all\" | StateGroup;\n\nexport interface UseEscrowsArgs {\n /** User address to filter by */\n address?: string;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Filter by role (requires address) */\n role?: EscrowRole;\n /** Filter by state group */\n stateTab?: EscrowStateTab;\n /** Filter by specific state */\n state?: string;\n /** Filter by multiple states */\n states?: string[];\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch escrows with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useEscrows } from '@zenland/sdk/react';\n *\n * function MyEscrows({ address }: { address: string }) {\n * const { data, isLoading } = useEscrows({\n * address,\n * role: 'buyer',\n * stateTab: 'ACTIVE',\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(escrow => (\n * <li key={escrow.id}>{escrow.state}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useEscrows(args?: UseEscrowsArgs) {\n const client = useZenlandClientOptional();\n const { address, role = \"all\", stateTab, enabled = true } = args ?? {};\n\n // Determine states to filter based on stateTab\n const getStatesFromTab = (): string[] | undefined => {\n if (!stateTab || stateTab === \"all\") {\n return args?.states;\n }\n return [...STATE_GROUPS[stateTab]];\n };\n\n return useQuery<GqlEscrowPage>({\n queryKey: [\"zenland\", \"escrows\", address, role, stateTab, args?.state, args?.states, args?.limit, args?.offset],\n queryFn: async () => {\n if (!address) {\n return { items: [], totalCount: 0, pageInfo: { hasNextPage: false, hasPreviousPage: false } };\n }\n\n const states = getStatesFromTab();\n\n return client.escrows.list({\n limit: args?.limit,\n offset: args?.offset,\n buyer: role === \"buyer\" ? address : undefined,\n seller: role === \"seller\" ? address : undefined,\n agent: role === \"agent\" ? address : undefined,\n user: role === \"all\" ? address : undefined,\n state: args?.state,\n states,\n });\n },\n enabled: !!address && enabled,\n });\n}\n\n// Re-export for convenience\nexport { STATE_GROUPS } from \"../../domains/escrows\";\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgent } from \"../../generated/types\";\n\nexport interface UseAgentOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch a single agent by address.\n *\n * @example\n * ```tsx\n * import { useAgent } from '@zenland/sdk/react';\n *\n * function AgentProfile({ address }: { address: string }) {\n * const { data: agent, isLoading, error } = useAgent(address);\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!agent) return <div>Agent not found</div>;\n *\n * return <div>{agent.description}</div>;\n * }\n * ```\n */\nexport function useAgent(address: string | undefined, options?: UseAgentOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<GqlAgent | null>({\n queryKey: [\"zenland\", \"agent\", address],\n queryFn: () => {\n if (!address) return null;\n return client.agents.getById(address);\n },\n enabled: !!address && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlAgentPage } from \"../../generated/types\";\n\nexport interface UseAgentsArgs {\n /** Only return active agents */\n onlyActive?: boolean;\n /** Only return available agents */\n onlyAvailable?: boolean;\n /** Pagination limit */\n limit?: number;\n /** Pagination offset */\n offset?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n}\n\n/**\n * Hook to fetch agents with filtering and pagination.\n *\n * @example\n * ```tsx\n * import { useAgents } from '@zenland/sdk/react';\n *\n * function AgentList() {\n * const { data, isLoading } = useAgents({ onlyActive: true });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {data?.items.map(agent => (\n * <li key={agent.id}>{agent.description}</li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useAgents(args?: UseAgentsArgs) {\n const client = useZenlandClientOptional();\n const { enabled = true, ...filterArgs } = args ?? {};\n\n return useQuery<GqlAgentPage>({\n queryKey: [\"zenland\", \"agents\", filterArgs.onlyActive, filterArgs.onlyAvailable, filterArgs.limit, filterArgs.offset],\n queryFn: () => client.agents.list(filterArgs),\n enabled,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { ProtocolStats } from \"../../domains/protocol-stats\";\n\nexport interface UseProtocolStatsOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 60s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch global protocol statistics.\n *\n * @example\n * ```tsx\n * import { useProtocolStats } from '@zenland/sdk/react';\n *\n * function ProtocolOverview() {\n * const { data: stats, isLoading } = useProtocolStats();\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (!stats) return <div>Stats not available</div>;\n *\n * return (\n * <div>\n * <p>Total Escrows: {stats.totalEscrowsCreated}</p>\n * <p>TVL: {stats.currentTVL.toString()}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useProtocolStats(options?: UseProtocolStatsOptions) {\n const client = useZenlandClientOptional();\n\n return useQuery<ProtocolStats | null>({\n queryKey: [\"zenland\", \"protocolStats\"],\n queryFn: () => client.protocolStats.get(),\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 30 * 1000, // 30 seconds\n refetchInterval: options?.refetchInterval ?? 60 * 1000, // 1 minute\n });\n}\n\nexport type { ProtocolStats };\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlEscrow } from \"../../generated/types\";\n\nexport interface UseRecentEscrowsOptions {\n /** Number of escrows to fetch (default: 5) */\n limit?: number;\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 15s) */\n staleTime?: number;\n /** Refetch interval in milliseconds (default: 30s) */\n refetchInterval?: number;\n}\n\n/**\n * Hook to fetch recent escrows for activity feeds.\n *\n * @example\n * ```tsx\n * import { useRecentEscrows } from '@zenland/sdk/react';\n *\n * function ActivityFeed() {\n * const { data: escrows, isLoading } = useRecentEscrows({ limit: 10 });\n *\n * if (isLoading) return <div>Loading...</div>;\n *\n * return (\n * <ul>\n * {escrows?.map(escrow => (\n * <li key={escrow.id}>\n * {escrow.state} - {escrow.amount}\n * </li>\n * ))}\n * </ul>\n * );\n * }\n * ```\n */\nexport function useRecentEscrows(options?: UseRecentEscrowsOptions) {\n const client = useZenlandClientOptional();\n const limit = options?.limit ?? 5;\n\n return useQuery<GqlEscrow[]>({\n queryKey: [\"zenland\", \"recentEscrows\", limit],\n queryFn: async () => {\n const result = await client.escrows.list({\n limit,\n orderBy: \"createdAt\",\n orderDirection: \"desc\",\n });\n return result.items;\n },\n enabled: options?.enabled ?? true,\n staleTime: options?.staleTime ?? 15 * 1000, // 15 seconds\n refetchInterval: options?.refetchInterval ?? 30 * 1000, // 30 seconds\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport { STATE_GROUPS } from \"../../domains/escrows\";\nimport type { GqlEscrow, ZenlandClient } from \"../../index\";\n\n/** State groups for categorization */\nconst ACTIVE_STATES = STATE_GROUPS.ACTIVE;\nconst DISPUTE_STATES = STATE_GROUPS.IN_DISPUTE;\nconst COMPLETED_STATES = STATE_GROUPS.COMPLETED;\nconst TVL_STATES = [...ACTIVE_STATES, ...DISPUTE_STATES] as const;\n\nexport interface UserDashboardStats {\n activeCount: number;\n disputeCount: number;\n completedCount: number;\n tvl: bigint;\n recentEscrows: GqlEscrow[];\n}\n\n/**\n * Fetch count of escrows for a user filtered by states.\n */\nasync function fetchUserEscrowCount(\n client: ZenlandClient,\n userAddress: string,\n states: readonly string[],\n): Promise<number> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1,\n user: userLower,\n states: [...states],\n });\n\n return result.totalCount;\n}\n\n/**\n * Fetch user's escrows that contribute to TVL and calculate sum.\n */\nasync function fetchUserTVL(client: ZenlandClient, userAddress: string): Promise<bigint> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit: 1000,\n user: userLower,\n states: [...TVL_STATES],\n });\n\n return result.items.reduce((sum, escrow) => sum + BigInt(escrow.amount), BigInt(0));\n}\n\n/**\n * Fetch user's recent escrows for dashboard display.\n */\nasync function fetchUserRecentEscrows(\n client: ZenlandClient,\n userAddress: string,\n limit: number = 5,\n): Promise<GqlEscrow[]> {\n const userLower = userAddress.toLowerCase();\n\n const result = await client.escrows.list({\n limit,\n user: userLower,\n });\n\n return result.items;\n}\n\n/**\n * Fetch all user dashboard stats in parallel.\n */\nasync function getUserDashboardStats(\n client: ZenlandClient,\n userAddress: string,\n): Promise<UserDashboardStats> {\n const [activeCount, disputeCount, completedCount, tvl, recentEscrows] = await Promise.all([\n fetchUserEscrowCount(client, userAddress, ACTIVE_STATES),\n fetchUserEscrowCount(client, userAddress, DISPUTE_STATES),\n fetchUserEscrowCount(client, userAddress, COMPLETED_STATES),\n fetchUserTVL(client, userAddress),\n fetchUserRecentEscrows(client, userAddress, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl,\n recentEscrows,\n };\n}\n\n/**\n * Fetch global dashboard stats.\n */\nasync function getGlobalDashboardStats(\n client: ZenlandClient,\n): Promise<Omit<UserDashboardStats, \"tvl\"> & { tvl: null }> {\n const [activeCount, disputeCount, completedCount, recentEscrows] = await Promise.all([\n fetchGlobalEscrowCount(client, [...ACTIVE_STATES]),\n fetchGlobalEscrowCount(client, [...DISPUTE_STATES]),\n fetchGlobalEscrowCount(client, [...COMPLETED_STATES]),\n fetchGlobalRecentEscrows(client, 5),\n ]);\n\n return {\n activeCount,\n disputeCount,\n completedCount,\n tvl: null,\n recentEscrows,\n };\n}\n\nasync function fetchGlobalEscrowCount(client: ZenlandClient, states: string[]): Promise<number> {\n const result = await client.escrows.list({\n limit: 1,\n states,\n });\n return result.totalCount;\n}\n\nasync function fetchGlobalRecentEscrows(client: ZenlandClient, limit: number = 5): Promise<GqlEscrow[]> {\n const result = await client.escrows.list({ limit });\n return result.items;\n}\n\n/**\n * Hook to fetch user-specific dashboard statistics.\n */\nexport function useUserStats(userAddress: string | undefined) {\n const client = useZenlandClientOptional();\n return useQuery<UserDashboardStats | null>({\n queryKey: [\"zenland\", \"userStats\", userAddress],\n queryFn: async () => {\n if (!userAddress) return null;\n return getUserDashboardStats(client, userAddress);\n },\n enabled: !!userAddress,\n staleTime: 15 * 1000,\n refetchInterval: 30 * 1000,\n });\n}\n\n/**\n * Hook to fetch global dashboard statistics.\n */\nexport function useGlobalStats() {\n const client = useZenlandClientOptional();\n return useQuery({\n queryKey: [\"zenland\", \"globalStats\"],\n queryFn: () => getGlobalDashboardStats(client),\n staleTime: 30 * 1000,\n refetchInterval: 60 * 1000,\n });\n}\n","\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useZenlandClientOptional } from \"../context\";\nimport type { GqlTransactionLog } from \"../../generated/types\";\nimport type { ListTransactionLogsArgs } from \"../../domains/transaction-logs\";\n\nexport interface UseTransactionLogsByEscrowOptions {\n /** Whether to enable the query */\n enabled?: boolean;\n /** Stale time in milliseconds (default: 30s) */\n staleTime?: number;\n /** Refetch interval in milliseconds */\n refetchInterval?: number;\n /** Transaction log list options */\n list?: Omit<ListTransactionLogsArgs, \"escrowAddress\">;\n}\n\n/**\n * Hook to fetch transaction logs for a specific escrow.\n */\nexport function useTransactionLogsByEscrow(\n escrowAddress: string | undefined | null,\n options?: UseTransactionLogsByEscrowOptions,\n) {\n const client = useZenlandClientOptional();\n const addr = escrowAddress?.toLowerCase();\n\n return useQuery<GqlTransactionLog[]>({\n queryKey: [\n \"zenland\",\n \"transactionLogs\",\n \"escrow\",\n addr,\n options?.list?.limit,\n options?.list?.offset,\n options?.list?.orderBy,\n options?.list?.orderDirection,\n ],\n queryFn: async () => {\n if (!addr) return [];\n return client.transactionLogs.getByEscrow(addr, options?.list);\n },\n enabled: !!addr && (options?.enabled ?? true),\n staleTime: options?.staleTime ?? 30_000,\n refetchInterval: options?.refetchInterval,\n refetchOnWindowFocus: false,\n });\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,YAAY,eAA+B;;;ACe5D,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,UAAU,EAAE,OAAO,UAAU,UAAU,CAAC;AAAA,IACnD,QAAQ,SAAS;AAAA,IACjB,OAAO;AAAA,EACT,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,EAAE;AAC5C,UAAM,IAAI;AAAA,MACR,2BAA2B,IAAI,MAAM,IAAI,IAAI,UAA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,SAAOC,UAAoC;AAAA,IACzC,UAAU,CAAC,WAAW,aAAa,WAAW;AAAA,IAC9C,SAAS,YAAY;AACnB,UAAI,CAAC,YAAa,QAAO;AACzB,aAAO,sBAAsB,QAAQ,WAAW;AAAA,IAClD;AAAA,IACA,SAAS,CAAC,CAAC;AAAA,IACX,WAAW,KAAK;AAAA,IAChB,iBAAiB,KAAK;AAAA,EACxB,CAAC;AACH;AAKO,SAAS,iBAAiB;AAC/B,QAAM,SAAS,yBAAyB;AACxC,SAAOA,UAAS;AAAA,IACd,UAAU,CAAC,WAAW,aAAa;AAAA,IACnC,SAAS,MAAM,wBAAwB,MAAM;AAAA,IAC7C,WAAW,KAAK;AAAA,IAChB,iBAAiB,KAAK;AAAA,EACxB,CAAC;AACH;;;AC9JA,SAAS,YAAAC,iBAAgB;AAmBlB,SAAS,2BACd,eACA,SACA;AACA,QAAM,SAAS,yBAAyB;AACxC,QAAM,OAAO,eAAe,YAAY;AAExC,SAAOC,UAA8B;AAAA,IACnC,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,IACjB;AAAA,IACA,SAAS,YAAY;AACnB,UAAI,CAAC,KAAM,QAAO,CAAC;AACnB,aAAO,OAAO,gBAAgB,YAAY,MAAM,SAAS,IAAI;AAAA,IAC/D;AAAA,IACA,SAAS,CAAC,CAAC,SAAS,SAAS,WAAW;AAAA,IACxC,WAAW,SAAS,aAAa;AAAA,IACjC,iBAAiB,SAAS;AAAA,IAC1B,sBAAsB;AAAA,EACxB,CAAC;AACH;","names":["useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery","useQuery"]}
|