@secondlayer/sdk 15.5.1 → 16.0.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/AGENTS.md +1 -1
- package/README.md +6 -6
- package/dist/index.d.ts +7 -16
- package/dist/index.js +8 -56
- package/dist/index.js.map +8 -9
- package/dist/sinks/bun-sqlite.d.ts +1 -1
- package/dist/sinks/bun-sqlite.js.map +1 -1
- package/dist/sinks/drizzle.d.ts +1 -1
- package/dist/sinks/drizzle.js.map +1 -1
- package/dist/sinks/kysely.d.ts +1 -1
- package/dist/sinks/kysely.js.map +1 -1
- package/dist/streams/index.d.ts +6 -13
- package/dist/streams/index.js +6 -55
- package/dist/streams/index.js.map +6 -7
- package/dist/subgraphs/index.d.ts +6 -12
- package/dist/subgraphs/index.js +8 -8
- package/dist/subgraphs/index.js.map +6 -6
- package/package.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -96,7 +96,7 @@ import { kyselySink } from "@secondlayer/sdk/sinks/kysely";
|
|
|
96
96
|
|
|
97
97
|
await sl.streams.events.consume({
|
|
98
98
|
sink: kyselySink(db, { id: "my-indexer", tables: ["transfers"], height: "height" }),
|
|
99
|
-
onBatch: async (events,
|
|
99
|
+
onBatch: async (events, ctx) => {
|
|
100
100
|
for (const e of events) await ctx.tx.insertInto("transfers").values(...).execute();
|
|
101
101
|
},
|
|
102
102
|
});
|
package/README.md
CHANGED
|
@@ -114,11 +114,11 @@ await streams.events.consume({
|
|
|
114
114
|
types: ["ft_transfer"],
|
|
115
115
|
batchSize: 100,
|
|
116
116
|
maxPages: 1,
|
|
117
|
-
onBatch: async (events,
|
|
117
|
+
onBatch: async (events, ctx) => {
|
|
118
118
|
for (const event of events) {
|
|
119
119
|
console.log(event.cursor, event.tx_id);
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return ctx.cursor;
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
124
|
```
|
|
@@ -231,9 +231,9 @@ await streams.events.replay({
|
|
|
231
231
|
const bytes = await streams.dumps.download(file);
|
|
232
232
|
await ingestParquet(bytes, { skipAtOrBelow: from }); // your tooling
|
|
233
233
|
},
|
|
234
|
-
async onBatch(events,
|
|
234
|
+
async onBatch(events, ctx) {
|
|
235
235
|
for (const event of events) await handle(event);
|
|
236
|
-
return
|
|
236
|
+
return ctx.cursor;
|
|
237
237
|
},
|
|
238
238
|
});
|
|
239
239
|
```
|
|
@@ -272,7 +272,7 @@ for (const item of fetched.urls) {
|
|
|
272
272
|
Decoder helper.
|
|
273
273
|
|
|
274
274
|
```typescript
|
|
275
|
-
import { decodeFtTransfer, isFtTransfer } from "@secondlayer/sdk";
|
|
275
|
+
import { decodeFtTransfer, isFtTransfer } from "@secondlayer/sdk/streams/rows";
|
|
276
276
|
|
|
277
277
|
for await (const event of streams.events.stream({ types: ["ft_transfer"] })) {
|
|
278
278
|
if (!isFtTransfer(event)) continue;
|
|
@@ -333,7 +333,7 @@ await sl.index.contractCalls.consume({
|
|
|
333
333
|
functionName: "purchase-asset",
|
|
334
334
|
fromCursor: await loadCheckpoint(), // null on first run
|
|
335
335
|
fromHeight: 0, // first run: backfill from genesis
|
|
336
|
-
onBatch: async (calls,
|
|
336
|
+
onBatch: async (calls, ctx) => {
|
|
337
337
|
await commitRowsAndCheckpoint(calls, ctx.cursor);
|
|
338
338
|
return ctx.cursor;
|
|
339
339
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -941,10 +941,7 @@ type ConsumerBatchContext<
|
|
|
941
941
|
blocksBehind: number | null;
|
|
942
942
|
/**
|
|
943
943
|
* The full tip for this page — `StreamsTip` or `IndexTip` depending on the
|
|
944
|
-
* surface.
|
|
945
|
-
* which is the only way to reach it today and is also how the worst
|
|
946
|
-
* `finalizedOnly` mistake becomes reachable (`return envelope.next_cursor`
|
|
947
|
-
* jumps the cursor past events that were filtered out and never delivered).
|
|
944
|
+
* surface.
|
|
948
945
|
*/
|
|
949
946
|
tip: TTip;
|
|
950
947
|
/**
|
|
@@ -953,9 +950,6 @@ type ConsumerBatchContext<
|
|
|
953
950
|
*/
|
|
954
951
|
reorgs: readonly TReorg[];
|
|
955
952
|
};
|
|
956
|
-
/** @deprecated Use {@link ConsumerBatchContext} — the Index and Streams loops
|
|
957
|
-
* share one shape now. Kept as an alias so existing annotations compile. */
|
|
958
|
-
type StreamsBatchContext = ConsumerBatchContext;
|
|
959
953
|
/**
|
|
960
954
|
* The checkpoint for a reorg rollback. Persist `cursor` (the rewind position)
|
|
961
955
|
* inside the same transaction as your rollback so the two commit atomically.
|
|
@@ -1025,7 +1019,7 @@ type StreamsEventsConsumeParams<
|
|
|
1025
1019
|
* labels do not interleave within a page — add `onBatch` when you need
|
|
1026
1020
|
* strict global order across labels.
|
|
1027
1021
|
*/
|
|
1028
|
-
on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx:
|
|
1022
|
+
on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: ConsumerBatchContext<StreamsTip, StreamsReorg> & WithSinkTx<TTx>) => void | Promise<void> };
|
|
1029
1023
|
batchSize?: number;
|
|
1030
1024
|
/**
|
|
1031
1025
|
* Apply a page of canonical events. Persist `ctx.cursor` in the same
|
|
@@ -1035,7 +1029,7 @@ type StreamsEventsConsumeParams<
|
|
|
1035
1029
|
* Optional only when `on` handles the page instead; a consume call with
|
|
1036
1030
|
* neither throws.
|
|
1037
1031
|
*/
|
|
1038
|
-
onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[],
|
|
1032
|
+
onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], ctx: ConsumerBatchContext<StreamsTip, StreamsReorg> & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
|
|
1039
1033
|
/**
|
|
1040
1034
|
* Roll your projection back to `reorg.fork_point_height`, persisting
|
|
1041
1035
|
* `ctx.cursor` in the same transaction. Called once per *new* reorg at or
|
|
@@ -1107,7 +1101,7 @@ type StreamsEventsConsumeBitcoinParams<TTx = never> = {
|
|
|
1107
1101
|
/** A mainnet address. */
|
|
1108
1102
|
address?: string;
|
|
1109
1103
|
batchSize?: number;
|
|
1110
|
-
onBatch: (events: RuneStreamsEvent[],
|
|
1104
|
+
onBatch: (events: RuneStreamsEvent[], ctx: ConsumerBatchContext<StreamsBitcoinTip, StreamsReorg> & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
|
|
1111
1105
|
onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
|
|
1112
1106
|
maxRollbackDepth?: number;
|
|
1113
1107
|
retryCount?: number;
|
|
@@ -1206,7 +1200,7 @@ type StreamsEventsReplayParams = {
|
|
|
1206
1200
|
from: string | null;
|
|
1207
1201
|
}) => Promise<void> | void;
|
|
1208
1202
|
/** Called per live page after the dump phase, like `consume`. */
|
|
1209
|
-
onBatch: (events: StreamsEvent[],
|
|
1203
|
+
onBatch: (events: StreamsEvent[], ctx: ConsumerBatchContext<StreamsTip, StreamsReorg>) => Promise<string | null | undefined> | string | null | undefined;
|
|
1210
1204
|
/**
|
|
1211
1205
|
* Called when the live-tail phase (after the dump backfill) crosses a reorg,
|
|
1212
1206
|
* before the cursor rewinds and re-reads the now-canonical events — same
|
|
@@ -1529,7 +1523,7 @@ type IndexConsumeOptions<
|
|
|
1529
1523
|
* an empty page still proves the loop is alive. Feed it to
|
|
1530
1524
|
* `consumerHealth().record`. */
|
|
1531
1525
|
onProgress?: (ctx: ConsumerBatchContext) => void;
|
|
1532
|
-
onBatch: (items: TItem[],
|
|
1526
|
+
onBatch: (items: TItem[], ctx: ConsumerBatchContext<TEnvelope["tip"], TEnvelope["reorgs"][number]> & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
|
|
1533
1527
|
/** Called once per new reorg at or below the checkpoint, before the loop
|
|
1534
1528
|
* rewinds to `ctx.cursor` (`null` = pre-genesis) and re-reads. A reorg
|
|
1535
1529
|
* whose fork sits ABOVE the checkpoint is not a rollback: nothing past
|
|
@@ -4154,8 +4148,6 @@ declare class ArchiveGateNotConfiguredError extends SecondLayerError {
|
|
|
4154
4148
|
/** Parse a `Retry-After` header: delta-seconds or an HTTP-date. */
|
|
4155
4149
|
declare function parseRetryAfter(value?: string | null): number | undefined;
|
|
4156
4150
|
type CreateArchiveClientOptions = {
|
|
4157
|
-
/** @deprecated Prefer `accountKey`. Kept one release as an alias. */
|
|
4158
|
-
apiKey?: string;
|
|
4159
4151
|
accountKey?: string;
|
|
4160
4152
|
fetchImpl?: FetchLike;
|
|
4161
4153
|
archiveBaseUrl?: string;
|
|
@@ -4387,7 +4379,6 @@ declare class StreamsServerError extends ApiError {
|
|
|
4387
4379
|
declare class StreamsSignatureError extends SecondLayerError {
|
|
4388
4380
|
constructor(message?: string);
|
|
4389
4381
|
}
|
|
4390
|
-
import { decodeFtTransfer, isFtTransfer, decodeNftTransfer, isNftTransfer, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, isStxBurn, isStxLock, isStxMint, isStxTransfer, decodeFtBurn, decodeFtMint, decodeNftBurn, decodeNftMint, isFtBurn, isFtMint, isNftBurn, isNftMint, decodePrint, isPrint } from "@secondlayer/shared/streams-rows";
|
|
4391
4382
|
import { DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, FtTransferEvent, FtTransferPayload as FtTransferPayload2, NftTransferEvent, NftTransferPayload as NftTransferPayload2 } from "@secondlayer/shared/streams-rows";
|
|
4392
4383
|
/**
|
|
4393
4384
|
* Helpers for Streams cursors. A cursor is the opaque `<block>:<index>` string
|
|
@@ -4427,4 +4418,4 @@ declare const Cursor: {
|
|
|
4427
4418
|
};
|
|
4428
4419
|
};
|
|
4429
4420
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
4430
|
-
export { ACCOUNT_KEY_ENV, ActiveSubgraphOperation, ApiError, ArchiveAuthError, ArchiveClient, ArchiveCreditsBalance, ArchiveDataset, ArchiveFetchItem, ArchiveFetchResult, ArchiveFlow, ArchiveGateNotConfiguredError, ArchiveLoadOptions, ArchiveManifest, ArchivePartition, ArchiveQuote, ArchiveSignatureError, ArchiveStatus, ArchiveVerifyInput, ArchiveVerifyRangeStatus, ArchiveVerifyResult, AuthError, BitcoinOutputSpent, BitcoinOutputUnspent, BitcoinOutspend, BitcoinResource, BlockEnvelope, BlocksEnvelope, BlocksListParams, BlocksWalkParams, CanonicalEnvelope, CanonicalListParams, CanonicalWalkParams, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTrigger, ChainTriggerType, ChainTxLevelEvent, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainWebhookEnvelope, ConsumerBatchContext, ConsumerHealth, ConsumerSink, ContextAccount, ContextField, ContextFieldError, ContextSnapshot, ContractCallsConsumeParams, ContractCallsEnvelope, ContractCallsListParams, ContractCallsWalkParams, ContractConformance, ContractSummary, Contracts, ContractsEnvelope, ContractsListParams, CreateArchiveClientOptions, CreateWebhookRequest2 as CreateWebhookRequest, CreateWebhookResponse2 as CreateWebhookResponse, Cursor, DEFAULT_REQUEST_TIMEOUT_MS, DOWN_MIN_CONSECUTIVE, DeadRow2 as DeadRow, DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, DeliveryRow2 as DeliveryRow, DoctorEvidence, DoctorFix, DoctorIssue, DoctorIssueCode, DoctorReport, DoctorSeverity, EtagCache, EtagEntry, EventsConsumeParams, EventsEnvelope, EventsListParams, EventsWalkParams, FetchLike2 as FetchLike, FtTransfer, FtTransferEvent, FtTransferPayload2 as FtTransferPayload, FtTransfersEnvelope, FtTransfersListParams, FtTransfersResource, FtTransfersWalkParams, INDEX_MAX_PAGE_SIZE, INSTANCE_TOKEN_ENV, Index, IndexAlwaysFields, IndexBitcoinTip, IndexBlock, IndexBtcReorg, IndexCanonicalBlock, IndexConsumeOptions, IndexContractCall, IndexDiscovery, IndexEvent, IndexEventFields, IndexEventOf, IndexEventType, IndexEventTypeFilters, IndexEventsResource, IndexFeedEnvelope, IndexFeedFetcher, IndexFeedItem, IndexFtBurn, IndexFtMint, IndexFtTransfer, IndexMapDelete, IndexMapInsert, IndexMapSet, IndexMempoolTransaction, IndexNestedContractCall, IndexNftBurn, IndexNftMint, IndexNftTransfer, IndexOrder, IndexPostCondition, IndexPox5Event, IndexPox5EventTopic, IndexPoxCycle, IndexPoxCycleSigner, IndexPrint, IndexReorg, IndexRuneBalance, IndexRuneEntry, IndexRuneEvent, IndexRuneEventKind, IndexRuneRefSummary, IndexRuneTerms, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStateWrite, IndexStxBurn, IndexStxLock, IndexStxMint, IndexStxTransfer, IndexTip, IndexTransaction, IndexVarSet, InstanceClient, InstanceDiagnosis3 as InstanceDiagnosis, InstanceIssue, InstanceState, InstanceStatus, InsufficientArchiveCreditsError, LOCAL_API_URL, LoadedArchive, MemoryEtagCache, MempoolEnvelope, MempoolListParams, MempoolTransactionEnvelope, MempoolWalkParams, NftTransfer, NftTransferEvent, NftTransferPayload2 as NftTransferPayload, NftTransfersEnvelope, NftTransfersListParams, NftTransfersResource, NftTransfersWalkParams, Pox5EventsConsumeParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, RuneActivityEnvelope, RuneActivityListParams, RuneActivityWalkParams, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneBalancesEnvelope, RuneBalancesListParams, RuneEnvelope, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneId, RuneRef, RuneStreamsEvent, RunesEnvelope, RunesListParams, RunesResource, SbtcDepositEnvelope, SbtcDepositEvent, SbtcDepositsConsumeParams, SbtcDepositsEnvelope, SbtcDepositsListParams, SbtcDepositsWalkParams, SbtcEventTopic2 as SbtcEventTopic, SbtcEventsConsumeParams, SbtcEventsEnvelope, SbtcEventsListParams, SbtcEventsWalkParams, SbtcResource, SbtcSummaryEnvelope, SbtcWithdrawalEnvelope, SbtcWithdrawalEvent, SbtcWithdrawalStatus, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalsEnvelope, SbtcWithdrawalsListParams, SbtcWithdrawalsWalkParams, SecondLayer, SecondLayerArchive, SecondLayerError, SecondLayerErrorOptions, SecondLayerOptions, SinkTx, StackingEnvelope, StackingListParams, StackingWalkParams, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StateWritesEnvelope, StateWritesListParams, StateWritesWalkParams, StreamsBatch,
|
|
4421
|
+
export { ACCOUNT_KEY_ENV, ActiveSubgraphOperation, ApiError, ArchiveAuthError, ArchiveClient, ArchiveCreditsBalance, ArchiveDataset, ArchiveFetchItem, ArchiveFetchResult, ArchiveFlow, ArchiveGateNotConfiguredError, ArchiveLoadOptions, ArchiveManifest, ArchivePartition, ArchiveQuote, ArchiveSignatureError, ArchiveStatus, ArchiveVerifyInput, ArchiveVerifyRangeStatus, ArchiveVerifyResult, AuthError, BitcoinOutputSpent, BitcoinOutputUnspent, BitcoinOutspend, BitcoinResource, BlockEnvelope, BlocksEnvelope, BlocksListParams, BlocksWalkParams, CanonicalEnvelope, CanonicalListParams, CanonicalWalkParams, ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTrigger, ChainTriggerType, ChainTxLevelEvent, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainWebhookEnvelope, ConsumerBatchContext, ConsumerHealth, ConsumerSink, ContextAccount, ContextField, ContextFieldError, ContextSnapshot, ContractCallsConsumeParams, ContractCallsEnvelope, ContractCallsListParams, ContractCallsWalkParams, ContractConformance, ContractSummary, Contracts, ContractsEnvelope, ContractsListParams, CreateArchiveClientOptions, CreateWebhookRequest2 as CreateWebhookRequest, CreateWebhookResponse2 as CreateWebhookResponse, Cursor, DEFAULT_REQUEST_TIMEOUT_MS, DOWN_MIN_CONSECUTIVE, DeadRow2 as DeadRow, DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, DeliveryRow2 as DeliveryRow, DoctorEvidence, DoctorFix, DoctorIssue, DoctorIssueCode, DoctorReport, DoctorSeverity, EtagCache, EtagEntry, EventsConsumeParams, EventsEnvelope, EventsListParams, EventsWalkParams, FetchLike2 as FetchLike, FtTransfer, FtTransferEvent, FtTransferPayload2 as FtTransferPayload, FtTransfersEnvelope, FtTransfersListParams, FtTransfersResource, FtTransfersWalkParams, INDEX_MAX_PAGE_SIZE, INSTANCE_TOKEN_ENV, Index, IndexAlwaysFields, IndexBitcoinTip, IndexBlock, IndexBtcReorg, IndexCanonicalBlock, IndexConsumeOptions, IndexContractCall, IndexDiscovery, IndexEvent, IndexEventFields, IndexEventOf, IndexEventType, IndexEventTypeFilters, IndexEventsResource, IndexFeedEnvelope, IndexFeedFetcher, IndexFeedItem, IndexFtBurn, IndexFtMint, IndexFtTransfer, IndexMapDelete, IndexMapInsert, IndexMapSet, IndexMempoolTransaction, IndexNestedContractCall, IndexNftBurn, IndexNftMint, IndexNftTransfer, IndexOrder, IndexPostCondition, IndexPox5Event, IndexPox5EventTopic, IndexPoxCycle, IndexPoxCycleSigner, IndexPrint, IndexReorg, IndexRuneBalance, IndexRuneEntry, IndexRuneEvent, IndexRuneEventKind, IndexRuneRefSummary, IndexRuneTerms, IndexSbtcDeposit, IndexSbtcDepositDetail, IndexSbtcEvent, IndexSbtcSummary, IndexSbtcWithdrawal, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawalPhase, IndexStackingAction, IndexStateWrite, IndexStxBurn, IndexStxLock, IndexStxMint, IndexStxTransfer, IndexTip, IndexTransaction, IndexVarSet, InstanceClient, InstanceDiagnosis3 as InstanceDiagnosis, InstanceIssue, InstanceState, InstanceStatus, InsufficientArchiveCreditsError, LOCAL_API_URL, LoadedArchive, MemoryEtagCache, MempoolEnvelope, MempoolListParams, MempoolTransactionEnvelope, MempoolWalkParams, NftTransfer, NftTransferEvent, NftTransferPayload2 as NftTransferPayload, NftTransfersEnvelope, NftTransfersListParams, NftTransfersResource, NftTransfersWalkParams, Pox5EventsConsumeParams, Pox5EventsEnvelope, Pox5EventsListParams, Pox5EventsWalkParams, Pox5Resource, PoxCycleEnvelope, PoxCyclesEnvelope, PoxCyclesListParams, PoxCyclesWalkParams, PoxResource, PrintSchemaResponse, PublicStatus2 as PublicStatus, RateLimitError, ReplayResult2 as ReplayResult, RequestOptions, RewardSet2 as RewardSet, RotateSecretResponse2 as RotateSecretResponse, RuneActivityEnvelope, RuneActivityListParams, RuneActivityWalkParams, RuneApplyDeliveryOf, RuneApplyEnvelope, RuneBalancesEnvelope, RuneBalancesListParams, RuneEnvelope, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneId, RuneRef, RuneStreamsEvent, RunesEnvelope, RunesListParams, RunesResource, SbtcDepositEnvelope, SbtcDepositEvent, SbtcDepositsConsumeParams, SbtcDepositsEnvelope, SbtcDepositsListParams, SbtcDepositsWalkParams, SbtcEventTopic2 as SbtcEventTopic, SbtcEventsConsumeParams, SbtcEventsEnvelope, SbtcEventsListParams, SbtcEventsWalkParams, SbtcResource, SbtcSummaryEnvelope, SbtcWithdrawalEnvelope, SbtcWithdrawalEvent, SbtcWithdrawalStatus, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalsEnvelope, SbtcWithdrawalsListParams, SbtcWithdrawalsWalkParams, SecondLayer, SecondLayerArchive, SecondLayerError, SecondLayerErrorOptions, SecondLayerOptions, SinkTx, StackingEnvelope, StackingListParams, StackingWalkParams, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StateWritesEnvelope, StateWritesListParams, StateWritesWalkParams, StreamsBatch, StreamsBitcoinCanonicalBlock, StreamsBitcoinTip, StreamsCanonicalBlock, StreamsClient, StreamsConsumeBitcoinParams, StreamsConsumeParams, StreamsConsumeStacksParams, StreamsDumpFile, StreamsDumps, StreamsDumpsManifest, StreamsEvent, StreamsEventPayload, StreamsEventType, StreamsEventsBitcoinListParams, StreamsEventsConsumeBitcoinParams, StreamsEventsConsumeParams, StreamsEventsConsumeResult, StreamsEventsEnvelope, StreamsEventsListEnvelope, StreamsEventsListParams, StreamsEventsStacksListParams, StreamsEventsStreamBitcoinParams, StreamsEventsStreamParams, StreamsEventsStreamStacksParams, StreamsEventsSubscribeBitcoinParams, StreamsEventsSubscribeParams, StreamsEventsSubscribeStacksParams, StreamsReorg, StreamsReorgContext, StreamsReorgsListEnvelope, StreamsReorgsListParams, StreamsServerError, StreamsSignatureError, StreamsSubscription, StreamsTip, StreamsWireEvent2 as StreamsWireEvent, SubgraphAgentSchema3 as SubgraphAgentSchema, SubgraphOperationStatus, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphSpecOptions3 as SubgraphSpecOptions, Subgraphs, TransactionEnvelope, TransactionProof, TransactionProofVerifyResult, TransactionsEnvelope, TransactionsListParams, TransactionsWalkParams, UpdateWebhookRequest2 as UpdateWebhookRequest, ValidationError, VmStreamsEvent, WalkOptions, WebhookActivity2 as WebhookActivity, WebhookActivityHour, WebhookAuth, WebhookDeliveryDetail2 as WebhookDeliveryDetail, WebhookDetail2 as WebhookDetail, WebhookFormat, WebhookHeaderInput, WebhookKind, WebhookStatus, WebhookSummary2 as WebhookSummary, WebhookTestResult2 as WebhookTestResult, Webhooks, WithSinkTx, buildDoctorReport, buildListIssue, consumeIndexFeed, consumerHealth, contextField, createArchiveClient, createStreamsClient, decode, decodeChainWebhook, decodeClarityValue, fetchRewardSet, getSubgraph, isHostedApiUrl, isSuccessDelivery, parseRetryAfter, resolveAccountKey, resolveApiKey, resolveBaseUrl, shutdownSignal, toJsonSafe, trigger, verifySecondlayerSignature, verify as verifyStandardWebhooksHeaders, verifyTransactionProof, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -450,7 +450,7 @@ function stripSlash(url) {
|
|
|
450
450
|
return url.replace(/\/+$/, "");
|
|
451
451
|
}
|
|
452
452
|
function createArchiveClient(options = {}) {
|
|
453
|
-
const accountKey = resolveAccountKey(options.accountKey
|
|
453
|
+
const accountKey = resolveAccountKey(options.accountKey);
|
|
454
454
|
const fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));
|
|
455
455
|
const archiveBaseUrl = stripSlash(options.archiveBaseUrl ?? DEFAULT_ARCHIVE_BASE_URL);
|
|
456
456
|
const archiveOpsUrl = stripSlash(options.archiveOpsUrl ?? DEFAULT_ARCHIVE_OPS_URL);
|
|
@@ -970,7 +970,7 @@ async function consumeStreamsEvents(opts) {
|
|
|
970
970
|
const sink = opts.sink;
|
|
971
971
|
if (checkpoint !== null && (checkpoint !== cursor || emitted.length > 0)) {
|
|
972
972
|
await sink.commitBatch(checkpoint, async (tx) => {
|
|
973
|
-
await opts.onBatch(emitted,
|
|
973
|
+
await opts.onBatch(emitted, {
|
|
974
974
|
...ctx,
|
|
975
975
|
tx
|
|
976
976
|
});
|
|
@@ -978,7 +978,7 @@ async function consumeStreamsEvents(opts) {
|
|
|
978
978
|
}
|
|
979
979
|
nextCursor = checkpoint;
|
|
980
980
|
} else {
|
|
981
|
-
const returnedCursor = await opts.onBatch(emitted,
|
|
981
|
+
const returnedCursor = await opts.onBatch(emitted, ctx);
|
|
982
982
|
if (finalizedOnly)
|
|
983
983
|
assertFinalizedCheckpoint(returnedCursor, checkpoint);
|
|
984
984
|
nextCursor = returnedCursor ?? checkpoint;
|
|
@@ -1151,7 +1151,7 @@ async function consumeIndexFeed(opts) {
|
|
|
1151
1151
|
const sink = opts.sink;
|
|
1152
1152
|
if (checkpoint !== null && (checkpoint !== cursor || emitted.length > 0)) {
|
|
1153
1153
|
await sink.commitBatch(checkpoint, async (tx) => {
|
|
1154
|
-
await opts.onBatch(emitted,
|
|
1154
|
+
await opts.onBatch(emitted, {
|
|
1155
1155
|
...ctx,
|
|
1156
1156
|
tx
|
|
1157
1157
|
});
|
|
@@ -1159,7 +1159,7 @@ async function consumeIndexFeed(opts) {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
nextCursor = checkpoint;
|
|
1161
1161
|
} else {
|
|
1162
|
-
const returnedCursor = await opts.onBatch(emitted,
|
|
1162
|
+
const returnedCursor = await opts.onBatch(emitted, ctx);
|
|
1163
1163
|
if (finalizedOnly)
|
|
1164
1164
|
assertFinalizedCheckpoint(returnedCursor, checkpoint);
|
|
1165
1165
|
nextCursor = returnedCursor ?? checkpoint;
|
|
@@ -2223,7 +2223,7 @@ function createStreamsClient(options) {
|
|
|
2223
2223
|
}
|
|
2224
2224
|
const dispatch = params.on;
|
|
2225
2225
|
const project = (events) => params.decoded ? events.map(decode) : events;
|
|
2226
|
-
const onBatch = async (events,
|
|
2226
|
+
const onBatch = async (events, ctx) => {
|
|
2227
2227
|
for (const label of labels) {
|
|
2228
2228
|
const forLabel = events.filter((event) => event.matched?.includes(label));
|
|
2229
2229
|
if (forLabel.length === 0)
|
|
@@ -2231,7 +2231,7 @@ function createStreamsClient(options) {
|
|
|
2231
2231
|
await dispatch?.[label]?.(project(forLabel), ctx);
|
|
2232
2232
|
}
|
|
2233
2233
|
const userOnBatch = params.onBatch;
|
|
2234
|
-
return await userOnBatch?.(project(events),
|
|
2234
|
+
return await userOnBatch?.(project(events), ctx);
|
|
2235
2235
|
};
|
|
2236
2236
|
return consumeStreamsEvents({
|
|
2237
2237
|
fromCursor: params.fromCursor,
|
|
@@ -3356,32 +3356,6 @@ function verifyTransactionProof(proof, opts) {
|
|
|
3356
3356
|
errors
|
|
3357
3357
|
};
|
|
3358
3358
|
}
|
|
3359
|
-
// src/streams/index.ts
|
|
3360
|
-
import {
|
|
3361
|
-
decodeFtTransfer,
|
|
3362
|
-
isFtTransfer,
|
|
3363
|
-
decodeNftTransfer,
|
|
3364
|
-
isNftTransfer,
|
|
3365
|
-
decodeStxBurn,
|
|
3366
|
-
decodeStxLock,
|
|
3367
|
-
decodeStxMint,
|
|
3368
|
-
decodeStxTransfer,
|
|
3369
|
-
isStxBurn,
|
|
3370
|
-
isStxLock,
|
|
3371
|
-
isStxMint,
|
|
3372
|
-
isStxTransfer,
|
|
3373
|
-
decodeFtBurn,
|
|
3374
|
-
decodeFtMint,
|
|
3375
|
-
decodeNftBurn,
|
|
3376
|
-
decodeNftMint,
|
|
3377
|
-
isFtBurn,
|
|
3378
|
-
isFtMint,
|
|
3379
|
-
isNftBurn,
|
|
3380
|
-
isNftMint,
|
|
3381
|
-
decodePrint,
|
|
3382
|
-
isPrint
|
|
3383
|
-
} from "@secondlayer/shared/streams-rows";
|
|
3384
|
-
|
|
3385
3359
|
// src/streams/types.ts
|
|
3386
3360
|
import {
|
|
3387
3361
|
RUNE_EVENT_TYPES,
|
|
@@ -3427,31 +3401,9 @@ export {
|
|
|
3427
3401
|
decode,
|
|
3428
3402
|
decodeChainWebhook,
|
|
3429
3403
|
decodeClarityValue,
|
|
3430
|
-
decodeFtBurn,
|
|
3431
|
-
decodeFtMint,
|
|
3432
|
-
decodeFtTransfer,
|
|
3433
|
-
decodeNftBurn,
|
|
3434
|
-
decodeNftMint,
|
|
3435
|
-
decodeNftTransfer,
|
|
3436
|
-
decodePrint,
|
|
3437
|
-
decodeStxBurn,
|
|
3438
|
-
decodeStxLock,
|
|
3439
|
-
decodeStxMint,
|
|
3440
|
-
decodeStxTransfer,
|
|
3441
3404
|
fetchRewardSet,
|
|
3442
3405
|
getSubgraph,
|
|
3443
|
-
isFtBurn,
|
|
3444
|
-
isFtMint,
|
|
3445
|
-
isFtTransfer,
|
|
3446
3406
|
isHostedApiUrl,
|
|
3447
|
-
isNftBurn,
|
|
3448
|
-
isNftMint,
|
|
3449
|
-
isNftTransfer,
|
|
3450
|
-
isPrint,
|
|
3451
|
-
isStxBurn,
|
|
3452
|
-
isStxLock,
|
|
3453
|
-
isStxMint,
|
|
3454
|
-
isStxTransfer,
|
|
3455
3407
|
isSuccessDelivery,
|
|
3456
3408
|
parseRetryAfter,
|
|
3457
3409
|
resolveAccountKey,
|
|
@@ -3466,5 +3418,5 @@ export {
|
|
|
3466
3418
|
verifyWebhookSignature
|
|
3467
3419
|
};
|
|
3468
3420
|
|
|
3469
|
-
//# debugId=
|
|
3421
|
+
//# debugId=9551CE26B3E76ABF64756E2164756E21
|
|
3470
3422
|
//# sourceMappingURL=index.js.map
|