@secondlayer/sdk 6.47.0 → 6.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1286 -1211
- package/dist/index.js +8 -1
- package/dist/index.js.map +5 -5
- package/dist/sinks/bun-sqlite.d.ts +158 -0
- package/dist/sinks/bun-sqlite.js +255 -0
- package/dist/sinks/bun-sqlite.js.map +12 -0
- package/dist/sinks/core.d.ts +195 -0
- package/dist/sinks/core.js +215 -0
- package/dist/sinks/core.js.map +11 -0
- package/dist/sinks/drizzle.d.ts +184 -0
- package/dist/sinks/drizzle.js +309 -0
- package/dist/sinks/drizzle.js.map +12 -0
- package/dist/sinks/kysely.d.ts +87 -2
- package/dist/sinks/kysely.js +91 -54
- package/dist/sinks/kysely.js.map +6 -5
- package/dist/sinks/testing.d.ts +183 -0
- package/dist/sinks/testing.js +194 -0
- package/dist/sinks/testing.js.map +10 -0
- package/dist/streams/index.d.ts +558 -482
- package/dist/streams/index.js +7 -1
- package/dist/streams/index.js.map +4 -4
- package/dist/streams/rows.d.ts +208 -208
- package/dist/streams/rows.js +1 -1
- package/dist/streams/rows.js.map +2 -2
- package/dist/subgraphs/index.d.ts +1044 -968
- package/dist/subgraphs/index.js +8 -1
- package/dist/subgraphs/index.js.map +5 -5
- package/dist/x402.d.ts +49 -49
- package/dist/x402.js +1 -1
- package/dist/x402.js.map +2 -2
- package/package.json +25 -3
|
@@ -61,9 +61,9 @@ interface SubgraphRowsEnvelope<T = unknown> {
|
|
|
61
61
|
rows: T[];
|
|
62
62
|
next_cursor: string | null;
|
|
63
63
|
tip: {
|
|
64
|
-
block_height: number
|
|
65
|
-
subgraph_height: number
|
|
66
|
-
blocks_behind: number
|
|
64
|
+
block_height: number;
|
|
65
|
+
subgraph_height: number;
|
|
66
|
+
blocks_behind: number;
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
interface BundleSubgraphResponse {
|
|
@@ -79,34 +79,34 @@ interface BundleSubgraphResponse {
|
|
|
79
79
|
}
|
|
80
80
|
declare class Subgraphs extends BaseClient {
|
|
81
81
|
list(): Promise<{
|
|
82
|
-
data: SubgraphSummary[]
|
|
82
|
+
data: SubgraphSummary[];
|
|
83
83
|
}>;
|
|
84
84
|
get(name: string): Promise<SubgraphDetail>;
|
|
85
85
|
openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
|
|
86
86
|
schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
|
|
87
87
|
markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
|
|
88
88
|
reindex(name: string, options?: {
|
|
89
|
-
fromBlock?: number
|
|
90
|
-
toBlock?: number
|
|
89
|
+
fromBlock?: number;
|
|
90
|
+
toBlock?: number;
|
|
91
91
|
}): Promise<ReindexResponse>;
|
|
92
92
|
stop(name: string): Promise<{
|
|
93
|
-
message: string
|
|
94
|
-
operationId?: string
|
|
95
|
-
status?: string
|
|
93
|
+
message: string;
|
|
94
|
+
operationId?: string;
|
|
95
|
+
status?: string;
|
|
96
96
|
}>;
|
|
97
97
|
backfill(name: string, options: {
|
|
98
|
-
fromBlock: number
|
|
99
|
-
toBlock: number
|
|
98
|
+
fromBlock: number;
|
|
99
|
+
toBlock: number;
|
|
100
100
|
}): Promise<ReindexResponse>;
|
|
101
101
|
gaps(name: string, opts?: {
|
|
102
|
-
limit?: number
|
|
103
|
-
offset?: number
|
|
104
|
-
resolved?: boolean
|
|
102
|
+
limit?: number;
|
|
103
|
+
offset?: number;
|
|
104
|
+
resolved?: boolean;
|
|
105
105
|
}): Promise<SubgraphGapsResponse>;
|
|
106
106
|
delete(name: string, options?: {
|
|
107
|
-
force?: boolean
|
|
107
|
+
force?: boolean;
|
|
108
108
|
}): Promise<{
|
|
109
|
-
message: string
|
|
109
|
+
message: string;
|
|
110
110
|
}>;
|
|
111
111
|
/**
|
|
112
112
|
* Publish: claim the name in the global public namespace and open anon
|
|
@@ -114,14 +114,14 @@ declare class Subgraphs extends BaseClient {
|
|
|
114
114
|
* holds the public name.
|
|
115
115
|
*/
|
|
116
116
|
publish(name: string): Promise<{
|
|
117
|
-
name: string
|
|
118
|
-
visibility: "public"
|
|
119
|
-
url: string
|
|
117
|
+
name: string;
|
|
118
|
+
visibility: "public";
|
|
119
|
+
url: string;
|
|
120
120
|
}>;
|
|
121
121
|
/** Make reads private again (owning account's bearer key required). */
|
|
122
122
|
unpublish(name: string): Promise<{
|
|
123
|
-
name: string
|
|
124
|
-
visibility: "private"
|
|
123
|
+
name: string;
|
|
124
|
+
visibility: "private";
|
|
125
125
|
}>;
|
|
126
126
|
/**
|
|
127
127
|
* Open /v1 read: cursor-paginated rows. Anon works for public subgraphs;
|
|
@@ -129,11 +129,11 @@ declare class Subgraphs extends BaseClient {
|
|
|
129
129
|
* `next_cursor`.
|
|
130
130
|
*/
|
|
131
131
|
rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset" | "sort"> & {
|
|
132
|
-
cursor?: string
|
|
132
|
+
cursor?: string;
|
|
133
133
|
}): Promise<SubgraphRowsEnvelope<T>>;
|
|
134
134
|
/** Recent reindex/backfill operations for a subgraph, newest first. */
|
|
135
135
|
operations(name: string): Promise<{
|
|
136
|
-
operations: SubgraphOperationStatus[]
|
|
136
|
+
operations: SubgraphOperationStatus[];
|
|
137
137
|
}>;
|
|
138
138
|
/** Status of a single operation (poll the `operationId` returned by
|
|
139
139
|
* reindex/backfill/stop until `status` is terminal). */
|
|
@@ -145,11 +145,11 @@ declare class Subgraphs extends BaseClient {
|
|
|
145
145
|
* authoring loop so Vercel's serverless runtime doesn't have to run esbuild.
|
|
146
146
|
*/
|
|
147
147
|
bundle(data: {
|
|
148
|
-
code: string
|
|
148
|
+
code: string;
|
|
149
149
|
}): Promise<BundleSubgraphResponse>;
|
|
150
150
|
queryTable(name: string, table: string, params?: SubgraphQueryParams): Promise<unknown[]>;
|
|
151
151
|
queryTableCount(name: string, table: string, params?: SubgraphQueryParams): Promise<{
|
|
152
|
-
count: number
|
|
152
|
+
count: number;
|
|
153
153
|
}>;
|
|
154
154
|
queryTableAggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
|
|
155
155
|
/**
|
|
@@ -165,8 +165,8 @@ declare class Subgraphs extends BaseClient {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
typed<T extends {
|
|
168
|
-
name: string
|
|
169
|
-
schema: Record<string, unknown
|
|
168
|
+
name: string;
|
|
169
|
+
schema: Record<string, unknown>;
|
|
170
170
|
}>(def: T): InferSubgraphClient<T>;
|
|
171
171
|
private createTableClient;
|
|
172
172
|
}
|
|
@@ -221,12 +221,12 @@ declare class ApiKeys extends BaseClient {
|
|
|
221
221
|
* account-level (owner) key or a dashboard session.
|
|
222
222
|
*/
|
|
223
223
|
list(): Promise<{
|
|
224
|
-
keys: ApiKeySummary[]
|
|
224
|
+
keys: ApiKeySummary[];
|
|
225
225
|
}>;
|
|
226
226
|
/** Revoke a key by id. Existing requests with that key stop working. */
|
|
227
227
|
revoke(id: string): Promise<{
|
|
228
|
-
revoked: true
|
|
229
|
-
id: string
|
|
228
|
+
revoked: true;
|
|
229
|
+
id: string;
|
|
230
230
|
}>;
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
@@ -274,7 +274,7 @@ declare class Contracts extends BaseClient {
|
|
|
274
274
|
* Pass `{ includeAbi: true }` for the full ABI blob. Resolves null on 404.
|
|
275
275
|
*/
|
|
276
276
|
get(contractId: string, opts?: {
|
|
277
|
-
includeAbi?: boolean
|
|
277
|
+
includeAbi?: boolean;
|
|
278
278
|
}): Promise<ContractSummary | null>;
|
|
279
279
|
}
|
|
280
280
|
import { Pox5EventTopic } from "@secondlayer/stacks/pox5";
|
|
@@ -312,8 +312,8 @@ interface TransactionProof {
|
|
|
312
312
|
/** Present when consensus-level verification is available: the reward cycle and
|
|
313
313
|
* its signer set, against which the header's signer signatures are checked. */
|
|
314
314
|
consensus?: {
|
|
315
|
-
reward_cycle: number
|
|
316
|
-
reward_set: RewardSet
|
|
315
|
+
reward_cycle: number;
|
|
316
|
+
reward_set: RewardSet;
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
@@ -331,12 +331,83 @@ interface TransactionProof {
|
|
|
331
331
|
* The interface is dependency-free on purpose: implementations with real
|
|
332
332
|
* database drivers live behind subpath exports (`@secondlayer/sdk/sinks/*`)
|
|
333
333
|
* so the root entry ships no DB dependency.
|
|
334
|
+
*
|
|
335
|
+
* ## The contract
|
|
336
|
+
*
|
|
337
|
+
* Binding on every implementation; the conformance kit
|
|
338
|
+
* (`@secondlayer/sdk/sinks/testing`) probes each one. Violations are SILENT
|
|
339
|
+
* in production — they surface as gaps or duplicates weeks later, never as
|
|
340
|
+
* errors at the violation site — which is why they are spelled out here and
|
|
341
|
+
* mechanically tested.
|
|
342
|
+
*
|
|
343
|
+
* What the loop guarantees the sink:
|
|
344
|
+
*
|
|
345
|
+
* 1. **Init-before-first-page.** `loadCursor` is called exactly once, before
|
|
346
|
+
* the first fetch — even when the caller passed an explicit `fromCursor`.
|
|
347
|
+
* It is the sink's init hook: create checkpoint storage, validate
|
|
348
|
+
* rollback preconditions.
|
|
349
|
+
* 2. **Deterministic replay.** Re-reading from the same cursor yields the
|
|
350
|
+
* same rows in the same order. `cursor` is therefore a valid idempotency
|
|
351
|
+
* key: an append-only sink can dedup on it with no contract change.
|
|
352
|
+
* 3. **At-least-once delivery.** A batch whose commit outcome was lost (crash
|
|
353
|
+
* after commit, before the loop observed it) is re-committed on restart
|
|
354
|
+
* with the SAME cursor and the same rows.
|
|
355
|
+
*
|
|
356
|
+
* What the sink must guarantee — `commitBatch`:
|
|
357
|
+
*
|
|
358
|
+
* 4. **Rows+cursor atomicity.** The handler's writes and `cursor` commit in
|
|
359
|
+
* ONE transaction. Committing them separately is the classic torn-batch
|
|
360
|
+
* bug: a crash between the two either re-delivers (duplicates) or skips
|
|
361
|
+
* (gap) depending on the order.
|
|
362
|
+
* 5. **Abort on throw.** A throw from `write` aborts the WHOLE transaction —
|
|
363
|
+
* neither rows nor cursor land — so a crashed batch is simply re-read.
|
|
364
|
+
* 6. **The lent transaction is the real one.** `write(tx)` receives the same
|
|
365
|
+
* live transaction the cursor commits in; every handler write must go
|
|
366
|
+
* through it. Writes outside `tx` escape atomicity AND rollback.
|
|
367
|
+
* 7. **Replay safety.** Committing the same cursor twice must not corrupt
|
|
368
|
+
* state (per #3 the rows are identical; upsert/dedup make it exact).
|
|
369
|
+
*
|
|
370
|
+
* What the sink must guarantee — `rollback`:
|
|
371
|
+
*
|
|
372
|
+
* 8. **Delete+rewind atomicity.** Undoing rows at/above the fork and
|
|
373
|
+
* committing `rewindCursor` happen in ONE transaction. A crash between
|
|
374
|
+
* them resumes above the fork and the deleted range is never re-read —
|
|
375
|
+
* the silent-gap bug.
|
|
376
|
+
* 9. **Inclusive fork point.** Undo AT OR ABOVE `forkPointHeight` (`>=`) —
|
|
377
|
+
* the new canonical chain re-supplies the fork block itself.
|
|
378
|
+
* 10. **Idempotent.** The loop may re-apply the same rollback after a crash
|
|
379
|
+
* (reorgs are deduped in memory only); a second application must be a
|
|
380
|
+
* harmless no-op.
|
|
381
|
+
* 11. **Scope by height, not cursor.** On a page reporting several forks the
|
|
382
|
+
* loop calls `rollback` once per fork: each call carries its own
|
|
383
|
+
* `forkPointHeight` but ALL carry the same `rewindCursor` (the lowest
|
|
384
|
+
* fork point). Derive the undo range from `forkPointHeight` only; a
|
|
385
|
+
* sink that derives it from `rewindCursor` under-deletes silently.
|
|
386
|
+
*
|
|
387
|
+
* Error semantics and concurrency:
|
|
388
|
+
*
|
|
389
|
+
* 12. **Throw, don't swallow; no internal retry.** The loop owns retry
|
|
390
|
+
* policy. A swallowed commit error advances the loop past unwritten
|
|
391
|
+
* data; an internal retry can double-apply around a partial failure.
|
|
392
|
+
* 13. **Single writer per checkpoint id.** The loop assumes one live
|
|
393
|
+
* consumer per checkpoint identity. A sink that can detect a second
|
|
394
|
+
* writer (e.g. a lock) must fail loudly — never block or interleave.
|
|
334
395
|
*/
|
|
335
396
|
interface ConsumerSink<Tx = unknown> {
|
|
336
397
|
/** Phantom marker carrying `Tx` in a directly-inferable position, so the
|
|
337
398
|
* consume loops' `TTx` type parameter resolves from the `sink` option
|
|
338
399
|
* (never set at runtime). */
|
|
339
400
|
readonly _tx?: Tx;
|
|
401
|
+
/** Static capabilities, read by the loop before the first fetch to fail
|
|
402
|
+
* fast on impossible pairings. */
|
|
403
|
+
readonly capabilities?: {
|
|
404
|
+
/** This sink cannot undo committed rows (append-only store, ClickHouse,
|
|
405
|
+
* parquet, …), so `rollback` is unimplementable and following the
|
|
406
|
+
* unfinalized tip would corrupt it on the first fork. The loop throws
|
|
407
|
+
* loudly unless consuming with `finalizedOnly: true` — in that mode
|
|
408
|
+
* reorgs never reach the sink and `rollback` may simply throw. */
|
|
409
|
+
finalizedOnly?: boolean;
|
|
410
|
+
};
|
|
340
411
|
/** The committed checkpoint, or `null` on first run. Called once, before
|
|
341
412
|
* the first page. Implementations may create their checkpoint storage
|
|
342
413
|
* here and SHOULD validate their rollback preconditions (e.g. that every
|
|
@@ -356,6 +427,11 @@ interface ConsumerSink<Tx = unknown> {
|
|
|
356
427
|
* without the rewound cursor is the classic silent-gap bug: a crash
|
|
357
428
|
* between the two writes resumes above the fork and the deleted range is
|
|
358
429
|
* never re-read.
|
|
430
|
+
*
|
|
431
|
+
* On a multi-fork page this is called once PER fork, every call with the
|
|
432
|
+
* same `rewindCursor` (the lowest fork point) but its own
|
|
433
|
+
* `forkPointHeight` — scope the undo by `forkPointHeight` only (contract
|
|
434
|
+
* invariant #11), and expect re-application after a crash (#10).
|
|
359
435
|
*/
|
|
360
436
|
rollback(forkPointHeight: number, rewindCursor: string): Promise<void>;
|
|
361
437
|
}
|
|
@@ -363,75 +439,75 @@ interface ConsumerSink<Tx = unknown> {
|
|
|
363
439
|
* is unchanged (an intersection with `unknown` is an identity, so
|
|
364
440
|
* contextual typing of `onBatch` callbacks never degrades to a union). */
|
|
365
441
|
type WithSinkTx<TTx> = [TTx] extends [never] ? unknown : {
|
|
366
|
-
tx: TTx
|
|
442
|
+
tx: TTx;
|
|
367
443
|
};
|
|
368
444
|
import { StreamsEventType } from "@secondlayer/shared";
|
|
369
445
|
/** A Clarity value as Streams serves it: the canonical hex string, a typed
|
|
370
446
|
* object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
|
|
371
447
|
* Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
|
|
372
448
|
type StreamsClarityValue = string | {
|
|
373
|
-
hex: string
|
|
449
|
+
hex: string;
|
|
374
450
|
} | Record<string, unknown>;
|
|
375
451
|
type StxTransferPayload = {
|
|
376
|
-
sender: string
|
|
377
|
-
recipient: string
|
|
378
|
-
amount: string
|
|
379
|
-
memo?: string
|
|
452
|
+
sender: string;
|
|
453
|
+
recipient: string;
|
|
454
|
+
amount: string;
|
|
455
|
+
memo?: string;
|
|
380
456
|
};
|
|
381
457
|
type StxMintPayload = {
|
|
382
|
-
recipient: string
|
|
383
|
-
amount: string
|
|
458
|
+
recipient: string;
|
|
459
|
+
amount: string;
|
|
384
460
|
};
|
|
385
461
|
type StxBurnPayload = {
|
|
386
|
-
sender: string
|
|
387
|
-
amount: string
|
|
462
|
+
sender: string;
|
|
463
|
+
amount: string;
|
|
388
464
|
};
|
|
389
465
|
type StxLockPayload = {
|
|
390
|
-
locked_address: string
|
|
391
|
-
locked_amount: string
|
|
392
|
-
unlock_height: string
|
|
466
|
+
locked_address: string;
|
|
467
|
+
locked_amount: string;
|
|
468
|
+
unlock_height: string;
|
|
393
469
|
};
|
|
394
470
|
type FtTransferPayload = {
|
|
395
|
-
asset_identifier: string
|
|
396
|
-
sender: string
|
|
397
|
-
recipient: string
|
|
398
|
-
amount: string
|
|
471
|
+
asset_identifier: string;
|
|
472
|
+
sender: string;
|
|
473
|
+
recipient: string;
|
|
474
|
+
amount: string;
|
|
399
475
|
};
|
|
400
476
|
type FtMintPayload = {
|
|
401
|
-
asset_identifier: string
|
|
402
|
-
recipient: string
|
|
403
|
-
amount: string
|
|
477
|
+
asset_identifier: string;
|
|
478
|
+
recipient: string;
|
|
479
|
+
amount: string;
|
|
404
480
|
};
|
|
405
481
|
type FtBurnPayload = {
|
|
406
|
-
asset_identifier: string
|
|
407
|
-
sender: string
|
|
408
|
-
amount: string
|
|
482
|
+
asset_identifier: string;
|
|
483
|
+
sender: string;
|
|
484
|
+
amount: string;
|
|
409
485
|
};
|
|
410
486
|
type NftTransferPayload = {
|
|
411
|
-
asset_identifier: string
|
|
412
|
-
sender: string
|
|
413
|
-
recipient: string
|
|
414
|
-
value: StreamsClarityValue
|
|
487
|
+
asset_identifier: string;
|
|
488
|
+
sender: string;
|
|
489
|
+
recipient: string;
|
|
490
|
+
value: StreamsClarityValue;
|
|
415
491
|
/** Canonical serialized hex of `value`, when the stream carries it. */
|
|
416
|
-
raw_value?: string
|
|
492
|
+
raw_value?: string;
|
|
417
493
|
};
|
|
418
494
|
type NftMintPayload = {
|
|
419
|
-
asset_identifier: string
|
|
420
|
-
recipient: string
|
|
421
|
-
value: StreamsClarityValue
|
|
422
|
-
raw_value?: string
|
|
495
|
+
asset_identifier: string;
|
|
496
|
+
recipient: string;
|
|
497
|
+
value: StreamsClarityValue;
|
|
498
|
+
raw_value?: string;
|
|
423
499
|
};
|
|
424
500
|
type NftBurnPayload = {
|
|
425
|
-
asset_identifier: string
|
|
426
|
-
sender: string
|
|
427
|
-
value: StreamsClarityValue
|
|
428
|
-
raw_value?: string
|
|
501
|
+
asset_identifier: string;
|
|
502
|
+
sender: string;
|
|
503
|
+
value: StreamsClarityValue;
|
|
504
|
+
raw_value?: string;
|
|
429
505
|
};
|
|
430
506
|
type PrintPayload = {
|
|
431
|
-
contract_id?: string | null
|
|
432
|
-
topic?: string
|
|
433
|
-
value?: unknown
|
|
434
|
-
raw_value?: string
|
|
507
|
+
contract_id?: string | null;
|
|
508
|
+
topic?: string;
|
|
509
|
+
value?: unknown;
|
|
510
|
+
raw_value?: string;
|
|
435
511
|
};
|
|
436
512
|
type StreamsEventBase = {
|
|
437
513
|
/**
|
|
@@ -439,97 +515,97 @@ type StreamsEventBase = {
|
|
|
439
515
|
* it as the primary key of your projection rows — replaying a batch then
|
|
440
516
|
* upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
|
|
441
517
|
*/
|
|
442
|
-
cursor: string
|
|
443
|
-
block_height: number
|
|
444
|
-
block_hash: string
|
|
445
|
-
burn_block_height: number
|
|
446
|
-
tx_id: string
|
|
447
|
-
tx_index: number
|
|
448
|
-
event_index: number
|
|
449
|
-
contract_id: string | null
|
|
450
|
-
ts: string
|
|
518
|
+
cursor: string;
|
|
519
|
+
block_height: number;
|
|
520
|
+
block_hash: string;
|
|
521
|
+
burn_block_height: number;
|
|
522
|
+
tx_id: string;
|
|
523
|
+
tx_index: number;
|
|
524
|
+
event_index: number;
|
|
525
|
+
contract_id: string | null;
|
|
526
|
+
ts: string;
|
|
451
527
|
/**
|
|
452
528
|
* True when this event's block is past the finality boundary (immutable).
|
|
453
529
|
* Optional for back-compat; the API always sets it on Streams responses.
|
|
454
530
|
*/
|
|
455
|
-
finalized?: boolean
|
|
531
|
+
finalized?: boolean;
|
|
456
532
|
/**
|
|
457
533
|
* Labels whose filter group this event satisfied, present only when the
|
|
458
534
|
* request used a labelled `filters` map. The SDK dispatches on it for you
|
|
459
535
|
* (`on.<label>`), so handlers rarely read it directly.
|
|
460
536
|
*/
|
|
461
|
-
matched?: string[]
|
|
537
|
+
matched?: string[];
|
|
462
538
|
};
|
|
463
539
|
type StreamsEventOf<
|
|
464
540
|
T extends StreamsEventType,
|
|
465
541
|
P
|
|
466
542
|
> = StreamsEventBase & {
|
|
467
|
-
event_type: T
|
|
468
|
-
payload: P
|
|
543
|
+
event_type: T;
|
|
544
|
+
payload: P;
|
|
469
545
|
};
|
|
470
546
|
/** A raw Streams event. Discriminated on `event_type`, so `event.payload`
|
|
471
547
|
* narrows to the matching payload shape once the type is checked. */
|
|
472
548
|
type StreamsEvent = StreamsEventOf<"stx_transfer", StxTransferPayload> | StreamsEventOf<"stx_mint", StxMintPayload> | StreamsEventOf<"stx_burn", StxBurnPayload> | StreamsEventOf<"stx_lock", StxLockPayload> | StreamsEventOf<"ft_transfer", FtTransferPayload> | StreamsEventOf<"ft_mint", FtMintPayload> | StreamsEventOf<"ft_burn", FtBurnPayload> | StreamsEventOf<"nft_transfer", NftTransferPayload> | StreamsEventOf<"nft_mint", NftMintPayload> | StreamsEventOf<"nft_burn", NftBurnPayload> | StreamsEventOf<"print", PrintPayload>;
|
|
473
549
|
type StreamsTip = {
|
|
474
|
-
block_height: number
|
|
475
|
-
block_hash: string
|
|
476
|
-
burn_block_height: number
|
|
550
|
+
block_height: number;
|
|
551
|
+
block_hash: string;
|
|
552
|
+
burn_block_height: number;
|
|
477
553
|
/**
|
|
478
554
|
* Highest Stacks block past the burn-confirmation finality boundary.
|
|
479
555
|
* Optional for back-compat; the API always sets it.
|
|
480
556
|
*/
|
|
481
|
-
finalized_height?: number
|
|
482
|
-
lag_seconds: number
|
|
557
|
+
finalized_height?: number;
|
|
558
|
+
lag_seconds: number;
|
|
483
559
|
/**
|
|
484
560
|
* Oldest height still seekable on the live API for the caller's tier
|
|
485
561
|
* (`tip - retention`). `null` = unlimited retention. Older reads must use the
|
|
486
562
|
* cold dumps lane. Optional for back-compat.
|
|
487
563
|
*/
|
|
488
|
-
oldest_seekable_height?: number | null
|
|
564
|
+
oldest_seekable_height?: number | null;
|
|
489
565
|
/** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
|
|
490
|
-
oldest_cursor?: string | null
|
|
566
|
+
oldest_cursor?: string | null;
|
|
491
567
|
};
|
|
492
568
|
type StreamsCanonicalBlock = {
|
|
493
|
-
block_height: number
|
|
494
|
-
block_hash: string
|
|
495
|
-
burn_block_height: number
|
|
496
|
-
burn_block_hash: string | null
|
|
497
|
-
is_canonical: true
|
|
569
|
+
block_height: number;
|
|
570
|
+
block_hash: string;
|
|
571
|
+
burn_block_height: number;
|
|
572
|
+
burn_block_hash: string | null;
|
|
573
|
+
is_canonical: true;
|
|
498
574
|
};
|
|
499
575
|
type StreamsReorg = {
|
|
500
|
-
detected_at: string
|
|
501
|
-
fork_point_height: number
|
|
576
|
+
detected_at: string;
|
|
577
|
+
fork_point_height: number;
|
|
502
578
|
orphaned_range: {
|
|
503
|
-
from: string
|
|
504
|
-
to: string
|
|
505
|
-
}
|
|
579
|
+
from: string;
|
|
580
|
+
to: string;
|
|
581
|
+
};
|
|
506
582
|
/**
|
|
507
583
|
* First position of the new canonical chain at the fork, `fork:0`
|
|
508
584
|
* (INCLUSIVE). Not an exclusive resume token — resuming directly from it
|
|
509
585
|
* skips `fork:0`. The consumer rewinds to the foot of `fork_point_height`
|
|
510
586
|
* (`Cursor.atHeight`) to re-read the new run from `fork:0` inclusive.
|
|
511
587
|
*/
|
|
512
|
-
new_canonical_tip: string
|
|
588
|
+
new_canonical_tip: string;
|
|
513
589
|
};
|
|
514
590
|
type StreamsEventsEnvelope<TEvent = StreamsEvent> = {
|
|
515
|
-
events: TEvent[]
|
|
516
|
-
next_cursor: string | null
|
|
517
|
-
tip: StreamsTip
|
|
518
|
-
reorgs: StreamsReorg[]
|
|
591
|
+
events: TEvent[];
|
|
592
|
+
next_cursor: string | null;
|
|
593
|
+
tip: StreamsTip;
|
|
594
|
+
reorgs: StreamsReorg[];
|
|
519
595
|
};
|
|
520
596
|
type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
|
|
521
597
|
/** The StreamsEvent union narrowed to a `types` selection — what a
|
|
522
598
|
* const-generic `types: ["ft_transfer"]` buys at the type level. */
|
|
523
599
|
type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
|
|
524
|
-
event_type: T[number]
|
|
600
|
+
event_type: T[number];
|
|
525
601
|
}>;
|
|
526
602
|
type StreamsReorgsListParams = {
|
|
527
|
-
since: string
|
|
528
|
-
limit?: number
|
|
603
|
+
since: string;
|
|
604
|
+
limit?: number;
|
|
529
605
|
};
|
|
530
606
|
type StreamsReorgsListEnvelope = {
|
|
531
|
-
reorgs: StreamsReorg[]
|
|
532
|
-
next_since: string | null
|
|
607
|
+
reorgs: StreamsReorg[];
|
|
608
|
+
next_since: string | null;
|
|
533
609
|
};
|
|
534
610
|
/** A filter that matches a single value or any value in a list. */
|
|
535
611
|
type StreamsFilterValue = string | readonly string[];
|
|
@@ -538,11 +614,11 @@ type StreamsFilterValue = string | readonly string[];
|
|
|
538
614
|
* map OR together server-side.
|
|
539
615
|
*/
|
|
540
616
|
type StreamsLabelledFilter = {
|
|
541
|
-
types?: readonly StreamsEventType[]
|
|
542
|
-
contractId?: StreamsFilterValue
|
|
543
|
-
sender?: StreamsFilterValue
|
|
544
|
-
recipient?: StreamsFilterValue
|
|
545
|
-
assetIdentifier?: string
|
|
617
|
+
types?: readonly StreamsEventType[];
|
|
618
|
+
contractId?: StreamsFilterValue;
|
|
619
|
+
sender?: StreamsFilterValue;
|
|
620
|
+
recipient?: StreamsFilterValue;
|
|
621
|
+
assetIdentifier?: string;
|
|
546
622
|
};
|
|
547
623
|
/** A map of label → filter group. Labels are yours; the server echoes them. */
|
|
548
624
|
type StreamsFilterMap = Record<string, StreamsLabelledFilter>;
|
|
@@ -555,65 +631,65 @@ type StreamsEventForFilter<
|
|
|
555
631
|
F,
|
|
556
632
|
D extends boolean = false
|
|
557
633
|
> = F extends {
|
|
558
|
-
types: readonly (infer T extends StreamsEventType)[]
|
|
634
|
+
types: readonly (infer T extends StreamsEventType)[];
|
|
559
635
|
} ? D extends true ? Extract<IndexEvent, {
|
|
560
|
-
event_type: T
|
|
636
|
+
event_type: T;
|
|
561
637
|
}> : Extract<StreamsEvent, {
|
|
562
|
-
event_type: T
|
|
638
|
+
event_type: T;
|
|
563
639
|
}> : D extends true ? IndexEvent : StreamsEvent;
|
|
564
640
|
type StreamsEventsListParams = {
|
|
565
|
-
cursor?: string | null
|
|
566
|
-
fromHeight?: number
|
|
567
|
-
toHeight?: number
|
|
568
|
-
types?: readonly StreamsEventType[]
|
|
641
|
+
cursor?: string | null;
|
|
642
|
+
fromHeight?: number;
|
|
643
|
+
toHeight?: number;
|
|
644
|
+
types?: readonly StreamsEventType[];
|
|
569
645
|
/** Event types to exclude (applied after `types`). */
|
|
570
|
-
notTypes?: readonly StreamsEventType[]
|
|
571
|
-
contractId?: StreamsFilterValue
|
|
572
|
-
sender?: StreamsFilterValue
|
|
573
|
-
recipient?: StreamsFilterValue
|
|
574
|
-
assetIdentifier?: string
|
|
646
|
+
notTypes?: readonly StreamsEventType[];
|
|
647
|
+
contractId?: StreamsFilterValue;
|
|
648
|
+
sender?: StreamsFilterValue;
|
|
649
|
+
recipient?: StreamsFilterValue;
|
|
650
|
+
assetIdentifier?: string;
|
|
575
651
|
/**
|
|
576
652
|
* Labelled filter groups. The groups OR together in one scan and each
|
|
577
653
|
* returned event carries the labels it matched (`event.matched`) — two
|
|
578
654
|
* unrelated concerns share one page, one cursor, one checkpoint.
|
|
579
655
|
*/
|
|
580
|
-
filters?: StreamsFilterMap
|
|
581
|
-
limit?: number
|
|
656
|
+
filters?: StreamsFilterMap;
|
|
657
|
+
limit?: number;
|
|
582
658
|
};
|
|
583
659
|
type StreamsEventsStreamParams = {
|
|
584
|
-
fromCursor?: string | null
|
|
585
|
-
types?: readonly StreamsEventType[]
|
|
586
|
-
notTypes?: readonly StreamsEventType[]
|
|
587
|
-
contractId?: StreamsFilterValue
|
|
588
|
-
sender?: StreamsFilterValue
|
|
589
|
-
recipient?: StreamsFilterValue
|
|
590
|
-
assetIdentifier?: string
|
|
660
|
+
fromCursor?: string | null;
|
|
661
|
+
types?: readonly StreamsEventType[];
|
|
662
|
+
notTypes?: readonly StreamsEventType[];
|
|
663
|
+
contractId?: StreamsFilterValue;
|
|
664
|
+
sender?: StreamsFilterValue;
|
|
665
|
+
recipient?: StreamsFilterValue;
|
|
666
|
+
assetIdentifier?: string;
|
|
591
667
|
/** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
|
|
592
|
-
filters?: StreamsFilterMap
|
|
593
|
-
batchSize?: number
|
|
594
|
-
emptyBackoffMs?: number
|
|
595
|
-
maxPages?: number
|
|
596
|
-
maxEmptyPolls?: number
|
|
597
|
-
signal?: AbortSignal
|
|
668
|
+
filters?: StreamsFilterMap;
|
|
669
|
+
batchSize?: number;
|
|
670
|
+
emptyBackoffMs?: number;
|
|
671
|
+
maxPages?: number;
|
|
672
|
+
maxEmptyPolls?: number;
|
|
673
|
+
signal?: AbortSignal;
|
|
598
674
|
};
|
|
599
675
|
type StreamsEventsSubscribeParams = {
|
|
600
676
|
/** Resume strictly after this cursor; omit to live-tail from the tip. */
|
|
601
|
-
fromCursor?: string | null
|
|
602
|
-
types?: readonly StreamsEventType[]
|
|
603
|
-
notTypes?: readonly StreamsEventType[]
|
|
604
|
-
contractId?: StreamsFilterValue
|
|
605
|
-
sender?: StreamsFilterValue
|
|
606
|
-
recipient?: StreamsFilterValue
|
|
607
|
-
assetIdentifier?: string
|
|
677
|
+
fromCursor?: string | null;
|
|
678
|
+
types?: readonly StreamsEventType[];
|
|
679
|
+
notTypes?: readonly StreamsEventType[];
|
|
680
|
+
contractId?: StreamsFilterValue;
|
|
681
|
+
sender?: StreamsFilterValue;
|
|
682
|
+
recipient?: StreamsFilterValue;
|
|
683
|
+
assetIdentifier?: string;
|
|
608
684
|
/** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
|
|
609
|
-
filters?: StreamsFilterMap
|
|
685
|
+
filters?: StreamsFilterMap;
|
|
610
686
|
/** Abort to unsubscribe (the returned function does the same). */
|
|
611
|
-
signal?: AbortSignal
|
|
687
|
+
signal?: AbortSignal;
|
|
612
688
|
/** Called for each pushed event, in order. */
|
|
613
|
-
onEvent: (event: StreamsEvent) => void | Promise<void
|
|
689
|
+
onEvent: (event: StreamsEvent) => void | Promise<void>;
|
|
614
690
|
/** Called on a connection error; the subscription auto-reconnects from the
|
|
615
691
|
* last delivered cursor unless the signal has aborted. */
|
|
616
|
-
onError?: (err: unknown) => void
|
|
692
|
+
onError?: (err: unknown) => void;
|
|
617
693
|
};
|
|
618
694
|
/**
|
|
619
695
|
* The checkpoint the SDK computes for a batch. Persist `cursor` inside the same
|
|
@@ -640,14 +716,14 @@ type ConsumerBatchContext<
|
|
|
640
716
|
TReorg = unknown
|
|
641
717
|
> = {
|
|
642
718
|
/** Checkpoint to commit alongside your rows. */
|
|
643
|
-
cursor: string | null
|
|
719
|
+
cursor: string | null;
|
|
644
720
|
/** Highest canonical block the sweep has reached. `null` before the first
|
|
645
721
|
* row of a fresh consume. */
|
|
646
|
-
height: number | null
|
|
722
|
+
height: number | null;
|
|
647
723
|
/** Chain tip as of this page's read. */
|
|
648
|
-
tipHeight: number
|
|
724
|
+
tipHeight: number;
|
|
649
725
|
/** `tipHeight - height`, floored at 0. `null` until `height` is known. */
|
|
650
|
-
blocksBehind: number | null
|
|
726
|
+
blocksBehind: number | null;
|
|
651
727
|
/**
|
|
652
728
|
* The full tip for this page — `StreamsTip` or `IndexTip` depending on the
|
|
653
729
|
* surface. Exposed here so a handler never needs the `envelope` parameter,
|
|
@@ -655,12 +731,12 @@ type ConsumerBatchContext<
|
|
|
655
731
|
* `finalizedOnly` mistake becomes reachable (`return envelope.next_cursor`
|
|
656
732
|
* jumps the cursor past events that were filtered out and never delivered).
|
|
657
733
|
*/
|
|
658
|
-
tip: TTip
|
|
734
|
+
tip: TTip;
|
|
659
735
|
/**
|
|
660
736
|
* Reorgs reported alongside this page; empty when none. Rollback still
|
|
661
737
|
* belongs in `onReorg` — this is for observability inside a batch.
|
|
662
738
|
*/
|
|
663
|
-
reorgs: readonly TReorg[]
|
|
739
|
+
reorgs: readonly TReorg[];
|
|
664
740
|
};
|
|
665
741
|
/** @deprecated Use {@link ConsumerBatchContext} — the Index and Streams loops
|
|
666
742
|
* share one shape now. Kept as an alias so existing annotations compile. */
|
|
@@ -670,20 +746,20 @@ type StreamsBatchContext = ConsumerBatchContext;
|
|
|
670
746
|
* inside the same transaction as your rollback so the two commit atomically.
|
|
671
747
|
*/
|
|
672
748
|
type StreamsReorgContext = {
|
|
673
|
-
cursor: string
|
|
749
|
+
cursor: string;
|
|
674
750
|
};
|
|
675
751
|
type StreamsEventsConsumeParams<
|
|
676
752
|
TTx = never,
|
|
677
753
|
D extends boolean = false,
|
|
678
754
|
F extends StreamsFilterMap = Record<never, never>
|
|
679
755
|
> = {
|
|
680
|
-
fromCursor?: string | null
|
|
756
|
+
fromCursor?: string | null;
|
|
681
757
|
/**
|
|
682
758
|
* Deliver events pre-decoded as the flat, `event_type`-discriminated rows
|
|
683
759
|
* Index serves (`IndexEvent`), so Streams consumption reads identically
|
|
684
760
|
* to Index consumption — no guard+decode pairs in your handler.
|
|
685
761
|
*/
|
|
686
|
-
decoded?: D
|
|
762
|
+
decoded?: D;
|
|
687
763
|
/**
|
|
688
764
|
* Destination adapter that owns the checkpoint + rollback transaction
|
|
689
765
|
* (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
|
|
@@ -692,29 +768,29 @@ type StreamsEventsConsumeParams<
|
|
|
692
768
|
* transaction), reorg rollback is automatic, and `onBatch`'s return value
|
|
693
769
|
* is ignored.
|
|
694
770
|
*/
|
|
695
|
-
sink?: ConsumerSink<TTx
|
|
771
|
+
sink?: ConsumerSink<TTx>;
|
|
696
772
|
/** Fires once per page, before `onBatch` and before any early return. */
|
|
697
|
-
onProgress?: (ctx: ConsumerBatchContext) => void
|
|
698
|
-
mode?: "tail" | "bounded"
|
|
773
|
+
onProgress?: (ctx: ConsumerBatchContext) => void;
|
|
774
|
+
mode?: "tail" | "bounded";
|
|
699
775
|
/**
|
|
700
776
|
* Emit only finalized (immutable) events and never surface reorgs. The SDK
|
|
701
777
|
* checkpoints at the last finalized event and re-reads the unfinalized tail
|
|
702
778
|
* until it settles. Trades finality lag for zero reorg handling; `onReorg` is
|
|
703
779
|
* ignored.
|
|
704
780
|
*/
|
|
705
|
-
finalizedOnly?: boolean
|
|
706
|
-
types?: readonly StreamsEventType[]
|
|
707
|
-
notTypes?: readonly StreamsEventType[]
|
|
708
|
-
contractId?: StreamsFilterValue
|
|
709
|
-
sender?: StreamsFilterValue
|
|
710
|
-
recipient?: StreamsFilterValue
|
|
711
|
-
assetIdentifier?: string
|
|
781
|
+
finalizedOnly?: boolean;
|
|
782
|
+
types?: readonly StreamsEventType[];
|
|
783
|
+
notTypes?: readonly StreamsEventType[];
|
|
784
|
+
contractId?: StreamsFilterValue;
|
|
785
|
+
sender?: StreamsFilterValue;
|
|
786
|
+
recipient?: StreamsFilterValue;
|
|
787
|
+
assetIdentifier?: string;
|
|
712
788
|
/**
|
|
713
789
|
* Labelled filter groups. The groups OR together in ONE server-side scan,
|
|
714
790
|
* so two unrelated concerns share one page, one cursor, and one checkpoint
|
|
715
791
|
* instead of two consume loops. Pair with `on` to handle each label.
|
|
716
792
|
*/
|
|
717
|
-
filters?: F
|
|
793
|
+
filters?: F;
|
|
718
794
|
/**
|
|
719
795
|
* One handler per label in `filters`. Every label must be handled, so
|
|
720
796
|
* adding a label is a compile error until its handler exists.
|
|
@@ -725,8 +801,8 @@ type StreamsEventsConsumeParams<
|
|
|
725
801
|
* labels do not interleave within a page — add `onBatch` when you need
|
|
726
802
|
* strict global order across labels.
|
|
727
803
|
*/
|
|
728
|
-
on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> }
|
|
729
|
-
batchSize?: number
|
|
804
|
+
on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> };
|
|
805
|
+
batchSize?: number;
|
|
730
806
|
/**
|
|
731
807
|
* Apply a page of canonical events. Persist `ctx.cursor` in the same
|
|
732
808
|
* transaction as your writes. Returning a cursor overrides `ctx.cursor` as
|
|
@@ -735,7 +811,7 @@ type StreamsEventsConsumeParams<
|
|
|
735
811
|
* Optional only when `on` handles the page instead; a consume call with
|
|
736
812
|
* neither throws.
|
|
737
813
|
*/
|
|
738
|
-
onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined
|
|
814
|
+
onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
|
|
739
815
|
/**
|
|
740
816
|
* Roll your projection back to `reorg.fork_point_height`, persisting
|
|
741
817
|
* `ctx.cursor` in the same transaction. Called once per *new* reorg
|
|
@@ -743,23 +819,23 @@ type StreamsEventsConsumeParams<
|
|
|
743
819
|
* now-canonical events. Omit it to ignore reorgs (events stay canonical, but
|
|
744
820
|
* stale rows from an orphaned fork are left in place).
|
|
745
821
|
*/
|
|
746
|
-
onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
|
|
822
|
+
onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
|
|
747
823
|
/** Page-fetch retries after the first failure (429/5xx/network only —
|
|
748
824
|
* 4xx and handler throws always propagate). Default 3; `0` disables. */
|
|
749
|
-
retryCount?: number
|
|
825
|
+
retryCount?: number;
|
|
750
826
|
/** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
|
|
751
827
|
* `Retry-After` overrides it. Default 1000. */
|
|
752
|
-
retryDelay?: number
|
|
828
|
+
retryDelay?: number;
|
|
753
829
|
/** Void observer, called before each retry sleep (metrics/logging). */
|
|
754
830
|
onError?: (err: unknown, ctx: {
|
|
755
|
-
attempt: number
|
|
756
|
-
retriesLeft: number
|
|
757
|
-
delayMs: number
|
|
758
|
-
}) => void
|
|
759
|
-
emptyBackoffMs?: number
|
|
760
|
-
maxPages?: number
|
|
761
|
-
maxEmptyPolls?: number
|
|
762
|
-
signal?: AbortSignal
|
|
831
|
+
attempt: number;
|
|
832
|
+
retriesLeft: number;
|
|
833
|
+
delayMs: number;
|
|
834
|
+
}) => void;
|
|
835
|
+
emptyBackoffMs?: number;
|
|
836
|
+
maxPages?: number;
|
|
837
|
+
maxEmptyPolls?: number;
|
|
838
|
+
signal?: AbortSignal;
|
|
763
839
|
};
|
|
764
840
|
/**
|
|
765
841
|
* One yielded page from {@link StreamsClient.consume} — the
|
|
@@ -768,111 +844,111 @@ type StreamsEventsConsumeParams<
|
|
|
768
844
|
*/
|
|
769
845
|
type StreamsBatch<TEvent = StreamsEvent> = {
|
|
770
846
|
/** Canonical events of this page, in cursor order. */
|
|
771
|
-
events: TEvent[]
|
|
847
|
+
events: TEvent[];
|
|
772
848
|
/** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
|
|
773
|
-
cursor: string | null
|
|
774
|
-
tip: StreamsTip
|
|
849
|
+
cursor: string | null;
|
|
850
|
+
tip: StreamsTip;
|
|
775
851
|
/** Chain reorgs reported alongside this page; empty when none. */
|
|
776
|
-
reorgs: StreamsReorg[]
|
|
852
|
+
reorgs: StreamsReorg[];
|
|
777
853
|
};
|
|
778
854
|
type StreamsConsumeParams = {
|
|
779
855
|
/** Resume strictly after this cursor; omit to start from the oldest seekable page. */
|
|
780
|
-
cursor?: string | null
|
|
781
|
-
types?: readonly StreamsEventType[]
|
|
782
|
-
notTypes?: readonly StreamsEventType[]
|
|
783
|
-
contractId?: StreamsFilterValue
|
|
784
|
-
sender?: StreamsFilterValue
|
|
785
|
-
recipient?: StreamsFilterValue
|
|
786
|
-
assetIdentifier?: string
|
|
856
|
+
cursor?: string | null;
|
|
857
|
+
types?: readonly StreamsEventType[];
|
|
858
|
+
notTypes?: readonly StreamsEventType[];
|
|
859
|
+
contractId?: StreamsFilterValue;
|
|
860
|
+
sender?: StreamsFilterValue;
|
|
861
|
+
recipient?: StreamsFilterValue;
|
|
862
|
+
assetIdentifier?: string;
|
|
787
863
|
/** Labelled OR-groups — same semantics as `events.consume`; each returned
|
|
788
864
|
* event echoes the labels it matched. */
|
|
789
|
-
filters?: StreamsFilterMap
|
|
865
|
+
filters?: StreamsFilterMap;
|
|
790
866
|
/** Events per page (the `limit` query param). Default 100. */
|
|
791
|
-
batchSize?: number
|
|
867
|
+
batchSize?: number;
|
|
792
868
|
/** Poll interval while caught up at the tip, in ms. Default 2000. */
|
|
793
|
-
intervalMs?: number
|
|
869
|
+
intervalMs?: number;
|
|
794
870
|
/** Abort to end the iteration. */
|
|
795
|
-
signal?: AbortSignal
|
|
871
|
+
signal?: AbortSignal;
|
|
796
872
|
};
|
|
797
873
|
type StreamsEventsConsumeResult = {
|
|
798
|
-
cursor: string | null
|
|
799
|
-
pages: number
|
|
800
|
-
emptyPolls: number
|
|
874
|
+
cursor: string | null;
|
|
875
|
+
pages: number;
|
|
876
|
+
emptyPolls: number;
|
|
801
877
|
};
|
|
802
878
|
type StreamsEventsReplayParams = {
|
|
803
879
|
/** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
|
|
804
|
-
from?: "genesis" | string
|
|
880
|
+
from?: "genesis" | string;
|
|
805
881
|
/**
|
|
806
882
|
* Called once per finalized dump file, in block order, before live tailing.
|
|
807
883
|
* Process the parquet with your own tooling (e.g. DuckDB) — the SDK does not
|
|
808
884
|
* decode parquet. Use `client.dumps.download(file)` to fetch + verify bytes.
|
|
809
885
|
*/
|
|
810
|
-
onDumpFile: (file: StreamsDumpFile) => Promise<void> | void
|
|
886
|
+
onDumpFile: (file: StreamsDumpFile) => Promise<void> | void;
|
|
811
887
|
/** Called per live page after the dump phase, like `consume`. */
|
|
812
|
-
onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined
|
|
888
|
+
onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined;
|
|
813
889
|
/**
|
|
814
890
|
* Called when the live-tail phase (after the dump backfill) crosses a reorg,
|
|
815
891
|
* before the cursor rewinds and re-reads the now-canonical events — same
|
|
816
892
|
* contract as `consume`. The dump-backfill phase is finalized and never
|
|
817
893
|
* reorgs; omit this to leave stale rows from an orphaned fork in place.
|
|
818
894
|
*/
|
|
819
|
-
onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
|
|
820
|
-
mode?: "tail" | "bounded"
|
|
821
|
-
batchSize?: number
|
|
822
|
-
emptyBackoffMs?: number
|
|
823
|
-
maxPages?: number
|
|
824
|
-
maxEmptyPolls?: number
|
|
825
|
-
signal?: AbortSignal
|
|
895
|
+
onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
|
|
896
|
+
mode?: "tail" | "bounded";
|
|
897
|
+
batchSize?: number;
|
|
898
|
+
emptyBackoffMs?: number;
|
|
899
|
+
maxPages?: number;
|
|
900
|
+
maxEmptyPolls?: number;
|
|
901
|
+
signal?: AbortSignal;
|
|
826
902
|
/** Narrow the LIVE TAIL after the dump phase. The dump files themselves are
|
|
827
903
|
* always all-type (block-partitioned parquet) — filter those in your own
|
|
828
904
|
* tooling while processing each file. */
|
|
829
|
-
types?: readonly StreamsEventType[]
|
|
830
|
-
notTypes?: readonly StreamsEventType[]
|
|
905
|
+
types?: readonly StreamsEventType[];
|
|
906
|
+
notTypes?: readonly StreamsEventType[];
|
|
831
907
|
/** Labelled OR-groups for the live tail, like `consume`. */
|
|
832
|
-
filters?: StreamsFilterMap
|
|
908
|
+
filters?: StreamsFilterMap;
|
|
833
909
|
};
|
|
834
910
|
/** One bulk parquet file in the dumps manifest. `path` is the object key under
|
|
835
911
|
* the dumps base URL. */
|
|
836
912
|
type StreamsDumpFile = {
|
|
837
|
-
path: string
|
|
838
|
-
from_block: number
|
|
839
|
-
to_block: number
|
|
840
|
-
min_cursor: string | null
|
|
841
|
-
max_cursor: string | null
|
|
842
|
-
row_count: number
|
|
843
|
-
byte_size: number
|
|
844
|
-
sha256: string
|
|
845
|
-
schema_version: number
|
|
846
|
-
created_at: string
|
|
913
|
+
path: string;
|
|
914
|
+
from_block: number;
|
|
915
|
+
to_block: number;
|
|
916
|
+
min_cursor: string | null;
|
|
917
|
+
max_cursor: string | null;
|
|
918
|
+
row_count: number;
|
|
919
|
+
byte_size: number;
|
|
920
|
+
sha256: string;
|
|
921
|
+
schema_version: number;
|
|
922
|
+
created_at: string;
|
|
847
923
|
};
|
|
848
924
|
type StreamsDumpsManifest = {
|
|
849
|
-
dataset: string
|
|
850
|
-
network: string
|
|
851
|
-
version: string
|
|
852
|
-
schema_version: number
|
|
853
|
-
generated_at: string
|
|
854
|
-
producer_version: string
|
|
855
|
-
finality_lag_blocks: number
|
|
925
|
+
dataset: string;
|
|
926
|
+
network: string;
|
|
927
|
+
version: string;
|
|
928
|
+
schema_version: number;
|
|
929
|
+
generated_at: string;
|
|
930
|
+
producer_version: string;
|
|
931
|
+
finality_lag_blocks: number;
|
|
856
932
|
/** Cursor at the end of the finalized bulk coverage — hand to live tailing. */
|
|
857
|
-
latest_finalized_cursor: string | null
|
|
933
|
+
latest_finalized_cursor: string | null;
|
|
858
934
|
coverage: {
|
|
859
|
-
from_block: number
|
|
860
|
-
to_block: number
|
|
861
|
-
}
|
|
862
|
-
files: StreamsDumpFile[]
|
|
935
|
+
from_block: number;
|
|
936
|
+
to_block: number;
|
|
937
|
+
};
|
|
938
|
+
files: StreamsDumpFile[];
|
|
863
939
|
/** ed25519 signature over the manifest's canonical bytes. Absent on legacy
|
|
864
940
|
* unsigned manifests. Verified by `list()` when `verifyDumpsManifest` is on. */
|
|
865
|
-
signature?: string
|
|
941
|
+
signature?: string;
|
|
866
942
|
/** Short id of the signing public key. */
|
|
867
|
-
key_id?: string
|
|
943
|
+
key_id?: string;
|
|
868
944
|
};
|
|
869
945
|
type StreamsDumps = {
|
|
870
946
|
/** Fetch and parse the latest dumps manifest. */
|
|
871
|
-
list(): Promise<StreamsDumpsManifest
|
|
947
|
+
list(): Promise<StreamsDumpsManifest>;
|
|
872
948
|
/** Absolute URL for a manifest file. */
|
|
873
|
-
fileUrl(file: StreamsDumpFile): string
|
|
949
|
+
fileUrl(file: StreamsDumpFile): string;
|
|
874
950
|
/** Download a parquet file and verify its sha256 against the manifest. */
|
|
875
|
-
download(file: StreamsDumpFile): Promise<Uint8Array
|
|
951
|
+
download(file: StreamsDumpFile): Promise<Uint8Array>;
|
|
876
952
|
};
|
|
877
953
|
type StreamsClient = {
|
|
878
954
|
/**
|
|
@@ -892,16 +968,16 @@ type StreamsClient = {
|
|
|
892
968
|
/** Narrowing overload: a literal `types` array narrows every batch's
|
|
893
969
|
* event union to exactly those members. */
|
|
894
970
|
consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeParams & {
|
|
895
|
-
types: T
|
|
896
|
-
}): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T
|
|
897
|
-
consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch
|
|
971
|
+
types: T;
|
|
972
|
+
}): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
|
|
973
|
+
consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
|
|
898
974
|
events: {
|
|
899
975
|
/** Narrowing overload, matching `consume`. */
|
|
900
976
|
list<const T extends readonly StreamsEventType[]>(params: StreamsEventsListParams & {
|
|
901
|
-
types: T
|
|
902
|
-
}): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T
|
|
903
|
-
list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope
|
|
904
|
-
byTxId(txId: string): Promise<StreamsEventsListEnvelope
|
|
977
|
+
types: T;
|
|
978
|
+
}): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T>>>;
|
|
979
|
+
list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>;
|
|
980
|
+
byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
|
|
905
981
|
/**
|
|
906
982
|
* Pull pages from Streams and call `onBatch` after each page.
|
|
907
983
|
*
|
|
@@ -916,8 +992,8 @@ type StreamsClient = {
|
|
|
916
992
|
TTx = never,
|
|
917
993
|
D extends boolean = false
|
|
918
994
|
>(params: StreamsEventsConsumeParams<TTx, D, F> & {
|
|
919
|
-
sink?: ConsumerSink<TTx
|
|
920
|
-
}): Promise<StreamsEventsConsumeResult
|
|
995
|
+
sink?: ConsumerSink<TTx>;
|
|
996
|
+
}): Promise<StreamsEventsConsumeResult>;
|
|
921
997
|
/**
|
|
922
998
|
* Backfill from bulk dumps, then continue live from the dump→live seam in
|
|
923
999
|
* one call. Iterates finalized dump files (via `onDumpFile`) in block
|
|
@@ -925,7 +1001,7 @@ type StreamsClient = {
|
|
|
925
1001
|
* (exclusive input → no gap or duplicate at the seam). Requires
|
|
926
1002
|
* `dumpsBaseUrl`.
|
|
927
1003
|
*/
|
|
928
|
-
replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult
|
|
1004
|
+
replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
|
|
929
1005
|
/**
|
|
930
1006
|
* Follow Streams as an async iterator.
|
|
931
1007
|
*
|
|
@@ -935,41 +1011,41 @@ type StreamsClient = {
|
|
|
935
1011
|
*/
|
|
936
1012
|
/** Narrowing overload, matching `consume`. */
|
|
937
1013
|
stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamParams & {
|
|
938
|
-
types: T
|
|
939
|
-
}): AsyncIterable<StreamsEventOfTypes<T
|
|
940
|
-
stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent
|
|
1014
|
+
types: T;
|
|
1015
|
+
}): AsyncIterable<StreamsEventOfTypes<T>>;
|
|
1016
|
+
stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
|
|
941
1017
|
/**
|
|
942
1018
|
* Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
|
|
943
1019
|
* canonical event as the server pushes it (chain cadence, not poll-bounded),
|
|
944
1020
|
* and verifies each frame's inline ed25519 signature when the client was
|
|
945
1021
|
* created with `verify`. Returns an unsubscribe function.
|
|
946
1022
|
*/
|
|
947
|
-
subscribe(params: StreamsEventsSubscribeParams): () => void
|
|
948
|
-
}
|
|
1023
|
+
subscribe(params: StreamsEventsSubscribeParams): () => void;
|
|
1024
|
+
};
|
|
949
1025
|
blocks: {
|
|
950
|
-
events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope
|
|
951
|
-
}
|
|
1026
|
+
events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
|
|
1027
|
+
};
|
|
952
1028
|
reorgs: {
|
|
953
|
-
list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope
|
|
954
|
-
}
|
|
1029
|
+
list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>;
|
|
1030
|
+
};
|
|
955
1031
|
/** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
|
|
956
|
-
dumps: StreamsDumps
|
|
957
|
-
canonical(height: number): Promise<StreamsCanonicalBlock
|
|
958
|
-
tip(): Promise<StreamsTip
|
|
1032
|
+
dumps: StreamsDumps;
|
|
1033
|
+
canonical(height: number): Promise<StreamsCanonicalBlock>;
|
|
1034
|
+
tip(): Promise<StreamsTip>;
|
|
959
1035
|
/** Your own Streams consumption (events today + this month) and tier limits. */
|
|
960
|
-
usage(): Promise<StreamsUsage
|
|
1036
|
+
usage(): Promise<StreamsUsage>;
|
|
961
1037
|
};
|
|
962
1038
|
type StreamsUsage = {
|
|
963
|
-
product: "streams"
|
|
964
|
-
tier: string
|
|
1039
|
+
product: "streams";
|
|
1040
|
+
tier: string;
|
|
965
1041
|
limits: {
|
|
966
|
-
rate_limit_per_second: number | null
|
|
967
|
-
retention_days: number | null
|
|
968
|
-
}
|
|
1042
|
+
rate_limit_per_second: number | null;
|
|
1043
|
+
retention_days: number | null;
|
|
1044
|
+
};
|
|
969
1045
|
usage: {
|
|
970
|
-
events_today: number
|
|
971
|
-
events_this_month: number
|
|
972
|
-
}
|
|
1046
|
+
events_today: number;
|
|
1047
|
+
events_this_month: number;
|
|
1048
|
+
};
|
|
973
1049
|
};
|
|
974
1050
|
type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
975
1051
|
/** Options shared by both consume loops' page-fetch retry. Vocabulary matches
|
|
@@ -977,28 +1053,28 @@ type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
|
977
1053
|
* language across the family, not a third. */
|
|
978
1054
|
type PageRetryOptions = {
|
|
979
1055
|
/** Retries after the first failure. Default 3; `0` disables. */
|
|
980
|
-
retryCount?: number
|
|
1056
|
+
retryCount?: number;
|
|
981
1057
|
/** Base delay in ms; the n-th retry waits `retryDelay * n` (matches the
|
|
982
1058
|
* stacks transport). A server `Retry-After` overrides it. Default 1000. */
|
|
983
|
-
retryDelay?: number
|
|
1059
|
+
retryDelay?: number;
|
|
984
1060
|
/** Void observer, called before each retry sleep (metrics/logging). The
|
|
985
1061
|
* retry policy owns the decision; this cannot change it. */
|
|
986
1062
|
onError?: (err: unknown, ctx: {
|
|
987
|
-
attempt: number
|
|
988
|
-
retriesLeft: number
|
|
989
|
-
delayMs: number
|
|
990
|
-
}) => void
|
|
1063
|
+
attempt: number;
|
|
1064
|
+
retriesLeft: number;
|
|
1065
|
+
delayMs: number;
|
|
1066
|
+
}) => void;
|
|
991
1067
|
};
|
|
992
1068
|
/** Minimum shape a consumed Index row must expose. */
|
|
993
1069
|
type IndexFeedItem = {
|
|
994
|
-
cursor: string
|
|
995
|
-
block_height: number
|
|
1070
|
+
cursor: string;
|
|
1071
|
+
block_height: number;
|
|
996
1072
|
};
|
|
997
1073
|
/** Minimum envelope shape of a consumable Index feed page. */
|
|
998
1074
|
type IndexFeedEnvelope = {
|
|
999
|
-
next_cursor: string | null
|
|
1000
|
-
tip: IndexTip
|
|
1001
|
-
reorgs: IndexReorg[]
|
|
1075
|
+
next_cursor: string | null;
|
|
1076
|
+
tip: IndexTip;
|
|
1077
|
+
reorgs: IndexReorg[];
|
|
1002
1078
|
};
|
|
1003
1079
|
/** Consumer options shared by `index.events.consume` and
|
|
1004
1080
|
* `index.contractCalls.consume`. Same contract as the Streams consumer:
|
|
@@ -1011,18 +1087,18 @@ type IndexConsumeOptions<
|
|
|
1011
1087
|
> = {
|
|
1012
1088
|
/** Resume from a committed checkpoint. Without it (and without
|
|
1013
1089
|
* `fromHeight`) the API serves only the recent default window. */
|
|
1014
|
-
fromCursor?: string | null
|
|
1090
|
+
fromCursor?: string | null;
|
|
1015
1091
|
/** Start a fresh sweep at this height (e.g. `0` for genesis backfill).
|
|
1016
1092
|
* Ignored once a cursor exists (including a sink's committed cursor). */
|
|
1017
|
-
fromHeight?: number
|
|
1093
|
+
fromHeight?: number;
|
|
1018
1094
|
/** `tail` (default) keeps polling at the tip; `bounded` returns on the
|
|
1019
1095
|
* first empty page. */
|
|
1020
|
-
mode?: "tail" | "bounded"
|
|
1096
|
+
mode?: "tail" | "bounded";
|
|
1021
1097
|
/** Emit only rows at or below the tip's `finalized_height`; the
|
|
1022
1098
|
* unfinalized tail is re-read each poll until it settles. Finalized data
|
|
1023
1099
|
* never reorgs, so `onReorg` is skipped entirely. */
|
|
1024
|
-
finalizedOnly?: boolean
|
|
1025
|
-
batchSize?: number
|
|
1100
|
+
finalizedOnly?: boolean;
|
|
1101
|
+
batchSize?: number;
|
|
1026
1102
|
/**
|
|
1027
1103
|
* Destination adapter that owns the checkpoint + rollback transaction
|
|
1028
1104
|
* (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
|
|
@@ -1031,37 +1107,37 @@ type IndexConsumeOptions<
|
|
|
1031
1107
|
* transaction — a throw aborts both), reorg rollback is automatic (no
|
|
1032
1108
|
* `onReorg` needed), and `onBatch`'s return value is ignored.
|
|
1033
1109
|
*/
|
|
1034
|
-
sink?: ConsumerSink<TTx
|
|
1110
|
+
sink?: ConsumerSink<TTx>;
|
|
1035
1111
|
/** Fires once per page, before `onBatch` and before any early return —
|
|
1036
1112
|
* an empty page still proves the loop is alive. Feed it to
|
|
1037
1113
|
* `consumerHealth().record`. */
|
|
1038
|
-
onProgress?: (ctx: ConsumerBatchContext) => void
|
|
1039
|
-
onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined
|
|
1114
|
+
onProgress?: (ctx: ConsumerBatchContext) => void;
|
|
1115
|
+
onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
|
|
1040
1116
|
onReorg?: (reorg: IndexReorg, ctx: {
|
|
1041
|
-
cursor: string
|
|
1042
|
-
}) => Promise<void> | void
|
|
1043
|
-
sleep?: Sleep
|
|
1044
|
-
emptyBackoffMs?: number
|
|
1045
|
-
maxPages?: number
|
|
1046
|
-
maxEmptyPolls?: number
|
|
1047
|
-
signal?: AbortSignal
|
|
1117
|
+
cursor: string;
|
|
1118
|
+
}) => Promise<void> | void;
|
|
1119
|
+
sleep?: Sleep;
|
|
1120
|
+
emptyBackoffMs?: number;
|
|
1121
|
+
maxPages?: number;
|
|
1122
|
+
maxEmptyPolls?: number;
|
|
1123
|
+
signal?: AbortSignal;
|
|
1048
1124
|
/** Page-fetch retries after the first failure (429/5xx/network only —
|
|
1049
1125
|
* 4xx and handler throws always propagate). Default 3; `0` disables. */
|
|
1050
|
-
retryCount?: number
|
|
1126
|
+
retryCount?: number;
|
|
1051
1127
|
/** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
|
|
1052
1128
|
* `Retry-After` overrides it. Default 1000. */
|
|
1053
|
-
retryDelay?: number
|
|
1129
|
+
retryDelay?: number;
|
|
1054
1130
|
/** Void observer, called before each retry sleep. Cannot change the retry
|
|
1055
1131
|
* decision — the policy owns it. */
|
|
1056
|
-
onError?: PageRetryOptions["onError"]
|
|
1132
|
+
onError?: PageRetryOptions["onError"];
|
|
1057
1133
|
};
|
|
1058
1134
|
type IndexTip = {
|
|
1059
|
-
block_height: number
|
|
1135
|
+
block_height: number;
|
|
1060
1136
|
/** Highest height treated as immutable (past the burn-confirmation
|
|
1061
1137
|
* finality boundary). Rows at or below it never reorg — `finalizedOnly`
|
|
1062
1138
|
* consumers gate on this, since Index rows carry no per-event flag. */
|
|
1063
|
-
finalized_height: number
|
|
1064
|
-
lag_seconds: number
|
|
1139
|
+
finalized_height: number;
|
|
1140
|
+
lag_seconds: number;
|
|
1065
1141
|
};
|
|
1066
1142
|
/**
|
|
1067
1143
|
* A chain reorg overlapping a returned page's height range. Height-keyed feeds
|
|
@@ -1074,54 +1150,54 @@ type IndexTip = {
|
|
|
1074
1150
|
* inclusive. Empty when the page spans no reorg.
|
|
1075
1151
|
*/
|
|
1076
1152
|
type IndexReorg = {
|
|
1077
|
-
id: string
|
|
1078
|
-
detected_at: string
|
|
1079
|
-
fork_point_height: number
|
|
1080
|
-
old_index_block_hash: string | null
|
|
1081
|
-
new_index_block_hash: string | null
|
|
1153
|
+
id: string;
|
|
1154
|
+
detected_at: string;
|
|
1155
|
+
fork_point_height: number;
|
|
1156
|
+
old_index_block_hash: string | null;
|
|
1157
|
+
new_index_block_hash: string | null;
|
|
1082
1158
|
/** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */
|
|
1083
1159
|
orphaned_range: {
|
|
1084
|
-
from: string
|
|
1085
|
-
to: string
|
|
1086
|
-
}
|
|
1160
|
+
from: string;
|
|
1161
|
+
to: string;
|
|
1162
|
+
};
|
|
1087
1163
|
/**
|
|
1088
1164
|
* First position of the new canonical chain at the fork, `fork:0`
|
|
1089
1165
|
* (INCLUSIVE). Not an exclusive resume token — resuming a `(bh,ei) > cursor`
|
|
1090
1166
|
* read directly from it would skip `fork:0`. To re-read the new run, rewind
|
|
1091
1167
|
* to the foot of `fork_point_height` (`Cursor.atHeight`), not to this value.
|
|
1092
1168
|
*/
|
|
1093
|
-
new_canonical_tip: string
|
|
1169
|
+
new_canonical_tip: string;
|
|
1094
1170
|
};
|
|
1095
1171
|
type IndexUsage = {
|
|
1096
|
-
product: "index"
|
|
1097
|
-
tier: string
|
|
1172
|
+
product: "index";
|
|
1173
|
+
tier: string;
|
|
1098
1174
|
limits: {
|
|
1099
|
-
rate_limit_per_second: number | null
|
|
1100
|
-
}
|
|
1175
|
+
rate_limit_per_second: number | null;
|
|
1176
|
+
};
|
|
1101
1177
|
usage: {
|
|
1102
|
-
decoded_events_today: number
|
|
1103
|
-
decoded_events_this_month: number
|
|
1104
|
-
}
|
|
1178
|
+
decoded_events_today: number;
|
|
1179
|
+
decoded_events_this_month: number;
|
|
1180
|
+
};
|
|
1105
1181
|
};
|
|
1106
1182
|
type FtTransfer = {
|
|
1107
|
-
cursor: string
|
|
1108
|
-
block_height: number
|
|
1109
|
-
block_time?: string | null
|
|
1110
|
-
tx_id: string
|
|
1111
|
-
tx_index: number
|
|
1112
|
-
event_index: number
|
|
1113
|
-
event_type: "ft_transfer"
|
|
1114
|
-
contract_id: string
|
|
1115
|
-
asset_identifier: string
|
|
1116
|
-
sender: string
|
|
1117
|
-
recipient: string
|
|
1118
|
-
amount: string
|
|
1183
|
+
cursor: string;
|
|
1184
|
+
block_height: number;
|
|
1185
|
+
block_time?: string | null;
|
|
1186
|
+
tx_id: string;
|
|
1187
|
+
tx_index: number;
|
|
1188
|
+
event_index: number;
|
|
1189
|
+
event_type: "ft_transfer";
|
|
1190
|
+
contract_id: string;
|
|
1191
|
+
asset_identifier: string;
|
|
1192
|
+
sender: string;
|
|
1193
|
+
recipient: string;
|
|
1194
|
+
amount: string;
|
|
1119
1195
|
};
|
|
1120
1196
|
type FtTransfersEnvelope<TRow = FtTransfer> = {
|
|
1121
|
-
events: TRow[]
|
|
1122
|
-
next_cursor: string | null
|
|
1123
|
-
tip: IndexTip
|
|
1124
|
-
reorgs: IndexReorg[]
|
|
1197
|
+
events: TRow[];
|
|
1198
|
+
next_cursor: string | null;
|
|
1199
|
+
tip: IndexTip;
|
|
1200
|
+
reorgs: IndexReorg[];
|
|
1125
1201
|
};
|
|
1126
1202
|
/** Transfer columns that survive any projection — the consume contract
|
|
1127
1203
|
* (`cursor`, `block_height`) plus the `event_type` discriminant. */
|
|
@@ -1135,40 +1211,40 @@ type FtTransfersListParams = {
|
|
|
1135
1211
|
* one a compile error rather than `undefined` at runtime. Omitting
|
|
1136
1212
|
* `block_time` also lets the server skip the blocks join.
|
|
1137
1213
|
*/
|
|
1138
|
-
fields?: readonly (keyof FtTransfer & string)[]
|
|
1139
|
-
cursor?: string | null
|
|
1140
|
-
fromCursor?: string | null
|
|
1141
|
-
limit?: number
|
|
1142
|
-
contractId?: string
|
|
1143
|
-
assetIdentifier?: string
|
|
1144
|
-
sender?: string
|
|
1145
|
-
recipient?: string
|
|
1146
|
-
fromHeight?: number
|
|
1147
|
-
toHeight?: number
|
|
1214
|
+
fields?: readonly (keyof FtTransfer & string)[];
|
|
1215
|
+
cursor?: string | null;
|
|
1216
|
+
fromCursor?: string | null;
|
|
1217
|
+
limit?: number;
|
|
1218
|
+
contractId?: string;
|
|
1219
|
+
assetIdentifier?: string;
|
|
1220
|
+
sender?: string;
|
|
1221
|
+
recipient?: string;
|
|
1222
|
+
fromHeight?: number;
|
|
1223
|
+
toHeight?: number;
|
|
1148
1224
|
};
|
|
1149
1225
|
type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & {
|
|
1150
|
-
batchSize?: number
|
|
1151
|
-
signal?: AbortSignal
|
|
1226
|
+
batchSize?: number;
|
|
1227
|
+
signal?: AbortSignal;
|
|
1152
1228
|
};
|
|
1153
1229
|
type NftTransfer = {
|
|
1154
|
-
cursor: string
|
|
1155
|
-
block_height: number
|
|
1156
|
-
block_time?: string | null
|
|
1157
|
-
tx_id: string
|
|
1158
|
-
tx_index: number
|
|
1159
|
-
event_index: number
|
|
1160
|
-
event_type: "nft_transfer"
|
|
1161
|
-
contract_id: string
|
|
1162
|
-
asset_identifier: string
|
|
1163
|
-
sender: string
|
|
1164
|
-
recipient: string
|
|
1165
|
-
value: string
|
|
1230
|
+
cursor: string;
|
|
1231
|
+
block_height: number;
|
|
1232
|
+
block_time?: string | null;
|
|
1233
|
+
tx_id: string;
|
|
1234
|
+
tx_index: number;
|
|
1235
|
+
event_index: number;
|
|
1236
|
+
event_type: "nft_transfer";
|
|
1237
|
+
contract_id: string;
|
|
1238
|
+
asset_identifier: string;
|
|
1239
|
+
sender: string;
|
|
1240
|
+
recipient: string;
|
|
1241
|
+
value: string;
|
|
1166
1242
|
};
|
|
1167
1243
|
type NftTransfersEnvelope<TRow = NftTransfer> = {
|
|
1168
|
-
events: TRow[]
|
|
1169
|
-
next_cursor: string | null
|
|
1170
|
-
tip: IndexTip
|
|
1171
|
-
reorgs: IndexReorg[]
|
|
1244
|
+
events: TRow[];
|
|
1245
|
+
next_cursor: string | null;
|
|
1246
|
+
tip: IndexTip;
|
|
1247
|
+
reorgs: IndexReorg[];
|
|
1172
1248
|
};
|
|
1173
1249
|
/** See {@link FtTransferAlwaysFields}. */
|
|
1174
1250
|
type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
|
|
@@ -1176,110 +1252,110 @@ type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
|
|
|
1176
1252
|
type NftTransferFields<F extends keyof NftTransfer & string> = Pick<NftTransfer, (F | NftTransferAlwaysFields) & keyof NftTransfer>;
|
|
1177
1253
|
type NftTransfersListParams = {
|
|
1178
1254
|
/** Columns to return (see {@link FtTransfersListParams.fields}). */
|
|
1179
|
-
fields?: readonly (keyof NftTransfer & string)[]
|
|
1180
|
-
cursor?: string | null
|
|
1181
|
-
fromCursor?: string | null
|
|
1182
|
-
limit?: number
|
|
1183
|
-
contractId?: string
|
|
1184
|
-
assetIdentifier?: string
|
|
1185
|
-
sender?: string
|
|
1186
|
-
recipient?: string
|
|
1187
|
-
fromHeight?: number
|
|
1188
|
-
toHeight?: number
|
|
1255
|
+
fields?: readonly (keyof NftTransfer & string)[];
|
|
1256
|
+
cursor?: string | null;
|
|
1257
|
+
fromCursor?: string | null;
|
|
1258
|
+
limit?: number;
|
|
1259
|
+
contractId?: string;
|
|
1260
|
+
assetIdentifier?: string;
|
|
1261
|
+
sender?: string;
|
|
1262
|
+
recipient?: string;
|
|
1263
|
+
fromHeight?: number;
|
|
1264
|
+
toHeight?: number;
|
|
1189
1265
|
};
|
|
1190
1266
|
type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
|
|
1191
|
-
batchSize?: number
|
|
1192
|
-
signal?: AbortSignal
|
|
1267
|
+
batchSize?: number;
|
|
1268
|
+
signal?: AbortSignal;
|
|
1193
1269
|
};
|
|
1194
1270
|
type IndexEventBase = {
|
|
1195
|
-
cursor: string
|
|
1196
|
-
block_height: number
|
|
1197
|
-
block_time?: string | null
|
|
1198
|
-
tx_id: string
|
|
1199
|
-
tx_index: number
|
|
1200
|
-
event_index: number
|
|
1201
|
-
contract_id: string | null
|
|
1271
|
+
cursor: string;
|
|
1272
|
+
block_height: number;
|
|
1273
|
+
block_time?: string | null;
|
|
1274
|
+
tx_id: string;
|
|
1275
|
+
tx_index: number;
|
|
1276
|
+
event_index: number;
|
|
1277
|
+
contract_id: string | null;
|
|
1202
1278
|
/** Submitting-transaction context, present only when `txContext: true` was
|
|
1203
1279
|
* requested. `tx_sender` is the real tx sender — distinct from a transfer's
|
|
1204
1280
|
* asset `sender`, and the only place a `print` event's sender is available.
|
|
1205
1281
|
* Lets a consumer build per-event tx context without a `/v1/index/transactions`
|
|
1206
1282
|
* call per event. */
|
|
1207
|
-
tx_sender?: string | null
|
|
1208
|
-
tx_type?: string | null
|
|
1209
|
-
tx_status?: string | null
|
|
1210
|
-
tx_contract_id?: string | null
|
|
1211
|
-
tx_function_name?: string | null
|
|
1283
|
+
tx_sender?: string | null;
|
|
1284
|
+
tx_type?: string | null;
|
|
1285
|
+
tx_status?: string | null;
|
|
1286
|
+
tx_contract_id?: string | null;
|
|
1287
|
+
tx_function_name?: string | null;
|
|
1212
1288
|
};
|
|
1213
1289
|
type IndexFtTransfer = IndexEventBase & {
|
|
1214
|
-
event_type: "ft_transfer"
|
|
1215
|
-
asset_identifier: string
|
|
1216
|
-
sender: string
|
|
1217
|
-
recipient: string
|
|
1218
|
-
amount: string
|
|
1290
|
+
event_type: "ft_transfer";
|
|
1291
|
+
asset_identifier: string;
|
|
1292
|
+
sender: string;
|
|
1293
|
+
recipient: string;
|
|
1294
|
+
amount: string;
|
|
1219
1295
|
};
|
|
1220
1296
|
type IndexNftTransfer = IndexEventBase & {
|
|
1221
|
-
event_type: "nft_transfer"
|
|
1222
|
-
asset_identifier: string
|
|
1223
|
-
sender: string
|
|
1224
|
-
recipient: string
|
|
1225
|
-
value: string
|
|
1297
|
+
event_type: "nft_transfer";
|
|
1298
|
+
asset_identifier: string;
|
|
1299
|
+
sender: string;
|
|
1300
|
+
recipient: string;
|
|
1301
|
+
value: string;
|
|
1226
1302
|
};
|
|
1227
1303
|
type IndexStxTransfer = IndexEventBase & {
|
|
1228
|
-
event_type: "stx_transfer"
|
|
1229
|
-
sender: string
|
|
1230
|
-
recipient: string
|
|
1231
|
-
amount: string
|
|
1232
|
-
memo: string | null
|
|
1304
|
+
event_type: "stx_transfer";
|
|
1305
|
+
sender: string;
|
|
1306
|
+
recipient: string;
|
|
1307
|
+
amount: string;
|
|
1308
|
+
memo: string | null;
|
|
1233
1309
|
};
|
|
1234
1310
|
type IndexStxMint = IndexEventBase & {
|
|
1235
|
-
event_type: "stx_mint"
|
|
1236
|
-
recipient: string
|
|
1237
|
-
amount: string
|
|
1311
|
+
event_type: "stx_mint";
|
|
1312
|
+
recipient: string;
|
|
1313
|
+
amount: string;
|
|
1238
1314
|
};
|
|
1239
1315
|
type IndexStxBurn = IndexEventBase & {
|
|
1240
|
-
event_type: "stx_burn"
|
|
1241
|
-
sender: string
|
|
1242
|
-
amount: string
|
|
1316
|
+
event_type: "stx_burn";
|
|
1317
|
+
sender: string;
|
|
1318
|
+
amount: string;
|
|
1243
1319
|
};
|
|
1244
1320
|
type IndexStxLock = IndexEventBase & {
|
|
1245
|
-
event_type: "stx_lock"
|
|
1246
|
-
sender: string
|
|
1247
|
-
amount: string
|
|
1321
|
+
event_type: "stx_lock";
|
|
1322
|
+
sender: string;
|
|
1323
|
+
amount: string;
|
|
1248
1324
|
payload: {
|
|
1249
|
-
unlock_height: string | null
|
|
1250
|
-
}
|
|
1325
|
+
unlock_height: string | null;
|
|
1326
|
+
};
|
|
1251
1327
|
};
|
|
1252
1328
|
type IndexFtMint = IndexEventBase & {
|
|
1253
|
-
event_type: "ft_mint"
|
|
1254
|
-
asset_identifier: string
|
|
1255
|
-
recipient: string
|
|
1256
|
-
amount: string
|
|
1329
|
+
event_type: "ft_mint";
|
|
1330
|
+
asset_identifier: string;
|
|
1331
|
+
recipient: string;
|
|
1332
|
+
amount: string;
|
|
1257
1333
|
};
|
|
1258
1334
|
type IndexFtBurn = IndexEventBase & {
|
|
1259
|
-
event_type: "ft_burn"
|
|
1260
|
-
asset_identifier: string
|
|
1261
|
-
sender: string
|
|
1262
|
-
amount: string
|
|
1335
|
+
event_type: "ft_burn";
|
|
1336
|
+
asset_identifier: string;
|
|
1337
|
+
sender: string;
|
|
1338
|
+
amount: string;
|
|
1263
1339
|
};
|
|
1264
1340
|
type IndexNftMint = IndexEventBase & {
|
|
1265
|
-
event_type: "nft_mint"
|
|
1266
|
-
asset_identifier: string
|
|
1267
|
-
recipient: string
|
|
1268
|
-
value: string
|
|
1341
|
+
event_type: "nft_mint";
|
|
1342
|
+
asset_identifier: string;
|
|
1343
|
+
recipient: string;
|
|
1344
|
+
value: string;
|
|
1269
1345
|
};
|
|
1270
1346
|
type IndexNftBurn = IndexEventBase & {
|
|
1271
|
-
event_type: "nft_burn"
|
|
1272
|
-
asset_identifier: string
|
|
1273
|
-
sender: string
|
|
1274
|
-
value: string
|
|
1347
|
+
event_type: "nft_burn";
|
|
1348
|
+
asset_identifier: string;
|
|
1349
|
+
sender: string;
|
|
1350
|
+
value: string;
|
|
1275
1351
|
};
|
|
1276
1352
|
type IndexPrint = IndexEventBase & {
|
|
1277
|
-
event_type: "print"
|
|
1353
|
+
event_type: "print";
|
|
1278
1354
|
payload: {
|
|
1279
|
-
topic: string | null
|
|
1280
|
-
value: unknown
|
|
1281
|
-
raw_value: string | null
|
|
1282
|
-
}
|
|
1355
|
+
topic: string | null;
|
|
1356
|
+
value: unknown;
|
|
1357
|
+
raw_value: string | null;
|
|
1358
|
+
};
|
|
1283
1359
|
};
|
|
1284
1360
|
/** Decoded chain event, discriminated by `event_type`. */
|
|
1285
1361
|
type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
|
|
@@ -1296,39 +1372,39 @@ type EventsEnvelope<
|
|
|
1296
1372
|
T extends IndexEventType = IndexEventType,
|
|
1297
1373
|
TRow = IndexEventOf<T>
|
|
1298
1374
|
> = {
|
|
1299
|
-
events: TRow[]
|
|
1300
|
-
next_cursor: string | null
|
|
1301
|
-
tip: IndexTip
|
|
1302
|
-
reorgs: IndexReorg[]
|
|
1375
|
+
events: TRow[];
|
|
1376
|
+
next_cursor: string | null;
|
|
1377
|
+
tip: IndexTip;
|
|
1378
|
+
reorgs: IndexReorg[];
|
|
1303
1379
|
};
|
|
1304
1380
|
/** The single decoded-event member matching one `event_type` literal.
|
|
1305
1381
|
* `IndexEventOf<"ft_transfer">` is `IndexFtTransfer`. */
|
|
1306
1382
|
type IndexEventOf<T extends IndexEventType> = Extract<IndexEvent, {
|
|
1307
|
-
event_type: T
|
|
1383
|
+
event_type: T;
|
|
1308
1384
|
}>;
|
|
1309
1385
|
type EventsListParams<T extends IndexEventType = IndexEventType> = {
|
|
1310
1386
|
/** Required. One of the decoded event types. Passing a literal narrows the
|
|
1311
1387
|
* rows every surface hands back to that event's own shape. */
|
|
1312
|
-
eventType: T
|
|
1313
|
-
cursor?: string | null
|
|
1314
|
-
fromCursor?: string | null
|
|
1315
|
-
limit?: number
|
|
1388
|
+
eventType: T;
|
|
1389
|
+
cursor?: string | null;
|
|
1390
|
+
fromCursor?: string | null;
|
|
1391
|
+
limit?: number;
|
|
1316
1392
|
/** One id, or several to scope the sweep to a set of contracts (max 20).
|
|
1317
1393
|
* Mutually exclusive with `trait`. */
|
|
1318
|
-
contractId?: string | readonly string[]
|
|
1319
|
-
assetIdentifier?: string
|
|
1320
|
-
sender?: string
|
|
1321
|
-
recipient?: string
|
|
1322
|
-
fromHeight?: number
|
|
1323
|
-
toHeight?: number
|
|
1394
|
+
contractId?: string | readonly string[];
|
|
1395
|
+
assetIdentifier?: string;
|
|
1396
|
+
sender?: string;
|
|
1397
|
+
recipient?: string;
|
|
1398
|
+
fromHeight?: number;
|
|
1399
|
+
toHeight?: number;
|
|
1324
1400
|
/** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
|
|
1325
1401
|
* Mutually exclusive with contractId; contract-keyed event types only. */
|
|
1326
|
-
trait?: string
|
|
1402
|
+
trait?: string;
|
|
1327
1403
|
/** Join the submitting transaction into each event — populates `tx_sender`,
|
|
1328
1404
|
* `tx_type`, `tx_status`, `tx_contract_id`, `tx_function_name`. Off by default.
|
|
1329
1405
|
* Avoids a `/v1/index/transactions` call per event; for `print` events it's
|
|
1330
1406
|
* the only source of the submitting sender. */
|
|
1331
|
-
txContext?: boolean
|
|
1407
|
+
txContext?: boolean;
|
|
1332
1408
|
/**
|
|
1333
1409
|
* Return only these columns. The server projects the SELECT, so an
|
|
1334
1410
|
* unrequested field is physically absent — and the returned row type
|
|
@@ -1343,188 +1419,188 @@ type EventsListParams<T extends IndexEventType = IndexEventType> = {
|
|
|
1343
1419
|
* not per field. What it buys is wire bytes, plus skipping the `blocks`
|
|
1344
1420
|
* join when `block_time` is omitted.
|
|
1345
1421
|
*/
|
|
1346
|
-
fields?: readonly (keyof IndexEventOf<T> & string)[]
|
|
1422
|
+
fields?: readonly (keyof IndexEventOf<T> & string)[];
|
|
1347
1423
|
};
|
|
1348
1424
|
type EventsWalkParams<T extends IndexEventType = IndexEventType> = Omit<EventsListParams<T>, "limit"> & {
|
|
1349
|
-
batchSize?: number
|
|
1350
|
-
signal?: AbortSignal
|
|
1425
|
+
batchSize?: number;
|
|
1426
|
+
signal?: AbortSignal;
|
|
1351
1427
|
};
|
|
1352
1428
|
type EventsConsumeParams<
|
|
1353
1429
|
T extends IndexEventType = IndexEventType,
|
|
1354
1430
|
TTx = never
|
|
1355
1431
|
> = Omit<EventsListParams<T>, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexEventOf<T>, EventsEnvelope<T>, TTx>;
|
|
1356
1432
|
type IndexContractCall = {
|
|
1357
|
-
cursor: string
|
|
1358
|
-
block_height: number
|
|
1359
|
-
block_time?: string | null
|
|
1360
|
-
tx_id: string
|
|
1361
|
-
tx_index: number
|
|
1362
|
-
contract_id: string
|
|
1363
|
-
function_name: string
|
|
1364
|
-
sender: string
|
|
1365
|
-
status: string
|
|
1366
|
-
args: unknown[]
|
|
1367
|
-
result: unknown
|
|
1368
|
-
result_hex: string | null
|
|
1433
|
+
cursor: string;
|
|
1434
|
+
block_height: number;
|
|
1435
|
+
block_time?: string | null;
|
|
1436
|
+
tx_id: string;
|
|
1437
|
+
tx_index: number;
|
|
1438
|
+
contract_id: string;
|
|
1439
|
+
function_name: string;
|
|
1440
|
+
sender: string;
|
|
1441
|
+
status: string;
|
|
1442
|
+
args: unknown[];
|
|
1443
|
+
result: unknown;
|
|
1444
|
+
result_hex: string | null;
|
|
1369
1445
|
};
|
|
1370
1446
|
type ContractCallsEnvelope = {
|
|
1371
|
-
contract_calls: IndexContractCall[]
|
|
1372
|
-
next_cursor: string | null
|
|
1373
|
-
tip: IndexTip
|
|
1374
|
-
reorgs: IndexReorg[]
|
|
1447
|
+
contract_calls: IndexContractCall[];
|
|
1448
|
+
next_cursor: string | null;
|
|
1449
|
+
tip: IndexTip;
|
|
1450
|
+
reorgs: IndexReorg[];
|
|
1375
1451
|
};
|
|
1376
1452
|
type ContractCallsListParams = {
|
|
1377
|
-
cursor?: string | null
|
|
1378
|
-
fromCursor?: string | null
|
|
1379
|
-
limit?: number
|
|
1453
|
+
cursor?: string | null;
|
|
1454
|
+
fromCursor?: string | null;
|
|
1455
|
+
limit?: number;
|
|
1380
1456
|
/** One id, or several to scope the sweep to a set of contracts (max 20).
|
|
1381
1457
|
* Mutually exclusive with `trait`. */
|
|
1382
|
-
contractId?: string | readonly string[]
|
|
1383
|
-
functionName?: string
|
|
1384
|
-
sender?: string
|
|
1385
|
-
fromHeight?: number
|
|
1386
|
-
toHeight?: number
|
|
1458
|
+
contractId?: string | readonly string[];
|
|
1459
|
+
functionName?: string;
|
|
1460
|
+
sender?: string;
|
|
1461
|
+
fromHeight?: number;
|
|
1462
|
+
toHeight?: number;
|
|
1387
1463
|
/** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
|
|
1388
1464
|
* Mutually exclusive with contractId. */
|
|
1389
|
-
trait?: string
|
|
1465
|
+
trait?: string;
|
|
1390
1466
|
};
|
|
1391
1467
|
type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
|
|
1392
|
-
batchSize?: number
|
|
1393
|
-
signal?: AbortSignal
|
|
1468
|
+
batchSize?: number;
|
|
1469
|
+
signal?: AbortSignal;
|
|
1394
1470
|
};
|
|
1395
1471
|
type ContractCallsConsumeParams<TTx = never> = Omit<ContractCallsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexContractCall, ContractCallsEnvelope, TTx>;
|
|
1396
1472
|
/** One canonical block in the sync map. Lean by design — block + parent hash
|
|
1397
1473
|
* for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for
|
|
1398
1474
|
* the full block resource. */
|
|
1399
1475
|
type IndexCanonicalBlock = {
|
|
1400
|
-
cursor: string
|
|
1401
|
-
block_height: number
|
|
1402
|
-
block_hash: string
|
|
1403
|
-
parent_hash: string
|
|
1404
|
-
burn_block_height: number
|
|
1405
|
-
burn_block_hash: string | null
|
|
1476
|
+
cursor: string;
|
|
1477
|
+
block_height: number;
|
|
1478
|
+
block_hash: string;
|
|
1479
|
+
parent_hash: string;
|
|
1480
|
+
burn_block_height: number;
|
|
1481
|
+
burn_block_hash: string | null;
|
|
1406
1482
|
};
|
|
1407
1483
|
type CanonicalEnvelope = {
|
|
1408
|
-
canonical: IndexCanonicalBlock[]
|
|
1409
|
-
next_cursor: string | null
|
|
1410
|
-
tip: IndexTip
|
|
1484
|
+
canonical: IndexCanonicalBlock[];
|
|
1485
|
+
next_cursor: string | null;
|
|
1486
|
+
tip: IndexTip;
|
|
1411
1487
|
};
|
|
1412
1488
|
type CanonicalListParams = {
|
|
1413
|
-
cursor?: string | null
|
|
1414
|
-
fromCursor?: string | null
|
|
1415
|
-
limit?: number
|
|
1416
|
-
fromHeight?: number
|
|
1417
|
-
toHeight?: number
|
|
1489
|
+
cursor?: string | null;
|
|
1490
|
+
fromCursor?: string | null;
|
|
1491
|
+
limit?: number;
|
|
1492
|
+
fromHeight?: number;
|
|
1493
|
+
toHeight?: number;
|
|
1418
1494
|
};
|
|
1419
1495
|
type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & {
|
|
1420
|
-
batchSize?: number
|
|
1421
|
-
signal?: AbortSignal
|
|
1496
|
+
batchSize?: number;
|
|
1497
|
+
signal?: AbortSignal;
|
|
1422
1498
|
};
|
|
1423
1499
|
/** A block resource. Metadata is intentionally thin — only chain-linkage and
|
|
1424
1500
|
* burn-anchor fields are persisted (no miner / tx_count / signer). */
|
|
1425
1501
|
type IndexBlock = {
|
|
1426
|
-
cursor: string
|
|
1427
|
-
block_height: number
|
|
1428
|
-
block_hash: string
|
|
1429
|
-
parent_hash: string
|
|
1430
|
-
burn_block_height: number
|
|
1431
|
-
burn_block_hash: string | null
|
|
1432
|
-
block_time: string | null
|
|
1433
|
-
canonical: boolean
|
|
1502
|
+
cursor: string;
|
|
1503
|
+
block_height: number;
|
|
1504
|
+
block_hash: string;
|
|
1505
|
+
parent_hash: string;
|
|
1506
|
+
burn_block_height: number;
|
|
1507
|
+
burn_block_hash: string | null;
|
|
1508
|
+
block_time: string | null;
|
|
1509
|
+
canonical: boolean;
|
|
1434
1510
|
};
|
|
1435
1511
|
type BlocksEnvelope = {
|
|
1436
|
-
blocks: IndexBlock[]
|
|
1437
|
-
next_cursor: string | null
|
|
1438
|
-
tip: IndexTip
|
|
1512
|
+
blocks: IndexBlock[];
|
|
1513
|
+
next_cursor: string | null;
|
|
1514
|
+
tip: IndexTip;
|
|
1439
1515
|
};
|
|
1440
1516
|
type BlockEnvelope = {
|
|
1441
|
-
block: IndexBlock
|
|
1442
|
-
tip: IndexTip
|
|
1517
|
+
block: IndexBlock;
|
|
1518
|
+
tip: IndexTip;
|
|
1443
1519
|
};
|
|
1444
1520
|
type BlocksListParams = {
|
|
1445
|
-
cursor?: string | null
|
|
1446
|
-
fromCursor?: string | null
|
|
1447
|
-
limit?: number
|
|
1448
|
-
fromHeight?: number
|
|
1449
|
-
toHeight?: number
|
|
1521
|
+
cursor?: string | null;
|
|
1522
|
+
fromCursor?: string | null;
|
|
1523
|
+
limit?: number;
|
|
1524
|
+
fromHeight?: number;
|
|
1525
|
+
toHeight?: number;
|
|
1450
1526
|
};
|
|
1451
1527
|
type BlocksWalkParams = Omit<BlocksListParams, "limit"> & {
|
|
1452
|
-
batchSize?: number
|
|
1453
|
-
signal?: AbortSignal
|
|
1528
|
+
batchSize?: number;
|
|
1529
|
+
signal?: AbortSignal;
|
|
1454
1530
|
};
|
|
1455
1531
|
type IndexPostCondition = {
|
|
1456
|
-
type: "stx"
|
|
1457
|
-
principal: string
|
|
1458
|
-
condition_code: number
|
|
1459
|
-
condition_code_name: string | null
|
|
1460
|
-
amount: string
|
|
1532
|
+
type: "stx";
|
|
1533
|
+
principal: string;
|
|
1534
|
+
condition_code: number;
|
|
1535
|
+
condition_code_name: string | null;
|
|
1536
|
+
amount: string;
|
|
1461
1537
|
} | {
|
|
1462
|
-
type: "ft"
|
|
1463
|
-
principal: string
|
|
1464
|
-
asset_identifier: string
|
|
1465
|
-
condition_code: number
|
|
1466
|
-
condition_code_name: string | null
|
|
1467
|
-
amount: string
|
|
1538
|
+
type: "ft";
|
|
1539
|
+
principal: string;
|
|
1540
|
+
asset_identifier: string;
|
|
1541
|
+
condition_code: number;
|
|
1542
|
+
condition_code_name: string | null;
|
|
1543
|
+
amount: string;
|
|
1468
1544
|
} | {
|
|
1469
|
-
type: "nft"
|
|
1470
|
-
principal: string
|
|
1471
|
-
asset_identifier: string
|
|
1472
|
-
asset_value: unknown
|
|
1473
|
-
condition_code: number
|
|
1474
|
-
condition_code_name: string | null
|
|
1545
|
+
type: "nft";
|
|
1546
|
+
principal: string;
|
|
1547
|
+
asset_identifier: string;
|
|
1548
|
+
asset_value: unknown;
|
|
1549
|
+
condition_code: number;
|
|
1550
|
+
condition_code_name: string | null;
|
|
1475
1551
|
};
|
|
1476
1552
|
/** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.
|
|
1477
1553
|
* Payload sub-objects are present only for the matching `tx_type`; enrichment
|
|
1478
1554
|
* fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */
|
|
1479
1555
|
type IndexTransaction = {
|
|
1480
|
-
cursor: string
|
|
1481
|
-
tx_id: string
|
|
1482
|
-
block_height: number
|
|
1483
|
-
block_time?: string | null
|
|
1484
|
-
tx_index: number
|
|
1485
|
-
tx_type: string
|
|
1486
|
-
sender: string
|
|
1487
|
-
status: string
|
|
1488
|
-
fee: string | null
|
|
1489
|
-
nonce: string | null
|
|
1490
|
-
sponsored: boolean | null
|
|
1491
|
-
anchor_mode: string | null
|
|
1492
|
-
post_condition_mode: string | null
|
|
1493
|
-
post_conditions: IndexPostCondition[]
|
|
1556
|
+
cursor: string;
|
|
1557
|
+
tx_id: string;
|
|
1558
|
+
block_height: number;
|
|
1559
|
+
block_time?: string | null;
|
|
1560
|
+
tx_index: number;
|
|
1561
|
+
tx_type: string;
|
|
1562
|
+
sender: string;
|
|
1563
|
+
status: string;
|
|
1564
|
+
fee: string | null;
|
|
1565
|
+
nonce: string | null;
|
|
1566
|
+
sponsored: boolean | null;
|
|
1567
|
+
anchor_mode: string | null;
|
|
1568
|
+
post_condition_mode: string | null;
|
|
1569
|
+
post_conditions: IndexPostCondition[];
|
|
1494
1570
|
contract_call?: {
|
|
1495
|
-
contract_id: string
|
|
1496
|
-
function_name: string
|
|
1497
|
-
function_args: unknown[]
|
|
1571
|
+
contract_id: string;
|
|
1572
|
+
function_name: string;
|
|
1573
|
+
function_args: unknown[];
|
|
1498
1574
|
/** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */
|
|
1499
|
-
function_args_hex: string[]
|
|
1500
|
-
result: unknown
|
|
1501
|
-
result_hex: string | null
|
|
1502
|
-
}
|
|
1575
|
+
function_args_hex: string[];
|
|
1576
|
+
result: unknown;
|
|
1577
|
+
result_hex: string | null;
|
|
1578
|
+
};
|
|
1503
1579
|
token_transfer?: {
|
|
1504
|
-
recipient: string
|
|
1505
|
-
amount: string
|
|
1506
|
-
memo: string
|
|
1507
|
-
}
|
|
1580
|
+
recipient: string;
|
|
1581
|
+
amount: string;
|
|
1582
|
+
memo: string;
|
|
1583
|
+
};
|
|
1508
1584
|
smart_contract?: {
|
|
1509
|
-
contract_id: string | null
|
|
1510
|
-
clarity_version: number | null
|
|
1511
|
-
}
|
|
1585
|
+
contract_id: string | null;
|
|
1586
|
+
clarity_version: number | null;
|
|
1587
|
+
};
|
|
1512
1588
|
coinbase?: {
|
|
1513
|
-
alt_recipient: string | null
|
|
1514
|
-
}
|
|
1589
|
+
alt_recipient: string | null;
|
|
1590
|
+
};
|
|
1515
1591
|
tenure_change?: {
|
|
1516
|
-
cause: number
|
|
1517
|
-
}
|
|
1592
|
+
cause: number;
|
|
1593
|
+
};
|
|
1518
1594
|
};
|
|
1519
1595
|
type TransactionsEnvelope<TRow = IndexTransaction> = {
|
|
1520
|
-
transactions: TRow[]
|
|
1521
|
-
next_cursor: string | null
|
|
1522
|
-
tip: IndexTip
|
|
1523
|
-
reorgs: IndexReorg[]
|
|
1596
|
+
transactions: TRow[];
|
|
1597
|
+
next_cursor: string | null;
|
|
1598
|
+
tip: IndexTip;
|
|
1599
|
+
reorgs: IndexReorg[];
|
|
1524
1600
|
};
|
|
1525
1601
|
type TransactionEnvelope = {
|
|
1526
|
-
transaction: IndexTransaction
|
|
1527
|
-
tip: IndexTip
|
|
1602
|
+
transaction: IndexTransaction;
|
|
1603
|
+
tip: IndexTip;
|
|
1528
1604
|
};
|
|
1529
1605
|
/** Transaction columns that survive any projection. */
|
|
1530
1606
|
type TransactionAlwaysFields = "cursor" | "block_height" | "tx_id";
|
|
@@ -1536,123 +1612,123 @@ type TransactionsListParams = {
|
|
|
1536
1612
|
* is physically absent — and the narrowing overload on `list` makes reading
|
|
1537
1613
|
* one a compile error rather than `undefined` at runtime.
|
|
1538
1614
|
*/
|
|
1539
|
-
fields?: readonly (keyof IndexTransaction & string)[]
|
|
1540
|
-
cursor?: string | null
|
|
1541
|
-
fromCursor?: string | null
|
|
1542
|
-
limit?: number
|
|
1543
|
-
type?: string
|
|
1544
|
-
sender?: string
|
|
1545
|
-
contractId?: string
|
|
1546
|
-
fromHeight?: number
|
|
1547
|
-
toHeight?: number
|
|
1615
|
+
fields?: readonly (keyof IndexTransaction & string)[];
|
|
1616
|
+
cursor?: string | null;
|
|
1617
|
+
fromCursor?: string | null;
|
|
1618
|
+
limit?: number;
|
|
1619
|
+
type?: string;
|
|
1620
|
+
sender?: string;
|
|
1621
|
+
contractId?: string;
|
|
1622
|
+
fromHeight?: number;
|
|
1623
|
+
toHeight?: number;
|
|
1548
1624
|
};
|
|
1549
1625
|
type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & {
|
|
1550
|
-
batchSize?: number
|
|
1551
|
-
signal?: AbortSignal
|
|
1626
|
+
batchSize?: number;
|
|
1627
|
+
signal?: AbortSignal;
|
|
1552
1628
|
};
|
|
1553
1629
|
/** A decoded PoX-4 stacking action (one per stacking contract call). */
|
|
1554
1630
|
type IndexStackingAction = {
|
|
1555
|
-
cursor: string
|
|
1556
|
-
block_height: number
|
|
1557
|
-
block_time?: string | null
|
|
1558
|
-
burn_block_height: number
|
|
1559
|
-
tx_id: string
|
|
1560
|
-
tx_index: number
|
|
1561
|
-
function_name: string
|
|
1562
|
-
caller: string
|
|
1563
|
-
stacker: string | null
|
|
1564
|
-
delegate_to: string | null
|
|
1565
|
-
amount_ustx: string | null
|
|
1566
|
-
lock_period: number | null
|
|
1631
|
+
cursor: string;
|
|
1632
|
+
block_height: number;
|
|
1633
|
+
block_time?: string | null;
|
|
1634
|
+
burn_block_height: number;
|
|
1635
|
+
tx_id: string;
|
|
1636
|
+
tx_index: number;
|
|
1637
|
+
function_name: string;
|
|
1638
|
+
caller: string;
|
|
1639
|
+
stacker: string | null;
|
|
1640
|
+
delegate_to: string | null;
|
|
1641
|
+
amount_ustx: string | null;
|
|
1642
|
+
lock_period: number | null;
|
|
1567
1643
|
pox_addr: {
|
|
1568
|
-
version: number | null
|
|
1569
|
-
hashbytes: string | null
|
|
1570
|
-
btc: string | null
|
|
1571
|
-
}
|
|
1572
|
-
start_cycle: number | null
|
|
1573
|
-
end_cycle: number | null
|
|
1574
|
-
reward_cycle: number | null
|
|
1575
|
-
signer_key: string | null
|
|
1576
|
-
result_ok: boolean
|
|
1644
|
+
version: number | null;
|
|
1645
|
+
hashbytes: string | null;
|
|
1646
|
+
btc: string | null;
|
|
1647
|
+
};
|
|
1648
|
+
start_cycle: number | null;
|
|
1649
|
+
end_cycle: number | null;
|
|
1650
|
+
reward_cycle: number | null;
|
|
1651
|
+
signer_key: string | null;
|
|
1652
|
+
result_ok: boolean;
|
|
1577
1653
|
};
|
|
1578
1654
|
type StackingEnvelope = {
|
|
1579
|
-
stacking: IndexStackingAction[]
|
|
1580
|
-
next_cursor: string | null
|
|
1581
|
-
tip: IndexTip
|
|
1582
|
-
reorgs: IndexReorg[]
|
|
1655
|
+
stacking: IndexStackingAction[];
|
|
1656
|
+
next_cursor: string | null;
|
|
1657
|
+
tip: IndexTip;
|
|
1658
|
+
reorgs: IndexReorg[];
|
|
1583
1659
|
/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
|
|
1584
|
-
notes?: string
|
|
1660
|
+
notes?: string;
|
|
1585
1661
|
};
|
|
1586
1662
|
type StackingListParams = {
|
|
1587
|
-
cursor?: string | null
|
|
1588
|
-
fromCursor?: string | null
|
|
1589
|
-
limit?: number
|
|
1590
|
-
functionName?: string
|
|
1591
|
-
stacker?: string
|
|
1592
|
-
caller?: string
|
|
1593
|
-
fromHeight?: number
|
|
1594
|
-
toHeight?: number
|
|
1663
|
+
cursor?: string | null;
|
|
1664
|
+
fromCursor?: string | null;
|
|
1665
|
+
limit?: number;
|
|
1666
|
+
functionName?: string;
|
|
1667
|
+
stacker?: string;
|
|
1668
|
+
caller?: string;
|
|
1669
|
+
fromHeight?: number;
|
|
1670
|
+
toHeight?: number;
|
|
1595
1671
|
};
|
|
1596
1672
|
type StackingWalkParams = Omit<StackingListParams, "limit"> & {
|
|
1597
|
-
batchSize?: number
|
|
1598
|
-
signal?: AbortSignal
|
|
1673
|
+
batchSize?: number;
|
|
1674
|
+
signal?: AbortSignal;
|
|
1599
1675
|
};
|
|
1600
1676
|
/** A pending (unconfirmed) transaction. Like a transaction document but
|
|
1601
1677
|
* pre-chain — no block_height/tx_index/result/events — with `received_at` and
|
|
1602
1678
|
* a sequence cursor instead of a block position. */
|
|
1603
1679
|
type IndexMempoolTransaction = {
|
|
1604
|
-
cursor: string
|
|
1605
|
-
tx_id: string
|
|
1606
|
-
tx_type: string
|
|
1607
|
-
sender: string
|
|
1608
|
-
received_at?: string | null
|
|
1609
|
-
fee: string | null
|
|
1610
|
-
nonce: string | null
|
|
1611
|
-
sponsored: boolean | null
|
|
1612
|
-
anchor_mode: string | null
|
|
1613
|
-
post_condition_mode: string | null
|
|
1614
|
-
post_conditions: IndexPostCondition[]
|
|
1680
|
+
cursor: string;
|
|
1681
|
+
tx_id: string;
|
|
1682
|
+
tx_type: string;
|
|
1683
|
+
sender: string;
|
|
1684
|
+
received_at?: string | null;
|
|
1685
|
+
fee: string | null;
|
|
1686
|
+
nonce: string | null;
|
|
1687
|
+
sponsored: boolean | null;
|
|
1688
|
+
anchor_mode: string | null;
|
|
1689
|
+
post_condition_mode: string | null;
|
|
1690
|
+
post_conditions: IndexPostCondition[];
|
|
1615
1691
|
contract_call?: {
|
|
1616
|
-
contract_id: string
|
|
1617
|
-
function_name: string
|
|
1618
|
-
function_args: unknown[]
|
|
1619
|
-
}
|
|
1692
|
+
contract_id: string;
|
|
1693
|
+
function_name: string;
|
|
1694
|
+
function_args: unknown[];
|
|
1695
|
+
};
|
|
1620
1696
|
token_transfer?: {
|
|
1621
|
-
recipient: string
|
|
1622
|
-
amount: string
|
|
1623
|
-
memo: string
|
|
1624
|
-
}
|
|
1697
|
+
recipient: string;
|
|
1698
|
+
amount: string;
|
|
1699
|
+
memo: string;
|
|
1700
|
+
};
|
|
1625
1701
|
smart_contract?: {
|
|
1626
|
-
clarity_version: number | null
|
|
1627
|
-
}
|
|
1702
|
+
clarity_version: number | null;
|
|
1703
|
+
};
|
|
1628
1704
|
coinbase?: {
|
|
1629
|
-
alt_recipient: string | null
|
|
1630
|
-
}
|
|
1705
|
+
alt_recipient: string | null;
|
|
1706
|
+
};
|
|
1631
1707
|
tenure_change?: {
|
|
1632
|
-
cause: number
|
|
1633
|
-
}
|
|
1708
|
+
cause: number;
|
|
1709
|
+
};
|
|
1634
1710
|
};
|
|
1635
1711
|
type MempoolEnvelope = {
|
|
1636
|
-
mempool: IndexMempoolTransaction[]
|
|
1637
|
-
next_cursor: string | null
|
|
1638
|
-
tip: IndexTip
|
|
1712
|
+
mempool: IndexMempoolTransaction[];
|
|
1713
|
+
next_cursor: string | null;
|
|
1714
|
+
tip: IndexTip;
|
|
1639
1715
|
};
|
|
1640
1716
|
type MempoolTransactionEnvelope = {
|
|
1641
|
-
transaction: IndexMempoolTransaction
|
|
1642
|
-
tip: IndexTip
|
|
1717
|
+
transaction: IndexMempoolTransaction;
|
|
1718
|
+
tip: IndexTip;
|
|
1643
1719
|
};
|
|
1644
1720
|
type MempoolListParams = {
|
|
1645
|
-
cursor?: string | null
|
|
1646
|
-
fromCursor?: string | null
|
|
1647
|
-
limit?: number
|
|
1648
|
-
sender?: string
|
|
1649
|
-
type?: string
|
|
1721
|
+
cursor?: string | null;
|
|
1722
|
+
fromCursor?: string | null;
|
|
1723
|
+
limit?: number;
|
|
1724
|
+
sender?: string;
|
|
1725
|
+
type?: string;
|
|
1650
1726
|
/** Filter to pending calls to a single contract (e.g. `SP….contract`). */
|
|
1651
|
-
contractId?: string
|
|
1727
|
+
contractId?: string;
|
|
1652
1728
|
};
|
|
1653
1729
|
type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
|
|
1654
|
-
batchSize?: number
|
|
1655
|
-
signal?: AbortSignal
|
|
1730
|
+
batchSize?: number;
|
|
1731
|
+
signal?: AbortSignal;
|
|
1656
1732
|
};
|
|
1657
1733
|
/**
|
|
1658
1734
|
* Empirical per-topic print payload schema for a contract, inferred from
|
|
@@ -1660,194 +1736,194 @@ type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
|
|
|
1660
1736
|
* when the contract has more print events than the windows examined.
|
|
1661
1737
|
*/
|
|
1662
1738
|
type PrintSchemaResponse = {
|
|
1663
|
-
contract_id: string
|
|
1664
|
-
topics: InferredTopicSchema[]
|
|
1665
|
-
sampled: boolean
|
|
1666
|
-
total_events: number
|
|
1739
|
+
contract_id: string;
|
|
1740
|
+
topics: InferredTopicSchema[];
|
|
1741
|
+
sampled: boolean;
|
|
1742
|
+
total_events: number;
|
|
1667
1743
|
/** True when the count hit the server-side cap (total_events is the cap). */
|
|
1668
|
-
total_events_capped: boolean
|
|
1744
|
+
total_events_capped: boolean;
|
|
1669
1745
|
sample: {
|
|
1670
|
-
size: number
|
|
1671
|
-
newest_height: number | null
|
|
1672
|
-
oldest_height: number | null
|
|
1673
|
-
}
|
|
1674
|
-
tip: IndexTip
|
|
1746
|
+
size: number;
|
|
1747
|
+
newest_height: number | null;
|
|
1748
|
+
oldest_height: number | null;
|
|
1749
|
+
};
|
|
1750
|
+
tip: IndexTip;
|
|
1675
1751
|
};
|
|
1676
1752
|
type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
|
|
1677
1753
|
/** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
|
|
1678
1754
|
* `request_id`). One terminal `completed-deposit` event per deposit. */
|
|
1679
1755
|
type IndexSbtcDeposit = {
|
|
1680
|
-
cursor: string
|
|
1681
|
-
block_height: number
|
|
1682
|
-
block_time?: string | null
|
|
1683
|
-
tx_id: string
|
|
1684
|
-
tx_index: number
|
|
1685
|
-
event_index: number
|
|
1686
|
-
amount: string | null
|
|
1687
|
-
sender: string | null
|
|
1688
|
-
bitcoin_txid: string | null
|
|
1689
|
-
output_index: number | null
|
|
1690
|
-
recipient_btc_version: number | null
|
|
1691
|
-
recipient_btc_hashbytes: string | null
|
|
1756
|
+
cursor: string;
|
|
1757
|
+
block_height: number;
|
|
1758
|
+
block_time?: string | null;
|
|
1759
|
+
tx_id: string;
|
|
1760
|
+
tx_index: number;
|
|
1761
|
+
event_index: number;
|
|
1762
|
+
amount: string | null;
|
|
1763
|
+
sender: string | null;
|
|
1764
|
+
bitcoin_txid: string | null;
|
|
1765
|
+
output_index: number | null;
|
|
1766
|
+
recipient_btc_version: number | null;
|
|
1767
|
+
recipient_btc_hashbytes: string | null;
|
|
1692
1768
|
};
|
|
1693
1769
|
/** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
|
|
1694
1770
|
type IndexSbtcDepositDetail = IndexSbtcDeposit & {
|
|
1695
|
-
status: "COMPLETED"
|
|
1771
|
+
status: "COMPLETED";
|
|
1696
1772
|
};
|
|
1697
1773
|
/** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
|
|
1698
1774
|
* derived from the latest accept/reject. */
|
|
1699
1775
|
type IndexSbtcWithdrawal = {
|
|
1700
|
-
cursor: string
|
|
1701
|
-
request_id: number
|
|
1702
|
-
status: SbtcWithdrawalStatus
|
|
1703
|
-
amount: string | null
|
|
1704
|
-
sender: string | null
|
|
1705
|
-
recipient_btc_version: number | null
|
|
1706
|
-
recipient_btc_hashbytes: string | null
|
|
1707
|
-
sweep_txid: string | null
|
|
1776
|
+
cursor: string;
|
|
1777
|
+
request_id: number;
|
|
1778
|
+
status: SbtcWithdrawalStatus;
|
|
1779
|
+
amount: string | null;
|
|
1780
|
+
sender: string | null;
|
|
1781
|
+
recipient_btc_version: number | null;
|
|
1782
|
+
recipient_btc_hashbytes: string | null;
|
|
1783
|
+
sweep_txid: string | null;
|
|
1708
1784
|
/** BTC L1 settlement of the committed sweep: true once confirmed, false while
|
|
1709
1785
|
* pending, null when there is no sweep yet (REQUESTED). */
|
|
1710
|
-
settlement_confirmed: boolean | null
|
|
1786
|
+
settlement_confirmed: boolean | null;
|
|
1711
1787
|
/** BTC confirmations on the sweep tx, null when no settlement row yet. */
|
|
1712
|
-
btc_confirmations: number | null
|
|
1788
|
+
btc_confirmations: number | null;
|
|
1713
1789
|
/** Confirming BTC block height, null while unconfirmed / no sweep. */
|
|
1714
|
-
btc_block_height: number | null
|
|
1790
|
+
btc_block_height: number | null;
|
|
1715
1791
|
/** When the sweep crossed the confirmation threshold (ISO), null otherwise. */
|
|
1716
|
-
confirmed_at: string | null
|
|
1717
|
-
requested_at?: string | null
|
|
1718
|
-
resolved_at?: string | null
|
|
1792
|
+
confirmed_at: string | null;
|
|
1793
|
+
requested_at?: string | null;
|
|
1794
|
+
resolved_at?: string | null;
|
|
1719
1795
|
};
|
|
1720
1796
|
/** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
|
|
1721
1797
|
type IndexSbtcWithdrawalPhase = {
|
|
1722
|
-
block_height: number
|
|
1723
|
-
block_time: string | null
|
|
1724
|
-
tx_id: string
|
|
1798
|
+
block_height: number;
|
|
1799
|
+
block_time: string | null;
|
|
1800
|
+
tx_id: string;
|
|
1725
1801
|
};
|
|
1726
1802
|
/** A single peg-out's full assembled lifecycle, fetched by `request_id`.
|
|
1727
1803
|
* `finalized` is true once terminal and past the reorg margin. */
|
|
1728
1804
|
type IndexSbtcWithdrawalDetail = {
|
|
1729
|
-
request_id: number
|
|
1730
|
-
status: SbtcWithdrawalStatus
|
|
1731
|
-
amount: string | null
|
|
1732
|
-
sender: string | null
|
|
1733
|
-
recipient_btc_version: number | null
|
|
1734
|
-
recipient_btc_hashbytes: string | null
|
|
1735
|
-
requested: IndexSbtcWithdrawalPhase
|
|
1805
|
+
request_id: number;
|
|
1806
|
+
status: SbtcWithdrawalStatus;
|
|
1807
|
+
amount: string | null;
|
|
1808
|
+
sender: string | null;
|
|
1809
|
+
recipient_btc_version: number | null;
|
|
1810
|
+
recipient_btc_hashbytes: string | null;
|
|
1811
|
+
requested: IndexSbtcWithdrawalPhase;
|
|
1736
1812
|
accepted: (IndexSbtcWithdrawalPhase & {
|
|
1737
|
-
sweep_txid: string | null
|
|
1738
|
-
signer_bitmap: string | null
|
|
1739
|
-
}) | null
|
|
1740
|
-
rejected: IndexSbtcWithdrawalPhase | null
|
|
1813
|
+
sweep_txid: string | null;
|
|
1814
|
+
signer_bitmap: string | null;
|
|
1815
|
+
}) | null;
|
|
1816
|
+
rejected: IndexSbtcWithdrawalPhase | null;
|
|
1741
1817
|
settlement: {
|
|
1742
|
-
sweep_txid: string | null
|
|
1743
|
-
btc_confirmations: number | null
|
|
1744
|
-
settlement_confirmed: boolean | null
|
|
1818
|
+
sweep_txid: string | null;
|
|
1819
|
+
btc_confirmations: number | null;
|
|
1820
|
+
settlement_confirmed: boolean | null;
|
|
1745
1821
|
/** Confirming Bitcoin block height; null until the sweep confirms. */
|
|
1746
|
-
btc_block_height: number | null
|
|
1822
|
+
btc_block_height: number | null;
|
|
1747
1823
|
/** ISO timestamp the sweep first crossed the confirmation threshold. */
|
|
1748
|
-
confirmed_at: string | null
|
|
1749
|
-
}
|
|
1750
|
-
finalized: boolean
|
|
1824
|
+
confirmed_at: string | null;
|
|
1825
|
+
};
|
|
1826
|
+
finalized: boolean;
|
|
1751
1827
|
};
|
|
1752
1828
|
/** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
|
|
1753
1829
|
* per event across all topics. */
|
|
1754
1830
|
type IndexSbtcEvent = {
|
|
1755
|
-
cursor: string
|
|
1756
|
-
block_height: number
|
|
1757
|
-
block_time?: string | null
|
|
1758
|
-
tx_id: string
|
|
1759
|
-
tx_index: number
|
|
1760
|
-
event_index: number
|
|
1761
|
-
topic: SbtcEventTopic
|
|
1762
|
-
request_id: number | null
|
|
1763
|
-
amount: string | null
|
|
1764
|
-
sender: string | null
|
|
1765
|
-
recipient_btc_version: number | null
|
|
1766
|
-
recipient_btc_hashbytes: string | null
|
|
1767
|
-
bitcoin_txid: string | null
|
|
1768
|
-
output_index: number | null
|
|
1769
|
-
sweep_txid: string | null
|
|
1770
|
-
burn_hash: string | null
|
|
1771
|
-
burn_height: number | null
|
|
1772
|
-
signer_bitmap: string | null
|
|
1773
|
-
max_fee: string | null
|
|
1774
|
-
fee: string | null
|
|
1775
|
-
governance_contract_type: number | null
|
|
1776
|
-
governance_new_contract: string | null
|
|
1777
|
-
signer_aggregate_pubkey: string | null
|
|
1778
|
-
signer_threshold: number | null
|
|
1779
|
-
signer_address: string | null
|
|
1780
|
-
signer_keys_count: number | null
|
|
1831
|
+
cursor: string;
|
|
1832
|
+
block_height: number;
|
|
1833
|
+
block_time?: string | null;
|
|
1834
|
+
tx_id: string;
|
|
1835
|
+
tx_index: number;
|
|
1836
|
+
event_index: number;
|
|
1837
|
+
topic: SbtcEventTopic;
|
|
1838
|
+
request_id: number | null;
|
|
1839
|
+
amount: string | null;
|
|
1840
|
+
sender: string | null;
|
|
1841
|
+
recipient_btc_version: number | null;
|
|
1842
|
+
recipient_btc_hashbytes: string | null;
|
|
1843
|
+
bitcoin_txid: string | null;
|
|
1844
|
+
output_index: number | null;
|
|
1845
|
+
sweep_txid: string | null;
|
|
1846
|
+
burn_hash: string | null;
|
|
1847
|
+
burn_height: number | null;
|
|
1848
|
+
signer_bitmap: string | null;
|
|
1849
|
+
max_fee: string | null;
|
|
1850
|
+
fee: string | null;
|
|
1851
|
+
governance_contract_type: number | null;
|
|
1852
|
+
governance_new_contract: string | null;
|
|
1853
|
+
signer_aggregate_pubkey: string | null;
|
|
1854
|
+
signer_threshold: number | null;
|
|
1855
|
+
signer_address: string | null;
|
|
1856
|
+
signer_keys_count: number | null;
|
|
1781
1857
|
};
|
|
1782
1858
|
/** The peg "scoreboard" — a single all-time canonical aggregate. */
|
|
1783
1859
|
type IndexSbtcSummary = {
|
|
1784
|
-
total_deposits: number
|
|
1785
|
-
total_withdrawals_requested: number
|
|
1786
|
-
total_withdrawals_accepted: number
|
|
1787
|
-
total_withdrawals_rejected: number
|
|
1788
|
-
net_peg_flow_sats: string
|
|
1789
|
-
total_locked_sats: string
|
|
1790
|
-
sbtc_supply_sats: string | null
|
|
1860
|
+
total_deposits: number;
|
|
1861
|
+
total_withdrawals_requested: number;
|
|
1862
|
+
total_withdrawals_accepted: number;
|
|
1863
|
+
total_withdrawals_rejected: number;
|
|
1864
|
+
net_peg_flow_sats: string;
|
|
1865
|
+
total_locked_sats: string;
|
|
1866
|
+
sbtc_supply_sats: string | null;
|
|
1791
1867
|
};
|
|
1792
1868
|
type SbtcDepositsEnvelope<TRow = IndexSbtcDeposit> = {
|
|
1793
|
-
deposits: TRow[]
|
|
1794
|
-
next_cursor: string | null
|
|
1795
|
-
tip: IndexTip
|
|
1796
|
-
reorgs: IndexReorg[]
|
|
1869
|
+
deposits: TRow[];
|
|
1870
|
+
next_cursor: string | null;
|
|
1871
|
+
tip: IndexTip;
|
|
1872
|
+
reorgs: IndexReorg[];
|
|
1797
1873
|
/** Present only when the sBTC decoder is disabled, explaining an empty feed. */
|
|
1798
|
-
notes?: string
|
|
1874
|
+
notes?: string;
|
|
1799
1875
|
};
|
|
1800
1876
|
type SbtcDepositEnvelope = {
|
|
1801
|
-
deposit: IndexSbtcDepositDetail
|
|
1802
|
-
tip: IndexTip
|
|
1877
|
+
deposit: IndexSbtcDepositDetail;
|
|
1878
|
+
tip: IndexTip;
|
|
1803
1879
|
};
|
|
1804
1880
|
type SbtcWithdrawalsEnvelope<TRow = IndexSbtcWithdrawal> = {
|
|
1805
|
-
withdrawals: TRow[]
|
|
1806
|
-
next_cursor: string | null
|
|
1807
|
-
tip: IndexTip
|
|
1808
|
-
reorgs: IndexReorg[]
|
|
1809
|
-
notes?: string
|
|
1881
|
+
withdrawals: TRow[];
|
|
1882
|
+
next_cursor: string | null;
|
|
1883
|
+
tip: IndexTip;
|
|
1884
|
+
reorgs: IndexReorg[];
|
|
1885
|
+
notes?: string;
|
|
1810
1886
|
};
|
|
1811
1887
|
type SbtcWithdrawalEnvelope = {
|
|
1812
|
-
withdrawal: IndexSbtcWithdrawalDetail
|
|
1813
|
-
tip: IndexTip
|
|
1888
|
+
withdrawal: IndexSbtcWithdrawalDetail;
|
|
1889
|
+
tip: IndexTip;
|
|
1814
1890
|
};
|
|
1815
1891
|
type SbtcEventsEnvelope = {
|
|
1816
|
-
events: IndexSbtcEvent[]
|
|
1817
|
-
next_cursor: string | null
|
|
1818
|
-
tip: IndexTip
|
|
1819
|
-
reorgs: IndexReorg[]
|
|
1820
|
-
notes?: string
|
|
1892
|
+
events: IndexSbtcEvent[];
|
|
1893
|
+
next_cursor: string | null;
|
|
1894
|
+
tip: IndexTip;
|
|
1895
|
+
reorgs: IndexReorg[];
|
|
1896
|
+
notes?: string;
|
|
1821
1897
|
};
|
|
1822
1898
|
type SbtcSummaryEnvelope = {
|
|
1823
|
-
summary: IndexSbtcSummary
|
|
1824
|
-
tip: IndexTip
|
|
1825
|
-
notes?: string
|
|
1899
|
+
summary: IndexSbtcSummary;
|
|
1900
|
+
tip: IndexTip;
|
|
1901
|
+
notes?: string;
|
|
1826
1902
|
};
|
|
1827
1903
|
type SbtcDepositsListParams = {
|
|
1828
|
-
cursor?: string | null
|
|
1829
|
-
fromCursor?: string | null
|
|
1830
|
-
limit?: number
|
|
1904
|
+
cursor?: string | null;
|
|
1905
|
+
fromCursor?: string | null;
|
|
1906
|
+
limit?: number;
|
|
1831
1907
|
/** Clamp to the finality boundary — only settled deposits past the reorg margin. */
|
|
1832
|
-
confirmed?: boolean
|
|
1833
|
-
sender?: string
|
|
1834
|
-
bitcoinTxid?: string
|
|
1835
|
-
fromHeight?: number
|
|
1836
|
-
toHeight?: number
|
|
1908
|
+
confirmed?: boolean;
|
|
1909
|
+
sender?: string;
|
|
1910
|
+
bitcoinTxid?: string;
|
|
1911
|
+
fromHeight?: number;
|
|
1912
|
+
toHeight?: number;
|
|
1837
1913
|
/**
|
|
1838
1914
|
* Columns to return. The server projects the row, so an unrequested column
|
|
1839
1915
|
* is physically absent — and the narrowing overload on `list` makes reading
|
|
1840
1916
|
* one a compile error rather than `undefined` at runtime.
|
|
1841
1917
|
*/
|
|
1842
|
-
fields?: readonly (keyof IndexSbtcDeposit & string)[]
|
|
1918
|
+
fields?: readonly (keyof IndexSbtcDeposit & string)[];
|
|
1843
1919
|
};
|
|
1844
1920
|
/** Deposit columns that survive any projection — pagination needs them. */
|
|
1845
1921
|
type SbtcDepositAlwaysFields = "cursor" | "block_height";
|
|
1846
1922
|
/** A deposit row narrowed to the requested columns plus the always-present ones. */
|
|
1847
1923
|
type SbtcDepositFields<F extends keyof IndexSbtcDeposit & string> = Pick<IndexSbtcDeposit, (F | SbtcDepositAlwaysFields) & keyof IndexSbtcDeposit>;
|
|
1848
1924
|
type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
|
|
1849
|
-
batchSize?: number
|
|
1850
|
-
signal?: AbortSignal
|
|
1925
|
+
batchSize?: number;
|
|
1926
|
+
signal?: AbortSignal;
|
|
1851
1927
|
};
|
|
1852
1928
|
/** SbtcWithdrawal columns that survive any projection. */
|
|
1853
1929
|
type SbtcWithdrawalAlwaysFields = "cursor" | "request_id";
|
|
@@ -1859,39 +1935,39 @@ type SbtcWithdrawalsListParams = {
|
|
|
1859
1935
|
* is physically absent — and the narrowing overload on `list` makes reading
|
|
1860
1936
|
* one a compile error rather than `undefined` at runtime.
|
|
1861
1937
|
*/
|
|
1862
|
-
fields?: readonly (keyof IndexSbtcWithdrawal & string)[]
|
|
1863
|
-
cursor?: string | null
|
|
1864
|
-
fromCursor?: string | null
|
|
1865
|
-
limit?: number
|
|
1866
|
-
confirmed?: boolean
|
|
1867
|
-
status?: SbtcWithdrawalStatus
|
|
1868
|
-
sender?: string
|
|
1869
|
-
requestId?: number
|
|
1938
|
+
fields?: readonly (keyof IndexSbtcWithdrawal & string)[];
|
|
1939
|
+
cursor?: string | null;
|
|
1940
|
+
fromCursor?: string | null;
|
|
1941
|
+
limit?: number;
|
|
1942
|
+
confirmed?: boolean;
|
|
1943
|
+
status?: SbtcWithdrawalStatus;
|
|
1944
|
+
sender?: string;
|
|
1945
|
+
requestId?: number;
|
|
1870
1946
|
/** Filter by BTC L1 settlement: true → only confirmed sweeps; false → not
|
|
1871
1947
|
* yet confirmed (pending or no sweep). */
|
|
1872
|
-
settlementConfirmed?: boolean
|
|
1873
|
-
fromHeight?: number
|
|
1874
|
-
toHeight?: number
|
|
1948
|
+
settlementConfirmed?: boolean;
|
|
1949
|
+
fromHeight?: number;
|
|
1950
|
+
toHeight?: number;
|
|
1875
1951
|
};
|
|
1876
1952
|
type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
|
|
1877
|
-
batchSize?: number
|
|
1878
|
-
signal?: AbortSignal
|
|
1953
|
+
batchSize?: number;
|
|
1954
|
+
signal?: AbortSignal;
|
|
1879
1955
|
};
|
|
1880
1956
|
type SbtcEventsListParams = {
|
|
1881
|
-
cursor?: string | null
|
|
1882
|
-
fromCursor?: string | null
|
|
1883
|
-
limit?: number
|
|
1884
|
-
confirmed?: boolean
|
|
1885
|
-
topic?: SbtcEventTopic
|
|
1886
|
-
sender?: string
|
|
1887
|
-
requestId?: number
|
|
1888
|
-
bitcoinTxid?: string
|
|
1889
|
-
fromHeight?: number
|
|
1890
|
-
toHeight?: number
|
|
1957
|
+
cursor?: string | null;
|
|
1958
|
+
fromCursor?: string | null;
|
|
1959
|
+
limit?: number;
|
|
1960
|
+
confirmed?: boolean;
|
|
1961
|
+
topic?: SbtcEventTopic;
|
|
1962
|
+
sender?: string;
|
|
1963
|
+
requestId?: number;
|
|
1964
|
+
bitcoinTxid?: string;
|
|
1965
|
+
fromHeight?: number;
|
|
1966
|
+
toHeight?: number;
|
|
1891
1967
|
};
|
|
1892
1968
|
type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
|
|
1893
|
-
batchSize?: number
|
|
1894
|
-
signal?: AbortSignal
|
|
1969
|
+
batchSize?: number;
|
|
1970
|
+
signal?: AbortSignal;
|
|
1895
1971
|
};
|
|
1896
1972
|
type SbtcEventsConsumeParams<TTx = never> = Omit<SbtcEventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcEvent, SbtcEventsEnvelope, TTx>;
|
|
1897
1973
|
type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
|
|
@@ -1902,98 +1978,98 @@ interface SbtcResource {
|
|
|
1902
1978
|
/** Narrowing overload: `fields` shrinks the row type to exactly the
|
|
1903
1979
|
* requested columns plus {@link SbtcDepositAlwaysFields}. */
|
|
1904
1980
|
list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
|
|
1905
|
-
fields: readonly F[]
|
|
1906
|
-
}): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F
|
|
1907
|
-
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope
|
|
1908
|
-
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit
|
|
1981
|
+
fields: readonly F[];
|
|
1982
|
+
}): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
|
|
1983
|
+
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
|
|
1984
|
+
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
|
|
1909
1985
|
/** Checkpointed sweep of completed deposits — append-only, so safe to
|
|
1910
1986
|
* mirror. See {@link IndexConsumeOptions}. */
|
|
1911
1987
|
consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
|
|
1912
|
-
sink?: ConsumerSink<TTx
|
|
1988
|
+
sink?: ConsumerSink<TTx>;
|
|
1913
1989
|
}): Promise<{
|
|
1914
|
-
cursor: string | null
|
|
1915
|
-
pages: number
|
|
1916
|
-
emptyPolls: number
|
|
1917
|
-
}
|
|
1990
|
+
cursor: string | null;
|
|
1991
|
+
pages: number;
|
|
1992
|
+
emptyPolls: number;
|
|
1993
|
+
}>;
|
|
1918
1994
|
/** Fetch a completed deposit by Bitcoin txid; 404 → null. */
|
|
1919
|
-
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null
|
|
1995
|
+
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
|
|
1920
1996
|
};
|
|
1921
1997
|
withdrawals: {
|
|
1922
1998
|
/** Narrowing overload: `fields` shrinks the row type to exactly the
|
|
1923
1999
|
* requested columns plus {@link SbtcWithdrawalAlwaysFields}. */
|
|
1924
2000
|
list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
|
|
1925
|
-
fields: readonly F[]
|
|
1926
|
-
}): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F
|
|
1927
|
-
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope
|
|
1928
|
-
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal
|
|
2001
|
+
fields: readonly F[];
|
|
2002
|
+
}): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
|
|
2003
|
+
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
|
|
2004
|
+
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
|
|
1929
2005
|
/** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
|
|
1930
|
-
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null
|
|
2006
|
+
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
|
|
1931
2007
|
};
|
|
1932
2008
|
events: {
|
|
1933
|
-
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope
|
|
1934
|
-
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent
|
|
2009
|
+
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
|
|
2010
|
+
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
|
|
1935
2011
|
/** Checkpointed sweep of the raw peg event log — append-only across all
|
|
1936
2012
|
* six topics. See {@link IndexConsumeOptions}. */
|
|
1937
2013
|
consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
|
|
1938
|
-
sink?: ConsumerSink<TTx
|
|
2014
|
+
sink?: ConsumerSink<TTx>;
|
|
1939
2015
|
}): Promise<{
|
|
1940
|
-
cursor: string | null
|
|
1941
|
-
pages: number
|
|
1942
|
-
emptyPolls: number
|
|
1943
|
-
}
|
|
2016
|
+
cursor: string | null;
|
|
2017
|
+
pages: number;
|
|
2018
|
+
emptyPolls: number;
|
|
2019
|
+
}>;
|
|
1944
2020
|
};
|
|
1945
2021
|
/** The peg scoreboard — a single all-time aggregate (no pagination). */
|
|
1946
2022
|
summary(): Promise<SbtcSummaryEnvelope>;
|
|
1947
2023
|
}
|
|
1948
2024
|
/** Per-function action count within a reward cycle. */
|
|
1949
2025
|
type IndexPoxFunctionCount = {
|
|
1950
|
-
function_name: string
|
|
1951
|
-
count: number
|
|
2026
|
+
function_name: string;
|
|
2027
|
+
count: number;
|
|
1952
2028
|
};
|
|
1953
2029
|
/** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
|
|
1954
2030
|
* (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
|
|
1955
2031
|
type IndexPoxCycle = {
|
|
1956
|
-
reward_cycle: number
|
|
2032
|
+
reward_cycle: number;
|
|
1957
2033
|
/** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
|
|
1958
|
-
total_stacked_ustx: string
|
|
1959
|
-
unique_stackers: number
|
|
1960
|
-
unique_delegators: number
|
|
1961
|
-
action_count: number
|
|
1962
|
-
start_block_height: number
|
|
1963
|
-
end_block_height: number
|
|
2034
|
+
total_stacked_ustx: string;
|
|
2035
|
+
unique_stackers: number;
|
|
2036
|
+
unique_delegators: number;
|
|
2037
|
+
action_count: number;
|
|
2038
|
+
start_block_height: number;
|
|
2039
|
+
end_block_height: number;
|
|
1964
2040
|
/** True when this is the latest reward cycle (still accumulating new actions). */
|
|
1965
|
-
is_current: boolean
|
|
1966
|
-
function_breakdown: IndexPoxFunctionCount[]
|
|
2041
|
+
is_current: boolean;
|
|
2042
|
+
function_breakdown: IndexPoxFunctionCount[];
|
|
1967
2043
|
};
|
|
1968
2044
|
type PoxCyclesEnvelope = {
|
|
1969
|
-
cycles: IndexPoxCycle[]
|
|
2045
|
+
cycles: IndexPoxCycle[];
|
|
1970
2046
|
/** The next `reward_cycle` to page from (cycles descend), or null at the end. */
|
|
1971
|
-
next_cursor: number | null
|
|
1972
|
-
tip: IndexTip
|
|
2047
|
+
next_cursor: number | null;
|
|
2048
|
+
tip: IndexTip;
|
|
1973
2049
|
/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
|
|
1974
|
-
notes?: string
|
|
2050
|
+
notes?: string;
|
|
1975
2051
|
};
|
|
1976
2052
|
type PoxCycleEnvelope = {
|
|
1977
|
-
cycle: IndexPoxCycle
|
|
1978
|
-
tip: IndexTip
|
|
1979
|
-
notes?: string
|
|
2053
|
+
cycle: IndexPoxCycle;
|
|
2054
|
+
tip: IndexTip;
|
|
2055
|
+
notes?: string;
|
|
1980
2056
|
};
|
|
1981
2057
|
type PoxCyclesListParams = {
|
|
1982
2058
|
/** A `reward_cycle` to page from; the page returns cycles below it (descending). */
|
|
1983
|
-
cursor?: number | null
|
|
1984
|
-
limit?: number
|
|
2059
|
+
cursor?: number | null;
|
|
2060
|
+
limit?: number;
|
|
1985
2061
|
};
|
|
1986
2062
|
type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
|
|
1987
|
-
batchSize?: number
|
|
1988
|
-
signal?: AbortSignal
|
|
2063
|
+
batchSize?: number;
|
|
2064
|
+
signal?: AbortSignal;
|
|
1989
2065
|
};
|
|
1990
2066
|
/** `index.pox` — PoX reward-cycle aggregates. */
|
|
1991
2067
|
interface PoxResource {
|
|
1992
2068
|
cycles: {
|
|
1993
|
-
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope
|
|
1994
|
-
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle
|
|
2069
|
+
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
|
|
2070
|
+
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
|
|
1995
2071
|
/** Fetch one reward cycle's aggregate by number; 404 → null. */
|
|
1996
|
-
get(rewardCycle: number): Promise<PoxCycleEnvelope | null
|
|
2072
|
+
get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
|
|
1997
2073
|
};
|
|
1998
2074
|
}
|
|
1999
2075
|
/** The decoded `pox-5` boot-contract print topics (SIP-045 Bitcoin Staking) —
|
|
@@ -2004,37 +2080,37 @@ type IndexPox5EventTopic = Pox5EventTopic;
|
|
|
2004
2080
|
* `data` always carries the full decoded tuple, including nested shapes
|
|
2005
2081
|
* (`btc-lockup`, `bond-rewards`, `bond-periods`) that have no flat column. */
|
|
2006
2082
|
type IndexPox5Event = {
|
|
2007
|
-
cursor: string
|
|
2008
|
-
block_height: number
|
|
2009
|
-
block_time: string | null
|
|
2010
|
-
tx_id: string
|
|
2011
|
-
tx_index: number
|
|
2012
|
-
event_index: number
|
|
2013
|
-
topic: IndexPox5EventTopic
|
|
2014
|
-
staker: string | null
|
|
2015
|
-
signer: string | null
|
|
2016
|
-
signer_manager: string | null
|
|
2017
|
-
bond_index: number | null
|
|
2083
|
+
cursor: string;
|
|
2084
|
+
block_height: number;
|
|
2085
|
+
block_time: string | null;
|
|
2086
|
+
tx_id: string;
|
|
2087
|
+
tx_index: number;
|
|
2088
|
+
event_index: number;
|
|
2089
|
+
topic: IndexPox5EventTopic;
|
|
2090
|
+
staker: string | null;
|
|
2091
|
+
signer: string | null;
|
|
2092
|
+
signer_manager: string | null;
|
|
2093
|
+
bond_index: number | null;
|
|
2018
2094
|
/** ustx, bigint-safe string. */
|
|
2019
|
-
amount_ustx: string | null
|
|
2095
|
+
amount_ustx: string | null;
|
|
2020
2096
|
/** sats, bigint-safe string. */
|
|
2021
|
-
amount_sats: string | null
|
|
2022
|
-
reward_cycle: number | null
|
|
2023
|
-
first_reward_cycle: number | null
|
|
2024
|
-
unlock_cycle: number | null
|
|
2025
|
-
unlock_burn_height: number | null
|
|
2026
|
-
is_l1_lock: boolean | null
|
|
2027
|
-
signer_key: string | null
|
|
2097
|
+
amount_sats: string | null;
|
|
2098
|
+
reward_cycle: number | null;
|
|
2099
|
+
first_reward_cycle: number | null;
|
|
2100
|
+
unlock_cycle: number | null;
|
|
2101
|
+
unlock_burn_height: number | null;
|
|
2102
|
+
is_l1_lock: boolean | null;
|
|
2103
|
+
signer_key: string | null;
|
|
2028
2104
|
/** The full decoded print tuple as JSON. */
|
|
2029
|
-
data: unknown
|
|
2105
|
+
data: unknown;
|
|
2030
2106
|
};
|
|
2031
2107
|
type Pox5EventsEnvelope<TRow = IndexPox5Event> = {
|
|
2032
|
-
events: TRow[]
|
|
2033
|
-
next_cursor: string | null
|
|
2034
|
-
tip: IndexTip
|
|
2035
|
-
reorgs: IndexReorg[]
|
|
2108
|
+
events: TRow[];
|
|
2109
|
+
next_cursor: string | null;
|
|
2110
|
+
tip: IndexTip;
|
|
2111
|
+
reorgs: IndexReorg[];
|
|
2036
2112
|
/** Present only when the PoX-5 decoder is disabled, explaining an empty feed. */
|
|
2037
|
-
notes?: string
|
|
2113
|
+
notes?: string;
|
|
2038
2114
|
};
|
|
2039
2115
|
/** Pox5Event columns that survive any projection. */
|
|
2040
2116
|
type Pox5EventAlwaysFields = "cursor" | "block_height" | "topic";
|
|
@@ -2046,24 +2122,24 @@ type Pox5EventsListParams = {
|
|
|
2046
2122
|
* is physically absent — and the narrowing overload on `list` makes reading
|
|
2047
2123
|
* one a compile error rather than `undefined` at runtime.
|
|
2048
2124
|
*/
|
|
2049
|
-
fields?: readonly (keyof IndexPox5Event & string)[]
|
|
2050
|
-
cursor?: string | null
|
|
2051
|
-
fromCursor?: string | null
|
|
2052
|
-
limit?: number
|
|
2125
|
+
fields?: readonly (keyof IndexPox5Event & string)[];
|
|
2126
|
+
cursor?: string | null;
|
|
2127
|
+
fromCursor?: string | null;
|
|
2128
|
+
limit?: number;
|
|
2053
2129
|
/** Clamp to the finality boundary — only rows past the reorg margin. */
|
|
2054
|
-
confirmed?: boolean
|
|
2055
|
-
topic?: IndexPox5EventTopic
|
|
2056
|
-
staker?: string
|
|
2057
|
-
signer?: string
|
|
2058
|
-
signerManager?: string
|
|
2059
|
-
bondIndex?: number
|
|
2060
|
-
rewardCycle?: number
|
|
2061
|
-
fromHeight?: number
|
|
2062
|
-
toHeight?: number
|
|
2130
|
+
confirmed?: boolean;
|
|
2131
|
+
topic?: IndexPox5EventTopic;
|
|
2132
|
+
staker?: string;
|
|
2133
|
+
signer?: string;
|
|
2134
|
+
signerManager?: string;
|
|
2135
|
+
bondIndex?: number;
|
|
2136
|
+
rewardCycle?: number;
|
|
2137
|
+
fromHeight?: number;
|
|
2138
|
+
toHeight?: number;
|
|
2063
2139
|
};
|
|
2064
2140
|
type Pox5EventsWalkParams = Omit<Pox5EventsListParams, "limit"> & {
|
|
2065
|
-
batchSize?: number
|
|
2066
|
-
signal?: AbortSignal
|
|
2141
|
+
batchSize?: number;
|
|
2142
|
+
signal?: AbortSignal;
|
|
2067
2143
|
};
|
|
2068
2144
|
/** `index.pox5` — decoded PoX-5 print events, the staking primitive from the
|
|
2069
2145
|
* epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
|
|
@@ -2072,10 +2148,10 @@ interface Pox5Resource {
|
|
|
2072
2148
|
/** Narrowing overload: `fields` shrinks the row type to exactly the
|
|
2073
2149
|
* requested columns plus {@link Pox5EventAlwaysFields}. */
|
|
2074
2150
|
list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
|
|
2075
|
-
fields: readonly F[]
|
|
2076
|
-
}): Promise<Pox5EventsEnvelope<Pox5EventFields<F
|
|
2077
|
-
list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope
|
|
2078
|
-
walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event
|
|
2151
|
+
fields: readonly F[];
|
|
2152
|
+
}): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
|
|
2153
|
+
list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
|
|
2154
|
+
walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
|
|
2079
2155
|
};
|
|
2080
2156
|
}
|
|
2081
2157
|
/**
|
|
@@ -2089,20 +2165,20 @@ interface FtTransfersResource {
|
|
|
2089
2165
|
/** Narrowing overload for the callable shorthand — same wire path as
|
|
2090
2166
|
* `list`, so it must narrow identically. */
|
|
2091
2167
|
<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
|
|
2092
|
-
fields: readonly F[]
|
|
2168
|
+
fields: readonly F[];
|
|
2093
2169
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2094
2170
|
(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2095
2171
|
/** Narrowing overload: `fields` shrinks the row type to exactly the
|
|
2096
2172
|
* requested columns plus {@link FtTransferAlwaysFields}. */
|
|
2097
2173
|
list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
|
|
2098
|
-
fields: readonly F[]
|
|
2174
|
+
fields: readonly F[];
|
|
2099
2175
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2100
2176
|
list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2101
2177
|
/** Narrowing overload, matching `list`: `walk` forwards `fields` to the
|
|
2102
2178
|
* wire, so without this the yielded rows are stripped while the type
|
|
2103
2179
|
* still promises every column. */
|
|
2104
2180
|
walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
|
|
2105
|
-
fields: readonly F[]
|
|
2181
|
+
fields: readonly F[];
|
|
2106
2182
|
}): AsyncIterable<FtTransferFields<F>>;
|
|
2107
2183
|
walk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;
|
|
2108
2184
|
}
|
|
@@ -2111,18 +2187,18 @@ interface NftTransfersResource {
|
|
|
2111
2187
|
/** Narrowing overload for the callable shorthand — same wire path as
|
|
2112
2188
|
* `list`, so it must narrow identically. */
|
|
2113
2189
|
<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
|
|
2114
|
-
fields: readonly F[]
|
|
2190
|
+
fields: readonly F[];
|
|
2115
2191
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2116
2192
|
(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2117
2193
|
/** Narrowing overload: `fields` shrinks the row type to exactly the
|
|
2118
2194
|
* requested columns plus {@link NftTransferAlwaysFields}. */
|
|
2119
2195
|
list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
|
|
2120
|
-
fields: readonly F[]
|
|
2196
|
+
fields: readonly F[];
|
|
2121
2197
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2122
2198
|
list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2123
2199
|
/** Narrowing overload, matching `list` (see {@link FtTransfersResource}). */
|
|
2124
2200
|
walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
|
|
2125
|
-
fields: readonly F[]
|
|
2201
|
+
fields: readonly F[];
|
|
2126
2202
|
}): AsyncIterable<NftTransferFields<F>>;
|
|
2127
2203
|
walk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;
|
|
2128
2204
|
}
|
|
@@ -2134,7 +2210,7 @@ interface IndexEventsResource {
|
|
|
2134
2210
|
T extends IndexEventType,
|
|
2135
2211
|
const F extends keyof IndexEventOf<T> & string
|
|
2136
2212
|
>(params: EventsListParams<T> & {
|
|
2137
|
-
fields: readonly F[]
|
|
2213
|
+
fields: readonly F[];
|
|
2138
2214
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2139
2215
|
<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2140
2216
|
/** Narrowing overload: `fields` shrinks the returned row type to exactly
|
|
@@ -2144,7 +2220,7 @@ interface IndexEventsResource {
|
|
|
2144
2220
|
T extends IndexEventType,
|
|
2145
2221
|
const F extends keyof IndexEventOf<T> & string
|
|
2146
2222
|
>(params: EventsListParams<T> & {
|
|
2147
|
-
fields: readonly F[]
|
|
2223
|
+
fields: readonly F[];
|
|
2148
2224
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2149
2225
|
list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2150
2226
|
/** Narrowing overload, matching `list`: `walk` forwards `fields` to the
|
|
@@ -2154,33 +2230,33 @@ interface IndexEventsResource {
|
|
|
2154
2230
|
T extends IndexEventType,
|
|
2155
2231
|
const F extends keyof IndexEventOf<T> & string
|
|
2156
2232
|
>(params: EventsWalkParams<T> & {
|
|
2157
|
-
fields: readonly F[]
|
|
2233
|
+
fields: readonly F[];
|
|
2158
2234
|
}): AsyncIterable<IndexEventFields<T, F>>;
|
|
2159
2235
|
walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
|
|
2160
2236
|
consume<
|
|
2161
2237
|
T extends IndexEventType,
|
|
2162
2238
|
TTx = never
|
|
2163
2239
|
>(params: EventsConsumeParams<T, TTx> & {
|
|
2164
|
-
sink?: ConsumerSink<TTx
|
|
2240
|
+
sink?: ConsumerSink<TTx>;
|
|
2165
2241
|
}): Promise<{
|
|
2166
|
-
cursor: string | null
|
|
2167
|
-
pages: number
|
|
2168
|
-
emptyPolls: number
|
|
2242
|
+
cursor: string | null;
|
|
2243
|
+
pages: number;
|
|
2244
|
+
emptyPolls: number;
|
|
2169
2245
|
}>;
|
|
2170
2246
|
}
|
|
2171
2247
|
/** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */
|
|
2172
2248
|
type IndexEventTypeFilters = {
|
|
2173
|
-
columns?: string[]
|
|
2174
|
-
allowed_filters?: string[]
|
|
2175
|
-
equality_filters?: string[]
|
|
2176
|
-
required_non_null?: string[]
|
|
2249
|
+
columns?: string[];
|
|
2250
|
+
allowed_filters?: string[];
|
|
2251
|
+
equality_filters?: string[];
|
|
2252
|
+
required_non_null?: string[];
|
|
2177
2253
|
};
|
|
2178
2254
|
/** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.
|
|
2179
2255
|
* Shape is intentionally open (the server may add fields); the agent-relevant
|
|
2180
2256
|
* parts are the per-type filter rules. */
|
|
2181
2257
|
type IndexDiscovery = {
|
|
2182
|
-
event_type_filters?: Record<string, IndexEventTypeFilters
|
|
2183
|
-
[key: string]: unknown
|
|
2258
|
+
event_type_filters?: Record<string, IndexEventTypeFilters>;
|
|
2259
|
+
[key: string]: unknown;
|
|
2184
2260
|
};
|
|
2185
2261
|
declare class Index extends BaseClient {
|
|
2186
2262
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
@@ -2206,27 +2282,27 @@ declare class Index extends BaseClient {
|
|
|
2206
2282
|
* Callable: `index.events(params)` ≡ `index.events.list(params)`. */
|
|
2207
2283
|
readonly events: IndexEventsResource;
|
|
2208
2284
|
readonly contractCalls: {
|
|
2209
|
-
list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope
|
|
2210
|
-
walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall
|
|
2285
|
+
list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
|
|
2286
|
+
walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
|
|
2211
2287
|
consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
|
|
2212
|
-
sink?: ConsumerSink<TTx
|
|
2288
|
+
sink?: ConsumerSink<TTx>;
|
|
2213
2289
|
}) => Promise<{
|
|
2214
|
-
cursor: string | null
|
|
2215
|
-
pages: number
|
|
2216
|
-
emptyPolls: number
|
|
2217
|
-
}
|
|
2290
|
+
cursor: string | null;
|
|
2291
|
+
pages: number;
|
|
2292
|
+
emptyPolls: number;
|
|
2293
|
+
}>;
|
|
2218
2294
|
};
|
|
2219
2295
|
/** Canonical block-hash map — sync only the current canonical chain. */
|
|
2220
2296
|
readonly canonical: {
|
|
2221
|
-
list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope
|
|
2222
|
-
walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock
|
|
2297
|
+
list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
|
|
2298
|
+
walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
|
|
2223
2299
|
};
|
|
2224
2300
|
/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
|
|
2225
2301
|
* (resolves to null on 404). */
|
|
2226
2302
|
readonly blocks: {
|
|
2227
|
-
list: (params?: BlocksListParams) => Promise<BlocksEnvelope
|
|
2228
|
-
walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock
|
|
2229
|
-
get: (ref: string | number) => Promise<BlockEnvelope | null
|
|
2303
|
+
list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
|
|
2304
|
+
walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
|
|
2305
|
+
get: (ref: string | number) => Promise<BlockEnvelope | null>;
|
|
2230
2306
|
};
|
|
2231
2307
|
/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
|
|
2232
2308
|
* (resolves to null on 404). */
|
|
@@ -2237,26 +2313,26 @@ declare class Index extends BaseClient {
|
|
|
2237
2313
|
* overloads. */
|
|
2238
2314
|
list: {
|
|
2239
2315
|
<const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
|
|
2240
|
-
fields: readonly F[]
|
|
2241
|
-
}): Promise<TransactionsEnvelope<TransactionFields<F
|
|
2242
|
-
(params?: TransactionsListParams): Promise<TransactionsEnvelope
|
|
2243
|
-
}
|
|
2244
|
-
walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction
|
|
2245
|
-
get: (txId: string) => Promise<TransactionEnvelope | null
|
|
2246
|
-
getProof: (txId: string) => Promise<TransactionProof | null
|
|
2316
|
+
fields: readonly F[];
|
|
2317
|
+
}): Promise<TransactionsEnvelope<TransactionFields<F>>>;
|
|
2318
|
+
(params?: TransactionsListParams): Promise<TransactionsEnvelope>;
|
|
2319
|
+
};
|
|
2320
|
+
walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
|
|
2321
|
+
get: (txId: string) => Promise<TransactionEnvelope | null>;
|
|
2322
|
+
getProof: (txId: string) => Promise<TransactionProof | null>;
|
|
2247
2323
|
};
|
|
2248
2324
|
/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
|
|
2249
2325
|
* platform's PoX-4 decoder is disabled. */
|
|
2250
2326
|
readonly stacking: {
|
|
2251
|
-
list: (params?: StackingListParams) => Promise<StackingEnvelope
|
|
2252
|
-
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction
|
|
2327
|
+
list: (params?: StackingListParams) => Promise<StackingEnvelope>;
|
|
2328
|
+
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
|
|
2253
2329
|
};
|
|
2254
2330
|
/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
|
|
2255
2331
|
* tx_id (resolves to null when the tx has confirmed or dropped). */
|
|
2256
2332
|
readonly mempool: {
|
|
2257
|
-
list: (params?: MempoolListParams) => Promise<MempoolEnvelope
|
|
2258
|
-
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction
|
|
2259
|
-
get: (txId: string) => Promise<MempoolTransactionEnvelope | null
|
|
2333
|
+
list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
|
|
2334
|
+
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
|
|
2335
|
+
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
|
|
2260
2336
|
};
|
|
2261
2337
|
/** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
|
|
2262
2338
|
* Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
|
|
@@ -2369,7 +2445,7 @@ declare class Projects extends BaseClient {
|
|
|
2369
2445
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
2370
2446
|
/** All projects owned by the account, newest-relevant first. */
|
|
2371
2447
|
list(): Promise<{
|
|
2372
|
-
projects: Project[]
|
|
2448
|
+
projects: Project[];
|
|
2373
2449
|
}>;
|
|
2374
2450
|
/** A single project by slug. */
|
|
2375
2451
|
get(slug: string): Promise<Project>;
|
|
@@ -2379,7 +2455,7 @@ declare class Projects extends BaseClient {
|
|
|
2379
2455
|
update(slug: string, patch: UpdateProjectParams): Promise<Project>;
|
|
2380
2456
|
/** Delete a project. The account's last remaining project cannot be deleted. */
|
|
2381
2457
|
delete(slug: string): Promise<{
|
|
2382
|
-
ok: true
|
|
2458
|
+
ok: true;
|
|
2383
2459
|
}>;
|
|
2384
2460
|
/** Team members and pending invitations for a project. */
|
|
2385
2461
|
team(slug: string): Promise<ProjectTeam>;
|
|
@@ -2387,7 +2463,7 @@ declare class Projects extends BaseClient {
|
|
|
2387
2463
|
import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, SubscriptionTestResult, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
|
|
2388
2464
|
declare class Subscriptions extends BaseClient {
|
|
2389
2465
|
list(): Promise<{
|
|
2390
|
-
data: SubscriptionSummary[]
|
|
2466
|
+
data: SubscriptionSummary[];
|
|
2391
2467
|
}>;
|
|
2392
2468
|
get(id: string): Promise<SubscriptionDetail>;
|
|
2393
2469
|
create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
|
|
@@ -2395,25 +2471,25 @@ declare class Subscriptions extends BaseClient {
|
|
|
2395
2471
|
pause(id: string): Promise<SubscriptionDetail>;
|
|
2396
2472
|
resume(id: string): Promise<SubscriptionDetail>;
|
|
2397
2473
|
delete(id: string): Promise<{
|
|
2398
|
-
ok: true
|
|
2474
|
+
ok: true;
|
|
2399
2475
|
}>;
|
|
2400
2476
|
rotateSecret(id: string): Promise<RotateSecretResponse>;
|
|
2401
2477
|
/** Send a one-off test webhook to the subscription's URL (built for its
|
|
2402
2478
|
* format, SSRF-guarded). Logged as a delivery row, visible via recentDeliveries. */
|
|
2403
2479
|
test(id: string): Promise<SubscriptionTestResult>;
|
|
2404
2480
|
recentDeliveries(id: string): Promise<{
|
|
2405
|
-
data: DeliveryRow[]
|
|
2481
|
+
data: DeliveryRow[];
|
|
2406
2482
|
}>;
|
|
2407
2483
|
replay(id: string, range: {
|
|
2408
|
-
fromBlock: number
|
|
2409
|
-
toBlock: number
|
|
2410
|
-
force?: string
|
|
2484
|
+
fromBlock: number;
|
|
2485
|
+
toBlock: number;
|
|
2486
|
+
force?: string;
|
|
2411
2487
|
}): Promise<ReplayResult>;
|
|
2412
2488
|
dead(id: string): Promise<{
|
|
2413
|
-
data: DeadRow[]
|
|
2489
|
+
data: DeadRow[];
|
|
2414
2490
|
}>;
|
|
2415
2491
|
requeueDead(id: string, outboxId: string): Promise<{
|
|
2416
|
-
ok: true
|
|
2492
|
+
ok: true;
|
|
2417
2493
|
}>;
|
|
2418
2494
|
}
|
|
2419
2495
|
interface ContextAccount {
|
|
@@ -2451,8 +2527,8 @@ interface ContextSnapshot {
|
|
|
2451
2527
|
indexTip: IndexTip | null;
|
|
2452
2528
|
subgraphs: SubgraphSummary2[] | null;
|
|
2453
2529
|
subscriptions: {
|
|
2454
|
-
count: number
|
|
2455
|
-
byStatus: Record<string, number
|
|
2530
|
+
count: number;
|
|
2531
|
+
byStatus: Record<string, number>;
|
|
2456
2532
|
} | null;
|
|
2457
2533
|
/** The account's projects (null when unreadable — e.g. a scoped key). */
|
|
2458
2534
|
projects: ContextProject[] | null;
|
|
@@ -2481,14 +2557,14 @@ declare class SecondLayer extends BaseClient {
|
|
|
2481
2557
|
* PAYMENT-BALANCE/SESSION) apply to every item.
|
|
2482
2558
|
*/
|
|
2483
2559
|
batch(requests: Array<{
|
|
2484
|
-
path: string
|
|
2485
|
-
params?: Record<string, string | number | boolean
|
|
2560
|
+
path: string;
|
|
2561
|
+
params?: Record<string, string | number | boolean>;
|
|
2486
2562
|
}>): Promise<{
|
|
2487
2563
|
results: Array<{
|
|
2488
|
-
path: string | null
|
|
2489
|
-
status: number
|
|
2490
|
-
body: unknown
|
|
2491
|
-
}
|
|
2564
|
+
path: string | null;
|
|
2565
|
+
status: number;
|
|
2566
|
+
body: unknown;
|
|
2567
|
+
}>;
|
|
2492
2568
|
}>;
|
|
2493
2569
|
context(): Promise<ContextSnapshot>;
|
|
2494
2570
|
}
|
|
@@ -2507,8 +2583,8 @@ declare class SecondLayer extends BaseClient {
|
|
|
2507
2583
|
* ```
|
|
2508
2584
|
*/
|
|
2509
2585
|
declare function getSubgraph<T extends {
|
|
2510
|
-
name: string
|
|
2511
|
-
schema: Record<string, unknown
|
|
2586
|
+
name: string;
|
|
2587
|
+
schema: Record<string, unknown>;
|
|
2512
2588
|
}>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
|
|
2513
2589
|
import { SubgraphAgentSchema as SubgraphAgentSchema2, SubgraphSpecFormat, SubgraphSpecOptions as SubgraphSpecOptions2 } from "@secondlayer/shared/subgraphs/spec";
|
|
2514
2590
|
export { getSubgraph, Subgraphs, SubgraphSpecOptions2 as SubgraphSpecOptions, SubgraphSpecFormat, SubgraphAgentSchema2 as SubgraphAgentSchema, SecondLayerOptions };
|