@secondlayer/stacks 2.21.1 → 3.0.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.
Files changed (72) hide show
  1. package/README.md +6 -5
  2. package/dist/shared/stacks-2p9cazp7.cjs +263 -0
  3. package/dist/shared/stacks-2p9cazp7.cjs.map +12 -0
  4. package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
  5. package/dist/shared/{stacks-cdvn8qbh.cjs → stacks-b221qkst.cjs} +4 -3
  6. package/dist/shared/stacks-b221qkst.cjs.map +10 -0
  7. package/dist/shared/{stacks-0x50nn01.cjs → stacks-byyex2zk.cjs} +3 -2
  8. package/dist/shared/{stacks-0x50nn01.cjs.map → stacks-byyex2zk.cjs.map} +2 -2
  9. package/dist/shared/{stacks-rb9shyk8.js → stacks-ch5vshcd.js} +4 -4
  10. package/dist/shared/stacks-ch5vshcd.js.map +10 -0
  11. package/dist/shared/{stacks-f0hfqaj5.js → stacks-cyeajysa.js} +2 -2
  12. package/dist/shared/{stacks-msmgyerb.js → stacks-r2yw4xzb.js} +4 -3
  13. package/dist/shared/stacks-r2yw4xzb.js.map +10 -0
  14. package/dist/shared/stacks-tqrws7kd.js +252 -0
  15. package/dist/shared/stacks-tqrws7kd.js.map +12 -0
  16. package/dist/src/accounts/index.js +1 -2
  17. package/dist/src/accounts/index.js.map +2 -2
  18. package/dist/src/actions/index.cjs +3 -1
  19. package/dist/src/actions/index.cjs.map +1 -1
  20. package/dist/src/actions/index.d.cts +16 -1
  21. package/dist/src/actions/index.d.ts +16 -1
  22. package/dist/src/actions/index.js +9 -6
  23. package/dist/src/actions/index.js.map +1 -1
  24. package/dist/src/bitcoin/index.js +2 -3
  25. package/dist/src/bitcoin/index.js.map +2 -2
  26. package/dist/src/bns/index.js +3 -4
  27. package/dist/src/bns/index.js.map +2 -2
  28. package/dist/src/chains/index.js +1 -2
  29. package/dist/src/chains/index.js.map +1 -1
  30. package/dist/src/clarity/index.d.cts +3 -1
  31. package/dist/src/clarity/index.d.ts +3 -1
  32. package/dist/src/clarity/index.js +3 -2
  33. package/dist/src/clarity/index.js.map +1 -1
  34. package/dist/src/filters/index.cjs +1 -261
  35. package/dist/src/filters/index.cjs.map +3 -6
  36. package/dist/src/filters/index.js +13 -249
  37. package/dist/src/filters/index.js.map +3 -6
  38. package/dist/src/index.cjs +2 -75
  39. package/dist/src/index.cjs.map +3 -8
  40. package/dist/src/index.d.cts +389 -164
  41. package/dist/src/index.d.ts +389 -164
  42. package/dist/src/index.js +7 -80
  43. package/dist/src/index.js.map +3 -8
  44. package/dist/src/postconditions/index.js +1 -2
  45. package/dist/src/postconditions/index.js.map +1 -1
  46. package/dist/src/pox/index.js +3 -4
  47. package/dist/src/pox/index.js.map +2 -2
  48. package/dist/src/pox5/index.js +4 -5
  49. package/dist/src/pox5/index.js.map +2 -2
  50. package/dist/src/sbtc/index.js +3 -4
  51. package/dist/src/sbtc/index.js.map +2 -2
  52. package/dist/src/stackingdao/index.js +3 -4
  53. package/dist/src/stackingdao/index.js.map +2 -2
  54. package/dist/src/subscriptions/index.js +1 -2
  55. package/dist/src/subscriptions/index.js.map +1 -1
  56. package/dist/src/tools/index.cjs +3 -2
  57. package/dist/src/tools/index.cjs.map +4 -4
  58. package/dist/src/tools/index.js +3 -2
  59. package/dist/src/tools/index.js.map +4 -4
  60. package/dist/src/transactions/index.js +1 -2
  61. package/dist/src/transactions/index.js.map +1 -1
  62. package/dist/src/utils/index.js +1 -2
  63. package/dist/src/utils/index.js.map +2 -2
  64. package/dist/src/x402/index.js +1 -2
  65. package/dist/src/x402/index.js.map +2 -2
  66. package/package.json +4 -2
  67. package/dist/shared/stacks-cdvn8qbh.cjs.map +0 -10
  68. package/dist/shared/stacks-cfazrteq.js +0 -20
  69. package/dist/shared/stacks-cfazrteq.js.map +0 -9
  70. package/dist/shared/stacks-msmgyerb.js.map +0 -10
  71. package/dist/shared/stacks-rb9shyk8.js.map +0 -10
  72. /package/dist/shared/{stacks-f0hfqaj5.js.map → stacks-cyeajysa.js.map} +0 -0
@@ -1,3 +1,385 @@
1
+ declare const DECODED_EVENT_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "print"];
2
+ type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];
3
+ /** Every chain-event filter member across all four surfaces: the 10 decoded
4
+ * token/STX types, the three contract-shaped types (spelled as subgraphs and
5
+ * triggers spell them — Index/Streams project `print_event` → `print`), and
6
+ * the five sBTC lifecycle types (Subscriptions-only). */
7
+ declare const CHAIN_EVENT_FILTER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed"];
8
+ type ChainEventFilterType = (typeof CHAIN_EVENT_FILTER_TYPES)[number];
9
+ /** C32-encoded address version bytes for single-sig and multi-sig on each network. */
10
+ declare const AddressVersion: {
11
+ readonly MainnetSingleSig: 22
12
+ readonly MainnetMultiSig: 20
13
+ readonly TestnetSingleSig: 26
14
+ readonly TestnetMultiSig: 21
15
+ };
16
+ type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
17
+ /** Mainnet burn address (all-zero hash160). */
18
+ declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
19
+ /** Testnet burn address (all-zero hash160). */
20
+ declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
21
+ /** Number of microSTX per 1 STX (10^6). */
22
+ declare const MICROSTX_PER_STX = 1000000n;
23
+ type AbiUInt128 = "uint128";
24
+ type AbiInt128 = "int128";
25
+ type AbiBool = "bool";
26
+ type AbiPrincipal = "principal";
27
+ type AbiTraitReference = "trait_reference";
28
+ type AbiNone = "none";
29
+ type AbiStringAscii<L extends number = number> = {
30
+ "string-ascii": {
31
+ length: L
32
+ }
33
+ };
34
+ type AbiStringUtf8<L extends number = number> = {
35
+ "string-utf8": {
36
+ length: L
37
+ }
38
+ };
39
+ type AbiBuffer<L extends number = number> = {
40
+ buff: {
41
+ length: L
42
+ }
43
+ };
44
+ type AbiPrimitiveType = AbiUInt128 | AbiInt128 | AbiBool | AbiPrincipal | AbiTraitReference | AbiNone | AbiStringAscii | AbiStringUtf8 | AbiBuffer;
45
+ interface AbiListType {
46
+ list: {
47
+ type: AbiType
48
+ length: number
49
+ };
50
+ }
51
+ interface AbiTupleType {
52
+ tuple: ReadonlyArray<{
53
+ name: string
54
+ type: AbiType
55
+ }>;
56
+ }
57
+ interface AbiOptionalType {
58
+ optional: AbiType;
59
+ }
60
+ interface AbiResponseType {
61
+ response: {
62
+ ok: AbiType
63
+ error: AbiType
64
+ };
65
+ }
66
+ /** Discriminated union of all Clarity value types (primitives, buffers, lists, tuples, optionals, responses). */
67
+ type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
68
+ type FunctionAccess = "public" | "read-only" | "private";
69
+ interface FunctionArg {
70
+ name: string;
71
+ type: AbiType;
72
+ }
73
+ /** A single Clarity function definition with name, access level, arguments, and return type. */
74
+ interface AbiFunction {
75
+ name: string;
76
+ access: FunctionAccess;
77
+ args: ReadonlyArray<FunctionArg>;
78
+ outputs: AbiType;
79
+ }
80
+ type VariableAccess = "constant" | "variable";
81
+ interface AbiVariable {
82
+ name: string;
83
+ type: AbiType;
84
+ access: VariableAccess;
85
+ }
86
+ interface AbiMap {
87
+ name: string;
88
+ key: AbiType;
89
+ value: AbiType;
90
+ }
91
+ interface AbiFungibleToken {
92
+ name: string;
93
+ }
94
+ interface AbiNonFungibleToken {
95
+ name: string;
96
+ type: AbiType;
97
+ }
98
+ type TraitFunctionAccess = Exclude<FunctionAccess, "private">;
99
+ interface AbiTraitFunction {
100
+ name: string;
101
+ access: TraitFunctionAccess;
102
+ args: ReadonlyArray<FunctionArg>;
103
+ outputs: AbiType;
104
+ }
105
+ interface AbiTraitDefinition {
106
+ name: string;
107
+ functions: ReadonlyArray<AbiTraitFunction>;
108
+ }
109
+ /** Full Clarity contract ABI including functions, maps, variables, and token definitions. */
110
+ interface AbiContract {
111
+ functions: ReadonlyArray<AbiFunction>;
112
+ maps?: ReadonlyArray<AbiMap>;
113
+ variables?: ReadonlyArray<AbiVariable>;
114
+ fungible_tokens?: ReadonlyArray<AbiFungibleToken>;
115
+ non_fungible_tokens?: ReadonlyArray<AbiNonFungibleToken>;
116
+ implemented_traits?: ReadonlyArray<string>;
117
+ defined_traits?: ReadonlyArray<AbiTraitDefinition>;
118
+ }
119
+ /** Scalar print field types (structural mirror of the subgraphs `ColumnType`). */
120
+ type PrintScalarType = "uint" | "int" | "text" | "principal" | "boolean" | "timestamp" | "jsonb";
121
+ /**
122
+ * One declared print field — structural mirror of `PrintField` in
123
+ * `@secondlayer/subgraphs`. Composite forms exist because real print payloads
124
+ * nest: a vocabulary that could only say `"jsonb"` is what let a flat-field
125
+ * declaration type-check while every event decoded to null.
126
+ *
127
+ * Kept literal through `toSubgraphSource()` so handler narrowing survives.
128
+ */
129
+ type PrintFieldType = PrintScalarType | {
130
+ type: PrintFieldType
131
+ optional: true
132
+ } | {
133
+ tuple: Record<string, PrintFieldType>
134
+ } | {
135
+ list: PrintFieldType
136
+ };
137
+ interface StxTransferSpec {
138
+ type: "stx_transfer";
139
+ sender?: string;
140
+ recipient?: string;
141
+ minAmount?: bigint;
142
+ maxAmount?: bigint;
143
+ }
144
+ interface StxMintSpec {
145
+ type: "stx_mint";
146
+ recipient?: string;
147
+ minAmount?: bigint;
148
+ }
149
+ interface StxBurnSpec {
150
+ type: "stx_burn";
151
+ sender?: string;
152
+ minAmount?: bigint;
153
+ }
154
+ interface StxLockSpec {
155
+ type: "stx_lock";
156
+ lockedAddress?: string;
157
+ minAmount?: bigint;
158
+ }
159
+ /** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
160
+ * of a fixed contract. Index + Subgraphs + Subscriptions; Streams has no
161
+ * trait resolution — `toStreamsParams()` throws if set. */
162
+ type TraitScope = {
163
+ trait?: string
164
+ };
165
+ interface FtTransferSpec extends TraitScope {
166
+ type: "ft_transfer";
167
+ assetIdentifier?: string;
168
+ sender?: string;
169
+ recipient?: string;
170
+ minAmount?: bigint;
171
+ }
172
+ interface FtMintSpec extends TraitScope {
173
+ type: "ft_mint";
174
+ assetIdentifier?: string;
175
+ recipient?: string;
176
+ minAmount?: bigint;
177
+ }
178
+ interface FtBurnSpec extends TraitScope {
179
+ type: "ft_burn";
180
+ assetIdentifier?: string;
181
+ sender?: string;
182
+ minAmount?: bigint;
183
+ }
184
+ interface NftTransferSpec extends TraitScope {
185
+ type: "nft_transfer";
186
+ assetIdentifier?: string;
187
+ sender?: string;
188
+ recipient?: string;
189
+ }
190
+ interface NftMintSpec extends TraitScope {
191
+ type: "nft_mint";
192
+ assetIdentifier?: string;
193
+ recipient?: string;
194
+ }
195
+ interface NftBurnSpec extends TraitScope {
196
+ type: "nft_burn";
197
+ assetIdentifier?: string;
198
+ sender?: string;
199
+ }
200
+ interface ContractCallSpec extends TraitScope {
201
+ type: "contract_call";
202
+ /** One contract id, or a set of them (max 20). Mirrors the subgraphs
203
+ * filter — a router plus its pools is one source, not N. */
204
+ contractId?: string | readonly string[];
205
+ functionName?: string;
206
+ caller?: string;
207
+ /** Contract ABI (`as const`) — preserved literally so `toSubgraphSource()`
208
+ * keeps typing `event.input` in `defineSubgraph`. */
209
+ abi?: AbiContract;
210
+ }
211
+ interface ContractDeploySpec {
212
+ type: "contract_deploy";
213
+ deployer?: string;
214
+ contractName?: string;
215
+ }
216
+ interface PrintEventSpec extends TraitScope {
217
+ type: "print_event";
218
+ /** One contract id, or a set of them (max 20). */
219
+ contractId?: string | readonly string[];
220
+ topic?: string;
221
+ /** Per-topic field schema — preserved literally so `toSubgraphSource()`
222
+ * keeps the discriminated-union narrowing of `event.data`. */
223
+ prints?: Record<string, Record<string, PrintFieldType>>;
224
+ }
225
+ interface SbtcDepositSpec {
226
+ type: "sbtc_deposit";
227
+ sender?: string;
228
+ minAmount?: bigint;
229
+ maxAmount?: bigint;
230
+ bitcoinTxid?: string;
231
+ requestId?: number;
232
+ }
233
+ interface SbtcWithdrawalCreateSpec {
234
+ type: "sbtc_withdrawal_create";
235
+ sender?: string;
236
+ minAmount?: bigint;
237
+ maxAmount?: bigint;
238
+ requestId?: number;
239
+ }
240
+ interface SbtcWithdrawalAcceptSpec {
241
+ type: "sbtc_withdrawal_accept";
242
+ requestId?: number;
243
+ sweepTxid?: string;
244
+ }
245
+ interface SbtcWithdrawalRejectSpec {
246
+ type: "sbtc_withdrawal_reject";
247
+ requestId?: number;
248
+ }
249
+ interface SbtcWithdrawalSweptConfirmedSpec {
250
+ type: "sbtc_withdrawal_swept_confirmed";
251
+ requestId?: number;
252
+ sweepTxid?: string;
253
+ }
254
+ type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
255
+ type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
256
+ type: T
257
+ }>;
258
+ /** Wire shape of a chain trigger (Subscriptions), derived per member from
259
+ * the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
260
+ * JS safe integers) and the type-only `abi`/`prints` decorations dropped.
261
+ * Structurally assignable to the SDK's `ChainTrigger` union. */
262
+ type ChainTriggerOf<S> = { [K in keyof Omit<S, "abi" | "prints">] : Exclude<S[K], bigint | readonly string[]> | (bigint extends S[K] ? string : never) };
263
+ /** Params fragment for `index.events.*` (spread into list/walk/consume). */
264
+ type IndexEventsParamsShape = {
265
+ eventType: DecodedEventType
266
+ contractId?: string
267
+ assetIdentifier?: string
268
+ sender?: string
269
+ recipient?: string
270
+ trait?: string
271
+ };
272
+ /** Params fragment for `index.contractCalls.*`. */
273
+ type ContractCallsParamsShape = {
274
+ contractId?: string
275
+ functionName?: string
276
+ sender?: string
277
+ trait?: string
278
+ };
279
+ /** Params fragment for `streams.events.*`. */
280
+ type StreamsParamsShape = {
281
+ types: readonly DecodedEventType[]
282
+ contractId?: string
283
+ sender?: string
284
+ recipient?: string
285
+ assetIdentifier?: string
286
+ };
287
+ type DecodedMember = "stx_transfer" | "stx_mint" | "stx_burn" | "stx_lock" | "ft_transfer" | "ft_mint" | "ft_burn" | "nft_transfer" | "nft_mint" | "nft_burn" | "print_event";
288
+ type ProjectionsFor<
289
+ T extends ChainEventFilterType,
290
+ S
291
+ > = {
292
+ /** Wire trigger for `subscriptions.create({ triggers: [...] })`. BigInt
293
+ * amounts become strings here — the one sanctioned boundary. */
294
+ toChainTrigger(): ChainTriggerOf<S>
295
+ } & (T extends DecodedMember ? {
296
+ /** Params for `index.events.list/walk/consume` (merge your own
297
+ * `limit`/`fromHeight`/`txContext` etc. on top). */
298
+ toIndexParams<Extra extends Record<string, unknown>>(extra?: Extra): IndexEventsParamsShape & Extra
299
+ /** Params for `streams.events.list/consume/stream`. Throws if the
300
+ * filter uses `trait` (Streams has no trait resolution) or a
301
+ * min/max amount (Streams filters have no amount predicates). */
302
+ toStreamsParams<Extra extends Record<string, unknown>>(extra?: Extra): StreamsParamsShape & Extra
303
+ } : {}) & (T extends "contract_call" ? {
304
+ /** Params for `index.contractCalls.list/walk/consume`. */
305
+ toContractCallsParams<Extra extends Record<string, unknown>>(extra?: Extra): ContractCallsParamsShape & Extra
306
+ } : {}) & (T extends Exclude<ChainEventFilterType, `sbtc_${string}`> ? {
307
+ /** The `sources` entry for `defineSubgraph` — literal `prints`/`abi`
308
+ * types are preserved, so handler narrowing survives. */
309
+ toSubgraphSource(): S
310
+ } : {});
311
+ /**
312
+ * A canonical chain-event filter: the spec fields plus the projections its
313
+ * member supports. Write the filter once; project it to a query
314
+ * (`toIndexParams`), a stream (`toStreamsParams`), a webhook trigger
315
+ * (`toChainTrigger`), or a subgraph source (`toSubgraphSource`).
316
+ */
317
+ type ChainEventFilter<
318
+ T extends ChainEventFilterType = ChainEventFilterType,
319
+ S extends {
320
+ type: T
321
+ } = SpecFor<T>
322
+ > = S & ProjectionsFor<T, S>;
323
+ type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
324
+ /** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
325
+ * annotation on exported values (an inferred object of generic factories
326
+ * collapses to `{}` in the emitted declarations). */
327
+ interface OnNamespace {
328
+ stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
329
+ stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
330
+ stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
331
+ stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
332
+ ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
333
+ ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
334
+ ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
335
+ nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
336
+ nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
337
+ nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
338
+ /** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps
339
+ * typing `event.input` inside `defineSubgraph`. */
340
+ contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
341
+ abi?: A
342
+ }): ChainEventFilter<"contract_call", {
343
+ type: "contract_call"
344
+ } & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
345
+ abi?: A
346
+ }>;
347
+ contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
348
+ /** Canonical member is `print_event` (as Subgraphs and Subscriptions spell
349
+ * it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`
350
+ * literals are preserved (`const P`) for per-topic `event.data` narrowing. */
351
+ print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
352
+ prints?: P
353
+ }): ChainEventFilter<"print_event", {
354
+ type: "print_event"
355
+ } & Omit<SpecFor<"print_event">, "type" | "prints"> & {
356
+ prints?: P
357
+ }>;
358
+ sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
359
+ sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
360
+ sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
361
+ sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
362
+ sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
363
+ }
364
+ /**
365
+ * `on.*` — one filter vocabulary for every surface.
366
+ *
367
+ * ```ts
368
+ * import { on } from "@secondlayer/stacks/filters";
369
+ *
370
+ * const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });
371
+ *
372
+ * sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull
373
+ * sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });
374
+ * sl.subscriptions.create({ name, url, triggers: [usdc.toChainTrigger()] });
375
+ * defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });
376
+ * ```
377
+ *
378
+ * A surface a member can't reach is a missing method (compile error), and a
379
+ * field a surface can't express throws at projection time — never a silent
380
+ * zero-row or over-wide match.
381
+ */
382
+ declare const on: OnNamespace;
1
383
  /** Account derived from a local private key (mnemonic or raw key). */
2
384
  type LocalAccount = {
3
385
  type: "local"
@@ -736,6 +1118,12 @@ type ReadContractParams = {
736
1118
  functionName: string
737
1119
  args?: ClarityValue[]
738
1120
  sender?: string
1121
+ /**
1122
+ * Nakamoto StacksBlockId to evaluate against. Without it the node answers
1123
+ * at its own moving tip, which makes a read non-deterministic — the same
1124
+ * reindex of the same block can return a different value.
1125
+ */
1126
+ tip?: string
739
1127
  };
740
1128
  declare class BaseError extends Error {
741
1129
  name: string;
@@ -1335,155 +1723,6 @@ type WebSocketTransport = Transport & {
1335
1723
  * HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
1336
1724
  */
1337
1725
  declare function webSocket(url?: string, config?: WebSocketTransportConfig): TransportFactory;
1338
- declare namespace exports_on {
1339
- export { transferTo, sip010Transfer, sip009Transfer, sbtcWithdrawal, sbtcDeposit, poxStack, makeSpec, bnsName, SubscriptionFilterSpec, PoxFunction, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, BnsAction };
1340
- }
1341
- /**
1342
- * Filter specs for `@secondlayer/sdk` subscriptions.
1343
- *
1344
- * Each `on.*` factory in this directory binds typed filter clauses to a
1345
- * known table shape and returns a `SubscriptionFilterSpec`. Spread it into
1346
- * a full subscription input alongside `name`, `url`, `format`, etc:
1347
- *
1348
- * const spec = on.transferTo(
1349
- * { subgraph: "my-watcher", table: "transfers" },
1350
- * "SP1ABC...",
1351
- * );
1352
- * await sdk.subscriptions.create({
1353
- * ...spec,
1354
- * name: "watch-incoming",
1355
- * url: "https://my-app.com/webhook",
1356
- * });
1357
- *
1358
- * The user supplies which subgraph + table to bind against — these factories
1359
- * don't assume curated read endpoints are subscribable. To watch FT transfers
1360
- * to an address, build a subgraph with a `transfers` table (see
1361
- * `sl subgraphs create --template sip-010-balances`) and bind here.
1362
- */
1363
- /**
1364
- * What every factory takes as its first arg: which user-owned subgraph table
1365
- * to filter against.
1366
- */
1367
- type FactoryTarget = {
1368
- subgraph: string
1369
- table: string
1370
- };
1371
- /**
1372
- * A primitive value that can appear in a filter clause.
1373
- * Mirrors `SubscriptionFilterPrimitive` in
1374
- * `@secondlayer/shared/schemas/subscriptions` — duplicated here to keep
1375
- * `@secondlayer/stacks` from importing the api/server schema package.
1376
- */
1377
- type FilterPrimitive = string | number | boolean;
1378
- /** Operator forms a filter clause can take. */
1379
- type FilterOperator = {
1380
- eq: FilterPrimitive
1381
- } | {
1382
- neq: FilterPrimitive
1383
- } | {
1384
- gt: string | number
1385
- } | {
1386
- gte: string | number
1387
- } | {
1388
- lt: string | number
1389
- } | {
1390
- lte: string | number
1391
- } | {
1392
- in: FilterPrimitive[]
1393
- };
1394
- /** A single column's filter: bare value (eq) or operator object. */
1395
- type FilterClause = FilterPrimitive | FilterOperator;
1396
- /** Map of column → filter clause. Empty `{}` matches every row. */
1397
- type Filter = Record<string, FilterClause>;
1398
- /**
1399
- * Output of every `on.*` factory. Use directly as a partial input to
1400
- * `sdk.subscriptions.create` — the SDK's existing `CreateSubscriptionRequest`
1401
- * already accepts these three fields.
1402
- */
1403
- type SubscriptionFilterSpec = {
1404
- subgraphName: string
1405
- tableName: string
1406
- filter: Filter
1407
- };
1408
- /** Thin helper to build a spec without restating the field-name mapping. */
1409
- declare function makeSpec(target: FactoryTarget, filter: Filter): SubscriptionFilterSpec;
1410
- type BnsAction = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
1411
- /**
1412
- * Match BNS-V2 name lifecycle events.
1413
- *
1414
- * Bind against a subgraph table that mirrors the `bns_name_events` shape
1415
- * (topic, namespace, name, owner, ...). Easiest path: scaffold via
1416
- * `sl subgraphs create --template bns-names`.
1417
- *
1418
- * @param action restrict to one topic; omit to fire on every name event
1419
- */
1420
- declare function bnsName(target: FactoryTarget, action?: BnsAction, opts?: {
1421
- namespace?: string
1422
- owner?: string
1423
- }): SubscriptionFilterSpec;
1424
- type PoxFunction = "stack-stx" | "stack-extend" | "stack-increase" | "delegate-stx" | "revoke-delegate-stx" | "delegate-stack-stx" | "delegate-stack-extend" | "delegate-stack-increase" | "stack-aggregation-commit" | "stack-aggregation-commit-indexed" | "stack-aggregation-increase" | "set-signer-key-authorization";
1425
- /**
1426
- * Match PoX-4 stacking calls. Bind against a subgraph table mirroring
1427
- * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via
1428
- * `sl subgraphs create --template pox-stacking`.
1429
- *
1430
- * @param fn restrict to one PoX-4 function; omit to fire on every call
1431
- */
1432
- declare function poxStack(target: FactoryTarget, fn?: PoxFunction, opts?: {
1433
- stacker?: string
1434
- signerKey?: string
1435
- }): SubscriptionFilterSpec;
1436
- /**
1437
- * Match sBTC deposit completion events. Bind against a subgraph table
1438
- * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).
1439
- * Scaffold via `sl subgraphs create --template sbtc-flows`.
1440
- */
1441
- declare function sbtcDeposit(target: FactoryTarget, opts?: {
1442
- sender?: string
1443
- bitcoinTxid?: string
1444
- }): SubscriptionFilterSpec;
1445
- /**
1446
- * Match sBTC withdrawal lifecycle events. Phase defaults to all three
1447
- * (`create` / `accept` / `reject`); pass an explicit `phase` to narrow.
1448
- */
1449
- declare function sbtcWithdrawal(target: FactoryTarget, opts?: {
1450
- phase?: "create" | "accept" | "reject"
1451
- sender?: string
1452
- requestId?: number
1453
- }): SubscriptionFilterSpec;
1454
- /**
1455
- * Match transfer events into a recipient address.
1456
- *
1457
- * Works against any subgraph table that has a `recipient` column (and
1458
- * optionally `asset_identifier`). Templates that scaffold this shape:
1459
- * `sip-010-balances`, `sbtc-flows`.
1460
- *
1461
- * @param target the user's subgraph + table to bind against
1462
- * @param recipient stx principal that should receive the transfer
1463
- * @param opts.asset optional asset identifier (e.g. `"SP1...usdc::usdc-token"`)
1464
- * to filter to a specific FT/NFT contract
1465
- */
1466
- declare function transferTo(target: FactoryTarget, recipient: string, opts?: {
1467
- asset?: string
1468
- }): SubscriptionFilterSpec;
1469
- /**
1470
- * SIP-010 (fungible token) transfer sugar — alias for `transferTo` that
1471
- * makes the asset filter intent explicit at the call site. Same backing
1472
- * filter; the `asset` param is optional (omit to match every SIP-010
1473
- * transfer in the bound table).
1474
- */
1475
- declare function sip010Transfer(target: FactoryTarget, asset?: string, opts?: {
1476
- recipient?: string
1477
- }): SubscriptionFilterSpec;
1478
- /**
1479
- * SIP-009 (non-fungible token) transfer sugar — same pattern as
1480
- * `sip010Transfer`. Bind against an NFT-shaped table (see template
1481
- * `nft-transfers` if/when published).
1482
- */
1483
- declare function sip009Transfer(target: FactoryTarget, asset?: string, opts?: {
1484
- recipient?: string
1485
- tokenId?: string | number
1486
- }): SubscriptionFilterSpec;
1487
1726
  /** Create a ProviderAccount by querying the wallet for addresses */
1488
1727
  declare function providerToAccount(provider: StacksProvider): Promise<ProviderAccount>;
1489
1728
  /** Stacks mainnet chain definition (Hiro API). */
@@ -1506,20 +1745,6 @@ declare function formatStx(microStx: bigint | number | string): string;
1506
1745
  * @example parseStx("1.5") → 1500000n
1507
1746
  */
1508
1747
  declare function parseStx(stx: string | number): bigint;
1509
- /** C32-encoded address version bytes for single-sig and multi-sig on each network. */
1510
- declare const AddressVersion: {
1511
- readonly MainnetSingleSig: 22
1512
- readonly MainnetMultiSig: 20
1513
- readonly TestnetSingleSig: 26
1514
- readonly TestnetMultiSig: 21
1515
- };
1516
- type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
1517
- /** Mainnet burn address (all-zero hash160). */
1518
- declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
1519
- /** Testnet burn address (all-zero hash160). */
1520
- declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
1521
- /** Number of microSTX per 1 STX (10^6). */
1522
- declare const MICROSTX_PER_STX = 1000000n;
1523
1748
  /** Alias for validateStacksAddress — matches future.md naming. */
1524
1749
  declare const isValidAddress: (address: string) => boolean;
1525
1750
  /**
@@ -1610,4 +1835,4 @@ declare class MalformedResponseError extends BaseError {
1610
1835
  declare class WebSocketError extends BaseError {
1611
1836
  name: string;
1612
1837
  }
1613
- export { webSocket, walletActions, waitForTransactionReceipt2 as waitForTransactionReceipt, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, exports_on as on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexTxSource, indexSource, http, hiroNonceSource, getTransaction2 as getTransaction, getContractAddress, formatStx, fallback, extendedApiSource, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, WaitForTransactionTimeoutError, WaitForTransactionReceiptParams, TxRejectionReason, TransportFactory, TransportConfig, Transport, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, TransactionError, TransactionDroppedError, TransactionAbortedError, TESTNET_ZERO_ADDRESS, SubscriptionFilterSpec, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PoxFunction, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MalformedResponseError, MICROSTX_PER_STX, LocalAccount, IndexTxSourceParams, IndexSourceParams, HttpRequestError, HiroNonceSourceParams, GetTransactionParams, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, BroadcastError, BnsAction, BaseError, AddressVersion, Account };
1838
+ export { webSocket, walletActions, waitForTransactionReceipt2 as waitForTransactionReceipt, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx, on, nextFreeNonce, multisigActions, mocknet, mempoolAwareSource, memoryStore, mainnet, jsonRpcSource, isValidAddress, isNonceConflictError, isAddressEqual, indexTxSource, indexSource, http, hiroNonceSource, getTransaction2 as getTransaction, getContractAddress, formatStx, fallback, extendedApiSource, devnet, defineChain, custom, createWalletClient, createPublicClient, createNonceManager, createMultiSigClient, createClient, broadcastWithNonceReset, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WebSocketError, WalletClientConfig, WalletClient, WalletActions, WaitForTransactionTimeoutError, WaitForTransactionReceiptParams, TxRejectionReason, TransportFactory, TransportConfig, Transport, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, TransactionError, TransactionDroppedError, TransactionAbortedError, TESTNET_ZERO_ADDRESS, Subscription, StartNonceReconcilerParams, StacksProvider, StacksChain, SqlLike, SimulationError, SigningError, SerializationError, RequestOptions, RequestFn, RedisStoreParams, RedisLike, ReconcileNonceResult, ReconcileNonceParams, ReadOnlyCallError, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, PostgresStoreParams, NonceStore, NonceManagerSource, NonceManager, MultiSigClientConfig, MultiSigClient, MultiSigActions, MempoolAwareSourceParams, MalformedResponseError, MICROSTX_PER_STX, LocalAccount, IndexTxSourceParams, IndexSourceParams, HttpRequestError, HiroNonceSourceParams, GetTransactionParams, CustomAccount, CreateNonceManagerParams, ContractCallError, ClientConfig, Client, ChainTriggerOf, ChainEventFilterType, ChainEventFilterSpec, ChainEventFilter, BroadcastError, BaseError, AddressVersion, Account };