@secondlayer/sdk 6.1.0 → 6.2.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 +172 -129
- package/dist/index.js +142 -120
- package/dist/index.js.map +6 -5
- package/dist/subgraphs/index.d.ts +166 -0
- package/dist/subgraphs/index.js +141 -1
- package/dist/subgraphs/index.js.map +6 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,175 @@ declare class Subgraphs extends BaseClient {
|
|
|
105
105
|
private createTableClient;
|
|
106
106
|
}
|
|
107
107
|
import { InferSubgraphClient as InferSubgraphClient2 } from "@secondlayer/subgraphs";
|
|
108
|
+
/**
|
|
109
|
+
* Typed client for the contract-discovery API (`GET /v1/contracts`).
|
|
110
|
+
*
|
|
111
|
+
* "Find all contracts conforming to a trait" — backed by the contract registry:
|
|
112
|
+
* `declared` traits parsed from Clarity source, `inferred` standards from static
|
|
113
|
+
* ABI shape-matching. Anonymous public read. `trait` is required; the ABI blob is
|
|
114
|
+
* omitted unless `include: "abi"` is passed.
|
|
115
|
+
*/
|
|
116
|
+
/** Whether a trait match must be declared in source, inferred from ABI, or either. */
|
|
117
|
+
type ContractConformance = "declared" | "inferred" | "any";
|
|
118
|
+
interface ContractsListParams {
|
|
119
|
+
/** Required. Trait identifier to match (e.g. "sip-010", or a fully-qualified trait). */
|
|
120
|
+
trait: string;
|
|
121
|
+
/** Match source. Defaults to "any" server-side. */
|
|
122
|
+
conformance?: ContractConformance;
|
|
123
|
+
/** Set to "abi" to include the full ABI blob in each row. */
|
|
124
|
+
include?: "abi";
|
|
125
|
+
/** Page size, 1–500 (default 100 server-side). */
|
|
126
|
+
limit?: number;
|
|
127
|
+
/** Opaque cursor from a prior response's `next_cursor`. */
|
|
128
|
+
cursor?: string;
|
|
129
|
+
}
|
|
130
|
+
interface ContractSummary {
|
|
131
|
+
contract_id: string;
|
|
132
|
+
deployer: string;
|
|
133
|
+
block_height: number;
|
|
134
|
+
declared_traits: string[] | null;
|
|
135
|
+
inferred_standards: string[] | null;
|
|
136
|
+
abi_status: string;
|
|
137
|
+
/** Present only when `include: "abi"` was requested. */
|
|
138
|
+
abi?: unknown;
|
|
139
|
+
}
|
|
140
|
+
interface ContractsEnvelope {
|
|
141
|
+
contracts: ContractSummary[];
|
|
142
|
+
next_cursor: string | null;
|
|
143
|
+
}
|
|
144
|
+
declare class Contracts extends BaseClient {
|
|
145
|
+
constructor(options?: Partial<SecondLayerOptions>);
|
|
146
|
+
/** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */
|
|
147
|
+
list(params: ContractsListParams): Promise<ContractsEnvelope>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Typed client for the Foundation Datasets REST API (`/v1/datasets/*`).
|
|
151
|
+
*
|
|
152
|
+
* Most datasets are cursor-paginated event lists with a uniform `list`/`walk`
|
|
153
|
+
* surface; a few (bns names/namespaces/resolve, network-health) are
|
|
154
|
+
* offset/single-object/summary and get bespoke methods. Query params are typed
|
|
155
|
+
* per dataset; rows are `DatasetRow` (JSON) in v1 — per-dataset row interfaces
|
|
156
|
+
* are a fast-follow.
|
|
157
|
+
*/
|
|
158
|
+
/** A dataset row — flat JSON object. Per-dataset interfaces are a follow-up. */
|
|
159
|
+
type DatasetRow = Record<string, unknown>;
|
|
160
|
+
/** Filters shared by every cursor-paginated dataset. */
|
|
161
|
+
interface CursorListParams {
|
|
162
|
+
cursor?: string;
|
|
163
|
+
limit?: number;
|
|
164
|
+
fromBlock?: number;
|
|
165
|
+
toBlock?: number;
|
|
166
|
+
}
|
|
167
|
+
interface CursorEnvelope {
|
|
168
|
+
rows: DatasetRow[];
|
|
169
|
+
next_cursor: string | null;
|
|
170
|
+
tip?: {
|
|
171
|
+
block_height: number
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
type RangeFilters = CursorListParams;
|
|
175
|
+
type StxTransfersParams = RangeFilters & {
|
|
176
|
+
sender?: string
|
|
177
|
+
recipient?: string
|
|
178
|
+
};
|
|
179
|
+
type SbtcEventsParams = RangeFilters & {
|
|
180
|
+
topic?: string
|
|
181
|
+
address?: string
|
|
182
|
+
};
|
|
183
|
+
type SbtcTokenEventsParams = RangeFilters & {
|
|
184
|
+
eventType?: string
|
|
185
|
+
sender?: string
|
|
186
|
+
recipient?: string
|
|
187
|
+
};
|
|
188
|
+
type Pox4CallsParams = RangeFilters & {
|
|
189
|
+
functionName?: string
|
|
190
|
+
stacker?: string
|
|
191
|
+
delegateTo?: string
|
|
192
|
+
signerKey?: string
|
|
193
|
+
rewardCycle?: number
|
|
194
|
+
/** Any-role: matches caller OR stacker OR delegate_to. */
|
|
195
|
+
address?: string
|
|
196
|
+
};
|
|
197
|
+
type BurnchainRewardsParams = RangeFilters & {
|
|
198
|
+
/** Filter to one Bitcoin reward address. */
|
|
199
|
+
recipient?: string
|
|
200
|
+
};
|
|
201
|
+
type BurnchainRewardSlotsParams = RangeFilters & {
|
|
202
|
+
/** Filter to one reward-set Bitcoin address. */
|
|
203
|
+
holder?: string
|
|
204
|
+
};
|
|
205
|
+
type BnsEventsParams = RangeFilters & {
|
|
206
|
+
topic?: string
|
|
207
|
+
namespace?: string
|
|
208
|
+
name?: string
|
|
209
|
+
owner?: string
|
|
210
|
+
};
|
|
211
|
+
type BnsNamespaceEventsParams = RangeFilters & {
|
|
212
|
+
status?: string
|
|
213
|
+
namespace?: string
|
|
214
|
+
};
|
|
215
|
+
type BnsMarketplaceEventsParams = RangeFilters & {
|
|
216
|
+
action?: string
|
|
217
|
+
bnsId?: string
|
|
218
|
+
};
|
|
219
|
+
type CursorDataset<P> = {
|
|
220
|
+
list: (params?: P) => Promise<CursorEnvelope>
|
|
221
|
+
walk: (params?: P & {
|
|
222
|
+
batchSize?: number
|
|
223
|
+
signal?: AbortSignal
|
|
224
|
+
}) => AsyncIterable<DatasetRow>
|
|
225
|
+
};
|
|
226
|
+
/** Cursor-paginated dataset slugs → REST path + envelope row key. */
|
|
227
|
+
declare const CURSOR_SLUGS: Record<string, {
|
|
228
|
+
path: string
|
|
229
|
+
rowKey: string
|
|
230
|
+
}>;
|
|
231
|
+
declare class Datasets extends BaseClient {
|
|
232
|
+
constructor(options?: Partial<SecondLayerOptions>);
|
|
233
|
+
/** Dataset catalog + freshness (the discovery endpoint). */
|
|
234
|
+
listDatasets(): Promise<unknown>;
|
|
235
|
+
/**
|
|
236
|
+
* Generic cursor query by slug — used by the CLI. Params are passed through as
|
|
237
|
+
* REST query keys (snake_case), so callers can use the documented filter names
|
|
238
|
+
* directly. Throws for non-cursor (bespoke) datasets.
|
|
239
|
+
*/
|
|
240
|
+
query(slug: string, params?: Record<string, unknown>): Promise<CursorEnvelope>;
|
|
241
|
+
readonly stxTransfers: CursorDataset<StxTransfersParams>;
|
|
242
|
+
readonly sbtcEvents: CursorDataset<SbtcEventsParams>;
|
|
243
|
+
readonly sbtcTokenEvents: CursorDataset<SbtcTokenEventsParams>;
|
|
244
|
+
readonly pox4Calls: CursorDataset<Pox4CallsParams>;
|
|
245
|
+
readonly burnchainRewards: CursorDataset<BurnchainRewardsParams>;
|
|
246
|
+
readonly burnchainRewardSlots: CursorDataset<BurnchainRewardSlotsParams>;
|
|
247
|
+
readonly bnsEvents: CursorDataset<BnsEventsParams>;
|
|
248
|
+
readonly bnsNamespaceEvents: CursorDataset<BnsNamespaceEventsParams>;
|
|
249
|
+
readonly bnsMarketplaceEvents: CursorDataset<BnsMarketplaceEventsParams>;
|
|
250
|
+
/** BNS names — offset-paginated. */
|
|
251
|
+
bnsNames(params?: {
|
|
252
|
+
namespace?: string
|
|
253
|
+
owner?: string
|
|
254
|
+
limit?: number
|
|
255
|
+
offset?: number
|
|
256
|
+
}): Promise<{
|
|
257
|
+
names: DatasetRow[]
|
|
258
|
+
}>;
|
|
259
|
+
/** All BNS namespaces (no pagination). */
|
|
260
|
+
bnsNamespaces(): Promise<{
|
|
261
|
+
namespaces: DatasetRow[]
|
|
262
|
+
}>;
|
|
263
|
+
/** Resolve a fully-qualified BNS name → single record. */
|
|
264
|
+
bnsResolve(fqn: string): Promise<{
|
|
265
|
+
name: DatasetRow | null
|
|
266
|
+
}>;
|
|
267
|
+
/** Network health summary. */
|
|
268
|
+
networkHealth(): Promise<{
|
|
269
|
+
summary: DatasetRow
|
|
270
|
+
}>;
|
|
271
|
+
private get;
|
|
272
|
+
/** Map camelCase filter fields to snake_case query keys (dropping pagination
|
|
273
|
+
* controls) and build the canonical query suffix. */
|
|
274
|
+
private paramsToQuery;
|
|
275
|
+
private cursorDataset;
|
|
276
|
+
}
|
|
108
277
|
type IndexTip = {
|
|
109
278
|
block_height: number
|
|
110
279
|
lag_seconds: number
|
|
@@ -706,6 +875,8 @@ declare class Subscriptions extends BaseClient {
|
|
|
706
875
|
declare class SecondLayer extends BaseClient {
|
|
707
876
|
readonly streams: StreamsClient;
|
|
708
877
|
readonly index: Index;
|
|
878
|
+
readonly datasets: Datasets;
|
|
879
|
+
readonly contracts: Contracts;
|
|
709
880
|
readonly subgraphs: Subgraphs;
|
|
710
881
|
readonly subscriptions: Subscriptions;
|
|
711
882
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
@@ -1040,134 +1211,6 @@ declare const Cursor: {
|
|
|
1040
1211
|
}
|
|
1041
1212
|
};
|
|
1042
1213
|
type DecodedEventRow = DecodedFtTransfer | DecodedNftTransfer | DecodedStxTransfer | DecodedStxMint | DecodedStxBurn | DecodedStxLock | DecodedFtMint | DecodedFtBurn | DecodedNftMint | DecodedNftBurn | DecodedPrint;
|
|
1043
|
-
/**
|
|
1044
|
-
* Typed client for the Foundation Datasets REST API (`/v1/datasets/*`).
|
|
1045
|
-
*
|
|
1046
|
-
* Most datasets are cursor-paginated event lists with a uniform `list`/`walk`
|
|
1047
|
-
* surface; a few (bns names/namespaces/resolve, network-health) are
|
|
1048
|
-
* offset/single-object/summary and get bespoke methods. Query params are typed
|
|
1049
|
-
* per dataset; rows are `DatasetRow` (JSON) in v1 — per-dataset row interfaces
|
|
1050
|
-
* are a fast-follow.
|
|
1051
|
-
*/
|
|
1052
|
-
/** A dataset row — flat JSON object. Per-dataset interfaces are a follow-up. */
|
|
1053
|
-
type DatasetRow = Record<string, unknown>;
|
|
1054
|
-
/** Filters shared by every cursor-paginated dataset. */
|
|
1055
|
-
interface CursorListParams {
|
|
1056
|
-
cursor?: string;
|
|
1057
|
-
limit?: number;
|
|
1058
|
-
fromBlock?: number;
|
|
1059
|
-
toBlock?: number;
|
|
1060
|
-
}
|
|
1061
|
-
interface CursorEnvelope {
|
|
1062
|
-
rows: DatasetRow[];
|
|
1063
|
-
next_cursor: string | null;
|
|
1064
|
-
tip?: {
|
|
1065
|
-
block_height: number
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
type RangeFilters = CursorListParams;
|
|
1069
|
-
type StxTransfersParams = RangeFilters & {
|
|
1070
|
-
sender?: string
|
|
1071
|
-
recipient?: string
|
|
1072
|
-
};
|
|
1073
|
-
type SbtcEventsParams = RangeFilters & {
|
|
1074
|
-
topic?: string
|
|
1075
|
-
address?: string
|
|
1076
|
-
};
|
|
1077
|
-
type SbtcTokenEventsParams = RangeFilters & {
|
|
1078
|
-
eventType?: string
|
|
1079
|
-
sender?: string
|
|
1080
|
-
recipient?: string
|
|
1081
|
-
};
|
|
1082
|
-
type Pox4CallsParams = RangeFilters & {
|
|
1083
|
-
functionName?: string
|
|
1084
|
-
stacker?: string
|
|
1085
|
-
delegateTo?: string
|
|
1086
|
-
signerKey?: string
|
|
1087
|
-
rewardCycle?: number
|
|
1088
|
-
/** Any-role: matches caller OR stacker OR delegate_to. */
|
|
1089
|
-
address?: string
|
|
1090
|
-
};
|
|
1091
|
-
type BurnchainRewardsParams = RangeFilters & {
|
|
1092
|
-
/** Filter to one Bitcoin reward address. */
|
|
1093
|
-
recipient?: string
|
|
1094
|
-
};
|
|
1095
|
-
type BurnchainRewardSlotsParams = RangeFilters & {
|
|
1096
|
-
/** Filter to one reward-set Bitcoin address. */
|
|
1097
|
-
holder?: string
|
|
1098
|
-
};
|
|
1099
|
-
type BnsEventsParams = RangeFilters & {
|
|
1100
|
-
topic?: string
|
|
1101
|
-
namespace?: string
|
|
1102
|
-
name?: string
|
|
1103
|
-
owner?: string
|
|
1104
|
-
};
|
|
1105
|
-
type BnsNamespaceEventsParams = RangeFilters & {
|
|
1106
|
-
status?: string
|
|
1107
|
-
namespace?: string
|
|
1108
|
-
};
|
|
1109
|
-
type BnsMarketplaceEventsParams = RangeFilters & {
|
|
1110
|
-
action?: string
|
|
1111
|
-
bnsId?: string
|
|
1112
|
-
};
|
|
1113
|
-
type CursorDataset<P> = {
|
|
1114
|
-
list: (params?: P) => Promise<CursorEnvelope>
|
|
1115
|
-
walk: (params?: P & {
|
|
1116
|
-
batchSize?: number
|
|
1117
|
-
signal?: AbortSignal
|
|
1118
|
-
}) => AsyncIterable<DatasetRow>
|
|
1119
|
-
};
|
|
1120
|
-
/** Cursor-paginated dataset slugs → REST path + envelope row key. */
|
|
1121
|
-
declare const CURSOR_SLUGS: Record<string, {
|
|
1122
|
-
path: string
|
|
1123
|
-
rowKey: string
|
|
1124
|
-
}>;
|
|
1125
|
-
declare class Datasets extends BaseClient {
|
|
1126
|
-
constructor(options?: Partial<SecondLayerOptions>);
|
|
1127
|
-
/** Dataset catalog + freshness (the discovery endpoint). */
|
|
1128
|
-
listDatasets(): Promise<unknown>;
|
|
1129
|
-
/**
|
|
1130
|
-
* Generic cursor query by slug — used by the CLI. Params are passed through as
|
|
1131
|
-
* REST query keys (snake_case), so callers can use the documented filter names
|
|
1132
|
-
* directly. Throws for non-cursor (bespoke) datasets.
|
|
1133
|
-
*/
|
|
1134
|
-
query(slug: string, params?: Record<string, unknown>): Promise<CursorEnvelope>;
|
|
1135
|
-
readonly stxTransfers: CursorDataset<StxTransfersParams>;
|
|
1136
|
-
readonly sbtcEvents: CursorDataset<SbtcEventsParams>;
|
|
1137
|
-
readonly sbtcTokenEvents: CursorDataset<SbtcTokenEventsParams>;
|
|
1138
|
-
readonly pox4Calls: CursorDataset<Pox4CallsParams>;
|
|
1139
|
-
readonly burnchainRewards: CursorDataset<BurnchainRewardsParams>;
|
|
1140
|
-
readonly burnchainRewardSlots: CursorDataset<BurnchainRewardSlotsParams>;
|
|
1141
|
-
readonly bnsEvents: CursorDataset<BnsEventsParams>;
|
|
1142
|
-
readonly bnsNamespaceEvents: CursorDataset<BnsNamespaceEventsParams>;
|
|
1143
|
-
readonly bnsMarketplaceEvents: CursorDataset<BnsMarketplaceEventsParams>;
|
|
1144
|
-
/** BNS names — offset-paginated. */
|
|
1145
|
-
bnsNames(params?: {
|
|
1146
|
-
namespace?: string
|
|
1147
|
-
owner?: string
|
|
1148
|
-
limit?: number
|
|
1149
|
-
offset?: number
|
|
1150
|
-
}): Promise<{
|
|
1151
|
-
names: DatasetRow[]
|
|
1152
|
-
}>;
|
|
1153
|
-
/** All BNS namespaces (no pagination). */
|
|
1154
|
-
bnsNamespaces(): Promise<{
|
|
1155
|
-
namespaces: DatasetRow[]
|
|
1156
|
-
}>;
|
|
1157
|
-
/** Resolve a fully-qualified BNS name → single record. */
|
|
1158
|
-
bnsResolve(fqn: string): Promise<{
|
|
1159
|
-
name: DatasetRow | null
|
|
1160
|
-
}>;
|
|
1161
|
-
/** Network health summary. */
|
|
1162
|
-
networkHealth(): Promise<{
|
|
1163
|
-
summary: DatasetRow
|
|
1164
|
-
}>;
|
|
1165
|
-
private get;
|
|
1166
|
-
/** Map camelCase filter fields to snake_case query keys (dropping pagination
|
|
1167
|
-
* controls) and build the canonical query suffix. */
|
|
1168
|
-
private paramsToQuery;
|
|
1169
|
-
private cursorDataset;
|
|
1170
|
-
}
|
|
1171
1214
|
import { SubgraphAgentSchema as SubgraphAgentSchema3, SubgraphSpecFormat as SubgraphSpecFormat2, SubgraphSpecOptions as SubgraphSpecOptions3 } from "@secondlayer/shared/subgraphs/spec";
|
|
1172
1215
|
/**
|
|
1173
1216
|
* Error thrown by {@link SecondLayer} when an API request fails.
|
|
@@ -1286,4 +1329,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
1286
1329
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
1287
1330
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
1288
1331
|
declare function decodeClarityValue(hex: string): unknown;
|
|
1289
|
-
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, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, Pox4CallsParams, 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, Datasets, DatasetRow, CursorListParams, CursorEnvelope, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, CURSOR_SLUGS, AuthError, ApiError };
|
|
1332
|
+
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, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, SecondLayerOptions, SecondLayer, RotateSecretResponse2 as RotateSecretResponse, ReplayResult2 as ReplayResult, RateLimitError, Pox4CallsParams, 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, Datasets, DatasetRow, CursorListParams, CursorEnvelope, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, CURSOR_SLUGS, AuthError, ApiError };
|
package/dist/index.js
CHANGED
|
@@ -324,6 +324,142 @@ class Subgraphs extends BaseClient {
|
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
// src/contracts/client.ts
|
|
328
|
+
class Contracts extends BaseClient {
|
|
329
|
+
constructor(options = {}) {
|
|
330
|
+
super(options);
|
|
331
|
+
}
|
|
332
|
+
list(params) {
|
|
333
|
+
return this.request("GET", `/v1/contracts${buildQuery({
|
|
334
|
+
trait: params.trait,
|
|
335
|
+
conformance: params.conformance,
|
|
336
|
+
include: params.include,
|
|
337
|
+
limit: params.limit,
|
|
338
|
+
cursor: params.cursor
|
|
339
|
+
})}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/datasets/client.ts
|
|
344
|
+
var PARAM_KEYS = {
|
|
345
|
+
fromBlock: "from_block",
|
|
346
|
+
toBlock: "to_block",
|
|
347
|
+
functionName: "function_name",
|
|
348
|
+
delegateTo: "delegate_to",
|
|
349
|
+
signerKey: "signer_key",
|
|
350
|
+
rewardCycle: "reward_cycle",
|
|
351
|
+
eventType: "event_type",
|
|
352
|
+
bnsId: "bns_id"
|
|
353
|
+
};
|
|
354
|
+
var CURSOR_SLUGS = {
|
|
355
|
+
"stx-transfers": { path: "stx-transfers", rowKey: "events" },
|
|
356
|
+
"sbtc-events": { path: "sbtc/events", rowKey: "events" },
|
|
357
|
+
"sbtc-token-events": { path: "sbtc/token-events", rowKey: "events" },
|
|
358
|
+
"pox-4-calls": { path: "pox-4/calls", rowKey: "calls" },
|
|
359
|
+
"burnchain-rewards": { path: "burnchain/rewards", rowKey: "rewards" },
|
|
360
|
+
"burnchain-reward-slots": {
|
|
361
|
+
path: "burnchain/reward-slots",
|
|
362
|
+
rowKey: "slots"
|
|
363
|
+
},
|
|
364
|
+
"bns-events": { path: "bns/events", rowKey: "events" },
|
|
365
|
+
"bns-namespace-events": { path: "bns/namespace-events", rowKey: "events" },
|
|
366
|
+
"bns-marketplace-events": {
|
|
367
|
+
path: "bns/marketplace-events",
|
|
368
|
+
rowKey: "events"
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
class Datasets extends BaseClient {
|
|
373
|
+
constructor(options = {}) {
|
|
374
|
+
super(options);
|
|
375
|
+
}
|
|
376
|
+
listDatasets() {
|
|
377
|
+
return this.request("GET", "/v1/datasets");
|
|
378
|
+
}
|
|
379
|
+
async query(slug, params = {}) {
|
|
380
|
+
const d = CURSOR_SLUGS[slug];
|
|
381
|
+
if (!d) {
|
|
382
|
+
throw new Error(`unknown cursor dataset "${slug}" (use one of: ${Object.keys(CURSOR_SLUGS).join(", ")})`);
|
|
383
|
+
}
|
|
384
|
+
const env = await this.get(d.path, this.paramsToQuery(params));
|
|
385
|
+
return {
|
|
386
|
+
rows: env[d.rowKey] ?? [],
|
|
387
|
+
next_cursor: env.next_cursor ?? null,
|
|
388
|
+
tip: env.tip
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
stxTransfers = this.cursorDataset("stx-transfers", "events");
|
|
392
|
+
sbtcEvents = this.cursorDataset("sbtc/events", "events");
|
|
393
|
+
sbtcTokenEvents = this.cursorDataset("sbtc/token-events", "events");
|
|
394
|
+
pox4Calls = this.cursorDataset("pox-4/calls", "calls");
|
|
395
|
+
burnchainRewards = this.cursorDataset("burnchain/rewards", "rewards");
|
|
396
|
+
burnchainRewardSlots = this.cursorDataset("burnchain/reward-slots", "slots");
|
|
397
|
+
bnsEvents = this.cursorDataset("bns/events", "events");
|
|
398
|
+
bnsNamespaceEvents = this.cursorDataset("bns/namespace-events", "events");
|
|
399
|
+
bnsMarketplaceEvents = this.cursorDataset("bns/marketplace-events", "events");
|
|
400
|
+
bnsNames(params = {}) {
|
|
401
|
+
return this.get("bns/names", buildQuery({
|
|
402
|
+
namespace: params.namespace,
|
|
403
|
+
owner: params.owner,
|
|
404
|
+
limit: params.limit,
|
|
405
|
+
offset: params.offset
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
bnsNamespaces() {
|
|
409
|
+
return this.get("bns/namespaces", "");
|
|
410
|
+
}
|
|
411
|
+
bnsResolve(fqn) {
|
|
412
|
+
return this.get("bns/resolve", buildQuery({ fqn }));
|
|
413
|
+
}
|
|
414
|
+
networkHealth() {
|
|
415
|
+
return this.get("network-health/summary", "");
|
|
416
|
+
}
|
|
417
|
+
get(path, query) {
|
|
418
|
+
return this.request("GET", `/v1/datasets/${path}${query}`);
|
|
419
|
+
}
|
|
420
|
+
paramsToQuery(params) {
|
|
421
|
+
const mapped = {};
|
|
422
|
+
for (const [k, v] of Object.entries(params)) {
|
|
423
|
+
if (v === undefined || v === null || k === "batchSize" || k === "signal")
|
|
424
|
+
continue;
|
|
425
|
+
mapped[PARAM_KEYS[k] ?? k] = v;
|
|
426
|
+
}
|
|
427
|
+
return buildQuery(mapped);
|
|
428
|
+
}
|
|
429
|
+
cursorDataset(path, rowKey) {
|
|
430
|
+
const list = async (params = {}) => {
|
|
431
|
+
const envelope = await this.get(path, this.paramsToQuery(params));
|
|
432
|
+
return {
|
|
433
|
+
rows: envelope[rowKey] ?? [],
|
|
434
|
+
next_cursor: envelope.next_cursor ?? null,
|
|
435
|
+
tip: envelope.tip
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
const walk = async function* (params = {}) {
|
|
439
|
+
const batchSize = params.batchSize ?? 200;
|
|
440
|
+
let cursor = params.cursor ?? null;
|
|
441
|
+
let first = true;
|
|
442
|
+
while (!params.signal?.aborted) {
|
|
443
|
+
const env = await list({
|
|
444
|
+
...params,
|
|
445
|
+
limit: batchSize,
|
|
446
|
+
cursor: first ? params.cursor : cursor ?? undefined
|
|
447
|
+
});
|
|
448
|
+
for (const row of env.rows) {
|
|
449
|
+
if (params.signal?.aborted)
|
|
450
|
+
return;
|
|
451
|
+
yield row;
|
|
452
|
+
}
|
|
453
|
+
if (!env.next_cursor || env.next_cursor === cursor || env.rows.length < batchSize)
|
|
454
|
+
return;
|
|
455
|
+
cursor = env.next_cursor;
|
|
456
|
+
first = false;
|
|
457
|
+
}
|
|
458
|
+
}.bind(this);
|
|
459
|
+
return { list, walk };
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
327
463
|
// src/index-api/client.ts
|
|
328
464
|
function firstWalkFromHeight(params) {
|
|
329
465
|
if (params.fromHeight !== undefined)
|
|
@@ -1017,6 +1153,8 @@ class Subscriptions extends BaseClient {
|
|
|
1017
1153
|
class SecondLayer extends BaseClient {
|
|
1018
1154
|
streams;
|
|
1019
1155
|
index;
|
|
1156
|
+
datasets;
|
|
1157
|
+
contracts;
|
|
1020
1158
|
subgraphs;
|
|
1021
1159
|
subscriptions;
|
|
1022
1160
|
constructor(options = {}) {
|
|
@@ -1027,6 +1165,8 @@ class SecondLayer extends BaseClient {
|
|
|
1027
1165
|
fetchImpl: options.fetchImpl
|
|
1028
1166
|
});
|
|
1029
1167
|
this.index = new Index(options);
|
|
1168
|
+
this.datasets = new Datasets(options);
|
|
1169
|
+
this.contracts = new Contracts(options);
|
|
1030
1170
|
this.subgraphs = new Subgraphs(options);
|
|
1031
1171
|
this.subscriptions = new Subscriptions(options);
|
|
1032
1172
|
}
|
|
@@ -1335,125 +1475,6 @@ var STREAMS_EVENT_TYPES = [
|
|
|
1335
1475
|
"nft_burn",
|
|
1336
1476
|
"print"
|
|
1337
1477
|
];
|
|
1338
|
-
// src/datasets/client.ts
|
|
1339
|
-
var PARAM_KEYS = {
|
|
1340
|
-
fromBlock: "from_block",
|
|
1341
|
-
toBlock: "to_block",
|
|
1342
|
-
functionName: "function_name",
|
|
1343
|
-
delegateTo: "delegate_to",
|
|
1344
|
-
signerKey: "signer_key",
|
|
1345
|
-
rewardCycle: "reward_cycle",
|
|
1346
|
-
eventType: "event_type",
|
|
1347
|
-
bnsId: "bns_id"
|
|
1348
|
-
};
|
|
1349
|
-
var CURSOR_SLUGS = {
|
|
1350
|
-
"stx-transfers": { path: "stx-transfers", rowKey: "events" },
|
|
1351
|
-
"sbtc-events": { path: "sbtc/events", rowKey: "events" },
|
|
1352
|
-
"sbtc-token-events": { path: "sbtc/token-events", rowKey: "events" },
|
|
1353
|
-
"pox-4-calls": { path: "pox-4/calls", rowKey: "calls" },
|
|
1354
|
-
"burnchain-rewards": { path: "burnchain/rewards", rowKey: "rewards" },
|
|
1355
|
-
"burnchain-reward-slots": {
|
|
1356
|
-
path: "burnchain/reward-slots",
|
|
1357
|
-
rowKey: "slots"
|
|
1358
|
-
},
|
|
1359
|
-
"bns-events": { path: "bns/events", rowKey: "events" },
|
|
1360
|
-
"bns-namespace-events": { path: "bns/namespace-events", rowKey: "events" },
|
|
1361
|
-
"bns-marketplace-events": {
|
|
1362
|
-
path: "bns/marketplace-events",
|
|
1363
|
-
rowKey: "events"
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
class Datasets extends BaseClient {
|
|
1368
|
-
constructor(options = {}) {
|
|
1369
|
-
super(options);
|
|
1370
|
-
}
|
|
1371
|
-
listDatasets() {
|
|
1372
|
-
return this.request("GET", "/v1/datasets");
|
|
1373
|
-
}
|
|
1374
|
-
async query(slug, params = {}) {
|
|
1375
|
-
const d = CURSOR_SLUGS[slug];
|
|
1376
|
-
if (!d) {
|
|
1377
|
-
throw new Error(`unknown cursor dataset "${slug}" (use one of: ${Object.keys(CURSOR_SLUGS).join(", ")})`);
|
|
1378
|
-
}
|
|
1379
|
-
const env = await this.get(d.path, this.paramsToQuery(params));
|
|
1380
|
-
return {
|
|
1381
|
-
rows: env[d.rowKey] ?? [],
|
|
1382
|
-
next_cursor: env.next_cursor ?? null,
|
|
1383
|
-
tip: env.tip
|
|
1384
|
-
};
|
|
1385
|
-
}
|
|
1386
|
-
stxTransfers = this.cursorDataset("stx-transfers", "events");
|
|
1387
|
-
sbtcEvents = this.cursorDataset("sbtc/events", "events");
|
|
1388
|
-
sbtcTokenEvents = this.cursorDataset("sbtc/token-events", "events");
|
|
1389
|
-
pox4Calls = this.cursorDataset("pox-4/calls", "calls");
|
|
1390
|
-
burnchainRewards = this.cursorDataset("burnchain/rewards", "rewards");
|
|
1391
|
-
burnchainRewardSlots = this.cursorDataset("burnchain/reward-slots", "slots");
|
|
1392
|
-
bnsEvents = this.cursorDataset("bns/events", "events");
|
|
1393
|
-
bnsNamespaceEvents = this.cursorDataset("bns/namespace-events", "events");
|
|
1394
|
-
bnsMarketplaceEvents = this.cursorDataset("bns/marketplace-events", "events");
|
|
1395
|
-
bnsNames(params = {}) {
|
|
1396
|
-
return this.get("bns/names", buildQuery({
|
|
1397
|
-
namespace: params.namespace,
|
|
1398
|
-
owner: params.owner,
|
|
1399
|
-
limit: params.limit,
|
|
1400
|
-
offset: params.offset
|
|
1401
|
-
}));
|
|
1402
|
-
}
|
|
1403
|
-
bnsNamespaces() {
|
|
1404
|
-
return this.get("bns/namespaces", "");
|
|
1405
|
-
}
|
|
1406
|
-
bnsResolve(fqn) {
|
|
1407
|
-
return this.get("bns/resolve", buildQuery({ fqn }));
|
|
1408
|
-
}
|
|
1409
|
-
networkHealth() {
|
|
1410
|
-
return this.get("network-health/summary", "");
|
|
1411
|
-
}
|
|
1412
|
-
get(path, query) {
|
|
1413
|
-
return this.request("GET", `/v1/datasets/${path}${query}`);
|
|
1414
|
-
}
|
|
1415
|
-
paramsToQuery(params) {
|
|
1416
|
-
const mapped = {};
|
|
1417
|
-
for (const [k, v] of Object.entries(params)) {
|
|
1418
|
-
if (v === undefined || v === null || k === "batchSize" || k === "signal")
|
|
1419
|
-
continue;
|
|
1420
|
-
mapped[PARAM_KEYS[k] ?? k] = v;
|
|
1421
|
-
}
|
|
1422
|
-
return buildQuery(mapped);
|
|
1423
|
-
}
|
|
1424
|
-
cursorDataset(path, rowKey) {
|
|
1425
|
-
const list = async (params = {}) => {
|
|
1426
|
-
const envelope = await this.get(path, this.paramsToQuery(params));
|
|
1427
|
-
return {
|
|
1428
|
-
rows: envelope[rowKey] ?? [],
|
|
1429
|
-
next_cursor: envelope.next_cursor ?? null,
|
|
1430
|
-
tip: envelope.tip
|
|
1431
|
-
};
|
|
1432
|
-
};
|
|
1433
|
-
const walk = async function* (params = {}) {
|
|
1434
|
-
const batchSize = params.batchSize ?? 200;
|
|
1435
|
-
let cursor = params.cursor ?? null;
|
|
1436
|
-
let first = true;
|
|
1437
|
-
while (!params.signal?.aborted) {
|
|
1438
|
-
const env = await list({
|
|
1439
|
-
...params,
|
|
1440
|
-
limit: batchSize,
|
|
1441
|
-
cursor: first ? params.cursor : cursor ?? undefined
|
|
1442
|
-
});
|
|
1443
|
-
for (const row of env.rows) {
|
|
1444
|
-
if (params.signal?.aborted)
|
|
1445
|
-
return;
|
|
1446
|
-
yield row;
|
|
1447
|
-
}
|
|
1448
|
-
if (!env.next_cursor || env.next_cursor === cursor || env.rows.length < batchSize)
|
|
1449
|
-
return;
|
|
1450
|
-
cursor = env.next_cursor;
|
|
1451
|
-
first = false;
|
|
1452
|
-
}
|
|
1453
|
-
}.bind(this);
|
|
1454
|
-
return { list, walk };
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
1478
|
// src/webhooks.ts
|
|
1458
1479
|
import {
|
|
1459
1480
|
verify
|
|
@@ -1536,10 +1557,11 @@ export {
|
|
|
1536
1557
|
Index,
|
|
1537
1558
|
Datasets,
|
|
1538
1559
|
Cursor,
|
|
1560
|
+
Contracts,
|
|
1539
1561
|
CURSOR_SLUGS,
|
|
1540
1562
|
AuthError,
|
|
1541
1563
|
ApiError
|
|
1542
1564
|
};
|
|
1543
1565
|
|
|
1544
|
-
//# debugId=
|
|
1566
|
+
//# debugId=C7330C1F713D815864756E2164756E21
|
|
1545
1567
|
//# sourceMappingURL=index.js.map
|