@secondlayer/stacks 2.22.0 → 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 (47) hide show
  1. package/dist/shared/stacks-2p9cazp7.cjs +263 -0
  2. package/dist/shared/stacks-2p9cazp7.cjs.map +12 -0
  3. package/dist/shared/stacks-tqrws7kd.js +252 -0
  4. package/dist/shared/stacks-tqrws7kd.js.map +12 -0
  5. package/dist/src/accounts/index.js +1 -2
  6. package/dist/src/accounts/index.js.map +2 -2
  7. package/dist/src/actions/index.js +1 -2
  8. package/dist/src/actions/index.js.map +1 -1
  9. package/dist/src/bitcoin/index.js +1 -2
  10. package/dist/src/bitcoin/index.js.map +2 -2
  11. package/dist/src/bns/index.js +1 -2
  12. package/dist/src/bns/index.js.map +2 -2
  13. package/dist/src/chains/index.js +1 -2
  14. package/dist/src/chains/index.js.map +1 -1
  15. package/dist/src/clarity/index.js +1 -2
  16. package/dist/src/clarity/index.js.map +1 -1
  17. package/dist/src/filters/index.cjs +1 -261
  18. package/dist/src/filters/index.cjs.map +3 -6
  19. package/dist/src/filters/index.js +13 -249
  20. package/dist/src/filters/index.js.map +3 -6
  21. package/dist/src/index.cjs +2 -75
  22. package/dist/src/index.cjs.map +3 -8
  23. package/dist/src/index.d.cts +383 -164
  24. package/dist/src/index.d.ts +383 -164
  25. package/dist/src/index.js +5 -78
  26. package/dist/src/index.js.map +3 -8
  27. package/dist/src/postconditions/index.js +1 -2
  28. package/dist/src/postconditions/index.js.map +1 -1
  29. package/dist/src/pox/index.js +1 -2
  30. package/dist/src/pox/index.js.map +2 -2
  31. package/dist/src/pox5/index.js +1 -2
  32. package/dist/src/pox5/index.js.map +2 -2
  33. package/dist/src/sbtc/index.js +1 -2
  34. package/dist/src/sbtc/index.js.map +2 -2
  35. package/dist/src/stackingdao/index.js +1 -2
  36. package/dist/src/stackingdao/index.js.map +2 -2
  37. package/dist/src/subscriptions/index.js +1 -2
  38. package/dist/src/subscriptions/index.js.map +1 -1
  39. package/dist/src/transactions/index.js +1 -2
  40. package/dist/src/transactions/index.js.map +1 -1
  41. package/dist/src/utils/index.js +1 -2
  42. package/dist/src/utils/index.js.map +2 -2
  43. package/dist/src/x402/index.js +1 -2
  44. package/dist/src/x402/index.js.map +2 -2
  45. package/package.json +1 -1
  46. package/dist/shared/stacks-cfazrteq.js +0 -20
  47. package/dist/shared/stacks-cfazrteq.js.map +0 -9
@@ -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"
@@ -1341,155 +1723,6 @@ type WebSocketTransport = Transport & {
1341
1723
  * HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
1342
1724
  */
1343
1725
  declare function webSocket(url?: string, config?: WebSocketTransportConfig): TransportFactory;
1344
- declare namespace exports_on {
1345
- export { transferTo, sip010Transfer, sip009Transfer, sbtcWithdrawal, sbtcDeposit, poxStack, makeSpec, bnsName, SubscriptionFilterSpec, PoxFunction, FilterPrimitive, FilterOperator, FilterClause, Filter, FactoryTarget, BnsAction };
1346
- }
1347
- /**
1348
- * Filter specs for `@secondlayer/sdk` subscriptions.
1349
- *
1350
- * Each `on.*` factory in this directory binds typed filter clauses to a
1351
- * known table shape and returns a `SubscriptionFilterSpec`. Spread it into
1352
- * a full subscription input alongside `name`, `url`, `format`, etc:
1353
- *
1354
- * const spec = on.transferTo(
1355
- * { subgraph: "my-watcher", table: "transfers" },
1356
- * "SP1ABC...",
1357
- * );
1358
- * await sdk.subscriptions.create({
1359
- * ...spec,
1360
- * name: "watch-incoming",
1361
- * url: "https://my-app.com/webhook",
1362
- * });
1363
- *
1364
- * The user supplies which subgraph + table to bind against — these factories
1365
- * don't assume curated read endpoints are subscribable. To watch FT transfers
1366
- * to an address, build a subgraph with a `transfers` table (see
1367
- * `sl subgraphs create --template sip-010-balances`) and bind here.
1368
- */
1369
- /**
1370
- * What every factory takes as its first arg: which user-owned subgraph table
1371
- * to filter against.
1372
- */
1373
- type FactoryTarget = {
1374
- subgraph: string
1375
- table: string
1376
- };
1377
- /**
1378
- * A primitive value that can appear in a filter clause.
1379
- * Mirrors `SubscriptionFilterPrimitive` in
1380
- * `@secondlayer/shared/schemas/subscriptions` — duplicated here to keep
1381
- * `@secondlayer/stacks` from importing the api/server schema package.
1382
- */
1383
- type FilterPrimitive = string | number | boolean;
1384
- /** Operator forms a filter clause can take. */
1385
- type FilterOperator = {
1386
- eq: FilterPrimitive
1387
- } | {
1388
- neq: FilterPrimitive
1389
- } | {
1390
- gt: string | number
1391
- } | {
1392
- gte: string | number
1393
- } | {
1394
- lt: string | number
1395
- } | {
1396
- lte: string | number
1397
- } | {
1398
- in: FilterPrimitive[]
1399
- };
1400
- /** A single column's filter: bare value (eq) or operator object. */
1401
- type FilterClause = FilterPrimitive | FilterOperator;
1402
- /** Map of column → filter clause. Empty `{}` matches every row. */
1403
- type Filter = Record<string, FilterClause>;
1404
- /**
1405
- * Output of every `on.*` factory. Use directly as a partial input to
1406
- * `sdk.subscriptions.create` — the SDK's existing `CreateSubscriptionRequest`
1407
- * already accepts these three fields.
1408
- */
1409
- type SubscriptionFilterSpec = {
1410
- subgraphName: string
1411
- tableName: string
1412
- filter: Filter
1413
- };
1414
- /** Thin helper to build a spec without restating the field-name mapping. */
1415
- declare function makeSpec(target: FactoryTarget, filter: Filter): SubscriptionFilterSpec;
1416
- type BnsAction = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
1417
- /**
1418
- * Match BNS-V2 name lifecycle events.
1419
- *
1420
- * Bind against a subgraph table that mirrors the `bns_name_events` shape
1421
- * (topic, namespace, name, owner, ...). Easiest path: scaffold via
1422
- * `sl subgraphs create --template bns-names`.
1423
- *
1424
- * @param action restrict to one topic; omit to fire on every name event
1425
- */
1426
- declare function bnsName(target: FactoryTarget, action?: BnsAction, opts?: {
1427
- namespace?: string
1428
- owner?: string
1429
- }): SubscriptionFilterSpec;
1430
- 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";
1431
- /**
1432
- * Match PoX-4 stacking calls. Bind against a subgraph table mirroring
1433
- * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via
1434
- * `sl subgraphs create --template pox-stacking`.
1435
- *
1436
- * @param fn restrict to one PoX-4 function; omit to fire on every call
1437
- */
1438
- declare function poxStack(target: FactoryTarget, fn?: PoxFunction, opts?: {
1439
- stacker?: string
1440
- signerKey?: string
1441
- }): SubscriptionFilterSpec;
1442
- /**
1443
- * Match sBTC deposit completion events. Bind against a subgraph table
1444
- * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).
1445
- * Scaffold via `sl subgraphs create --template sbtc-flows`.
1446
- */
1447
- declare function sbtcDeposit(target: FactoryTarget, opts?: {
1448
- sender?: string
1449
- bitcoinTxid?: string
1450
- }): SubscriptionFilterSpec;
1451
- /**
1452
- * Match sBTC withdrawal lifecycle events. Phase defaults to all three
1453
- * (`create` / `accept` / `reject`); pass an explicit `phase` to narrow.
1454
- */
1455
- declare function sbtcWithdrawal(target: FactoryTarget, opts?: {
1456
- phase?: "create" | "accept" | "reject"
1457
- sender?: string
1458
- requestId?: number
1459
- }): SubscriptionFilterSpec;
1460
- /**
1461
- * Match transfer events into a recipient address.
1462
- *
1463
- * Works against any subgraph table that has a `recipient` column (and
1464
- * optionally `asset_identifier`). Templates that scaffold this shape:
1465
- * `sip-010-balances`, `sbtc-flows`.
1466
- *
1467
- * @param target the user's subgraph + table to bind against
1468
- * @param recipient stx principal that should receive the transfer
1469
- * @param opts.asset optional asset identifier (e.g. `"SP1...usdc::usdc-token"`)
1470
- * to filter to a specific FT/NFT contract
1471
- */
1472
- declare function transferTo(target: FactoryTarget, recipient: string, opts?: {
1473
- asset?: string
1474
- }): SubscriptionFilterSpec;
1475
- /**
1476
- * SIP-010 (fungible token) transfer sugar — alias for `transferTo` that
1477
- * makes the asset filter intent explicit at the call site. Same backing
1478
- * filter; the `asset` param is optional (omit to match every SIP-010
1479
- * transfer in the bound table).
1480
- */
1481
- declare function sip010Transfer(target: FactoryTarget, asset?: string, opts?: {
1482
- recipient?: string
1483
- }): SubscriptionFilterSpec;
1484
- /**
1485
- * SIP-009 (non-fungible token) transfer sugar — same pattern as
1486
- * `sip010Transfer`. Bind against an NFT-shaped table (see template
1487
- * `nft-transfers` if/when published).
1488
- */
1489
- declare function sip009Transfer(target: FactoryTarget, asset?: string, opts?: {
1490
- recipient?: string
1491
- tokenId?: string | number
1492
- }): SubscriptionFilterSpec;
1493
1726
  /** Create a ProviderAccount by querying the wallet for addresses */
1494
1727
  declare function providerToAccount(provider: StacksProvider): Promise<ProviderAccount>;
1495
1728
  /** Stacks mainnet chain definition (Hiro API). */
@@ -1512,20 +1745,6 @@ declare function formatStx(microStx: bigint | number | string): string;
1512
1745
  * @example parseStx("1.5") → 1500000n
1513
1746
  */
1514
1747
  declare function parseStx(stx: string | number): bigint;
1515
- /** C32-encoded address version bytes for single-sig and multi-sig on each network. */
1516
- declare const AddressVersion: {
1517
- readonly MainnetSingleSig: 22
1518
- readonly MainnetMultiSig: 20
1519
- readonly TestnetSingleSig: 26
1520
- readonly TestnetMultiSig: 21
1521
- };
1522
- type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
1523
- /** Mainnet burn address (all-zero hash160). */
1524
- declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
1525
- /** Testnet burn address (all-zero hash160). */
1526
- declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
1527
- /** Number of microSTX per 1 STX (10^6). */
1528
- declare const MICROSTX_PER_STX = 1000000n;
1529
1748
  /** Alias for validateStacksAddress — matches future.md naming. */
1530
1749
  declare const isValidAddress: (address: string) => boolean;
1531
1750
  /**
@@ -1616,4 +1835,4 @@ declare class MalformedResponseError extends BaseError {
1616
1835
  declare class WebSocketError extends BaseError {
1617
1836
  name: string;
1618
1837
  }
1619
- 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 };
package/dist/src/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ on
3
+ } from "../shared/stacks-tqrws7kd.js";
1
4
  import {
2
5
  providerToAccount
3
6
  } from "../shared/stacks-qcae5852.js";
@@ -105,9 +108,6 @@ import {
105
108
  parseContractId
106
109
  } from "../shared/stacks-azp00pve.js";
107
110
  import"../shared/stacks-qs5fzts5.js";
108
- import {
109
- __export
110
- } from "../shared/stacks-cfazrteq.js";
111
111
 
112
112
  // src/clients/createClient.ts
113
113
  var BASE_KEYS = new Set([
@@ -825,79 +825,6 @@ function webSocket(url, config) {
825
825
  return transport;
826
826
  };
827
827
  }
828
- // src/on/index.ts
829
- var exports_on = {};
830
- __export(exports_on, {
831
- transferTo: () => transferTo,
832
- sip010Transfer: () => sip010Transfer,
833
- sip009Transfer: () => sip009Transfer,
834
- sbtcWithdrawal: () => sbtcWithdrawal,
835
- sbtcDeposit: () => sbtcDeposit,
836
- poxStack: () => poxStack,
837
- makeSpec: () => makeSpec,
838
- bnsName: () => bnsName
839
- });
840
-
841
- // src/on/spec.ts
842
- function makeSpec(target, filter) {
843
- return {
844
- subgraphName: target.subgraph,
845
- tableName: target.table,
846
- filter
847
- };
848
- }
849
-
850
- // src/on/bns.ts
851
- function bnsName(target, action, opts) {
852
- return makeSpec(target, {
853
- ...action && { topic: action },
854
- ...opts?.namespace && { namespace: opts.namespace },
855
- ...opts?.owner && { owner: opts.owner }
856
- });
857
- }
858
- // src/on/pox.ts
859
- function poxStack(target, fn, opts) {
860
- return makeSpec(target, {
861
- ...fn && { function_name: fn },
862
- ...opts?.stacker && { stacker: opts.stacker },
863
- ...opts?.signerKey && { signer_key: opts.signerKey }
864
- });
865
- }
866
- // src/on/sbtc.ts
867
- function sbtcDeposit(target, opts) {
868
- return makeSpec(target, {
869
- topic: "completed-deposit",
870
- ...opts?.sender && { sender: opts.sender },
871
- ...opts?.bitcoinTxid && { bitcoin_txid: opts.bitcoinTxid }
872
- });
873
- }
874
- function sbtcWithdrawal(target, opts) {
875
- return makeSpec(target, {
876
- topic: opts?.phase ? { eq: `withdrawal-${opts.phase}` } : { in: ["withdrawal-create", "withdrawal-accept", "withdrawal-reject"] },
877
- ...opts?.sender && { sender: opts.sender },
878
- ...opts?.requestId !== undefined && { request_id: opts.requestId }
879
- });
880
- }
881
- // src/on/transfer.ts
882
- function transferTo(target, recipient, opts) {
883
- return makeSpec(target, {
884
- recipient,
885
- ...opts?.asset && { asset_identifier: opts.asset }
886
- });
887
- }
888
- function sip010Transfer(target, asset, opts) {
889
- return makeSpec(target, {
890
- ...asset && { asset_identifier: asset },
891
- ...opts?.recipient && { recipient: opts.recipient }
892
- });
893
- }
894
- function sip009Transfer(target, asset, opts) {
895
- return makeSpec(target, {
896
- ...asset && { asset_identifier: asset },
897
- ...opts?.recipient && { recipient: opts.recipient },
898
- ...opts?.tokenId !== undefined && { token_id: String(opts.tokenId) }
899
- });
900
- }
901
828
  // src/errors/contract.ts
902
829
  class ContractCallError extends BaseError {
903
830
  name = "ContractCallError";
@@ -919,7 +846,7 @@ export {
919
846
  providerToAccount,
920
847
  postgresStore,
921
848
  parseStx,
922
- exports_on as on,
849
+ on,
923
850
  nextFreeNonce,
924
851
  multisigActions,
925
852
  mocknet,
@@ -968,5 +895,5 @@ export {
968
895
  AddressVersion
969
896
  };
970
897
 
971
- //# debugId=1F5628B4C4CAF51E64756E2164756E21
898
+ //# debugId=2F16B7F3389307BC64756E2164756E21
972
899
  //# sourceMappingURL=index.js.map