@secondlayer/sdk 6.3.0 → 6.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 +68 -1
- package/dist/index.js +49 -1
- package/dist/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +67 -0
- package/dist/subgraphs/index.js +49 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -676,6 +676,63 @@ 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
|
+
/** Filter to pending calls to a single contract (e.g. `SP….contract`). */
|
|
730
|
+
contractId?: string
|
|
731
|
+
};
|
|
732
|
+
type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
|
|
733
|
+
batchSize?: number
|
|
734
|
+
signal?: AbortSignal
|
|
735
|
+
};
|
|
679
736
|
declare class Index extends BaseClient {
|
|
680
737
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
681
738
|
readonly ftTransfers: {
|
|
@@ -720,6 +777,13 @@ declare class Index extends BaseClient {
|
|
|
720
777
|
list: (params?: StackingListParams) => Promise<StackingEnvelope>
|
|
721
778
|
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
|
|
722
779
|
};
|
|
780
|
+
/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
|
|
781
|
+
* tx_id (resolves to null when the tx has confirmed or dropped). */
|
|
782
|
+
readonly mempool: {
|
|
783
|
+
list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
|
|
784
|
+
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
|
|
785
|
+
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
|
|
786
|
+
};
|
|
723
787
|
private listFtTransfers;
|
|
724
788
|
private listNftTransfers;
|
|
725
789
|
private walkFtTransfers;
|
|
@@ -738,6 +802,9 @@ declare class Index extends BaseClient {
|
|
|
738
802
|
private walkTransactions;
|
|
739
803
|
private listStacking;
|
|
740
804
|
private walkStacking;
|
|
805
|
+
private listMempool;
|
|
806
|
+
private getMempoolTx;
|
|
807
|
+
private walkMempool;
|
|
741
808
|
}
|
|
742
809
|
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
810
|
type StreamsEventType = (typeof STREAMS_EVENT_TYPES)[number];
|
|
@@ -1555,4 +1622,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
1555
1622
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
1556
1623
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
1557
1624
|
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 };
|
|
1625
|
+
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,49 @@ 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
|
+
contract_id: params.contractId
|
|
834
|
+
})}`);
|
|
835
|
+
}
|
|
836
|
+
async getMempoolTx(txId) {
|
|
837
|
+
try {
|
|
838
|
+
return await this.request("GET", `/v1/index/mempool/${encodeURIComponent(txId)}`);
|
|
839
|
+
} catch (err) {
|
|
840
|
+
if (err instanceof ApiError && err.status === 404)
|
|
841
|
+
return null;
|
|
842
|
+
throw err;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
async* walkMempool(params = {}) {
|
|
846
|
+
const batchSize = params.batchSize ?? 200;
|
|
847
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
848
|
+
let firstPage = true;
|
|
849
|
+
while (!params.signal?.aborted) {
|
|
850
|
+
const envelope = await this.listMempool({
|
|
851
|
+
...params,
|
|
852
|
+
limit: batchSize,
|
|
853
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
854
|
+
fromCursor: firstPage ? params.fromCursor : undefined
|
|
855
|
+
});
|
|
856
|
+
for (const tx of envelope.mempool) {
|
|
857
|
+
if (params.signal?.aborted)
|
|
858
|
+
return;
|
|
859
|
+
yield tx;
|
|
860
|
+
}
|
|
861
|
+
const nextCursor = envelope.next_cursor;
|
|
862
|
+
if (!nextCursor || nextCursor === cursor || envelope.mempool.length < batchSize) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
cursor = nextCursor;
|
|
866
|
+
firstPage = false;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
821
869
|
}
|
|
822
870
|
|
|
823
871
|
// src/streams/client.ts
|
|
@@ -1741,5 +1789,5 @@ export {
|
|
|
1741
1789
|
ApiError
|
|
1742
1790
|
};
|
|
1743
1791
|
|
|
1744
|
-
//# debugId=
|
|
1792
|
+
//# debugId=40E154374B2B1ACD64756E2164756E21
|
|
1745
1793
|
//# sourceMappingURL=index.js.map
|