@secondlayer/sdk 5.3.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +176 -2
- package/dist/index.js +108 -4
- package/dist/index.js.map +5 -5
- package/dist/streams/index.d.ts +23 -2
- package/dist/streams/index.js +23 -4
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +153 -0
- package/dist/subgraphs/index.js +86 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,146 @@ type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
|
|
|
176
176
|
batchSize?: number
|
|
177
177
|
signal?: AbortSignal
|
|
178
178
|
};
|
|
179
|
+
type IndexEventBase = {
|
|
180
|
+
cursor: string
|
|
181
|
+
block_height: number
|
|
182
|
+
block_time?: string | null
|
|
183
|
+
tx_id: string
|
|
184
|
+
tx_index: number
|
|
185
|
+
event_index: number
|
|
186
|
+
contract_id: string | null
|
|
187
|
+
};
|
|
188
|
+
type IndexFtTransfer = IndexEventBase & {
|
|
189
|
+
event_type: "ft_transfer"
|
|
190
|
+
asset_identifier: string
|
|
191
|
+
sender: string
|
|
192
|
+
recipient: string
|
|
193
|
+
amount: string
|
|
194
|
+
};
|
|
195
|
+
type IndexNftTransfer = IndexEventBase & {
|
|
196
|
+
event_type: "nft_transfer"
|
|
197
|
+
asset_identifier: string
|
|
198
|
+
sender: string
|
|
199
|
+
recipient: string
|
|
200
|
+
value: string
|
|
201
|
+
};
|
|
202
|
+
type IndexStxTransfer = IndexEventBase & {
|
|
203
|
+
event_type: "stx_transfer"
|
|
204
|
+
sender: string
|
|
205
|
+
recipient: string
|
|
206
|
+
amount: string
|
|
207
|
+
memo: string | null
|
|
208
|
+
};
|
|
209
|
+
type IndexStxMint = IndexEventBase & {
|
|
210
|
+
event_type: "stx_mint"
|
|
211
|
+
recipient: string
|
|
212
|
+
amount: string
|
|
213
|
+
};
|
|
214
|
+
type IndexStxBurn = IndexEventBase & {
|
|
215
|
+
event_type: "stx_burn"
|
|
216
|
+
sender: string
|
|
217
|
+
amount: string
|
|
218
|
+
};
|
|
219
|
+
type IndexStxLock = IndexEventBase & {
|
|
220
|
+
event_type: "stx_lock"
|
|
221
|
+
sender: string
|
|
222
|
+
amount: string
|
|
223
|
+
payload: {
|
|
224
|
+
unlock_height: string | null
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
type IndexFtMint = IndexEventBase & {
|
|
228
|
+
event_type: "ft_mint"
|
|
229
|
+
asset_identifier: string
|
|
230
|
+
recipient: string
|
|
231
|
+
amount: string
|
|
232
|
+
};
|
|
233
|
+
type IndexFtBurn = IndexEventBase & {
|
|
234
|
+
event_type: "ft_burn"
|
|
235
|
+
asset_identifier: string
|
|
236
|
+
sender: string
|
|
237
|
+
amount: string
|
|
238
|
+
};
|
|
239
|
+
type IndexNftMint = IndexEventBase & {
|
|
240
|
+
event_type: "nft_mint"
|
|
241
|
+
asset_identifier: string
|
|
242
|
+
recipient: string
|
|
243
|
+
value: string
|
|
244
|
+
};
|
|
245
|
+
type IndexNftBurn = IndexEventBase & {
|
|
246
|
+
event_type: "nft_burn"
|
|
247
|
+
asset_identifier: string
|
|
248
|
+
sender: string
|
|
249
|
+
value: string
|
|
250
|
+
};
|
|
251
|
+
type IndexPrint = IndexEventBase & {
|
|
252
|
+
event_type: "print"
|
|
253
|
+
payload: {
|
|
254
|
+
topic: string | null
|
|
255
|
+
value: unknown
|
|
256
|
+
raw_value: string | null
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
/** Decoded chain event, discriminated by `event_type`. */
|
|
260
|
+
type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
|
|
261
|
+
type IndexEventType = IndexEvent["event_type"];
|
|
262
|
+
type EventsEnvelope = {
|
|
263
|
+
events: IndexEvent[]
|
|
264
|
+
next_cursor: string | null
|
|
265
|
+
tip: IndexTip
|
|
266
|
+
reorgs: never[]
|
|
267
|
+
};
|
|
268
|
+
type EventsListParams = {
|
|
269
|
+
/** Required. One of the decoded event types. */
|
|
270
|
+
eventType: IndexEventType
|
|
271
|
+
cursor?: string | null
|
|
272
|
+
fromCursor?: string | null
|
|
273
|
+
limit?: number
|
|
274
|
+
contractId?: string
|
|
275
|
+
assetIdentifier?: string
|
|
276
|
+
sender?: string
|
|
277
|
+
recipient?: string
|
|
278
|
+
fromHeight?: number
|
|
279
|
+
toHeight?: number
|
|
280
|
+
};
|
|
281
|
+
type EventsWalkParams = Omit<EventsListParams, "limit"> & {
|
|
282
|
+
batchSize?: number
|
|
283
|
+
signal?: AbortSignal
|
|
284
|
+
};
|
|
285
|
+
type IndexContractCall = {
|
|
286
|
+
cursor: string
|
|
287
|
+
block_height: number
|
|
288
|
+
block_time?: string | null
|
|
289
|
+
tx_id: string
|
|
290
|
+
tx_index: number
|
|
291
|
+
contract_id: string
|
|
292
|
+
function_name: string
|
|
293
|
+
sender: string
|
|
294
|
+
status: string
|
|
295
|
+
args: unknown[]
|
|
296
|
+
result: unknown
|
|
297
|
+
result_hex: string | null
|
|
298
|
+
};
|
|
299
|
+
type ContractCallsEnvelope = {
|
|
300
|
+
contract_calls: IndexContractCall[]
|
|
301
|
+
next_cursor: string | null
|
|
302
|
+
tip: IndexTip
|
|
303
|
+
reorgs: never[]
|
|
304
|
+
};
|
|
305
|
+
type ContractCallsListParams = {
|
|
306
|
+
cursor?: string | null
|
|
307
|
+
fromCursor?: string | null
|
|
308
|
+
limit?: number
|
|
309
|
+
contractId?: string
|
|
310
|
+
functionName?: string
|
|
311
|
+
sender?: string
|
|
312
|
+
fromHeight?: number
|
|
313
|
+
toHeight?: number
|
|
314
|
+
};
|
|
315
|
+
type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
|
|
316
|
+
batchSize?: number
|
|
317
|
+
signal?: AbortSignal
|
|
318
|
+
};
|
|
179
319
|
declare class Index extends BaseClient {
|
|
180
320
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
181
321
|
readonly ftTransfers: {
|
|
@@ -186,10 +326,23 @@ declare class Index extends BaseClient {
|
|
|
186
326
|
list: (params?: NftTransfersListParams) => Promise<NftTransfersEnvelope>
|
|
187
327
|
walk: (params?: NftTransfersWalkParams) => AsyncIterable<NftTransfer>
|
|
188
328
|
};
|
|
329
|
+
/** Generic decoded events by `event_type` (the full /v1/index/events surface). */
|
|
330
|
+
readonly events: {
|
|
331
|
+
list: (params: EventsListParams) => Promise<EventsEnvelope>
|
|
332
|
+
walk: (params: EventsWalkParams) => AsyncIterable<IndexEvent>
|
|
333
|
+
};
|
|
334
|
+
readonly contractCalls: {
|
|
335
|
+
list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>
|
|
336
|
+
walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>
|
|
337
|
+
};
|
|
189
338
|
private listFtTransfers;
|
|
190
339
|
private listNftTransfers;
|
|
191
340
|
private walkFtTransfers;
|
|
192
341
|
private walkNftTransfers;
|
|
342
|
+
private listEvents;
|
|
343
|
+
private walkEvents;
|
|
344
|
+
private listContractCalls;
|
|
345
|
+
private walkContractCalls;
|
|
193
346
|
}
|
|
194
347
|
declare const STREAMS_EVENT_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "print"];
|
|
195
348
|
type StreamsEventType = (typeof STREAMS_EVENT_TYPES)[number];
|
|
@@ -509,6 +662,27 @@ declare function isStxBurn(event: StreamsEvent): event is StreamsEvent & {
|
|
|
509
662
|
event_type: "stx_burn"
|
|
510
663
|
};
|
|
511
664
|
declare function decodeStxBurn(event: StreamsEvent): DecodedStxBurn;
|
|
665
|
+
type DecodedStxLockPayload = {
|
|
666
|
+
sender: string
|
|
667
|
+
amount: string
|
|
668
|
+
payload: {
|
|
669
|
+
unlock_height: string | null
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
type DecodedStxLock = {
|
|
673
|
+
cursor: string
|
|
674
|
+
block_height: number
|
|
675
|
+
tx_id: string
|
|
676
|
+
tx_index: number
|
|
677
|
+
event_index: number
|
|
678
|
+
event_type: "stx_lock"
|
|
679
|
+
decoded_payload: DecodedStxLockPayload
|
|
680
|
+
source_cursor: string
|
|
681
|
+
};
|
|
682
|
+
declare function isStxLock(event: StreamsEvent): event is StreamsEvent & {
|
|
683
|
+
event_type: "stx_lock"
|
|
684
|
+
};
|
|
685
|
+
declare function decodeStxLock(event: StreamsEvent): DecodedStxLock;
|
|
512
686
|
type DecodedFtMintPayload = {
|
|
513
687
|
asset_identifier: string
|
|
514
688
|
contract_id: string
|
|
@@ -635,7 +809,7 @@ type DecodedEventColumns = {
|
|
|
635
809
|
/** JSONB overflow for non-flat types (e.g. print's decoded value). */
|
|
636
810
|
payload?: unknown
|
|
637
811
|
};
|
|
638
|
-
type DecodedEventRow = DecodedFtTransfer | DecodedNftTransfer | DecodedStxTransfer | DecodedStxMint | DecodedStxBurn | DecodedFtMint | DecodedFtBurn | DecodedNftMint | DecodedNftBurn | DecodedPrint;
|
|
812
|
+
type DecodedEventRow = DecodedFtTransfer | DecodedNftTransfer | DecodedStxTransfer | DecodedStxMint | DecodedStxBurn | DecodedStxLock | DecodedFtMint | DecodedFtBurn | DecodedNftMint | DecodedNftBurn | DecodedPrint;
|
|
639
813
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
640
814
|
/**
|
|
641
815
|
* Error thrown by {@link SecondLayer} when an API request fails.
|
|
@@ -754,4 +928,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
754
928
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
755
929
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
756
930
|
declare function decodeClarityValue(hex: string): unknown;
|
|
757
|
-
export { verifyWebhookSignature, toJsonSafe, isStxTransfer, isStxMint, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, decodeStxTransfer, decodeStxMint, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createStreamsClient, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsClient, StreamsCanonicalBlock, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, IndexTip, Index, FtTransfersWalkParams, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, AuthError, ApiError };
|
|
931
|
+
export { verifyWebhookSignature, toJsonSafe, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createStreamsClient, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsClient, StreamsCanonicalBlock, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, IndexTip, IndexEventType, IndexEvent, IndexContractCall, Index, FtTransfersWalkParams, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, AuthError, ApiError };
|
package/dist/index.js
CHANGED
|
@@ -317,6 +317,14 @@ class Index extends BaseClient {
|
|
|
317
317
|
list: (params = {}) => this.listNftTransfers(params),
|
|
318
318
|
walk: (params = {}) => this.walkNftTransfers(params)
|
|
319
319
|
};
|
|
320
|
+
events = {
|
|
321
|
+
list: (params) => this.listEvents(params),
|
|
322
|
+
walk: (params) => this.walkEvents(params)
|
|
323
|
+
};
|
|
324
|
+
contractCalls = {
|
|
325
|
+
list: (params = {}) => this.listContractCalls(params),
|
|
326
|
+
walk: (params = {}) => this.walkContractCalls(params)
|
|
327
|
+
};
|
|
320
328
|
async listFtTransfers(params = {}) {
|
|
321
329
|
const searchParams = new URLSearchParams;
|
|
322
330
|
appendSearchParam(searchParams, "cursor", params.cursor);
|
|
@@ -394,6 +402,83 @@ class Index extends BaseClient {
|
|
|
394
402
|
firstPage = false;
|
|
395
403
|
}
|
|
396
404
|
}
|
|
405
|
+
async listEvents(params) {
|
|
406
|
+
const searchParams = new URLSearchParams;
|
|
407
|
+
appendSearchParam(searchParams, "event_type", params.eventType);
|
|
408
|
+
appendSearchParam(searchParams, "cursor", params.cursor);
|
|
409
|
+
appendSearchParam(searchParams, "from_cursor", params.fromCursor);
|
|
410
|
+
appendSearchParam(searchParams, "limit", params.limit);
|
|
411
|
+
appendSearchParam(searchParams, "contract_id", params.contractId);
|
|
412
|
+
appendSearchParam(searchParams, "asset_identifier", params.assetIdentifier);
|
|
413
|
+
appendSearchParam(searchParams, "sender", params.sender);
|
|
414
|
+
appendSearchParam(searchParams, "recipient", params.recipient);
|
|
415
|
+
appendSearchParam(searchParams, "from_height", params.fromHeight);
|
|
416
|
+
appendSearchParam(searchParams, "to_height", params.toHeight);
|
|
417
|
+
return this.request("GET", `/v1/index/events?${searchParams.toString()}`);
|
|
418
|
+
}
|
|
419
|
+
async* walkEvents(params) {
|
|
420
|
+
const batchSize = params.batchSize ?? 200;
|
|
421
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
422
|
+
let firstPage = true;
|
|
423
|
+
while (!params.signal?.aborted) {
|
|
424
|
+
const envelope = await this.listEvents({
|
|
425
|
+
...params,
|
|
426
|
+
limit: batchSize,
|
|
427
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
428
|
+
fromCursor: firstPage ? params.fromCursor : undefined,
|
|
429
|
+
fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
|
|
430
|
+
});
|
|
431
|
+
for (const event of envelope.events) {
|
|
432
|
+
if (params.signal?.aborted)
|
|
433
|
+
return;
|
|
434
|
+
yield event;
|
|
435
|
+
}
|
|
436
|
+
const nextCursor = envelope.next_cursor;
|
|
437
|
+
if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
cursor = nextCursor;
|
|
441
|
+
firstPage = false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
async listContractCalls(params = {}) {
|
|
445
|
+
const searchParams = new URLSearchParams;
|
|
446
|
+
appendSearchParam(searchParams, "cursor", params.cursor);
|
|
447
|
+
appendSearchParam(searchParams, "from_cursor", params.fromCursor);
|
|
448
|
+
appendSearchParam(searchParams, "limit", params.limit);
|
|
449
|
+
appendSearchParam(searchParams, "contract_id", params.contractId);
|
|
450
|
+
appendSearchParam(searchParams, "function_name", params.functionName);
|
|
451
|
+
appendSearchParam(searchParams, "sender", params.sender);
|
|
452
|
+
appendSearchParam(searchParams, "from_height", params.fromHeight);
|
|
453
|
+
appendSearchParam(searchParams, "to_height", params.toHeight);
|
|
454
|
+
const query = searchParams.toString();
|
|
455
|
+
return this.request("GET", `/v1/index/contract-calls${query ? `?${query}` : ""}`);
|
|
456
|
+
}
|
|
457
|
+
async* walkContractCalls(params = {}) {
|
|
458
|
+
const batchSize = params.batchSize ?? 200;
|
|
459
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
460
|
+
let firstPage = true;
|
|
461
|
+
while (!params.signal?.aborted) {
|
|
462
|
+
const envelope = await this.listContractCalls({
|
|
463
|
+
...params,
|
|
464
|
+
limit: batchSize,
|
|
465
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
466
|
+
fromCursor: firstPage ? params.fromCursor : undefined,
|
|
467
|
+
fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
|
|
468
|
+
});
|
|
469
|
+
for (const call of envelope.contract_calls) {
|
|
470
|
+
if (params.signal?.aborted)
|
|
471
|
+
return;
|
|
472
|
+
yield call;
|
|
473
|
+
}
|
|
474
|
+
const nextCursor = envelope.next_cursor;
|
|
475
|
+
if (!nextCursor || nextCursor === cursor || envelope.contract_calls.length < batchSize) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
cursor = nextCursor;
|
|
479
|
+
firstPage = false;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
397
482
|
}
|
|
398
483
|
|
|
399
484
|
// src/streams/consumer.ts
|
|
@@ -859,13 +944,16 @@ function requireString3(payload, field, eventType) {
|
|
|
859
944
|
function optionalString(value) {
|
|
860
945
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
861
946
|
}
|
|
862
|
-
function
|
|
863
|
-
const amount = requireString3(payload,
|
|
947
|
+
function requireAmountField(payload, field, eventType) {
|
|
948
|
+
const amount = requireString3(payload, field, eventType);
|
|
864
949
|
if (!/^(0|[1-9]\d*)$/.test(amount)) {
|
|
865
|
-
throw new Error(`${eventType} payload has malformed
|
|
950
|
+
throw new Error(`${eventType} payload has malformed ${field}`);
|
|
866
951
|
}
|
|
867
952
|
return amount;
|
|
868
953
|
}
|
|
954
|
+
function requireAmount(payload, eventType) {
|
|
955
|
+
return requireAmountField(payload, "amount", eventType);
|
|
956
|
+
}
|
|
869
957
|
function parseAssetIdentifier3(assetIdentifier, eventType) {
|
|
870
958
|
const [contractId, tokenName] = assetIdentifier.split("::");
|
|
871
959
|
if (!contractId) {
|
|
@@ -949,6 +1037,20 @@ function decodeStxBurn(event) {
|
|
|
949
1037
|
amount: requireAmount(payload, "stx_burn")
|
|
950
1038
|
});
|
|
951
1039
|
}
|
|
1040
|
+
function isStxLock(event) {
|
|
1041
|
+
return event.event_type === "stx_lock";
|
|
1042
|
+
}
|
|
1043
|
+
function decodeStxLock(event) {
|
|
1044
|
+
if (!isStxLock(event)) {
|
|
1045
|
+
throw new Error(`Expected stx_lock event, got ${event.event_type}`);
|
|
1046
|
+
}
|
|
1047
|
+
const payload = event.payload;
|
|
1048
|
+
return decodedRow(event, "stx_lock", {
|
|
1049
|
+
sender: requireString3(payload, "locked_address", "stx_lock"),
|
|
1050
|
+
amount: requireAmountField(payload, "locked_amount", "stx_lock"),
|
|
1051
|
+
payload: { unlock_height: optionalString(payload.unlock_height) }
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
952
1054
|
// src/streams/token-mint-burn.ts
|
|
953
1055
|
function assetFields(event, eventType) {
|
|
954
1056
|
const assetIdentifier = requireString3(event.payload, "asset_identifier", eventType);
|
|
@@ -1126,6 +1228,7 @@ export {
|
|
|
1126
1228
|
toJsonSafe,
|
|
1127
1229
|
isStxTransfer,
|
|
1128
1230
|
isStxMint,
|
|
1231
|
+
isStxLock,
|
|
1129
1232
|
isStxBurn,
|
|
1130
1233
|
isPrint,
|
|
1131
1234
|
isNftTransfer,
|
|
@@ -1137,6 +1240,7 @@ export {
|
|
|
1137
1240
|
getSubgraph,
|
|
1138
1241
|
decodeStxTransfer,
|
|
1139
1242
|
decodeStxMint,
|
|
1243
|
+
decodeStxLock,
|
|
1140
1244
|
decodeStxBurn,
|
|
1141
1245
|
decodePrint,
|
|
1142
1246
|
decodeNftTransfer,
|
|
@@ -1159,5 +1263,5 @@ export {
|
|
|
1159
1263
|
ApiError
|
|
1160
1264
|
};
|
|
1161
1265
|
|
|
1162
|
-
//# debugId=
|
|
1266
|
+
//# debugId=4BB5ADD439A129B064756E2164756E21
|
|
1163
1267
|
//# sourceMappingURL=index.js.map
|