@secondlayer/stacks 6.1.0 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/stacks-esm-0pc6tmf0.js +50 -0
- package/dist/shared/{stacks-esm-743jfh10.js.map → stacks-esm-0pc6tmf0.js.map} +2 -2
- package/dist/shared/{stacks-esm-0rdxcta7.js → stacks-esm-16d82wyc.js} +10 -10
- package/dist/shared/{stacks-esm-0rdxcta7.js.map → stacks-esm-16d82wyc.js.map} +2 -2
- package/dist/shared/{stacks-esm-cvhazvhd.js → stacks-esm-7a0ehykf.js} +43 -43
- package/dist/shared/{stacks-esm-cvhazvhd.js.map → stacks-esm-7a0ehykf.js.map} +2 -2
- package/dist/shared/{stacks-esm-1jae0a3r.js → stacks-esm-7v18h5dk.js} +4 -4
- package/dist/shared/{stacks-esm-1jae0a3r.js.map → stacks-esm-7v18h5dk.js.map} +2 -2
- package/dist/shared/{stacks-esm-9rnx0zxr.js → stacks-esm-8f5catbf.js} +126 -126
- package/dist/shared/{stacks-esm-9rnx0zxr.js.map → stacks-esm-8f5catbf.js.map} +2 -2
- package/dist/shared/{stacks-esm-7fpqgtyx.js → stacks-esm-8jt6k8p3.js} +13 -13
- package/dist/shared/{stacks-esm-7fpqgtyx.js.map → stacks-esm-8jt6k8p3.js.map} +2 -2
- package/dist/shared/{stacks-esm-hr7fpxtj.js → stacks-esm-a20wyky3.js} +92 -92
- package/dist/shared/{stacks-esm-hr7fpxtj.js.map → stacks-esm-a20wyky3.js.map} +2 -2
- package/dist/shared/{stacks-esm-3pv5avgr.js → stacks-esm-b54n1jdx.js} +54 -54
- package/dist/shared/{stacks-esm-3pv5avgr.js.map → stacks-esm-b54n1jdx.js.map} +2 -2
- package/dist/shared/{stacks-esm-r9q4wnyw.js → stacks-esm-cmtj5vky.js} +162 -162
- package/dist/shared/{stacks-esm-r9q4wnyw.js.map → stacks-esm-cmtj5vky.js.map} +2 -2
- package/dist/shared/{stacks-esm-wv67m4g6.js → stacks-esm-e2qhfgke.js} +36 -36
- package/dist/shared/{stacks-esm-wv67m4g6.js.map → stacks-esm-e2qhfgke.js.map} +2 -2
- package/dist/shared/{stacks-esm-qk0p9fr6.js → stacks-esm-ea4m4bk7.js} +117 -117
- package/dist/shared/{stacks-esm-qk0p9fr6.js.map → stacks-esm-ea4m4bk7.js.map} +2 -2
- package/dist/shared/{stacks-esm-fcfdn2zx.js → stacks-esm-hkw1kvd4.js} +140 -140
- package/dist/shared/{stacks-esm-fcfdn2zx.js.map → stacks-esm-hkw1kvd4.js.map} +2 -2
- package/dist/shared/{stacks-esm-qkj67g80.js → stacks-esm-k108pemv.js} +4 -4
- package/dist/shared/{stacks-esm-qkj67g80.js.map → stacks-esm-k108pemv.js.map} +2 -2
- package/dist/shared/stacks-esm-kbz5s6v8.js +84 -0
- package/dist/shared/{stacks-esm-2mc7ebrm.js.map → stacks-esm-kbz5s6v8.js.map} +2 -2
- package/dist/shared/{stacks-esm-n53kvwmt.js → stacks-esm-mt1thm7k.js} +9 -9
- package/dist/shared/{stacks-esm-n53kvwmt.js.map → stacks-esm-mt1thm7k.js.map} +2 -2
- package/dist/shared/{stacks-esm-v45990hx.js → stacks-esm-n1mekwnb.js} +9 -9
- package/dist/shared/{stacks-esm-v45990hx.js.map → stacks-esm-n1mekwnb.js.map} +2 -2
- package/dist/shared/{stacks-esm-r6dejrgr.js → stacks-esm-nt5hf8ht.js} +34 -34
- package/dist/shared/{stacks-esm-r6dejrgr.js.map → stacks-esm-nt5hf8ht.js.map} +2 -2
- package/dist/shared/{stacks-esm-skmcf5n2.js → stacks-esm-phgy8yqf.js} +210 -210
- package/dist/shared/{stacks-esm-skmcf5n2.js.map → stacks-esm-phgy8yqf.js.map} +2 -2
- package/dist/shared/{stacks-esm-kds4n82p.js → stacks-esm-pxv6ny92.js} +116 -116
- package/dist/shared/{stacks-esm-kds4n82p.js.map → stacks-esm-pxv6ny92.js.map} +2 -2
- package/dist/shared/{stacks-esm-3g33bqsm.js → stacks-esm-qfzxhdqz.js} +19 -19
- package/dist/shared/{stacks-esm-3g33bqsm.js.map → stacks-esm-qfzxhdqz.js.map} +2 -2
- package/dist/shared/{stacks-esm-aw2mj3sj.js → stacks-esm-snj9s2q8.js} +43 -43
- package/dist/shared/{stacks-esm-aw2mj3sj.js.map → stacks-esm-snj9s2q8.js.map} +2 -2
- package/dist/shared/{stacks-esm-q19a17fd.js → stacks-esm-ss9ap75h.js} +28 -28
- package/dist/shared/{stacks-esm-q19a17fd.js.map → stacks-esm-ss9ap75h.js.map} +2 -2
- package/dist/shared/{stacks-esm-x1r01353.js → stacks-esm-t88hc019.js} +18 -18
- package/dist/shared/{stacks-esm-x1r01353.js.map → stacks-esm-t88hc019.js.map} +2 -2
- package/dist/shared/stacks-esm-tdrdye4y.js +48 -0
- package/dist/shared/{stacks-esm-pxhfqfff.js.map → stacks-esm-tdrdye4y.js.map} +2 -2
- package/dist/src/accounts/index.cjs +15 -13
- package/dist/src/accounts/index.cjs.map +2 -2
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/accounts/index.js +26 -26
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +83 -81
- package/dist/src/actions/index.cjs.map +2 -2
- package/dist/src/actions/index.d.cts +1 -1
- package/dist/src/actions/index.d.ts +1 -1
- package/dist/src/actions/index.js +102 -103
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +2035 -2036
- package/dist/src/bitcoin/index.cjs.map +8 -8
- package/dist/src/bitcoin/index.d.cts +92 -92
- package/dist/src/bitcoin/index.d.ts +92 -92
- package/dist/src/bitcoin/index.js +88 -90
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +3313 -3310
- package/dist/src/bns/index.cjs.map +13 -13
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +39 -41
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.cjs +14 -12
- package/dist/src/chains/index.cjs.map +2 -2
- package/dist/src/chains/index.d.cts +1 -1
- package/dist/src/chains/index.d.ts +1 -1
- package/dist/src/chains/index.js +12 -12
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +98 -96
- package/dist/src/clarity/index.cjs.map +2 -2
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/clarity/index.js +170 -171
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +27 -20
- package/dist/src/connect/index.cjs.map +3 -3
- package/dist/src/connect/index.d.cts +1 -1
- package/dist/src/connect/index.d.ts +1 -1
- package/dist/src/connect/index.js +27 -20
- package/dist/src/connect/index.js.map +3 -3
- package/dist/src/connect/walletconnect/index.cjs +6 -46
- package/dist/src/connect/walletconnect/index.cjs.map +3 -4
- package/dist/src/connect/walletconnect/index.d.cts +1 -1
- package/dist/src/connect/walletconnect/index.d.ts +1 -1
- package/dist/src/connect/walletconnect/index.js +6 -46
- package/dist/src/connect/walletconnect/index.js.map +3 -4
- package/dist/src/filters/index.cjs +22 -20
- package/dist/src/filters/index.cjs.map +2 -2
- package/dist/src/filters/index.d.cts +1 -1
- package/dist/src/filters/index.d.ts +1 -1
- package/dist/src/filters/index.js +30 -30
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/index.cjs +1411 -1410
- package/dist/src/index.cjs.map +11 -11
- package/dist/src/index.d.cts +724 -724
- package/dist/src/index.d.ts +724 -724
- package/dist/src/index.js +219 -219
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.cjs +26 -24
- package/dist/src/postconditions/index.cjs.map +2 -2
- package/dist/src/postconditions/index.d.cts +1 -1
- package/dist/src/postconditions/index.d.ts +1 -1
- package/dist/src/postconditions/index.js +16 -17
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +722 -721
- package/dist/src/pox/index.cjs.map +9 -9
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +40 -41
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +141 -137
- package/dist/src/pox5/index.cjs.map +3 -3
- package/dist/src/pox5/index.d.cts +9 -1
- package/dist/src/pox5/index.d.ts +9 -1
- package/dist/src/pox5/index.js +210 -209
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +71 -69
- package/dist/src/sbtc/index.cjs.map +2 -2
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +39 -40
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/simnet/index.cjs +16 -16
- package/dist/src/simnet/index.cjs.map +2 -2
- package/dist/src/simnet/index.d.cts +1 -1
- package/dist/src/simnet/index.d.ts +1 -1
- package/dist/src/simnet/index.js +16 -16
- package/dist/src/simnet/index.js.map +2 -2
- package/dist/src/stackingdao/index.cjs +716 -715
- package/dist/src/stackingdao/index.cjs.map +9 -9
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +26 -27
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.cjs +15 -13
- package/dist/src/subscriptions/index.cjs.map +2 -2
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/subscriptions/index.js +14 -15
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.cjs +79 -77
- package/dist/src/transactions/index.cjs.map +2 -2
- package/dist/src/transactions/index.d.cts +1 -1
- package/dist/src/transactions/index.d.ts +1 -1
- package/dist/src/transactions/index.js +104 -105
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +76 -74
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.d.cts +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +131 -131
- package/dist/src/utils/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-esm-2mc7ebrm.js +0 -84
- package/dist/shared/stacks-esm-743jfh10.js +0 -50
- package/dist/shared/stacks-esm-pxhfqfff.js +0 -48
package/dist/src/index.d.cts
CHANGED
|
@@ -1,522 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* the five sBTC lifecycle types (Webhooks-only). */
|
|
12
|
-
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", "nested_contract_call", "var_set", "map_set", "map_insert", "map_delete", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed"];
|
|
13
|
-
type ChainEventFilterType = (typeof CHAIN_EVENT_FILTER_TYPES)[number];
|
|
14
|
-
/** C32-encoded address version bytes for single-sig and multi-sig on each network. */
|
|
15
|
-
declare const AddressVersion: {
|
|
16
|
-
readonly MainnetSingleSig: 22
|
|
17
|
-
readonly MainnetMultiSig: 20
|
|
18
|
-
readonly TestnetSingleSig: 26
|
|
19
|
-
readonly TestnetMultiSig: 21
|
|
1
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
2
|
+
type LocalAccount = {
|
|
3
|
+
type: "local"
|
|
4
|
+
address: string
|
|
5
|
+
/** Compressed public key (hex) */
|
|
6
|
+
publicKey: string
|
|
7
|
+
/** Raw ECDSA sign over a hash */
|
|
8
|
+
sign(hash: Uint8Array): Uint8Array
|
|
9
|
+
/** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */
|
|
10
|
+
signMessage(message: string | Uint8Array): string
|
|
20
11
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
declare const MICROSTX_PER_STX = 1000000n;
|
|
28
|
-
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
29
|
-
declare const isValidAddress: (address: string) => boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Compare two Stacks addresses for equality (case-insensitive, version-aware).
|
|
32
|
-
* Throws if either address is invalid.
|
|
33
|
-
*/
|
|
34
|
-
declare function isAddressEqual(a: string, b: string): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Build a contract address from deployer + contract name.
|
|
37
|
-
* Validates both parts; returns `deployer.contractName`.
|
|
38
|
-
*/
|
|
39
|
-
declare function getContractAddress(deployer: string, contractName: string): string;
|
|
40
|
-
type AbiUInt128 = "uint128";
|
|
41
|
-
type AbiInt128 = "int128";
|
|
42
|
-
type AbiBool = "bool";
|
|
43
|
-
type AbiPrincipal = "principal";
|
|
44
|
-
type AbiTraitReference = "trait_reference";
|
|
45
|
-
type AbiNone = "none";
|
|
46
|
-
type AbiStringAscii<L extends number = number> = {
|
|
47
|
-
"string-ascii": {
|
|
48
|
-
length: L
|
|
49
|
-
}
|
|
12
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
13
|
+
type CustomAccount = {
|
|
14
|
+
type: "custom"
|
|
15
|
+
address: string
|
|
16
|
+
publicKey: string
|
|
17
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
50
18
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
19
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
20
|
+
type StacksProvider = {
|
|
21
|
+
request(method: string, params?: any): Promise<any>
|
|
55
22
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
24
|
+
type ProviderAccount = {
|
|
25
|
+
type: "provider"
|
|
26
|
+
address: string
|
|
27
|
+
publicKey: string
|
|
28
|
+
provider: StacksProvider
|
|
60
29
|
};
|
|
61
|
-
type
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type: AbiType
|
|
65
|
-
length: number
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
interface AbiTupleType {
|
|
69
|
-
tuple: ReadonlyArray<{
|
|
70
|
-
name: string
|
|
71
|
-
type: AbiType
|
|
72
|
-
}>;
|
|
73
|
-
}
|
|
74
|
-
interface AbiOptionalType {
|
|
75
|
-
optional: AbiType;
|
|
76
|
-
}
|
|
77
|
-
interface AbiResponseType {
|
|
78
|
-
response: {
|
|
79
|
-
ok: AbiType
|
|
80
|
-
error: AbiType
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/** Discriminated union of all Clarity value types (primitives, buffers, lists, tuples, optionals, responses). */
|
|
84
|
-
type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
|
|
85
|
-
type FunctionAccess = "public" | "read-only" | "private";
|
|
86
|
-
interface FunctionArg {
|
|
87
|
-
name: string;
|
|
88
|
-
type: AbiType;
|
|
89
|
-
}
|
|
90
|
-
/** A single Clarity function definition with name, access level, arguments, and return type. */
|
|
91
|
-
interface AbiFunction {
|
|
92
|
-
name: string;
|
|
93
|
-
access: FunctionAccess;
|
|
94
|
-
args: ReadonlyArray<FunctionArg>;
|
|
95
|
-
outputs: AbiType;
|
|
96
|
-
}
|
|
97
|
-
type VariableAccess = "constant" | "variable";
|
|
98
|
-
interface AbiVariable {
|
|
99
|
-
name: string;
|
|
100
|
-
type: AbiType;
|
|
101
|
-
access: VariableAccess;
|
|
102
|
-
}
|
|
103
|
-
interface AbiMap {
|
|
104
|
-
name: string;
|
|
105
|
-
key: AbiType;
|
|
106
|
-
value: AbiType;
|
|
107
|
-
}
|
|
108
|
-
interface AbiFungibleToken {
|
|
109
|
-
name: string;
|
|
110
|
-
}
|
|
111
|
-
interface AbiNonFungibleToken {
|
|
112
|
-
name: string;
|
|
113
|
-
type: AbiType;
|
|
114
|
-
}
|
|
115
|
-
type TraitFunctionAccess = Exclude<FunctionAccess, "private">;
|
|
116
|
-
interface AbiTraitFunction {
|
|
117
|
-
name: string;
|
|
118
|
-
access: TraitFunctionAccess;
|
|
119
|
-
args: ReadonlyArray<FunctionArg>;
|
|
120
|
-
outputs: AbiType;
|
|
121
|
-
}
|
|
122
|
-
interface AbiTraitDefinition {
|
|
123
|
-
name: string;
|
|
124
|
-
functions: ReadonlyArray<AbiTraitFunction>;
|
|
125
|
-
}
|
|
126
|
-
/** Full Clarity contract ABI including functions, maps, variables, and token definitions. */
|
|
127
|
-
interface AbiContract {
|
|
128
|
-
functions: ReadonlyArray<AbiFunction>;
|
|
129
|
-
maps?: ReadonlyArray<AbiMap>;
|
|
130
|
-
variables?: ReadonlyArray<AbiVariable>;
|
|
131
|
-
fungible_tokens?: ReadonlyArray<AbiFungibleToken>;
|
|
132
|
-
non_fungible_tokens?: ReadonlyArray<AbiNonFungibleToken>;
|
|
133
|
-
implemented_traits?: ReadonlyArray<string>;
|
|
134
|
-
defined_traits?: ReadonlyArray<AbiTraitDefinition>;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* `<contract>::<asset-name>` — the shape a fungible/non-fungible asset filter
|
|
138
|
-
* takes, expressed so the compiler can check it.
|
|
139
|
-
*
|
|
140
|
-
* The most common mistake in this API is passing a CONTRACT ID
|
|
141
|
-
* (`SP….sbtc-token`) where an asset identifier (`SP….sbtc-token::sbtc-token`)
|
|
142
|
-
* belongs, and the failure mode is a query that quietly returns zero rows. The
|
|
143
|
-
* two differ structurally by `::`, so a template-literal type catches it at the
|
|
144
|
-
* call site — no brand, no cast, literals just work.
|
|
145
|
-
*
|
|
146
|
-
* A value that is only known at runtime (config, env) is not narrow enough on
|
|
147
|
-
* purpose; run it through {@link assetId} once, which validates and narrows.
|
|
148
|
-
*
|
|
149
|
-
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm — they
|
|
150
|
-
* are legitimately not full identifiers (`SPB.*`), and the runtime validator
|
|
151
|
-
* short-circuits on them for the same reason.
|
|
152
|
-
*/
|
|
153
|
-
type AssetIdentifier = `${string}::${string}` | `${string}*${string}`;
|
|
154
|
-
/** Scalar print field types (structural mirror of the subgraphs `ColumnType`). */
|
|
155
|
-
type PrintScalarType = "uint" | "int" | "text" | "principal" | "boolean" | "timestamp" | "jsonb";
|
|
156
|
-
/**
|
|
157
|
-
* One declared print field — structural mirror of `PrintField` in
|
|
158
|
-
* `@secondlayer/subgraphs`. Composite forms exist because real print payloads
|
|
159
|
-
* nest: a vocabulary that could only say `"jsonb"` is what let a flat-field
|
|
160
|
-
* declaration type-check while every event decoded to null.
|
|
161
|
-
*
|
|
162
|
-
* Kept literal through `toSubgraphSource()` so handler narrowing survives.
|
|
163
|
-
*/
|
|
164
|
-
type PrintFieldType = PrintScalarType | {
|
|
165
|
-
type: PrintFieldType
|
|
166
|
-
optional: true
|
|
167
|
-
} | {
|
|
168
|
-
tuple: Record<string, PrintFieldType>
|
|
169
|
-
} | {
|
|
170
|
-
list: PrintFieldType
|
|
30
|
+
type IntCV = {
|
|
31
|
+
readonly type: "int"
|
|
32
|
+
readonly value: bigint
|
|
171
33
|
};
|
|
172
|
-
|
|
173
|
-
type: "
|
|
174
|
-
|
|
175
|
-
recipient?: string;
|
|
176
|
-
minAmount?: bigint;
|
|
177
|
-
maxAmount?: bigint;
|
|
178
|
-
}
|
|
179
|
-
interface StxMintSpec {
|
|
180
|
-
type: "stx_mint";
|
|
181
|
-
recipient?: string;
|
|
182
|
-
minAmount?: bigint;
|
|
183
|
-
}
|
|
184
|
-
interface StxBurnSpec {
|
|
185
|
-
type: "stx_burn";
|
|
186
|
-
sender?: string;
|
|
187
|
-
minAmount?: bigint;
|
|
188
|
-
}
|
|
189
|
-
interface StxLockSpec {
|
|
190
|
-
type: "stx_lock";
|
|
191
|
-
lockedAddress?: string;
|
|
192
|
-
minAmount?: bigint;
|
|
193
|
-
}
|
|
194
|
-
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
195
|
-
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
196
|
-
* trait resolution — `toStreamsParams()` throws if set. */
|
|
197
|
-
type TraitScope = {
|
|
198
|
-
trait?: string
|
|
34
|
+
type UIntCV = {
|
|
35
|
+
readonly type: "uint"
|
|
36
|
+
readonly value: bigint
|
|
199
37
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
* `stacks` is the dependency-graph leaf and cannot import it. */
|
|
204
|
-
type FactoryScope = {
|
|
205
|
-
factory?: {
|
|
206
|
-
/** Source name whose events reveal the addresses. */
|
|
207
|
-
from: string
|
|
208
|
-
/** Dotted path to the address on that source's payload (e.g. "data.pool"). */
|
|
209
|
-
field: string
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
interface FtTransferSpec extends TraitScope {
|
|
213
|
-
type: "ft_transfer";
|
|
214
|
-
assetIdentifier?: AssetIdentifier;
|
|
215
|
-
sender?: string;
|
|
216
|
-
recipient?: string;
|
|
217
|
-
minAmount?: bigint;
|
|
218
|
-
}
|
|
219
|
-
interface FtMintSpec extends TraitScope {
|
|
220
|
-
type: "ft_mint";
|
|
221
|
-
assetIdentifier?: AssetIdentifier;
|
|
222
|
-
recipient?: string;
|
|
223
|
-
minAmount?: bigint;
|
|
224
|
-
}
|
|
225
|
-
interface FtBurnSpec extends TraitScope {
|
|
226
|
-
type: "ft_burn";
|
|
227
|
-
assetIdentifier?: AssetIdentifier;
|
|
228
|
-
sender?: string;
|
|
229
|
-
minAmount?: bigint;
|
|
230
|
-
}
|
|
231
|
-
interface NftTransferSpec extends TraitScope {
|
|
232
|
-
type: "nft_transfer";
|
|
233
|
-
assetIdentifier?: AssetIdentifier;
|
|
234
|
-
sender?: string;
|
|
235
|
-
recipient?: string;
|
|
236
|
-
}
|
|
237
|
-
interface NftMintSpec extends TraitScope {
|
|
238
|
-
type: "nft_mint";
|
|
239
|
-
assetIdentifier?: AssetIdentifier;
|
|
240
|
-
recipient?: string;
|
|
241
|
-
}
|
|
242
|
-
interface NftBurnSpec extends TraitScope {
|
|
243
|
-
type: "nft_burn";
|
|
244
|
-
assetIdentifier?: AssetIdentifier;
|
|
245
|
-
sender?: string;
|
|
246
|
-
}
|
|
247
|
-
interface ContractCallSpec extends TraitScope, FactoryScope {
|
|
248
|
-
type: "contract_call";
|
|
249
|
-
/** One contract id, or a set of them (max 20). Mirrors the subgraphs
|
|
250
|
-
* filter — a router plus its pools is one source, not N. */
|
|
251
|
-
contractId?: string | readonly string[];
|
|
252
|
-
functionName?: string;
|
|
253
|
-
caller?: string;
|
|
254
|
-
/** Contract ABI (`as const`) — preserved literally so `toSubgraphSource()`
|
|
255
|
-
* keeps typing `event.input` in `defineSubgraph`. */
|
|
256
|
-
abi?: AbiContract;
|
|
257
|
-
}
|
|
258
|
-
interface ContractDeploySpec {
|
|
259
|
-
type: "contract_deploy";
|
|
260
|
-
deployer?: string;
|
|
261
|
-
contractName?: string;
|
|
262
|
-
}
|
|
263
|
-
interface NestedContractCallSpec extends TraitScope, FactoryScope {
|
|
264
|
-
type: "nested_contract_call";
|
|
265
|
-
contractId?: string | readonly string[];
|
|
266
|
-
functionName?: string;
|
|
267
|
-
caller?: string;
|
|
268
|
-
sender?: string;
|
|
269
|
-
}
|
|
270
|
-
interface VarSetSpec extends TraitScope, FactoryScope {
|
|
271
|
-
type: "var_set";
|
|
272
|
-
contractId?: string | readonly string[];
|
|
273
|
-
varName?: string;
|
|
274
|
-
}
|
|
275
|
-
interface MapSetSpec extends TraitScope, FactoryScope {
|
|
276
|
-
type: "map_set";
|
|
277
|
-
contractId?: string | readonly string[];
|
|
278
|
-
map?: string;
|
|
279
|
-
}
|
|
280
|
-
interface MapInsertSpec extends TraitScope, FactoryScope {
|
|
281
|
-
type: "map_insert";
|
|
282
|
-
contractId?: string | readonly string[];
|
|
283
|
-
map?: string;
|
|
284
|
-
}
|
|
285
|
-
interface MapDeleteSpec extends TraitScope, FactoryScope {
|
|
286
|
-
type: "map_delete";
|
|
287
|
-
contractId?: string | readonly string[];
|
|
288
|
-
map?: string;
|
|
289
|
-
}
|
|
290
|
-
interface PrintEventSpec extends TraitScope, FactoryScope {
|
|
291
|
-
type: "print_event";
|
|
292
|
-
/** One contract id, or a set of them (max 20). */
|
|
293
|
-
contractId?: string | readonly string[];
|
|
294
|
-
topic?: string;
|
|
295
|
-
/** Per-topic field schema — preserved literally so `toSubgraphSource()`
|
|
296
|
-
* keeps the discriminated-union narrowing of `event.data`. */
|
|
297
|
-
prints?: Record<string, Record<string, PrintFieldType>>;
|
|
298
|
-
}
|
|
299
|
-
interface SbtcDepositSpec {
|
|
300
|
-
type: "sbtc_deposit";
|
|
301
|
-
sender?: string;
|
|
302
|
-
minAmount?: bigint;
|
|
303
|
-
maxAmount?: bigint;
|
|
304
|
-
bitcoinTxid?: string;
|
|
305
|
-
requestId?: number;
|
|
306
|
-
}
|
|
307
|
-
interface SbtcWithdrawalCreateSpec {
|
|
308
|
-
type: "sbtc_withdrawal_create";
|
|
309
|
-
sender?: string;
|
|
310
|
-
minAmount?: bigint;
|
|
311
|
-
maxAmount?: bigint;
|
|
312
|
-
requestId?: number;
|
|
313
|
-
}
|
|
314
|
-
interface SbtcWithdrawalAcceptSpec {
|
|
315
|
-
type: "sbtc_withdrawal_accept";
|
|
316
|
-
requestId?: number;
|
|
317
|
-
sweepTxid?: string;
|
|
318
|
-
}
|
|
319
|
-
interface SbtcWithdrawalRejectSpec {
|
|
320
|
-
type: "sbtc_withdrawal_reject";
|
|
321
|
-
requestId?: number;
|
|
322
|
-
}
|
|
323
|
-
interface SbtcWithdrawalSweptConfirmedSpec {
|
|
324
|
-
type: "sbtc_withdrawal_swept_confirmed";
|
|
325
|
-
requestId?: number;
|
|
326
|
-
sweepTxid?: string;
|
|
327
|
-
}
|
|
328
|
-
type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | NestedContractCallSpec | VarSetSpec | MapSetSpec | MapInsertSpec | MapDeleteSpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
|
|
329
|
-
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
330
|
-
type: T
|
|
331
|
-
}>;
|
|
332
|
-
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
333
|
-
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
334
|
-
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
335
|
-
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
|
336
|
-
type ChainTriggerOf<S> = { [K in keyof Omit<S, "abi" | "prints" | "factory">] : Exclude<S[K], bigint | readonly string[]> | (bigint extends S[K] ? string : never) };
|
|
337
|
-
/** Params fragment for `index.events.*` (spread into list/walk/consume). */
|
|
338
|
-
type IndexEventsParamsShape = {
|
|
339
|
-
eventType: DecodedEventType | VmEventType
|
|
340
|
-
/** A spec's contract set passes through verbatim (the API takes up to 20). */
|
|
341
|
-
contractId?: string | readonly string[]
|
|
342
|
-
assetIdentifier?: AssetIdentifier
|
|
343
|
-
sender?: string
|
|
344
|
-
recipient?: string
|
|
345
|
-
functionName?: string
|
|
346
|
-
caller?: string
|
|
347
|
-
map?: string
|
|
348
|
-
varName?: string
|
|
349
|
-
trait?: string
|
|
350
|
-
};
|
|
351
|
-
/** Params fragment for `index.contractCalls.*`. */
|
|
352
|
-
type ContractCallsParamsShape = {
|
|
353
|
-
/** A spec's contract set passes through verbatim (the API takes up to 20). */
|
|
354
|
-
contractId?: string | readonly string[]
|
|
355
|
-
functionName?: string
|
|
356
|
-
/** Populated from the spec's `caller` — the endpoint filters by tx sender,
|
|
357
|
-
* which is the caller. */
|
|
358
|
-
sender?: string
|
|
359
|
-
trait?: string
|
|
360
|
-
};
|
|
361
|
-
type VmMember = "nested_contract_call" | "var_set" | "map_set" | "map_insert" | "map_delete";
|
|
362
|
-
/** Params fragment for classic `streams.events.*` (Streams 1.0). VM members
|
|
363
|
-
* project to {@link StreamsVmParamsShape} instead — mixing the vocabularies
|
|
364
|
-
* here makes `events.consume({ ...on.ftTransfer().toStreamsParams(), onBatch })`
|
|
365
|
-
* fail type-check. */
|
|
366
|
-
type StreamsParamsShape = {
|
|
367
|
-
types: readonly DecodedEventType[]
|
|
368
|
-
contractId?: string | readonly string[]
|
|
369
|
-
sender?: string
|
|
370
|
-
recipient?: string
|
|
371
|
-
assetIdentifier?: AssetIdentifier
|
|
372
|
-
};
|
|
373
|
-
/** VM member projection: `clock` is the `"vm"` literal so SDK overload 1 matches. */
|
|
374
|
-
type StreamsVmParamsShape<T extends VmMember = VmMember> = {
|
|
375
|
-
types: readonly [T]
|
|
376
|
-
clock: "vm"
|
|
377
|
-
contractId?: string | readonly string[]
|
|
378
|
-
};
|
|
379
|
-
type DecodedMember = "stx_transfer" | "stx_mint" | "stx_burn" | "stx_lock" | "ft_transfer" | "ft_mint" | "ft_burn" | "nft_transfer" | "nft_mint" | "nft_burn" | "print_event";
|
|
380
|
-
type ProjectionsFor<
|
|
381
|
-
T extends ChainEventFilterType,
|
|
382
|
-
S
|
|
383
|
-
> = {
|
|
384
|
-
/** Wire trigger for `webhooks.create({ triggers: [...] })`. BigInt
|
|
385
|
-
* amounts become strings here — the one sanctioned boundary. */
|
|
386
|
-
toChainTrigger(): ChainTriggerOf<S>
|
|
387
|
-
} & (T extends DecodedMember | VmMember ? {
|
|
388
|
-
/** Params for `index.events.list/walk/consume` (merge your own
|
|
389
|
-
* `limit`/`fromHeight`/`txContext` etc. on top). */
|
|
390
|
-
toIndexParams<Extra extends Record<string, unknown>>(extra?: Extra): IndexEventsParamsShape & Extra
|
|
391
|
-
/** Params for `streams.events.list/consume/stream`. Throws if the
|
|
392
|
-
* filter uses `trait` (Streams has no trait resolution) or a
|
|
393
|
-
* min/max amount (Streams filters have no amount predicates). */
|
|
394
|
-
toStreamsParams<Extra extends Record<string, unknown> = Record<string, never>>(extra?: Extra): T extends VmMember ? StreamsVmParamsShape<T> & Extra : StreamsParamsShape & Extra
|
|
395
|
-
} : {}) & (T extends "contract_call" ? {
|
|
396
|
-
/** Params for `index.contractCalls.list/walk/consume`. */
|
|
397
|
-
toContractCallsParams<Extra extends Record<string, unknown>>(extra?: Extra): ContractCallsParamsShape & Extra
|
|
398
|
-
} : {}) & (T extends Exclude<ChainEventFilterType, `sbtc_${string}`> ? {
|
|
399
|
-
/** The `sources` entry for `defineSubgraph` — literal `prints`/`abi`
|
|
400
|
-
* types are preserved, so handler narrowing survives. */
|
|
401
|
-
toSubgraphSource(): S
|
|
402
|
-
} : {});
|
|
403
|
-
/**
|
|
404
|
-
* A canonical chain-event filter: the spec fields plus the projections its
|
|
405
|
-
* member supports. Write the filter once; project it to a query
|
|
406
|
-
* (`toIndexParams`), a stream (`toStreamsParams`), a webhook trigger
|
|
407
|
-
* (`toChainTrigger`), or a subgraph source (`toSubgraphSource`).
|
|
408
|
-
*/
|
|
409
|
-
type ChainEventFilter<
|
|
410
|
-
T extends ChainEventFilterType = ChainEventFilterType,
|
|
411
|
-
S extends {
|
|
412
|
-
type: T
|
|
413
|
-
} = SpecFor<T>
|
|
414
|
-
> = S & ProjectionsFor<T, S>;
|
|
415
|
-
type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
|
|
416
|
-
/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
|
|
417
|
-
* annotation on exported values (an inferred object of generic factories
|
|
418
|
-
* collapses to `{}` in the emitted declarations). */
|
|
419
|
-
interface OnNamespace {
|
|
420
|
-
stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
|
|
421
|
-
stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
|
|
422
|
-
stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
|
|
423
|
-
stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
|
|
424
|
-
ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
|
|
425
|
-
ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
|
|
426
|
-
ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
|
|
427
|
-
nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
|
|
428
|
-
nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
|
|
429
|
-
nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
|
|
430
|
-
/** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps
|
|
431
|
-
* typing `event.input` inside `defineSubgraph`. */
|
|
432
|
-
contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
433
|
-
abi?: A
|
|
434
|
-
}): ChainEventFilter<"contract_call", {
|
|
435
|
-
type: "contract_call"
|
|
436
|
-
} & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
437
|
-
abi?: A
|
|
438
|
-
}>;
|
|
439
|
-
contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
|
|
440
|
-
/** Canonical member is `print_event` (as Subgraphs and Webhooks spell
|
|
441
|
-
* it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`
|
|
442
|
-
* literals are preserved (`const P`) for per-topic `event.data` narrowing. */
|
|
443
|
-
print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
444
|
-
prints?: P
|
|
445
|
-
}): ChainEventFilter<"print_event", {
|
|
446
|
-
type: "print_event"
|
|
447
|
-
} & Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
448
|
-
prints?: P
|
|
449
|
-
}>;
|
|
450
|
-
nestedCall(fields?: Fields<"nested_contract_call">): ChainEventFilter<"nested_contract_call">;
|
|
451
|
-
varSet(fields?: Fields<"var_set">): ChainEventFilter<"var_set">;
|
|
452
|
-
mapSet(fields?: Fields<"map_set">): ChainEventFilter<"map_set">;
|
|
453
|
-
mapInsert(fields?: Fields<"map_insert">): ChainEventFilter<"map_insert">;
|
|
454
|
-
mapDelete(fields?: Fields<"map_delete">): ChainEventFilter<"map_delete">;
|
|
455
|
-
sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
|
|
456
|
-
sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
|
|
457
|
-
sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
|
|
458
|
-
sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
|
|
459
|
-
sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* `on.*` — one filter vocabulary for every surface.
|
|
463
|
-
*
|
|
464
|
-
* ```ts
|
|
465
|
-
* import { on } from "@secondlayer/stacks/filters";
|
|
466
|
-
*
|
|
467
|
-
* const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });
|
|
468
|
-
*
|
|
469
|
-
* sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull
|
|
470
|
-
* sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });
|
|
471
|
-
* sl.webhooks.create({ name, url, triggers: [usdc.toChainTrigger()] });
|
|
472
|
-
* defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });
|
|
473
|
-
* ```
|
|
474
|
-
*
|
|
475
|
-
* A surface a member can't reach is a missing method (compile error), and a
|
|
476
|
-
* field a surface can't express throws at projection time — never a silent
|
|
477
|
-
* zero-row or over-wide match.
|
|
478
|
-
*/
|
|
479
|
-
declare const on: OnNamespace;
|
|
480
|
-
/** Account derived from a local private key (mnemonic or raw key). */
|
|
481
|
-
type LocalAccount = {
|
|
482
|
-
type: "local"
|
|
483
|
-
address: string
|
|
484
|
-
/** Compressed public key (hex) */
|
|
485
|
-
publicKey: string
|
|
486
|
-
/** Raw ECDSA sign over a hash */
|
|
487
|
-
sign(hash: Uint8Array): Uint8Array
|
|
488
|
-
/** Sign a raw UTF-8 / byte message (`sha256(bytes)`). Not SIP-018. */
|
|
489
|
-
signMessage(message: string | Uint8Array): string
|
|
490
|
-
};
|
|
491
|
-
/** Account with a user-provided signing function (sync or async). */
|
|
492
|
-
type CustomAccount = {
|
|
493
|
-
type: "custom"
|
|
494
|
-
address: string
|
|
495
|
-
publicKey: string
|
|
496
|
-
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
497
|
-
};
|
|
498
|
-
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
499
|
-
type StacksProvider = {
|
|
500
|
-
request(method: string, params?: any): Promise<any>
|
|
501
|
-
};
|
|
502
|
-
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
503
|
-
type ProviderAccount = {
|
|
504
|
-
type: "provider"
|
|
505
|
-
address: string
|
|
506
|
-
publicKey: string
|
|
507
|
-
provider: StacksProvider
|
|
508
|
-
};
|
|
509
|
-
type IntCV = {
|
|
510
|
-
readonly type: "int"
|
|
511
|
-
readonly value: bigint
|
|
512
|
-
};
|
|
513
|
-
type UIntCV = {
|
|
514
|
-
readonly type: "uint"
|
|
515
|
-
readonly value: bigint
|
|
516
|
-
};
|
|
517
|
-
type BooleanCV = TrueCV | FalseCV;
|
|
518
|
-
type TrueCV = {
|
|
519
|
-
readonly type: "true"
|
|
38
|
+
type BooleanCV = TrueCV | FalseCV;
|
|
39
|
+
type TrueCV = {
|
|
40
|
+
readonly type: "true"
|
|
520
41
|
};
|
|
521
42
|
type FalseCV = {
|
|
522
43
|
readonly type: "false"
|
|
@@ -1698,241 +1219,720 @@ type WalletActions = {
|
|
|
1698
1219
|
signMessage: (params: SignMessageParams) => Promise<string>
|
|
1699
1220
|
sponsorTransaction: (params: SponsorTransactionParams) => Promise<StacksTransaction>
|
|
1700
1221
|
};
|
|
1701
|
-
/** Decorator that binds {@link WalletActions} to a client instance. */
|
|
1702
|
-
declare function walletActions(client: Client): WalletActions;
|
|
1703
|
-
/** Configuration for {@link createWalletClient} — requires an account for signing. */
|
|
1704
|
-
type WalletClientConfig = ClientConfig & {
|
|
1705
|
-
account: Account
|
|
1222
|
+
/** Decorator that binds {@link WalletActions} to a client instance. */
|
|
1223
|
+
declare function walletActions(client: Client): WalletActions;
|
|
1224
|
+
/** Configuration for {@link createWalletClient} — requires an account for signing. */
|
|
1225
|
+
type WalletClientConfig = ClientConfig & {
|
|
1226
|
+
account: Account
|
|
1227
|
+
};
|
|
1228
|
+
/**
|
|
1229
|
+
* Create a client pre-extended with {@link WalletActions} for signing and broadcasting transactions.
|
|
1230
|
+
*/
|
|
1231
|
+
declare function createWalletClient(config: WalletClientConfig): Client<WalletActions> & WalletActions & {
|
|
1232
|
+
account: Account
|
|
1233
|
+
};
|
|
1234
|
+
type MultiSigTransferStxParams = {
|
|
1235
|
+
to: string
|
|
1236
|
+
amount: IntegerType
|
|
1237
|
+
memo?: string
|
|
1238
|
+
fee?: IntegerType
|
|
1239
|
+
nonce?: IntegerType
|
|
1240
|
+
postConditionMode?: PostConditionMode
|
|
1241
|
+
postConditions?: PostConditionInput[]
|
|
1242
|
+
};
|
|
1243
|
+
type MultiSigCallContractParams = {
|
|
1244
|
+
contract: string
|
|
1245
|
+
functionName: string
|
|
1246
|
+
functionArgs?: ClarityValue[]
|
|
1247
|
+
fee?: IntegerType
|
|
1248
|
+
nonce?: IntegerType
|
|
1249
|
+
postConditionMode?: PostConditionMode
|
|
1250
|
+
postConditions?: PostConditionInput[]
|
|
1251
|
+
};
|
|
1252
|
+
type MultiSigDeployContractParams = {
|
|
1253
|
+
contractName: string
|
|
1254
|
+
codeBody: string
|
|
1255
|
+
clarityVersion?: ClarityVersion
|
|
1256
|
+
fee?: IntegerType
|
|
1257
|
+
nonce?: IntegerType
|
|
1258
|
+
postConditionMode?: PostConditionMode
|
|
1259
|
+
postConditions?: PostConditionInput[]
|
|
1260
|
+
};
|
|
1261
|
+
type MultiSigSendTransactionParams = {
|
|
1262
|
+
transaction: StacksTransaction
|
|
1263
|
+
attachment?: Uint8Array | string
|
|
1264
|
+
};
|
|
1265
|
+
/** Multi-sig transaction actions: build unsigned transactions and broadcast with auto-finalization. */
|
|
1266
|
+
type MultiSigActions = {
|
|
1267
|
+
transferStx: (params: MultiSigTransferStxParams) => Promise<StacksTransaction>
|
|
1268
|
+
callContract: (params: MultiSigCallContractParams) => Promise<StacksTransaction>
|
|
1269
|
+
deployContract: (params: MultiSigDeployContractParams) => Promise<StacksTransaction>
|
|
1270
|
+
sendTransaction: (params: MultiSigSendTransactionParams) => Promise<SendTransactionResult>
|
|
1271
|
+
};
|
|
1272
|
+
/** Decorator that binds {@link MultiSigActions} to a multi-sig client. */
|
|
1273
|
+
declare function multisigActions(client: Client): MultiSigActions;
|
|
1274
|
+
/** Configuration for {@link createMultiSigClient} — requires signer public keys and threshold. */
|
|
1275
|
+
type MultiSigClientConfig = Omit<ClientConfig, "account"> & {
|
|
1276
|
+
signers: string[]
|
|
1277
|
+
requiredSignatures: number
|
|
1278
|
+
hashMode?: MultiSigHashMode
|
|
1279
|
+
};
|
|
1280
|
+
/** A client pre-extended with {@link MultiSigActions} for m-of-n signing flows. */
|
|
1281
|
+
type MultiSigClient = Client<MultiSigActions> & MultiSigActions;
|
|
1282
|
+
/**
|
|
1283
|
+
* Create a client for multi-sig transaction flows.
|
|
1284
|
+
* Builds unsigned transactions that can be signed by each party then broadcast.
|
|
1285
|
+
*/
|
|
1286
|
+
declare function createMultiSigClient(config: MultiSigClientConfig): MultiSigClient;
|
|
1287
|
+
/**
|
|
1288
|
+
* Persisted {@link NonceStore} adapters for multi-process / multi-builder
|
|
1289
|
+
* deployments (the smart-wallet-as-a-service case).
|
|
1290
|
+
*
|
|
1291
|
+
* The in-memory {@link memoryStore} is correct only within one process: two
|
|
1292
|
+
* workers sharing a signing key both read the same confirmed floor and collide.
|
|
1293
|
+
* These adapters move the atomic reserve into a shared datastore — Redis `INCR`
|
|
1294
|
+
* inside an `EVAL`, or a single Postgres upsert under a row lock — so the store
|
|
1295
|
+
* itself becomes the cross-process lock and the durable source of truth.
|
|
1296
|
+
*
|
|
1297
|
+
* Both are dependency-injected: pass your own `Bun.redis` / `Bun.sql` client.
|
|
1298
|
+
* No global `Bun` reference, so importing this module is runtime-agnostic.
|
|
1299
|
+
*/
|
|
1300
|
+
/** Minimal structural shape of a `Bun.redis` client (the `send` escape hatch). */
|
|
1301
|
+
type RedisLike = {
|
|
1302
|
+
send(command: string, args: string[]): Promise<unknown>
|
|
1303
|
+
};
|
|
1304
|
+
type RedisStoreParams = {
|
|
1305
|
+
redis: RedisLike
|
|
1306
|
+
/** Key prefix for stored nonce counters. Default `"stacks:nonce:"`. */
|
|
1307
|
+
prefix?: string
|
|
1308
|
+
};
|
|
1309
|
+
/**
|
|
1310
|
+
* Redis-backed nonce store. The atomic reserve lives in a Lua `EVAL`, so it is
|
|
1311
|
+
* safe across processes sharing one Redis. The confirmed floor (`getFloor`) is
|
|
1312
|
+
* read only once per key, on cold start.
|
|
1313
|
+
*/
|
|
1314
|
+
declare function redisStore(params: RedisStoreParams): NonceStore;
|
|
1315
|
+
/** Minimal structural shape of a `Bun.sql` tagged-template client. */
|
|
1316
|
+
type SqlLike = (strings: TemplateStringsArray, ...values: unknown[]) => Promise<Array<Record<string, unknown>>>;
|
|
1317
|
+
type PostgresStoreParams = {
|
|
1318
|
+
sql: SqlLike
|
|
1319
|
+
/**
|
|
1320
|
+
* Run `CREATE TABLE IF NOT EXISTS stacks_nonce_state` lazily on first use.
|
|
1321
|
+
* Default `true`. Set `false` if you manage the schema via migrations.
|
|
1322
|
+
*/
|
|
1323
|
+
ensureTable?: boolean
|
|
1324
|
+
};
|
|
1325
|
+
/**
|
|
1326
|
+
* Postgres-backed nonce store. Each reserve is a single atomic statement under
|
|
1327
|
+
* a row lock, so concurrent reservers on the same key serialize and never
|
|
1328
|
+
* collide across processes. State is durable — survives restarts.
|
|
1329
|
+
*
|
|
1330
|
+
* Uses a fixed table `stacks_nonce_state (key text primary key, next numeric)`.
|
|
1331
|
+
*/
|
|
1332
|
+
declare function postgresStore(params: PostgresStoreParams): NonceStore;
|
|
1333
|
+
/**
|
|
1334
|
+
* Mempool-aware {@link NonceManagerSource}s.
|
|
1335
|
+
*
|
|
1336
|
+
* The default {@link jsonRpcSource} reads only the confirmed nonce, so a tx
|
|
1337
|
+
* sitting in the mempool is invisible — broadcasting many quickly forces manual
|
|
1338
|
+
* tracking. These sources fold pending (mempool) txs into the next-nonce
|
|
1339
|
+
* computation. The gap-filling core is generic; where the pending set comes from
|
|
1340
|
+
* is pluggable, so you are never locked to any one provider:
|
|
1341
|
+
*
|
|
1342
|
+
* - {@link mempoolAwareSource} — bring your own `getPending`.
|
|
1343
|
+
* - {@link indexSource}: prebuilt over a Secondlayer instance's `/v1/index/mempool`.
|
|
1344
|
+
* - {@link hiroNonceSource} — prebuilt over Hiro's `/extended` nonces endpoint.
|
|
1345
|
+
*/
|
|
1346
|
+
type FetchImpl = typeof globalThis.fetch;
|
|
1347
|
+
/**
|
|
1348
|
+
* The next free nonce ≥ `confirmed` not already taken by a pending tx.
|
|
1349
|
+
*
|
|
1350
|
+
* Unlike Hiro's `possible_next_nonce` (which is `max(pending) + 1` and strands
|
|
1351
|
+
* higher txs when a lower nonce is missing), this FILLS gaps: it returns the
|
|
1352
|
+
* lowest unused slot, so a dropped-tx hole is reused instead of stranding the
|
|
1353
|
+
* chain.
|
|
1354
|
+
*/
|
|
1355
|
+
declare function nextFreeNonce(confirmed: bigint, pending: bigint[]): bigint;
|
|
1356
|
+
type MempoolAwareSourceParams = {
|
|
1357
|
+
/** Pending (mempool) nonces for an address. */
|
|
1358
|
+
getPending: (args: {
|
|
1359
|
+
client: Client
|
|
1360
|
+
address: string
|
|
1361
|
+
}) => Promise<bigint[]>
|
|
1362
|
+
/**
|
|
1363
|
+
* Confirmed-nonce floor. Defaults to the node's `/v2/accounts` read — the
|
|
1364
|
+
* user's own node via the client transport, no provider dependency.
|
|
1365
|
+
*/
|
|
1366
|
+
getConfirmed?: (args: {
|
|
1367
|
+
client: Client
|
|
1368
|
+
address: string
|
|
1369
|
+
}) => Promise<bigint>
|
|
1370
|
+
};
|
|
1371
|
+
/**
|
|
1372
|
+
* Build a gap-filling, mempool-aware source from any `getPending`. The confirmed
|
|
1373
|
+
* floor defaults to the node read; if `getPending` throws, the source degrades
|
|
1374
|
+
* to confirmed-only rather than blocking a broadcast. A misconfigured pending
|
|
1375
|
+
* feed ({@link IndexSourceConfigError}) is rethrown: it would fail on every
|
|
1376
|
+
* read, and degrading silently would hide that the mempool is never consulted.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function mempoolAwareSource(params: MempoolAwareSourceParams): NonceManagerSource;
|
|
1379
|
+
type IndexSourceParams = {
|
|
1380
|
+
/**
|
|
1381
|
+
* URL of your Secondlayer instance. Without it the client's transport
|
|
1382
|
+
* URL is assumed to be the instance: a transport on a Hiro host throws
|
|
1383
|
+
* up front, and a host that answers `/v1/index` with a non-JSON 404
|
|
1384
|
+
* (a bare stacks-node) throws on the first read. Neither is degraded
|
|
1385
|
+
* to the confirmed floor. Pass it whenever the transport is not the
|
|
1386
|
+
* instance.
|
|
1387
|
+
*/
|
|
1388
|
+
baseUrl?: string
|
|
1389
|
+
/** Instance token, sent as `Authorization: Bearer`. */
|
|
1390
|
+
apiKey?: string
|
|
1391
|
+
/** Max mempool pages to read per address. Default 10 (×200 = 2000 txs). */
|
|
1392
|
+
maxPages?: number
|
|
1393
|
+
/** Override the confirmed floor (defaults to the node read). */
|
|
1394
|
+
getConfirmed?: (args: {
|
|
1395
|
+
client: Client
|
|
1396
|
+
address: string
|
|
1397
|
+
}) => Promise<bigint>
|
|
1706
1398
|
};
|
|
1707
1399
|
/**
|
|
1708
|
-
*
|
|
1400
|
+
* Mempool-aware source backed by a Secondlayer instance's `/v1/index/mempool`.
|
|
1401
|
+
* Requests go through the transport layer (retries, timeout, typed errors).
|
|
1402
|
+
* The instance's mempool is a go-forward view observed by its own node, so
|
|
1403
|
+
* it can lag or miss transactions that node never saw; the manager's local
|
|
1404
|
+
* increment still prevents same-process collisions. Past `maxPages` the
|
|
1405
|
+
* pending set is truncated and the next free nonce may already be taken;
|
|
1406
|
+
* a nonce conflict at broadcast then resets the manager. Transient failures
|
|
1407
|
+
* (5xx, timeout) degrade to the confirmed floor; a missing or wrong instance
|
|
1408
|
+
* URL throws so the misconfiguration is visible on the first read.
|
|
1709
1409
|
*/
|
|
1710
|
-
declare function
|
|
1711
|
-
|
|
1410
|
+
declare function indexSource(params?: IndexSourceParams): NonceManagerSource;
|
|
1411
|
+
type HiroNonceSourceParams = {
|
|
1412
|
+
/** Hiro API base URL, e.g. `https://api.hiro.so` or `https://api.testnet.hiro.so`. */
|
|
1413
|
+
baseUrl: string
|
|
1414
|
+
apiKey?: string
|
|
1415
|
+
fetchImpl?: FetchImpl
|
|
1712
1416
|
};
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1417
|
+
/**
|
|
1418
|
+
* Off-the-shelf, non-Secondlayer mempool-aware source over Hiro's
|
|
1419
|
+
* `/extended/v1/address/{address}/nonces`. Fills the lowest detected gap first,
|
|
1420
|
+
* then falls back to `possible_next_nonce`. Requires a host that serves Hiro's
|
|
1421
|
+
* extended API (a bare stacks-node does not).
|
|
1422
|
+
*/
|
|
1423
|
+
declare function hiroNonceSource(params: HiroNonceSourceParams): NonceManagerSource;
|
|
1424
|
+
/**
|
|
1425
|
+
* Create an HTTP transport for Stacks node RPC calls.
|
|
1426
|
+
* Falls back to the chain's default RPC URL, then `localhost:3999`.
|
|
1427
|
+
*/
|
|
1428
|
+
declare function http(url?: string, config?: TransportConfig): TransportFactory;
|
|
1429
|
+
/** Create a transport backed by a user-provided request function. */
|
|
1430
|
+
declare function custom(params: {
|
|
1431
|
+
request: RequestFn
|
|
1432
|
+
}): TransportFactory;
|
|
1433
|
+
/** Create a transport that tries each transport in order until one succeeds. */
|
|
1434
|
+
declare function fallback(transports: TransportFactory[]): TransportFactory;
|
|
1435
|
+
/** Configuration for the WebSocket transport, extending base {@link TransportConfig}. */
|
|
1436
|
+
type WebSocketTransportConfig = TransportConfig & {
|
|
1437
|
+
/** WebSocket URL (resolved from chain if omitted) */
|
|
1438
|
+
url?: string
|
|
1439
|
+
/** Enable auto-reconnect (default: true) */
|
|
1440
|
+
reconnect?: boolean
|
|
1441
|
+
/** Max reconnect attempts (default: 10) */
|
|
1442
|
+
reconnectMaxAttempts?: number
|
|
1443
|
+
/** Base delay in ms for exponential backoff (default: 1000) */
|
|
1444
|
+
reconnectBaseDelay?: number
|
|
1721
1445
|
};
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
nonce?: IntegerType
|
|
1728
|
-
postConditionMode?: PostConditionMode
|
|
1729
|
-
postConditions?: PostConditionInput[]
|
|
1446
|
+
/** Transport with WebSocket subscription capabilities and auto-reconnect. */
|
|
1447
|
+
type WebSocketTransport = Transport & {
|
|
1448
|
+
type: "webSocket"
|
|
1449
|
+
subscribe: (params: WsSubscribeParams, callback: (data: any) => void) => Promise<Subscription>
|
|
1450
|
+
destroy: () => void
|
|
1730
1451
|
};
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1452
|
+
/**
|
|
1453
|
+
* Create a WebSocket transport for real-time Stacks event subscriptions.
|
|
1454
|
+
* HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
|
|
1455
|
+
*/
|
|
1456
|
+
declare function webSocket(url?: string, config?: WebSocketTransportConfig): TransportFactory;
|
|
1457
|
+
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"];
|
|
1458
|
+
type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];
|
|
1459
|
+
/** Opt-in node vm_events, stored names. Parallel to DECODED_EVENT_TYPES — not
|
|
1460
|
+
* the decoded_events / Streams 1.0 vocab. Cursor second component is
|
|
1461
|
+
* ordinal. Inner calls are never `contract_call`. */
|
|
1462
|
+
declare const VM_EVENT_TYPES: readonly ["nested_contract_call", "var_set", "map_set", "map_insert", "map_delete"];
|
|
1463
|
+
type VmEventType = (typeof VM_EVENT_TYPES)[number];
|
|
1464
|
+
/** Every chain-event filter member across all four surfaces: the 10 decoded
|
|
1465
|
+
* token/STX types, the three contract-shaped types (spelled as subgraphs and
|
|
1466
|
+
* triggers spell them — Index/Streams project `print_event` → `print`), and
|
|
1467
|
+
* the five sBTC lifecycle types (Webhooks-only). */
|
|
1468
|
+
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", "nested_contract_call", "var_set", "map_set", "map_insert", "map_delete", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed"];
|
|
1469
|
+
type ChainEventFilterType = (typeof CHAIN_EVENT_FILTER_TYPES)[number];
|
|
1470
|
+
/** C32-encoded address version bytes for single-sig and multi-sig on each network. */
|
|
1471
|
+
declare const AddressVersion: {
|
|
1472
|
+
readonly MainnetSingleSig: 22
|
|
1473
|
+
readonly MainnetMultiSig: 20
|
|
1474
|
+
readonly TestnetSingleSig: 26
|
|
1475
|
+
readonly TestnetMultiSig: 21
|
|
1739
1476
|
};
|
|
1740
|
-
type
|
|
1741
|
-
|
|
1742
|
-
|
|
1477
|
+
type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
|
|
1478
|
+
/** Mainnet burn address (all-zero hash160). */
|
|
1479
|
+
declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
|
|
1480
|
+
/** Testnet burn address (all-zero hash160). */
|
|
1481
|
+
declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
|
|
1482
|
+
/** Number of microSTX per 1 STX (10^6). */
|
|
1483
|
+
declare const MICROSTX_PER_STX = 1000000n;
|
|
1484
|
+
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
1485
|
+
declare const isValidAddress: (address: string) => boolean;
|
|
1486
|
+
/**
|
|
1487
|
+
* Compare two Stacks addresses for equality (case-insensitive, version-aware).
|
|
1488
|
+
* Throws if either address is invalid.
|
|
1489
|
+
*/
|
|
1490
|
+
declare function isAddressEqual(a: string, b: string): boolean;
|
|
1491
|
+
/**
|
|
1492
|
+
* Build a contract address from deployer + contract name.
|
|
1493
|
+
* Validates both parts; returns `deployer.contractName`.
|
|
1494
|
+
*/
|
|
1495
|
+
declare function getContractAddress(deployer: string, contractName: string): string;
|
|
1496
|
+
type AbiUInt128 = "uint128";
|
|
1497
|
+
type AbiInt128 = "int128";
|
|
1498
|
+
type AbiBool = "bool";
|
|
1499
|
+
type AbiPrincipal = "principal";
|
|
1500
|
+
type AbiTraitReference = "trait_reference";
|
|
1501
|
+
type AbiNone = "none";
|
|
1502
|
+
type AbiStringAscii<L extends number = number> = {
|
|
1503
|
+
"string-ascii": {
|
|
1504
|
+
length: L
|
|
1505
|
+
}
|
|
1743
1506
|
};
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
deployContract: (params: MultiSigDeployContractParams) => Promise<StacksTransaction>
|
|
1749
|
-
sendTransaction: (params: MultiSigSendTransactionParams) => Promise<SendTransactionResult>
|
|
1507
|
+
type AbiStringUtf8<L extends number = number> = {
|
|
1508
|
+
"string-utf8": {
|
|
1509
|
+
length: L
|
|
1510
|
+
}
|
|
1750
1511
|
};
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
signers: string[]
|
|
1756
|
-
requiredSignatures: number
|
|
1757
|
-
hashMode?: MultiSigHashMode
|
|
1512
|
+
type AbiBuffer<L extends number = number> = {
|
|
1513
|
+
buff: {
|
|
1514
|
+
length: L
|
|
1515
|
+
}
|
|
1758
1516
|
};
|
|
1759
|
-
|
|
1760
|
-
|
|
1517
|
+
type AbiPrimitiveType = AbiUInt128 | AbiInt128 | AbiBool | AbiPrincipal | AbiTraitReference | AbiNone | AbiStringAscii | AbiStringUtf8 | AbiBuffer;
|
|
1518
|
+
interface AbiListType {
|
|
1519
|
+
list: {
|
|
1520
|
+
type: AbiType
|
|
1521
|
+
length: number
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
interface AbiTupleType {
|
|
1525
|
+
tuple: ReadonlyArray<{
|
|
1526
|
+
name: string
|
|
1527
|
+
type: AbiType
|
|
1528
|
+
}>;
|
|
1529
|
+
}
|
|
1530
|
+
interface AbiOptionalType {
|
|
1531
|
+
optional: AbiType;
|
|
1532
|
+
}
|
|
1533
|
+
interface AbiResponseType {
|
|
1534
|
+
response: {
|
|
1535
|
+
ok: AbiType
|
|
1536
|
+
error: AbiType
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
/** Discriminated union of all Clarity value types (primitives, buffers, lists, tuples, optionals, responses). */
|
|
1540
|
+
type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
|
|
1541
|
+
type FunctionAccess = "public" | "read-only" | "private";
|
|
1542
|
+
interface FunctionArg {
|
|
1543
|
+
name: string;
|
|
1544
|
+
type: AbiType;
|
|
1545
|
+
}
|
|
1546
|
+
/** A single Clarity function definition with name, access level, arguments, and return type. */
|
|
1547
|
+
interface AbiFunction {
|
|
1548
|
+
name: string;
|
|
1549
|
+
access: FunctionAccess;
|
|
1550
|
+
args: ReadonlyArray<FunctionArg>;
|
|
1551
|
+
outputs: AbiType;
|
|
1552
|
+
}
|
|
1553
|
+
type VariableAccess = "constant" | "variable";
|
|
1554
|
+
interface AbiVariable {
|
|
1555
|
+
name: string;
|
|
1556
|
+
type: AbiType;
|
|
1557
|
+
access: VariableAccess;
|
|
1558
|
+
}
|
|
1559
|
+
interface AbiMap {
|
|
1560
|
+
name: string;
|
|
1561
|
+
key: AbiType;
|
|
1562
|
+
value: AbiType;
|
|
1563
|
+
}
|
|
1564
|
+
interface AbiFungibleToken {
|
|
1565
|
+
name: string;
|
|
1566
|
+
}
|
|
1567
|
+
interface AbiNonFungibleToken {
|
|
1568
|
+
name: string;
|
|
1569
|
+
type: AbiType;
|
|
1570
|
+
}
|
|
1571
|
+
type TraitFunctionAccess = Exclude<FunctionAccess, "private">;
|
|
1572
|
+
interface AbiTraitFunction {
|
|
1573
|
+
name: string;
|
|
1574
|
+
access: TraitFunctionAccess;
|
|
1575
|
+
args: ReadonlyArray<FunctionArg>;
|
|
1576
|
+
outputs: AbiType;
|
|
1577
|
+
}
|
|
1578
|
+
interface AbiTraitDefinition {
|
|
1579
|
+
name: string;
|
|
1580
|
+
functions: ReadonlyArray<AbiTraitFunction>;
|
|
1581
|
+
}
|
|
1582
|
+
/** Full Clarity contract ABI including functions, maps, variables, and token definitions. */
|
|
1583
|
+
interface AbiContract {
|
|
1584
|
+
functions: ReadonlyArray<AbiFunction>;
|
|
1585
|
+
maps?: ReadonlyArray<AbiMap>;
|
|
1586
|
+
variables?: ReadonlyArray<AbiVariable>;
|
|
1587
|
+
fungible_tokens?: ReadonlyArray<AbiFungibleToken>;
|
|
1588
|
+
non_fungible_tokens?: ReadonlyArray<AbiNonFungibleToken>;
|
|
1589
|
+
implemented_traits?: ReadonlyArray<string>;
|
|
1590
|
+
defined_traits?: ReadonlyArray<AbiTraitDefinition>;
|
|
1591
|
+
}
|
|
1761
1592
|
/**
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1593
|
+
* `<contract>::<asset-name>` — the shape a fungible/non-fungible asset filter
|
|
1594
|
+
* takes, expressed so the compiler can check it.
|
|
1595
|
+
*
|
|
1596
|
+
* The most common mistake in this API is passing a CONTRACT ID
|
|
1597
|
+
* (`SP….sbtc-token`) where an asset identifier (`SP….sbtc-token::sbtc-token`)
|
|
1598
|
+
* belongs, and the failure mode is a query that quietly returns zero rows. The
|
|
1599
|
+
* two differ structurally by `::`, so a template-literal type catches it at the
|
|
1600
|
+
* call site — no brand, no cast, literals just work.
|
|
1601
|
+
*
|
|
1602
|
+
* A value that is only known at runtime (config, env) is not narrow enough on
|
|
1603
|
+
* purpose; run it through {@link assetId} once, which validates and narrows.
|
|
1604
|
+
*
|
|
1605
|
+
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm — they
|
|
1606
|
+
* are legitimately not full identifiers (`SPB.*`), and the runtime validator
|
|
1607
|
+
* short-circuits on them for the same reason.
|
|
1764
1608
|
*/
|
|
1765
|
-
|
|
1609
|
+
type AssetIdentifier = `${string}::${string}` | `${string}*${string}`;
|
|
1610
|
+
/** Scalar print field types (structural mirror of the subgraphs `ColumnType`). */
|
|
1611
|
+
type PrintScalarType = "uint" | "int" | "text" | "principal" | "boolean" | "timestamp" | "jsonb";
|
|
1766
1612
|
/**
|
|
1767
|
-
*
|
|
1768
|
-
*
|
|
1769
|
-
*
|
|
1770
|
-
*
|
|
1771
|
-
* workers sharing a signing key both read the same confirmed floor and collide.
|
|
1772
|
-
* These adapters move the atomic reserve into a shared datastore — Redis `INCR`
|
|
1773
|
-
* inside an `EVAL`, or a single Postgres upsert under a row lock — so the store
|
|
1774
|
-
* itself becomes the cross-process lock and the durable source of truth.
|
|
1613
|
+
* One declared print field — structural mirror of `PrintField` in
|
|
1614
|
+
* `@secondlayer/subgraphs`. Composite forms exist because real print payloads
|
|
1615
|
+
* nest: a vocabulary that could only say `"jsonb"` is what let a flat-field
|
|
1616
|
+
* declaration type-check while every event decoded to null.
|
|
1775
1617
|
*
|
|
1776
|
-
*
|
|
1777
|
-
* No global `Bun` reference, so importing this module is runtime-agnostic.
|
|
1618
|
+
* Kept literal through `toSubgraphSource()` so handler narrowing survives.
|
|
1778
1619
|
*/
|
|
1779
|
-
|
|
1780
|
-
type
|
|
1781
|
-
|
|
1620
|
+
type PrintFieldType = PrintScalarType | {
|
|
1621
|
+
type: PrintFieldType
|
|
1622
|
+
optional: true
|
|
1623
|
+
} | {
|
|
1624
|
+
tuple: Record<string, PrintFieldType>
|
|
1625
|
+
} | {
|
|
1626
|
+
list: PrintFieldType
|
|
1627
|
+
};
|
|
1628
|
+
interface StxTransferSpec {
|
|
1629
|
+
type: "stx_transfer";
|
|
1630
|
+
sender?: string;
|
|
1631
|
+
recipient?: string;
|
|
1632
|
+
minAmount?: bigint;
|
|
1633
|
+
maxAmount?: bigint;
|
|
1634
|
+
}
|
|
1635
|
+
interface StxMintSpec {
|
|
1636
|
+
type: "stx_mint";
|
|
1637
|
+
recipient?: string;
|
|
1638
|
+
minAmount?: bigint;
|
|
1639
|
+
}
|
|
1640
|
+
interface StxBurnSpec {
|
|
1641
|
+
type: "stx_burn";
|
|
1642
|
+
sender?: string;
|
|
1643
|
+
minAmount?: bigint;
|
|
1644
|
+
}
|
|
1645
|
+
interface StxLockSpec {
|
|
1646
|
+
type: "stx_lock";
|
|
1647
|
+
lockedAddress?: string;
|
|
1648
|
+
minAmount?: bigint;
|
|
1649
|
+
}
|
|
1650
|
+
/** Scope to contracts conforming to a trait/standard (e.g. "sip-010") instead
|
|
1651
|
+
* of a fixed contract. Index + Subgraphs + Webhooks; Streams has no
|
|
1652
|
+
* trait resolution — `toStreamsParams()` throws if set. */
|
|
1653
|
+
type TraitScope = {
|
|
1654
|
+
trait?: string
|
|
1655
|
+
};
|
|
1656
|
+
/** Scope to a DYNAMIC address set discovered from another source's events —
|
|
1657
|
+
* a Subgraphs-only concept (`toSubgraphSource()` keeps it; every other
|
|
1658
|
+
* projection throws). Structural mirror of the subgraphs `FactoryScope`:
|
|
1659
|
+
* `stacks` is the dependency-graph leaf and cannot import it. */
|
|
1660
|
+
type FactoryScope = {
|
|
1661
|
+
factory?: {
|
|
1662
|
+
/** Source name whose events reveal the addresses. */
|
|
1663
|
+
from: string
|
|
1664
|
+
/** Dotted path to the address on that source's payload (e.g. "data.pool"). */
|
|
1665
|
+
field: string
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
interface FtTransferSpec extends TraitScope {
|
|
1669
|
+
type: "ft_transfer";
|
|
1670
|
+
assetIdentifier?: AssetIdentifier;
|
|
1671
|
+
sender?: string;
|
|
1672
|
+
recipient?: string;
|
|
1673
|
+
minAmount?: bigint;
|
|
1674
|
+
}
|
|
1675
|
+
interface FtMintSpec extends TraitScope {
|
|
1676
|
+
type: "ft_mint";
|
|
1677
|
+
assetIdentifier?: AssetIdentifier;
|
|
1678
|
+
recipient?: string;
|
|
1679
|
+
minAmount?: bigint;
|
|
1680
|
+
}
|
|
1681
|
+
interface FtBurnSpec extends TraitScope {
|
|
1682
|
+
type: "ft_burn";
|
|
1683
|
+
assetIdentifier?: AssetIdentifier;
|
|
1684
|
+
sender?: string;
|
|
1685
|
+
minAmount?: bigint;
|
|
1686
|
+
}
|
|
1687
|
+
interface NftTransferSpec extends TraitScope {
|
|
1688
|
+
type: "nft_transfer";
|
|
1689
|
+
assetIdentifier?: AssetIdentifier;
|
|
1690
|
+
sender?: string;
|
|
1691
|
+
recipient?: string;
|
|
1692
|
+
}
|
|
1693
|
+
interface NftMintSpec extends TraitScope {
|
|
1694
|
+
type: "nft_mint";
|
|
1695
|
+
assetIdentifier?: AssetIdentifier;
|
|
1696
|
+
recipient?: string;
|
|
1697
|
+
}
|
|
1698
|
+
interface NftBurnSpec extends TraitScope {
|
|
1699
|
+
type: "nft_burn";
|
|
1700
|
+
assetIdentifier?: AssetIdentifier;
|
|
1701
|
+
sender?: string;
|
|
1702
|
+
}
|
|
1703
|
+
interface ContractCallSpec extends TraitScope, FactoryScope {
|
|
1704
|
+
type: "contract_call";
|
|
1705
|
+
/** One contract id, or a set of them (max 20). Mirrors the subgraphs
|
|
1706
|
+
* filter — a router plus its pools is one source, not N. */
|
|
1707
|
+
contractId?: string | readonly string[];
|
|
1708
|
+
functionName?: string;
|
|
1709
|
+
caller?: string;
|
|
1710
|
+
/** Contract ABI (`as const`) — preserved literally so `toSubgraphSource()`
|
|
1711
|
+
* keeps typing `event.input` in `defineSubgraph`. */
|
|
1712
|
+
abi?: AbiContract;
|
|
1713
|
+
}
|
|
1714
|
+
interface ContractDeploySpec {
|
|
1715
|
+
type: "contract_deploy";
|
|
1716
|
+
deployer?: string;
|
|
1717
|
+
contractName?: string;
|
|
1718
|
+
}
|
|
1719
|
+
interface NestedContractCallSpec extends TraitScope, FactoryScope {
|
|
1720
|
+
type: "nested_contract_call";
|
|
1721
|
+
contractId?: string | readonly string[];
|
|
1722
|
+
functionName?: string;
|
|
1723
|
+
caller?: string;
|
|
1724
|
+
sender?: string;
|
|
1725
|
+
}
|
|
1726
|
+
interface VarSetSpec extends TraitScope, FactoryScope {
|
|
1727
|
+
type: "var_set";
|
|
1728
|
+
contractId?: string | readonly string[];
|
|
1729
|
+
varName?: string;
|
|
1730
|
+
}
|
|
1731
|
+
interface MapSetSpec extends TraitScope, FactoryScope {
|
|
1732
|
+
type: "map_set";
|
|
1733
|
+
contractId?: string | readonly string[];
|
|
1734
|
+
map?: string;
|
|
1735
|
+
}
|
|
1736
|
+
interface MapInsertSpec extends TraitScope, FactoryScope {
|
|
1737
|
+
type: "map_insert";
|
|
1738
|
+
contractId?: string | readonly string[];
|
|
1739
|
+
map?: string;
|
|
1740
|
+
}
|
|
1741
|
+
interface MapDeleteSpec extends TraitScope, FactoryScope {
|
|
1742
|
+
type: "map_delete";
|
|
1743
|
+
contractId?: string | readonly string[];
|
|
1744
|
+
map?: string;
|
|
1745
|
+
}
|
|
1746
|
+
interface PrintEventSpec extends TraitScope, FactoryScope {
|
|
1747
|
+
type: "print_event";
|
|
1748
|
+
/** One contract id, or a set of them (max 20). */
|
|
1749
|
+
contractId?: string | readonly string[];
|
|
1750
|
+
topic?: string;
|
|
1751
|
+
/** Per-topic field schema — preserved literally so `toSubgraphSource()`
|
|
1752
|
+
* keeps the discriminated-union narrowing of `event.data`. */
|
|
1753
|
+
prints?: Record<string, Record<string, PrintFieldType>>;
|
|
1754
|
+
}
|
|
1755
|
+
interface SbtcDepositSpec {
|
|
1756
|
+
type: "sbtc_deposit";
|
|
1757
|
+
sender?: string;
|
|
1758
|
+
minAmount?: bigint;
|
|
1759
|
+
maxAmount?: bigint;
|
|
1760
|
+
bitcoinTxid?: string;
|
|
1761
|
+
requestId?: number;
|
|
1762
|
+
}
|
|
1763
|
+
interface SbtcWithdrawalCreateSpec {
|
|
1764
|
+
type: "sbtc_withdrawal_create";
|
|
1765
|
+
sender?: string;
|
|
1766
|
+
minAmount?: bigint;
|
|
1767
|
+
maxAmount?: bigint;
|
|
1768
|
+
requestId?: number;
|
|
1769
|
+
}
|
|
1770
|
+
interface SbtcWithdrawalAcceptSpec {
|
|
1771
|
+
type: "sbtc_withdrawal_accept";
|
|
1772
|
+
requestId?: number;
|
|
1773
|
+
sweepTxid?: string;
|
|
1774
|
+
}
|
|
1775
|
+
interface SbtcWithdrawalRejectSpec {
|
|
1776
|
+
type: "sbtc_withdrawal_reject";
|
|
1777
|
+
requestId?: number;
|
|
1778
|
+
}
|
|
1779
|
+
interface SbtcWithdrawalSweptConfirmedSpec {
|
|
1780
|
+
type: "sbtc_withdrawal_swept_confirmed";
|
|
1781
|
+
requestId?: number;
|
|
1782
|
+
sweepTxid?: string;
|
|
1783
|
+
}
|
|
1784
|
+
type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | NestedContractCallSpec | VarSetSpec | MapSetSpec | MapInsertSpec | MapDeleteSpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
|
|
1785
|
+
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
1786
|
+
type: T
|
|
1787
|
+
}>;
|
|
1788
|
+
/** Wire shape of a chain trigger (Webhooks), derived per member from
|
|
1789
|
+
* the spec: same fields, with `bigint` amounts stringified (uint128 exceeds
|
|
1790
|
+
* JS safe integers) and the type-only `abi`/`prints` decorations dropped.
|
|
1791
|
+
* Structurally assignable to the SDK's `ChainTrigger` union. */
|
|
1792
|
+
type ChainTriggerOf<S> = { [K in keyof Omit<S, "abi" | "prints" | "factory">] : Exclude<S[K], bigint | readonly string[]> | (bigint extends S[K] ? string : never) };
|
|
1793
|
+
/** Params fragment for `index.events.*` (spread into list/walk/consume). */
|
|
1794
|
+
type IndexEventsParamsShape = {
|
|
1795
|
+
eventType: DecodedEventType | VmEventType
|
|
1796
|
+
/** A spec's contract set passes through verbatim (the API takes up to 20). */
|
|
1797
|
+
contractId?: string | readonly string[]
|
|
1798
|
+
assetIdentifier?: AssetIdentifier
|
|
1799
|
+
sender?: string
|
|
1800
|
+
recipient?: string
|
|
1801
|
+
functionName?: string
|
|
1802
|
+
caller?: string
|
|
1803
|
+
map?: string
|
|
1804
|
+
varName?: string
|
|
1805
|
+
trait?: string
|
|
1806
|
+
};
|
|
1807
|
+
/** Params fragment for `index.contractCalls.*`. */
|
|
1808
|
+
type ContractCallsParamsShape = {
|
|
1809
|
+
/** A spec's contract set passes through verbatim (the API takes up to 20). */
|
|
1810
|
+
contractId?: string | readonly string[]
|
|
1811
|
+
functionName?: string
|
|
1812
|
+
/** Populated from the spec's `caller` — the endpoint filters by tx sender,
|
|
1813
|
+
* which is the caller. */
|
|
1814
|
+
sender?: string
|
|
1815
|
+
trait?: string
|
|
1782
1816
|
};
|
|
1783
|
-
type
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1817
|
+
type VmMember = "nested_contract_call" | "var_set" | "map_set" | "map_insert" | "map_delete";
|
|
1818
|
+
/** Params fragment for classic `streams.events.*` (Streams 1.0). VM members
|
|
1819
|
+
* project to {@link StreamsVmParamsShape} instead — mixing the vocabularies
|
|
1820
|
+
* here makes `events.consume({ ...on.ftTransfer().toStreamsParams(), onBatch })`
|
|
1821
|
+
* fail type-check. */
|
|
1822
|
+
type StreamsParamsShape = {
|
|
1823
|
+
types: readonly DecodedEventType[]
|
|
1824
|
+
contractId?: string | readonly string[]
|
|
1825
|
+
sender?: string
|
|
1826
|
+
recipient?: string
|
|
1827
|
+
assetIdentifier?: AssetIdentifier
|
|
1787
1828
|
};
|
|
1788
|
-
/**
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
declare function redisStore(params: RedisStoreParams): NonceStore;
|
|
1794
|
-
/** Minimal structural shape of a `Bun.sql` tagged-template client. */
|
|
1795
|
-
type SqlLike = (strings: TemplateStringsArray, ...values: unknown[]) => Promise<Array<Record<string, unknown>>>;
|
|
1796
|
-
type PostgresStoreParams = {
|
|
1797
|
-
sql: SqlLike
|
|
1798
|
-
/**
|
|
1799
|
-
* Run `CREATE TABLE IF NOT EXISTS stacks_nonce_state` lazily on first use.
|
|
1800
|
-
* Default `true`. Set `false` if you manage the schema via migrations.
|
|
1801
|
-
*/
|
|
1802
|
-
ensureTable?: boolean
|
|
1829
|
+
/** VM member projection: `clock` is the `"vm"` literal so SDK overload 1 matches. */
|
|
1830
|
+
type StreamsVmParamsShape<T extends VmMember = VmMember> = {
|
|
1831
|
+
types: readonly [T]
|
|
1832
|
+
clock: "vm"
|
|
1833
|
+
contractId?: string | readonly string[]
|
|
1803
1834
|
};
|
|
1835
|
+
type DecodedMember = "stx_transfer" | "stx_mint" | "stx_burn" | "stx_lock" | "ft_transfer" | "ft_mint" | "ft_burn" | "nft_transfer" | "nft_mint" | "nft_burn" | "print_event";
|
|
1836
|
+
type ProjectionsFor<
|
|
1837
|
+
T extends ChainEventFilterType,
|
|
1838
|
+
S
|
|
1839
|
+
> = {
|
|
1840
|
+
/** Wire trigger for `webhooks.create({ triggers: [...] })`. BigInt
|
|
1841
|
+
* amounts become strings here — the one sanctioned boundary. */
|
|
1842
|
+
toChainTrigger(): ChainTriggerOf<S>
|
|
1843
|
+
} & (T extends DecodedMember | VmMember ? {
|
|
1844
|
+
/** Params for `index.events.list/walk/consume` (merge your own
|
|
1845
|
+
* `limit`/`fromHeight`/`txContext` etc. on top). */
|
|
1846
|
+
toIndexParams<Extra extends Record<string, unknown>>(extra?: Extra): IndexEventsParamsShape & Extra
|
|
1847
|
+
/** Params for `streams.events.list/consume/stream`. Throws if the
|
|
1848
|
+
* filter uses `trait` (Streams has no trait resolution) or a
|
|
1849
|
+
* min/max amount (Streams filters have no amount predicates). */
|
|
1850
|
+
toStreamsParams<Extra extends Record<string, unknown> = Record<string, never>>(extra?: Extra): T extends VmMember ? StreamsVmParamsShape<T> & Extra : StreamsParamsShape & Extra
|
|
1851
|
+
} : {}) & (T extends "contract_call" ? {
|
|
1852
|
+
/** Params for `index.contractCalls.list/walk/consume`. */
|
|
1853
|
+
toContractCallsParams<Extra extends Record<string, unknown>>(extra?: Extra): ContractCallsParamsShape & Extra
|
|
1854
|
+
} : {}) & (T extends Exclude<ChainEventFilterType, `sbtc_${string}`> ? {
|
|
1855
|
+
/** The `sources` entry for `defineSubgraph` — literal `prints`/`abi`
|
|
1856
|
+
* types are preserved, so handler narrowing survives. */
|
|
1857
|
+
toSubgraphSource(): S
|
|
1858
|
+
} : {});
|
|
1804
1859
|
/**
|
|
1805
|
-
*
|
|
1806
|
-
*
|
|
1807
|
-
*
|
|
1808
|
-
*
|
|
1809
|
-
* Uses a fixed table `stacks_nonce_state (key text primary key, next numeric)`.
|
|
1860
|
+
* A canonical chain-event filter: the spec fields plus the projections its
|
|
1861
|
+
* member supports. Write the filter once; project it to a query
|
|
1862
|
+
* (`toIndexParams`), a stream (`toStreamsParams`), a webhook trigger
|
|
1863
|
+
* (`toChainTrigger`), or a subgraph source (`toSubgraphSource`).
|
|
1810
1864
|
*/
|
|
1811
|
-
|
|
1865
|
+
type ChainEventFilter<
|
|
1866
|
+
T extends ChainEventFilterType = ChainEventFilterType,
|
|
1867
|
+
S extends {
|
|
1868
|
+
type: T
|
|
1869
|
+
} = SpecFor<T>
|
|
1870
|
+
> = S & ProjectionsFor<T, S>;
|
|
1871
|
+
type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
|
|
1872
|
+
/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
|
|
1873
|
+
* annotation on exported values (an inferred object of generic factories
|
|
1874
|
+
* collapses to `{}` in the emitted declarations). */
|
|
1875
|
+
interface OnNamespace {
|
|
1876
|
+
stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
|
|
1877
|
+
stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
|
|
1878
|
+
stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
|
|
1879
|
+
stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
|
|
1880
|
+
ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
|
|
1881
|
+
ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
|
|
1882
|
+
ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
|
|
1883
|
+
nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
|
|
1884
|
+
nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
|
|
1885
|
+
nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
|
|
1886
|
+
/** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps
|
|
1887
|
+
* typing `event.input` inside `defineSubgraph`. */
|
|
1888
|
+
contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
1889
|
+
abi?: A
|
|
1890
|
+
}): ChainEventFilter<"contract_call", {
|
|
1891
|
+
type: "contract_call"
|
|
1892
|
+
} & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
1893
|
+
abi?: A
|
|
1894
|
+
}>;
|
|
1895
|
+
contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
|
|
1896
|
+
/** Canonical member is `print_event` (as Subgraphs and Webhooks spell
|
|
1897
|
+
* it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`
|
|
1898
|
+
* literals are preserved (`const P`) for per-topic `event.data` narrowing. */
|
|
1899
|
+
print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
1900
|
+
prints?: P
|
|
1901
|
+
}): ChainEventFilter<"print_event", {
|
|
1902
|
+
type: "print_event"
|
|
1903
|
+
} & Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
1904
|
+
prints?: P
|
|
1905
|
+
}>;
|
|
1906
|
+
nestedCall(fields?: Fields<"nested_contract_call">): ChainEventFilter<"nested_contract_call">;
|
|
1907
|
+
varSet(fields?: Fields<"var_set">): ChainEventFilter<"var_set">;
|
|
1908
|
+
mapSet(fields?: Fields<"map_set">): ChainEventFilter<"map_set">;
|
|
1909
|
+
mapInsert(fields?: Fields<"map_insert">): ChainEventFilter<"map_insert">;
|
|
1910
|
+
mapDelete(fields?: Fields<"map_delete">): ChainEventFilter<"map_delete">;
|
|
1911
|
+
sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
|
|
1912
|
+
sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
|
|
1913
|
+
sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
|
|
1914
|
+
sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
|
|
1915
|
+
sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
|
|
1916
|
+
}
|
|
1812
1917
|
/**
|
|
1813
|
-
*
|
|
1918
|
+
* `on.*` — one filter vocabulary for every surface.
|
|
1814
1919
|
*
|
|
1815
|
-
*
|
|
1816
|
-
*
|
|
1817
|
-
* tracking. These sources fold pending (mempool) txs into the next-nonce
|
|
1818
|
-
* computation. The gap-filling core is generic; where the pending set comes from
|
|
1819
|
-
* is pluggable, so you are never locked to any one provider:
|
|
1920
|
+
* ```ts
|
|
1921
|
+
* import { on } from "@secondlayer/stacks/filters";
|
|
1820
1922
|
*
|
|
1821
|
-
*
|
|
1822
|
-
* - {@link indexSource}: prebuilt over a Secondlayer instance's `/v1/index/mempool`.
|
|
1823
|
-
* - {@link hiroNonceSource} — prebuilt over Hiro's `/extended` nonces endpoint.
|
|
1824
|
-
*/
|
|
1825
|
-
type FetchImpl = typeof globalThis.fetch;
|
|
1826
|
-
/**
|
|
1827
|
-
* The next free nonce ≥ `confirmed` not already taken by a pending tx.
|
|
1923
|
+
* const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });
|
|
1828
1924
|
*
|
|
1829
|
-
*
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
client: Client
|
|
1839
|
-
address: string
|
|
1840
|
-
}) => Promise<bigint[]>
|
|
1841
|
-
/**
|
|
1842
|
-
* Confirmed-nonce floor. Defaults to the node's `/v2/accounts` read — the
|
|
1843
|
-
* user's own node via the client transport, no provider dependency.
|
|
1844
|
-
*/
|
|
1845
|
-
getConfirmed?: (args: {
|
|
1846
|
-
client: Client
|
|
1847
|
-
address: string
|
|
1848
|
-
}) => Promise<bigint>
|
|
1849
|
-
};
|
|
1850
|
-
/**
|
|
1851
|
-
* Build a gap-filling, mempool-aware source from any `getPending`. The confirmed
|
|
1852
|
-
* floor defaults to the node read; if `getPending` throws, the source degrades
|
|
1853
|
-
* to confirmed-only rather than blocking a broadcast. A misconfigured pending
|
|
1854
|
-
* feed ({@link IndexSourceConfigError}) is rethrown: it would fail on every
|
|
1855
|
-
* read, and degrading silently would hide that the mempool is never consulted.
|
|
1856
|
-
*/
|
|
1857
|
-
declare function mempoolAwareSource(params: MempoolAwareSourceParams): NonceManagerSource;
|
|
1858
|
-
type IndexSourceParams = {
|
|
1859
|
-
/**
|
|
1860
|
-
* URL of your Secondlayer instance. Without it the client's transport
|
|
1861
|
-
* URL is assumed to be the instance: a transport on a Hiro host throws
|
|
1862
|
-
* up front, and a host that answers `/v1/index` with a non-JSON 404
|
|
1863
|
-
* (a bare stacks-node) throws on the first read. Neither is degraded
|
|
1864
|
-
* to the confirmed floor. Pass it whenever the transport is not the
|
|
1865
|
-
* instance.
|
|
1866
|
-
*/
|
|
1867
|
-
baseUrl?: string
|
|
1868
|
-
/** Instance token, sent as `Authorization: Bearer`. */
|
|
1869
|
-
apiKey?: string
|
|
1870
|
-
/** Max mempool pages to read per address. Default 10 (×200 = 2000 txs). */
|
|
1871
|
-
maxPages?: number
|
|
1872
|
-
/** Override the confirmed floor (defaults to the node read). */
|
|
1873
|
-
getConfirmed?: (args: {
|
|
1874
|
-
client: Client
|
|
1875
|
-
address: string
|
|
1876
|
-
}) => Promise<bigint>
|
|
1877
|
-
};
|
|
1878
|
-
/**
|
|
1879
|
-
* Mempool-aware source backed by a Secondlayer instance's `/v1/index/mempool`.
|
|
1880
|
-
* Requests go through the transport layer (retries, timeout, typed errors).
|
|
1881
|
-
* The instance's mempool is a go-forward view observed by its own node, so
|
|
1882
|
-
* it can lag or miss transactions that node never saw; the manager's local
|
|
1883
|
-
* increment still prevents same-process collisions. Past `maxPages` the
|
|
1884
|
-
* pending set is truncated and the next free nonce may already be taken;
|
|
1885
|
-
* a nonce conflict at broadcast then resets the manager. Transient failures
|
|
1886
|
-
* (5xx, timeout) degrade to the confirmed floor; a missing or wrong instance
|
|
1887
|
-
* URL throws so the misconfiguration is visible on the first read.
|
|
1888
|
-
*/
|
|
1889
|
-
declare function indexSource(params?: IndexSourceParams): NonceManagerSource;
|
|
1890
|
-
type HiroNonceSourceParams = {
|
|
1891
|
-
/** Hiro API base URL, e.g. `https://api.hiro.so` or `https://api.testnet.hiro.so`. */
|
|
1892
|
-
baseUrl: string
|
|
1893
|
-
apiKey?: string
|
|
1894
|
-
fetchImpl?: FetchImpl
|
|
1895
|
-
};
|
|
1896
|
-
/**
|
|
1897
|
-
* Off-the-shelf, non-Secondlayer mempool-aware source over Hiro's
|
|
1898
|
-
* `/extended/v1/address/{address}/nonces`. Fills the lowest detected gap first,
|
|
1899
|
-
* then falls back to `possible_next_nonce`. Requires a host that serves Hiro's
|
|
1900
|
-
* extended API (a bare stacks-node does not).
|
|
1901
|
-
*/
|
|
1902
|
-
declare function hiroNonceSource(params: HiroNonceSourceParams): NonceManagerSource;
|
|
1903
|
-
/**
|
|
1904
|
-
* Create an HTTP transport for Stacks node RPC calls.
|
|
1905
|
-
* Falls back to the chain's default RPC URL, then `localhost:3999`.
|
|
1906
|
-
*/
|
|
1907
|
-
declare function http(url?: string, config?: TransportConfig): TransportFactory;
|
|
1908
|
-
/** Create a transport backed by a user-provided request function. */
|
|
1909
|
-
declare function custom(params: {
|
|
1910
|
-
request: RequestFn
|
|
1911
|
-
}): TransportFactory;
|
|
1912
|
-
/** Create a transport that tries each transport in order until one succeeds. */
|
|
1913
|
-
declare function fallback(transports: TransportFactory[]): TransportFactory;
|
|
1914
|
-
/** Configuration for the WebSocket transport, extending base {@link TransportConfig}. */
|
|
1915
|
-
type WebSocketTransportConfig = TransportConfig & {
|
|
1916
|
-
/** WebSocket URL (resolved from chain if omitted) */
|
|
1917
|
-
url?: string
|
|
1918
|
-
/** Enable auto-reconnect (default: true) */
|
|
1919
|
-
reconnect?: boolean
|
|
1920
|
-
/** Max reconnect attempts (default: 10) */
|
|
1921
|
-
reconnectMaxAttempts?: number
|
|
1922
|
-
/** Base delay in ms for exponential backoff (default: 1000) */
|
|
1923
|
-
reconnectBaseDelay?: number
|
|
1924
|
-
};
|
|
1925
|
-
/** Transport with WebSocket subscription capabilities and auto-reconnect. */
|
|
1926
|
-
type WebSocketTransport = Transport & {
|
|
1927
|
-
type: "webSocket"
|
|
1928
|
-
subscribe: (params: WsSubscribeParams, callback: (data: any) => void) => Promise<Subscription>
|
|
1929
|
-
destroy: () => void
|
|
1930
|
-
};
|
|
1931
|
-
/**
|
|
1932
|
-
* Create a WebSocket transport for real-time Stacks event subscriptions.
|
|
1933
|
-
* HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
|
|
1925
|
+
* sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull
|
|
1926
|
+
* sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });
|
|
1927
|
+
* sl.webhooks.create({ name, url, triggers: [usdc.toChainTrigger()] });
|
|
1928
|
+
* defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });
|
|
1929
|
+
* ```
|
|
1930
|
+
*
|
|
1931
|
+
* A surface a member can't reach is a missing method (compile error), and a
|
|
1932
|
+
* field a surface can't express throws at projection time — never a silent
|
|
1933
|
+
* zero-row or over-wide match.
|
|
1934
1934
|
*/
|
|
1935
|
-
declare
|
|
1935
|
+
declare const on: OnNamespace;
|
|
1936
1936
|
/** Create a ProviderAccount by querying the wallet for addresses */
|
|
1937
1937
|
declare function providerToAccount(provider: StacksProvider): Promise<ProviderAccount>;
|
|
1938
1938
|
/** Stacks mainnet chain definition (Hiro API). */
|
|
@@ -2042,4 +2042,4 @@ declare class ReadContractError extends BaseError {
|
|
|
2042
2042
|
declare class WebSocketError extends BaseError {
|
|
2043
2043
|
name: string;
|
|
2044
2044
|
}
|
|
2045
|
-
export {
|
|
2045
|
+
export { Account, AddressVersion, BaseError, BroadcastError, ChainEventFilter, ChainEventFilterSpec, ChainEventFilterType, ChainTriggerOf, Client, ClientConfig, CreateNonceManagerParams, CustomAccount, GetTransactionParams, HiroNonceSourceParams, HttpRequestError, IndexSourceConfigError, IndexSourceParams, IndexTxSourceParams, LocalAccount, MICROSTX_PER_STX, MalformedResponseError, MempoolAwareSourceParams, MultiSigActions, MultiSigClient, MultiSigClientConfig, NonceManager, NonceManagerSource, NonceStore, PostgresStoreParams, ProviderAccount, PublicActions, PublicClient, PublicClientConfig, ReadContractError, ReconcileNonceParams, ReconcileNonceResult, RedisLike, RedisStoreParams, RequestFn, RequestOptions, SerializationError, SigningError, SimulationError, SqlLike, StacksChain, StacksProvider, StartNonceReconcilerParams, Subscription, TESTNET_ZERO_ADDRESS, TimeoutError, TransactionAbortedError, TransactionDroppedError, TransactionError, TransactionReceipt, TransactionSnapshot, TransactionStatus, TransactionStatusSource, Transport, TransportConfig, TransportFactory, TxRejectionReason, WaitForTransactionReceiptParams, WaitForTransactionTimeoutError, WalletActions, WalletClient, WalletClientConfig, WebSocketError, WebSocketTransport, WebSocketTransportConfig, ZERO_ADDRESS, broadcastWithNonceReset, createClient, createMultiSigClient, createNonceManager, createPublicClient, createWalletClient, custom, defineChain, devnet, extendedApiSource, fallback, formatStx, getContractAddress, getTransaction2 as getTransaction, hiroNonceSource, http, indexSource, indexTxSource, isAddressEqual, isNonceConflictError, isValidAddress, jsonRpcSource, mainnet, memoryStore, mempoolAwareSource, mocknet, multisigActions, nextFreeNonce, on, parseStx, postgresStore, providerToAccount, publicActions, reconcileNonce, redisStore, resolveNonce, startNonceReconciler, testnet, waitForTransactionReceipt2 as waitForTransactionReceipt, walletActions, webSocket };
|