@secondlayer/sdk 15.0.0 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +549 -127
- package/dist/index.js.map +11 -11
- package/dist/streams/index.d.ts +109 -59
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +548 -126
- package/dist/subgraphs/index.js.map +9 -9
- package/dist/webhooks/doctor.d.ts +1 -1
- package/dist/webhooks/doctor.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,17 @@ import { InstanceDiagnosis, PublicStatus } from "@secondlayer/shared/archive/ins
|
|
|
4
4
|
/** Structural `/public/status` payload. Extra fields are ignored by diagnosis. */
|
|
5
5
|
type InstanceStatus = PublicStatus;
|
|
6
6
|
type InstanceClient = {
|
|
7
|
+
/**
|
|
8
|
+
* Get the instance's public status report.
|
|
9
|
+
*
|
|
10
|
+
* Reads `GET /public/status`: the overall status, chain tip, chain integrity, and the state of each service and decoder.
|
|
11
|
+
*/
|
|
7
12
|
status(): Promise<InstanceStatus>;
|
|
13
|
+
/**
|
|
14
|
+
* Turn the status report into a verdict with next steps.
|
|
15
|
+
*
|
|
16
|
+
* Resolves to a `state` (`healthy`, `empty-index`, or `degraded`), the API's own `overall` status, and a list of issues, each with the commands that resolve it. A fresh instance with no blocks indexed reads as `empty-index`, not broken.
|
|
17
|
+
*/
|
|
8
18
|
diagnose(): Promise<InstanceDiagnosis>;
|
|
9
19
|
};
|
|
10
20
|
type ArchiveVerifyInput = {
|
|
@@ -107,33 +117,83 @@ type ArchiveLoadOptions = {
|
|
|
107
117
|
insecure?: boolean;
|
|
108
118
|
};
|
|
109
119
|
type ArchiveClient = {
|
|
120
|
+
/**
|
|
121
|
+
* Load the latest signed archive manifest.
|
|
122
|
+
*
|
|
123
|
+
* Reads `<archive>/latest.json` unless `against` names another manifest URL. The manifest's ed25519 signature is checked against the archive signing key, and a missing or invalid one throws `ArchiveSignatureError`. `insecure: true` skips the check; `signature.verified` on the result says whether it held.
|
|
124
|
+
*/
|
|
110
125
|
latest(against?: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
|
|
126
|
+
/**
|
|
127
|
+
* Load an archive manifest from a URL.
|
|
128
|
+
*
|
|
129
|
+
* Takes http(s) URLs only; a local path throws a `ValidationError` and stays on the CLI. The signature check is the same as {@link latest}.
|
|
130
|
+
*/
|
|
111
131
|
load(against: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
|
|
132
|
+
/**
|
|
133
|
+
* Get the archive's current operational state.
|
|
134
|
+
*
|
|
135
|
+
* Reads the public `status.json`: `fresh`, `lagging`, `stale`, `gap`, `failed-audit`, or `source-unavailable`, plus how far the last signed publish reaches.
|
|
136
|
+
*/
|
|
112
137
|
status(): Promise<ArchiveStatus>;
|
|
138
|
+
/**
|
|
139
|
+
* List a loaded archive's partitions, optionally filtered.
|
|
140
|
+
*
|
|
141
|
+
* Runs locally on the manifest you already loaded and makes no request. Filter by `dataset` (`blocks`, `transactions`, or `events`) and a block range.
|
|
142
|
+
*/
|
|
113
143
|
partitions(ref: LoadedArchive, filter?: {
|
|
114
144
|
dataset?: ArchiveDataset;
|
|
115
145
|
fromBlock?: number;
|
|
116
146
|
toBlock?: number;
|
|
117
147
|
}): ArchivePartition[];
|
|
148
|
+
/**
|
|
149
|
+
* Price a fetch against your balance before you pay for it.
|
|
150
|
+
*
|
|
151
|
+
* Nothing is charged. `flow` is `bootstrap` or `repair`. The quote has the bundle count, the price in USD, the free repair allowance applied, your balance, and `sufficient`. Needs an account key (`sk-sl_*`), not an instance token.
|
|
152
|
+
*/
|
|
118
153
|
quote(input: {
|
|
119
154
|
paths: string[];
|
|
120
155
|
flow: ArchiveFlow;
|
|
121
156
|
}): Promise<ArchiveQuote>;
|
|
157
|
+
/**
|
|
158
|
+
* Get presigned download URLs for archive partitions.
|
|
159
|
+
*
|
|
160
|
+
* Draws credits per partition bundle; your first six repair bundles each month are free. Lists longer than 64 paths go out in batches of 64. Each URL is short-lived (`expiresAt`); pass it to {@link download}. An empty balance throws `InsufficientArchiveCreditsError` with the shortfall. Needs an account key (`sk-sl_*`).
|
|
161
|
+
*/
|
|
122
162
|
fetch(input: {
|
|
123
163
|
paths: string[];
|
|
124
164
|
flow: ArchiveFlow;
|
|
125
165
|
}): Promise<ArchiveFetchResult>;
|
|
166
|
+
/**
|
|
167
|
+
* Download a partition's bytes and verify them.
|
|
168
|
+
*
|
|
169
|
+
* The sha256 is checked against the manifest, and a mismatch throws `ArchiveSignatureError`. On the official archive host you must pass the presigned `url` from {@link fetch}, or it throws a `ValidationError`; any other host downloads straight from its archive tree.
|
|
170
|
+
*/
|
|
126
171
|
download(partition: ArchivePartition, opts?: {
|
|
127
172
|
url?: string;
|
|
128
173
|
}): Promise<Uint8Array>;
|
|
129
174
|
credits: {
|
|
175
|
+
/**
|
|
176
|
+
* Get your archive credit balance.
|
|
177
|
+
*
|
|
178
|
+
* Returns `creditsUsdMicros` (millionths of a dollar, as a string) and your auto-refill setting. Needs an account key (`sk-sl_*`).
|
|
179
|
+
*/
|
|
130
180
|
balance(): Promise<ArchiveCreditsBalance>;
|
|
181
|
+
/**
|
|
182
|
+
* Start a card checkout for a credit pack.
|
|
183
|
+
*
|
|
184
|
+
* `pack` is the dollar amount: 10, 25, 50, or 100. Resolves to the checkout `url`. Needs no account key.
|
|
185
|
+
*/
|
|
131
186
|
checkout(input: {
|
|
132
187
|
email: string;
|
|
133
188
|
pack: 10 | 25 | 50 | 100;
|
|
134
189
|
}): Promise<{
|
|
135
190
|
url: string;
|
|
136
191
|
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Set or turn off automatic credit refill.
|
|
194
|
+
*
|
|
195
|
+
* Pass `belowUsd` and `packUsd` to buy a pack whenever the balance drops below the threshold, or `{ off: true }` to stop. Needs an account key (`sk-sl_*`).
|
|
196
|
+
*/
|
|
137
197
|
refill(input: {
|
|
138
198
|
belowUsd: number;
|
|
139
199
|
packUsd: 10 | 25 | 50 | 100;
|
|
@@ -147,6 +207,11 @@ type ArchiveClient = {
|
|
|
147
207
|
};
|
|
148
208
|
/** Hosted archive client plus instance `verify`. `status()` is still the public archive tree. */
|
|
149
209
|
type SecondLayerArchive = ArchiveClient & {
|
|
210
|
+
/**
|
|
211
|
+
* Check your instance's data against a signed archive.
|
|
212
|
+
*
|
|
213
|
+
* Runs `POST /v1/archive/verify` on your instance: read-only, and it compares raw identity digests only (the deep semantic check is CLI-only). Resolves to `clean`, `diverged`, or `unanchored`; a failed signature is `unanchored`, never `clean`. Narrow the check with `fromBlock` and `toBlock`. Verification is free.
|
|
214
|
+
*/
|
|
150
215
|
verify(input: ArchiveVerifyInput): Promise<ArchiveVerifyResult>;
|
|
151
216
|
};
|
|
152
217
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
@@ -311,8 +376,10 @@ declare class Contracts extends BaseClient {
|
|
|
311
376
|
/** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */
|
|
312
377
|
list(params: ContractsListParams): Promise<ContractsEnvelope>;
|
|
313
378
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
379
|
+
* Get one contract from the registry by id, or `null`.
|
|
380
|
+
*
|
|
381
|
+
* The prod-safe ABI source. Pass `{ includeAbi: true }` for the full ABI
|
|
382
|
+
* blob. Resolves to `null` on 404.
|
|
316
383
|
*/
|
|
317
384
|
get(contractId: string, opts?: {
|
|
318
385
|
includeAbi?: boolean;
|
|
@@ -552,7 +619,7 @@ type StreamsTip = {
|
|
|
552
619
|
/** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
|
|
553
620
|
oldest_cursor?: string | null;
|
|
554
621
|
};
|
|
555
|
-
/** `chain=bitcoin` tip
|
|
622
|
+
/** `chain=bitcoin` tip — no `burn_block_height`/retention fields,
|
|
556
623
|
* since Bitcoin has no burn chain of its own and Runes reads have no
|
|
557
624
|
* retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
|
|
558
625
|
type StreamsBitcoinTip = {
|
|
@@ -568,7 +635,7 @@ type StreamsCanonicalBlock = {
|
|
|
568
635
|
burn_block_hash: string | null;
|
|
569
636
|
is_canonical: true;
|
|
570
637
|
};
|
|
571
|
-
/** `chain=bitcoin` canonical block
|
|
638
|
+
/** `chain=bitcoin` canonical block — no burn-chain fields. */
|
|
572
639
|
type StreamsBitcoinCanonicalBlock = {
|
|
573
640
|
block_height: number;
|
|
574
641
|
block_hash: string;
|
|
@@ -651,8 +718,8 @@ type StreamsEventsListParamsCommon = {
|
|
|
651
718
|
toHeight?: number;
|
|
652
719
|
limit?: number;
|
|
653
720
|
};
|
|
654
|
-
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
|
|
655
|
-
*
|
|
721
|
+
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
|
|
722
|
+
* were added. */
|
|
656
723
|
type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
657
724
|
chain?: "stacks";
|
|
658
725
|
/** `vm` reads ordinal. Omit for Streams 1.0. */
|
|
@@ -672,7 +739,7 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
|
672
739
|
filters?: StreamsFilterMap;
|
|
673
740
|
};
|
|
674
741
|
/**
|
|
675
|
-
* `chain: "bitcoin"`
|
|
742
|
+
* `chain: "bitcoin"` — Runes events, own cursor space. `types` is
|
|
676
743
|
* restricted to {@link RuneEventType} at the type level, so e.g.
|
|
677
744
|
* `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
|
|
678
745
|
* than a silent 400 at request time. `contractId`/`sender`/`recipient`/
|
|
@@ -710,7 +777,7 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
|
|
|
710
777
|
/** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
|
|
711
778
|
filters?: StreamsFilterMap;
|
|
712
779
|
};
|
|
713
|
-
/** `chain: "bitcoin"`
|
|
780
|
+
/** `chain: "bitcoin"` — Runes events, tailed the same way as
|
|
714
781
|
* the Stacks default. `types` is restricted to {@link RuneEventType} at the
|
|
715
782
|
* type level, matching {@link StreamsEventsBitcoinListParams}.
|
|
716
783
|
* `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
|
|
@@ -768,7 +835,7 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
|
|
|
768
835
|
*/
|
|
769
836
|
onEvent: (event: StreamsEvent) => void | Promise<void>;
|
|
770
837
|
};
|
|
771
|
-
/** `chain: "bitcoin"`
|
|
838
|
+
/** `chain: "bitcoin"` — Runes events pushed live, on their own
|
|
772
839
|
* cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
|
|
773
840
|
* don't exist on this branch — they're Stacks-only. */
|
|
774
841
|
type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
|
|
@@ -978,7 +1045,7 @@ type StreamsEventsConsumeParams<
|
|
|
978
1045
|
wake?: () => Promise<void>;
|
|
979
1046
|
};
|
|
980
1047
|
/**
|
|
981
|
-
* `chain: "bitcoin"`
|
|
1048
|
+
* `chain: "bitcoin"` — the checkpointed sweep over Runes
|
|
982
1049
|
* events. A separate, simpler type from {@link StreamsEventsConsumeParams}
|
|
983
1050
|
* rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
|
|
984
1051
|
* concepts (labelled OR-groups and Index-shaped projection have no Runes
|
|
@@ -1056,7 +1123,7 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
|
|
|
1056
1123
|
* event echoes the labels it matched. */
|
|
1057
1124
|
filters?: StreamsFilterMap;
|
|
1058
1125
|
};
|
|
1059
|
-
/** `chain: "bitcoin"`
|
|
1126
|
+
/** `chain: "bitcoin"` — Runes batches, own cursor space.
|
|
1060
1127
|
* `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
|
|
1061
1128
|
* on this branch — they're Stacks-only. */
|
|
1062
1129
|
type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
|
|
@@ -1160,38 +1227,43 @@ type StreamsDumps = {
|
|
|
1160
1227
|
};
|
|
1161
1228
|
type StreamsClient = {
|
|
1162
1229
|
/**
|
|
1163
|
-
*
|
|
1230
|
+
* Read Streams page by page as an async iterator.
|
|
1231
|
+
*
|
|
1232
|
+
* Yields one {@link StreamsBatch} per events page, so each yield is exactly
|
|
1233
|
+
* one API call. Empty pages are skipped; at the tip the iterator polls again
|
|
1234
|
+
* every `intervalMs` (default 2000) until `signal` aborts.
|
|
1164
1235
|
*
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
* with zero extra API calls. Batches are chosen over per-block groupings
|
|
1168
|
-
* because the envelope is page-keyed, so every yield is exactly one fetch.
|
|
1169
|
-
* Empty pages are skipped; at the tip the iterator re-polls every
|
|
1170
|
-
* `intervalMs` (default 2000) until aborted via `signal`.
|
|
1236
|
+
* Reorgs appear on `batch.reorgs`, but the cursor is not rewound for you.
|
|
1237
|
+
* Use `events.consume` with `onReorg` when you need rollback.
|
|
1171
1238
|
*
|
|
1172
|
-
*
|
|
1173
|
-
*
|
|
1174
|
-
* rollback semantics.
|
|
1239
|
+
* A literal `types` array narrows every batch's event union to those types.
|
|
1240
|
+
* `chain: "bitcoin"` batches carry Runes rows only, on the bitcoin tip shape.
|
|
1175
1241
|
*/
|
|
1176
|
-
/** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
|
|
1177
|
-
* shape (plan 059/061). */
|
|
1178
1242
|
consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1179
|
-
/** Narrowing overload: a literal `types` array narrows every batch's
|
|
1180
|
-
* event union to exactly those members. */
|
|
1181
1243
|
consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
|
|
1182
1244
|
types: T;
|
|
1183
1245
|
}): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
|
|
1184
1246
|
consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
|
|
1185
1247
|
events: {
|
|
1186
|
-
/**
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1248
|
+
/**
|
|
1249
|
+
* Read one page of chain events and the next cursor.
|
|
1250
|
+
*
|
|
1251
|
+
* Narrow with `types`, `notTypes`, `contractId`, `sender`, `recipient`,
|
|
1252
|
+
* `assetIdentifier`, `fromHeight`/`toHeight`, or labelled `filters`.
|
|
1253
|
+
* Filters match exactly, and an event type without a given field never
|
|
1254
|
+
* matches it. Pass `next_cursor` back as `cursor` to continue. The
|
|
1255
|
+
* envelope also carries the `tip` and any `reorgs`. To write the events
|
|
1256
|
+
* somewhere with a checkpoint, use `events.consume` instead.
|
|
1257
|
+
*
|
|
1258
|
+
* A literal `types` array narrows every row to those event types.
|
|
1259
|
+
* `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
|
|
1260
|
+
* `event_index` = `ordinal`), never `StreamsEvent`; it is Stacks only.
|
|
1261
|
+
* `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip shape,
|
|
1262
|
+
* and filter by `rune` or `address`.
|
|
1263
|
+
*/
|
|
1189
1264
|
list(params: StreamsEventsStacksListParams & {
|
|
1190
1265
|
clock: "vm";
|
|
1191
1266
|
}): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
|
|
1192
|
-
/** Narrowing overload, matching `consume`. Classic clock only —
|
|
1193
|
-
* `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
|
|
1194
|
-
* variable (clock unresolved) is the wire-union fallback. */
|
|
1195
1267
|
list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
|
|
1196
1268
|
types: T;
|
|
1197
1269
|
notTypes?: readonly StreamsEventType[];
|
|
@@ -1202,27 +1274,35 @@ type StreamsClient = {
|
|
|
1202
1274
|
notTypes?: readonly StreamsEventType[];
|
|
1203
1275
|
clock?: "classic";
|
|
1204
1276
|
}): Promise<StreamsEventsEnvelope>;
|
|
1205
|
-
/** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
|
|
1206
|
-
* shape (plan 059). */
|
|
1207
1277
|
list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1208
|
-
/** Unresolved `chain`/`clock` on a general params variable: the wire union. */
|
|
1209
1278
|
list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
|
|
1210
|
-
/**
|
|
1279
|
+
/**
|
|
1280
|
+
* Read every event a transaction emitted.
|
|
1281
|
+
*
|
|
1282
|
+
* Returns the events and the `tip`, with no `next_cursor`: one transaction
|
|
1283
|
+
* is one response.
|
|
1284
|
+
*
|
|
1285
|
+
* `chain: "bitcoin"` returns the Runes events for one Bitcoin transaction.
|
|
1286
|
+
*/
|
|
1211
1287
|
byTxId(txId: string, opts: {
|
|
1212
1288
|
chain: "bitcoin";
|
|
1213
1289
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1214
1290
|
byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
|
|
1215
1291
|
/**
|
|
1216
|
-
*
|
|
1292
|
+
* Run a checkpointed indexer that rewinds on reorgs.
|
|
1217
1293
|
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1294
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same
|
|
1295
|
+
* transaction; resume with `fromCursor`. Reorgs at or below your checkpoint
|
|
1296
|
+
* call `onReorg`, then the loop re-reads from the fork point. Delivery is
|
|
1297
|
+
* at-least-once, so keep writes idempotent. With a `sink`, the checkpoint
|
|
1298
|
+
* and rollback are handled for you. `mode: "tail"` (default) keeps polling
|
|
1299
|
+
* at the tip; `mode: "bounded"` returns on the first empty page. It also
|
|
1300
|
+
* stops on `maxPages`, `maxEmptyPolls`, or `signal`. Pass `finalizedOnly`
|
|
1301
|
+
* to skip reorg handling entirely.
|
|
1302
|
+
*
|
|
1303
|
+
* `chain: "bitcoin"` sweeps Runes events; see
|
|
1304
|
+
* {@link StreamsEventsConsumeBitcoinParams}.
|
|
1223
1305
|
*/
|
|
1224
|
-
/** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
|
|
1225
|
-
* {@link StreamsEventsConsumeBitcoinParams}. */
|
|
1226
1306
|
consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
|
|
1227
1307
|
sink?: ConsumerSink<TTx>;
|
|
1228
1308
|
}): Promise<StreamsEventsConsumeResult>;
|
|
@@ -1234,46 +1314,66 @@ type StreamsClient = {
|
|
|
1234
1314
|
sink?: ConsumerSink<TTx>;
|
|
1235
1315
|
}): Promise<StreamsEventsConsumeResult>;
|
|
1236
1316
|
/**
|
|
1237
|
-
* Backfill from bulk dumps, then continue live
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
* `
|
|
1317
|
+
* Backfill from bulk dumps, then continue live in one call.
|
|
1318
|
+
*
|
|
1319
|
+
* Hands each finalized dump file to `onDumpFile` in block order, then tails
|
|
1320
|
+
* live from the manifest's `latest_finalized_cursor`, with no gap or
|
|
1321
|
+
* duplicate at the seam. A file that straddles `from` is delivered whole,
|
|
1322
|
+
* so skip the rows at or below it. Requires `dumpsBaseUrl`.
|
|
1242
1323
|
*/
|
|
1243
1324
|
replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
|
|
1244
1325
|
/**
|
|
1245
|
-
*
|
|
1326
|
+
* Read events one at a time as an async iterator.
|
|
1246
1327
|
*
|
|
1247
|
-
*
|
|
1248
|
-
* indefinitely
|
|
1249
|
-
* `maxEmptyPolls`
|
|
1328
|
+
* For live processors and watch-style apps that keep their own state. It
|
|
1329
|
+
* tails indefinitely and stops when `signal`, `maxPages`, or
|
|
1330
|
+
* `maxEmptyPolls` ends it. There is no checkpoint or reorg handling; use
|
|
1331
|
+
* `events.consume` for that.
|
|
1332
|
+
*
|
|
1333
|
+
* A literal `types` array narrows every event to those types.
|
|
1334
|
+
* `chain: "bitcoin"` yields Runes events only.
|
|
1250
1335
|
*/
|
|
1251
|
-
/** `chain: "bitcoin"` — Runes events only (plan 059/061). */
|
|
1252
1336
|
stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
|
|
1253
|
-
/** Narrowing overload, matching `consume`. */
|
|
1254
1337
|
stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
|
|
1255
1338
|
types: T;
|
|
1256
1339
|
}): AsyncIterable<StreamsEventOfTypes<T>>;
|
|
1257
1340
|
stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
|
|
1258
1341
|
/**
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1342
|
+
* Get each new event pushed to `onEvent` as it lands.
|
|
1343
|
+
*
|
|
1344
|
+
* Reconnects from the last handled cursor after a transport error, and
|
|
1345
|
+
* verifies each frame's ed25519 signature when the client has `verify` on.
|
|
1346
|
+
* Returns an unsubscribe function whose `done` promise settles when the
|
|
1347
|
+
* loop ends. Not reorg-aware: an event delivered and then orphaned is never
|
|
1348
|
+
* retracted. Durable writers use `events.consume`.
|
|
1349
|
+
*
|
|
1350
|
+
* `chain: "bitcoin"` delivers Runes rows to `onEvent`.
|
|
1265
1351
|
*/
|
|
1266
|
-
/** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
|
|
1267
1352
|
subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
|
|
1268
1353
|
subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
|
|
1269
1354
|
};
|
|
1270
1355
|
blocks: {
|
|
1356
|
+
/**
|
|
1357
|
+
* Read every event in one block, by height or hash.
|
|
1358
|
+
*
|
|
1359
|
+
* Returns the events and the `tip`, with no `next_cursor`.
|
|
1360
|
+
*
|
|
1361
|
+
* `chain: "bitcoin"` returns the Runes events in one Bitcoin block.
|
|
1362
|
+
*/
|
|
1271
1363
|
events(heightOrHash: number | string, opts: {
|
|
1272
1364
|
chain: "bitcoin";
|
|
1273
1365
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1274
1366
|
events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
|
|
1275
1367
|
};
|
|
1276
1368
|
reorgs: {
|
|
1369
|
+
/**
|
|
1370
|
+
* List chain reorgs since a cursor.
|
|
1371
|
+
*
|
|
1372
|
+
* `since` is required. Each reorg gives its `fork_point_height` and the
|
|
1373
|
+
* orphaned range. Page with `next_since`.
|
|
1374
|
+
*
|
|
1375
|
+
* `chain: "bitcoin"` lists Bitcoin reorgs, on their own cursor space.
|
|
1376
|
+
*/
|
|
1277
1377
|
list(params: StreamsReorgsListParams & {
|
|
1278
1378
|
chain: "bitcoin";
|
|
1279
1379
|
}): Promise<StreamsReorgsListEnvelope>;
|
|
@@ -1281,10 +1381,27 @@ type StreamsClient = {
|
|
|
1281
1381
|
};
|
|
1282
1382
|
/** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
|
|
1283
1383
|
dumps: StreamsDumps;
|
|
1384
|
+
/**
|
|
1385
|
+
* Get the canonical block at a height.
|
|
1386
|
+
*
|
|
1387
|
+
* Returns the block hash and, on Stacks, the burn block it anchors to.
|
|
1388
|
+
*
|
|
1389
|
+
* `chain: "bitcoin"` returns the Bitcoin block, without burn-chain fields.
|
|
1390
|
+
*/
|
|
1284
1391
|
canonical(height: number, opts: {
|
|
1285
1392
|
chain: "bitcoin";
|
|
1286
1393
|
}): Promise<StreamsBitcoinCanonicalBlock>;
|
|
1287
1394
|
canonical(height: number): Promise<StreamsCanonicalBlock>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Get the current chain tip.
|
|
1397
|
+
*
|
|
1398
|
+
* Returns the tip height and hash, `finalized_height`, and `lag_seconds`. On
|
|
1399
|
+
* Stacks it also reports the oldest height your tier can seek; older reads
|
|
1400
|
+
* come from the bulk dumps.
|
|
1401
|
+
*
|
|
1402
|
+
* `chain: "bitcoin"` returns the Bitcoin tip, without burn-chain or retention
|
|
1403
|
+
* fields.
|
|
1404
|
+
*/
|
|
1288
1405
|
tip(opts: {
|
|
1289
1406
|
chain: "bitcoin";
|
|
1290
1407
|
}): Promise<StreamsBitcoinTip>;
|
|
@@ -2320,15 +2437,27 @@ type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "curs
|
|
|
2320
2437
|
* events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
|
|
2321
2438
|
interface SbtcResource {
|
|
2322
2439
|
deposits: {
|
|
2323
|
-
/**
|
|
2324
|
-
*
|
|
2440
|
+
/**
|
|
2441
|
+
* Read one page of completed sBTC deposits.
|
|
2442
|
+
*
|
|
2443
|
+
* Filter by `sender`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only deposits past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor` and `block_height` always come back.
|
|
2444
|
+
*/
|
|
2325
2445
|
list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
|
|
2326
2446
|
fields: readonly F[];
|
|
2327
2447
|
}): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
|
|
2328
2448
|
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
|
|
2449
|
+
/**
|
|
2450
|
+
* Iterate every completed sBTC deposit, paging for you.
|
|
2451
|
+
*
|
|
2452
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2453
|
+
*/
|
|
2329
2454
|
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
|
|
2330
|
-
/**
|
|
2331
|
-
*
|
|
2455
|
+
/**
|
|
2456
|
+
* Run a checkpointed, reorg-aware indexer over completed deposits.
|
|
2457
|
+
*
|
|
2458
|
+
* Deposits are append-only, so they are safe to mirror. See
|
|
2459
|
+
* {@link IndexConsumeOptions}.
|
|
2460
|
+
*/
|
|
2332
2461
|
consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
|
|
2333
2462
|
sink?: ConsumerSink<TTx>;
|
|
2334
2463
|
}): Promise<{
|
|
@@ -2340,21 +2469,43 @@ interface SbtcResource {
|
|
|
2340
2469
|
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
|
|
2341
2470
|
};
|
|
2342
2471
|
withdrawals: {
|
|
2343
|
-
/**
|
|
2344
|
-
*
|
|
2472
|
+
/**
|
|
2473
|
+
* Read one page of sBTC withdrawals, each with its current status.
|
|
2474
|
+
*
|
|
2475
|
+
* Filter by `status` (`REQUESTED`, `ACCEPTED`, `REJECTED`), `sender`, `requestId`, `settlementConfirmed`, and a height range. A row changes as the peg-out moves along, which is why withdrawals have no `consume`. `fields` returns only those columns and narrows the row type; `cursor` and `request_id` always come back.
|
|
2476
|
+
*/
|
|
2345
2477
|
list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
|
|
2346
2478
|
fields: readonly F[];
|
|
2347
2479
|
}): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
|
|
2348
2480
|
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
|
|
2481
|
+
/**
|
|
2482
|
+
* Iterate every sBTC withdrawal, paging for you.
|
|
2483
|
+
*
|
|
2484
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2485
|
+
*/
|
|
2349
2486
|
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
|
|
2350
2487
|
/** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
|
|
2351
2488
|
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
|
|
2352
2489
|
};
|
|
2353
2490
|
events: {
|
|
2491
|
+
/**
|
|
2492
|
+
* Read one page of the raw sBTC peg event log.
|
|
2493
|
+
*
|
|
2494
|
+
* Filter by `topic`, `sender`, `requestId`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only events past the finality boundary.
|
|
2495
|
+
*/
|
|
2354
2496
|
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
|
|
2497
|
+
/**
|
|
2498
|
+
* Iterate every sBTC peg event, paging for you.
|
|
2499
|
+
*
|
|
2500
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2501
|
+
*/
|
|
2355
2502
|
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
|
|
2356
|
-
/**
|
|
2357
|
-
*
|
|
2503
|
+
/**
|
|
2504
|
+
* Run a checkpointed, reorg-aware indexer over the raw peg event log.
|
|
2505
|
+
*
|
|
2506
|
+
* The log is append-only across all six topics. See
|
|
2507
|
+
* {@link IndexConsumeOptions}.
|
|
2508
|
+
*/
|
|
2358
2509
|
consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
|
|
2359
2510
|
sink?: ConsumerSink<TTx>;
|
|
2360
2511
|
}): Promise<{
|
|
@@ -2363,7 +2514,11 @@ interface SbtcResource {
|
|
|
2363
2514
|
emptyPolls: number;
|
|
2364
2515
|
}>;
|
|
2365
2516
|
};
|
|
2366
|
-
/**
|
|
2517
|
+
/**
|
|
2518
|
+
* Get the all-time sBTC peg scoreboard.
|
|
2519
|
+
*
|
|
2520
|
+
* A single aggregate, with no pagination.
|
|
2521
|
+
*/
|
|
2367
2522
|
summary(): Promise<SbtcSummaryEnvelope>;
|
|
2368
2523
|
}
|
|
2369
2524
|
/** One pox-5 reward cycle, exact to the node. */
|
|
@@ -2444,10 +2599,24 @@ type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & WalkOptions;
|
|
|
2444
2599
|
/** `index.pox` — reward cycles of the current PoX (PoX-5). */
|
|
2445
2600
|
interface PoxResource {
|
|
2446
2601
|
cycles: {
|
|
2602
|
+
/**
|
|
2603
|
+
* Read one page of PoX reward cycles, newest first.
|
|
2604
|
+
*
|
|
2605
|
+
* `cursor` is a `reward_cycle` number, and the page returns the cycles below it. `next_cursor` is the next cycle number to page from, or `null` at the end. This reports the current PoX (PoX-5); PoX-4 history is not served here, so read `stacking` for it.
|
|
2606
|
+
*/
|
|
2447
2607
|
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
|
|
2608
|
+
/**
|
|
2609
|
+
* Iterate every reward cycle, paging for you.
|
|
2610
|
+
*
|
|
2611
|
+
* Takes the same filters as `list` (it pages by reward cycle number). Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2612
|
+
*/
|
|
2448
2613
|
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
|
|
2449
|
-
/**
|
|
2450
|
-
*
|
|
2614
|
+
/**
|
|
2615
|
+
* Get one reward cycle by number, or `null`.
|
|
2616
|
+
*
|
|
2617
|
+
* Resolves to `null` on 404: an unknown cycle, or one below pox-5's first
|
|
2618
|
+
* reward cycle (141), whose PoX-4 history is final and not served here.
|
|
2619
|
+
*/
|
|
2451
2620
|
get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
|
|
2452
2621
|
};
|
|
2453
2622
|
}
|
|
@@ -2522,15 +2691,27 @@ type Pox5EventsConsumeParams<TTx = never> = Omit<Pox5EventsListParams, "cursor"
|
|
|
2522
2691
|
* epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
|
|
2523
2692
|
interface Pox5Resource {
|
|
2524
2693
|
events: {
|
|
2525
|
-
/**
|
|
2526
|
-
*
|
|
2694
|
+
/**
|
|
2695
|
+
* Read one page of decoded PoX-5 staking events.
|
|
2696
|
+
*
|
|
2697
|
+
* Filter by `topic`, `staker`, `signer`, `signerManager`, `bondIndex`, `rewardCycle`, and a height range. `confirmed: true` keeps only rows past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `topic` always come back.
|
|
2698
|
+
*/
|
|
2527
2699
|
list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
|
|
2528
2700
|
fields: readonly F[];
|
|
2529
2701
|
}): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
|
|
2530
2702
|
list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
|
|
2703
|
+
/**
|
|
2704
|
+
* Iterate every PoX-5 event, paging for you.
|
|
2705
|
+
*
|
|
2706
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2707
|
+
*/
|
|
2531
2708
|
walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
|
|
2532
|
-
/**
|
|
2533
|
-
*
|
|
2709
|
+
/**
|
|
2710
|
+
* Run a checkpointed, reorg-aware indexer over PoX-5 events.
|
|
2711
|
+
*
|
|
2712
|
+
* The pox-5 print log is append-only across all 19 topics. See
|
|
2713
|
+
* {@link IndexConsumeOptions}.
|
|
2714
|
+
*/
|
|
2534
2715
|
consume<TTx = never>(params: Pox5EventsConsumeParams<TTx> & {
|
|
2535
2716
|
sink?: ConsumerSink<TTx>;
|
|
2536
2717
|
}): Promise<{
|
|
@@ -2708,14 +2889,28 @@ interface RunesResource {
|
|
|
2708
2889
|
/** The rune catalog. `search` prefix-matches the name; `sort` is etch
|
|
2709
2890
|
* order (default) or busiest-first. */
|
|
2710
2891
|
list(params?: RunesListParams): Promise<RunesEnvelope>;
|
|
2711
|
-
/**
|
|
2712
|
-
*
|
|
2892
|
+
/**
|
|
2893
|
+
* Get one rune by id or name, or `null`.
|
|
2894
|
+
*
|
|
2895
|
+
* Resolves to `null` on 404: no such rune, or Runes isn't configured on
|
|
2896
|
+
* this instance.
|
|
2897
|
+
*/
|
|
2713
2898
|
get(rune: RuneRef): Promise<RuneEnvelope | null>;
|
|
2714
2899
|
/** Current per-outpoint rune balances by address or outpoint. */
|
|
2715
2900
|
balances(params: RuneBalancesListParams): Promise<RuneBalancesEnvelope>;
|
|
2716
2901
|
/** Etch/mint/transfer/burn events, cursor `<block_height>:<event_index>`. */
|
|
2717
2902
|
activity: {
|
|
2903
|
+
/**
|
|
2904
|
+
* Read one page of Rune etch, mint, transfer, and burn events.
|
|
2905
|
+
*
|
|
2906
|
+
* Filter by `rune` (an id or a name), `address`, `kind`, `txid`, and a height range. The cursor is `<block_height>:<event_index>`, and the envelope's tip is a Bitcoin tip. `notes` says so when Runes is not configured on the instance.
|
|
2907
|
+
*/
|
|
2718
2908
|
list(params?: RuneActivityListParams): Promise<RuneActivityEnvelope>;
|
|
2909
|
+
/**
|
|
2910
|
+
* Iterate every Rune event, paging for you.
|
|
2911
|
+
*
|
|
2912
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2913
|
+
*/
|
|
2719
2914
|
walk(params?: RuneActivityWalkParams): AsyncIterable<IndexRuneEvent>;
|
|
2720
2915
|
};
|
|
2721
2916
|
}
|
|
@@ -2733,15 +2928,20 @@ interface FtTransfersResource {
|
|
|
2733
2928
|
fields: readonly F[];
|
|
2734
2929
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2735
2930
|
(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2736
|
-
/**
|
|
2737
|
-
*
|
|
2931
|
+
/**
|
|
2932
|
+
* Read one page of fungible-token transfers, plus the cursor for the next.
|
|
2933
|
+
*
|
|
2934
|
+
* Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Filters are equality only: there is no amount filter. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back. `reorgs` on the envelope lists forks that overlap the page.
|
|
2935
|
+
*/
|
|
2738
2936
|
list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
|
|
2739
2937
|
fields: readonly F[];
|
|
2740
2938
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2741
2939
|
list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2742
|
-
/**
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2940
|
+
/**
|
|
2941
|
+
* Iterate every fungible-token transfer, paging for you.
|
|
2942
|
+
*
|
|
2943
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2944
|
+
*/
|
|
2745
2945
|
walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
|
|
2746
2946
|
fields: readonly F[];
|
|
2747
2947
|
}): AsyncIterable<FtTransferFields<F>>;
|
|
@@ -2755,13 +2955,20 @@ interface NftTransfersResource {
|
|
|
2755
2955
|
fields: readonly F[];
|
|
2756
2956
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2757
2957
|
(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2758
|
-
/**
|
|
2759
|
-
*
|
|
2958
|
+
/**
|
|
2959
|
+
* Read one page of NFT transfers, plus the cursor for the next.
|
|
2960
|
+
*
|
|
2961
|
+
* Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back.
|
|
2962
|
+
*/
|
|
2760
2963
|
list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
|
|
2761
2964
|
fields: readonly F[];
|
|
2762
2965
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2763
2966
|
list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2764
|
-
/**
|
|
2967
|
+
/**
|
|
2968
|
+
* Iterate every NFT transfer, paging for you.
|
|
2969
|
+
*
|
|
2970
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2971
|
+
*/
|
|
2765
2972
|
walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
|
|
2766
2973
|
fields: readonly F[];
|
|
2767
2974
|
}): AsyncIterable<NftTransferFields<F>>;
|
|
@@ -2778,9 +2985,11 @@ interface IndexEventsResource {
|
|
|
2778
2985
|
fields: readonly F[];
|
|
2779
2986
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2780
2987
|
<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2781
|
-
/**
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
2988
|
+
/**
|
|
2989
|
+
* Read one page of decoded events of one type.
|
|
2990
|
+
*
|
|
2991
|
+
* `eventType` is required: a decoded type (`ft_transfer`, `print`, ...) or a VM type (`nested_contract_call`, `map_set`, ...), and a literal narrows the row type. Scope with `contractId` (one id or up to 20) or `trait`, never both, plus `assetIdentifier`, `sender`, `recipient`, `functionName`, `caller`, `map`, `varName`, `txId`, and a height range. `txContext: true` joins the submitting transaction onto each event. `fields` returns only those columns and narrows the row type; it saves wire bytes but does not change what you are billed, since rows are metered, not columns.
|
|
2992
|
+
*/
|
|
2784
2993
|
list<
|
|
2785
2994
|
T extends IndexEventType,
|
|
2786
2995
|
const F extends keyof IndexEventOf<T> & string
|
|
@@ -2788,9 +2997,11 @@ interface IndexEventsResource {
|
|
|
2788
2997
|
fields: readonly F[];
|
|
2789
2998
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2790
2999
|
list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2791
|
-
/**
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
3000
|
+
/**
|
|
3001
|
+
* Iterate every decoded event of one type, paging for you.
|
|
3002
|
+
*
|
|
3003
|
+
* Takes the same filters as `list`, including `eventType`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3004
|
+
*/
|
|
2794
3005
|
walk<
|
|
2795
3006
|
T extends IndexEventType,
|
|
2796
3007
|
const F extends keyof IndexEventOf<T> & string
|
|
@@ -2798,6 +3009,11 @@ interface IndexEventsResource {
|
|
|
2798
3009
|
fields: readonly F[];
|
|
2799
3010
|
}): AsyncIterable<IndexEventFields<T, F>>;
|
|
2800
3011
|
walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
|
|
3012
|
+
/**
|
|
3013
|
+
* Run a checkpointed, reorg-aware indexer over decoded events.
|
|
3014
|
+
*
|
|
3015
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`.
|
|
3016
|
+
*/
|
|
2801
3017
|
consume<
|
|
2802
3018
|
T extends IndexEventType,
|
|
2803
3019
|
TTx = never
|
|
@@ -2826,15 +3042,19 @@ type IndexDiscovery = {
|
|
|
2826
3042
|
declare class Index extends BaseClient {
|
|
2827
3043
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
2828
3044
|
/**
|
|
2829
|
-
*
|
|
2830
|
-
*
|
|
2831
|
-
*
|
|
3045
|
+
* Get the live vocabulary of what Index can query.
|
|
3046
|
+
*
|
|
3047
|
+
* The discovery doc lists every endpoint and each event type's columns,
|
|
3048
|
+
* allowed and equality filters, and required-non-null fields. Read it to
|
|
3049
|
+
* learn what's queryable (and which types accept `trait`) instead of
|
|
3050
|
+
* hardcoding.
|
|
2832
3051
|
*/
|
|
2833
3052
|
discover(): Promise<IndexDiscovery>;
|
|
2834
3053
|
/**
|
|
2835
|
-
*
|
|
2836
|
-
*
|
|
2837
|
-
*
|
|
3054
|
+
* Get the print payload schema a contract actually emits.
|
|
3055
|
+
*
|
|
3056
|
+
* Lists the topics it emits and each field's observed Clarity, TS, and
|
|
3057
|
+
* column types. Anonymous read; resolves to `null` on 404.
|
|
2838
3058
|
*/
|
|
2839
3059
|
printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
|
|
2840
3060
|
/** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
|
|
@@ -2845,8 +3065,23 @@ declare class Index extends BaseClient {
|
|
|
2845
3065
|
* Callable: `index.events(params)` ≡ `index.events.list(params)`. */
|
|
2846
3066
|
readonly events: IndexEventsResource;
|
|
2847
3067
|
readonly contractCalls: {
|
|
3068
|
+
/**
|
|
3069
|
+
* Read one page of decoded contract calls.
|
|
3070
|
+
*
|
|
3071
|
+
* Filter by `contractId` (one id or up to 20) or `trait`, never both, plus `functionName`, `sender`, and a height range. Each row has the function name, arguments, result, and status. Pass `next_cursor` back as `cursor` to continue.
|
|
3072
|
+
*/
|
|
2848
3073
|
list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
|
|
3074
|
+
/**
|
|
3075
|
+
* Iterate every decoded contract call, paging for you.
|
|
3076
|
+
*
|
|
3077
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3078
|
+
*/
|
|
2849
3079
|
walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
|
|
3080
|
+
/**
|
|
3081
|
+
* Run a checkpointed, reorg-aware indexer over contract calls.
|
|
3082
|
+
*
|
|
3083
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`. Calls already carry `sender` and `function_name`, so there is no `txContext`.
|
|
3084
|
+
*/
|
|
2850
3085
|
consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
|
|
2851
3086
|
sink?: ConsumerSink<TTx>;
|
|
2852
3087
|
}) => Promise<{
|
|
@@ -2857,49 +3092,125 @@ declare class Index extends BaseClient {
|
|
|
2857
3092
|
};
|
|
2858
3093
|
/** Canonical block-hash map — sync only the current canonical chain. */
|
|
2859
3094
|
readonly canonical: {
|
|
3095
|
+
/**
|
|
3096
|
+
* Read one page of the canonical block-hash map.
|
|
3097
|
+
*
|
|
3098
|
+
* Each row is a block's hash, its parent hash, and its burn-chain anchor. Compare it with your own tables to confirm you follow the current chain.
|
|
3099
|
+
*/
|
|
2860
3100
|
list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
|
|
3101
|
+
/**
|
|
3102
|
+
* Iterate every canonical block hash, paging for you.
|
|
3103
|
+
*
|
|
3104
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3105
|
+
*/
|
|
2861
3106
|
walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
|
|
2862
3107
|
};
|
|
2863
3108
|
/** Exact MARF writes per canonical block (`/v1/index/state-writes`). */
|
|
2864
3109
|
readonly stateWrites: {
|
|
3110
|
+
/**
|
|
3111
|
+
* Read one page of the contract-state writes each block committed.
|
|
3112
|
+
*
|
|
3113
|
+
* Rows are the exact key and value writes, in the node's write order (`ordinal`), so you can see which key a transaction changed when events alone do not show it. Filter by `blockHeight` (excludes `fromHeight` and `toHeight`) or `contractId`. `txContext: true` joins the writing transaction. Rows exist only from the height your node first subscribed to state writes.
|
|
3114
|
+
*/
|
|
2865
3115
|
list: (params?: StateWritesListParams) => Promise<StateWritesEnvelope>;
|
|
3116
|
+
/**
|
|
3117
|
+
* Iterate every state write, paging for you.
|
|
3118
|
+
*
|
|
3119
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3120
|
+
*/
|
|
2866
3121
|
walk: (params?: StateWritesWalkParams) => AsyncIterable<IndexStateWrite>;
|
|
2867
3122
|
};
|
|
2868
3123
|
/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
|
|
2869
3124
|
* (resolves to null on 404). */
|
|
2870
3125
|
readonly blocks: {
|
|
3126
|
+
/**
|
|
3127
|
+
* Read one page of canonical blocks.
|
|
3128
|
+
*
|
|
3129
|
+
* Each block has its hash, parent hash, burn-chain anchor, and `block_time`. Filter by a height range.
|
|
3130
|
+
*/
|
|
2871
3131
|
list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
|
|
3132
|
+
/**
|
|
3133
|
+
* Iterate every canonical block, paging for you.
|
|
3134
|
+
*
|
|
3135
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3136
|
+
*/
|
|
2872
3137
|
walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
|
|
3138
|
+
/**
|
|
3139
|
+
* Get one block by height or hash, or `null`.
|
|
3140
|
+
*
|
|
3141
|
+
* Resolves to `null` when no such block exists (404).
|
|
3142
|
+
*/
|
|
2873
3143
|
get: (ref: string | number) => Promise<BlockEnvelope | null>;
|
|
2874
3144
|
};
|
|
2875
3145
|
/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
|
|
2876
3146
|
* (resolves to null on 404). */
|
|
2877
3147
|
readonly transactions: {
|
|
2878
|
-
/**
|
|
2879
|
-
*
|
|
2880
|
-
*
|
|
2881
|
-
*
|
|
3148
|
+
/**
|
|
3149
|
+
* Read one page of full transaction documents.
|
|
3150
|
+
*
|
|
3151
|
+
* Filter by `type`, `sender`, `contractId`, and a height range. Each document has the decoded post conditions and the payload for its `tx_type`; enrichment fields are null when the raw transaction cannot be decoded. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `tx_id` always come back.
|
|
3152
|
+
*/
|
|
2882
3153
|
list: {
|
|
2883
3154
|
<const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
|
|
2884
3155
|
fields: readonly F[];
|
|
2885
3156
|
}): Promise<TransactionsEnvelope<TransactionFields<F>>>;
|
|
2886
3157
|
(params?: TransactionsListParams): Promise<TransactionsEnvelope>;
|
|
2887
3158
|
};
|
|
3159
|
+
/**
|
|
3160
|
+
* Iterate every transaction document, paging for you.
|
|
3161
|
+
*
|
|
3162
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3163
|
+
*/
|
|
2888
3164
|
walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
|
|
3165
|
+
/**
|
|
3166
|
+
* Get one transaction by id, or `null`.
|
|
3167
|
+
*
|
|
3168
|
+
* Resolves to `null` when the transaction is not found (404).
|
|
3169
|
+
*/
|
|
2889
3170
|
get: (txId: string) => Promise<TransactionEnvelope | null>;
|
|
3171
|
+
/**
|
|
3172
|
+
* Get a transaction's inclusion proof, or `null`.
|
|
3173
|
+
*
|
|
3174
|
+
* The proof is the raw transaction, the Nakamoto block header, and the merkle path. Check it yourself with `verifyTransactionProof`; nothing in it needs to be trusted. Resolves to `null` on 404. A 503 (`PROOF_TX_SET_INCOMPLETE` or `PROOF_NODE_UNAVAILABLE`) throws an `ApiError`: the proof cannot be assembled on this deployment right now.
|
|
3175
|
+
*/
|
|
2890
3176
|
getProof: (txId: string) => Promise<TransactionProof | null>;
|
|
2891
3177
|
};
|
|
2892
3178
|
/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
|
|
2893
3179
|
* platform's PoX-4 decoder is disabled. */
|
|
2894
3180
|
readonly stacking: {
|
|
3181
|
+
/**
|
|
3182
|
+
* Read one page of decoded PoX-4 stacking actions.
|
|
3183
|
+
*
|
|
3184
|
+
* One row per stacking contract call. Filter by `functionName`, `stacker`, `caller`, and a height range. The feed is empty, with a `notes` hint, when the instance's PoX-4 decoder is disabled. For the current PoX, use `pox5.events` and `pox.cycles`.
|
|
3185
|
+
*/
|
|
2895
3186
|
list: (params?: StackingListParams) => Promise<StackingEnvelope>;
|
|
3187
|
+
/**
|
|
3188
|
+
* Iterate every PoX-4 stacking action, paging for you.
|
|
3189
|
+
*
|
|
3190
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3191
|
+
*/
|
|
2896
3192
|
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
|
|
2897
3193
|
};
|
|
2898
3194
|
/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
|
|
2899
3195
|
* tx_id (resolves to null when the tx has confirmed or dropped). */
|
|
2900
3196
|
readonly mempool: {
|
|
3197
|
+
/**
|
|
3198
|
+
* Read one page of pending, unconfirmed transactions.
|
|
3199
|
+
*
|
|
3200
|
+
* Filter by `sender`, `type`, `contractId`, and `functionName`. There is no height filter: rows carry `received_at` and a sequence cursor instead of a block position.
|
|
3201
|
+
*/
|
|
2901
3202
|
list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
|
|
3203
|
+
/**
|
|
3204
|
+
* Iterate every pending transaction, paging for you.
|
|
3205
|
+
*
|
|
3206
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3207
|
+
*/
|
|
2902
3208
|
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
|
|
3209
|
+
/**
|
|
3210
|
+
* Get one pending transaction, or `null`.
|
|
3211
|
+
*
|
|
3212
|
+
* Resolves to `null` once the transaction has confirmed or dropped.
|
|
3213
|
+
*/
|
|
2903
3214
|
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
|
|
2904
3215
|
};
|
|
2905
3216
|
/** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
|
|
@@ -3030,26 +3341,54 @@ interface BundleSubgraphResponse {
|
|
|
3030
3341
|
bundleSize: number;
|
|
3031
3342
|
}
|
|
3032
3343
|
declare class Subgraphs extends BaseClient {
|
|
3344
|
+
/**
|
|
3345
|
+
* List the subgraphs deployed to this instance.
|
|
3346
|
+
*
|
|
3347
|
+
* Each summary has the status, the last processed block against the chain tip, progress, `gapCount`, and an `integrity` flag.
|
|
3348
|
+
*/
|
|
3033
3349
|
list(): Promise<{
|
|
3034
3350
|
data: SubgraphSummary[];
|
|
3035
3351
|
}>;
|
|
3036
3352
|
/**
|
|
3037
|
-
*
|
|
3038
|
-
*
|
|
3039
|
-
*
|
|
3353
|
+
* Get a subgraph's health, sync position, and tables.
|
|
3354
|
+
*
|
|
3355
|
+
* The verify step after a deploy, reindex, or backfill: poll it until
|
|
3356
|
+
* `sync` catches the tip.
|
|
3040
3357
|
*/
|
|
3041
3358
|
status(name: string): Promise<SubgraphDetail>;
|
|
3359
|
+
/**
|
|
3360
|
+
* Get a subgraph's OpenAPI spec.
|
|
3361
|
+
*
|
|
3362
|
+
* Describes the REST routes generated for each table. Pass `serverUrl` to set the server the spec advertises.
|
|
3363
|
+
*/
|
|
3042
3364
|
openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
|
|
3365
|
+
/**
|
|
3366
|
+
* Get a subgraph's schema as JSON, shaped for agents.
|
|
3367
|
+
*
|
|
3368
|
+
* Per table: the endpoints, columns, indexes, which fields are sortable, selectable, searchable, or filterable, and a ready example query. Pass `serverUrl` to set the server the endpoints use.
|
|
3369
|
+
*/
|
|
3043
3370
|
schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
|
|
3371
|
+
/**
|
|
3372
|
+
* Get a subgraph's generated API docs as Markdown text.
|
|
3373
|
+
*
|
|
3374
|
+
* Pass `serverUrl` to set the server the examples use.
|
|
3375
|
+
*/
|
|
3044
3376
|
markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
|
|
3045
3377
|
/**
|
|
3046
|
-
*
|
|
3378
|
+
* Rebuild a subgraph from scratch.
|
|
3379
|
+
*
|
|
3380
|
+
* A reindex always drops and rebuilds the whole subgraph, so it takes no
|
|
3047
3381
|
* block range; the API rejects one with `REINDEX_RANGE_NOT_SUPPORTED`.
|
|
3048
3382
|
* Use {@link backfill} to process a specific range. While a reindex or
|
|
3049
3383
|
* backfill is already running the API answers 409 with code
|
|
3050
3384
|
* `OPERATION_IN_PROGRESS`; poll {@link operations} until it finishes.
|
|
3051
3385
|
*/
|
|
3052
3386
|
reindex(name: string): Promise<ReindexResponse>;
|
|
3387
|
+
/**
|
|
3388
|
+
* Stop a running reindex or backfill.
|
|
3389
|
+
*
|
|
3390
|
+
* Requests the cancel and resolves with the `operationId` and a `cancel_requested` status. Poll {@link getOperation} until `status` is terminal. Throws a 404 with code `NO_OPERATION` when nothing is running.
|
|
3391
|
+
*/
|
|
3053
3392
|
stop(name: string): Promise<{
|
|
3054
3393
|
message: string;
|
|
3055
3394
|
operationId?: string;
|
|
@@ -3061,19 +3400,31 @@ declare class Subgraphs extends BaseClient {
|
|
|
3061
3400
|
fromBlock: number;
|
|
3062
3401
|
toBlock: number;
|
|
3063
3402
|
}): Promise<ReindexResponse>;
|
|
3403
|
+
/**
|
|
3404
|
+
* List the block ranges a subgraph is missing.
|
|
3405
|
+
*
|
|
3406
|
+
* Each gap has its `start`, `end`, `size`, `reason`, and when it was detected and resolved. `resolved` filters to resolved or open gaps; page with `limit` and `offset`. `meta` reports the total gap count and total missing blocks.
|
|
3407
|
+
*/
|
|
3064
3408
|
gaps(name: string, opts?: {
|
|
3065
3409
|
limit?: number;
|
|
3066
3410
|
offset?: number;
|
|
3067
3411
|
resolved?: boolean;
|
|
3068
3412
|
}): Promise<SubgraphGapsResponse>;
|
|
3413
|
+
/**
|
|
3414
|
+
* Delete a subgraph and its tables.
|
|
3415
|
+
*
|
|
3416
|
+
* Permanent. The API cancels any running reindex or backfill first, waits up to 5 seconds for it to stop, then drops the subgraph's tables and registry entry. `force: true` is sent as `?force=true`.
|
|
3417
|
+
*/
|
|
3069
3418
|
delete(name: string, options?: {
|
|
3070
3419
|
force?: boolean;
|
|
3071
3420
|
}): Promise<{
|
|
3072
3421
|
message: string;
|
|
3073
3422
|
}>;
|
|
3074
3423
|
/**
|
|
3075
|
-
*
|
|
3076
|
-
*
|
|
3424
|
+
* Read a table's rows, one cursor page at a time.
|
|
3425
|
+
*
|
|
3426
|
+
* Anon works on an open instance; pass an apiKey on the client where reads
|
|
3427
|
+
* are closed. `next_cursor` is set
|
|
3077
3428
|
* on every page that returned rows and is `null` only on an empty page, so a
|
|
3078
3429
|
* poller tails with `cursor = page.next_cursor ?? cursor`. A paging loop
|
|
3079
3430
|
* ends on an empty page (or one shorter than `limit`).
|
|
@@ -3085,13 +3436,20 @@ declare class Subgraphs extends BaseClient {
|
|
|
3085
3436
|
operations(name: string): Promise<{
|
|
3086
3437
|
operations: SubgraphOperationStatus[];
|
|
3087
3438
|
}>;
|
|
3088
|
-
/**
|
|
3089
|
-
*
|
|
3439
|
+
/** Get the status of one reindex, backfill, or stop operation.
|
|
3440
|
+
*
|
|
3441
|
+
* Poll the `operationId` returned by `reindex`, `backfill`, or `stop`
|
|
3442
|
+
* until `status` is terminal. */
|
|
3090
3443
|
getOperation(name: string, operationId: string): Promise<SubgraphOperationStatus>;
|
|
3091
3444
|
/** Create or update a subgraph. A deploy that needs a rebuild queues one;
|
|
3092
3445
|
* if a reindex or backfill is already running the API answers 409 with
|
|
3093
3446
|
* code `OPERATION_IN_PROGRESS` (an `ApiError`, not a dedicated class). */
|
|
3094
3447
|
deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse>;
|
|
3448
|
+
/**
|
|
3449
|
+
* Get a deployed subgraph's source.
|
|
3450
|
+
*
|
|
3451
|
+
* Returns `sourceCode`, the bundled `handlerCode` the runtime executes, and the `pin` hash of what you deployed. `handlerCode` and `pin` are `null` for local deploys. A subgraph deployed before source was captured returns `sourceCode: null` and `readOnly: true` with a `reason`; redeploy it to capture the source.
|
|
3452
|
+
*/
|
|
3095
3453
|
getSource(name: string): Promise<SubgraphSource>;
|
|
3096
3454
|
/**
|
|
3097
3455
|
* Bundle a TypeScript subgraph source on the server. Used by the web chat
|
|
@@ -3100,13 +3458,15 @@ declare class Subgraphs extends BaseClient {
|
|
|
3100
3458
|
bundle(data: {
|
|
3101
3459
|
code: string;
|
|
3102
3460
|
}): Promise<BundleSubgraphResponse>;
|
|
3103
|
-
/**
|
|
3104
|
-
*
|
|
3461
|
+
/** Count the rows in a table that match a filter.
|
|
3462
|
+
*
|
|
3463
|
+
* The count is exact. Same auth posture as {@link rows}. */
|
|
3105
3464
|
count(name: string, table: string, params?: Pick<SubgraphQueryParams, "filters">): Promise<{
|
|
3106
3465
|
count: number;
|
|
3107
3466
|
}>;
|
|
3108
|
-
/**
|
|
3109
|
-
*
|
|
3467
|
+
/** Compute scalar aggregates over a table's matching rows.
|
|
3468
|
+
*
|
|
3469
|
+
* Same auth posture as {@link rows}. */
|
|
3110
3470
|
aggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
|
|
3111
3471
|
/**
|
|
3112
3472
|
* Returns a typed client for a subgraph defined with `defineSubgraph()`.
|
|
@@ -3139,37 +3499,93 @@ import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, Repl
|
|
|
3139
3499
|
import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookActivity as WebhookActivity2, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail as WebhookDeliveryDetail2, WebhookDetail as WebhookDetail2, WebhookFormat, WebhookKind, WebhookStatus, WebhookSummary as WebhookSummary2, WebhookTestResult as WebhookTestResult2, UpdateWebhookRequest as UpdateWebhookRequest2 } from "@secondlayer/shared/schemas/webhooks";
|
|
3140
3500
|
import { trigger } from "@secondlayer/shared/schemas/webhooks";
|
|
3141
3501
|
declare class Webhooks extends BaseClient {
|
|
3502
|
+
/**
|
|
3503
|
+
* List your webhooks.
|
|
3504
|
+
*
|
|
3505
|
+
* Each summary has the status, format, URL, last delivery and last success, and the circuit breaker state (`circuitFailures`, `circuitOpenedAt`).
|
|
3506
|
+
*/
|
|
3142
3507
|
list(): Promise<{
|
|
3143
3508
|
data: WebhookSummary[];
|
|
3144
3509
|
}>;
|
|
3510
|
+
/**
|
|
3511
|
+
* Get one webhook's full configuration.
|
|
3512
|
+
*
|
|
3513
|
+
* Adds the triggers, the receiver's auth (redacted to header names and whether a secret is set), the retry and timeout limits, `lastError`, and a `warning` when this instance's trigger evaluator is not running.
|
|
3514
|
+
*/
|
|
3145
3515
|
get(id: string): Promise<WebhookDetail>;
|
|
3516
|
+
/**
|
|
3517
|
+
* Create a webhook that POSTs chain events to your URL.
|
|
3518
|
+
*
|
|
3519
|
+
* Takes a `name`, a `url`, and `triggers` built with `trigger.*`; each trigger is validated before anything is provisioned, and an invalid one is a 400. The signing secret comes back once in `signingSecret`, so store it. A webhook starts at the chain tip and never backfills: use {@link replay} for history. Hosted accounts cap `maxRetries` at 7 and `timeoutMs` at 30000.
|
|
3520
|
+
*/
|
|
3146
3521
|
create(input: CreateWebhookRequest): Promise<CreateWebhookResponse>;
|
|
3522
|
+
/**
|
|
3523
|
+
* Change a webhook's name, URL, format, auth, or delivery limits.
|
|
3524
|
+
*
|
|
3525
|
+
* Send only the fields to change: `name`, `url`, `format`, `authConfig`, `maxRetries`, `timeoutMs`, `concurrency`. Triggers are not part of an update. Resolves to the updated webhook.
|
|
3526
|
+
*/
|
|
3147
3527
|
update(id: string, patch: UpdateWebhookRequest): Promise<WebhookDetail>;
|
|
3528
|
+
/**
|
|
3529
|
+
* Stop deliveries without deleting the webhook.
|
|
3530
|
+
*
|
|
3531
|
+
* Resolves to the updated webhook. {@link resume} turns it back on.
|
|
3532
|
+
*/
|
|
3148
3533
|
pause(id: string): Promise<WebhookDetail>;
|
|
3534
|
+
/**
|
|
3535
|
+
* Start delivering again after a pause.
|
|
3536
|
+
*
|
|
3537
|
+
* Also clears a circuit-breaker pause, which happens after 20 straight failed deliveries. Resolves to the updated webhook.
|
|
3538
|
+
*/
|
|
3149
3539
|
resume(id: string): Promise<WebhookDetail>;
|
|
3540
|
+
/**
|
|
3541
|
+
* Delete a webhook.
|
|
3542
|
+
*
|
|
3543
|
+
* Resolves to `{ ok: true }`. Throws a 404 when the webhook does not exist.
|
|
3544
|
+
*/
|
|
3150
3545
|
delete(id: string): Promise<{
|
|
3151
3546
|
ok: true;
|
|
3152
3547
|
}>;
|
|
3548
|
+
/**
|
|
3549
|
+
* Issue a new signing secret.
|
|
3550
|
+
*
|
|
3551
|
+
* The new secret comes back once in `signingSecret`. Update the receiver that calls `verifyWebhookSignature` with it: deliveries are signed with the new secret from now on.
|
|
3552
|
+
*/
|
|
3153
3553
|
rotateSecret(id: string): Promise<RotateSecretResponse>;
|
|
3154
|
-
/** Send a one-off test
|
|
3155
|
-
*
|
|
3554
|
+
/** Send a one-off test delivery to a webhook's URL.
|
|
3555
|
+
*
|
|
3556
|
+
* Built for the webhook's format and SSRF-guarded. Logged as a delivery
|
|
3557
|
+
* row, visible via `deliveries`. */
|
|
3156
3558
|
test(id: string): Promise<WebhookTestResult>;
|
|
3157
3559
|
/** The last 100 delivery attempts, newest first. The server caps the window;
|
|
3158
3560
|
* there is nothing to page. */
|
|
3159
3561
|
deliveries(id: string): Promise<{
|
|
3160
3562
|
data: DeliveryRow[];
|
|
3161
3563
|
}>;
|
|
3162
|
-
/**
|
|
3163
|
-
*
|
|
3564
|
+
/** Get a webhook's hourly delivery counts for the last 7 days.
|
|
3565
|
+
*
|
|
3566
|
+
* Each hour has delivered, waiting, and gave-up counts, plus the current
|
|
3567
|
+
* queue depth. This is the events chart on the detail page. */
|
|
3164
3568
|
activity(id: string): Promise<WebhookActivity>;
|
|
3165
|
-
/**
|
|
3166
|
-
*
|
|
3569
|
+
/** Get one delivery attempt with its payload and response.
|
|
3570
|
+
*
|
|
3571
|
+
* Includes the outbox context (payload, response headers). This is the
|
|
3572
|
+
* delivery card on the detail page. */
|
|
3167
3573
|
delivery(id: string, deliveryId: string): Promise<WebhookDeliveryDetail>;
|
|
3574
|
+
/**
|
|
3575
|
+
* Re-deliver historical events over an existing webhook.
|
|
3576
|
+
*
|
|
3577
|
+
* Pass `fromBlock` and `toBlock`; the range is capped at 100,000 blocks. A replay is historical only and never moves the live cursor. It is idempotent: the same range twice is a no-op, so pass any string as `force` to re-deliver it. Replays carry `is_replay` and use the standard `chain.{type}.apply` envelope. Resolves to `replayId`, `enqueuedCount`, and `scannedCount`. A second replay while one is running is a 409. `sbtc_withdrawal_swept_confirmed` is forward-only and never replayed. Hosted accounts get 5 replays an hour.
|
|
3578
|
+
*/
|
|
3168
3579
|
replay(id: string, range: {
|
|
3169
3580
|
fromBlock: number;
|
|
3170
3581
|
toBlock: number;
|
|
3171
3582
|
force?: string;
|
|
3172
3583
|
}): Promise<ReplayResult>;
|
|
3584
|
+
/**
|
|
3585
|
+
* List the events a webhook gave up delivering.
|
|
3586
|
+
*
|
|
3587
|
+
* Returns up to 100 dead-lettered events, newest failure first. Each row's `id` is what {@link requeue} takes.
|
|
3588
|
+
*/
|
|
3173
3589
|
dead(id: string): Promise<{
|
|
3174
3590
|
data: DeadRow[];
|
|
3175
3591
|
}>;
|
|
@@ -3243,8 +3659,12 @@ declare class SecondLayer extends BaseClient {
|
|
|
3243
3659
|
readonly instance: InstanceClient;
|
|
3244
3660
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
3245
3661
|
/**
|
|
3246
|
-
*
|
|
3247
|
-
*
|
|
3662
|
+
* Run up to 10 public reads in one round trip (`POST /v1/batch`).
|
|
3663
|
+
*
|
|
3664
|
+
* Each item is authorized on its own; the client's bearer token applies to
|
|
3665
|
+
* every item. Results come back in order as `{ path, status, body }`. Only
|
|
3666
|
+
* paths under `/v1/index/`, `/v1/subgraphs`, `/v1/streams/`, and
|
|
3667
|
+
* `/v1/contracts` are allowed; anything else is a per-item 400.
|
|
3248
3668
|
*/
|
|
3249
3669
|
batch(requests: Array<{
|
|
3250
3670
|
path: string;
|
|
@@ -3257,10 +3677,12 @@ declare class SecondLayer extends BaseClient {
|
|
|
3257
3677
|
}>;
|
|
3258
3678
|
}>;
|
|
3259
3679
|
/**
|
|
3260
|
-
*
|
|
3261
|
-
*
|
|
3262
|
-
*
|
|
3263
|
-
*
|
|
3680
|
+
* Get a one-call snapshot of your account and instance.
|
|
3681
|
+
*
|
|
3682
|
+
* Returns a {@link ContextSnapshot}: the same orientation an MCP agent reads
|
|
3683
|
+
* from `secondlayer://context`, available to any SDK or CLI consumer. Reads
|
|
3684
|
+
* run concurrently; a failed read lands as `{ value: null, error }` on its
|
|
3685
|
+
* field rather than rejecting the whole snapshot.
|
|
3264
3686
|
*/
|
|
3265
3687
|
context(): Promise<ContextSnapshot>;
|
|
3266
3688
|
}
|
|
@@ -3291,7 +3713,7 @@ import { DeadRow as DeadRow3, DeliveryRow as DeliveryRow3, WebhookDetail as Webh
|
|
|
3291
3713
|
* dashboard's webhook detail page. Moved out of the CLI (unchanged behavior)
|
|
3292
3714
|
* so the web can build the same judgment without printing CLI-command text.
|
|
3293
3715
|
*
|
|
3294
|
-
*
|
|
3716
|
+
* Five deterministic, numbers-only detectors sit on top of the
|
|
3295
3717
|
* existing flag checks: no model, no history beyond the deliveries window
|
|
3296
3718
|
* already fetched. Thresholds are named constants below, conservative on
|
|
3297
3719
|
* purpose — a wrong insight costs more trust than a missed one.
|