@zenland/sdk 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -245,6 +245,11 @@ query protocolStats($id: String! = "mainnet") {
245
245
  totalAgentsRegistered
246
246
  activeAgentsCount
247
247
  }
248
+ agents(where: { isActive: true }, limit: 1000) {
249
+ items {
250
+ stablecoinStake
251
+ }
252
+ }
248
253
  }
249
254
  `;
250
255
  var TRANSACTION_LOGS_QUERY = `
@@ -378,14 +383,21 @@ function createAgentsDomain(baseUrl) {
378
383
 
379
384
  // src/domains/protocol-stats.ts
380
385
  var DEFAULT_STATS_ID = "mainnet";
381
- function normalizeProtocolStats(raw) {
386
+ function normalizeProtocolStats(raw, activeAgents) {
387
+ const escrowTVL = BigInt(raw.currentTVL);
388
+ const agentStakingTVL = activeAgents.reduce(
389
+ (sum, a) => sum + BigInt(a.stablecoinStake),
390
+ 0n
391
+ );
382
392
  return {
383
393
  id: raw.id,
384
394
  chainId: raw.chainId,
385
395
  totalEscrowsCreated: raw.totalEscrowsCreated,
386
396
  totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
387
397
  totalFeesCollected: BigInt(raw.totalFeesCollected),
388
- currentTVL: BigInt(raw.currentTVL),
398
+ currentTVL: escrowTVL + agentStakingTVL,
399
+ escrowTVL,
400
+ agentStakingTVL,
389
401
  activeEscrowCount: raw.activeEscrowCount,
390
402
  totalAgentsRegistered: raw.totalAgentsRegistered,
391
403
  activeAgentsCount: raw.activeAgentsCount
@@ -402,7 +414,7 @@ function createProtocolStatsDomain(baseUrl) {
402
414
  if (!response.protocolStats) {
403
415
  return null;
404
416
  }
405
- return normalizeProtocolStats(response.protocolStats);
417
+ return normalizeProtocolStats(response.protocolStats, response.agents?.items ?? []);
406
418
  }
407
419
  async function getRaw(options) {
408
420
  const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
@@ -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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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":";;;;;;;;;;;;;;;;;;;;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,QAAM,WAAW,GA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AAC7C,SAAO,IAAI,SAAS,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/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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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 agents(where: { isActive: true }, limit: 1000) {\n items {\n stablecoinStake\n }\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 /** True TVL = escrowTVL + agentStakingTVL */\n currentTVL: bigint;\n /** TVL held in active escrow contracts only */\n escrowTVL: bigint;\n /** TVL held as agent stablecoin collateral in the registry */\n agentStakingTVL: bigint;\n activeEscrowCount: number;\n totalAgentsRegistered: number;\n activeAgentsCount: number;\n}\n\n/**\n * Convert raw GraphQL response to normalized ProtocolStats\n */\nfunction normalizeProtocolStats(\n raw: GqlProtocolStats,\n activeAgents: Array<{ stablecoinStake: string | number | bigint }>,\n): ProtocolStats {\n const escrowTVL = BigInt(raw.currentTVL);\n const agentStakingTVL = activeAgents.reduce(\n (sum, a) => sum + BigInt(a.stablecoinStake),\n 0n,\n );\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: escrowTVL + agentStakingTVL,\n escrowTVL,\n agentStakingTVL,\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, response.agents?.items ?? []);\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":";;;;;;;;;;;;;;;;;;;;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,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,UA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ChD,iBAAiB,4BAA4B,OAAO;AAAA,EACtD;AACF;AAKA,SAAS,iBAAiB,KAAqB;AAC7C,SAAO,IAAI,SAAS,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":[]}
package/dist/index.d.cts CHANGED
@@ -222,7 +222,12 @@ interface ProtocolStats {
222
222
  totalEscrowsCreated: number;
223
223
  totalVolumeEscrowed: bigint;
224
224
  totalFeesCollected: bigint;
225
+ /** True TVL = escrowTVL + agentStakingTVL */
225
226
  currentTVL: bigint;
227
+ /** TVL held in active escrow contracts only */
228
+ escrowTVL: bigint;
229
+ /** TVL held as agent stablecoin collateral in the registry */
230
+ agentStakingTVL: bigint;
226
231
  activeEscrowCount: number;
227
232
  totalAgentsRegistered: number;
228
233
  activeAgentsCount: number;
package/dist/index.d.ts CHANGED
@@ -222,7 +222,12 @@ interface ProtocolStats {
222
222
  totalEscrowsCreated: number;
223
223
  totalVolumeEscrowed: bigint;
224
224
  totalFeesCollected: bigint;
225
+ /** True TVL = escrowTVL + agentStakingTVL */
225
226
  currentTVL: bigint;
227
+ /** TVL held in active escrow contracts only */
228
+ escrowTVL: bigint;
229
+ /** TVL held as agent stablecoin collateral in the registry */
230
+ agentStakingTVL: bigint;
226
231
  activeEscrowCount: number;
227
232
  totalAgentsRegistered: number;
228
233
  activeAgentsCount: number;
package/dist/index.js CHANGED
@@ -209,6 +209,11 @@ query protocolStats($id: String! = "mainnet") {
209
209
  totalAgentsRegistered
210
210
  activeAgentsCount
211
211
  }
212
+ agents(where: { isActive: true }, limit: 1000) {
213
+ items {
214
+ stablecoinStake
215
+ }
216
+ }
212
217
  }
213
218
  `;
214
219
  var TRANSACTION_LOGS_QUERY = `
@@ -342,14 +347,21 @@ function createAgentsDomain(baseUrl) {
342
347
 
343
348
  // src/domains/protocol-stats.ts
344
349
  var DEFAULT_STATS_ID = "mainnet";
345
- function normalizeProtocolStats(raw) {
350
+ function normalizeProtocolStats(raw, activeAgents) {
351
+ const escrowTVL = BigInt(raw.currentTVL);
352
+ const agentStakingTVL = activeAgents.reduce(
353
+ (sum, a) => sum + BigInt(a.stablecoinStake),
354
+ 0n
355
+ );
346
356
  return {
347
357
  id: raw.id,
348
358
  chainId: raw.chainId,
349
359
  totalEscrowsCreated: raw.totalEscrowsCreated,
350
360
  totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
351
361
  totalFeesCollected: BigInt(raw.totalFeesCollected),
352
- currentTVL: BigInt(raw.currentTVL),
362
+ currentTVL: escrowTVL + agentStakingTVL,
363
+ escrowTVL,
364
+ agentStakingTVL,
353
365
  activeEscrowCount: raw.activeEscrowCount,
354
366
  totalAgentsRegistered: raw.totalAgentsRegistered,
355
367
  activeAgentsCount: raw.activeAgentsCount
@@ -366,7 +378,7 @@ function createProtocolStatsDomain(baseUrl) {
366
378
  if (!response.protocolStats) {
367
379
  return null;
368
380
  }
369
- return normalizeProtocolStats(response.protocolStats);
381
+ return normalizeProtocolStats(response.protocolStats, response.agents?.items ?? []);
370
382
  }
371
383
  async function getRaw(options) {
372
384
  const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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;A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,gBAAgB;AAEpE,SAAO;AAAA,IACL;AAAA,IACA,SAAS,oBAAoB,OAAO;AAAA,IACpC,QAAQ,mBAAmB,OAAO;AAAA,IAClC,eAAe,0BAA0B,OAAO;AAAA,IAChD,iBAAiB,4BAA4B,OAAO;AAAA,EACtD;AACF;AAKA,SAAS,iBAAiB,KAAqB;AAC7C,SAAO,IAAI,SAAS,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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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 agents(where: { isActive: true }, limit: 1000) {\n items {\n stablecoinStake\n }\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 /** True TVL = escrowTVL + agentStakingTVL */\n currentTVL: bigint;\n /** TVL held in active escrow contracts only */\n escrowTVL: bigint;\n /** TVL held as agent stablecoin collateral in the registry */\n agentStakingTVL: bigint;\n activeEscrowCount: number;\n totalAgentsRegistered: number;\n activeAgentsCount: number;\n}\n\n/**\n * Convert raw GraphQL response to normalized ProtocolStats\n */\nfunction normalizeProtocolStats(\n raw: GqlProtocolStats,\n activeAgents: Array<{ stablecoinStake: string | number | bigint }>,\n): ProtocolStats {\n const escrowTVL = BigInt(raw.currentTVL);\n const agentStakingTVL = activeAgents.reduce(\n (sum, a) => sum + BigInt(a.stablecoinStake),\n 0n,\n );\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: escrowTVL + agentStakingTVL,\n escrowTVL,\n agentStakingTVL,\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, response.agents?.items ?? []);\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;AAC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IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACvDA,IAAM,mBAAmB;AAgDlB,SAAS,oBAAoB,QAA6C;AAC/E,QAAM,UAAU,iBAAiB,QAAQ,WAAW,gBAAgB;AAEpE,SAAO;AAAA,IACL;AAAA,IACA,SAAS,oBAAoB,OAAO;AAAA,IACpC,QAAQ,mBAAmB,OAAO;AAAA,IAClC,eAAe,0BAA0B,OAAO;AAAA,IAChD,iBAAiB,4BAA4B,OAAO;AAAA,EACtD;AACF;AAKA,SAAS,iBAAiB,KAAqB;AAC7C,SAAO,IAAI,SAAS,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":[]}
package/dist/react.cjs CHANGED
@@ -252,6 +252,11 @@ query protocolStats($id: String! = "mainnet") {
252
252
  totalAgentsRegistered
253
253
  activeAgentsCount
254
254
  }
255
+ agents(where: { isActive: true }, limit: 1000) {
256
+ items {
257
+ stablecoinStake
258
+ }
259
+ }
255
260
  }
256
261
  `;
257
262
  var TRANSACTION_LOGS_QUERY = `
@@ -385,14 +390,21 @@ function createAgentsDomain(baseUrl) {
385
390
 
386
391
  // src/domains/protocol-stats.ts
387
392
  var DEFAULT_STATS_ID = "mainnet";
388
- function normalizeProtocolStats(raw) {
393
+ function normalizeProtocolStats(raw, activeAgents) {
394
+ const escrowTVL = BigInt(raw.currentTVL);
395
+ const agentStakingTVL = activeAgents.reduce(
396
+ (sum, a) => sum + BigInt(a.stablecoinStake),
397
+ 0n
398
+ );
389
399
  return {
390
400
  id: raw.id,
391
401
  chainId: raw.chainId,
392
402
  totalEscrowsCreated: raw.totalEscrowsCreated,
393
403
  totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
394
404
  totalFeesCollected: BigInt(raw.totalFeesCollected),
395
- currentTVL: BigInt(raw.currentTVL),
405
+ currentTVL: escrowTVL + agentStakingTVL,
406
+ escrowTVL,
407
+ agentStakingTVL,
396
408
  activeEscrowCount: raw.activeEscrowCount,
397
409
  totalAgentsRegistered: raw.totalAgentsRegistered,
398
410
  activeAgentsCount: raw.activeAgentsCount
@@ -409,7 +421,7 @@ function createProtocolStatsDomain(baseUrl) {
409
421
  if (!response.protocolStats) {
410
422
  return null;
411
423
  }
412
- return normalizeProtocolStats(response.protocolStats);
424
+ return normalizeProtocolStats(response.protocolStats, response.agents?.items ?? []);
413
425
  }
414
426
  async function getRaw(options) {
415
427
  const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
@@ -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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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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H;;;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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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 agents(where: { isActive: true }, limit: 1000) {\n items {\n stablecoinStake\n }\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 /** True TVL = escrowTVL + agentStakingTVL */\n currentTVL: bigint;\n /** TVL held in active escrow contracts only */\n escrowTVL: bigint;\n /** TVL held as agent stablecoin collateral in the registry */\n agentStakingTVL: bigint;\n activeEscrowCount: number;\n totalAgentsRegistered: number;\n activeAgentsCount: number;\n}\n\n/**\n * Convert raw GraphQL response to normalized ProtocolStats\n */\nfunction normalizeProtocolStats(\n raw: GqlProtocolStats,\n activeAgents: Array<{ stablecoinStake: string | number | bigint }>,\n): ProtocolStats {\n const escrowTVL = BigInt(raw.currentTVL);\n const agentStakingTVL = activeAgents.reduce(\n (sum, a) => sum + BigInt(a.stablecoinStake),\n 0n,\n );\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: escrowTVL + agentStakingTVL,\n escrowTVL,\n agentStakingTVL,\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, response.agents?.items ?? []);\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;AA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iB,KAAK;AAAA,EACxB,CAAC;AACH;AAKO,SAAS,iBAAiB;AAC/B,QAAM,SAAS,yBAAyB;AACxC,aAAO,8BAAS;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,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"]}
package/dist/react.d.cts CHANGED
@@ -192,7 +192,12 @@ interface ProtocolStats {
192
192
  totalEscrowsCreated: number;
193
193
  totalVolumeEscrowed: bigint;
194
194
  totalFeesCollected: bigint;
195
+ /** True TVL = escrowTVL + agentStakingTVL */
195
196
  currentTVL: bigint;
197
+ /** TVL held in active escrow contracts only */
198
+ escrowTVL: bigint;
199
+ /** TVL held as agent stablecoin collateral in the registry */
200
+ agentStakingTVL: bigint;
196
201
  activeEscrowCount: number;
197
202
  totalAgentsRegistered: number;
198
203
  activeAgentsCount: number;
package/dist/react.d.ts CHANGED
@@ -192,7 +192,12 @@ interface ProtocolStats {
192
192
  totalEscrowsCreated: number;
193
193
  totalVolumeEscrowed: bigint;
194
194
  totalFeesCollected: bigint;
195
+ /** True TVL = escrowTVL + agentStakingTVL */
195
196
  currentTVL: bigint;
197
+ /** TVL held in active escrow contracts only */
198
+ escrowTVL: bigint;
199
+ /** TVL held as agent stablecoin collateral in the registry */
200
+ agentStakingTVL: bigint;
196
201
  activeEscrowCount: number;
197
202
  totalAgentsRegistered: number;
198
203
  activeAgentsCount: number;
package/dist/react.js CHANGED
@@ -214,6 +214,11 @@ query protocolStats($id: String! = "mainnet") {
214
214
  totalAgentsRegistered
215
215
  activeAgentsCount
216
216
  }
217
+ agents(where: { isActive: true }, limit: 1000) {
218
+ items {
219
+ stablecoinStake
220
+ }
221
+ }
217
222
  }
218
223
  `;
219
224
  var TRANSACTION_LOGS_QUERY = `
@@ -347,14 +352,21 @@ function createAgentsDomain(baseUrl) {
347
352
 
348
353
  // src/domains/protocol-stats.ts
349
354
  var DEFAULT_STATS_ID = "mainnet";
350
- function normalizeProtocolStats(raw) {
355
+ function normalizeProtocolStats(raw, activeAgents) {
356
+ const escrowTVL = BigInt(raw.currentTVL);
357
+ const agentStakingTVL = activeAgents.reduce(
358
+ (sum, a) => sum + BigInt(a.stablecoinStake),
359
+ 0n
360
+ );
351
361
  return {
352
362
  id: raw.id,
353
363
  chainId: raw.chainId,
354
364
  totalEscrowsCreated: raw.totalEscrowsCreated,
355
365
  totalVolumeEscrowed: BigInt(raw.totalVolumeEscrowed),
356
366
  totalFeesCollected: BigInt(raw.totalFeesCollected),
357
- currentTVL: BigInt(raw.currentTVL),
367
+ currentTVL: escrowTVL + agentStakingTVL,
368
+ escrowTVL,
369
+ agentStakingTVL,
358
370
  activeEscrowCount: raw.activeEscrowCount,
359
371
  totalAgentsRegistered: raw.totalAgentsRegistered,
360
372
  activeAgentsCount: raw.activeAgentsCount
@@ -371,7 +383,7 @@ function createProtocolStatsDomain(baseUrl) {
371
383
  if (!response.protocolStats) {
372
384
  return null;
373
385
  }
374
- return normalizeProtocolStats(response.protocolStats);
386
+ return normalizeProtocolStats(response.protocolStats, response.agents?.items ?? []);
375
387
  }
376
388
  async function getRaw(options) {
377
389
  const variables = { id: options?.statsId ?? DEFAULT_STATS_ID };
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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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,CA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BAAiB,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 totalEscrowsAssigned\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 totalEscrowsAssigned\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 chainId\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 chainId\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 agents(where: { isActive: true }, limit: 1000) {\n items {\n stablecoinStake\n }\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 /** True TVL = escrowTVL + agentStakingTVL */\n currentTVL: bigint;\n /** TVL held in active escrow contracts only */\n escrowTVL: bigint;\n /** TVL held as agent stablecoin collateral in the registry */\n agentStakingTVL: bigint;\n activeEscrowCount: number;\n totalAgentsRegistered: number;\n activeAgentsCount: number;\n}\n\n/**\n * Convert raw GraphQL response to normalized ProtocolStats\n */\nfunction normalizeProtocolStats(\n raw: GqlProtocolStats,\n activeAgents: Array<{ stablecoinStake: string | number | bigint }>,\n): ProtocolStats {\n const escrowTVL = BigInt(raw.currentTVL);\n const agentStakingTVL = activeAgents.reduce(\n (sum, a) => sum + BigInt(a.stablecoinStake),\n 0n,\n );\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: escrowTVL + agentStakingTVL,\n escrowTVL,\n agentStakingTVL,\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, response.agents?.items ?? []);\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,OA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C,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenland/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Official SDK for interacting with the Zenland escrow protocol indexer",
5
5
  "license": "MIT",
6
6
  "author": "Zenland",