@secondlayer/stacks 2.22.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/stacks-86ngngnk.cjs +271 -0
- package/dist/shared/stacks-86ngngnk.cjs.map +12 -0
- package/dist/shared/stacks-qc25xx02.js +259 -0
- package/dist/shared/stacks-qc25xx02.js.map +12 -0
- package/dist/src/accounts/index.js +1 -2
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.js +1 -2
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.js +1 -2
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.js +1 -2
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.js +1 -2
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.js +1 -2
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/filters/index.cjs +1 -261
- package/dist/src/filters/index.cjs.map +3 -6
- package/dist/src/filters/index.d.cts +52 -27
- package/dist/src/filters/index.d.ts +52 -27
- package/dist/src/filters/index.js +15 -249
- package/dist/src/filters/index.js.map +3 -6
- package/dist/src/index.cjs +2 -75
- package/dist/src/index.cjs.map +3 -8
- package/dist/src/index.d.cts +401 -164
- package/dist/src/index.d.ts +401 -164
- package/dist/src/index.js +5 -78
- package/dist/src/index.js.map +3 -8
- package/dist/src/postconditions/index.js +1 -2
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +71 -14
- package/dist/src/pox/index.cjs.map +4 -4
- package/dist/src/pox/index.d.cts +437 -1
- package/dist/src/pox/index.d.ts +437 -1
- package/dist/src/pox/index.js +71 -15
- package/dist/src/pox/index.js.map +4 -4
- package/dist/src/pox5/index.cjs +70 -33
- package/dist/src/pox5/index.cjs.map +3 -3
- package/dist/src/pox5/index.d.cts +899 -1
- package/dist/src/pox5/index.d.ts +899 -1
- package/dist/src/pox5/index.js +70 -34
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.js +1 -2
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/stackingdao/index.js +1 -2
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.js +1 -2
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.js +1 -2
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.js +1 -2
- package/dist/src/utils/index.js.map +2 -2
- package/dist/src/x402/index.js +1 -2
- package/dist/src/x402/index.js.map +2 -2
- package/package.json +3 -5
- package/dist/shared/stacks-cfazrteq.js +0 -20
- package/dist/shared/stacks-cfazrteq.js.map +0 -9
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,403 @@
|
|
|
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
|
+
/**
|
|
120
|
+
* `<contract>::<asset-name>` — the shape a fungible/non-fungible asset filter
|
|
121
|
+
* takes, expressed so the compiler can check it.
|
|
122
|
+
*
|
|
123
|
+
* The most common mistake in this API is passing a CONTRACT ID
|
|
124
|
+
* (`SP….sbtc-token`) where an asset identifier (`SP….sbtc-token::sbtc-token`)
|
|
125
|
+
* belongs, and the failure mode is a query that quietly returns zero rows. The
|
|
126
|
+
* two differ structurally by `::`, so a template-literal type catches it at the
|
|
127
|
+
* call site — no brand, no cast, literals just work.
|
|
128
|
+
*
|
|
129
|
+
* A value that is only known at runtime (config, env) is not narrow enough on
|
|
130
|
+
* purpose; run it through {@link assetId} once, which validates and narrows.
|
|
131
|
+
*
|
|
132
|
+
* Wildcard patterns (Subscriptions-only) are admitted by the second arm — they
|
|
133
|
+
* are legitimately not full identifiers (`SPB.*`), and the runtime validator
|
|
134
|
+
* short-circuits on them for the same reason.
|
|
135
|
+
*/
|
|
136
|
+
type AssetIdentifier = `${string}::${string}` | `${string}*${string}`;
|
|
137
|
+
/** Scalar print field types (structural mirror of the subgraphs `ColumnType`). */
|
|
138
|
+
type PrintScalarType = "uint" | "int" | "text" | "principal" | "boolean" | "timestamp" | "jsonb";
|
|
139
|
+
/**
|
|
140
|
+
* One declared print field — structural mirror of `PrintField` in
|
|
141
|
+
* `@secondlayer/subgraphs`. Composite forms exist because real print payloads
|
|
142
|
+
* nest: a vocabulary that could only say `"jsonb"` is what let a flat-field
|
|
143
|
+
* declaration type-check while every event decoded to null.
|
|
144
|
+
*
|
|
145
|
+
* Kept literal through `toSubgraphSource()` so handler narrowing survives.
|
|
146
|
+
*/
|
|
147
|
+
type PrintFieldType = PrintScalarType | {
|
|
148
|
+
type: PrintFieldType
|
|
149
|
+
optional: true
|
|
150
|
+
} | {
|
|
151
|
+
tuple: Record<string, PrintFieldType>
|
|
152
|
+
} | {
|
|
153
|
+
list: PrintFieldType
|
|
154
|
+
};
|
|
155
|
+
interface StxTransferSpec {
|
|
156
|
+
type: "stx_transfer";
|
|
157
|
+
sender?: string;
|
|
158
|
+
recipient?: string;
|
|
159
|
+
minAmount?: bigint;
|
|
160
|
+
maxAmount?: bigint;
|
|
161
|
+
}
|
|
162
|
+
interface StxMintSpec {
|
|
163
|
+
type: "stx_mint";
|
|
164
|
+
recipient?: string;
|
|
165
|
+
minAmount?: bigint;
|
|
166
|
+
}
|
|
167
|
+
interface StxBurnSpec {
|
|
168
|
+
type: "stx_burn";
|
|
169
|
+
sender?: string;
|
|
170
|
+
minAmount?: bigint;
|
|
171
|
+
}
|
|
172
|
+
interface StxLockSpec {
|
|
173
|
+
type: "stx_lock";
|
|
174
|
+
lockedAddress?: string;
|
|
175
|
+
minAmount?: bigint;
|
|
176
|
+
}
|
|
177
|
+
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
178
|
+
* of a fixed contract. Index + Subgraphs + Subscriptions; Streams has no
|
|
179
|
+
* trait resolution — `toStreamsParams()` throws if set. */
|
|
180
|
+
type TraitScope = {
|
|
181
|
+
trait?: string
|
|
182
|
+
};
|
|
183
|
+
interface FtTransferSpec extends TraitScope {
|
|
184
|
+
type: "ft_transfer";
|
|
185
|
+
assetIdentifier?: AssetIdentifier;
|
|
186
|
+
sender?: string;
|
|
187
|
+
recipient?: string;
|
|
188
|
+
minAmount?: bigint;
|
|
189
|
+
}
|
|
190
|
+
interface FtMintSpec extends TraitScope {
|
|
191
|
+
type: "ft_mint";
|
|
192
|
+
assetIdentifier?: AssetIdentifier;
|
|
193
|
+
recipient?: string;
|
|
194
|
+
minAmount?: bigint;
|
|
195
|
+
}
|
|
196
|
+
interface FtBurnSpec extends TraitScope {
|
|
197
|
+
type: "ft_burn";
|
|
198
|
+
assetIdentifier?: AssetIdentifier;
|
|
199
|
+
sender?: string;
|
|
200
|
+
minAmount?: bigint;
|
|
201
|
+
}
|
|
202
|
+
interface NftTransferSpec extends TraitScope {
|
|
203
|
+
type: "nft_transfer";
|
|
204
|
+
assetIdentifier?: AssetIdentifier;
|
|
205
|
+
sender?: string;
|
|
206
|
+
recipient?: string;
|
|
207
|
+
}
|
|
208
|
+
interface NftMintSpec extends TraitScope {
|
|
209
|
+
type: "nft_mint";
|
|
210
|
+
assetIdentifier?: AssetIdentifier;
|
|
211
|
+
recipient?: string;
|
|
212
|
+
}
|
|
213
|
+
interface NftBurnSpec extends TraitScope {
|
|
214
|
+
type: "nft_burn";
|
|
215
|
+
assetIdentifier?: AssetIdentifier;
|
|
216
|
+
sender?: string;
|
|
217
|
+
}
|
|
218
|
+
interface ContractCallSpec extends TraitScope {
|
|
219
|
+
type: "contract_call";
|
|
220
|
+
/** One contract id, or a set of them (max 20). Mirrors the subgraphs
|
|
221
|
+
* filter — a router plus its pools is one source, not N. */
|
|
222
|
+
contractId?: string | readonly string[];
|
|
223
|
+
functionName?: string;
|
|
224
|
+
caller?: string;
|
|
225
|
+
/** Contract ABI (`as const`) — preserved literally so `toSubgraphSource()`
|
|
226
|
+
* keeps typing `event.input` in `defineSubgraph`. */
|
|
227
|
+
abi?: AbiContract;
|
|
228
|
+
}
|
|
229
|
+
interface ContractDeploySpec {
|
|
230
|
+
type: "contract_deploy";
|
|
231
|
+
deployer?: string;
|
|
232
|
+
contractName?: string;
|
|
233
|
+
}
|
|
234
|
+
interface PrintEventSpec extends TraitScope {
|
|
235
|
+
type: "print_event";
|
|
236
|
+
/** One contract id, or a set of them (max 20). */
|
|
237
|
+
contractId?: string | readonly string[];
|
|
238
|
+
topic?: string;
|
|
239
|
+
/** Per-topic field schema — preserved literally so `toSubgraphSource()`
|
|
240
|
+
* keeps the discriminated-union narrowing of `event.data`. */
|
|
241
|
+
prints?: Record<string, Record<string, PrintFieldType>>;
|
|
242
|
+
}
|
|
243
|
+
interface SbtcDepositSpec {
|
|
244
|
+
type: "sbtc_deposit";
|
|
245
|
+
sender?: string;
|
|
246
|
+
minAmount?: bigint;
|
|
247
|
+
maxAmount?: bigint;
|
|
248
|
+
bitcoinTxid?: string;
|
|
249
|
+
requestId?: number;
|
|
250
|
+
}
|
|
251
|
+
interface SbtcWithdrawalCreateSpec {
|
|
252
|
+
type: "sbtc_withdrawal_create";
|
|
253
|
+
sender?: string;
|
|
254
|
+
minAmount?: bigint;
|
|
255
|
+
maxAmount?: bigint;
|
|
256
|
+
requestId?: number;
|
|
257
|
+
}
|
|
258
|
+
interface SbtcWithdrawalAcceptSpec {
|
|
259
|
+
type: "sbtc_withdrawal_accept";
|
|
260
|
+
requestId?: number;
|
|
261
|
+
sweepTxid?: string;
|
|
262
|
+
}
|
|
263
|
+
interface SbtcWithdrawalRejectSpec {
|
|
264
|
+
type: "sbtc_withdrawal_reject";
|
|
265
|
+
requestId?: number;
|
|
266
|
+
}
|
|
267
|
+
interface SbtcWithdrawalSweptConfirmedSpec {
|
|
268
|
+
type: "sbtc_withdrawal_swept_confirmed";
|
|
269
|
+
requestId?: number;
|
|
270
|
+
sweepTxid?: string;
|
|
271
|
+
}
|
|
272
|
+
type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
|
|
273
|
+
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
274
|
+
type: T
|
|
275
|
+
}>;
|
|
276
|
+
/** Wire shape of a chain trigger (Subscriptions), derived per member from
|
|
277
|
+
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
278
|
+
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
279
|
+
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
|
280
|
+
type ChainTriggerOf<S> = { [K in keyof Omit<S, "abi" | "prints">] : Exclude<S[K], bigint | readonly string[]> | (bigint extends S[K] ? string : never) };
|
|
281
|
+
/** Params fragment for `index.events.*` (spread into list/walk/consume). */
|
|
282
|
+
type IndexEventsParamsShape = {
|
|
283
|
+
eventType: DecodedEventType
|
|
284
|
+
contractId?: string
|
|
285
|
+
assetIdentifier?: AssetIdentifier
|
|
286
|
+
sender?: string
|
|
287
|
+
recipient?: string
|
|
288
|
+
trait?: string
|
|
289
|
+
};
|
|
290
|
+
/** Params fragment for `index.contractCalls.*`. */
|
|
291
|
+
type ContractCallsParamsShape = {
|
|
292
|
+
contractId?: string
|
|
293
|
+
functionName?: string
|
|
294
|
+
sender?: string
|
|
295
|
+
trait?: string
|
|
296
|
+
};
|
|
297
|
+
/** Params fragment for `streams.events.*`. */
|
|
298
|
+
type StreamsParamsShape = {
|
|
299
|
+
types: readonly DecodedEventType[]
|
|
300
|
+
contractId?: string
|
|
301
|
+
sender?: string
|
|
302
|
+
recipient?: string
|
|
303
|
+
assetIdentifier?: AssetIdentifier
|
|
304
|
+
};
|
|
305
|
+
type DecodedMember = "stx_transfer" | "stx_mint" | "stx_burn" | "stx_lock" | "ft_transfer" | "ft_mint" | "ft_burn" | "nft_transfer" | "nft_mint" | "nft_burn" | "print_event";
|
|
306
|
+
type ProjectionsFor<
|
|
307
|
+
T extends ChainEventFilterType,
|
|
308
|
+
S
|
|
309
|
+
> = {
|
|
310
|
+
/** Wire trigger for `subscriptions.create({ triggers: [...] })`. BigInt
|
|
311
|
+
* amounts become strings here — the one sanctioned boundary. */
|
|
312
|
+
toChainTrigger(): ChainTriggerOf<S>
|
|
313
|
+
} & (T extends DecodedMember ? {
|
|
314
|
+
/** Params for `index.events.list/walk/consume` (merge your own
|
|
315
|
+
* `limit`/`fromHeight`/`txContext` etc. on top). */
|
|
316
|
+
toIndexParams<Extra extends Record<string, unknown>>(extra?: Extra): IndexEventsParamsShape & Extra
|
|
317
|
+
/** Params for `streams.events.list/consume/stream`. Throws if the
|
|
318
|
+
* filter uses `trait` (Streams has no trait resolution) or a
|
|
319
|
+
* min/max amount (Streams filters have no amount predicates). */
|
|
320
|
+
toStreamsParams<Extra extends Record<string, unknown>>(extra?: Extra): StreamsParamsShape & Extra
|
|
321
|
+
} : {}) & (T extends "contract_call" ? {
|
|
322
|
+
/** Params for `index.contractCalls.list/walk/consume`. */
|
|
323
|
+
toContractCallsParams<Extra extends Record<string, unknown>>(extra?: Extra): ContractCallsParamsShape & Extra
|
|
324
|
+
} : {}) & (T extends Exclude<ChainEventFilterType, `sbtc_${string}`> ? {
|
|
325
|
+
/** The `sources` entry for `defineSubgraph` — literal `prints`/`abi`
|
|
326
|
+
* types are preserved, so handler narrowing survives. */
|
|
327
|
+
toSubgraphSource(): S
|
|
328
|
+
} : {});
|
|
329
|
+
/**
|
|
330
|
+
* A canonical chain-event filter: the spec fields plus the projections its
|
|
331
|
+
* member supports. Write the filter once; project it to a query
|
|
332
|
+
* (`toIndexParams`), a stream (`toStreamsParams`), a webhook trigger
|
|
333
|
+
* (`toChainTrigger`), or a subgraph source (`toSubgraphSource`).
|
|
334
|
+
*/
|
|
335
|
+
type ChainEventFilter<
|
|
336
|
+
T extends ChainEventFilterType = ChainEventFilterType,
|
|
337
|
+
S extends {
|
|
338
|
+
type: T
|
|
339
|
+
} = SpecFor<T>
|
|
340
|
+
> = S & ProjectionsFor<T, S>;
|
|
341
|
+
type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
|
|
342
|
+
/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
|
|
343
|
+
* annotation on exported values (an inferred object of generic factories
|
|
344
|
+
* collapses to `{}` in the emitted declarations). */
|
|
345
|
+
interface OnNamespace {
|
|
346
|
+
stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
|
|
347
|
+
stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
|
|
348
|
+
stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
|
|
349
|
+
stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
|
|
350
|
+
ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
|
|
351
|
+
ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
|
|
352
|
+
ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
|
|
353
|
+
nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
|
|
354
|
+
nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
|
|
355
|
+
nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
|
|
356
|
+
/** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps
|
|
357
|
+
* typing `event.input` inside `defineSubgraph`. */
|
|
358
|
+
contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
359
|
+
abi?: A
|
|
360
|
+
}): ChainEventFilter<"contract_call", {
|
|
361
|
+
type: "contract_call"
|
|
362
|
+
} & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
363
|
+
abi?: A
|
|
364
|
+
}>;
|
|
365
|
+
contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
|
|
366
|
+
/** Canonical member is `print_event` (as Subgraphs and Subscriptions spell
|
|
367
|
+
* it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`
|
|
368
|
+
* literals are preserved (`const P`) for per-topic `event.data` narrowing. */
|
|
369
|
+
print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
370
|
+
prints?: P
|
|
371
|
+
}): ChainEventFilter<"print_event", {
|
|
372
|
+
type: "print_event"
|
|
373
|
+
} & Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
374
|
+
prints?: P
|
|
375
|
+
}>;
|
|
376
|
+
sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
|
|
377
|
+
sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
|
|
378
|
+
sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
|
|
379
|
+
sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
|
|
380
|
+
sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* `on.*` — one filter vocabulary for every surface.
|
|
384
|
+
*
|
|
385
|
+
* ```ts
|
|
386
|
+
* import { on } from "@secondlayer/stacks/filters";
|
|
387
|
+
*
|
|
388
|
+
* const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });
|
|
389
|
+
*
|
|
390
|
+
* sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull
|
|
391
|
+
* sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });
|
|
392
|
+
* sl.subscriptions.create({ name, url, triggers: [usdc.toChainTrigger()] });
|
|
393
|
+
* defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });
|
|
394
|
+
* ```
|
|
395
|
+
*
|
|
396
|
+
* A surface a member can't reach is a missing method (compile error), and a
|
|
397
|
+
* field a surface can't express throws at projection time — never a silent
|
|
398
|
+
* zero-row or over-wide match.
|
|
399
|
+
*/
|
|
400
|
+
declare const on: OnNamespace;
|
|
1
401
|
/** Account derived from a local private key (mnemonic or raw key). */
|
|
2
402
|
type LocalAccount = {
|
|
3
403
|
type: "local"
|
|
@@ -1341,155 +1741,6 @@ type WebSocketTransport = Transport & {
|
|
|
1341
1741
|
* HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
|
|
1342
1742
|
*/
|
|
1343
1743
|
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
1744
|
/** Create a ProviderAccount by querying the wallet for addresses */
|
|
1494
1745
|
declare function providerToAccount(provider: StacksProvider): Promise<ProviderAccount>;
|
|
1495
1746
|
/** Stacks mainnet chain definition (Hiro API). */
|
|
@@ -1512,20 +1763,6 @@ declare function formatStx(microStx: bigint | number | string): string;
|
|
|
1512
1763
|
* @example parseStx("1.5") → 1500000n
|
|
1513
1764
|
*/
|
|
1514
1765
|
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
1766
|
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
1530
1767
|
declare const isValidAddress: (address: string) => boolean;
|
|
1531
1768
|
/**
|
|
@@ -1616,4 +1853,4 @@ declare class MalformedResponseError extends BaseError {
|
|
|
1616
1853
|
declare class WebSocketError extends BaseError {
|
|
1617
1854
|
name: string;
|
|
1618
1855
|
}
|
|
1619
|
-
export { webSocket, walletActions, waitForTransactionReceipt2 as waitForTransactionReceipt, testnet, startNonceReconciler, resolveNonce, redisStore, reconcileNonce, publicActions, providerToAccount, postgresStore, parseStx,
|
|
1856
|
+
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 };
|