@secondlayer/stacks 0.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/README.md +92 -0
- package/dist/shared/stacks-02actsrx.cjs +17 -0
- package/dist/shared/stacks-02actsrx.cjs.map +10 -0
- package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
- package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
- package/dist/shared/stacks-24h5k94q.cjs +74 -0
- package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
- package/dist/shared/stacks-2ar4prfz.cjs +328 -0
- package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
- package/dist/shared/stacks-4py5pm0r.cjs +237 -0
- package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
- package/dist/shared/stacks-5tprhns9.cjs +54 -0
- package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
- package/dist/shared/stacks-61rvzkz1.cjs +132 -0
- package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
- package/dist/shared/stacks-709tra19.js +30 -0
- package/dist/shared/stacks-709tra19.js.map +10 -0
- package/dist/shared/stacks-74k8cxgb.cjs +567 -0
- package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
- package/dist/shared/stacks-8m9byk2j.js +7 -0
- package/dist/shared/stacks-8m9byk2j.js.map +9 -0
- package/dist/shared/stacks-8yykgdww.js +125 -0
- package/dist/shared/stacks-8yykgdww.js.map +11 -0
- package/dist/shared/stacks-9g0jhab3.cjs +40 -0
- package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
- package/dist/shared/stacks-an5k8n4t.cjs +291 -0
- package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
- package/dist/shared/stacks-b008c3w8.cjs +214 -0
- package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
- package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
- package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
- package/dist/shared/stacks-bycy6t9k.js +22 -0
- package/dist/shared/stacks-bycy6t9k.js.map +10 -0
- package/dist/shared/stacks-d1fmkv3p.js +258 -0
- package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
- package/dist/shared/stacks-dr5en54r.cjs +119 -0
- package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
- package/dist/shared/stacks-dxhntr76.js +278 -0
- package/dist/shared/stacks-dxhntr76.js.map +10 -0
- package/dist/shared/stacks-evnzth1q.cjs +35 -0
- package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
- package/dist/shared/stacks-f3tk2k5s.js +27 -0
- package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
- package/dist/shared/stacks-f7wdrzs3.js +285 -0
- package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
- package/dist/shared/stacks-fcaefc5b.cjs +16 -0
- package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
- package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
- package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
- package/dist/shared/stacks-gck1sq7h.cjs +28 -0
- package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
- package/dist/shared/stacks-gjvbq6w7.js +46 -0
- package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
- package/dist/shared/stacks-j2cy7qtt.js +237 -0
- package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
- package/dist/shared/stacks-k08tgzyp.cjs +232 -0
- package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
- package/dist/shared/stacks-k2p5tv6x.js +37 -0
- package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
- package/dist/shared/stacks-k58k970n.js +234 -0
- package/dist/shared/stacks-k58k970n.js.map +10 -0
- package/dist/shared/stacks-n2g56wgg.js +338 -0
- package/dist/shared/stacks-n2g56wgg.js.map +23 -0
- package/dist/shared/stacks-nqytwfcc.js +243 -0
- package/dist/shared/stacks-nqytwfcc.js.map +11 -0
- package/dist/shared/stacks-qcae5852.js +19 -0
- package/dist/shared/stacks-qcae5852.js.map +10 -0
- package/dist/shared/stacks-qt8ehebn.js +76 -0
- package/dist/shared/stacks-qt8ehebn.js.map +11 -0
- package/dist/shared/stacks-qvg7c24g.cjs +232 -0
- package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
- package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
- package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
- package/dist/shared/stacks-tjxmrssa.js +282 -0
- package/dist/shared/stacks-tjxmrssa.js.map +11 -0
- package/dist/shared/stacks-v9jqcpd4.js +18 -0
- package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
- package/dist/shared/stacks-vdfag81a.cjs +121 -0
- package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
- package/dist/shared/stacks-vdfs3e5v.js +134 -0
- package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
- package/dist/shared/stacks-y3dh7hv1.js +60 -0
- package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
- package/dist/shared/stacks-ya3x01yd.cjs +16 -0
- package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
- package/dist/shared/stacks-yfgsm6ap.js +599 -0
- package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
- package/dist/shared/stacks-yfveb68e.js +121 -0
- package/dist/shared/stacks-yfveb68e.js.map +10 -0
- package/dist/shared/stacks-zm0b3tgy.js +160 -0
- package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
- package/dist/shared/stacks-zyv9qqme.cjs +249 -0
- package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
- package/dist/src/accounts/index.cjs +90 -0
- package/dist/src/accounts/index.cjs.map +12 -0
- package/dist/src/accounts/index.d.cts +47 -0
- package/dist/src/accounts/index.d.ts +47 -0
- package/dist/src/accounts/index.js +104 -0
- package/dist/src/accounts/index.js.map +12 -0
- package/dist/src/actions/index.cjs +36 -0
- package/dist/src/actions/index.cjs.map +9 -0
- package/dist/src/actions/index.d.cts +886 -0
- package/dist/src/actions/index.d.ts +886 -0
- package/dist/src/actions/index.js +81 -0
- package/dist/src/actions/index.js.map +9 -0
- package/dist/src/bns/index.cjs +590 -0
- package/dist/src/bns/index.cjs.map +15 -0
- package/dist/src/bns/index.d.cts +241 -0
- package/dist/src/bns/index.d.ts +241 -0
- package/dist/src/bns/index.js +611 -0
- package/dist/src/bns/index.js.map +15 -0
- package/dist/src/chains/index.cjs +13 -0
- package/dist/src/chains/index.cjs.map +9 -0
- package/dist/src/chains/index.d.cts +53 -0
- package/dist/src/chains/index.d.ts +53 -0
- package/dist/src/chains/index.js +18 -0
- package/dist/src/chains/index.js.map +9 -0
- package/dist/src/clarity/index.cjs +3 -0
- package/dist/src/clarity/index.cjs.map +9 -0
- package/dist/src/clarity/index.d.cts +821 -0
- package/dist/src/clarity/index.d.ts +821 -0
- package/dist/src/clarity/index.js +145 -0
- package/dist/src/clarity/index.js.map +9 -0
- package/dist/src/connect/index.cjs +480 -0
- package/dist/src/connect/index.cjs.map +19 -0
- package/dist/src/connect/index.d.cts +110 -0
- package/dist/src/connect/index.d.ts +110 -0
- package/dist/src/connect/index.js +448 -0
- package/dist/src/connect/index.js.map +19 -0
- package/dist/src/connect/walletconnect/index.cjs +1322 -0
- package/dist/src/connect/walletconnect/index.cjs.map +18 -0
- package/dist/src/connect/walletconnect/index.d.cts +132 -0
- package/dist/src/connect/walletconnect/index.d.ts +132 -0
- package/dist/src/connect/walletconnect/index.js +1290 -0
- package/dist/src/connect/walletconnect/index.js.map +18 -0
- package/dist/src/index.cjs +557 -0
- package/dist/src/index.cjs.map +21 -0
- package/dist/src/index.d.cts +847 -0
- package/dist/src/index.d.ts +847 -0
- package/dist/src/index.js +629 -0
- package/dist/src/index.js.map +21 -0
- package/dist/src/postconditions/index.cjs +3 -0
- package/dist/src/postconditions/index.cjs.map +9 -0
- package/dist/src/postconditions/index.d.cts +91 -0
- package/dist/src/postconditions/index.d.ts +91 -0
- package/dist/src/postconditions/index.js +12 -0
- package/dist/src/postconditions/index.js.map +9 -0
- package/dist/src/pox/index.cjs +860 -0
- package/dist/src/pox/index.cjs.map +15 -0
- package/dist/src/pox/index.d.cts +244 -0
- package/dist/src/pox/index.d.ts +244 -0
- package/dist/src/pox/index.js +877 -0
- package/dist/src/pox/index.js.map +15 -0
- package/dist/src/stackingdao/index.cjs +300 -0
- package/dist/src/stackingdao/index.cjs.map +13 -0
- package/dist/src/stackingdao/index.d.cts +179 -0
- package/dist/src/stackingdao/index.d.ts +179 -0
- package/dist/src/stackingdao/index.js +318 -0
- package/dist/src/stackingdao/index.js.map +13 -0
- package/dist/src/subscriptions/index.cjs +14 -0
- package/dist/src/subscriptions/index.cjs.map +9 -0
- package/dist/src/subscriptions/index.d.cts +250 -0
- package/dist/src/subscriptions/index.d.ts +250 -0
- package/dist/src/subscriptions/index.js +21 -0
- package/dist/src/subscriptions/index.js.map +9 -0
- package/dist/src/transactions/index.cjs +50 -0
- package/dist/src/transactions/index.cjs.map +9 -0
- package/dist/src/transactions/index.d.cts +412 -0
- package/dist/src/transactions/index.d.ts +412 -0
- package/dist/src/transactions/index.js +101 -0
- package/dist/src/transactions/index.js.map +9 -0
- package/dist/src/utils/index.cjs +168 -0
- package/dist/src/utils/index.cjs.map +11 -0
- package/dist/src/utils/index.d.cts +140 -0
- package/dist/src/utils/index.d.ts +140 -0
- package/dist/src/utils/index.js +222 -0
- package/dist/src/utils/index.js.map +11 -0
- package/package.json +105 -0
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
/** Full chain descriptor used by clients and transports for network-aware operations. */
|
|
2
|
+
type StacksChain = {
|
|
3
|
+
/** Chain ID (e.g. 0x00000001 for mainnet) */
|
|
4
|
+
id: number
|
|
5
|
+
/** Human-readable name */
|
|
6
|
+
name: string
|
|
7
|
+
/** Network type */
|
|
8
|
+
network: "mainnet" | "testnet"
|
|
9
|
+
/** Transaction version byte for serialization */
|
|
10
|
+
transactionVersion: number
|
|
11
|
+
/** Peer network ID for P2P broadcasting */
|
|
12
|
+
peerNetworkId: number
|
|
13
|
+
/** Address version bytes */
|
|
14
|
+
addressVersion: {
|
|
15
|
+
singleSig: number
|
|
16
|
+
multiSig: number
|
|
17
|
+
}
|
|
18
|
+
/** Magic bytes for network identification */
|
|
19
|
+
magicBytes: string
|
|
20
|
+
/** Boot address (system contracts deployer) */
|
|
21
|
+
bootAddress: string
|
|
22
|
+
/** Native currency info */
|
|
23
|
+
nativeCurrency: {
|
|
24
|
+
name: string
|
|
25
|
+
symbol: string
|
|
26
|
+
decimals: number
|
|
27
|
+
}
|
|
28
|
+
/** Default RPC URLs */
|
|
29
|
+
rpcUrls: {
|
|
30
|
+
default: {
|
|
31
|
+
http: string[]
|
|
32
|
+
ws?: string[]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Block explorer URLs */
|
|
36
|
+
blockExplorers?: {
|
|
37
|
+
default: {
|
|
38
|
+
name: string
|
|
39
|
+
url: string
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** Function that sends an HTTP request to a Stacks node API path. */
|
|
44
|
+
type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
|
|
45
|
+
/** Options for a transport-level HTTP request. */
|
|
46
|
+
type RequestOptions = {
|
|
47
|
+
method?: "GET" | "POST" | "PUT" | "DELETE"
|
|
48
|
+
body?: unknown
|
|
49
|
+
headers?: Record<string, string>
|
|
50
|
+
};
|
|
51
|
+
/** Shared configuration for all transport types. */
|
|
52
|
+
type TransportConfig = {
|
|
53
|
+
url?: string
|
|
54
|
+
timeout?: number
|
|
55
|
+
retryCount?: number
|
|
56
|
+
retryDelay?: number
|
|
57
|
+
fetchOptions?: RequestInit
|
|
58
|
+
apiKey?: string
|
|
59
|
+
};
|
|
60
|
+
/** A resolved transport instance with a bound request function. */
|
|
61
|
+
type Transport = {
|
|
62
|
+
type: string
|
|
63
|
+
request: RequestFn
|
|
64
|
+
config: TransportConfig
|
|
65
|
+
destroy?: () => void
|
|
66
|
+
};
|
|
67
|
+
/** Factory that creates a {@link Transport} given an optional chain context. */
|
|
68
|
+
type TransportFactory = (params?: {
|
|
69
|
+
chain?: StacksChain
|
|
70
|
+
}) => Transport;
|
|
71
|
+
/** Account derived from a local private key (mnemonic or raw key). */
|
|
72
|
+
type LocalAccount = {
|
|
73
|
+
type: "local"
|
|
74
|
+
address: string
|
|
75
|
+
/** Compressed public key (hex) */
|
|
76
|
+
publicKey: string
|
|
77
|
+
/** Raw ECDSA sign over a hash */
|
|
78
|
+
sign(hash: Uint8Array): Uint8Array
|
|
79
|
+
/** Sign a structured message (SIP-018) */
|
|
80
|
+
signMessage(message: string | Uint8Array): string
|
|
81
|
+
};
|
|
82
|
+
/** Account with a user-provided signing function (sync or async). */
|
|
83
|
+
type CustomAccount = {
|
|
84
|
+
type: "custom"
|
|
85
|
+
address: string
|
|
86
|
+
publicKey: string
|
|
87
|
+
sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
|
|
88
|
+
};
|
|
89
|
+
/** Browser wallet provider interface (e.g. Leather, Xverse). */
|
|
90
|
+
type StacksProvider = {
|
|
91
|
+
request(method: string, params?: any): Promise<any>
|
|
92
|
+
};
|
|
93
|
+
/** Account backed by a browser wallet {@link StacksProvider}. */
|
|
94
|
+
type ProviderAccount = {
|
|
95
|
+
type: "provider"
|
|
96
|
+
address: string
|
|
97
|
+
publicKey: string
|
|
98
|
+
provider: StacksProvider
|
|
99
|
+
};
|
|
100
|
+
/** Union of all supported account types (local key, custom signer, or browser provider). */
|
|
101
|
+
type Account = LocalAccount | CustomAccount | ProviderAccount;
|
|
102
|
+
/**
|
|
103
|
+
* Core client instance that holds chain context, transport, and extensible actions.
|
|
104
|
+
* Created via {@link createClient}, {@link createPublicClient}, or {@link createWalletClient}.
|
|
105
|
+
*/
|
|
106
|
+
type Client<TExtended extends Record<string, unknown> = Record<string, unknown>> = {
|
|
107
|
+
chain?: StacksChain
|
|
108
|
+
account?: Account
|
|
109
|
+
transport: Transport
|
|
110
|
+
request: RequestFn
|
|
111
|
+
extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
|
|
112
|
+
} & TExtended;
|
|
113
|
+
/** Configuration for creating a base {@link Client}. */
|
|
114
|
+
type ClientConfig = {
|
|
115
|
+
chain?: StacksChain
|
|
116
|
+
transport: TransportFactory
|
|
117
|
+
account?: Account
|
|
118
|
+
};
|
|
119
|
+
/** A client pre-extended with read-only {@link PublicActions}. */
|
|
120
|
+
type PublicClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended>;
|
|
121
|
+
/** A client pre-extended with {@link WalletActions} and a required account. */
|
|
122
|
+
type WalletClient<TExtended extends Record<string, unknown> = Record<string, unknown>> = Client<TExtended> & {
|
|
123
|
+
account: Account
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Create a base client with transport and optional chain/account.
|
|
127
|
+
* Use `.extend()` to compose action decorators (public, wallet, multisig).
|
|
128
|
+
*/
|
|
129
|
+
declare function createClient<TExtended extends Record<string, unknown> = Record<string, unknown>>(config: ClientConfig): Client<TExtended>;
|
|
130
|
+
type GetNonceParams = {
|
|
131
|
+
address: string
|
|
132
|
+
};
|
|
133
|
+
type GetBalanceParams = {
|
|
134
|
+
address: string
|
|
135
|
+
};
|
|
136
|
+
type GetAccountInfoParams = {
|
|
137
|
+
address: string
|
|
138
|
+
};
|
|
139
|
+
type AccountInfo = {
|
|
140
|
+
balance: bigint
|
|
141
|
+
nonce: bigint
|
|
142
|
+
balanceProof: string
|
|
143
|
+
nonceProof: string
|
|
144
|
+
};
|
|
145
|
+
type GetBlockParams = {
|
|
146
|
+
height?: number
|
|
147
|
+
hash?: string
|
|
148
|
+
};
|
|
149
|
+
type IntCV = {
|
|
150
|
+
readonly type: "int"
|
|
151
|
+
readonly value: bigint
|
|
152
|
+
};
|
|
153
|
+
type UIntCV = {
|
|
154
|
+
readonly type: "uint"
|
|
155
|
+
readonly value: bigint
|
|
156
|
+
};
|
|
157
|
+
type BooleanCV = TrueCV | FalseCV;
|
|
158
|
+
type TrueCV = {
|
|
159
|
+
readonly type: "true"
|
|
160
|
+
};
|
|
161
|
+
type FalseCV = {
|
|
162
|
+
readonly type: "false"
|
|
163
|
+
};
|
|
164
|
+
type BufferCV = {
|
|
165
|
+
readonly type: "buffer"
|
|
166
|
+
readonly value: string
|
|
167
|
+
};
|
|
168
|
+
type NoneCV = {
|
|
169
|
+
readonly type: "none"
|
|
170
|
+
};
|
|
171
|
+
type SomeCV = {
|
|
172
|
+
readonly type: "some"
|
|
173
|
+
readonly value: ClarityValue
|
|
174
|
+
};
|
|
175
|
+
type ResponseOkCV = {
|
|
176
|
+
readonly type: "ok"
|
|
177
|
+
readonly value: ClarityValue
|
|
178
|
+
};
|
|
179
|
+
type ResponseErrorCV = {
|
|
180
|
+
readonly type: "err"
|
|
181
|
+
readonly value: ClarityValue
|
|
182
|
+
};
|
|
183
|
+
type StandardPrincipalCV = {
|
|
184
|
+
readonly type: "address"
|
|
185
|
+
readonly value: string
|
|
186
|
+
};
|
|
187
|
+
type ContractPrincipalCV = {
|
|
188
|
+
readonly type: "contract"
|
|
189
|
+
readonly value: string
|
|
190
|
+
};
|
|
191
|
+
type ListCV = {
|
|
192
|
+
type: "list"
|
|
193
|
+
value: ClarityValue[]
|
|
194
|
+
};
|
|
195
|
+
type TupleData = {
|
|
196
|
+
[key: string]: ClarityValue
|
|
197
|
+
};
|
|
198
|
+
type TupleCV = {
|
|
199
|
+
type: "tuple"
|
|
200
|
+
value: TupleData
|
|
201
|
+
};
|
|
202
|
+
type StringAsciiCV = {
|
|
203
|
+
readonly type: "ascii"
|
|
204
|
+
readonly value: string
|
|
205
|
+
};
|
|
206
|
+
type StringUtf8CV = {
|
|
207
|
+
readonly type: "utf8"
|
|
208
|
+
readonly value: string
|
|
209
|
+
};
|
|
210
|
+
type ClarityValue = IntCV | UIntCV | BooleanCV | BufferCV | NoneCV | SomeCV | ResponseOkCV | ResponseErrorCV | StandardPrincipalCV | ContractPrincipalCV | ListCV | TupleCV | StringAsciiCV | StringUtf8CV;
|
|
211
|
+
type ReadContractParams = {
|
|
212
|
+
contract: string
|
|
213
|
+
functionName: string
|
|
214
|
+
args?: ClarityValue[]
|
|
215
|
+
sender?: string
|
|
216
|
+
};
|
|
217
|
+
type GetContractAbiParams = {
|
|
218
|
+
contract: string
|
|
219
|
+
};
|
|
220
|
+
type GetMapEntryParams = {
|
|
221
|
+
contract: string
|
|
222
|
+
mapName: string
|
|
223
|
+
key: ClarityValue
|
|
224
|
+
};
|
|
225
|
+
declare const AuthType: {
|
|
226
|
+
readonly Standard: 0x04
|
|
227
|
+
readonly Sponsored: 0x05
|
|
228
|
+
};
|
|
229
|
+
type AuthType = (typeof AuthType)[keyof typeof AuthType];
|
|
230
|
+
declare const PayloadType: {
|
|
231
|
+
readonly TokenTransfer: 0x00
|
|
232
|
+
readonly SmartContract: 0x01
|
|
233
|
+
readonly ContractCall: 0x02
|
|
234
|
+
readonly PoisonMicroblock: 0x03
|
|
235
|
+
readonly Coinbase: 0x04
|
|
236
|
+
readonly CoinbaseToAltRecipient: 0x05
|
|
237
|
+
readonly VersionedSmartContract: 0x06
|
|
238
|
+
readonly TenureChange: 0x07
|
|
239
|
+
readonly NakamotoCoinbase: 0x08
|
|
240
|
+
};
|
|
241
|
+
type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];
|
|
242
|
+
declare const ClarityVersion: {
|
|
243
|
+
readonly Clarity1: 1
|
|
244
|
+
readonly Clarity2: 2
|
|
245
|
+
readonly Clarity3: 3
|
|
246
|
+
};
|
|
247
|
+
type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
|
|
248
|
+
declare const AnchorMode: {
|
|
249
|
+
readonly OnChainOnly: 0x01
|
|
250
|
+
readonly OffChainOnly: 0x02
|
|
251
|
+
readonly Any: 0x03
|
|
252
|
+
};
|
|
253
|
+
type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];
|
|
254
|
+
declare const PostConditionModeWire: {
|
|
255
|
+
readonly Allow: 0x01
|
|
256
|
+
readonly Deny: 0x02
|
|
257
|
+
};
|
|
258
|
+
type PostConditionModeWire = (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];
|
|
259
|
+
declare const AddressHashMode: {
|
|
260
|
+
readonly P2PKH: 0x00
|
|
261
|
+
readonly P2SH: 0x01
|
|
262
|
+
readonly P2WPKH: 0x02
|
|
263
|
+
readonly P2WSH: 0x03
|
|
264
|
+
readonly P2SH_NonSequential: 0x05
|
|
265
|
+
readonly P2WSH_P2SH_NonSequential: 0x07
|
|
266
|
+
};
|
|
267
|
+
type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];
|
|
268
|
+
declare const PubKeyEncoding: {
|
|
269
|
+
readonly Compressed: 0x00
|
|
270
|
+
readonly Uncompressed: 0x01
|
|
271
|
+
};
|
|
272
|
+
type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];
|
|
273
|
+
type TokenTransferPayload = {
|
|
274
|
+
payloadType: typeof PayloadType.TokenTransfer
|
|
275
|
+
recipient: ClarityValue
|
|
276
|
+
amount: bigint
|
|
277
|
+
memo: string
|
|
278
|
+
};
|
|
279
|
+
type ContractCallPayload = {
|
|
280
|
+
payloadType: typeof PayloadType.ContractCall
|
|
281
|
+
contractAddress: string
|
|
282
|
+
contractName: string
|
|
283
|
+
functionName: string
|
|
284
|
+
functionArgs: ClarityValue[]
|
|
285
|
+
};
|
|
286
|
+
type SmartContractPayload = {
|
|
287
|
+
payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract
|
|
288
|
+
clarityVersion?: ClarityVersion
|
|
289
|
+
contractName: string
|
|
290
|
+
codeBody: string
|
|
291
|
+
};
|
|
292
|
+
type TransactionPayload = TokenTransferPayload | ContractCallPayload | SmartContractPayload;
|
|
293
|
+
type SingleSigSpendingCondition = {
|
|
294
|
+
hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH
|
|
295
|
+
signer: string
|
|
296
|
+
nonce: bigint
|
|
297
|
+
fee: bigint
|
|
298
|
+
keyEncoding: PubKeyEncoding
|
|
299
|
+
signature: string
|
|
300
|
+
};
|
|
301
|
+
type TransactionAuthField = {
|
|
302
|
+
pubKeyEncoding: PubKeyEncoding
|
|
303
|
+
type: "publicKey" | "signature"
|
|
304
|
+
data: string
|
|
305
|
+
};
|
|
306
|
+
type MultiSigHashMode = typeof AddressHashMode.P2SH | typeof AddressHashMode.P2WSH | typeof AddressHashMode.P2SH_NonSequential | typeof AddressHashMode.P2WSH_P2SH_NonSequential;
|
|
307
|
+
type MultiSigSpendingCondition = {
|
|
308
|
+
hashMode: MultiSigHashMode
|
|
309
|
+
signer: string
|
|
310
|
+
nonce: bigint
|
|
311
|
+
fee: bigint
|
|
312
|
+
fields: TransactionAuthField[]
|
|
313
|
+
signaturesRequired: number
|
|
314
|
+
};
|
|
315
|
+
type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;
|
|
316
|
+
type StandardAuthorization = {
|
|
317
|
+
authType: typeof AuthType.Standard
|
|
318
|
+
spendingCondition: SpendingCondition
|
|
319
|
+
};
|
|
320
|
+
type SponsoredAuthorization = {
|
|
321
|
+
authType: typeof AuthType.Sponsored
|
|
322
|
+
spendingCondition: SpendingCondition
|
|
323
|
+
sponsorSpendingCondition: SpendingCondition
|
|
324
|
+
};
|
|
325
|
+
type Authorization = StandardAuthorization | SponsoredAuthorization;
|
|
326
|
+
type StacksTransaction = {
|
|
327
|
+
version: number
|
|
328
|
+
chainId: number
|
|
329
|
+
auth: Authorization
|
|
330
|
+
anchorMode: AnchorMode
|
|
331
|
+
postConditionMode: PostConditionModeWire
|
|
332
|
+
postConditions: PostConditionWire[]
|
|
333
|
+
payload: TransactionPayload
|
|
334
|
+
};
|
|
335
|
+
type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
|
|
336
|
+
type StxPostConditionWire = {
|
|
337
|
+
type: "stx"
|
|
338
|
+
principal: PostConditionPrincipalWire
|
|
339
|
+
conditionCode: number
|
|
340
|
+
amount: bigint
|
|
341
|
+
};
|
|
342
|
+
type FtPostConditionWire = {
|
|
343
|
+
type: "ft"
|
|
344
|
+
principal: PostConditionPrincipalWire
|
|
345
|
+
asset: AssetInfoWire
|
|
346
|
+
conditionCode: number
|
|
347
|
+
amount: bigint
|
|
348
|
+
};
|
|
349
|
+
type NftPostConditionWire = {
|
|
350
|
+
type: "nft"
|
|
351
|
+
principal: PostConditionPrincipalWire
|
|
352
|
+
asset: AssetInfoWire
|
|
353
|
+
conditionCode: number
|
|
354
|
+
assetId: ClarityValue
|
|
355
|
+
};
|
|
356
|
+
type PostConditionPrincipalWire = {
|
|
357
|
+
type: "origin"
|
|
358
|
+
} | {
|
|
359
|
+
type: "standard"
|
|
360
|
+
address: string
|
|
361
|
+
} | {
|
|
362
|
+
type: "contract"
|
|
363
|
+
address: string
|
|
364
|
+
contractName: string
|
|
365
|
+
};
|
|
366
|
+
type AssetInfoWire = {
|
|
367
|
+
address: string
|
|
368
|
+
contractName: string
|
|
369
|
+
assetName: string
|
|
370
|
+
};
|
|
371
|
+
type EstimateFeeParams = {
|
|
372
|
+
transaction: StacksTransaction
|
|
373
|
+
};
|
|
374
|
+
type FeeEstimation = {
|
|
375
|
+
feeRate: number
|
|
376
|
+
fee: number
|
|
377
|
+
};
|
|
378
|
+
type MulticallCall = {
|
|
379
|
+
contract: string
|
|
380
|
+
functionName: string
|
|
381
|
+
args?: ClarityValue[]
|
|
382
|
+
sender?: string
|
|
383
|
+
};
|
|
384
|
+
type MulticallParams<TAllowFailure extends boolean = true> = {
|
|
385
|
+
calls: readonly MulticallCall[]
|
|
386
|
+
allowFailure?: TAllowFailure
|
|
387
|
+
};
|
|
388
|
+
type MulticallSuccessResult = {
|
|
389
|
+
status: "success"
|
|
390
|
+
result: ClarityValue
|
|
391
|
+
};
|
|
392
|
+
type MulticallFailureResult = {
|
|
393
|
+
status: "failure"
|
|
394
|
+
error: Error
|
|
395
|
+
};
|
|
396
|
+
type MulticallResult<T extends boolean> = T extends true ? (MulticallSuccessResult | MulticallFailureResult)[] : ClarityValue[];
|
|
397
|
+
declare class BaseError extends Error {
|
|
398
|
+
name: string;
|
|
399
|
+
shortMessage: string;
|
|
400
|
+
details?: string;
|
|
401
|
+
constructor(shortMessage: string, options?: {
|
|
402
|
+
cause?: Error
|
|
403
|
+
details?: string
|
|
404
|
+
});
|
|
405
|
+
toJSON(): {};
|
|
406
|
+
}
|
|
407
|
+
declare class SimulationError extends BaseError {
|
|
408
|
+
name: string;
|
|
409
|
+
writesDetected: boolean;
|
|
410
|
+
constructor(message: string, options: {
|
|
411
|
+
writesDetected: boolean
|
|
412
|
+
details?: string
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
type SimulateCallParams = {
|
|
416
|
+
contract: string
|
|
417
|
+
functionName: string
|
|
418
|
+
args?: ClarityValue[]
|
|
419
|
+
sender?: string
|
|
420
|
+
tip?: string
|
|
421
|
+
};
|
|
422
|
+
type SimulateCallSuccess = {
|
|
423
|
+
success: true
|
|
424
|
+
result: ClarityValue
|
|
425
|
+
};
|
|
426
|
+
type SimulateCallFailure = {
|
|
427
|
+
success: false
|
|
428
|
+
error: SimulationError
|
|
429
|
+
};
|
|
430
|
+
type SimulateCallResult = SimulateCallSuccess | SimulateCallFailure;
|
|
431
|
+
type SimulateTransactionParams = {
|
|
432
|
+
transaction: StacksTransaction
|
|
433
|
+
sender?: string
|
|
434
|
+
tip?: string
|
|
435
|
+
};
|
|
436
|
+
type SimulateContractCallResult = {
|
|
437
|
+
type: "contract-call"
|
|
438
|
+
execution: SimulateCallResult
|
|
439
|
+
fees: FeeEstimation[]
|
|
440
|
+
};
|
|
441
|
+
type SimulateTransferResult = {
|
|
442
|
+
type: "token-transfer"
|
|
443
|
+
fees: FeeEstimation[]
|
|
444
|
+
};
|
|
445
|
+
type SimulateDeployResult = {
|
|
446
|
+
type: "contract-deploy"
|
|
447
|
+
fees: FeeEstimation[]
|
|
448
|
+
};
|
|
449
|
+
type SimulateTransactionResult = SimulateContractCallResult | SimulateTransferResult | SimulateDeployResult;
|
|
450
|
+
/** Handle returned by WebSocket subscription methods; call `unsubscribe()` to stop. */
|
|
451
|
+
type Subscription = {
|
|
452
|
+
unsubscribe: () => void
|
|
453
|
+
};
|
|
454
|
+
type WsEvent = "block" | "mempool" | "tx_update" | "address_tx_update" | "address_balance_update" | "nft_event" | "nft_asset_event" | "nft_collection_event";
|
|
455
|
+
type WsSubscribeParams = {
|
|
456
|
+
event: WsEvent
|
|
457
|
+
tx_id?: string
|
|
458
|
+
address?: string
|
|
459
|
+
asset_identifier?: string
|
|
460
|
+
value?: string
|
|
461
|
+
};
|
|
462
|
+
type BlockNotification = {
|
|
463
|
+
canonical: boolean
|
|
464
|
+
height: number
|
|
465
|
+
hash: string
|
|
466
|
+
index_block_hash: string
|
|
467
|
+
parent_block_hash: string
|
|
468
|
+
burn_block_height: number
|
|
469
|
+
burn_block_hash: string
|
|
470
|
+
parent_burn_block_hash: string
|
|
471
|
+
parent_burn_block_height: number
|
|
472
|
+
parent_index_block_hash: string
|
|
473
|
+
txs: string[]
|
|
474
|
+
};
|
|
475
|
+
type MempoolNotification = {
|
|
476
|
+
tx_id: string
|
|
477
|
+
tx_type: string
|
|
478
|
+
tx_status: string
|
|
479
|
+
receipt_time: number
|
|
480
|
+
receipt_time_iso: string
|
|
481
|
+
fee_rate: string
|
|
482
|
+
sender_address: string
|
|
483
|
+
sponsor_address?: string
|
|
484
|
+
nonce: number
|
|
485
|
+
contract_call?: {
|
|
486
|
+
contract_id: string
|
|
487
|
+
function_name: string
|
|
488
|
+
function_signature: string
|
|
489
|
+
}
|
|
490
|
+
token_transfer?: {
|
|
491
|
+
recipient_address: string
|
|
492
|
+
amount: string
|
|
493
|
+
memo: string
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
type TxUpdateNotification = {
|
|
497
|
+
tx_id: string
|
|
498
|
+
tx_type: string
|
|
499
|
+
tx_status: string
|
|
500
|
+
block_hash?: string
|
|
501
|
+
block_height?: number
|
|
502
|
+
burn_block_height?: number
|
|
503
|
+
burn_block_time?: number
|
|
504
|
+
tx_result?: {
|
|
505
|
+
hex: string
|
|
506
|
+
repr: string
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
type AddressTxNotification = {
|
|
510
|
+
address: string
|
|
511
|
+
tx_id: string
|
|
512
|
+
tx_type: string
|
|
513
|
+
tx_status: string
|
|
514
|
+
stx_sent: string
|
|
515
|
+
stx_received: string
|
|
516
|
+
stx_transfers: Array<{
|
|
517
|
+
amount: string
|
|
518
|
+
sender: string
|
|
519
|
+
recipient: string
|
|
520
|
+
}>
|
|
521
|
+
ft_transfers: Array<{
|
|
522
|
+
amount: string
|
|
523
|
+
asset_identifier: string
|
|
524
|
+
sender: string
|
|
525
|
+
recipient: string
|
|
526
|
+
}>
|
|
527
|
+
nft_transfers: Array<{
|
|
528
|
+
asset_identifier: string
|
|
529
|
+
sender: string
|
|
530
|
+
recipient: string
|
|
531
|
+
value: {
|
|
532
|
+
hex: string
|
|
533
|
+
repr: string
|
|
534
|
+
}
|
|
535
|
+
}>
|
|
536
|
+
};
|
|
537
|
+
type AddressBalanceNotification = {
|
|
538
|
+
address: string
|
|
539
|
+
balance: string
|
|
540
|
+
total_sent: string
|
|
541
|
+
total_received: string
|
|
542
|
+
total_fees_sent: string
|
|
543
|
+
total_miner_rewards_received: string
|
|
544
|
+
lock_tx_id: string
|
|
545
|
+
locked: string
|
|
546
|
+
lock_height: number
|
|
547
|
+
burnchain_lock_height: number
|
|
548
|
+
burnchain_unlock_height: number
|
|
549
|
+
};
|
|
550
|
+
type NftEventNotification = {
|
|
551
|
+
sender: string
|
|
552
|
+
recipient: string
|
|
553
|
+
asset_identifier: string
|
|
554
|
+
asset_event_type: string
|
|
555
|
+
value: {
|
|
556
|
+
hex: string
|
|
557
|
+
repr: string
|
|
558
|
+
}
|
|
559
|
+
tx_id: string
|
|
560
|
+
block_height: number
|
|
561
|
+
};
|
|
562
|
+
type WatchBlocksParams = {
|
|
563
|
+
onBlock: (block: BlockNotification) => void
|
|
564
|
+
};
|
|
565
|
+
type WatchMempoolParams = {
|
|
566
|
+
onTransaction: (tx: MempoolNotification) => void
|
|
567
|
+
};
|
|
568
|
+
type WatchTransactionParams = {
|
|
569
|
+
txId: string
|
|
570
|
+
onUpdate: (update: TxUpdateNotification) => void
|
|
571
|
+
};
|
|
572
|
+
type WatchAddressParams = {
|
|
573
|
+
address: string
|
|
574
|
+
onTransaction: (tx: AddressTxNotification) => void
|
|
575
|
+
};
|
|
576
|
+
type WatchAddressBalanceParams = {
|
|
577
|
+
address: string
|
|
578
|
+
onBalance: (balance: AddressBalanceNotification) => void
|
|
579
|
+
};
|
|
580
|
+
type WatchNftEventParams = {
|
|
581
|
+
onEvent: (event: NftEventNotification) => void
|
|
582
|
+
assetIdentifier?: string
|
|
583
|
+
value?: string
|
|
584
|
+
};
|
|
585
|
+
/** Read-only actions: balance queries, contract reads, block data, and event subscriptions. */
|
|
586
|
+
type PublicActions = {
|
|
587
|
+
getNonce: (params: GetNonceParams) => Promise<bigint>
|
|
588
|
+
getBalance: (params: GetBalanceParams) => Promise<bigint>
|
|
589
|
+
getAccountInfo: (params: GetAccountInfoParams) => Promise<AccountInfo>
|
|
590
|
+
getBlock: (params: GetBlockParams) => Promise<any>
|
|
591
|
+
getBlockHeight: () => Promise<number>
|
|
592
|
+
readContract: (params: ReadContractParams) => Promise<ClarityValue>
|
|
593
|
+
getContractAbi: (params: GetContractAbiParams) => Promise<any>
|
|
594
|
+
getMapEntry: (params: GetMapEntryParams) => Promise<ClarityValue>
|
|
595
|
+
estimateFee: (params: EstimateFeeParams) => Promise<FeeEstimation[]>
|
|
596
|
+
multicall: <T extends boolean = true>(params: MulticallParams<T>) => Promise<MulticallResult<T>>
|
|
597
|
+
simulateCall: (params: SimulateCallParams) => Promise<SimulateCallResult>
|
|
598
|
+
simulateTransaction: (params: SimulateTransactionParams) => Promise<SimulateTransactionResult>
|
|
599
|
+
watchBlocks: (params: WatchBlocksParams) => Promise<Subscription>
|
|
600
|
+
watchMempool: (params: WatchMempoolParams) => Promise<Subscription>
|
|
601
|
+
watchTransaction: (params: WatchTransactionParams) => Promise<Subscription>
|
|
602
|
+
watchAddress: (params: WatchAddressParams) => Promise<Subscription>
|
|
603
|
+
watchAddressBalance: (params: WatchAddressBalanceParams) => Promise<Subscription>
|
|
604
|
+
watchNftEvent: (params: WatchNftEventParams) => Promise<Subscription>
|
|
605
|
+
};
|
|
606
|
+
/** Decorator that binds {@link PublicActions} to a client instance. */
|
|
607
|
+
declare function publicActions(client: Client): PublicActions;
|
|
608
|
+
/** Configuration for {@link createPublicClient} (no account needed). */
|
|
609
|
+
type PublicClientConfig = Omit<ClientConfig, "account">;
|
|
610
|
+
/**
|
|
611
|
+
* Create a read-only client pre-extended with {@link PublicActions}.
|
|
612
|
+
* Use for queries, contract reads, and event subscriptions.
|
|
613
|
+
*/
|
|
614
|
+
declare function createPublicClient(config: PublicClientConfig): Client<PublicActions> & PublicActions;
|
|
615
|
+
type SendTransactionParams = {
|
|
616
|
+
transaction: StacksTransaction
|
|
617
|
+
attachment?: Uint8Array | string
|
|
618
|
+
};
|
|
619
|
+
type SendTransactionResult = {
|
|
620
|
+
txid: string
|
|
621
|
+
};
|
|
622
|
+
type SignTransactionParams = {
|
|
623
|
+
transaction: StacksTransaction
|
|
624
|
+
/** Public keys for multi-sig signing (auto-detected from _multisig metadata if omitted) */
|
|
625
|
+
signers?: string[]
|
|
626
|
+
};
|
|
627
|
+
type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
|
|
628
|
+
type NonFungibleComparator = "sent" | "not-sent";
|
|
629
|
+
type StxPostCondition = {
|
|
630
|
+
type: "stx-postcondition"
|
|
631
|
+
address: string
|
|
632
|
+
condition: FungibleComparator
|
|
633
|
+
amount: string | bigint | number
|
|
634
|
+
};
|
|
635
|
+
type FtPostCondition = {
|
|
636
|
+
type: "ft-postcondition"
|
|
637
|
+
address: string
|
|
638
|
+
condition: FungibleComparator
|
|
639
|
+
asset: string
|
|
640
|
+
amount: string | bigint | number
|
|
641
|
+
};
|
|
642
|
+
type NftPostCondition = {
|
|
643
|
+
type: "nft-postcondition"
|
|
644
|
+
address: string
|
|
645
|
+
condition: NonFungibleComparator
|
|
646
|
+
asset: string
|
|
647
|
+
assetId: ClarityValue
|
|
648
|
+
};
|
|
649
|
+
type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition;
|
|
650
|
+
type IntegerType = number | string | bigint | Uint8Array;
|
|
651
|
+
type TransferStxParams = {
|
|
652
|
+
to: string
|
|
653
|
+
amount: IntegerType
|
|
654
|
+
memo?: string
|
|
655
|
+
fee?: IntegerType
|
|
656
|
+
nonce?: IntegerType
|
|
657
|
+
postConditionMode?: "allow" | "deny"
|
|
658
|
+
postConditions?: PostCondition[]
|
|
659
|
+
};
|
|
660
|
+
type CallContractParams = {
|
|
661
|
+
contract: string
|
|
662
|
+
functionName: string
|
|
663
|
+
functionArgs?: ClarityValue[]
|
|
664
|
+
fee?: IntegerType
|
|
665
|
+
nonce?: IntegerType
|
|
666
|
+
postConditionMode?: "allow" | "deny"
|
|
667
|
+
postConditions?: PostCondition[]
|
|
668
|
+
};
|
|
669
|
+
type DeployContractParams = {
|
|
670
|
+
contractName: string
|
|
671
|
+
codeBody: string
|
|
672
|
+
clarityVersion?: ClarityVersion
|
|
673
|
+
fee?: IntegerType
|
|
674
|
+
nonce?: IntegerType
|
|
675
|
+
postConditionMode?: "allow" | "deny"
|
|
676
|
+
postConditions?: PostCondition[]
|
|
677
|
+
};
|
|
678
|
+
type SignMessageParams = {
|
|
679
|
+
message: string | ClarityValue
|
|
680
|
+
domain?: {
|
|
681
|
+
name: string
|
|
682
|
+
version: string
|
|
683
|
+
chainId: number
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
type SponsorTransactionParams = {
|
|
687
|
+
transaction: StacksTransaction
|
|
688
|
+
fee?: IntegerType
|
|
689
|
+
nonce?: IntegerType
|
|
690
|
+
};
|
|
691
|
+
/** Signing actions: send transactions, transfer STX, call/deploy contracts, sign messages. */
|
|
692
|
+
type WalletActions = {
|
|
693
|
+
sendTransaction: (params: SendTransactionParams) => Promise<SendTransactionResult>
|
|
694
|
+
signTransaction: (params: SignTransactionParams) => Promise<StacksTransaction>
|
|
695
|
+
transferStx: (params: TransferStxParams) => Promise<string>
|
|
696
|
+
callContract: (params: CallContractParams) => Promise<string>
|
|
697
|
+
deployContract: (params: DeployContractParams) => Promise<string>
|
|
698
|
+
signMessage: (params: SignMessageParams) => Promise<string>
|
|
699
|
+
sponsorTransaction: (params: SponsorTransactionParams) => Promise<StacksTransaction>
|
|
700
|
+
};
|
|
701
|
+
/** Decorator that binds {@link WalletActions} to a client instance. */
|
|
702
|
+
declare function walletActions(client: Client): WalletActions;
|
|
703
|
+
/** Configuration for {@link createWalletClient} — requires an account for signing. */
|
|
704
|
+
type WalletClientConfig = ClientConfig & {
|
|
705
|
+
account: Account
|
|
706
|
+
};
|
|
707
|
+
/**
|
|
708
|
+
* Create a client pre-extended with {@link WalletActions} for signing and broadcasting transactions.
|
|
709
|
+
*/
|
|
710
|
+
declare function createWalletClient(config: WalletClientConfig): Client<WalletActions> & WalletActions & {
|
|
711
|
+
account: Account
|
|
712
|
+
};
|
|
713
|
+
type MultiSigTransferStxParams = {
|
|
714
|
+
to: string
|
|
715
|
+
amount: IntegerType
|
|
716
|
+
memo?: string
|
|
717
|
+
fee?: IntegerType
|
|
718
|
+
nonce?: IntegerType
|
|
719
|
+
postConditionMode?: "allow" | "deny"
|
|
720
|
+
postConditions?: PostCondition[]
|
|
721
|
+
};
|
|
722
|
+
type MultiSigCallContractParams = {
|
|
723
|
+
contract: string
|
|
724
|
+
functionName: string
|
|
725
|
+
functionArgs?: ClarityValue[]
|
|
726
|
+
fee?: IntegerType
|
|
727
|
+
nonce?: IntegerType
|
|
728
|
+
postConditionMode?: "allow" | "deny"
|
|
729
|
+
postConditions?: PostCondition[]
|
|
730
|
+
};
|
|
731
|
+
type MultiSigDeployContractParams = {
|
|
732
|
+
contractName: string
|
|
733
|
+
codeBody: string
|
|
734
|
+
clarityVersion?: ClarityVersion
|
|
735
|
+
fee?: IntegerType
|
|
736
|
+
nonce?: IntegerType
|
|
737
|
+
postConditionMode?: "allow" | "deny"
|
|
738
|
+
postConditions?: PostCondition[]
|
|
739
|
+
};
|
|
740
|
+
type MultiSigSendTransactionParams = {
|
|
741
|
+
transaction: StacksTransaction
|
|
742
|
+
attachment?: Uint8Array | string
|
|
743
|
+
};
|
|
744
|
+
/** Multi-sig transaction actions: build unsigned transactions and broadcast with auto-finalization. */
|
|
745
|
+
type MultiSigActions = {
|
|
746
|
+
transferStx: (params: MultiSigTransferStxParams) => Promise<StacksTransaction>
|
|
747
|
+
callContract: (params: MultiSigCallContractParams) => Promise<StacksTransaction>
|
|
748
|
+
deployContract: (params: MultiSigDeployContractParams) => Promise<StacksTransaction>
|
|
749
|
+
sendTransaction: (params: MultiSigSendTransactionParams) => Promise<SendTransactionResult>
|
|
750
|
+
};
|
|
751
|
+
/** Decorator that binds {@link MultiSigActions} to a multi-sig client. */
|
|
752
|
+
declare function multisigActions(client: Client): MultiSigActions;
|
|
753
|
+
/** Configuration for {@link createMultiSigClient} — requires signer public keys and threshold. */
|
|
754
|
+
type MultiSigClientConfig = Omit<ClientConfig, "account"> & {
|
|
755
|
+
signers: string[]
|
|
756
|
+
requiredSignatures: number
|
|
757
|
+
hashMode?: MultiSigHashMode
|
|
758
|
+
};
|
|
759
|
+
/** A client pre-extended with {@link MultiSigActions} for m-of-n signing workflows. */
|
|
760
|
+
type MultiSigClient = Client<MultiSigActions> & MultiSigActions;
|
|
761
|
+
/**
|
|
762
|
+
* Create a client for multi-sig transaction workflows.
|
|
763
|
+
* Builds unsigned transactions that can be signed by each party then broadcast.
|
|
764
|
+
*/
|
|
765
|
+
declare function createMultiSigClient(config: MultiSigClientConfig): MultiSigClient;
|
|
766
|
+
/**
|
|
767
|
+
* Create an HTTP transport for Stacks node RPC calls.
|
|
768
|
+
* Falls back to the chain's default RPC URL, then `localhost:3999`.
|
|
769
|
+
*/
|
|
770
|
+
declare function http(url?: string, config?: TransportConfig): TransportFactory;
|
|
771
|
+
/** Create a transport backed by a user-provided request function. */
|
|
772
|
+
declare function custom(params: {
|
|
773
|
+
request: RequestFn
|
|
774
|
+
}): TransportFactory;
|
|
775
|
+
/** Create a transport that tries each transport in order until one succeeds. */
|
|
776
|
+
declare function fallback(transports: TransportFactory[]): TransportFactory;
|
|
777
|
+
/** Configuration for the WebSocket transport, extending base {@link TransportConfig}. */
|
|
778
|
+
type WebSocketTransportConfig = TransportConfig & {
|
|
779
|
+
/** WebSocket URL (resolved from chain if omitted) */
|
|
780
|
+
url?: string
|
|
781
|
+
/** Enable auto-reconnect (default: true) */
|
|
782
|
+
reconnect?: boolean
|
|
783
|
+
/** Max reconnect attempts (default: 10) */
|
|
784
|
+
reconnectMaxAttempts?: number
|
|
785
|
+
/** Base delay in ms for exponential backoff (default: 1000) */
|
|
786
|
+
reconnectBaseDelay?: number
|
|
787
|
+
};
|
|
788
|
+
/** Transport with WebSocket subscription capabilities and auto-reconnect. */
|
|
789
|
+
type WebSocketTransport = Transport & {
|
|
790
|
+
type: "webSocket"
|
|
791
|
+
subscribe: (params: WsSubscribeParams, callback: (data: any) => void) => Promise<Subscription>
|
|
792
|
+
destroy: () => void
|
|
793
|
+
};
|
|
794
|
+
/**
|
|
795
|
+
* Create a WebSocket transport for real-time Stacks event subscriptions.
|
|
796
|
+
* HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.
|
|
797
|
+
*/
|
|
798
|
+
declare function webSocket(url?: string, config?: WebSocketTransportConfig): TransportFactory;
|
|
799
|
+
/** Create a ProviderAccount by querying the wallet for addresses */
|
|
800
|
+
declare function providerToAccount(provider: StacksProvider): Promise<ProviderAccount>;
|
|
801
|
+
/** Stacks mainnet chain definition (Hiro API). */
|
|
802
|
+
declare const mainnet: StacksChain;
|
|
803
|
+
/** Stacks testnet chain definition (Hiro API). */
|
|
804
|
+
declare const testnet: StacksChain;
|
|
805
|
+
/** Local development chain definition (localhost:3999). */
|
|
806
|
+
declare const devnet: StacksChain;
|
|
807
|
+
/** Alias for devnet used in mock/test environments. */
|
|
808
|
+
declare const mocknet: StacksChain;
|
|
809
|
+
/** Identity helper for defining a custom {@link StacksChain} with full type inference. */
|
|
810
|
+
declare function defineChain(chain: StacksChain): StacksChain;
|
|
811
|
+
/**
|
|
812
|
+
* Format microSTX to STX string (6 decimals).
|
|
813
|
+
* @example formatStx(1000000n) → "1.0"
|
|
814
|
+
*/
|
|
815
|
+
declare function formatStx(microStx: bigint | number | string): string;
|
|
816
|
+
/**
|
|
817
|
+
* Parse STX string to microSTX bigint (6 decimals).
|
|
818
|
+
* @example parseStx("1.5") → 1500000n
|
|
819
|
+
*/
|
|
820
|
+
declare function parseStx(stx: string | number): bigint;
|
|
821
|
+
/** C32-encoded address version bytes for single-sig and multi-sig on each network. */
|
|
822
|
+
declare const AddressVersion: {
|
|
823
|
+
readonly MainnetSingleSig: 22
|
|
824
|
+
readonly MainnetMultiSig: 20
|
|
825
|
+
readonly TestnetSingleSig: 26
|
|
826
|
+
readonly TestnetMultiSig: 21
|
|
827
|
+
};
|
|
828
|
+
type AddressVersion = (typeof AddressVersion)[keyof typeof AddressVersion];
|
|
829
|
+
/** Mainnet burn address (all-zero hash160). */
|
|
830
|
+
declare const ZERO_ADDRESS = "SP000000000000000000002Q6VF78";
|
|
831
|
+
/** Testnet burn address (all-zero hash160). */
|
|
832
|
+
declare const TESTNET_ZERO_ADDRESS = "ST000000000000000000002AMW42H";
|
|
833
|
+
/** Number of microSTX per 1 STX (10^6). */
|
|
834
|
+
declare const MICROSTX_PER_STX = 1000000n;
|
|
835
|
+
/** Alias for validateStacksAddress — matches future.md naming. */
|
|
836
|
+
declare const isValidAddress: unknown;
|
|
837
|
+
/**
|
|
838
|
+
* Compare two Stacks addresses for equality (case-insensitive, version-aware).
|
|
839
|
+
* Throws if either address is invalid.
|
|
840
|
+
*/
|
|
841
|
+
declare function isAddressEqual(a: string, b: string): boolean;
|
|
842
|
+
/**
|
|
843
|
+
* Build a contract address from deployer + contract name.
|
|
844
|
+
* Validates both parts; returns `deployer.contractName`.
|
|
845
|
+
*/
|
|
846
|
+
declare function getContractAddress(deployer: string, contractName: string): string;
|
|
847
|
+
export { webSocket, walletActions, testnet, publicActions, providerToAccount, parseStx, multisigActions, mocknet, mainnet, isValidAddress, isAddressEqual, http, getContractAddress, formatStx, fallback, devnet, defineChain, custom, createWalletClient, createPublicClient, createMultiSigClient, createClient, ZERO_ADDRESS, WebSocketTransportConfig, WebSocketTransport, WalletClientConfig, WalletClient, WalletActions, TransportFactory, TransportConfig, Transport, TESTNET_ZERO_ADDRESS, Subscription, StacksProvider, StacksChain, RequestOptions, RequestFn, PublicClientConfig, PublicClient, PublicActions, ProviderAccount, MultiSigClientConfig, MultiSigClient, MultiSigActions, MICROSTX_PER_STX, LocalAccount, CustomAccount, ClientConfig, Client, AddressVersion, Account };
|