stxer 0.4.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +388 -18
- package/dist/ast.d.ts +32 -0
- package/dist/{BatchAPI.d.ts → batch-api.d.ts} +2 -1
- package/dist/clarity-api.d.ts +1 -1
- package/dist/constants.d.ts +9 -0
- package/dist/index.d.ts +6 -1
- package/dist/simulation-api.d.ts +138 -0
- package/dist/simulation.d.ts +12 -4
- package/dist/stxer.cjs.development.js +705 -287
- package/dist/stxer.cjs.development.js.map +1 -1
- package/dist/stxer.cjs.production.min.js +1 -1
- package/dist/stxer.cjs.production.min.js.map +1 -1
- package/dist/stxer.esm.js +696 -288
- package/dist/stxer.esm.js.map +1 -1
- package/dist/tip.d.ts +16 -0
- package/dist/types.d.ts +598 -0
- package/package.json +19 -12
- package/src/ast.ts +120 -0
- package/src/{BatchAPI.ts → batch-api.ts} +9 -8
- package/src/{BatchProcessor.ts → batch-processor.ts} +1 -1
- package/src/clarity-api.ts +1 -1
- package/src/constants.ts +12 -0
- package/src/index.ts +10 -1
- package/src/simulation-api.ts +273 -0
- package/src/simulation.ts +169 -138
- package/src/tip.ts +42 -0
- package/src/types.ts +700 -0
- package/dist/sample/counter.d.ts +0 -1
- package/dist/sample/read.d.ts +0 -1
- package/src/sample/counter.ts +0 -42
- package/src/sample/read.ts +0 -139
- /package/dist/{BatchProcessor.d.ts → batch-processor.d.ts} +0 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for stxer-api V2 endpoints
|
|
3
|
+
* Hand-written types based on OpenAPI spec at https://api.stxer.xyz/openapi.json
|
|
4
|
+
*/
|
|
5
|
+
export interface TenureCost {
|
|
6
|
+
read_count: number;
|
|
7
|
+
read_length: number;
|
|
8
|
+
write_count: number;
|
|
9
|
+
write_length: number;
|
|
10
|
+
runtime: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SidecarTip {
|
|
13
|
+
bitcoin_height: number;
|
|
14
|
+
block_hash: string;
|
|
15
|
+
block_height: number;
|
|
16
|
+
block_time: number;
|
|
17
|
+
burn_block_height: number;
|
|
18
|
+
burn_block_time: number;
|
|
19
|
+
consensus_hash: string;
|
|
20
|
+
index_block_hash: string;
|
|
21
|
+
is_nakamoto: boolean;
|
|
22
|
+
tenure_cost: TenureCost;
|
|
23
|
+
tenure_height: number;
|
|
24
|
+
sortition_id: string;
|
|
25
|
+
epoch_id: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ClarityAbiType {
|
|
28
|
+
readonly?: {
|
|
29
|
+
type: ClarityAbiTypeName;
|
|
30
|
+
length?: number;
|
|
31
|
+
} | string;
|
|
32
|
+
tuple?: {
|
|
33
|
+
name: string;
|
|
34
|
+
type: ClarityAbiType;
|
|
35
|
+
}[];
|
|
36
|
+
list?: {
|
|
37
|
+
type: ClarityAbiType;
|
|
38
|
+
length: number;
|
|
39
|
+
};
|
|
40
|
+
buffer?: {
|
|
41
|
+
length: number;
|
|
42
|
+
};
|
|
43
|
+
string_ascii?: {
|
|
44
|
+
length: number;
|
|
45
|
+
};
|
|
46
|
+
string_utf8?: {
|
|
47
|
+
length: number;
|
|
48
|
+
};
|
|
49
|
+
principal?: [];
|
|
50
|
+
bool?: [];
|
|
51
|
+
int?: {
|
|
52
|
+
length: number;
|
|
53
|
+
};
|
|
54
|
+
uint?: {
|
|
55
|
+
length: number;
|
|
56
|
+
};
|
|
57
|
+
response?: {
|
|
58
|
+
ok: ClarityAbiType;
|
|
59
|
+
error: ClarityAbiType;
|
|
60
|
+
};
|
|
61
|
+
optional?: ClarityAbiType;
|
|
62
|
+
contract?: {
|
|
63
|
+
name: string;
|
|
64
|
+
address: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export type ClarityAbiTypeName = 'optional' | 'response' | 'bool' | 'int' | 'uint' | 'string-ascii' | 'string-utf8' | 'buff' | 'list' | 'tuple' | 'principal' | 'trait-reference' | 'contract';
|
|
68
|
+
export interface ClarityAbiFunction {
|
|
69
|
+
name: string;
|
|
70
|
+
access: 'private' | 'public' | 'read_only';
|
|
71
|
+
args: Array<{
|
|
72
|
+
name: string;
|
|
73
|
+
type: ClarityAbiType;
|
|
74
|
+
}>;
|
|
75
|
+
outputs: {
|
|
76
|
+
type: ClarityAbiType;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface ClarityAbiVariable {
|
|
80
|
+
name: string;
|
|
81
|
+
access: 'variable' | 'constant';
|
|
82
|
+
type: ClarityAbiType;
|
|
83
|
+
}
|
|
84
|
+
export interface ClarityAbiMap {
|
|
85
|
+
name: string;
|
|
86
|
+
key: ClarityAbiType;
|
|
87
|
+
value: ClarityAbiType;
|
|
88
|
+
}
|
|
89
|
+
export interface ClarityAbiFungibleToken {
|
|
90
|
+
name: string;
|
|
91
|
+
}
|
|
92
|
+
export interface ClarityAbiNonFungibleToken {
|
|
93
|
+
name: string;
|
|
94
|
+
type: ClarityAbiType;
|
|
95
|
+
}
|
|
96
|
+
export type ClarityEpoch = 'Epoch10' | 'Epoch20' | 'Epoch2_05' | 'Epoch21' | 'Epoch22' | 'Epoch23' | 'Epoch24' | 'Epoch25' | 'Epoch30' | 'Epoch31' | 'Epoch32' | 'Epoch33' | 'Epoch34' | 'Epoch35';
|
|
97
|
+
export type ClarityVersion = 'Clarity1' | 'Clarity2' | 'Clarity3' | 'Clarity4';
|
|
98
|
+
export interface ClarityAbi {
|
|
99
|
+
functions: ClarityAbiFunction[];
|
|
100
|
+
variables: ClarityAbiVariable[];
|
|
101
|
+
maps: ClarityAbiMap[];
|
|
102
|
+
fungible_tokens: ClarityAbiFungibleToken[];
|
|
103
|
+
non_fungible_tokens: ClarityAbiNonFungibleToken[];
|
|
104
|
+
epoch: ClarityEpoch;
|
|
105
|
+
clarity_version: ClarityVersion;
|
|
106
|
+
}
|
|
107
|
+
export interface SymbolicExpressionField {
|
|
108
|
+
field: string;
|
|
109
|
+
}
|
|
110
|
+
export interface SymbolicExpressionTraitReference {
|
|
111
|
+
trait_reference: {
|
|
112
|
+
clarity_name: string;
|
|
113
|
+
trait_definition: string;
|
|
114
|
+
trait_definition_type: 'Defined' | 'Imported';
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export interface SymbolicExpressionAtom {
|
|
118
|
+
atom: string;
|
|
119
|
+
}
|
|
120
|
+
export interface SymbolicExpressionAtomValue {
|
|
121
|
+
atom_value: string;
|
|
122
|
+
}
|
|
123
|
+
export interface SymbolicExpressionLiteralValue {
|
|
124
|
+
literal_value: string;
|
|
125
|
+
}
|
|
126
|
+
export interface SymbolicExpressionList {
|
|
127
|
+
list: SymbolicExpression[];
|
|
128
|
+
}
|
|
129
|
+
export type SymbolicExpression = {
|
|
130
|
+
id: number;
|
|
131
|
+
span: string;
|
|
132
|
+
expr: SymbolicExpressionAtom | SymbolicExpressionAtomValue | SymbolicExpressionLiteralValue | SymbolicExpressionList | SymbolicExpressionField | SymbolicExpressionTraitReference;
|
|
133
|
+
pre_comments?: Array<{
|
|
134
|
+
comment: string;
|
|
135
|
+
span: string;
|
|
136
|
+
}>;
|
|
137
|
+
post_comments?: Array<{
|
|
138
|
+
comment: string;
|
|
139
|
+
span: string;
|
|
140
|
+
}>;
|
|
141
|
+
end_line_comment?: string;
|
|
142
|
+
};
|
|
143
|
+
export interface ContractAST {
|
|
144
|
+
contract_identifier: string;
|
|
145
|
+
expressions: SymbolicExpression[];
|
|
146
|
+
top_level_expression_sorting: number[];
|
|
147
|
+
referenced_traits: Record<string, {
|
|
148
|
+
trait_definition: string;
|
|
149
|
+
trait_definition_type: 'Defined' | 'Imported';
|
|
150
|
+
}>;
|
|
151
|
+
implemented_traits: string[];
|
|
152
|
+
tx_id?: string;
|
|
153
|
+
canonical?: boolean;
|
|
154
|
+
contract_id?: string;
|
|
155
|
+
block_height?: number;
|
|
156
|
+
source_code?: string;
|
|
157
|
+
abi?: ClarityAbi;
|
|
158
|
+
}
|
|
159
|
+
export interface ExecutionCost {
|
|
160
|
+
read_count: number;
|
|
161
|
+
read_length: number;
|
|
162
|
+
write_count: number;
|
|
163
|
+
write_length: number;
|
|
164
|
+
runtime: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Receipt for a transaction that the engine executed to completion.
|
|
168
|
+
*
|
|
169
|
+
* "Successful execution" does NOT imply contract-level success. Four
|
|
170
|
+
* failure signals to check, in this order:
|
|
171
|
+
* 1. Outer `Err` on `Result.Transaction` — engine could not run the tx
|
|
172
|
+
* at all (deserialization failure etc.); no receipt is produced.
|
|
173
|
+
* 2. `post_condition_aborted: true` — execution ran, post-condition
|
|
174
|
+
* tripped, state was rolled back.
|
|
175
|
+
* 3. `vm_error: string` (without `post_condition_aborted`) — Clarity
|
|
176
|
+
* VM raised a runtime error or static analysis failed.
|
|
177
|
+
* 4. `(err uX)` inside `result` — contract returned a Clarity error
|
|
178
|
+
* response. Application-level; NOT signalled by any field above.
|
|
179
|
+
* Decode `result` to detect.
|
|
180
|
+
*
|
|
181
|
+
* `post_condition_aborted` and `vm_error` are NOT independent: when a
|
|
182
|
+
* PC trips the upstream sets `post_condition_aborted: true` AND writes
|
|
183
|
+
* the PC abort reason into `vm_error` as a side effect. The reverse is
|
|
184
|
+
* not true — `vm_error` alone (with `post_condition_aborted: false`)
|
|
185
|
+
* means a VM / analysis failure that is not a PC abort.
|
|
186
|
+
*/
|
|
187
|
+
export interface TransactionReceipt {
|
|
188
|
+
/**
|
|
189
|
+
* Clarity return value, SIP-005 hex-serialized. For contract-call txs
|
|
190
|
+
* this includes the `(ok ...)` / `(err ...)` response wrapper —
|
|
191
|
+
* Clarity-level `(err uX)` lives here, NOT on `vm_error` or the outer
|
|
192
|
+
* `Err`.
|
|
193
|
+
*/
|
|
194
|
+
result: string;
|
|
195
|
+
stx_burned: number;
|
|
196
|
+
tx_index: number;
|
|
197
|
+
/**
|
|
198
|
+
* Error message from the upstream Clarity VM. `null` when the tx had
|
|
199
|
+
* no VM-level issue. When `post_condition_aborted` is `true` this
|
|
200
|
+
* field is also populated with the PC abort reason — check
|
|
201
|
+
* `post_condition_aborted` first to disambiguate.
|
|
202
|
+
*/
|
|
203
|
+
vm_error: string | null;
|
|
204
|
+
/**
|
|
205
|
+
* `true` when one or more post-conditions failed and the tx was
|
|
206
|
+
* aborted. Implies `vm_error` is also set (to the abort reason); the
|
|
207
|
+
* reverse does not hold.
|
|
208
|
+
*/
|
|
209
|
+
post_condition_aborted: boolean;
|
|
210
|
+
/** Wall-clock simulation time in milliseconds. */
|
|
211
|
+
costs: number;
|
|
212
|
+
execution_cost: ExecutionCost;
|
|
213
|
+
/**
|
|
214
|
+
* Events emitted during execution (contract logs, STX transfers,
|
|
215
|
+
* FT/NFT events, etc.). Each entry is a JSON-encoded **string** —
|
|
216
|
+
* call `JSON.parse(events[i])` to get the event object. Items are
|
|
217
|
+
* NOT JSON objects in the array.
|
|
218
|
+
*
|
|
219
|
+
* For typed access, use {@link parseSimulationEvent} or cast:
|
|
220
|
+
* `JSON.parse(events[i]) as SimulationEvent`.
|
|
221
|
+
*/
|
|
222
|
+
events: string[];
|
|
223
|
+
}
|
|
224
|
+
export interface TransactionOkResult {
|
|
225
|
+
Ok: TransactionReceipt;
|
|
226
|
+
}
|
|
227
|
+
export interface TransactionErrResult {
|
|
228
|
+
Err: string;
|
|
229
|
+
}
|
|
230
|
+
/** Common envelope present on every event variant. */
|
|
231
|
+
interface SimulationEventBase {
|
|
232
|
+
/** Hex txid with leading `0x`. */
|
|
233
|
+
txid: string;
|
|
234
|
+
event_index: number;
|
|
235
|
+
/**
|
|
236
|
+
* `true` when the event was emitted from successfully committed code.
|
|
237
|
+
* `false` when the tx was rolled back (post-condition abort, vm_error).
|
|
238
|
+
* Tracks rust `tx_receipt.vm_error.is_none() && !post_condition_aborted`.
|
|
239
|
+
*/
|
|
240
|
+
committed: boolean;
|
|
241
|
+
}
|
|
242
|
+
/** Payload for `print` events and other contract-emitted events. */
|
|
243
|
+
export interface SmartContractEventData {
|
|
244
|
+
/** `<address>.<contract_name>` of the contract that emitted the event. */
|
|
245
|
+
contract_identifier: string;
|
|
246
|
+
/** Topic key — `"print"` for `(print …)` calls. */
|
|
247
|
+
topic: string;
|
|
248
|
+
/**
|
|
249
|
+
* Structured Clarity Value JSON (the rust `Value` enum's serde output).
|
|
250
|
+
* The shape is complex and varies by Clarity type; prefer `raw_value`
|
|
251
|
+
* for typed decoding.
|
|
252
|
+
*/
|
|
253
|
+
value: unknown;
|
|
254
|
+
/**
|
|
255
|
+
* SIP-005 hex of the value, with leading `0x`. Pass to
|
|
256
|
+
* `deserializeCV()` from `@stacks/transactions` for typed decoding.
|
|
257
|
+
*/
|
|
258
|
+
raw_value: string;
|
|
259
|
+
}
|
|
260
|
+
export interface StxTransferEventData {
|
|
261
|
+
sender: string;
|
|
262
|
+
recipient: string;
|
|
263
|
+
/** uSTX amount as a decimal string (rust serializes u128 via Display). */
|
|
264
|
+
amount: string;
|
|
265
|
+
/** Hex memo, possibly empty. */
|
|
266
|
+
memo: string;
|
|
267
|
+
}
|
|
268
|
+
export interface StxMintEventData {
|
|
269
|
+
recipient: string;
|
|
270
|
+
amount: string;
|
|
271
|
+
}
|
|
272
|
+
export interface StxBurnEventData {
|
|
273
|
+
sender: string;
|
|
274
|
+
amount: string;
|
|
275
|
+
}
|
|
276
|
+
export interface StxLockEventData {
|
|
277
|
+
locked_amount: string;
|
|
278
|
+
/** Decimal string (rust serializes u64 via Display). */
|
|
279
|
+
unlock_height: string;
|
|
280
|
+
locked_address: string;
|
|
281
|
+
contract_identifier: string;
|
|
282
|
+
}
|
|
283
|
+
export interface NftTransferEventData {
|
|
284
|
+
/** `<contract_id>::<asset_name>`. */
|
|
285
|
+
asset_identifier: string;
|
|
286
|
+
sender: string;
|
|
287
|
+
recipient: string;
|
|
288
|
+
value: unknown;
|
|
289
|
+
raw_value: string;
|
|
290
|
+
}
|
|
291
|
+
export interface NftMintEventData {
|
|
292
|
+
asset_identifier: string;
|
|
293
|
+
recipient: string;
|
|
294
|
+
value: unknown;
|
|
295
|
+
raw_value: string;
|
|
296
|
+
}
|
|
297
|
+
export interface NftBurnEventData {
|
|
298
|
+
asset_identifier: string;
|
|
299
|
+
sender: string;
|
|
300
|
+
value: unknown;
|
|
301
|
+
raw_value: string;
|
|
302
|
+
}
|
|
303
|
+
export interface FtTransferEventData {
|
|
304
|
+
asset_identifier: string;
|
|
305
|
+
sender: string;
|
|
306
|
+
recipient: string;
|
|
307
|
+
amount: string;
|
|
308
|
+
}
|
|
309
|
+
export interface FtMintEventData {
|
|
310
|
+
asset_identifier: string;
|
|
311
|
+
recipient: string;
|
|
312
|
+
amount: string;
|
|
313
|
+
}
|
|
314
|
+
export interface FtBurnEventData {
|
|
315
|
+
asset_identifier: string;
|
|
316
|
+
sender: string;
|
|
317
|
+
amount: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Discriminated union of every event variant the simulator emits.
|
|
321
|
+
* The `type` discriminator names the per-variant payload key — e.g.
|
|
322
|
+
* `type: 'contract_event'` carries the payload at `event.contract_event`.
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* const event = parseSimulationEvent(receipt.events[0]);
|
|
326
|
+
* if (event.type === 'contract_event') {
|
|
327
|
+
* // event.contract_event.{contract_identifier, topic, raw_value, value}
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
export type SimulationEvent = (SimulationEventBase & {
|
|
332
|
+
type: 'contract_event';
|
|
333
|
+
contract_event: SmartContractEventData;
|
|
334
|
+
}) | (SimulationEventBase & {
|
|
335
|
+
type: 'stx_transfer_event';
|
|
336
|
+
stx_transfer_event: StxTransferEventData;
|
|
337
|
+
}) | (SimulationEventBase & {
|
|
338
|
+
type: 'stx_mint_event';
|
|
339
|
+
stx_mint_event: StxMintEventData;
|
|
340
|
+
}) | (SimulationEventBase & {
|
|
341
|
+
type: 'stx_burn_event';
|
|
342
|
+
stx_burn_event: StxBurnEventData;
|
|
343
|
+
}) | (SimulationEventBase & {
|
|
344
|
+
type: 'stx_lock_event';
|
|
345
|
+
stx_lock_event: StxLockEventData;
|
|
346
|
+
}) | (SimulationEventBase & {
|
|
347
|
+
type: 'nft_transfer_event';
|
|
348
|
+
nft_transfer_event: NftTransferEventData;
|
|
349
|
+
}) | (SimulationEventBase & {
|
|
350
|
+
type: 'nft_mint_event';
|
|
351
|
+
nft_mint_event: NftMintEventData;
|
|
352
|
+
}) | (SimulationEventBase & {
|
|
353
|
+
type: 'nft_burn_event';
|
|
354
|
+
nft_burn_event: NftBurnEventData;
|
|
355
|
+
}) | (SimulationEventBase & {
|
|
356
|
+
type: 'ft_transfer_event';
|
|
357
|
+
ft_transfer_event: FtTransferEventData;
|
|
358
|
+
}) | (SimulationEventBase & {
|
|
359
|
+
type: 'ft_mint_event';
|
|
360
|
+
ft_mint_event: FtMintEventData;
|
|
361
|
+
}) | (SimulationEventBase & {
|
|
362
|
+
type: 'ft_burn_event';
|
|
363
|
+
ft_burn_event: FtBurnEventData;
|
|
364
|
+
});
|
|
365
|
+
/** Convenience parser for `TransactionReceipt.events[i]`. */
|
|
366
|
+
export declare function parseSimulationEvent(raw: string): SimulationEvent;
|
|
367
|
+
export interface MapEntryStep {
|
|
368
|
+
MapEntry: [contract_id: string, map_name: string, key_hex: string];
|
|
369
|
+
}
|
|
370
|
+
export interface DataVarStep {
|
|
371
|
+
DataVar: [contract_id: string, variable_name: string];
|
|
372
|
+
}
|
|
373
|
+
export interface EvalReadonlyStep {
|
|
374
|
+
/** `sponsor` is `""` (empty string) when there is no sponsor. */
|
|
375
|
+
EvalReadonly: [
|
|
376
|
+
sender: string,
|
|
377
|
+
sponsor: string,
|
|
378
|
+
contract_id: string,
|
|
379
|
+
code: string
|
|
380
|
+
];
|
|
381
|
+
}
|
|
382
|
+
export interface StxBalanceStep {
|
|
383
|
+
/** Principal whose STX balance to read. */
|
|
384
|
+
StxBalance: string;
|
|
385
|
+
}
|
|
386
|
+
export interface FtBalanceStep {
|
|
387
|
+
/**
|
|
388
|
+
* Reads the FT balance via three separate parameters. Note: the batch
|
|
389
|
+
* `ft_balance` field on `SimulationBatchReadsRequest` uses a different
|
|
390
|
+
* `<contract_id>::<token_name>` combined identifier shape.
|
|
391
|
+
*/
|
|
392
|
+
FtBalance: [contract_id: string, token_name: string, principal: string];
|
|
393
|
+
}
|
|
394
|
+
export interface FtSupplyStep {
|
|
395
|
+
FtSupply: [contract_id: string, token_name: string];
|
|
396
|
+
}
|
|
397
|
+
export interface NonceStep {
|
|
398
|
+
/** Principal whose nonce to read. */
|
|
399
|
+
Nonce: string;
|
|
400
|
+
}
|
|
401
|
+
export type ReadStep = MapEntryStep | DataVarStep | EvalReadonlyStep | StxBalanceStep | FtBalanceStep | FtSupplyStep | NonceStep;
|
|
402
|
+
export interface ReadOkResult {
|
|
403
|
+
Ok: string;
|
|
404
|
+
}
|
|
405
|
+
export interface ReadErrResult {
|
|
406
|
+
Err: string;
|
|
407
|
+
}
|
|
408
|
+
export type ReadResult = ReadOkResult | ReadErrResult;
|
|
409
|
+
/**
|
|
410
|
+
* Per-step result returned by `POST /devtools/v2/simulations/{id}` (the
|
|
411
|
+
* "submit steps" endpoint). Mirrors the rust `RunSimulationStepResult`
|
|
412
|
+
* enum — externally tagged, exactly one variant key present.
|
|
413
|
+
*
|
|
414
|
+
* Distinct from `SimulationStepSummary`, which is what
|
|
415
|
+
* `GET /devtools/v2/simulations/{id}` returns and includes the original
|
|
416
|
+
* step input alongside the result.
|
|
417
|
+
*/
|
|
418
|
+
export type SimulationStepResult = {
|
|
419
|
+
Transaction: TransactionOkResult | TransactionErrResult;
|
|
420
|
+
} | {
|
|
421
|
+
Eval: {
|
|
422
|
+
Ok: string;
|
|
423
|
+
} | {
|
|
424
|
+
Err: string;
|
|
425
|
+
};
|
|
426
|
+
} | {
|
|
427
|
+
SetContractCode: {
|
|
428
|
+
Ok: null;
|
|
429
|
+
} | {
|
|
430
|
+
Err: string;
|
|
431
|
+
};
|
|
432
|
+
} | {
|
|
433
|
+
Reads: ReadResult[];
|
|
434
|
+
} | {
|
|
435
|
+
TenureExtend: ExecutionCost;
|
|
436
|
+
};
|
|
437
|
+
export interface TransactionStepSummary {
|
|
438
|
+
/** Transaction serialized to hex. */
|
|
439
|
+
Transaction: string;
|
|
440
|
+
/** Hex-encoded txid. Empty string `""` when the tx failed engine-level. */
|
|
441
|
+
TxId: string;
|
|
442
|
+
Result: {
|
|
443
|
+
Transaction: TransactionOkResult | TransactionErrResult;
|
|
444
|
+
};
|
|
445
|
+
ExecutionCost: ExecutionCost;
|
|
446
|
+
}
|
|
447
|
+
export interface ReadsStepSummary {
|
|
448
|
+
Reads: ReadStep[];
|
|
449
|
+
Result: {
|
|
450
|
+
Reads: ReadResult[];
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
export interface SetContractCodeStepSummary {
|
|
454
|
+
SetContractCode: [contract_id: string, code: string, clarity_version: number];
|
|
455
|
+
Result: {
|
|
456
|
+
SetContractCode: {
|
|
457
|
+
Ok: null;
|
|
458
|
+
} | {
|
|
459
|
+
Err: string;
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
export interface EvalStepSummary {
|
|
464
|
+
/** `sponsor` is `""` (empty string) when there is no sponsor. */
|
|
465
|
+
Eval: [sender: string, sponsor: string, contract_id: string, code: string];
|
|
466
|
+
Result: {
|
|
467
|
+
Eval: {
|
|
468
|
+
Ok: string;
|
|
469
|
+
} | {
|
|
470
|
+
Err: string;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
export interface TenureExtendStepSummary {
|
|
475
|
+
Result: {
|
|
476
|
+
TenureExtend: ExecutionCost;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
export type SimulationStepSummary = TransactionStepSummary | ReadsStepSummary | SetContractCodeStepSummary | EvalStepSummary | TenureExtendStepSummary;
|
|
480
|
+
export interface SimulationMetadata {
|
|
481
|
+
block_height: number;
|
|
482
|
+
block_hash: string;
|
|
483
|
+
burn_block_height: number;
|
|
484
|
+
burn_block_hash: string;
|
|
485
|
+
consensus_hash: string;
|
|
486
|
+
epoch: string;
|
|
487
|
+
index_block_hash: string;
|
|
488
|
+
skip_tracing: boolean;
|
|
489
|
+
sortition_id: string;
|
|
490
|
+
}
|
|
491
|
+
export interface SimulationResult {
|
|
492
|
+
metadata: SimulationMetadata;
|
|
493
|
+
steps: SimulationStepSummary[];
|
|
494
|
+
}
|
|
495
|
+
export interface CreateSimulationRequest {
|
|
496
|
+
block_height?: number;
|
|
497
|
+
block_hash?: string;
|
|
498
|
+
skip_tracing?: boolean;
|
|
499
|
+
}
|
|
500
|
+
export interface CreateSimulationResponse {
|
|
501
|
+
id: string;
|
|
502
|
+
}
|
|
503
|
+
export type SimulationStepInput = {
|
|
504
|
+
Transaction: string;
|
|
505
|
+
} | {
|
|
506
|
+
/** `sponsor` is `""` when there is no sponsor. */
|
|
507
|
+
Eval: [
|
|
508
|
+
sender: string,
|
|
509
|
+
sponsor: string,
|
|
510
|
+
contract_id: string,
|
|
511
|
+
code: string
|
|
512
|
+
];
|
|
513
|
+
} | {
|
|
514
|
+
SetContractCode: [
|
|
515
|
+
contract_id: string,
|
|
516
|
+
code: string,
|
|
517
|
+
clarity_version: number
|
|
518
|
+
];
|
|
519
|
+
} | {
|
|
520
|
+
Reads: ReadStep[];
|
|
521
|
+
} | {
|
|
522
|
+
TenureExtend: [];
|
|
523
|
+
};
|
|
524
|
+
export interface SubmitSimulationStepsRequest {
|
|
525
|
+
steps: SimulationStepInput[];
|
|
526
|
+
}
|
|
527
|
+
export interface SubmitSimulationStepsResponse {
|
|
528
|
+
steps: SimulationStepResult[];
|
|
529
|
+
}
|
|
530
|
+
export interface SimulationBatchReadsRequest {
|
|
531
|
+
/** `[contract_id, variable_name]` per entry. */
|
|
532
|
+
vars?: [contract_id: string, variable_name: string][];
|
|
533
|
+
/** `[contract_id, map_name, key_hex]` per entry. */
|
|
534
|
+
maps?: [contract_id: string, map_name: string, key_hex: string][];
|
|
535
|
+
/**
|
|
536
|
+
* `[contract_id, function_name, ...arg_hex]` per entry. The first two
|
|
537
|
+
* positions are fixed; remaining elements are hex-encoded Clarity
|
|
538
|
+
* values, one per function argument (so the length matches the
|
|
539
|
+
* function's arity, not arbitrary).
|
|
540
|
+
*/
|
|
541
|
+
readonly?: [
|
|
542
|
+
contract_id: string,
|
|
543
|
+
function_name: string,
|
|
544
|
+
...args_hex: string[]
|
|
545
|
+
][];
|
|
546
|
+
/**
|
|
547
|
+
* `[sender, sponsor, contract_id, function_name, ...arg_hex]` per
|
|
548
|
+
* entry. The first four positions are fixed (`sponsor` is `""` when
|
|
549
|
+
* there is no sponsor); remaining elements are hex-encoded Clarity
|
|
550
|
+
* values, one per function argument.
|
|
551
|
+
*/
|
|
552
|
+
readonly_with_sender?: [
|
|
553
|
+
sender: string,
|
|
554
|
+
sponsor: string,
|
|
555
|
+
contract_id: string,
|
|
556
|
+
function_name: string,
|
|
557
|
+
...args_hex: string[]
|
|
558
|
+
][];
|
|
559
|
+
/** Principals to read STX balances for. */
|
|
560
|
+
stx?: string[];
|
|
561
|
+
/** Principals to read nonces for. */
|
|
562
|
+
nonces?: string[];
|
|
563
|
+
/** `[<contract_id>::<token_name>, principal]` per entry. */
|
|
564
|
+
ft_balance?: [token_identifier: string, principal: string][];
|
|
565
|
+
/**
|
|
566
|
+
* Flat array of FT identifiers in `<contract_id>::<token_name>` form,
|
|
567
|
+
* one entry per token to look up. Any length.
|
|
568
|
+
*/
|
|
569
|
+
ft_supply?: string[];
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Each category is omitted from the JSON response when the corresponding
|
|
573
|
+
* request field was empty/absent (rust uses
|
|
574
|
+
* `serde(skip_serializing_if = "Vec::is_empty")` per field).
|
|
575
|
+
*/
|
|
576
|
+
export interface SimulationBatchReadsResponse {
|
|
577
|
+
vars?: ReadResult[];
|
|
578
|
+
maps?: ReadResult[];
|
|
579
|
+
readonly?: ReadResult[];
|
|
580
|
+
readonly_with_sender?: ReadResult[];
|
|
581
|
+
stx?: ReadResult[];
|
|
582
|
+
nonces?: ReadResult[];
|
|
583
|
+
ft_balance?: ReadResult[];
|
|
584
|
+
ft_supply?: ReadResult[];
|
|
585
|
+
}
|
|
586
|
+
export interface InstantSimulationRequest {
|
|
587
|
+
/** Transaction serialized to hex. */
|
|
588
|
+
transaction: string;
|
|
589
|
+
block_height?: number;
|
|
590
|
+
block_hash?: string;
|
|
591
|
+
reads?: ReadStep[];
|
|
592
|
+
}
|
|
593
|
+
export interface InstantSimulationResponse {
|
|
594
|
+
/** Always present (may be `[]`). Aligned positionally with the request `reads`. */
|
|
595
|
+
reads: ReadResult[];
|
|
596
|
+
receipt: TransactionReceipt;
|
|
597
|
+
}
|
|
598
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stxer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Kyle Fang",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"typings": "dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"!src/sample",
|
|
17
|
+
"!dist/sample"
|
|
16
18
|
],
|
|
17
19
|
"husky": {
|
|
18
20
|
"hooks": {
|
|
@@ -42,21 +44,21 @@
|
|
|
42
44
|
}
|
|
43
45
|
],
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"@biomejs/biome": "
|
|
46
|
-
"@size-limit/preset-small-lib": "
|
|
47
|
+
"@biomejs/biome": "2.4.13",
|
|
48
|
+
"@size-limit/preset-small-lib": "12.1.0",
|
|
47
49
|
"@tsconfig/recommended": "^1.0.13",
|
|
48
|
-
"@types/node": "
|
|
50
|
+
"@types/node": "25.6.0",
|
|
49
51
|
"dts-cli": "^2.0.5",
|
|
50
52
|
"husky": "^9.1.7",
|
|
51
|
-
"size-limit": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
53
|
+
"size-limit": "12.1.0",
|
|
54
|
+
"tsx": "^4.21.0",
|
|
55
|
+
"typescript": "5.9.3",
|
|
56
|
+
"vitest": "^4.1.5"
|
|
55
57
|
},
|
|
56
58
|
"dependencies": {
|
|
57
|
-
"@stacks/network": "^7.
|
|
59
|
+
"@stacks/network": "^7.3.1",
|
|
58
60
|
"@stacks/stacks-blockchain-api-types": "^7.14.1",
|
|
59
|
-
"@stacks/transactions": "
|
|
61
|
+
"@stacks/transactions": "7.4.0",
|
|
60
62
|
"c32check": "^2.0.0",
|
|
61
63
|
"clarity-abi": "^0.1.0",
|
|
62
64
|
"ts-clarity": "^0.1.1"
|
|
@@ -69,6 +71,11 @@
|
|
|
69
71
|
"start": "dts watch",
|
|
70
72
|
"test": "dts test",
|
|
71
73
|
"sample:counter": "tsx src/sample/counter.ts",
|
|
72
|
-
"sample:read": "tsx src/sample/read.ts"
|
|
74
|
+
"sample:read": "tsx src/sample/read.ts",
|
|
75
|
+
"sample:instant": "tsx src/sample/instant.ts",
|
|
76
|
+
"sample:failure-modes": "tsx src/sample/failure-modes.ts",
|
|
77
|
+
"sample:batch-categories": "tsx src/sample/batch-categories.ts",
|
|
78
|
+
"sample:verify-types": "tsx src/sample/verify-types.ts",
|
|
79
|
+
"sample:vitest": "vitest run src/sample/contract-vitest.test.ts"
|
|
73
80
|
}
|
|
74
81
|
}
|