@secondlayer/sdk 10.4.0 → 10.4.2
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 +0 -46
- package/dist/index.d.ts +3 -32
- package/dist/index.js +1 -7
- package/dist/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +0 -7
- package/dist/subgraphs/index.js +1 -6
- package/dist/subgraphs/index.js.map +4 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -595,52 +595,6 @@ verifySecondlayerSignature(
|
|
|
595
595
|
Prefer the per-webhook HMAC (Standard Webhooks) secret instead? Use
|
|
596
596
|
`verifyWebhookSignature(rawBody, headers, secret)` — raw body first.
|
|
597
597
|
|
|
598
|
-
## x402 pay-per-call (accountless)
|
|
599
|
-
|
|
600
|
-
Call the public `/v1/*` reads with **no API key, no account, no Stripe** — pay a
|
|
601
|
-
few hundredths of a cent per request from a Stacks wallet. Payment is **gasless**
|
|
602
|
-
(you sign; we sponsor the STX fee) and uses standard **x402 v2** on `stacks:1`.
|
|
603
|
-
Supported assets: **sBTC** (default), **USDCx**, **STX**.
|
|
604
|
-
|
|
605
|
-
> Keyed (`INSTANCE_TOKEN`) requests skip x402. The rail is for accountless
|
|
606
|
-
> callers on an instance that has it enabled.
|
|
607
|
-
|
|
608
|
-
Drop-in `fetch` that pays on `402` automatically:
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
import { withX402, readX402Receipt } from "@secondlayer/sdk";
|
|
612
|
-
import { privateKeyToAccount } from "@secondlayer/stacks/accounts";
|
|
613
|
-
|
|
614
|
-
const x402fetch = withX402(fetch, {
|
|
615
|
-
account: privateKeyToAccount(process.env.AGENT_STACKS_KEY!), // funded with sBTC/USDCx
|
|
616
|
-
preferAssets: ["sBTC", "USDCx", "STX"], // optional (this is the default)
|
|
617
|
-
maxAmountPerCall: { sBTC: 2000n }, // optional spend guard (atomic units)
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
const res = await x402fetch(
|
|
621
|
-
"http://127.0.0.1:3800/v1/index/events?event_type=ft_transfer",
|
|
622
|
-
);
|
|
623
|
-
const data = await res.json();
|
|
624
|
-
readX402Receipt(res); // { success, txid, payer, network } | null
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
Or a small client returning `{ data, payment }`:
|
|
628
|
-
|
|
629
|
-
```typescript
|
|
630
|
-
import { createX402Client } from "@secondlayer/sdk";
|
|
631
|
-
|
|
632
|
-
const sl = createX402Client({ account }); // baseUrl defaults to http://127.0.0.1:3800
|
|
633
|
-
const { data, payment } = await sl.get("/v1/index/events", {
|
|
634
|
-
query: { event_type: "ft_transfer" },
|
|
635
|
-
});
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
The SDK selects an offer by `preferAssets` (skipping any over `maxAmountPerCall`,
|
|
639
|
-
else throws `X402SpendGuardError`), auto-resolves your account nonce, signs
|
|
640
|
-
origin-only, and retries. A paid call settles on-chain before returning
|
|
641
|
-
(confirmed-tier today, ~seconds; near-instant optimistic serve for Index/Streams
|
|
642
|
-
is rolling out). Discover capabilities at `GET /x402/supported`.
|
|
643
|
-
|
|
644
598
|
## Error Handling
|
|
645
599
|
|
|
646
600
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -2564,27 +2564,9 @@ declare class Index extends BaseClient {
|
|
|
2564
2564
|
private walkPoxCycles;
|
|
2565
2565
|
private getPoxCycle;
|
|
2566
2566
|
}
|
|
2567
|
-
import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookDetail,
|
|
2568
|
-
import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookDetail as WebhookDetail2, WebhookFormat
|
|
2567
|
+
import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
|
|
2568
|
+
import { ChainTrigger, ChainTriggerType, CreateWebhookRequest as CreateWebhookRequest2, CreateWebhookResponse as CreateWebhookResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, WebhookDetail as WebhookDetail2, WebhookFormat, WebhookKind, WebhookRuntime, WebhookStatus, WebhookSummary as WebhookSummary2, WebhookTestResult as WebhookTestResult2, UpdateWebhookRequest as UpdateWebhookRequest2 } from "@secondlayer/shared/schemas/webhooks";
|
|
2569
2569
|
import { trigger } from "@secondlayer/shared/schemas/webhooks";
|
|
2570
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2571
|
-
type CreateSubscriptionRequest = CreateWebhookRequest;
|
|
2572
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2573
|
-
type CreateSubscriptionResponse = CreateWebhookResponse;
|
|
2574
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2575
|
-
type UpdateSubscriptionRequest = UpdateWebhookRequest;
|
|
2576
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2577
|
-
type SubscriptionDetail = WebhookDetail;
|
|
2578
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2579
|
-
type SubscriptionSummary = WebhookSummary;
|
|
2580
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2581
|
-
type SubscriptionFormat = WebhookFormat;
|
|
2582
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2583
|
-
type SubscriptionKind = WebhookKind;
|
|
2584
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2585
|
-
type SubscriptionRuntime = WebhookRuntime;
|
|
2586
|
-
/** @deprecated Use webhook type. Removed next minor. */
|
|
2587
|
-
type SubscriptionStatus = WebhookStatus;
|
|
2588
2570
|
declare class Webhooks extends BaseClient {
|
|
2589
2571
|
list(): Promise<{
|
|
2590
2572
|
data: WebhookSummary[];
|
|
@@ -2620,10 +2602,6 @@ declare class Webhooks extends BaseClient {
|
|
|
2620
2602
|
ok: true;
|
|
2621
2603
|
}>;
|
|
2622
2604
|
}
|
|
2623
|
-
/** @deprecated Use {@link Webhooks}. Removed in the next minor. */
|
|
2624
|
-
declare const Subscriptions: typeof Webhooks;
|
|
2625
|
-
/** @deprecated Use {@link Webhooks}. Removed in the next minor. */
|
|
2626
|
-
type Subscriptions = Webhooks;
|
|
2627
2605
|
interface ContextAccount {
|
|
2628
2606
|
email: string;
|
|
2629
2607
|
}
|
|
@@ -2669,11 +2647,6 @@ interface ContextSnapshot {
|
|
|
2669
2647
|
count: number;
|
|
2670
2648
|
byStatus: Record<string, number>;
|
|
2671
2649
|
}>;
|
|
2672
|
-
/** @deprecated Use {@link ContextSnapshot.webhooks}. Removed next minor. */
|
|
2673
|
-
subscriptions: ContextField<{
|
|
2674
|
-
count: number;
|
|
2675
|
-
byStatus: Record<string, number>;
|
|
2676
|
-
}>;
|
|
2677
2650
|
/** In-flight reindex operations (bounded to subgraphs reporting `reindexing`). */
|
|
2678
2651
|
activeOperations: ContextField<ActiveSubgraphOperation[]>;
|
|
2679
2652
|
/** Decoder lag / empty-index from `GET /public/status`. */
|
|
@@ -2691,8 +2664,6 @@ declare class SecondLayer extends BaseClient {
|
|
|
2691
2664
|
readonly webhooks: Webhooks;
|
|
2692
2665
|
readonly archive: SecondLayerArchive;
|
|
2693
2666
|
readonly instance: InstanceClient;
|
|
2694
|
-
/** @deprecated Use `webhooks`. Removed next minor. */
|
|
2695
|
-
get subscriptions(): Webhooks;
|
|
2696
2667
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
2697
2668
|
/**
|
|
2698
2669
|
* Up to 10 public reads in one round trip (`POST /v1/batch`). Each item
|
|
@@ -3165,4 +3136,4 @@ declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHea
|
|
|
3165
3136
|
declare function decodeChainWebhook(rawBody: string): ChainWebhookDelivery;
|
|
3166
3137
|
import { RewardSet as RewardSet2 } from "@secondlayer/shared/node/consensus";
|
|
3167
3138
|
import { decodeClarityValue, toJsonSafe } from "@secondlayer/shared/streams-rows";
|
|
3168
|
-
export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, resolveAccountKey, parseRetryAfter, 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, decodeChainWebhook, decode, createStreamsClient, createArchiveClient, contextField, consumerHealth, consumeIndexFeed, WithSinkTx, Webhooks, WebhookTestResult2 as WebhookTestResult, WebhookSummary2 as WebhookSummary,
|
|
3139
|
+
export { verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, shutdownSignal, resolveBaseUrl, resolveApiKey, resolveAccountKey, parseRetryAfter, 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, decodeChainWebhook, decode, createStreamsClient, createArchiveClient, contextField, consumerHealth, consumeIndexFeed, WithSinkTx, Webhooks, WebhookTestResult2 as WebhookTestResult, WebhookSummary2 as WebhookSummary, WebhookStatus, WebhookRuntime, WebhookKind, WebhookHeaderInput, WebhookFormat, WebhookDetail2 as WebhookDetail, WalkOptions, ValidationError, UpdateWebhookRequest2 as UpdateWebhookRequest, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsTip, StreamsSubscription, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SinkTx, SecondLayerOptions, SecondLayerErrorOptions, SecondLayerError, SecondLayerArchive, SecondLayer, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventsConsumeParams, SbtcEventTopic2 as SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositsConsumeParams, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, RequestOptions, ReplayResult2 as ReplayResult, RateLimitError, PublicStatus2 as PublicStatus, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload2 as NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, LoadedArchive, LOCAL_API_URL, InsufficientArchiveCreditsError, InstanceStatus, InstanceState, InstanceIssue, InstanceDiagnosis3 as InstanceDiagnosis, InstanceClient, IndexTransaction, IndexTip, IndexStxTransfer, IndexStxMint, IndexStxLock, IndexStxBurn, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPrint, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexNftTransfer, IndexNftMint, IndexNftBurn, IndexMempoolTransaction, IndexFtTransfer, IndexFtMint, IndexFtBurn, IndexFeedItem, IndexFeedFetcher, IndexFeedEnvelope, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEventOf, IndexEventFields, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, IndexAlwaysFields, Index, INSTANCE_TOKEN_ENV, INDEX_MAX_PAGE_SIZE, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload2 as FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, 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_REQUEST_TIMEOUT_MS, Cursor, CreateWebhookResponse2 as CreateWebhookResponse, CreateWebhookRequest2 as CreateWebhookRequest, CreateArchiveClientOptions, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextFieldError, ContextField, ContextAccount, ConsumerSink, ConsumerHealth, ConsumerBatchContext, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ArchiveVerifyResult, ArchiveVerifyRangeStatus, ArchiveVerifyInput, ArchiveStatus, ArchiveSignatureError, ArchiveQuote, ArchivePartition, ArchiveManifest, ArchiveLoadOptions, ArchiveGateNotConfiguredError, ArchiveFlow, ArchiveFetchResult, ArchiveFetchItem, ArchiveDataset, ArchiveCreditsBalance, ArchiveClient, ArchiveAuthError, ApiError, ActiveSubgraphOperation, ACCOUNT_KEY_ENV };
|
package/dist/index.js
CHANGED
|
@@ -2492,7 +2492,6 @@ class Webhooks extends BaseClient {
|
|
|
2492
2492
|
return this.request("POST", `/api/webhooks/${seg(id)}/dead/${seg(outboxId)}/requeue`);
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
|
-
var Subscriptions = Webhooks;
|
|
2496
2495
|
|
|
2497
2496
|
// src/client.ts
|
|
2498
2497
|
async function contextField(read) {
|
|
@@ -2528,9 +2527,6 @@ class SecondLayer extends BaseClient {
|
|
|
2528
2527
|
webhooks;
|
|
2529
2528
|
archive;
|
|
2530
2529
|
instance;
|
|
2531
|
-
get subscriptions() {
|
|
2532
|
-
return this.webhooks;
|
|
2533
|
-
}
|
|
2534
2530
|
constructor(options = {}) {
|
|
2535
2531
|
super(options);
|
|
2536
2532
|
this.streams = createStreamsClient({
|
|
@@ -2620,7 +2616,6 @@ class SecondLayer extends BaseClient {
|
|
|
2620
2616
|
},
|
|
2621
2617
|
subgraphs,
|
|
2622
2618
|
webhooks,
|
|
2623
|
-
subscriptions: webhooks,
|
|
2624
2619
|
activeOperations,
|
|
2625
2620
|
instance
|
|
2626
2621
|
};
|
|
@@ -2911,7 +2906,6 @@ export {
|
|
|
2911
2906
|
consumeIndexFeed,
|
|
2912
2907
|
Webhooks,
|
|
2913
2908
|
ValidationError,
|
|
2914
|
-
Subscriptions,
|
|
2915
2909
|
Subgraphs,
|
|
2916
2910
|
StreamsSignatureError,
|
|
2917
2911
|
StreamsServerError,
|
|
@@ -2934,5 +2928,5 @@ export {
|
|
|
2934
2928
|
ACCOUNT_KEY_ENV
|
|
2935
2929
|
};
|
|
2936
2930
|
|
|
2937
|
-
//# debugId=
|
|
2931
|
+
//# debugId=139DE2F111FF826D64756E2164756E21
|
|
2938
2932
|
//# sourceMappingURL=index.js.map
|