@secondlayer/sdk 6.3.0 → 6.4.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 +66 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +65 -0
- package/dist/subgraphs/index.js +48 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -676,6 +676,61 @@ type StackingWalkParams = Omit<StackingListParams, "limit"> & {
|
|
|
676
676
|
batchSize?: number
|
|
677
677
|
signal?: AbortSignal
|
|
678
678
|
};
|
|
679
|
+
/** A pending (unconfirmed) transaction. Like a transaction document but
|
|
680
|
+
* pre-chain — no block_height/tx_index/result/events — with `received_at` and
|
|
681
|
+
* a sequence cursor instead of a block position. */
|
|
682
|
+
type IndexMempoolTransaction = {
|
|
683
|
+
cursor: string
|
|
684
|
+
tx_id: string
|
|
685
|
+
tx_type: string
|
|
686
|
+
sender: string
|
|
687
|
+
received_at?: string | null
|
|
688
|
+
fee: string | null
|
|
689
|
+
nonce: string | null
|
|
690
|
+
sponsored: boolean | null
|
|
691
|
+
anchor_mode: string | null
|
|
692
|
+
post_condition_mode: string | null
|
|
693
|
+
post_conditions: IndexPostCondition[]
|
|
694
|
+
contract_call?: {
|
|
695
|
+
contract_id: string
|
|
696
|
+
function_name: string
|
|
697
|
+
function_args: unknown[]
|
|
698
|
+
}
|
|
699
|
+
token_transfer?: {
|
|
700
|
+
recipient: string
|
|
701
|
+
amount: string
|
|
702
|
+
memo: string
|
|
703
|
+
}
|
|
704
|
+
smart_contract?: {
|
|
705
|
+
clarity_version: number | null
|
|
706
|
+
}
|
|
707
|
+
coinbase?: {
|
|
708
|
+
alt_recipient: string | null
|
|
709
|
+
}
|
|
710
|
+
tenure_change?: {
|
|
711
|
+
cause: number
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
type MempoolEnvelope = {
|
|
715
|
+
mempool: IndexMempoolTransaction[]
|
|
716
|
+
next_cursor: string | null
|
|
717
|
+
tip: IndexTip
|
|
718
|
+
};
|
|
719
|
+
type MempoolTransactionEnvelope = {
|
|
720
|
+
transaction: IndexMempoolTransaction
|
|
721
|
+
tip: IndexTip
|
|
722
|
+
};
|
|
723
|
+
type MempoolListParams = {
|
|
724
|
+
cursor?: string | null
|
|
725
|
+
fromCursor?: string | null
|
|
726
|
+
limit?: number
|
|
727
|
+
sender?: string
|
|
728
|
+
type?: string
|
|
729
|
+
};
|
|
730
|
+
type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
|
|
731
|
+
batchSize?: number
|
|
732
|
+
signal?: AbortSignal
|
|
733
|
+
};
|
|
679
734
|
declare class Index extends BaseClient {
|
|
680
735
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
681
736
|
readonly ftTransfers: {
|
|
@@ -720,6 +775,13 @@ declare class Index extends BaseClient {
|
|
|
720
775
|
list: (params?: StackingListParams) => Promise<StackingEnvelope>
|
|
721
776
|
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
|
|
722
777
|
};
|
|
778
|
+
/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
|
|
779
|
+
* tx_id (resolves to null when the tx has confirmed or dropped). */
|
|
780
|
+
readonly mempool: {
|
|
781
|
+
list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
|
|
782
|
+
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
|
|
783
|
+
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
|
|
784
|
+
};
|
|
723
785
|
private listFtTransfers;
|
|
724
786
|
private listNftTransfers;
|
|
725
787
|
private walkFtTransfers;
|
|
@@ -738,6 +800,9 @@ declare class Index extends BaseClient {
|
|
|
738
800
|
private walkTransactions;
|
|
739
801
|
private listStacking;
|
|
740
802
|
private walkStacking;
|
|
803
|
+
private listMempool;
|
|
804
|
+
private getMempoolTx;
|
|
805
|
+
private walkMempool;
|
|
741
806
|
}
|
|
742
807
|
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"];
|
|
743
808
|
type StreamsEventType = (typeof STREAMS_EVENT_TYPES)[number];
|
|
@@ -1555,4 +1620,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
1555
1620
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
1556
1621
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
1557
1622
|
declare function decodeClarityValue(hex: string): unknown;
|
|
1558
|
-
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, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StackingWalkParams, StackingListParams, StackingEnvelope, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, Pox4CallsParams, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, IndexTransaction, IndexTip, IndexStackingAction, IndexPostCondition, IndexEventType, IndexEvent, IndexContractCall, IndexCanonicalBlock, IndexBlock, 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, Datasets, DatasetRow, CursorListParams, CursorEnvelope, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, CURSOR_SLUGS, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiError };
|
|
1623
|
+
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, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StackingWalkParams, StackingListParams, StackingEnvelope, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, Pox4CallsParams, NftTransfersWalkParams, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexTransaction, IndexTip, IndexStackingAction, IndexPostCondition, IndexMempoolTransaction, IndexEventType, IndexEvent, IndexContractCall, IndexCanonicalBlock, IndexBlock, 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, Datasets, DatasetRow, CursorListParams, CursorEnvelope, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, CURSOR_SLUGS, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiError };
|
package/dist/index.js
CHANGED
|
@@ -507,6 +507,11 @@ class Index extends BaseClient {
|
|
|
507
507
|
list: (params = {}) => this.listStacking(params),
|
|
508
508
|
walk: (params = {}) => this.walkStacking(params)
|
|
509
509
|
};
|
|
510
|
+
mempool = {
|
|
511
|
+
list: (params = {}) => this.listMempool(params),
|
|
512
|
+
walk: (params = {}) => this.walkMempool(params),
|
|
513
|
+
get: (txId) => this.getMempoolTx(txId)
|
|
514
|
+
};
|
|
510
515
|
async listFtTransfers(params = {}) {
|
|
511
516
|
return this.request("GET", `/v1/index/ft-transfers${buildQuery({
|
|
512
517
|
cursor: params.cursor,
|
|
@@ -818,6 +823,48 @@ class Index extends BaseClient {
|
|
|
818
823
|
firstPage = false;
|
|
819
824
|
}
|
|
820
825
|
}
|
|
826
|
+
async listMempool(params = {}) {
|
|
827
|
+
return this.request("GET", `/v1/index/mempool${buildQuery({
|
|
828
|
+
cursor: params.cursor,
|
|
829
|
+
from_cursor: params.fromCursor,
|
|
830
|
+
limit: params.limit,
|
|
831
|
+
sender: params.sender,
|
|
832
|
+
type: params.type
|
|
833
|
+
})}`);
|
|
834
|
+
}
|
|
835
|
+
async getMempoolTx(txId) {
|
|
836
|
+
try {
|
|
837
|
+
return await this.request("GET", `/v1/index/mempool/${encodeURIComponent(txId)}`);
|
|
838
|
+
} catch (err) {
|
|
839
|
+
if (err instanceof ApiError && err.status === 404)
|
|
840
|
+
return null;
|
|
841
|
+
throw err;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
async* walkMempool(params = {}) {
|
|
845
|
+
const batchSize = params.batchSize ?? 200;
|
|
846
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
847
|
+
let firstPage = true;
|
|
848
|
+
while (!params.signal?.aborted) {
|
|
849
|
+
const envelope = await this.listMempool({
|
|
850
|
+
...params,
|
|
851
|
+
limit: batchSize,
|
|
852
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
853
|
+
fromCursor: firstPage ? params.fromCursor : undefined
|
|
854
|
+
});
|
|
855
|
+
for (const tx of envelope.mempool) {
|
|
856
|
+
if (params.signal?.aborted)
|
|
857
|
+
return;
|
|
858
|
+
yield tx;
|
|
859
|
+
}
|
|
860
|
+
const nextCursor = envelope.next_cursor;
|
|
861
|
+
if (!nextCursor || nextCursor === cursor || envelope.mempool.length < batchSize) {
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
cursor = nextCursor;
|
|
865
|
+
firstPage = false;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
821
868
|
}
|
|
822
869
|
|
|
823
870
|
// src/streams/client.ts
|
|
@@ -1741,5 +1788,5 @@ export {
|
|
|
1741
1788
|
ApiError
|
|
1742
1789
|
};
|
|
1743
1790
|
|
|
1744
|
-
//# debugId=
|
|
1791
|
+
//# debugId=795A191B3E98A82E64756E2164756E21
|
|
1745
1792
|
//# sourceMappingURL=index.js.map
|