@secondlayer/sdk 6.9.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.d.ts +67 -1
- package/dist/index.js +173 -12
- package/dist/index.js.map +9 -8
- package/dist/streams/index.d.ts +36 -1
- package/dist/streams/index.js +166 -12
- package/dist/streams/index.js.map +7 -6
- package/dist/subgraphs/index.d.ts +30 -0
- package/dist/subgraphs/index.js +166 -12
- package/dist/subgraphs/index.js.map +7 -6
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/api-keys/client.ts", "../src/contracts/client.ts", "../src/datasets/client.ts", "../src/index-api/client.ts", "../src/streams/client.ts", "../src/streams/errors.ts", "../src/streams/cursor.ts", "../src/streams/consumer.ts", "../src/streams/dumps.ts", "../src/subscriptions/client.ts", "../src/client.ts", "../src/subgraphs/get-subgraph.ts"],
|
|
3
|
+
"sources": ["../src/errors.ts", "../src/base.ts", "../src/subgraphs/serialize.ts", "../src/subgraphs/client.ts", "../src/api-keys/client.ts", "../src/contracts/client.ts", "../src/datasets/client.ts", "../src/index-api/client.ts", "../src/streams/client.ts", "../src/streams/errors.ts", "../src/streams/cursor.ts", "../src/streams/consumer.ts", "../src/streams/dumps.ts", "../src/streams/subscribe.ts", "../src/subscriptions/client.ts", "../src/client.ts", "../src/subgraphs/get-subgraph.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Error thrown by {@link SecondLayer} when an API request fails.\n * Includes the HTTP status code for programmatic error handling.\n *\n * @example\n * ```ts\n * try {\n * await client.subgraphs.get(\"my-subgraph\");\n * } catch (err) {\n * if (err instanceof ApiError && err.status === 404) {\n * console.log(\"Subgraph not found\");\n * }\n * }\n * ```\n */\nexport class ApiError extends Error {\n\tconstructor(\n\t\t/** HTTP status code (0 for network errors). */\n\t\tpublic status: number,\n\t\tmessage: string,\n\t\t/** Raw response body (parsed JSON if possible) — preserved for callers that need error details. */\n\t\tpublic body?: unknown,\n\t\t/** Stable machine-readable code from the API's `{error, code}` error envelope. */\n\t\tpublic code?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t}\n}\n\n/**\n * Thrown on optimistic-concurrency conflict when a deploy supplies an\n * `expectedVersion` that no longer matches the server's stored version.\n */\nexport class VersionConflictError extends ApiError {\n\tconstructor(\n\t\tpublic currentVersion: string,\n\t\tpublic expectedVersion: string,\n\t\tmessage = `Version conflict: expected ${expectedVersion}, current ${currentVersion}`,\n\t) {\n\t\tsuper(409, message, { currentVersion, expectedVersion });\n\t\tthis.name = \"VersionConflictError\";\n\t}\n}\n",
|
|
6
6
|
"import { ApiError } from \"./errors.ts\";\n\nexport type FetchLike = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit,\n) => Promise<Response>;\n\nexport interface SecondLayerOptions {\n\t/** Base URL of the Secondlayer platform API (trailing slashes are stripped). */\n\tbaseUrl: string;\n\t/** Bearer token for authenticated requests. */\n\tapiKey?: string;\n\t/** Fetch implementation. Tests and edge runtimes can provide their own. */\n\tfetchImpl?: FetchLike;\n\t/** Deploy origin label sent as `x-sl-origin` (telemetry). Defaults to `cli`. */\n\torigin?: \"cli\" | \"mcp\" | \"session\";\n}\n\nconst DEFAULT_BASE_URL = \"https://api.secondlayer.tools\";\n\n/** Build a query-string suffix from name→value pairs. Skips null/undefined and\n * empty values; arrays are comma-joined. Returns \"\" (never a dangling \"?\") or\n * \"?a=1&b=2\" — the one canonical builder every list endpoint shares, so the\n * empty-query guard can't be forgotten per call site. */\nexport function buildQuery(\n\tparams: Record<\n\t\tstring,\n\t\tnumber | string | readonly string[] | null | undefined\n\t>,\n): string {\n\tconst search = new URLSearchParams();\n\tfor (const [name, value] of Object.entries(params)) {\n\t\tif (value === undefined || value === null) continue;\n\t\tconst serialized = Array.isArray(value) ? value.join(\",\") : String(value);\n\t\tif (serialized.length === 0) continue;\n\t\tsearch.set(name, serialized);\n\t}\n\tconst query = search.toString();\n\treturn query ? `?${query}` : \"\";\n}\n\nexport abstract class BaseClient {\n\tprotected baseUrl: string;\n\tprotected apiKey?: string;\n\tprotected origin: \"cli\" | \"mcp\" | \"session\";\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tthis.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n\t\tthis.apiKey = options.apiKey;\n\t\tthis.origin = options.origin ?? \"cli\";\n\t}\n\n\tstatic authHeaders(apiKey?: string): Record<string, string> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t};\n\t\tif (apiKey) {\n\t\t\theaders.Authorization = `Bearer ${apiKey}`;\n\t\t}\n\t\treturn headers;\n\t}\n\n\tprotected async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<T> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\tif (response.status === 204) {\n\t\t\treturn undefined as T;\n\t\t}\n\t\treturn response.json() as Promise<T>;\n\t}\n\n\tprotected async requestText(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<string> {\n\t\tconst response = await this.fetchResponse(method, path, body);\n\t\treturn response.text();\n\t}\n\n\tprivate async fetchResponse(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody?: unknown,\n\t): Promise<Response> {\n\t\tconst url = `${this.baseUrl}${path}`;\n\t\tconst headers = BaseClient.authHeaders(this.apiKey);\n\t\theaders[\"x-sl-origin\"] = this.origin;\n\n\t\t// Serialize the body BEFORE the network try so a body-encoding error\n\t\t// (e.g. unsupported BigInt) isn't misreported as \"Cannot reach API\".\n\t\t// BigInts are stringified — server schemas accept jsonb so the value\n\t\t// reaches the server intact, and any field that needs an actual bigint\n\t\t// at runtime is rehydrated by the consuming module (subgraph handler\n\t\t// code preserves the literal). See packages/subgraphs source-matcher\n\t\t// for the post-load shape.\n\t\tlet serializedBody: string | undefined;\n\t\tif (body !== undefined && body !== null) {\n\t\t\ttry {\n\t\t\t\tserializedBody = JSON.stringify(body, (_key, value) =>\n\t\t\t\t\ttypeof value === \"bigint\" ? value.toString() : value,\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tconst detail = err instanceof Error ? err.message : String(err);\n\t\t\t\tthrow new ApiError(0, `Failed to serialize request body: ${detail}`);\n\t\t\t}\n\t\t}\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await fetch(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tbody: serializedBody,\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new ApiError(\n\t\t\t\t0,\n\t\t\t\t`Cannot reach API at ${this.baseUrl}. Check your connection or try again.`,\n\t\t\t);\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 401) {\n\t\t\t\tthrow new ApiError(401, \"API key invalid or expired.\");\n\t\t\t}\n\n\t\t\tif (response.status === 429) {\n\t\t\t\tconst retryAfter = response.headers.get(\"Retry-After\");\n\t\t\t\tconst msg = retryAfter\n\t\t\t\t\t? `Rate limited. Wait ${retryAfter} seconds.`\n\t\t\t\t\t: \"Rate limited. Try again later.\";\n\t\t\t\tthrow new ApiError(429, msg);\n\t\t\t}\n\n\t\t\tif (response.status >= 500) {\n\t\t\t\tthrow new ApiError(\n\t\t\t\t\tresponse.status,\n\t\t\t\t\t`Server error. Try again or check status at ${this.baseUrl}/health`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst errorBody = await response.text();\n\t\t\tlet message = `HTTP ${response.status}`;\n\t\t\tlet parsedBody: unknown = errorBody;\n\t\t\tlet code: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst json = JSON.parse(errorBody);\n\t\t\t\tparsedBody = json;\n\t\t\t\tconst err = json.error ?? json.message;\n\t\t\t\tif (typeof err === \"string\") {\n\t\t\t\t\tmessage = err;\n\t\t\t\t} else if (err && typeof err === \"object\") {\n\t\t\t\t\tmessage = JSON.stringify(err);\n\t\t\t\t}\n\t\t\t\tif (typeof json.code === \"string\") {\n\t\t\t\t\tcode = json.code;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tif (errorBody) message = errorBody;\n\t\t\t}\n\t\t\tthrow new ApiError(response.status, message, parsedBody, code);\n\t\t}\n\n\t\treturn response;\n\t}\n}\n",
|
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
"import { BaseClient, type SecondLayerOptions } from \"../base.ts\";\n\n/**\n * Typed client for the agent-reachable key mint (`POST /v1/api-keys`).\n *\n * Lets a headless agent self-provision a SCOPED `streams`/`index` read key\n * without the dashboard. Requires an owner credential — an account-level API\n * key (or a dashboard session). The minted key is always scoped (never an\n * account/superkey) and inherits the account plan's tier.\n */\n\n/** Scope of a minted read key. */\nexport type ScopedKeyProduct = \"streams\" | \"index\";\n\nexport interface CreateApiKeyParams {\n\t/** Scope of the minted key. Defaults to \"streams\". */\n\tproduct?: ScopedKeyProduct;\n\t/** Optional human-readable label for the key. */\n\tname?: string;\n}\n\nexport interface CreateApiKeyResponse {\n\t/** Plaintext key — returned ONCE. Store it now; only its hash is persisted. */\n\tkey: string;\n\tprefix: string;\n\tid: string;\n\tproduct: string;\n\ttier: string | null;\n\tcreatedAt: string;\n}\n\nexport class ApiKeys extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/**\n\t * Mint a new scoped read key. The configured `apiKey` must be an\n\t * account-level (owner) key; the plaintext `key` in the response is shown\n\t * only once.\n\t */\n\tcreate(params: CreateApiKeyParams = {}): Promise<CreateApiKeyResponse> {\n\t\treturn this.request<CreateApiKeyResponse>(\"POST\", \"/v1/api-keys\", {\n\t\t\tproduct: params.product,\n\t\t\tname: params.name,\n\t\t});\n\t}\n}\n",
|
|
10
10
|
"import { BaseClient, type SecondLayerOptions, buildQuery } from \"../base.ts\";\n\n/**\n * Typed client for the contract-discovery API (`GET /v1/contracts`).\n *\n * \"Find all contracts conforming to a trait\" — backed by the contract registry:\n * `declared` traits parsed from Clarity source, `inferred` standards from static\n * ABI shape-matching. Anonymous public read. `trait` is required; the ABI blob is\n * omitted unless `include: \"abi\"` is passed.\n */\n\n/** Whether a trait match must be declared in source, inferred from ABI, or either. */\nexport type ContractConformance = \"declared\" | \"inferred\" | \"any\";\n\nexport interface ContractsListParams {\n\t/** Required. Trait identifier to match (e.g. \"sip-010\", or a fully-qualified trait). */\n\ttrait: string;\n\t/** Match source. Defaults to \"any\" server-side. */\n\tconformance?: ContractConformance;\n\t/** Set to \"abi\" to include the full ABI blob in each row. */\n\tinclude?: \"abi\";\n\t/** Page size, 1–500 (default 100 server-side). */\n\tlimit?: number;\n\t/** Opaque cursor from a prior response's `next_cursor`. */\n\tcursor?: string;\n}\n\nexport interface ContractSummary {\n\tcontract_id: string;\n\tdeployer: string;\n\tblock_height: number;\n\tdeclared_traits: string[] | null;\n\tinferred_standards: string[] | null;\n\tabi_status: string;\n\t/** Present only when `include: \"abi\"` was requested. */\n\tabi?: unknown;\n}\n\nexport interface ContractsEnvelope {\n\tcontracts: ContractSummary[];\n\tnext_cursor: string | null;\n}\n\nexport class Contracts extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */\n\tlist(params: ContractsListParams): Promise<ContractsEnvelope> {\n\t\treturn this.request<ContractsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/contracts${buildQuery({\n\t\t\t\ttrait: params.trait,\n\t\t\t\tconformance: params.conformance,\n\t\t\t\tinclude: params.include,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcursor: params.cursor,\n\t\t\t})}`,\n\t\t);\n\t}\n}\n",
|
|
11
11
|
"import { BaseClient, type SecondLayerOptions, buildQuery } from \"../base.ts\";\n\n/**\n * Typed client for the Foundation Datasets REST API (`/v1/datasets/*`).\n *\n * Most datasets are cursor-paginated event lists with a uniform `list`/`walk`\n * surface; a few (bns names/namespaces/resolve, network-health) are\n * offset/single-object/summary and get bespoke methods. Query params are typed\n * per dataset; rows are `DatasetRow` (JSON) in v1 — per-dataset row interfaces\n * are a fast-follow.\n */\n\n/** A dataset row — flat JSON object. Per-dataset interfaces are a follow-up. */\nexport type DatasetRow = Record<string, unknown>;\n\n/** Filters shared by every cursor-paginated dataset. */\nexport interface CursorListParams {\n\tcursor?: string;\n\tlimit?: number;\n\tfromBlock?: number;\n\ttoBlock?: number;\n}\n\nexport interface CursorEnvelope {\n\trows: DatasetRow[];\n\tnext_cursor: string | null;\n\ttip?: { block_height: number };\n}\n\nexport interface CursorWalkParams extends CursorListParams {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n}\n\n// Per-dataset filter params (precise — drives CLI flags + autocomplete).\ntype RangeFilters = CursorListParams;\nexport type StxTransfersParams = RangeFilters & {\n\tsender?: string;\n\trecipient?: string;\n};\nexport type SbtcEventsParams = RangeFilters & {\n\ttopic?: string;\n\taddress?: string;\n};\nexport type SbtcTokenEventsParams = RangeFilters & {\n\teventType?: string;\n\tsender?: string;\n\trecipient?: string;\n};\nexport type Pox4CallsParams = RangeFilters & {\n\tfunctionName?: string;\n\tstacker?: string;\n\tdelegateTo?: string;\n\tsignerKey?: string;\n\trewardCycle?: number;\n\t/** Any-role: matches caller OR stacker OR delegate_to. */\n\taddress?: string;\n};\nexport type BurnchainRewardsParams = RangeFilters & {\n\t/** Filter to one Bitcoin reward address. */\n\trecipient?: string;\n};\nexport type BurnchainRewardSlotsParams = RangeFilters & {\n\t/** Filter to one reward-set Bitcoin address. */\n\tholder?: string;\n};\nexport type BnsEventsParams = RangeFilters & {\n\ttopic?: string;\n\tnamespace?: string;\n\tname?: string;\n\towner?: string;\n};\nexport type BnsNamespaceEventsParams = RangeFilters & {\n\tstatus?: string;\n\tnamespace?: string;\n};\nexport type BnsMarketplaceEventsParams = RangeFilters & {\n\taction?: string;\n\tbnsId?: string;\n};\n\ntype CursorDataset<P> = {\n\tlist: (params?: P) => Promise<CursorEnvelope>;\n\twalk: (\n\t\tparams?: P & { batchSize?: number; signal?: AbortSignal },\n\t) => AsyncIterable<DatasetRow>;\n};\n\n/** snake_case query keys for the camelCase param fields. */\nconst PARAM_KEYS: Record<string, string> = {\n\tfromBlock: \"from_block\",\n\ttoBlock: \"to_block\",\n\tfunctionName: \"function_name\",\n\tdelegateTo: \"delegate_to\",\n\tsignerKey: \"signer_key\",\n\trewardCycle: \"reward_cycle\",\n\teventType: \"event_type\",\n\tbnsId: \"bns_id\",\n};\n\n/** Cursor-paginated dataset slugs → REST path + envelope row key. */\nexport const CURSOR_SLUGS: Record<string, { path: string; rowKey: string }> = {\n\t\"stx-transfers\": { path: \"stx-transfers\", rowKey: \"events\" },\n\t\"sbtc-events\": { path: \"sbtc/events\", rowKey: \"events\" },\n\t\"sbtc-token-events\": { path: \"sbtc/token-events\", rowKey: \"events\" },\n\t\"pox-4-calls\": { path: \"pox-4/calls\", rowKey: \"calls\" },\n\t\"burnchain-rewards\": { path: \"burnchain/rewards\", rowKey: \"rewards\" },\n\t\"burnchain-reward-slots\": {\n\t\tpath: \"burnchain/reward-slots\",\n\t\trowKey: \"slots\",\n\t},\n\t\"bns-events\": { path: \"bns/events\", rowKey: \"events\" },\n\t\"bns-namespace-events\": { path: \"bns/namespace-events\", rowKey: \"events\" },\n\t\"bns-marketplace-events\": {\n\t\tpath: \"bns/marketplace-events\",\n\t\trowKey: \"events\",\n\t},\n};\n\nexport class Datasets extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Dataset catalog + freshness (the discovery endpoint). */\n\tlistDatasets(): Promise<unknown> {\n\t\treturn this.request(\"GET\", \"/v1/datasets\");\n\t}\n\n\t/**\n\t * Generic cursor query by slug — used by the CLI. Params are passed through as\n\t * REST query keys (snake_case), so callers can use the documented filter names\n\t * directly. Throws for non-cursor (bespoke) datasets.\n\t */\n\tasync query(\n\t\tslug: string,\n\t\tparams: Record<string, unknown> = {},\n\t): Promise<CursorEnvelope> {\n\t\tconst d = CURSOR_SLUGS[slug];\n\t\tif (!d) {\n\t\t\tthrow new Error(\n\t\t\t\t`unknown cursor dataset \"${slug}\" (use one of: ${Object.keys(CURSOR_SLUGS).join(\", \")})`,\n\t\t\t);\n\t\t}\n\t\tconst env = await this.get<Record<string, unknown>>(\n\t\t\td.path,\n\t\t\tthis.paramsToQuery(params),\n\t\t);\n\t\treturn {\n\t\t\trows: (env[d.rowKey] as DatasetRow[]) ?? [],\n\t\t\tnext_cursor: (env.next_cursor as string | null) ?? null,\n\t\t\ttip: env.tip as { block_height: number } | undefined,\n\t\t};\n\t}\n\n\treadonly stxTransfers: CursorDataset<StxTransfersParams> =\n\t\tthis.cursorDataset<StxTransfersParams>(\"stx-transfers\", \"events\");\n\treadonly sbtcEvents: CursorDataset<SbtcEventsParams> =\n\t\tthis.cursorDataset<SbtcEventsParams>(\"sbtc/events\", \"events\");\n\treadonly sbtcTokenEvents: CursorDataset<SbtcTokenEventsParams> =\n\t\tthis.cursorDataset<SbtcTokenEventsParams>(\"sbtc/token-events\", \"events\");\n\treadonly pox4Calls: CursorDataset<Pox4CallsParams> =\n\t\tthis.cursorDataset<Pox4CallsParams>(\"pox-4/calls\", \"calls\");\n\treadonly burnchainRewards: CursorDataset<BurnchainRewardsParams> =\n\t\tthis.cursorDataset<BurnchainRewardsParams>(\"burnchain/rewards\", \"rewards\");\n\treadonly burnchainRewardSlots: CursorDataset<BurnchainRewardSlotsParams> =\n\t\tthis.cursorDataset<BurnchainRewardSlotsParams>(\n\t\t\t\"burnchain/reward-slots\",\n\t\t\t\"slots\",\n\t\t);\n\treadonly bnsEvents: CursorDataset<BnsEventsParams> =\n\t\tthis.cursorDataset<BnsEventsParams>(\"bns/events\", \"events\");\n\treadonly bnsNamespaceEvents: CursorDataset<BnsNamespaceEventsParams> =\n\t\tthis.cursorDataset<BnsNamespaceEventsParams>(\n\t\t\t\"bns/namespace-events\",\n\t\t\t\"events\",\n\t\t);\n\treadonly bnsMarketplaceEvents: CursorDataset<BnsMarketplaceEventsParams> =\n\t\tthis.cursorDataset<BnsMarketplaceEventsParams>(\n\t\t\t\"bns/marketplace-events\",\n\t\t\t\"events\",\n\t\t);\n\n\t// ── Bespoke (non-cursor) datasets ──────────────────────────────────────\n\n\t/** BNS names — offset-paginated. */\n\tbnsNames(\n\t\tparams: {\n\t\t\tnamespace?: string;\n\t\t\towner?: string;\n\t\t\tlimit?: number;\n\t\t\toffset?: number;\n\t\t} = {},\n\t): Promise<{ names: DatasetRow[] }> {\n\t\treturn this.get(\n\t\t\t\"bns/names\",\n\t\t\tbuildQuery({\n\t\t\t\tnamespace: params.namespace,\n\t\t\t\towner: params.owner,\n\t\t\t\tlimit: params.limit,\n\t\t\t\toffset: params.offset,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** All BNS namespaces (no pagination). */\n\tbnsNamespaces(): Promise<{ namespaces: DatasetRow[] }> {\n\t\treturn this.get(\"bns/namespaces\", \"\");\n\t}\n\n\t/** Resolve a fully-qualified BNS name → single record. */\n\tbnsResolve(fqn: string): Promise<{ name: DatasetRow | null }> {\n\t\treturn this.get(\"bns/resolve\", buildQuery({ fqn }));\n\t}\n\n\t/** Network health summary. */\n\tnetworkHealth(): Promise<{ summary: DatasetRow }> {\n\t\treturn this.get(\"network-health/summary\", \"\");\n\t}\n\n\t// ── internals ──────────────────────────────────────────────────────────\n\n\tprivate get<T>(path: string, query: string): Promise<T> {\n\t\treturn this.request<T>(\"GET\", `/v1/datasets/${path}${query}`);\n\t}\n\n\t/** Map camelCase filter fields to snake_case query keys (dropping pagination\n\t * controls) and build the canonical query suffix. */\n\tprivate paramsToQuery(params: Record<string, unknown>): string {\n\t\tconst mapped: Record<string, number | string | null | undefined> = {};\n\t\tfor (const [k, v] of Object.entries(params)) {\n\t\t\tif (v === undefined || v === null || k === \"batchSize\" || k === \"signal\")\n\t\t\t\tcontinue;\n\t\t\tmapped[PARAM_KEYS[k] ?? k] = v as string | number;\n\t\t}\n\t\treturn buildQuery(mapped);\n\t}\n\n\tprivate cursorDataset<P extends CursorListParams>(\n\t\tpath: string,\n\t\trowKey: string,\n\t): CursorDataset<P> {\n\t\tconst list = async (params: P = {} as P): Promise<CursorEnvelope> => {\n\t\t\tconst envelope = await this.get<Record<string, unknown>>(\n\t\t\t\tpath,\n\t\t\t\tthis.paramsToQuery(params as Record<string, unknown>),\n\t\t\t);\n\t\t\treturn {\n\t\t\t\trows: (envelope[rowKey] as DatasetRow[]) ?? [],\n\t\t\t\tnext_cursor: (envelope.next_cursor as string | null) ?? null,\n\t\t\t\ttip: envelope.tip as { block_height: number } | undefined,\n\t\t\t};\n\t\t};\n\t\tconst walk = async function* (\n\t\t\tthis: Datasets,\n\t\t\tparams: P & { batchSize?: number; signal?: AbortSignal } = {} as P,\n\t\t): AsyncGenerator<DatasetRow> {\n\t\t\tconst batchSize = params.batchSize ?? 200;\n\t\t\tlet cursor = params.cursor ?? null;\n\t\t\tlet first = true;\n\t\t\twhile (!params.signal?.aborted) {\n\t\t\t\tconst env = await list({\n\t\t\t\t\t...params,\n\t\t\t\t\tlimit: batchSize,\n\t\t\t\t\tcursor: first ? params.cursor : (cursor ?? undefined),\n\t\t\t\t} as P);\n\t\t\t\tfor (const row of env.rows) {\n\t\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\t\tyield row;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!env.next_cursor ||\n\t\t\t\t\tenv.next_cursor === cursor ||\n\t\t\t\t\tenv.rows.length < batchSize\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tcursor = env.next_cursor;\n\t\t\t\tfirst = false;\n\t\t\t}\n\t\t}.bind(this);\n\t\treturn { list, walk };\n\t}\n}\n",
|
|
12
|
-
"import { BaseClient, buildQuery } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\tlag_seconds: number;\n};\n\nexport type IndexUsage = {\n\tproduct: \"index\";\n\ttier: string;\n\tlimits: { rate_limit_per_second: number | null };\n\tusage: { decoded_events_today: number; decoded_events_this_month: number };\n};\n\nexport type FtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Generic decoded events (/v1/index/events) ──────────────────────\n\ntype IndexEventBase = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tcontract_id: string | null;\n};\n\nexport type IndexFtTransfer = IndexEventBase & {\n\tevent_type: \"ft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexNftTransfer = IndexEventBase & {\n\tevent_type: \"nft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexStxTransfer = IndexEventBase & {\n\tevent_type: \"stx_transfer\";\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\nexport type IndexStxMint = IndexEventBase & {\n\tevent_type: \"stx_mint\";\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexStxBurn = IndexEventBase & {\n\tevent_type: \"stx_burn\";\n\tsender: string;\n\tamount: string;\n};\nexport type IndexStxLock = IndexEventBase & {\n\tevent_type: \"stx_lock\";\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\nexport type IndexFtMint = IndexEventBase & {\n\tevent_type: \"ft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexFtBurn = IndexEventBase & {\n\tevent_type: \"ft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tamount: string;\n};\nexport type IndexNftMint = IndexEventBase & {\n\tevent_type: \"nft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexNftBurn = IndexEventBase & {\n\tevent_type: \"nft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tvalue: string;\n};\nexport type IndexPrint = IndexEventBase & {\n\tevent_type: \"print\";\n\tpayload: { topic: string | null; value: unknown; raw_value: string | null };\n};\n\n/** Decoded chain event, discriminated by `event_type`. */\nexport type IndexEvent =\n\t| IndexFtTransfer\n\t| IndexNftTransfer\n\t| IndexStxTransfer\n\t| IndexStxMint\n\t| IndexStxBurn\n\t| IndexStxLock\n\t| IndexFtMint\n\t| IndexFtBurn\n\t| IndexNftMint\n\t| IndexNftBurn\n\t| IndexPrint;\n\nexport type IndexEventType = IndexEvent[\"event_type\"];\n\nexport type EventsEnvelope = {\n\tevents: IndexEvent[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type EventsListParams = {\n\t/** Required. One of the decoded event types. */\n\teventType: IndexEventType;\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type EventsWalkParams = Omit<EventsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Contract calls (/v1/index/contract-calls) ──────────────────────\n\nexport type IndexContractCall = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tcontract_id: string;\n\tfunction_name: string;\n\tsender: string;\n\tstatus: string;\n\targs: unknown[];\n\tresult: unknown;\n\tresult_hex: string | null;\n};\n\nexport type ContractCallsEnvelope = {\n\tcontract_calls: IndexContractCall[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type ContractCallsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tfunctionName?: string;\n\tsender?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type ContractCallsWalkParams = Omit<ContractCallsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Canonical block-hash map (/v1/index/canonical) ─────────────────\n\n/** One canonical block in the sync map. Lean by design — block + parent hash\n * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for\n * the full block resource. */\nexport type IndexCanonicalBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n};\n\nexport type CanonicalEnvelope = {\n\tcanonical: IndexCanonicalBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type CanonicalListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type CanonicalWalkParams = Omit<CanonicalListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Blocks (/v1/index/blocks) ──────────────────────────────────────\n\n/** A block resource. Metadata is intentionally thin — only chain-linkage and\n * burn-anchor fields are persisted (no miner / tx_count / signer). */\nexport type IndexBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tblock_time: string | null;\n\tcanonical: boolean;\n};\n\nexport type BlocksEnvelope = {\n\tblocks: IndexBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type BlockEnvelope = {\n\tblock: IndexBlock;\n\ttip: IndexTip;\n};\n\nexport type BlocksListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type BlocksWalkParams = Omit<BlocksListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Transactions (/v1/index/transactions) ──────────────────────────\n\nexport type IndexPostCondition =\n\t| {\n\t\t\ttype: \"stx\";\n\t\t\tprincipal: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"ft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"nft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tasset_value: unknown;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t };\n\n/** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.\n * Payload sub-objects are present only for the matching `tx_type`; enrichment\n * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */\nexport type IndexTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_index: number;\n\ttx_type: string;\n\tsender: string;\n\tstatus: string;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t\t/** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */\n\t\tfunction_args_hex: string[];\n\t\tresult: unknown;\n\t\tresult_hex: string | null;\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: {\n\t\tcontract_id: string | null;\n\t\tclarity_version: number | null;\n\t};\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type TransactionsEnvelope = {\n\ttransactions: IndexTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type TransactionEnvelope = {\n\ttransaction: IndexTransaction;\n\ttip: IndexTip;\n};\n\nexport type TransactionsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\ttype?: string;\n\tsender?: string;\n\tcontractId?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type TransactionsWalkParams = Omit<TransactionsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Stacking (/v1/index/stacking) ──────────────────────────────────\n\n/** A decoded PoX-4 stacking action (one per stacking contract call). */\nexport type IndexStackingAction = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tfunction_name: string;\n\tcaller: string;\n\tstacker: string | null;\n\tdelegate_to: string | null;\n\tamount_ustx: string | null;\n\tlock_period: number | null;\n\tpox_addr: {\n\t\tversion: number | null;\n\t\thashbytes: string | null;\n\t\tbtc: string | null;\n\t};\n\tstart_cycle: number | null;\n\tend_cycle: number | null;\n\treward_cycle: number | null;\n\tsigner_key: string | null;\n\tresult_ok: boolean;\n};\n\nexport type StackingEnvelope = {\n\tstacking: IndexStackingAction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */\n\tnotes?: string;\n};\n\nexport type StackingListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfunctionName?: string;\n\tstacker?: string;\n\tcaller?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type StackingWalkParams = Omit<StackingListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Mempool (/v1/index/mempool) ────────────────────────────────────\n\n/** A pending (unconfirmed) transaction. Like a transaction document but\n * pre-chain — no block_height/tx_index/result/events — with `received_at` and\n * a sequence cursor instead of a block position. */\nexport type IndexMempoolTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\ttx_type: string;\n\tsender: string;\n\treceived_at?: string | null;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: { clarity_version: number | null };\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type MempoolEnvelope = {\n\tmempool: IndexMempoolTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type MempoolTransactionEnvelope = {\n\ttransaction: IndexMempoolTransaction;\n\ttip: IndexTip;\n};\n\nexport type MempoolListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tsender?: string;\n\ttype?: string;\n\t/** Filter to pending calls to a single contract (e.g. `SP….contract`). */\n\tcontractId?: string;\n};\n\nexport type MempoolWalkParams = Omit<MempoolListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Your own Index consumption (decoded events today + this month) and tier limits. */\n\tusage(): Promise<IndexUsage> {\n\t\treturn this.request<IndexUsage>(\"GET\", \"/v1/index/usage\");\n\t}\n\n\treadonly ftTransfers: {\n\t\tlist: (params?: FtTransfersListParams) => Promise<FtTransfersEnvelope>;\n\t\twalk: (params?: FtTransfersWalkParams) => AsyncIterable<FtTransfer>;\n\t} = {\n\t\tlist: (params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\tthis.walkFtTransfers(params),\n\t};\n\n\treadonly nftTransfers: {\n\t\tlist: (params?: NftTransfersListParams) => Promise<NftTransfersEnvelope>;\n\t\twalk: (params?: NftTransfersWalkParams) => AsyncIterable<NftTransfer>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: NftTransfersListParams = {},\n\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\tthis.walkNftTransfers(params),\n\t};\n\n\t/** Generic decoded events by `event_type` (the full /v1/index/events surface). */\n\treadonly events: {\n\t\tlist: (params: EventsListParams) => Promise<EventsEnvelope>;\n\t\twalk: (params: EventsWalkParams) => AsyncIterable<IndexEvent>;\n\t} = {\n\t\tlist: (params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\tthis.listEvents(params),\n\t\twalk: (params: EventsWalkParams): AsyncIterable<IndexEvent> =>\n\t\t\tthis.walkEvents(params),\n\t};\n\n\treadonly contractCalls: {\n\t\tlist: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;\n\t\twalk: (\n\t\t\tparams?: ContractCallsWalkParams,\n\t\t) => AsyncIterable<IndexContractCall>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: ContractCallsListParams = {},\n\t\t): Promise<ContractCallsEnvelope> => this.listContractCalls(params),\n\t\twalk: (\n\t\t\tparams: ContractCallsWalkParams = {},\n\t\t): AsyncIterable<IndexContractCall> => this.walkContractCalls(params),\n\t};\n\n\t/** Canonical block-hash map — sync only the current canonical chain. */\n\treadonly canonical: {\n\t\tlist: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;\n\t\twalk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;\n\t} = {\n\t\tlist: (params: CanonicalListParams = {}): Promise<CanonicalEnvelope> =>\n\t\t\tthis.listCanonical(params),\n\t\twalk: (\n\t\t\tparams: CanonicalWalkParams = {},\n\t\t): AsyncIterable<IndexCanonicalBlock> => this.walkCanonical(params),\n\t};\n\n\t/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash\n\t * (resolves to null on 404). */\n\treadonly blocks: {\n\t\tlist: (params?: BlocksListParams) => Promise<BlocksEnvelope>;\n\t\twalk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;\n\t\tget: (ref: string | number) => Promise<BlockEnvelope | null>;\n\t} = {\n\t\tlist: (params: BlocksListParams = {}): Promise<BlocksEnvelope> =>\n\t\t\tthis.listBlocks(params),\n\t\twalk: (params: BlocksWalkParams = {}): AsyncIterable<IndexBlock> =>\n\t\t\tthis.walkBlocks(params),\n\t\tget: (ref: string | number): Promise<BlockEnvelope | null> =>\n\t\t\tthis.getBlock(ref),\n\t};\n\n\t/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id\n\t * (resolves to null on 404). */\n\treadonly transactions: {\n\t\tlist: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>;\n\t\twalk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;\n\t\tget: (txId: string) => Promise<TransactionEnvelope | null>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: TransactionsListParams = {},\n\t\t): Promise<TransactionsEnvelope> => this.listTransactions(params),\n\t\twalk: (\n\t\t\tparams: TransactionsWalkParams = {},\n\t\t): AsyncIterable<IndexTransaction> => this.walkTransactions(params),\n\t\tget: (txId: string): Promise<TransactionEnvelope | null> =>\n\t\t\tthis.getTransaction(txId),\n\t};\n\n\t/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the\n\t * platform's PoX-4 decoder is disabled. */\n\treadonly stacking: {\n\t\tlist: (params?: StackingListParams) => Promise<StackingEnvelope>;\n\t\twalk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;\n\t} = {\n\t\tlist: (params: StackingListParams = {}): Promise<StackingEnvelope> =>\n\t\t\tthis.listStacking(params),\n\t\twalk: (\n\t\t\tparams: StackingWalkParams = {},\n\t\t): AsyncIterable<IndexStackingAction> => this.walkStacking(params),\n\t};\n\n\t/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by\n\t * tx_id (resolves to null when the tx has confirmed or dropped). */\n\treadonly mempool: {\n\t\tlist: (params?: MempoolListParams) => Promise<MempoolEnvelope>;\n\t\twalk: (\n\t\t\tparams?: MempoolWalkParams,\n\t\t) => AsyncIterable<IndexMempoolTransaction>;\n\t\tget: (txId: string) => Promise<MempoolTransactionEnvelope | null>;\n\t} = {\n\t\tlist: (params: MempoolListParams = {}): Promise<MempoolEnvelope> =>\n\t\t\tthis.listMempool(params),\n\t\twalk: (\n\t\t\tparams: MempoolWalkParams = {},\n\t\t): AsyncIterable<IndexMempoolTransaction> => this.walkMempool(params),\n\t\tget: (txId: string): Promise<MempoolTransactionEnvelope | null> =>\n\t\t\tthis.getMempoolTx(txId),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listEvents(params: EventsListParams): Promise<EventsEnvelope> {\n\t\treturn this.request<EventsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/events${buildQuery({\n\t\t\t\tevent_type: params.eventType,\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkEvents(\n\t\tparams: EventsWalkParams,\n\t): AsyncGenerator<IndexEvent> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listEvents({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listContractCalls(\n\t\tparams: ContractCallsListParams = {},\n\t): Promise<ContractCallsEnvelope> {\n\t\treturn this.request<ContractCallsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/contract-calls${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tsender: params.sender,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkContractCalls(\n\t\tparams: ContractCallsWalkParams = {},\n\t): AsyncGenerator<IndexContractCall> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listContractCalls({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const call of envelope.contract_calls) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield call;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.contract_calls.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listCanonical(\n\t\tparams: CanonicalListParams = {},\n\t): Promise<CanonicalEnvelope> {\n\t\treturn this.request<CanonicalEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/canonical${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkCanonical(\n\t\tparams: CanonicalWalkParams = {},\n\t): AsyncGenerator<IndexCanonicalBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listCanonical({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.canonical) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.canonical.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listBlocks(\n\t\tparams: BlocksListParams = {},\n\t): Promise<BlocksEnvelope> {\n\t\treturn this.request<BlocksEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/blocks${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getBlock(ref: string | number): Promise<BlockEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<BlockEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/blocks/${encodeURIComponent(String(ref))}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkBlocks(\n\t\tparams: BlocksWalkParams = {},\n\t): AsyncGenerator<IndexBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listBlocks({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.blocks) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.blocks.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listTransactions(\n\t\tparams: TransactionsListParams = {},\n\t): Promise<TransactionsEnvelope> {\n\t\treturn this.request<TransactionsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/transactions${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\ttype: params.type,\n\t\t\t\tsender: params.sender,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getTransaction(\n\t\ttxId: string,\n\t): Promise<TransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkTransactions(\n\t\tparams: TransactionsWalkParams = {},\n\t): AsyncGenerator<IndexTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listTransactions({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.transactions) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.transactions.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listStacking(\n\t\tparams: StackingListParams = {},\n\t): Promise<StackingEnvelope> {\n\t\treturn this.request<StackingEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/stacking${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tstacker: params.stacker,\n\t\t\t\tcaller: params.caller,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkStacking(\n\t\tparams: StackingWalkParams = {},\n\t): AsyncGenerator<IndexStackingAction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listStacking({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const action of envelope.stacking) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield action;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.stacking.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listMempool(\n\t\tparams: MempoolListParams = {},\n\t): Promise<MempoolEnvelope> {\n\t\treturn this.request<MempoolEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/mempool${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tsender: params.sender,\n\t\t\t\ttype: params.type,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getMempoolTx(\n\t\ttxId: string,\n\t): Promise<MempoolTransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<MempoolTransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/mempool/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkMempool(\n\t\tparams: MempoolWalkParams = {},\n\t): AsyncGenerator<IndexMempoolTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listMempool({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.mempool) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.mempool.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
13
|
-
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport { createStreamsDumps } from \"./dumps.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tStreamsSignatureError,\n\tValidationError,\n} from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsReplayParams,\n\tStreamsEventsStreamParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n\tStreamsUsage,\n} from \"./types.ts\";\n\n/** Parse a `<block>:<index>` cursor; null sorts before genesis. */\nfunction cursorTuple(cursor: string | null): [number, number] {\n\tif (!cursor) return [-1, -1];\n\tconst parts = cursor.split(\":\");\n\tconst [block, index] = parts.map(Number);\n\tif (\n\t\tparts.length !== 2 ||\n\t\t!Number.isInteger(block) ||\n\t\t!Number.isInteger(index)\n\t) {\n\t\tthrow new ValidationError(\n\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t400,\n\t\t);\n\t}\n\treturn [block, index];\n}\n\n/** The greater of two cursors (later in the stream). */\nfunction maxCursor(a: string | null, b: string | null): string | null {\n\tconst [ah, ai] = cursorTuple(a);\n\tconst [bh, bi] = cursorTuple(b);\n\treturn ah > bh || (ah === bh && ai >= bi) ? a : b;\n}\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n\t/**\n\t * Public base URL for bulk parquet dumps (the R2/CDN bucket root). Required\n\t * to use `client.dumps`. See `GET /public/streams/dumps/manifest`.\n\t */\n\tdumpsBaseUrl?: string;\n\t/**\n\t * Verify the ed25519 `X-Signature` on every response (default off). Pass\n\t * `true` to fetch the server's public key from\n\t * `/public/streams/signing-key`, or `{ publicKey }` to pin a known PEM. A\n\t * failed or missing signature throws `StreamsSignatureError`.\n\t */\n\tverify?: boolean | { publicKey: string };\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\tconst verify = options.verify ?? false;\n\tconst dumps = createStreamsDumps({\n\t\tbaseUrl: options.dumpsBaseUrl,\n\t\tfetchImpl,\n\t});\n\n\t// Lazily resolve and cache the verification key alongside its id, so a\n\t// rotation (signalled by a changed `X-Signature-KeyId`) can be detected.\n\ttype VerificationKey = {\n\t\tkeyId: string;\n\t\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n\t};\n\tlet keyPromise: Promise<VerificationKey> | null = null;\n\tfunction loadKey(): Promise<VerificationKey> {\n\t\tif (keyPromise) return keyPromise;\n\t\tkeyPromise = (async () => {\n\t\t\tif (typeof verify === \"object\") {\n\t\t\t\treturn {\n\t\t\t\t\tkeyId: ed25519.ed25519KeyId(verify.publicKey),\n\t\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(verify.publicKey),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst res = await fetchImpl(`${baseUrl}/public/streams/signing-key`);\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t`Could not fetch signing key (${res.status}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst body = (await res.json()) as {\n\t\t\t\tpublic_key_pem?: string;\n\t\t\t\tkey_id?: string;\n\t\t\t};\n\t\t\tif (!body.public_key_pem) {\n\t\t\t\tthrow new StreamsSignatureError(\"Signing key response missing key.\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkeyId: body.key_id ?? ed25519.ed25519KeyId(body.public_key_pem),\n\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(body.public_key_pem),\n\t\t\t};\n\t\t})();\n\t\treturn keyPromise;\n\t}\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\tconst text = await response.text();\n\t\tif (verify) {\n\t\t\tconst signature = response.headers.get(\"X-Signature\");\n\t\t\tif (!signature) {\n\t\t\t\tthrow new StreamsSignatureError(\"Response is missing X-Signature.\");\n\t\t\t}\n\t\t\tconst responseKeyId = response.headers.get(\"X-Signature-KeyId\");\n\t\t\tlet key = await loadKey();\n\t\t\t// The server rotated to a key we haven't seen.\n\t\t\tif (responseKeyId && responseKeyId !== key.keyId) {\n\t\t\t\tif (typeof verify === \"object\") {\n\t\t\t\t\t// Pinned key: a different id is never the pinned key — fail closed.\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}', expected pinned key '${key.keyId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Fetched key: refresh once. A still-mismatched id (no re-loop)\n\t\t\t\t// means the endpoint doesn't serve the signing key — fail closed.\n\t\t\t\tkeyPromise = null;\n\t\t\t\tkey = await loadKey();\n\t\t\t\tif (responseKeyId !== key.keyId) {\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}' not served by the signing-key endpoint.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ed25519.verifyEd25519(text, signature, key.publicKey)) {\n\t\t\t\tthrow new StreamsSignatureError();\n\t\t\t}\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tnotTypes,\n\t\tcontractId,\n\t\tsender,\n\t\trecipient,\n\t\tassetIdentifier,\n\t}) => {\n\t\treturn listEvents({\n\t\t\tcursor,\n\t\t\tlimit,\n\t\t\ttypes,\n\t\t\tnotTypes,\n\t\t\tcontractId,\n\t\t\tsender,\n\t\t\trecipient,\n\t\t\tassetIdentifier,\n\t\t});\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnot_types: params.notTypes,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\tfinalizedOnly: params.finalizedOnly,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\tonReorg: params.onReorg,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync replay(params: StreamsEventsReplayParams) {\n\t\t\t\tconst fromCursor =\n\t\t\t\t\tparams.from === \"genesis\" ? null : (params.from ?? null);\n\t\t\t\tconst fromBlock = fromCursor ? cursorTuple(fromCursor)[0] : 0;\n\t\t\t\tconst manifest = await dumps.list();\n\n\t\t\t\t// Hydrate finalized history from dumps, in block order.\n\t\t\t\tconst files = manifest.files\n\t\t\t\t\t.filter((file) => file.to_block >= fromBlock)\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t(a, b) => a.from_block - b.from_block || a.to_block - b.to_block,\n\t\t\t\t\t);\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tif (params.signal?.aborted) break;\n\t\t\t\t\tawait params.onDumpFile(file);\n\t\t\t\t}\n\n\t\t\t\t// Seam: tail live from just past the dumped coverage. Cursor input is\n\t\t\t\t// exclusive, so the first live event is strictly after the last dump.\n\t\t\t\tconst seam = maxCursor(fromCursor, manifest.latest_finalized_cursor);\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: seam,\n\t\t\t\t\tmode: params.mode ?? \"tail\",\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${buildQuery({\n\t\t\t\t\t\tsince: params.since,\n\t\t\t\t\t\tlimit: params.limit,\n\t\t\t\t\t})}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tdumps,\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t\tusage() {\n\t\t\treturn request<StreamsUsage>(\"/v1/streams/usage\");\n\t\t},\n\t};\n}\n",
|
|
12
|
+
"import { BaseClient, buildQuery } from \"../base.ts\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { ApiError } from \"../errors.ts\";\n\nexport type IndexTip = {\n\tblock_height: number;\n\tlag_seconds: number;\n};\n\nexport type IndexUsage = {\n\tproduct: \"index\";\n\ttier: string;\n\tlimits: { rate_limit_per_second: number | null };\n\tusage: { decoded_events_today: number; decoded_events_this_month: number };\n};\n\nexport type FtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type FtTransfersEnvelope = {\n\tevents: FtTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type FtTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type FtTransfersWalkParams = Omit<FtTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nexport type NftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tcontract_id: string;\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type NftTransfersEnvelope = {\n\tevents: NftTransfer[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n};\n\nexport type NftTransfersListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type NftTransfersWalkParams = Omit<NftTransfersListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Generic decoded events (/v1/index/events) ──────────────────────\n\ntype IndexEventBase = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tcontract_id: string | null;\n};\n\nexport type IndexFtTransfer = IndexEventBase & {\n\tevent_type: \"ft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexNftTransfer = IndexEventBase & {\n\tevent_type: \"nft_transfer\";\n\tasset_identifier: string;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexStxTransfer = IndexEventBase & {\n\tevent_type: \"stx_transfer\";\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\nexport type IndexStxMint = IndexEventBase & {\n\tevent_type: \"stx_mint\";\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexStxBurn = IndexEventBase & {\n\tevent_type: \"stx_burn\";\n\tsender: string;\n\tamount: string;\n};\nexport type IndexStxLock = IndexEventBase & {\n\tevent_type: \"stx_lock\";\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\nexport type IndexFtMint = IndexEventBase & {\n\tevent_type: \"ft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tamount: string;\n};\nexport type IndexFtBurn = IndexEventBase & {\n\tevent_type: \"ft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tamount: string;\n};\nexport type IndexNftMint = IndexEventBase & {\n\tevent_type: \"nft_mint\";\n\tasset_identifier: string;\n\trecipient: string;\n\tvalue: string;\n};\nexport type IndexNftBurn = IndexEventBase & {\n\tevent_type: \"nft_burn\";\n\tasset_identifier: string;\n\tsender: string;\n\tvalue: string;\n};\nexport type IndexPrint = IndexEventBase & {\n\tevent_type: \"print\";\n\tpayload: { topic: string | null; value: unknown; raw_value: string | null };\n};\n\n/** Decoded chain event, discriminated by `event_type`. */\nexport type IndexEvent =\n\t| IndexFtTransfer\n\t| IndexNftTransfer\n\t| IndexStxTransfer\n\t| IndexStxMint\n\t| IndexStxBurn\n\t| IndexStxLock\n\t| IndexFtMint\n\t| IndexFtBurn\n\t| IndexNftMint\n\t| IndexNftBurn\n\t| IndexPrint;\n\nexport type IndexEventType = IndexEvent[\"event_type\"];\n\nexport type EventsEnvelope = {\n\tevents: IndexEvent[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type EventsListParams = {\n\t/** Required. One of the decoded event types. */\n\teventType: IndexEventType;\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tassetIdentifier?: string;\n\tsender?: string;\n\trecipient?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type EventsWalkParams = Omit<EventsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Contract calls (/v1/index/contract-calls) ──────────────────────\n\nexport type IndexContractCall = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_id: string;\n\ttx_index: number;\n\tcontract_id: string;\n\tfunction_name: string;\n\tsender: string;\n\tstatus: string;\n\targs: unknown[];\n\tresult: unknown;\n\tresult_hex: string | null;\n};\n\nexport type ContractCallsEnvelope = {\n\tcontract_calls: IndexContractCall[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type ContractCallsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tcontractId?: string;\n\tfunctionName?: string;\n\tsender?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type ContractCallsWalkParams = Omit<ContractCallsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Canonical block-hash map (/v1/index/canonical) ─────────────────\n\n/** One canonical block in the sync map. Lean by design — block + parent hash\n * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for\n * the full block resource. */\nexport type IndexCanonicalBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n};\n\nexport type CanonicalEnvelope = {\n\tcanonical: IndexCanonicalBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type CanonicalListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type CanonicalWalkParams = Omit<CanonicalListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Blocks (/v1/index/blocks) ──────────────────────────────────────\n\n/** A block resource. Metadata is intentionally thin — only chain-linkage and\n * burn-anchor fields are persisted (no miner / tx_count / signer). */\nexport type IndexBlock = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: string | null;\n\tblock_time: string | null;\n\tcanonical: boolean;\n};\n\nexport type BlocksEnvelope = {\n\tblocks: IndexBlock[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type BlockEnvelope = {\n\tblock: IndexBlock;\n\ttip: IndexTip;\n};\n\nexport type BlocksListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type BlocksWalkParams = Omit<BlocksListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Transactions (/v1/index/transactions) ──────────────────────────\n\nexport type IndexPostCondition =\n\t| {\n\t\t\ttype: \"stx\";\n\t\t\tprincipal: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"ft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t\t\tamount: string;\n\t }\n\t| {\n\t\t\ttype: \"nft\";\n\t\t\tprincipal: string;\n\t\t\tasset_identifier: string;\n\t\t\tasset_value: unknown;\n\t\t\tcondition_code: number;\n\t\t\tcondition_code_name: string | null;\n\t };\n\n/** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.\n * Payload sub-objects are present only for the matching `tx_type`; enrichment\n * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */\nexport type IndexTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\ttx_index: number;\n\ttx_type: string;\n\tsender: string;\n\tstatus: string;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t\t/** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */\n\t\tfunction_args_hex: string[];\n\t\tresult: unknown;\n\t\tresult_hex: string | null;\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: {\n\t\tcontract_id: string | null;\n\t\tclarity_version: number | null;\n\t};\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type TransactionsEnvelope = {\n\ttransactions: IndexTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\treorgs: never[];\n};\n\nexport type TransactionEnvelope = {\n\ttransaction: IndexTransaction;\n\ttip: IndexTip;\n};\n\nexport type TransactionsListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\ttype?: string;\n\tsender?: string;\n\tcontractId?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type TransactionsWalkParams = Omit<TransactionsListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Stacking (/v1/index/stacking) ──────────────────────────────────\n\n/** A decoded PoX-4 stacking action (one per stacking contract call). */\nexport type IndexStackingAction = {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time?: string | null;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tfunction_name: string;\n\tcaller: string;\n\tstacker: string | null;\n\tdelegate_to: string | null;\n\tamount_ustx: string | null;\n\tlock_period: number | null;\n\tpox_addr: {\n\t\tversion: number | null;\n\t\thashbytes: string | null;\n\t\tbtc: string | null;\n\t};\n\tstart_cycle: number | null;\n\tend_cycle: number | null;\n\treward_cycle: number | null;\n\tsigner_key: string | null;\n\tresult_ok: boolean;\n};\n\nexport type StackingEnvelope = {\n\tstacking: IndexStackingAction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n\t// Reserved envelope field. v1 currently always emits [].\n\treorgs: never[];\n\t/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */\n\tnotes?: string;\n};\n\nexport type StackingListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tfunctionName?: string;\n\tstacker?: string;\n\tcaller?: string;\n\tfromHeight?: number;\n\ttoHeight?: number;\n};\n\nexport type StackingWalkParams = Omit<StackingListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\n// ── Mempool (/v1/index/mempool) ────────────────────────────────────\n\n/** A pending (unconfirmed) transaction. Like a transaction document but\n * pre-chain — no block_height/tx_index/result/events — with `received_at` and\n * a sequence cursor instead of a block position. */\nexport type IndexMempoolTransaction = {\n\tcursor: string;\n\ttx_id: string;\n\ttx_type: string;\n\tsender: string;\n\treceived_at?: string | null;\n\tfee: string | null;\n\tnonce: string | null;\n\tsponsored: boolean | null;\n\tanchor_mode: string | null;\n\tpost_condition_mode: string | null;\n\tpost_conditions: IndexPostCondition[];\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\ttoken_transfer?: { recipient: string; amount: string; memo: string };\n\tsmart_contract?: { clarity_version: number | null };\n\tcoinbase?: { alt_recipient: string | null };\n\ttenure_change?: { cause: number };\n};\n\nexport type MempoolEnvelope = {\n\tmempool: IndexMempoolTransaction[];\n\tnext_cursor: string | null;\n\ttip: IndexTip;\n};\n\nexport type MempoolTransactionEnvelope = {\n\ttransaction: IndexMempoolTransaction;\n\ttip: IndexTip;\n};\n\nexport type MempoolListParams = {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tlimit?: number;\n\tsender?: string;\n\ttype?: string;\n\t/** Filter to pending calls to a single contract (e.g. `SP….contract`). */\n\tcontractId?: string;\n};\n\nexport type MempoolWalkParams = Omit<MempoolListParams, \"limit\"> & {\n\tbatchSize?: number;\n\tsignal?: AbortSignal;\n};\n\nfunction firstWalkFromHeight(params: {\n\tcursor?: string | null;\n\tfromCursor?: string | null;\n\tfromHeight?: number;\n}): number | undefined {\n\tif (params.fromHeight !== undefined) return params.fromHeight;\n\tif (params.cursor || params.fromCursor) return undefined;\n\treturn 0;\n}\n\nexport class Index extends BaseClient {\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t}\n\n\t/** Your own Index consumption (decoded events today + this month) and tier limits. */\n\tusage(): Promise<IndexUsage> {\n\t\treturn this.request<IndexUsage>(\"GET\", \"/v1/index/usage\");\n\t}\n\n\treadonly ftTransfers: {\n\t\tlist: (params?: FtTransfersListParams) => Promise<FtTransfersEnvelope>;\n\t\twalk: (params?: FtTransfersWalkParams) => AsyncIterable<FtTransfer>;\n\t} = {\n\t\tlist: (params: FtTransfersListParams = {}): Promise<FtTransfersEnvelope> =>\n\t\t\tthis.listFtTransfers(params),\n\t\twalk: (params: FtTransfersWalkParams = {}): AsyncIterable<FtTransfer> =>\n\t\t\tthis.walkFtTransfers(params),\n\t};\n\n\treadonly nftTransfers: {\n\t\tlist: (params?: NftTransfersListParams) => Promise<NftTransfersEnvelope>;\n\t\twalk: (params?: NftTransfersWalkParams) => AsyncIterable<NftTransfer>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: NftTransfersListParams = {},\n\t\t): Promise<NftTransfersEnvelope> => this.listNftTransfers(params),\n\t\twalk: (params: NftTransfersWalkParams = {}): AsyncIterable<NftTransfer> =>\n\t\t\tthis.walkNftTransfers(params),\n\t};\n\n\t/** Generic decoded events by `event_type` (the full /v1/index/events surface). */\n\treadonly events: {\n\t\tlist: (params: EventsListParams) => Promise<EventsEnvelope>;\n\t\twalk: (params: EventsWalkParams) => AsyncIterable<IndexEvent>;\n\t} = {\n\t\tlist: (params: EventsListParams): Promise<EventsEnvelope> =>\n\t\t\tthis.listEvents(params),\n\t\twalk: (params: EventsWalkParams): AsyncIterable<IndexEvent> =>\n\t\t\tthis.walkEvents(params),\n\t};\n\n\treadonly contractCalls: {\n\t\tlist: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;\n\t\twalk: (\n\t\t\tparams?: ContractCallsWalkParams,\n\t\t) => AsyncIterable<IndexContractCall>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: ContractCallsListParams = {},\n\t\t): Promise<ContractCallsEnvelope> => this.listContractCalls(params),\n\t\twalk: (\n\t\t\tparams: ContractCallsWalkParams = {},\n\t\t): AsyncIterable<IndexContractCall> => this.walkContractCalls(params),\n\t};\n\n\t/** Canonical block-hash map — sync only the current canonical chain. */\n\treadonly canonical: {\n\t\tlist: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;\n\t\twalk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;\n\t} = {\n\t\tlist: (params: CanonicalListParams = {}): Promise<CanonicalEnvelope> =>\n\t\t\tthis.listCanonical(params),\n\t\twalk: (\n\t\t\tparams: CanonicalWalkParams = {},\n\t\t): AsyncIterable<IndexCanonicalBlock> => this.walkCanonical(params),\n\t};\n\n\t/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash\n\t * (resolves to null on 404). */\n\treadonly blocks: {\n\t\tlist: (params?: BlocksListParams) => Promise<BlocksEnvelope>;\n\t\twalk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;\n\t\tget: (ref: string | number) => Promise<BlockEnvelope | null>;\n\t} = {\n\t\tlist: (params: BlocksListParams = {}): Promise<BlocksEnvelope> =>\n\t\t\tthis.listBlocks(params),\n\t\twalk: (params: BlocksWalkParams = {}): AsyncIterable<IndexBlock> =>\n\t\t\tthis.walkBlocks(params),\n\t\tget: (ref: string | number): Promise<BlockEnvelope | null> =>\n\t\t\tthis.getBlock(ref),\n\t};\n\n\t/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id\n\t * (resolves to null on 404). */\n\treadonly transactions: {\n\t\tlist: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>;\n\t\twalk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;\n\t\tget: (txId: string) => Promise<TransactionEnvelope | null>;\n\t} = {\n\t\tlist: (\n\t\t\tparams: TransactionsListParams = {},\n\t\t): Promise<TransactionsEnvelope> => this.listTransactions(params),\n\t\twalk: (\n\t\t\tparams: TransactionsWalkParams = {},\n\t\t): AsyncIterable<IndexTransaction> => this.walkTransactions(params),\n\t\tget: (txId: string): Promise<TransactionEnvelope | null> =>\n\t\t\tthis.getTransaction(txId),\n\t};\n\n\t/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the\n\t * platform's PoX-4 decoder is disabled. */\n\treadonly stacking: {\n\t\tlist: (params?: StackingListParams) => Promise<StackingEnvelope>;\n\t\twalk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;\n\t} = {\n\t\tlist: (params: StackingListParams = {}): Promise<StackingEnvelope> =>\n\t\t\tthis.listStacking(params),\n\t\twalk: (\n\t\t\tparams: StackingWalkParams = {},\n\t\t): AsyncIterable<IndexStackingAction> => this.walkStacking(params),\n\t};\n\n\t/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by\n\t * tx_id (resolves to null when the tx has confirmed or dropped). */\n\treadonly mempool: {\n\t\tlist: (params?: MempoolListParams) => Promise<MempoolEnvelope>;\n\t\twalk: (\n\t\t\tparams?: MempoolWalkParams,\n\t\t) => AsyncIterable<IndexMempoolTransaction>;\n\t\tget: (txId: string) => Promise<MempoolTransactionEnvelope | null>;\n\t} = {\n\t\tlist: (params: MempoolListParams = {}): Promise<MempoolEnvelope> =>\n\t\t\tthis.listMempool(params),\n\t\twalk: (\n\t\t\tparams: MempoolWalkParams = {},\n\t\t): AsyncIterable<IndexMempoolTransaction> => this.walkMempool(params),\n\t\tget: (txId: string): Promise<MempoolTransactionEnvelope | null> =>\n\t\t\tthis.getMempoolTx(txId),\n\t};\n\n\tprivate async listFtTransfers(\n\t\tparams: FtTransfersListParams = {},\n\t): Promise<FtTransfersEnvelope> {\n\t\treturn this.request<FtTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/ft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async listNftTransfers(\n\t\tparams: NftTransfersListParams = {},\n\t): Promise<NftTransfersEnvelope> {\n\t\treturn this.request<NftTransfersEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/nft-transfers${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkFtTransfers(\n\t\tparams: FtTransfersWalkParams = {},\n\t): AsyncGenerator<FtTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listFtTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async *walkNftTransfers(\n\t\tparams: NftTransfersWalkParams = {},\n\t): AsyncGenerator<NftTransfer> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listNftTransfers({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listEvents(params: EventsListParams): Promise<EventsEnvelope> {\n\t\treturn this.request<EventsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/events${buildQuery({\n\t\t\t\tevent_type: params.eventType,\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkEvents(\n\t\tparams: EventsWalkParams,\n\t): AsyncGenerator<IndexEvent> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listEvents({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const event of envelope.events) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield event;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.events.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listContractCalls(\n\t\tparams: ContractCallsListParams = {},\n\t): Promise<ContractCallsEnvelope> {\n\t\treturn this.request<ContractCallsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/contract-calls${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tsender: params.sender,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkContractCalls(\n\t\tparams: ContractCallsWalkParams = {},\n\t): AsyncGenerator<IndexContractCall> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listContractCalls({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const call of envelope.contract_calls) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield call;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.contract_calls.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listCanonical(\n\t\tparams: CanonicalListParams = {},\n\t): Promise<CanonicalEnvelope> {\n\t\treturn this.request<CanonicalEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/canonical${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkCanonical(\n\t\tparams: CanonicalWalkParams = {},\n\t): AsyncGenerator<IndexCanonicalBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listCanonical({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.canonical) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.canonical.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listBlocks(\n\t\tparams: BlocksListParams = {},\n\t): Promise<BlocksEnvelope> {\n\t\treturn this.request<BlocksEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/blocks${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getBlock(ref: string | number): Promise<BlockEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<BlockEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/blocks/${encodeURIComponent(String(ref))}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkBlocks(\n\t\tparams: BlocksWalkParams = {},\n\t): AsyncGenerator<IndexBlock> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listBlocks({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const block of envelope.blocks) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield block;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.blocks.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listTransactions(\n\t\tparams: TransactionsListParams = {},\n\t): Promise<TransactionsEnvelope> {\n\t\treturn this.request<TransactionsEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/transactions${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\ttype: params.type,\n\t\t\t\tsender: params.sender,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getTransaction(\n\t\ttxId: string,\n\t): Promise<TransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<TransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/transactions/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkTransactions(\n\t\tparams: TransactionsWalkParams = {},\n\t): AsyncGenerator<IndexTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listTransactions({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.transactions) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.transactions.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listStacking(\n\t\tparams: StackingListParams = {},\n\t): Promise<StackingEnvelope> {\n\t\treturn this.request<StackingEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/stacking${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tfunction_name: params.functionName,\n\t\t\t\tstacker: params.stacker,\n\t\t\t\tcaller: params.caller,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async *walkStacking(\n\t\tparams: StackingWalkParams = {},\n\t): AsyncGenerator<IndexStackingAction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listStacking({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t\tfromHeight: firstPage ? firstWalkFromHeight(params) : undefined,\n\t\t\t});\n\n\t\t\tfor (const action of envelope.stacking) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield action;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.stacking.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n\n\tprivate async listMempool(\n\t\tparams: MempoolListParams = {},\n\t): Promise<MempoolEnvelope> {\n\t\treturn this.request<MempoolEnvelope>(\n\t\t\t\"GET\",\n\t\t\t`/v1/index/mempool${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_cursor: params.fromCursor,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tsender: params.sender,\n\t\t\t\ttype: params.type,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\tprivate async getMempoolTx(\n\t\ttxId: string,\n\t): Promise<MempoolTransactionEnvelope | null> {\n\t\ttry {\n\t\t\treturn await this.request<MempoolTransactionEnvelope>(\n\t\t\t\t\"GET\",\n\t\t\t\t`/v1/index/mempool/${encodeURIComponent(txId)}`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tif (err instanceof ApiError && err.status === 404) return null;\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate async *walkMempool(\n\t\tparams: MempoolWalkParams = {},\n\t): AsyncGenerator<IndexMempoolTransaction> {\n\t\tconst batchSize = params.batchSize ?? 200;\n\t\tlet cursor = params.cursor ?? params.fromCursor ?? null;\n\t\tlet firstPage = true;\n\n\t\twhile (!params.signal?.aborted) {\n\t\t\tconst envelope = await this.listMempool({\n\t\t\t\t...params,\n\t\t\t\tlimit: batchSize,\n\t\t\t\tcursor: firstPage ? params.cursor : cursor,\n\t\t\t\tfromCursor: firstPage ? params.fromCursor : undefined,\n\t\t\t});\n\n\t\t\tfor (const tx of envelope.mempool) {\n\t\t\t\tif (params.signal?.aborted) return;\n\t\t\t\tyield tx;\n\t\t\t}\n\n\t\t\tconst nextCursor = envelope.next_cursor;\n\t\t\tif (\n\t\t\t\t!nextCursor ||\n\t\t\t\tnextCursor === cursor ||\n\t\t\t\tenvelope.mempool.length < batchSize\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tfirstPage = false;\n\t\t}\n\t}\n}\n",
|
|
13
|
+
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport {\n\ttype StreamsEventsFetcher,\n\tconsumeStreamsEvents,\n\tstreamStreamsEvents,\n} from \"./consumer.ts\";\nimport { createStreamsDumps } from \"./dumps.ts\";\nimport {\n\tAuthError,\n\tRateLimitError,\n\tStreamsServerError,\n\tStreamsSignatureError,\n\tValidationError,\n} from \"./errors.ts\";\nimport { subscribeStreamsEvents } from \"./subscribe.ts\";\nimport type {\n\tFetchLike,\n\tStreamsCanonicalBlock,\n\tStreamsClient,\n\tStreamsEventsConsumeParams,\n\tStreamsEventsEnvelope,\n\tStreamsEventsListEnvelope,\n\tStreamsEventsListParams,\n\tStreamsEventsReplayParams,\n\tStreamsEventsStreamParams,\n\tStreamsEventsSubscribeParams,\n\tStreamsReorgsListEnvelope,\n\tStreamsReorgsListParams,\n\tStreamsTip,\n\tStreamsUsage,\n} from \"./types.ts\";\n\n/** Parse a `<block>:<index>` cursor; null sorts before genesis. */\nfunction cursorTuple(cursor: string | null): [number, number] {\n\tif (!cursor) return [-1, -1];\n\tconst parts = cursor.split(\":\");\n\tconst [block, index] = parts.map(Number);\n\tif (\n\t\tparts.length !== 2 ||\n\t\t!Number.isInteger(block) ||\n\t\t!Number.isInteger(index)\n\t) {\n\t\tthrow new ValidationError(\n\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t400,\n\t\t);\n\t}\n\treturn [block, index];\n}\n\n/** The greater of two cursors (later in the stream). */\nfunction maxCursor(a: string | null, b: string | null): string | null {\n\tconst [ah, ai] = cursorTuple(a);\n\tconst [bh, bi] = cursorTuple(b);\n\treturn ah > bh || (ah === bh && ai >= bi) ? a : b;\n}\n\nconst DEFAULT_STREAMS_BASE_URL = \"https://api.secondlayer.tools\";\n\nexport type CreateStreamsClientOptions = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\tfetchImpl?: FetchLike;\n\t/**\n\t * Public base URL for bulk parquet dumps (the R2/CDN bucket root). Required\n\t * to use `client.dumps`. See `GET /public/streams/dumps/manifest`.\n\t */\n\tdumpsBaseUrl?: string;\n\t/**\n\t * Verify the ed25519 `X-Signature` on every response (default off). Pass\n\t * `true` to fetch the server's public key from\n\t * `/public/streams/signing-key`, or `{ publicKey }` to pin a known PEM. A\n\t * failed or missing signature throws `StreamsSignatureError`.\n\t */\n\tverify?: boolean | { publicKey: string };\n\t/**\n\t * Verify the bulk dumps manifest's ed25519 signature in `client.dumps.list()`\n\t * before trusting any file sha256 (default off). Uses the same key source as\n\t * `verify`. Default off until historical manifests carry signatures.\n\t */\n\tverifyDumpsManifest?: boolean;\n};\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n\treturn baseUrl.replace(/\\/+$/, \"\");\n}\n\nasync function responseBody(response: Response): Promise<unknown> {\n\tconst text = await response.text();\n\tif (text.length === 0) return undefined;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\treturn text;\n\t}\n}\n\nfunction errorMessage(body: unknown, fallback: string): string {\n\tif (body && typeof body === \"object\") {\n\t\tconst record = body as Record<string, unknown>;\n\t\tconst message = record.error ?? record.message;\n\t\tif (typeof message === \"string\" && message.length > 0) return message;\n\t}\n\tif (typeof body === \"string\" && body.length > 0) return body;\n\treturn fallback;\n}\n\nasync function mapStreamsError(response: Response): Promise<never> {\n\tconst body = await responseBody(response);\n\n\tif (response.status === 401) {\n\t\tthrow new AuthError(errorMessage(body, \"API key invalid or expired.\"));\n\t}\n\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"Retry-After\") ?? undefined;\n\t\tthrow new RateLimitError(\n\t\t\terrorMessage(body, \"Rate limited. Try again later.\"),\n\t\t\tretryAfter,\n\t\t);\n\t}\n\n\tif (response.status >= 500) {\n\t\tthrow new StreamsServerError(\n\t\t\terrorMessage(body, `Streams server returned ${response.status}.`),\n\t\t\tresponse.status,\n\t\t\tbody,\n\t\t);\n\t}\n\n\tthrow new ValidationError(\n\t\terrorMessage(body, `Streams request returned ${response.status}.`),\n\t\tresponse.status,\n\t\tbody,\n\t);\n}\n\nexport function createStreamsClient(\n\toptions: CreateStreamsClientOptions,\n): StreamsClient {\n\tconst baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_STREAMS_BASE_URL);\n\tconst fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));\n\tconst verify = options.verify ?? false;\n\n\t// Lazily resolve and cache the verification key alongside its id, so a\n\t// rotation (signalled by a changed `X-Signature-KeyId`) can be detected.\n\ttype VerificationKey = {\n\t\tkeyId: string;\n\t\tpublicKeyPem: string;\n\t\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n\t};\n\tlet keyPromise: Promise<VerificationKey> | null = null;\n\tfunction loadKey(): Promise<VerificationKey> {\n\t\tif (keyPromise) return keyPromise;\n\t\tkeyPromise = (async () => {\n\t\t\tif (typeof verify === \"object\") {\n\t\t\t\treturn {\n\t\t\t\t\tkeyId: ed25519.ed25519KeyId(verify.publicKey),\n\t\t\t\t\tpublicKeyPem: verify.publicKey,\n\t\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(verify.publicKey),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst res = await fetchImpl(`${baseUrl}/public/streams/signing-key`);\n\t\t\tif (!res.ok) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t`Could not fetch signing key (${res.status}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst body = (await res.json()) as {\n\t\t\t\tpublic_key_pem?: string;\n\t\t\t\tkey_id?: string;\n\t\t\t};\n\t\t\tif (!body.public_key_pem) {\n\t\t\t\tthrow new StreamsSignatureError(\"Signing key response missing key.\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkeyId: body.key_id ?? ed25519.ed25519KeyId(body.public_key_pem),\n\t\t\t\tpublicKeyPem: body.public_key_pem,\n\t\t\t\tpublicKey: ed25519.loadEd25519PublicKey(body.public_key_pem),\n\t\t\t};\n\t\t})();\n\t\treturn keyPromise;\n\t}\n\n\tconst dumps = createStreamsDumps({\n\t\tbaseUrl: options.dumpsBaseUrl,\n\t\tfetchImpl,\n\t\tverifyManifest: options.verifyDumpsManifest ?? false,\n\t\tloadPublicKeyPem: async () => (await loadKey()).publicKeyPem,\n\t});\n\n\tasync function request<T>(path: string): Promise<T> {\n\t\tconst response = await fetchImpl(`${baseUrl}${path}`, {\n\t\t\theaders: { Authorization: `Bearer ${options.apiKey}` },\n\t\t});\n\t\tif (!response.ok) await mapStreamsError(response);\n\t\tconst text = await response.text();\n\t\tif (verify) {\n\t\t\tconst signature = response.headers.get(\"X-Signature\");\n\t\t\tif (!signature) {\n\t\t\t\tthrow new StreamsSignatureError(\"Response is missing X-Signature.\");\n\t\t\t}\n\t\t\tconst responseKeyId = response.headers.get(\"X-Signature-KeyId\");\n\t\t\tlet key = await loadKey();\n\t\t\t// The server rotated to a key we haven't seen.\n\t\t\tif (responseKeyId && responseKeyId !== key.keyId) {\n\t\t\t\tif (typeof verify === \"object\") {\n\t\t\t\t\t// Pinned key: a different id is never the pinned key — fail closed.\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}', expected pinned key '${key.keyId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Fetched key: refresh once. A still-mismatched id (no re-loop)\n\t\t\t\t// means the endpoint doesn't serve the signing key — fail closed.\n\t\t\t\tkeyPromise = null;\n\t\t\t\tkey = await loadKey();\n\t\t\t\tif (responseKeyId !== key.keyId) {\n\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t`Response signed with key '${responseKeyId}' not served by the signing-key endpoint.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ed25519.verifyEd25519(text, signature, key.publicKey)) {\n\t\t\t\tthrow new StreamsSignatureError();\n\t\t\t}\n\t\t}\n\t\treturn JSON.parse(text) as T;\n\t}\n\n\tconst fetchEvents: StreamsEventsFetcher = async ({\n\t\tcursor,\n\t\tlimit,\n\t\ttypes,\n\t\tnotTypes,\n\t\tcontractId,\n\t\tsender,\n\t\trecipient,\n\t\tassetIdentifier,\n\t}) => {\n\t\treturn listEvents({\n\t\t\tcursor,\n\t\t\tlimit,\n\t\t\ttypes,\n\t\t\tnotTypes,\n\t\t\tcontractId,\n\t\t\tsender,\n\t\t\trecipient,\n\t\t\tassetIdentifier,\n\t\t});\n\t};\n\n\tasync function listEvents(\n\t\tparams: StreamsEventsListParams = {},\n\t): Promise<StreamsEventsEnvelope> {\n\t\treturn request<StreamsEventsEnvelope>(\n\t\t\t`/v1/streams/events${buildQuery({\n\t\t\t\tcursor: params.cursor,\n\t\t\t\tfrom_height: params.fromHeight,\n\t\t\t\tto_height: params.toHeight,\n\t\t\t\tlimit: params.limit,\n\t\t\t\tcontract_id: params.contractId,\n\t\t\t\tsender: params.sender,\n\t\t\t\trecipient: params.recipient,\n\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\ttypes: params.types,\n\t\t\t\tnot_types: params.notTypes,\n\t\t\t})}`,\n\t\t);\n\t}\n\n\treturn {\n\t\tevents: {\n\t\t\tlist: listEvents,\n\t\t\tbyTxId(txId: string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/events/${encodeURIComponent(txId)}`,\n\t\t\t\t);\n\t\t\t},\n\t\t\tconsume(params: StreamsEventsConsumeParams) {\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\tmode: params.mode,\n\t\t\t\t\tfinalizedOnly: params.finalizedOnly,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\tonReorg: params.onReorg,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t\tstream(params: StreamsEventsStreamParams = {}) {\n\t\t\t\treturn streamStreamsEvents({\n\t\t\t\t\tfromCursor: params.fromCursor,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnotTypes: params.notTypes,\n\t\t\t\t\tcontractId: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tassetIdentifier: params.assetIdentifier,\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t});\n\t\t\t},\n\t\t\tsubscribe(params: StreamsEventsSubscribeParams) {\n\t\t\t\treturn subscribeStreamsEvents({\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tfetchImpl,\n\t\t\t\t\tverify: Boolean(verify),\n\t\t\t\t\tloadKey,\n\t\t\t\t\tparams,\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync replay(params: StreamsEventsReplayParams) {\n\t\t\t\tconst fromCursor =\n\t\t\t\t\tparams.from === \"genesis\" ? null : (params.from ?? null);\n\t\t\t\tconst fromBlock = fromCursor ? cursorTuple(fromCursor)[0] : 0;\n\t\t\t\tconst manifest = await dumps.list();\n\n\t\t\t\t// Hydrate finalized history from dumps, in block order.\n\t\t\t\tconst files = manifest.files\n\t\t\t\t\t.filter((file) => file.to_block >= fromBlock)\n\t\t\t\t\t.sort(\n\t\t\t\t\t\t(a, b) => a.from_block - b.from_block || a.to_block - b.to_block,\n\t\t\t\t\t);\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tif (params.signal?.aborted) break;\n\t\t\t\t\tawait params.onDumpFile(file);\n\t\t\t\t}\n\n\t\t\t\t// Seam: tail live from just past the dumped coverage. Cursor input is\n\t\t\t\t// exclusive, so the first live event is strictly after the last dump.\n\t\t\t\tconst seam = maxCursor(fromCursor, manifest.latest_finalized_cursor);\n\t\t\t\treturn consumeStreamsEvents({\n\t\t\t\t\tfromCursor: seam,\n\t\t\t\t\tmode: params.mode ?? \"tail\",\n\t\t\t\t\tbatchSize: params.batchSize ?? 100,\n\t\t\t\t\tfetchEvents,\n\t\t\t\t\tonBatch: params.onBatch,\n\t\t\t\t\temptyBackoffMs: params.emptyBackoffMs,\n\t\t\t\t\tmaxPages: params.maxPages,\n\t\t\t\t\tmaxEmptyPolls: params.maxEmptyPolls,\n\t\t\t\t\tsignal: params.signal,\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tblocks: {\n\t\t\tevents(heightOrHash: number | string) {\n\t\t\t\treturn request<StreamsEventsListEnvelope>(\n\t\t\t\t\t`/v1/streams/blocks/${encodeURIComponent(String(heightOrHash))}/events`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\treorgs: {\n\t\t\tlist(params: StreamsReorgsListParams) {\n\t\t\t\treturn request<StreamsReorgsListEnvelope>(\n\t\t\t\t\t`/v1/streams/reorgs${buildQuery({\n\t\t\t\t\t\tsince: params.since,\n\t\t\t\t\t\tlimit: params.limit,\n\t\t\t\t\t})}`,\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tdumps,\n\t\tcanonical(height: number) {\n\t\t\treturn request<StreamsCanonicalBlock>(`/v1/streams/canonical/${height}`);\n\t\t},\n\t\ttip() {\n\t\t\treturn request<StreamsTip>(\"/v1/streams/tip\");\n\t\t},\n\t\tusage() {\n\t\t\treturn request<StreamsUsage>(\"/v1/streams/usage\");\n\t\t},\n\t};\n}\n",
|
|
14
14
|
"export class AuthError extends Error {\n\treadonly status = 401;\n\n\tconstructor(message = \"API key invalid or expired.\") {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class RateLimitError extends Error {\n\treadonly status = 429;\n\n\tconstructor(\n\t\tmessage = \"Rate limited. Try again later.\",\n\t\treadonly retryAfter?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"RateLimitError\";\n\t}\n}\n\nexport class ValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n\nexport class StreamsServerError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly status: number,\n\t\treadonly body?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsServerError\";\n\t}\n}\n\n/** Thrown when response signature verification is enabled and fails. */\nexport class StreamsSignatureError extends Error {\n\tconstructor(message = \"Streams response signature verification failed.\") {\n\t\tsuper(message);\n\t\tthis.name = \"StreamsSignatureError\";\n\t}\n}\n",
|
|
15
15
|
"import { ValidationError } from \"./errors.ts\";\n\n/**\n * Helpers for Streams cursors. A cursor is the opaque `<block>:<index>` string\n * that marks a position in the event stream; treat the format as an\n * implementation detail and go through these helpers instead of string-building\n * it at call sites.\n */\nexport const Cursor = {\n\t/**\n\t * Cursor at the foot of `height`. Resuming from it re-reads every event\n\t * strictly above block `height` (cursors are exclusive), so this is the\n\t * position to rewind to after a reorg whose fork point is `height`.\n\t */\n\tatHeight(height: number): string {\n\t\treturn `${height}:0`;\n\t},\n\n\t/** Parse a `<block>:<index>` cursor. Throws `ValidationError` if malformed. */\n\tparse(cursor: string): { blockHeight: number; eventIndex: number } {\n\t\tconst parts = cursor.split(\":\");\n\t\tconst blockHeight = Number(parts[0]);\n\t\tconst eventIndex = Number(parts[1]);\n\t\tif (\n\t\t\tparts.length !== 2 ||\n\t\t\t!Number.isInteger(blockHeight) ||\n\t\t\t!Number.isInteger(eventIndex)\n\t\t) {\n\t\t\tthrow new ValidationError(\n\t\t\t\t`Invalid stream cursor \"${cursor}\"; expected \"<block>:<index>\" (e.g. \"951475:3\").`,\n\t\t\t\t400,\n\t\t\t);\n\t\t}\n\t\treturn { blockHeight, eventIndex };\n\t},\n};\n",
|
|
16
16
|
"import { Cursor } from \"./cursor.ts\";\nimport type {\n\tStreamsEvent,\n\tStreamsEventType,\n\tStreamsEventsEnvelope,\n\tStreamsFilterValue,\n\tStreamsReorg,\n} from \"./types.ts\";\n\n/** Stable identity of a reorg, for in-memory dedup across re-reported pages. */\nfunction reorgKey(reorg: StreamsReorg): string {\n\treturn `${reorg.detected_at}|${reorg.fork_point_height}|${reorg.new_canonical_tip}`;\n}\n\ntype StreamsEventsFetchParams = {\n\tcursor?: string | null;\n\tlimit: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n};\n\nexport type StreamsEventsFetcher = (\n\tparams: StreamsEventsFetchParams,\n) => Promise<StreamsEventsEnvelope>;\n\nexport type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;\n\nexport async function defaultSleep(\n\tms: number,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tif (signal?.aborted) return;\n\n\tawait new Promise<void>((resolve) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tif (!signal) return;\n\t\tsignal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t});\n}\n\nexport async function consumeStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tmode?: \"tail\" | \"bounded\";\n\tfinalizedOnly?: boolean;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tonBatch: (\n\t\tevents: StreamsEvent[],\n\t\tenvelope: StreamsEventsEnvelope,\n\t\tctx: { cursor: string | null },\n\t) =>\n\t\t| void\n\t\t| string\n\t\t| null\n\t\t| undefined\n\t\t| Promise<void>\n\t\t| Promise<string | null | undefined>;\n\tonReorg?: (\n\t\treorg: StreamsReorg,\n\t\tctx: { cursor: string },\n\t) => Promise<void> | void;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): Promise<{ cursor: string | null; pages: number; emptyPolls: number }> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst mode = opts.mode ?? \"tail\";\n\tconst finalizedOnly = opts.finalizedOnly ?? false;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\t// In-memory only: rollback is idempotent, so a crash before the rewind is\n\t// re-detected and re-applied harmlessly on restart — no need to persist.\n\tconst handledReorgs = new Set<string>();\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tnotTypes: opts.notTypes,\n\t\t\tcontractId: opts.contractId,\n\t\t\tsender: opts.sender,\n\t\t\trecipient: opts.recipient,\n\t\t\tassetIdentifier: opts.assetIdentifier,\n\t\t});\n\t\tpages++;\n\n\t\t// Reorgs: roll back each new fork, then rewind to the lowest fork point\n\t\t// and re-read the now-canonical run. Finalized data never reorgs, so\n\t\t// `finalizedOnly` skips this entirely.\n\t\tif (!finalizedOnly && opts.onReorg) {\n\t\t\tconst fresh = envelope.reorgs\n\t\t\t\t.filter((reorg) => !handledReorgs.has(reorgKey(reorg)))\n\t\t\t\t.sort((a, b) => a.fork_point_height - b.fork_point_height);\n\t\t\tif (fresh.length > 0) {\n\t\t\t\tconst forkPoint = Math.min(\n\t\t\t\t\t...fresh.map((reorg) => reorg.fork_point_height),\n\t\t\t\t);\n\t\t\t\tconst rewind = Cursor.atHeight(forkPoint);\n\t\t\t\tfor (const reorg of fresh) {\n\t\t\t\t\tawait opts.onReorg(reorg, { cursor: rewind });\n\t\t\t\t\thandledReorgs.add(reorgKey(reorg));\n\t\t\t\t}\n\t\t\t\tcursor = rewind;\n\t\t\t\temptyPolls = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tconst emitted = finalizedOnly\n\t\t\t? envelope.events.filter((event) => event.finalized)\n\t\t\t: envelope.events;\n\t\t// Only advance to the last finalized event in finalizedOnly mode; the\n\t\t// unfinalized tail is re-read next poll until it settles.\n\t\tconst checkpoint = finalizedOnly\n\t\t\t? (emitted.at(-1)?.cursor ?? cursor)\n\t\t\t: envelope.next_cursor;\n\n\t\tconst returnedCursor = await opts.onBatch(emitted, envelope, {\n\t\t\tcursor: checkpoint,\n\t\t});\n\t\tconst nextCursor = returnedCursor ?? checkpoint;\n\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (emitted.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (mode === \"bounded\") {\n\t\t\t\treturn { cursor, pages, emptyPolls };\n\t\t\t}\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn { cursor, pages, emptyPolls };\n\t}\n\n\treturn { cursor, pages, emptyPolls };\n}\n\nexport async function* streamStreamsEvents(opts: {\n\tfromCursor?: string | null;\n\tbatchSize: number;\n\ttypes?: readonly StreamsEventType[];\n\tnotTypes?: readonly StreamsEventType[];\n\tcontractId?: StreamsFilterValue;\n\tsender?: StreamsFilterValue;\n\trecipient?: StreamsFilterValue;\n\tassetIdentifier?: string;\n\tfetchEvents: StreamsEventsFetcher;\n\tsleep?: Sleep;\n\temptyBackoffMs?: number;\n\tmaxPages?: number;\n\tmaxEmptyPolls?: number;\n\tsignal?: AbortSignal;\n}): AsyncGenerator<StreamsEvent> {\n\tconst sleep = opts.sleep ?? defaultSleep;\n\tconst emptyBackoffMs = opts.emptyBackoffMs ?? 500;\n\tconst maxPages = opts.maxPages ?? Number.POSITIVE_INFINITY;\n\tconst maxEmptyPolls = opts.maxEmptyPolls ?? Number.POSITIVE_INFINITY;\n\tlet cursor = opts.fromCursor ?? null;\n\tlet pages = 0;\n\tlet emptyPolls = 0;\n\n\twhile (\n\t\tpages < maxPages &&\n\t\temptyPolls < maxEmptyPolls &&\n\t\t!opts.signal?.aborted\n\t) {\n\t\tconst envelope = await opts.fetchEvents({\n\t\t\tcursor,\n\t\t\tlimit: opts.batchSize,\n\t\t\ttypes: opts.types,\n\t\t\tnotTypes: opts.notTypes,\n\t\t\tcontractId: opts.contractId,\n\t\t\tsender: opts.sender,\n\t\t\trecipient: opts.recipient,\n\t\t\tassetIdentifier: opts.assetIdentifier,\n\t\t});\n\t\tpages++;\n\n\t\tfor (const event of envelope.events) {\n\t\t\tif (opts.signal?.aborted) return;\n\t\t\tyield event;\n\t\t}\n\n\t\tconst nextCursor = envelope.next_cursor;\n\t\tif (nextCursor && nextCursor !== cursor) {\n\t\t\tcursor = nextCursor;\n\t\t\temptyPolls = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (envelope.events.length === 0) {\n\t\t\temptyPolls++;\n\t\t\tif (emptyPolls >= maxEmptyPolls || pages >= maxPages) return;\n\t\t\tawait sleep(emptyBackoffMs, opts.signal);\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn;\n\t}\n}\n",
|
|
17
|
-
"import { createHash } from \"node:crypto\";\nimport { StreamsServerError, StreamsSignatureError } from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsDumpFile,\n\tStreamsDumps,\n\tStreamsDumpsManifest,\n} from \"./types.ts\";\n\n/**\n * Bulk parquet dumps: the cold backfill path for \"download all the raw data\".\n *\n * The manifest lives at `<dumpsBaseUrl>/manifest/latest.json` and each file's\n * `path` is the object key under the same base. Downloads are verified against\n * the manifest sha256 so a truncated or tampered file is rejected.\n */\nexport function createStreamsDumps(opts: {\n\tbaseUrl?: string;\n\tfetchImpl: FetchLike;\n}): StreamsDumps {\n\tconst baseUrl = opts.baseUrl?.replace(/\\/+$/, \"\");\n\n\tfunction requireBaseUrl(): string {\n\t\tif (!baseUrl) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t\"Streams dumps require `dumpsBaseUrl` on createStreamsClient.\",\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\treturn baseUrl;\n\t}\n\n\tfunction fileUrl(file: StreamsDumpFile): string {\n\t\treturn `${requireBaseUrl()}/${file.path.replace(/^\\/+/, \"\")}`;\n\t}\n\n\tasync function list(): Promise<StreamsDumpsManifest> {\n\t\tconst url = `${requireBaseUrl()}/manifest/latest.json`;\n\t\tconst res = await opts.fetchImpl(url);\n\t\tif (!res.ok) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t`Could not fetch dumps manifest (${res.status}).`,\n\t\t\t\tres.status,\n\t\t\t);\n\t\t}\n\t\
|
|
17
|
+
"import { createHash } from \"node:crypto\";\nimport { verifyStreamsBulkManifestSignature } from \"@secondlayer/shared/streams-bulk-manifest\";\nimport { StreamsServerError, StreamsSignatureError } from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsDumpFile,\n\tStreamsDumps,\n\tStreamsDumpsManifest,\n} from \"./types.ts\";\n\n/**\n * Bulk parquet dumps: the cold backfill path for \"download all the raw data\".\n *\n * The manifest lives at `<dumpsBaseUrl>/manifest/latest.json` and each file's\n * `path` is the object key under the same base. Downloads are verified against\n * the manifest sha256 so a truncated or tampered file is rejected.\n *\n * When `verifyManifest` is set, the manifest's own ed25519 signature is checked\n * (against the published Streams key) BEFORE any file sha256 is trusted — a\n * sha256 is only as trustworthy as the manifest it came from. Default off until\n * historical manifests have been backfilled with signatures.\n */\nexport function createStreamsDumps(opts: {\n\tbaseUrl?: string;\n\tfetchImpl: FetchLike;\n\tverifyManifest?: boolean;\n\tloadPublicKeyPem?: () => Promise<string>;\n}): StreamsDumps {\n\tconst baseUrl = opts.baseUrl?.replace(/\\/+$/, \"\");\n\n\tfunction requireBaseUrl(): string {\n\t\tif (!baseUrl) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t\"Streams dumps require `dumpsBaseUrl` on createStreamsClient.\",\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\treturn baseUrl;\n\t}\n\n\tfunction fileUrl(file: StreamsDumpFile): string {\n\t\treturn `${requireBaseUrl()}/${file.path.replace(/^\\/+/, \"\")}`;\n\t}\n\n\tasync function list(): Promise<StreamsDumpsManifest> {\n\t\tconst url = `${requireBaseUrl()}/manifest/latest.json`;\n\t\tconst res = await opts.fetchImpl(url);\n\t\tif (!res.ok) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t`Could not fetch dumps manifest (${res.status}).`,\n\t\t\t\tres.status,\n\t\t\t);\n\t\t}\n\t\tconst manifest = (await res.json()) as StreamsDumpsManifest;\n\t\tif (opts.verifyManifest) {\n\t\t\tif (!opts.loadPublicKeyPem) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\"Manifest verification is on but no signing key source is configured.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst publicKeyPem = await opts.loadPublicKeyPem();\n\t\t\tif (!verifyStreamsBulkManifestSignature(manifest, publicKeyPem)) {\n\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\"Dumps manifest signature is missing or invalid.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn manifest;\n\t}\n\n\tasync function download(file: StreamsDumpFile): Promise<Uint8Array> {\n\t\tconst res = await opts.fetchImpl(fileUrl(file));\n\t\tif (!res.ok) {\n\t\t\tthrow new StreamsServerError(\n\t\t\t\t`Could not download dump ${file.path} (${res.status}).`,\n\t\t\t\tres.status,\n\t\t\t);\n\t\t}\n\t\tconst bytes = new Uint8Array(await res.arrayBuffer());\n\t\tconst digest = createHash(\"sha256\").update(bytes).digest(\"hex\");\n\t\tif (digest !== file.sha256) {\n\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t`Dump ${file.path} sha256 mismatch (expected ${file.sha256}, got ${digest}).`,\n\t\t\t);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\treturn { list, fileUrl, download };\n}\n",
|
|
18
|
+
"import { ed25519 } from \"@secondlayer/shared\";\nimport { buildQuery } from \"../base.ts\";\nimport { StreamsServerError, StreamsSignatureError } from \"./errors.ts\";\nimport type {\n\tFetchLike,\n\tStreamsEvent,\n\tStreamsEventsSubscribeParams,\n} from \"./types.ts\";\n\ntype VerificationKey = {\n\tpublicKey: ReturnType<typeof ed25519.loadEd25519PublicKey>;\n};\n\n/**\n * Subscribe to the Streams SSE push surface (`GET /v1/streams/events/stream`).\n *\n * A fetch-based reader (not `EventSource`) so it can send the mandatory\n * `Authorization` header — Streams is key-mandatory and `EventSource` can't set\n * headers. Works in browsers and Node 18+. Reconnects from the last delivered\n * cursor on a dropped connection until the caller's signal aborts.\n */\nexport function subscribeStreamsEvents(opts: {\n\tbaseUrl: string;\n\tapiKey: string;\n\tfetchImpl: FetchLike;\n\tverify: boolean;\n\tloadKey: () => Promise<VerificationKey>;\n\treconnectDelayMs?: number;\n\tparams: StreamsEventsSubscribeParams;\n}): () => void {\n\tconst { params } = opts;\n\tconst controller = new AbortController();\n\tconst external = params.signal;\n\tif (external) {\n\t\tif (external.aborted) controller.abort();\n\t\telse\n\t\t\texternal.addEventListener(\"abort\", () => controller.abort(), {\n\t\t\t\tonce: true,\n\t\t\t});\n\t}\n\tlet cursor = params.fromCursor ?? null;\n\tconst reconnectDelayMs = opts.reconnectDelayMs ?? 1000;\n\n\tconst run = async (): Promise<void> => {\n\t\twhile (!controller.signal.aborted) {\n\t\t\ttry {\n\t\t\t\tconst url = `${opts.baseUrl}/v1/streams/events/stream${buildQuery({\n\t\t\t\t\tfrom_cursor: cursor ?? undefined,\n\t\t\t\t\ttypes: params.types,\n\t\t\t\t\tnot_types: params.notTypes,\n\t\t\t\t\tcontract_id: params.contractId,\n\t\t\t\t\tsender: params.sender,\n\t\t\t\t\trecipient: params.recipient,\n\t\t\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\t\t})}`;\n\t\t\t\tconst res = await opts.fetchImpl(url, {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tAuthorization: `Bearer ${opts.apiKey}`,\n\t\t\t\t\t\tAccept: \"text/event-stream\",\n\t\t\t\t\t},\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t});\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\tthrow new StreamsServerError(\n\t\t\t\t\t\t`Streams SSE returned ${res.status}.`,\n\t\t\t\t\t\tres.status,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!res.body) {\n\t\t\t\t\tthrow new StreamsServerError(\"Streams SSE response has no body.\", 0);\n\t\t\t\t}\n\t\t\t\tfor await (const frame of parseSseFrames(res.body, controller.signal)) {\n\t\t\t\t\tif (frame.event === \"ping\" || !frame.data) continue;\n\t\t\t\t\tlet parsed: { event?: StreamsEvent; sig?: string };\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparsed = JSON.parse(frame.data);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tcontinue; // ignore non-JSON frames\n\t\t\t\t\t}\n\t\t\t\t\tif (!parsed.event) continue;\n\t\t\t\t\tif (opts.verify) {\n\t\t\t\t\t\tconst key = await opts.loadKey();\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!parsed.sig ||\n\t\t\t\t\t\t\t!ed25519.verifyEd25519(\n\t\t\t\t\t\t\t\tJSON.stringify(parsed.event),\n\t\t\t\t\t\t\t\tparsed.sig,\n\t\t\t\t\t\t\t\tkey.publicKey,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new StreamsSignatureError(\n\t\t\t\t\t\t\t\t\"Streams SSE frame signature is missing or invalid.\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcursor = (parsed.event as { cursor?: string }).cursor ?? cursor;\n\t\t\t\t\tawait params.onEvent(parsed.event);\n\t\t\t\t}\n\t\t\t\t// Clean end (server closed the stream): reconnect from `cursor`.\n\t\t\t} catch (err) {\n\t\t\t\tif (controller.signal.aborted) return;\n\t\t\t\tparams.onError?.(err);\n\t\t\t\tawait sleep(reconnectDelayMs, controller.signal);\n\t\t\t}\n\t\t}\n\t};\n\tvoid run();\n\treturn () => controller.abort();\n}\n\nfunction sleep(ms: number, signal: AbortSignal): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tif (signal.aborted) return resolve();\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve();\n\t\t};\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nasync function* parseSseFrames(\n\tbody: ReadableStream<Uint8Array>,\n\tsignal: AbortSignal,\n): AsyncGenerator<{ event?: string; data?: string }> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\ttry {\n\t\twhile (!signal.aborted) {\n\t\t\tconst { value, done } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\tlet sep = buffer.indexOf(\"\\n\\n\");\n\t\t\twhile (sep !== -1) {\n\t\t\t\tyield parseFrame(buffer.slice(0, sep));\n\t\t\t\tbuffer = buffer.slice(sep + 2);\n\t\t\t\tsep = buffer.indexOf(\"\\n\\n\");\n\t\t\t}\n\t\t}\n\t} finally {\n\t\ttry {\n\t\t\tawait reader.cancel();\n\t\t} catch {\n\t\t\t// best-effort\n\t\t}\n\t}\n}\n\nfunction parseFrame(raw: string): { event?: string; data?: string } {\n\tlet event: string | undefined;\n\tconst data: string[] = [];\n\tfor (const line of raw.split(\"\\n\")) {\n\t\tif (line.startsWith(\"data:\")) {\n\t\t\tdata.push(line.slice(line.startsWith(\"data: \") ? 6 : 5));\n\t\t} else if (line.startsWith(\"event:\")) {\n\t\t\tevent = line.slice(line.startsWith(\"event: \") ? 7 : 6).trim();\n\t\t}\n\t}\n\treturn { event, data: data.length > 0 ? data.join(\"\\n\") : undefined };\n}\n",
|
|
18
19
|
"import type {\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\nimport { BaseClient } from \"../base.ts\";\n\nexport type {\n\tChainTrigger,\n\tChainTriggerType,\n\tCreateSubscriptionRequest,\n\tCreateSubscriptionResponse,\n\tDeadRow,\n\tDeliveryRow,\n\tReplayResult,\n\tRotateSecretResponse,\n\tSubscriptionDetail,\n\tSubscriptionFormat,\n\tSubscriptionKind,\n\tSubscriptionRuntime,\n\tSubscriptionStatus,\n\tSubscriptionSummary,\n\tUpdateSubscriptionRequest,\n} from \"@secondlayer/shared/schemas/subscriptions\";\n// `trigger.*` chain-trigger builders for direct chain-level subscriptions\n// (`create({ triggers: [trigger.contractCall({ ... })] })`).\nexport { trigger } from \"@secondlayer/shared/schemas/subscriptions\";\n\nexport class Subscriptions extends BaseClient {\n\tasync list(): Promise<{ data: SubscriptionSummary[] }> {\n\t\treturn this.request<{ data: SubscriptionSummary[] }>(\n\t\t\t\"GET\",\n\t\t\t\"/api/subscriptions\",\n\t\t);\n\t}\n\n\tasync get(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\"GET\", `/api/subscriptions/${id}`);\n\t}\n\n\tasync create(\n\t\tinput: CreateSubscriptionRequest,\n\t): Promise<CreateSubscriptionResponse> {\n\t\treturn this.request<CreateSubscriptionResponse>(\n\t\t\t\"POST\",\n\t\t\t\"/api/subscriptions\",\n\t\t\tinput,\n\t\t);\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\tpatch: UpdateSubscriptionRequest,\n\t): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"PATCH\",\n\t\t\t`/api/subscriptions/${id}`,\n\t\t\tpatch,\n\t\t);\n\t}\n\n\tasync pause(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/pause`,\n\t\t);\n\t}\n\n\tasync resume(id: string): Promise<SubscriptionDetail> {\n\t\treturn this.request<SubscriptionDetail>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/resume`,\n\t\t);\n\t}\n\n\tasync delete(id: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\"DELETE\", `/api/subscriptions/${id}`);\n\t}\n\n\tasync rotateSecret(id: string): Promise<RotateSecretResponse> {\n\t\treturn this.request<RotateSecretResponse>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/rotate-secret`,\n\t\t);\n\t}\n\n\tasync recentDeliveries(id: string): Promise<{ data: DeliveryRow[] }> {\n\t\treturn this.request<{ data: DeliveryRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/deliveries`,\n\t\t);\n\t}\n\n\tasync replay(\n\t\tid: string,\n\t\trange: { fromBlock: number; toBlock: number },\n\t): Promise<ReplayResult> {\n\t\treturn this.request<ReplayResult>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/replay`,\n\t\t\trange,\n\t\t);\n\t}\n\n\tasync dead(id: string): Promise<{ data: DeadRow[] }> {\n\t\treturn this.request<{ data: DeadRow[] }>(\n\t\t\t\"GET\",\n\t\t\t`/api/subscriptions/${id}/dead`,\n\t\t);\n\t}\n\n\tasync requeueDead(id: string, outboxId: string): Promise<{ ok: true }> {\n\t\treturn this.request<{ ok: true }>(\n\t\t\t\"POST\",\n\t\t\t`/api/subscriptions/${id}/dead/${outboxId}/requeue`,\n\t\t);\n\t}\n}\n",
|
|
19
20
|
"import type { SubgraphSummary } from \"@secondlayer/shared/schemas\";\nimport { ApiKeys } from \"./api-keys/client.ts\";\nimport { BaseClient } from \"./base.ts\";\nimport type { SecondLayerOptions } from \"./base.ts\";\nimport { Contracts } from \"./contracts/client.ts\";\nimport { Datasets } from \"./datasets/client.ts\";\nimport { Index } from \"./index-api/client.ts\";\nimport type { IndexTip } from \"./index-api/client.ts\";\nimport { createStreamsClient } from \"./streams/client.ts\";\nimport type { StreamsClient, StreamsTip } from \"./streams/types.ts\";\nimport { Subgraphs } from \"./subgraphs/client.ts\";\nimport type { SubgraphOperationStatus } from \"./subgraphs/client.ts\";\nimport { Subscriptions } from \"./subscriptions/client.ts\";\n\nexport interface ContextAccount {\n\temail: string;\n\tplan: string;\n}\n\nexport interface ActiveSubgraphOperation {\n\tsubgraph: string;\n\toperationId: string;\n\tkind: SubgraphOperationStatus[\"kind\"];\n\tstatus: SubgraphOperationStatus[\"status\"];\n\tprogress: number | null;\n}\n\n/**\n * A point-in-time orientation snapshot for an agent: who you are, the live tips,\n * and what you own. Each field is `null` when it couldn't be read (e.g. no key,\n * or a free-tier key for a Build+ surface) so the snapshot never throws.\n */\nexport interface ContextSnapshot {\n\taccount: ContextAccount | null;\n\tstreamsTip: StreamsTip | null;\n\tindexTip: IndexTip | null;\n\tsubgraphs: SubgraphSummary[] | null;\n\tsubscriptions: { count: number; byStatus: Record<string, number> } | null;\n\t/** In-flight reindex operations (bounded to subgraphs reporting `reindexing`). */\n\tactiveOperations: ActiveSubgraphOperation[] | null;\n}\n\nexport class SecondLayer extends BaseClient {\n\treadonly streams: StreamsClient;\n\treadonly index: Index;\n\treadonly datasets: Datasets;\n\treadonly contracts: Contracts;\n\treadonly subgraphs: Subgraphs;\n\treadonly subscriptions: Subscriptions;\n\treadonly apiKeys: ApiKeys;\n\n\tconstructor(options: Partial<SecondLayerOptions> = {}) {\n\t\tsuper(options);\n\t\tthis.streams = createStreamsClient({\n\t\t\tapiKey: options.apiKey ?? \"\",\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\tfetchImpl: options.fetchImpl,\n\t\t});\n\t\tthis.index = new Index(options);\n\t\tthis.datasets = new Datasets(options);\n\t\tthis.contracts = new Contracts(options);\n\t\tthis.subgraphs = new Subgraphs(options);\n\t\tthis.subscriptions = new Subscriptions(options);\n\t\tthis.apiKeys = new ApiKeys(options);\n\t}\n\n\t/**\n\t * Assemble a {@link ContextSnapshot} — the same orientation an MCP agent reads\n\t * from `secondlayer://context`, but available to any SDK/CLI consumer. Reads\n\t * run concurrently and degrade to `null` per field on failure.\n\t */\n\tasync context(): Promise<ContextSnapshot> {\n\t\tconst safe = <T>(p: Promise<T>): Promise<T | null> =>\n\t\t\tp.then((v) => v).catch(() => null);\n\n\t\tconst [account, streamsTip, indexEnv, subgraphsRes, subscriptionsRes] =\n\t\t\tawait Promise.all([\n\t\t\t\tsafe(this.request<ContextAccount>(\"GET\", \"/api/accounts/me\")),\n\t\t\t\tsafe(this.streams.tip()),\n\t\t\t\tsafe(this.index.canonical.list({ limit: 1 })),\n\t\t\t\tsafe(this.subgraphs.list()),\n\t\t\t\tsafe(this.subscriptions.list()),\n\t\t\t]);\n\n\t\tconst subgraphs = subgraphsRes?.data ?? null;\n\n\t\tlet subscriptions: ContextSnapshot[\"subscriptions\"] = null;\n\t\tif (subscriptionsRes) {\n\t\t\tconst byStatus: Record<string, number> = {};\n\t\t\tfor (const s of subscriptionsRes.data) {\n\t\t\t\tbyStatus[s.status] = (byStatus[s.status] ?? 0) + 1;\n\t\t\t}\n\t\t\tsubscriptions = { count: subscriptionsRes.data.length, byStatus };\n\t\t}\n\n\t\t// In-flight ops: only probe subgraphs that report `reindexing`, so this\n\t\t// stays cheap (usually zero extra calls) instead of N+1 over every subgraph.\n\t\tlet activeOperations: ActiveSubgraphOperation[] | null = null;\n\t\tif (subgraphs) {\n\t\t\tconst probed = await Promise.all(\n\t\t\t\tsubgraphs\n\t\t\t\t\t.filter((s) => s.status === \"reindexing\")\n\t\t\t\t\t.map(async (s) => {\n\t\t\t\t\t\tconst res = await safe(this.subgraphs.operations(s.name));\n\t\t\t\t\t\tconst op = res?.operations.find(\n\t\t\t\t\t\t\t(o) => o.status === \"queued\" || o.status === \"running\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn op\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tsubgraph: s.name,\n\t\t\t\t\t\t\t\t\toperationId: op.id,\n\t\t\t\t\t\t\t\t\tkind: op.kind,\n\t\t\t\t\t\t\t\t\tstatus: op.status,\n\t\t\t\t\t\t\t\t\tprogress: op.progress,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\t}),\n\t\t\t);\n\t\t\tactiveOperations = probed.filter(\n\t\t\t\t(o): o is ActiveSubgraphOperation => o !== null,\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\taccount,\n\t\t\tstreamsTip,\n\t\t\tindexTip: indexEnv?.tip ?? null,\n\t\t\tsubgraphs,\n\t\t\tsubscriptions,\n\t\t\tactiveOperations,\n\t\t};\n\t}\n}\n",
|
|
20
21
|
"import type { InferSubgraphClient } from \"@secondlayer/subgraphs\";\nimport type { SecondLayerOptions } from \"../base.ts\";\nimport { SecondLayer } from \"../client.ts\";\nimport { Subgraphs } from \"./client.ts\";\n\n/**\n * Returns a typed client for a subgraph defined with `defineSubgraph()`.\n *\n * Accepts a plain options object, a `SecondLayer` instance, or a `Subgraphs` instance.\n *\n * @example\n * ```ts\n * import mySubgraph from './subgraphs/my-subgraph'\n * import { getSubgraph } from '@secondlayer/sdk'\n *\n * const client = getSubgraph(mySubgraph, { apiKey: 'sl_...' })\n * const rows = await client.transfers.findMany({ where: { sender: 'SP...' } })\n * ```\n */\nexport function getSubgraph<\n\tT extends { name: string; schema: Record<string, unknown> },\n>(\n\tdef: T,\n\toptions: Partial<SecondLayerOptions> | SecondLayer | Subgraphs = {},\n): InferSubgraphClient<T> {\n\tif (options instanceof Subgraphs) {\n\t\treturn options.typed(def);\n\t}\n\tif (options instanceof SecondLayer) {\n\t\treturn options.subgraphs.typed(def);\n\t}\n\treturn new Subgraphs(options).typed(def);\n}\n"
|
|
21
22
|
],
|
|
22
|
-
"mappings": ";AAeO,MAAM,iBAAiB,MAAM;AAAA,EAG3B;AAAA,EAGA;AAAA,EAEA;AAAA,EAPR,WAAW,CAEH,QACP,SAEO,MAEA,MACN;AAAA,IACD,MAAM,OAAO;AAAA,IAPN;AAAA,IAGA;AAAA,IAEA;AAAA,IAGP,KAAK,OAAO;AAAA;AAEd;AAAA;AAMO,MAAM,6BAA6B,SAAS;AAAA,EAE1C;AAAA,EACA;AAAA,EAFR,WAAW,CACH,gBACA,iBACP,UAAU,8BAA8B,4BAA4B,kBACnE;AAAA,IACD,MAAM,KAAK,SAAS,EAAE,gBAAgB,gBAAgB,CAAC;AAAA,IAJhD;AAAA,IACA;AAAA,IAIP,KAAK,OAAO;AAAA;AAEd;;;ACzBA,IAAM,mBAAmB;AAMlB,SAAS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AAU,MAAM,GAAG;AAAA,EACnC;AAAA,EACA,OAAO,IAAI,UAAU,OAAO,EAAE,MAAM,GAAG;AAAA;",
|
|
24
|
+
"debugId": "B6D6E26DCF0C5E6064756E2164756E21",
|
|
24
25
|
"names": []
|
|
25
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"prepublishOnly": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@secondlayer/shared": "^6.
|
|
39
|
+
"@secondlayer/shared": "^6.23.0",
|
|
40
40
|
"@secondlayer/stacks": "^2.2.1",
|
|
41
|
-
"@secondlayer/subgraphs": "^3.7.
|
|
41
|
+
"@secondlayer/subgraphs": "^3.7.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/bun": "latest",
|