@secondlayer/sdk 6.21.1 → 6.22.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/README.md +6 -6
- package/dist/index.d.ts +27 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +26 -0
- package/dist/subgraphs/index.js +10 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -36,14 +36,14 @@ plan's tier.
|
|
|
36
36
|
|
|
37
37
|
## Mental model
|
|
38
38
|
|
|
39
|
-
- `sl.streams` reads raw ordered
|
|
40
|
-
- `sl.index` reads the decoded
|
|
39
|
+
- `sl.streams` reads raw ordered chain events from Stacks Streams.
|
|
40
|
+
- `sl.index` reads the decoded layer from Stacks Index — FT/NFT transfers, all event types (`events`), and `contractCalls`.
|
|
41
41
|
- `sl.contracts` finds deployed contracts by trait (SIP-009/010/013).
|
|
42
|
-
- `sl.subgraphs` reads app-specific
|
|
42
|
+
- `sl.subgraphs` reads app-specific tables from Stacks Subgraphs.
|
|
43
43
|
|
|
44
44
|
## Stacks Streams
|
|
45
45
|
|
|
46
|
-
Typed
|
|
46
|
+
Typed HTTP client for the raw event firehose. Reads require a bearer token (`apiKey`).
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
49
|
const tip = await sl.streams.tip();
|
|
@@ -219,7 +219,7 @@ helpers beside `src/streams/ft-transfer.ts` and export them through
|
|
|
219
219
|
|
|
220
220
|
## Stacks Index
|
|
221
221
|
|
|
222
|
-
Decoded
|
|
222
|
+
Decoded transfer events.
|
|
223
223
|
|
|
224
224
|
```typescript
|
|
225
225
|
const ftPage = await sl.index.ftTransfers.list({
|
|
@@ -316,7 +316,7 @@ Exported types: `TransactionProof`, `TransactionProofVerifyResult`, `RewardSet`.
|
|
|
316
316
|
|
|
317
317
|
## Stacks Subgraphs
|
|
318
318
|
|
|
319
|
-
Deploy and query app-specific
|
|
319
|
+
Deploy and query app-specific tables.
|
|
320
320
|
|
|
321
321
|
Subgraphs and subscriptions live on the platform API alongside Streams and Index. Deploying and managing them needs your `sk-sl_` key — no extra setup, no tenant URL.
|
|
322
322
|
|
package/dist/index.d.ts
CHANGED
|
@@ -273,6 +273,7 @@ declare class Contracts extends BaseClient {
|
|
|
273
273
|
includeAbi?: boolean
|
|
274
274
|
}): Promise<ContractSummary | null>;
|
|
275
275
|
}
|
|
276
|
+
import { InferredTopicSchema } from "@secondlayer/subgraphs";
|
|
276
277
|
import { RewardSet } from "@secondlayer/shared/node/consensus";
|
|
277
278
|
import { MerkleProofStep } from "@secondlayer/shared/node/nakamoto";
|
|
278
279
|
/**
|
|
@@ -853,6 +854,25 @@ type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
|
|
|
853
854
|
signal?: AbortSignal
|
|
854
855
|
};
|
|
855
856
|
/**
|
|
857
|
+
* Empirical per-topic print payload schema for a contract, inferred from
|
|
858
|
+
* sampled on-chain events. `topics` is sorted by count desc; `sampled` is true
|
|
859
|
+
* when the contract has more print events than the windows examined.
|
|
860
|
+
*/
|
|
861
|
+
type PrintSchemaResponse = {
|
|
862
|
+
contract_id: string
|
|
863
|
+
topics: InferredTopicSchema[]
|
|
864
|
+
sampled: boolean
|
|
865
|
+
total_events: number
|
|
866
|
+
/** True when the count hit the server-side cap (total_events is the cap). */
|
|
867
|
+
total_events_capped: boolean
|
|
868
|
+
sample: {
|
|
869
|
+
size: number
|
|
870
|
+
newest_height: number | null
|
|
871
|
+
oldest_height: number | null
|
|
872
|
+
}
|
|
873
|
+
tip: IndexTip
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
856
876
|
* `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
|
|
857
877
|
* still available: `await sl.index.ftTransfers({ contractId })`.
|
|
858
878
|
*
|
|
@@ -900,6 +920,12 @@ declare class Index extends BaseClient {
|
|
|
900
920
|
* learn what's queryable (and which types accept `trait`) instead of hardcoding.
|
|
901
921
|
*/
|
|
902
922
|
discover(): Promise<IndexDiscovery>;
|
|
923
|
+
/**
|
|
924
|
+
* Empirical per-topic print payload schema for a contract — what topics it
|
|
925
|
+
* emits and each field's observed Clarity/TS/column types. Anonymous read;
|
|
926
|
+
* 404 → null.
|
|
927
|
+
*/
|
|
928
|
+
printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
|
|
903
929
|
/** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
|
|
904
930
|
readonly ftTransfers: FtTransfersResource;
|
|
905
931
|
/** Callable: `index.nftTransfers(params)` ≡ `index.nftTransfers.list(params)`. */
|
|
@@ -2242,4 +2268,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
2242
2268
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
2243
2269
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
2244
2270
|
declare function decodeClarityValue(hex: string): unknown;
|
|
2245
|
-
export { withX402, verifyWebhookSignature, verifyTransactionProof, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createX402Client, createStreamsClient, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexReorg, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, 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, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainTriggerType, ChainTrigger, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };
|
|
2271
|
+
export { withX402, verifyWebhookSignature, verifyTransactionProof, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createX402Client, createStreamsClient, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PrintSchemaResponse, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexReorg, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, 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, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainTriggerType, ChainTrigger, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };
|
package/dist/index.js
CHANGED
|
@@ -461,6 +461,15 @@ class Index extends BaseClient {
|
|
|
461
461
|
discover() {
|
|
462
462
|
return this.request("GET", "/v1/index");
|
|
463
463
|
}
|
|
464
|
+
async printSchema(contractId) {
|
|
465
|
+
try {
|
|
466
|
+
return await this.request("GET", `/v1/index/contracts/${encodeURIComponent(contractId)}/print-schema`);
|
|
467
|
+
} catch (err) {
|
|
468
|
+
if (err instanceof ApiError && err.status === 404)
|
|
469
|
+
return null;
|
|
470
|
+
throw err;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
464
473
|
ftTransfers = Object.assign((params = {}) => this.listFtTransfers(params), {
|
|
465
474
|
list: (params = {}) => this.listFtTransfers(params),
|
|
466
475
|
walk: (params = {}) => this.walkFtTransfers(params)
|
|
@@ -2394,5 +2403,5 @@ export {
|
|
|
2394
2403
|
ApiError
|
|
2395
2404
|
};
|
|
2396
2405
|
|
|
2397
|
-
//# debugId=
|
|
2406
|
+
//# debugId=E3A93F3CA875072D64756E2164756E21
|
|
2398
2407
|
//# sourceMappingURL=index.js.map
|