stxer 0.7.0 → 0.9.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/CHANGELOG.md +141 -0
- package/README.md +237 -56
- package/dist/ast.d.ts +1 -1
- package/dist/bitcoin.d.ts +121 -0
- package/dist/index.d.ts +2 -0
- package/dist/simulation-api.d.ts +52 -3
- package/dist/simulation.d.ts +70 -3
- package/dist/stxer.cjs.development.js +906 -101
- 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 +887 -104
- package/dist/stxer.esm.js.map +1 -1
- package/dist/transaction.d.ts +71 -0
- package/dist/types.d.ts +247 -25
- package/package.json +26 -23
- package/src/ast.ts +1 -1
- package/src/bitcoin.ts +391 -0
- package/src/index.ts +2 -0
- package/src/simulation-api.ts +109 -12
- package/src/simulation.ts +247 -46
- package/src/transaction.ts +141 -0
- package/src/types.ts +256 -27
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction-building helpers for the simulator.
|
|
3
|
+
*
|
|
4
|
+
* The simulator does NOT verify signatures — it derives `tx-sender`
|
|
5
|
+
* from the `signer` field (= hash160 of the public key) plus the
|
|
6
|
+
* `hashMode` byte. By overriding those two fields on an *unsigned*
|
|
7
|
+
* transaction, you can simulate any sender without a private key.
|
|
8
|
+
*
|
|
9
|
+
* {@link setSender} performs the override; {@link buildUnsignedContractCallHex}
|
|
10
|
+
* combines the unsigned-tx builder from `@stacks/transactions` with
|
|
11
|
+
* `setSender` and returns a hex string ready to drop into a
|
|
12
|
+
* `{ Transaction: <hex> }` simulation step.
|
|
13
|
+
*/
|
|
14
|
+
import { type StacksNetworkName } from '@stacks/network';
|
|
15
|
+
import { type ClarityValue, PostConditionMode, type StacksTransactionWire } from '@stacks/transactions';
|
|
16
|
+
/**
|
|
17
|
+
* Override the spending condition's `signer` (and `hashMode`) so the
|
|
18
|
+
* simulator treats `tx-sender` as `sender`.
|
|
19
|
+
*
|
|
20
|
+
* Single-sig and multi-sig flavours are both handled — the multi-sig
|
|
21
|
+
* spending condition is rebuilt with empty signature fields because
|
|
22
|
+
* the simulator never validates signatures.
|
|
23
|
+
*/
|
|
24
|
+
export declare function setSender(tx: StacksTransactionWire, sender: string): StacksTransactionWire;
|
|
25
|
+
export interface ContractCallTxArgs {
|
|
26
|
+
/** Principal to set as `tx-sender`. */
|
|
27
|
+
sender: string;
|
|
28
|
+
/** Fully-qualified contract id, e.g. `"SP1G48….dia-oracle"`. */
|
|
29
|
+
contract: string;
|
|
30
|
+
functionName: string;
|
|
31
|
+
functionArgs: ClarityValue[];
|
|
32
|
+
/** microSTX. Defaults to 1_000. */
|
|
33
|
+
fee?: number;
|
|
34
|
+
/** Nonce to declare. Caller is responsible for sequencing. */
|
|
35
|
+
nonce: number;
|
|
36
|
+
network?: StacksNetworkName;
|
|
37
|
+
/**
|
|
38
|
+
* Post-condition mode. Defaults to `Allow` so the simulator runs
|
|
39
|
+
* the call regardless of asset movements; switch to `Deny` + an
|
|
40
|
+
* explicit list when a test wants to assert post-condition
|
|
41
|
+
* enforcement.
|
|
42
|
+
*/
|
|
43
|
+
postConditionMode?: PostConditionMode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Build an unsigned contract-call transaction with `sender` patched
|
|
47
|
+
* in via {@link setSender}, then return the serialized hex (no `0x`
|
|
48
|
+
* prefix). Drop the result directly into `{ Transaction: <hex> }`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { Cl } from '@stacks/transactions';
|
|
53
|
+
* import { buildUnsignedContractCallHex } from 'stxer';
|
|
54
|
+
*
|
|
55
|
+
* const txHex = await buildUnsignedContractCallHex({
|
|
56
|
+
* sender: 'SP3573...',
|
|
57
|
+
* contract: 'SM3VDXK...sbtc-deposit',
|
|
58
|
+
* functionName: 'complete-deposit-wrapper',
|
|
59
|
+
* functionArgs: [Cl.bufferFromHex(txid), Cl.uint(0), Cl.uint(amount), ...],
|
|
60
|
+
* nonce: 5,
|
|
61
|
+
* });
|
|
62
|
+
* await submitSimulationSteps(sim, { steps: [{ Transaction: txHex }] });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildUnsignedContractCallHex(args: ContractCallTxArgs): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Build a `Cl.contractPrincipal` from a `"SP….name"` id string.
|
|
68
|
+
* Trips on standard principals or malformed ids — those should use
|
|
69
|
+
* `Cl.principal` directly.
|
|
70
|
+
*/
|
|
71
|
+
export declare function ftPrincipal(contractId: string): ClarityValue;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,25 +2,40 @@
|
|
|
2
2
|
* Type definitions for stxer-api V2 endpoints
|
|
3
3
|
* Hand-written types based on OpenAPI spec at https://api.stxer.xyz/openapi.json
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Rust `u64` / `u128` fields serialize as JSON numbers but can exceed JS
|
|
7
|
+
* `Number.MAX_SAFE_INTEGER` (2^53 - 1). Accept either form: numbers are
|
|
8
|
+
* convenient for small values, decimal strings preserve full precision
|
|
9
|
+
* for large ones. Mirrors how `pox_addrs[k].payout` (u128) is typed.
|
|
10
|
+
*
|
|
11
|
+
* In practice nearly all values fit in `Number` — this typing exists so
|
|
12
|
+
* code that *might* see a large value (post-genesis cumulative cost
|
|
13
|
+
* counters, accumulated stx_burned in long simulations) cannot silently
|
|
14
|
+
* lose precision. Use `BigInt(x)` to normalize before arithmetic when in
|
|
15
|
+
* doubt.
|
|
16
|
+
*/
|
|
17
|
+
export type U64 = number | string;
|
|
18
|
+
/** Rust `u128`. See {@link U64} for usage notes. */
|
|
19
|
+
export type U128 = number | string;
|
|
5
20
|
export interface TenureCost {
|
|
6
|
-
read_count:
|
|
7
|
-
read_length:
|
|
8
|
-
write_count:
|
|
9
|
-
write_length:
|
|
10
|
-
runtime:
|
|
21
|
+
read_count: U64;
|
|
22
|
+
read_length: U64;
|
|
23
|
+
write_count: U64;
|
|
24
|
+
write_length: U64;
|
|
25
|
+
runtime: U64;
|
|
11
26
|
}
|
|
12
27
|
export interface SidecarTip {
|
|
13
28
|
bitcoin_height: number;
|
|
14
29
|
block_hash: string;
|
|
15
|
-
block_height:
|
|
16
|
-
block_time:
|
|
30
|
+
block_height: U64;
|
|
31
|
+
block_time: U64;
|
|
17
32
|
burn_block_height: number;
|
|
18
|
-
burn_block_time:
|
|
33
|
+
burn_block_time: U64;
|
|
19
34
|
consensus_hash: string;
|
|
20
35
|
index_block_hash: string;
|
|
21
36
|
is_nakamoto: boolean;
|
|
22
37
|
tenure_cost: TenureCost;
|
|
23
|
-
tenure_height:
|
|
38
|
+
tenure_height: U64;
|
|
24
39
|
sortition_id: string;
|
|
25
40
|
epoch_id: string;
|
|
26
41
|
}
|
|
@@ -93,8 +108,27 @@ export interface ClarityAbiNonFungibleToken {
|
|
|
93
108
|
name: string;
|
|
94
109
|
type: ClarityAbiType;
|
|
95
110
|
}
|
|
96
|
-
export type ClarityEpoch = 'Epoch10' | 'Epoch20' | 'Epoch2_05' | 'Epoch21' | 'Epoch22' | 'Epoch23' | 'Epoch24' | 'Epoch25' | 'Epoch30' | 'Epoch31' | 'Epoch32' | 'Epoch33' | 'Epoch34' | 'Epoch35';
|
|
97
|
-
|
|
111
|
+
export type ClarityEpoch = 'Epoch10' | 'Epoch20' | 'Epoch2_05' | 'Epoch21' | 'Epoch22' | 'Epoch23' | 'Epoch24' | 'Epoch25' | 'Epoch30' | 'Epoch31' | 'Epoch32' | 'Epoch33' | 'Epoch34' | 'Epoch35' | 'Epoch40';
|
|
112
|
+
/**
|
|
113
|
+
* Wire-format Clarity version name as emitted by the stxer AST parser
|
|
114
|
+
* (`/contracts:parse-ast`). Used in {@link ClarityAbi.clarity_version}.
|
|
115
|
+
*
|
|
116
|
+
* **Distinct from the numeric `ClarityVersion` enum re-exported by
|
|
117
|
+
* `@stacks/transactions`** (1..6), which is what the SDK builder
|
|
118
|
+
* methods (`addContractDeploy`, `makeUnsignedContractDeploy`, etc.)
|
|
119
|
+
* accept. To build transactions:
|
|
120
|
+
*
|
|
121
|
+
* import { ClarityVersion } from '@stacks/transactions';
|
|
122
|
+
* // ClarityVersion.Clarity5 -> 5
|
|
123
|
+
*
|
|
124
|
+
* To check an AST response:
|
|
125
|
+
*
|
|
126
|
+
* import type { ClarityVersionName } from 'stxer';
|
|
127
|
+
* if (abi.clarity_version === 'Clarity5') { ... }
|
|
128
|
+
*/
|
|
129
|
+
export type ClarityVersionName = 'Clarity1' | 'Clarity2' | 'Clarity3' | 'Clarity4' | 'Clarity5' | 'Clarity6';
|
|
130
|
+
/** @deprecated Renamed to {@link ClarityVersionName} in 0.8.0 to avoid collision with `@stacks/transactions`'s numeric `ClarityVersion` enum. Re-exported for back-compat — will be removed in a future major. */
|
|
131
|
+
export type ClarityVersion = ClarityVersionName;
|
|
98
132
|
export interface ClarityAbi {
|
|
99
133
|
functions: ClarityAbiFunction[];
|
|
100
134
|
variables: ClarityAbiVariable[];
|
|
@@ -102,7 +136,7 @@ export interface ClarityAbi {
|
|
|
102
136
|
fungible_tokens: ClarityAbiFungibleToken[];
|
|
103
137
|
non_fungible_tokens: ClarityAbiNonFungibleToken[];
|
|
104
138
|
epoch: ClarityEpoch;
|
|
105
|
-
clarity_version:
|
|
139
|
+
clarity_version: ClarityVersionName;
|
|
106
140
|
}
|
|
107
141
|
export interface SymbolicExpressionField {
|
|
108
142
|
field: string;
|
|
@@ -157,11 +191,11 @@ export interface ContractAST {
|
|
|
157
191
|
abi?: ClarityAbi;
|
|
158
192
|
}
|
|
159
193
|
export interface ExecutionCost {
|
|
160
|
-
read_count:
|
|
161
|
-
read_length:
|
|
162
|
-
write_count:
|
|
163
|
-
write_length:
|
|
164
|
-
runtime:
|
|
194
|
+
read_count: U64;
|
|
195
|
+
read_length: U64;
|
|
196
|
+
write_count: U64;
|
|
197
|
+
write_length: U64;
|
|
198
|
+
runtime: U64;
|
|
165
199
|
}
|
|
166
200
|
/**
|
|
167
201
|
* Receipt for a transaction that the engine executed to completion.
|
|
@@ -192,7 +226,11 @@ export interface TransactionReceipt {
|
|
|
192
226
|
* `Err`.
|
|
193
227
|
*/
|
|
194
228
|
result: string;
|
|
195
|
-
|
|
229
|
+
/**
|
|
230
|
+
* STX (in micro-STX) burned by this transaction. u128 — accept as
|
|
231
|
+
* `number | string` to preserve precision above 2^53.
|
|
232
|
+
*/
|
|
233
|
+
stx_burned: U128;
|
|
196
234
|
tx_index: number;
|
|
197
235
|
/**
|
|
198
236
|
* Error message from the upstream Clarity VM. `null` when the tx had
|
|
@@ -370,6 +408,31 @@ export interface MapEntryStep {
|
|
|
370
408
|
export interface DataVarStep {
|
|
371
409
|
DataVar: [contract_id: string, variable_name: string];
|
|
372
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Evaluate an arbitrary read-only Clarity expression in the context of
|
|
413
|
+
* `sender` (and optional `sponsor`). The Clarity analyzer rejects any
|
|
414
|
+
* expression that would mutate state, so this is a pure projection.
|
|
415
|
+
*
|
|
416
|
+
* Use when a plain `DataVar` / `MapEntry` read isn't enough — read-only
|
|
417
|
+
* `contract-call?` projections, custom expressions, or anything that
|
|
418
|
+
* needs a specific sender principal in scope. Cheaper than `Eval` (no
|
|
419
|
+
* write access, no step slot) and the only sender-context read shape.
|
|
420
|
+
*
|
|
421
|
+
* Choosing between read variants:
|
|
422
|
+
* - `DataVar` / `MapEntry` — direct storage reads, no Clarity
|
|
423
|
+
* evaluation; cheapest.
|
|
424
|
+
* - `EvalReadonly` — arbitrary read-only Clarity in sender/sponsor
|
|
425
|
+
* context; analyzer-enforced no writes.
|
|
426
|
+
* - `Eval` (top-level step variant on {@link SimulationStepInput},
|
|
427
|
+
* NOT a Reads sub-type) — arbitrary Clarity with **write access**.
|
|
428
|
+
* Use only when you need to mutate state.
|
|
429
|
+
* - `Transaction` — real Stacks tx with receipt, events,
|
|
430
|
+
* post-conditions, fee, nonce.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* { EvalReadonly: ['SP...sender', '', 'SP...contract', '(get-counter)'] }
|
|
434
|
+
* { EvalReadonly: ['SP...sender', '', 'SP...oracle', "(contract-call? .oracle get-value 'STX-USD)"] }
|
|
435
|
+
*/
|
|
373
436
|
export interface EvalReadonlyStep {
|
|
374
437
|
/** `sponsor` is `""` (empty string) when there is no sponsor. */
|
|
375
438
|
EvalReadonly: [
|
|
@@ -406,10 +469,90 @@ export interface ReadErrResult {
|
|
|
406
469
|
Err: string;
|
|
407
470
|
}
|
|
408
471
|
export type ReadResult = ReadOkResult | ReadErrResult;
|
|
472
|
+
/**
|
|
473
|
+
* Tenure-extend cause. `Extended` resets all cost dimensions; the
|
|
474
|
+
* SIP-034 variants reset a single dimension only.
|
|
475
|
+
*/
|
|
476
|
+
export type TenureExtendCause = 'Extended' | 'ExtendedRuntime' | 'ExtendedReadCount' | 'ExtendedReadLength' | 'ExtendedWriteCount' | 'ExtendedWriteLength';
|
|
477
|
+
/** PoX address used inside `AdvanceBlocksRequest.pox_addrs`. */
|
|
478
|
+
export interface PoxAddrInput {
|
|
479
|
+
/** Address version byte (0..255). */
|
|
480
|
+
version: number;
|
|
481
|
+
/** Address hashbytes as hex (no `0x` prefix). */
|
|
482
|
+
hashbytes: string;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Request payload for the `AdvanceBlocks` step variant. Synthesizes
|
|
486
|
+
* bitcoin and stacks blocks on top of the simulation's pinned parent
|
|
487
|
+
* tip. Hex strings for 32-byte hashes / VRF seeds; PoX address
|
|
488
|
+
* overrides use the tuple form `[addrs, payout_ustx]` on the wire.
|
|
489
|
+
*/
|
|
490
|
+
export interface AdvanceBlocksRequest {
|
|
491
|
+
bitcoin_blocks: number;
|
|
492
|
+
stacks_blocks_per_bitcoin: number;
|
|
493
|
+
/** Defaults to 600 (mainnet target) upstream when omitted. */
|
|
494
|
+
bitcoin_interval_secs?: U64;
|
|
495
|
+
/**
|
|
496
|
+
* Per-burn-index burn-header-hash overrides, keyed by 0-based burn
|
|
497
|
+
* index within this batch. Hex strings (32 bytes, with or without
|
|
498
|
+
* `0x` prefix).
|
|
499
|
+
*/
|
|
500
|
+
burn_header_hashes?: Record<string, string>;
|
|
501
|
+
/**
|
|
502
|
+
* Per-burn-index PoX address overrides as `[addrs, payout_ustx]`.
|
|
503
|
+
* `payout_ustx` is `u128` upstream — see {@link U128}.
|
|
504
|
+
*/
|
|
505
|
+
pox_addrs?: Record<string, [PoxAddrInput[], U128]>;
|
|
506
|
+
/** Per-burn-index VRF-seed overrides as 32-byte hex strings. */
|
|
507
|
+
vrf_seeds?: Record<string, string>;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* One synthesized block produced by an `AdvanceBlocks` step. Returned
|
|
511
|
+
* inside `SimulationStepResult.AdvanceBlocks.Ok` and as the `tip`
|
|
512
|
+
* fields when synthetic.
|
|
513
|
+
*/
|
|
514
|
+
export interface AdvancedBlockSummary {
|
|
515
|
+
stacks_height: U64;
|
|
516
|
+
burn_height: number;
|
|
517
|
+
coinbase_height: number;
|
|
518
|
+
index_block_hash: string;
|
|
519
|
+
burn_header_hash: string;
|
|
520
|
+
vrf_seed: string;
|
|
521
|
+
block_time: U64;
|
|
522
|
+
burn_block_time: U64;
|
|
523
|
+
/**
|
|
524
|
+
* `true` when this synthetic block is the first stacks block in a
|
|
525
|
+
* new tenure (i.e. follows a synthesized bitcoin block).
|
|
526
|
+
*/
|
|
527
|
+
tenure_change: boolean;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Response shape for `GET /devtools/v2/simulations/{id}/tip`. When
|
|
531
|
+
* `synthetic` is `false`, fields mirror the parent metadata pinned at
|
|
532
|
+
* session start; `vrf_seed` and `tenure_change` are omitted in that
|
|
533
|
+
* case.
|
|
534
|
+
*/
|
|
535
|
+
export interface SimulationTipResponse {
|
|
536
|
+
synthetic: boolean;
|
|
537
|
+
stacks_height: U64;
|
|
538
|
+
burn_height: number;
|
|
539
|
+
coinbase_height: number;
|
|
540
|
+
block_time: U64;
|
|
541
|
+
burn_block_time: U64;
|
|
542
|
+
index_block_hash: string;
|
|
543
|
+
consensus_hash: string;
|
|
544
|
+
burn_header_hash: string;
|
|
545
|
+
sortition_id: string;
|
|
546
|
+
epoch: string;
|
|
547
|
+
/** Only present when `synthetic` is `true`. */
|
|
548
|
+
vrf_seed?: string;
|
|
549
|
+
/** Only present when `synthetic` is `true`. */
|
|
550
|
+
tenure_change?: boolean;
|
|
551
|
+
}
|
|
409
552
|
/**
|
|
410
553
|
* Per-step result returned by `POST /devtools/v2/simulations/{id}` (the
|
|
411
|
-
* "submit steps" endpoint).
|
|
412
|
-
*
|
|
554
|
+
* "submit steps" endpoint). Externally tagged — exactly one variant key
|
|
555
|
+
* is present per object.
|
|
413
556
|
*
|
|
414
557
|
* Distinct from `SimulationStepSummary`, which is what
|
|
415
558
|
* `GET /devtools/v2/simulations/{id}` returns and includes the original
|
|
@@ -433,6 +576,12 @@ export type SimulationStepResult = {
|
|
|
433
576
|
Reads: ReadResult[];
|
|
434
577
|
} | {
|
|
435
578
|
TenureExtend: ExecutionCost;
|
|
579
|
+
} | {
|
|
580
|
+
AdvanceBlocks: {
|
|
581
|
+
Ok: AdvancedBlockSummary[];
|
|
582
|
+
} | {
|
|
583
|
+
Err: string;
|
|
584
|
+
};
|
|
436
585
|
};
|
|
437
586
|
export interface TransactionStepSummary {
|
|
438
587
|
/** Transaction serialized to hex. */
|
|
@@ -471,14 +620,50 @@ export interface EvalStepSummary {
|
|
|
471
620
|
};
|
|
472
621
|
};
|
|
473
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Echoed `AdvanceBlocks` input as serialized in the summary response.
|
|
625
|
+
* Differs from the request shape ({@link AdvanceBlocksRequest}) in two
|
|
626
|
+
* places: `bitcoin_interval_secs` is nullable (serde `Option`); each
|
|
627
|
+
* `pox_addrs` value is the `{addrs, payout}` object form (vs. the
|
|
628
|
+
* request's tuple form).
|
|
629
|
+
*/
|
|
630
|
+
export interface AdvanceBlocksStepEcho {
|
|
631
|
+
bitcoin_blocks: number;
|
|
632
|
+
stacks_blocks_per_bitcoin: number;
|
|
633
|
+
bitcoin_interval_secs: U64 | null;
|
|
634
|
+
burn_header_hashes: Record<string, string>;
|
|
635
|
+
pox_addrs: Record<string, {
|
|
636
|
+
addrs: PoxAddrInput[];
|
|
637
|
+
payout: U128;
|
|
638
|
+
}>;
|
|
639
|
+
vrf_seeds: Record<string, string>;
|
|
640
|
+
}
|
|
474
641
|
export interface TenureExtendStepSummary {
|
|
642
|
+
/**
|
|
643
|
+
* Echoed input shape. The server normalizes legacy `{TenureExtend: []}`
|
|
644
|
+
* inputs to `{cause: 'Extended'}` at parse time, so the summary always
|
|
645
|
+
* carries the modern form regardless of how the step was submitted.
|
|
646
|
+
*/
|
|
647
|
+
TenureExtend: {
|
|
648
|
+
cause: TenureExtendCause;
|
|
649
|
+
};
|
|
475
650
|
Result: {
|
|
476
651
|
TenureExtend: ExecutionCost;
|
|
477
652
|
};
|
|
478
653
|
}
|
|
479
|
-
export
|
|
654
|
+
export interface AdvanceBlocksStepSummary {
|
|
655
|
+
AdvanceBlocks: AdvanceBlocksStepEcho;
|
|
656
|
+
Result: {
|
|
657
|
+
AdvanceBlocks: {
|
|
658
|
+
Ok: AdvancedBlockSummary[];
|
|
659
|
+
} | {
|
|
660
|
+
Err: string;
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
export type SimulationStepSummary = TransactionStepSummary | ReadsStepSummary | SetContractCodeStepSummary | EvalStepSummary | TenureExtendStepSummary | AdvanceBlocksStepSummary;
|
|
480
665
|
export interface SimulationMetadata {
|
|
481
|
-
block_height:
|
|
666
|
+
block_height: U64;
|
|
482
667
|
block_hash: string;
|
|
483
668
|
burn_block_height: number;
|
|
484
669
|
burn_block_hash: string;
|
|
@@ -493,13 +678,46 @@ export interface SimulationResult {
|
|
|
493
678
|
steps: SimulationStepSummary[];
|
|
494
679
|
}
|
|
495
680
|
export interface CreateSimulationRequest {
|
|
496
|
-
block_height?:
|
|
681
|
+
block_height?: U64;
|
|
497
682
|
block_hash?: string;
|
|
498
683
|
skip_tracing?: boolean;
|
|
499
684
|
}
|
|
500
685
|
export interface CreateSimulationResponse {
|
|
501
686
|
id: string;
|
|
502
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* One step submitted to `POST /devtools/v2/simulations/{id}`. Tagged
|
|
690
|
+
* union — exactly one variant key per object.
|
|
691
|
+
*
|
|
692
|
+
* **Picking the right Clarity-execution shape** — `Transaction` /
|
|
693
|
+
* `Eval` / `Reads` differ on side-effects, cost, and what they emit:
|
|
694
|
+
*
|
|
695
|
+
* - `Transaction` — full Stacks tx mechanics. Generates a
|
|
696
|
+
* `TransactionReceipt` (events, vm_error, post_condition_aborted,
|
|
697
|
+
* execution_cost), consumes nonce, charges fee, enforces
|
|
698
|
+
* post-conditions. The only variant that emits a receipt. Use when
|
|
699
|
+
* simulating a real user action.
|
|
700
|
+
* - `Eval` — arbitrary Clarity with **write access** to contract
|
|
701
|
+
* storage; no fee, no nonce, no post-conditions, no receipt — just
|
|
702
|
+
* the resulting Clarity value or err. Use to stub state mid-session
|
|
703
|
+
* (`var-set`, `map-set`, …) or run code with side-effects without
|
|
704
|
+
* tx ceremony.
|
|
705
|
+
* - `Reads` (batch of {@link ReadStep}, including `EvalReadonly`) —
|
|
706
|
+
* pure projection, no state changes, cheapest. Use when you only
|
|
707
|
+
* need to read derived data; `EvalReadonly` provides the
|
|
708
|
+
* sender/sponsor context that `DataVar` / `MapEntry` cannot.
|
|
709
|
+
*
|
|
710
|
+
* `SetContractCode` replaces a contract's code (write side-effects, no
|
|
711
|
+
* fee/nonce/receipt — like `Eval` but at the contract level).
|
|
712
|
+
* `TenureExtend` resets cost dimensions. `AdvanceBlocks` synthesizes
|
|
713
|
+
* burn/stacks blocks (see {@link AdvanceBlocksRequest}).
|
|
714
|
+
*
|
|
715
|
+
* `TenureExtend` accepts both legacy `[]` (treated server-side as
|
|
716
|
+
* `cause: 'Extended'`) and modern `{ cause }` shapes. SDK 0.8.0 emits
|
|
717
|
+
* the modern form via {@link SimulationBuilder.addTenureExtend}; the
|
|
718
|
+
* legacy shape stays in this union so consumers passing literal step
|
|
719
|
+
* objects (not via the builder) still type-check.
|
|
720
|
+
*/
|
|
503
721
|
export type SimulationStepInput = {
|
|
504
722
|
Transaction: string;
|
|
505
723
|
} | {
|
|
@@ -519,7 +737,11 @@ export type SimulationStepInput = {
|
|
|
519
737
|
} | {
|
|
520
738
|
Reads: ReadStep[];
|
|
521
739
|
} | {
|
|
522
|
-
TenureExtend: []
|
|
740
|
+
TenureExtend: [] | {
|
|
741
|
+
cause: TenureExtendCause;
|
|
742
|
+
};
|
|
743
|
+
} | {
|
|
744
|
+
AdvanceBlocks: AdvanceBlocksRequest;
|
|
523
745
|
};
|
|
524
746
|
export interface SubmitSimulationStepsRequest {
|
|
525
747
|
steps: SimulationStepInput[];
|
|
@@ -586,7 +808,7 @@ export interface SimulationBatchReadsResponse {
|
|
|
586
808
|
export interface InstantSimulationRequest {
|
|
587
809
|
/** Transaction serialized to hex. */
|
|
588
810
|
transaction: string;
|
|
589
|
-
block_height?:
|
|
811
|
+
block_height?: U64;
|
|
590
812
|
block_hash?: string;
|
|
591
813
|
reads?: ReadStep[];
|
|
592
814
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stxer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Kyle Fang",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,25 @@
|
|
|
14
14
|
"dist",
|
|
15
15
|
"src",
|
|
16
16
|
"!src/sample",
|
|
17
|
-
"!dist/sample"
|
|
17
|
+
"!dist/sample",
|
|
18
|
+
"CHANGELOG.md"
|
|
18
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"analyze": "size-limit --why",
|
|
22
|
+
"build": "dts build",
|
|
23
|
+
"lint": "biome check .",
|
|
24
|
+
"prepare": "dts build",
|
|
25
|
+
"size": "size-limit",
|
|
26
|
+
"start": "dts watch",
|
|
27
|
+
"test": "dts test",
|
|
28
|
+
"sample:counter": "tsx src/sample/counter.ts",
|
|
29
|
+
"sample:read": "tsx src/sample/read.ts",
|
|
30
|
+
"sample:instant": "tsx src/sample/instant.ts",
|
|
31
|
+
"sample:failure-modes": "tsx src/sample/failure-modes.ts",
|
|
32
|
+
"sample:batch-categories": "tsx src/sample/batch-categories.ts",
|
|
33
|
+
"sample:verify-types": "tsx src/sample/verify-types.ts",
|
|
34
|
+
"sample:vitest": "vitest run"
|
|
35
|
+
},
|
|
19
36
|
"husky": {
|
|
20
37
|
"hooks": {
|
|
21
38
|
"pre-commit": "dts lint && biome check ."
|
|
@@ -44,38 +61,24 @@
|
|
|
44
61
|
}
|
|
45
62
|
],
|
|
46
63
|
"devDependencies": {
|
|
47
|
-
"@biomejs/biome": "2.
|
|
64
|
+
"@biomejs/biome": "2.5.5",
|
|
48
65
|
"@size-limit/preset-small-lib": "12.1.0",
|
|
49
66
|
"@tsconfig/recommended": "^1.0.13",
|
|
50
67
|
"@types/node": "25.6.0",
|
|
51
68
|
"dts-cli": "^2.0.5",
|
|
52
69
|
"husky": "^9.1.7",
|
|
53
70
|
"size-limit": "12.1.0",
|
|
54
|
-
"tsx": "^4.
|
|
71
|
+
"tsx": "^4.23.1",
|
|
55
72
|
"typescript": "5.9.3",
|
|
56
|
-
"vitest": "^4.1.
|
|
73
|
+
"vitest": "^4.1.10"
|
|
57
74
|
},
|
|
58
75
|
"dependencies": {
|
|
59
|
-
"@
|
|
76
|
+
"@noble/hashes": "^2.2.0",
|
|
77
|
+
"@stacks/network": "^7.5.0",
|
|
60
78
|
"@stacks/stacks-blockchain-api-types": "^7.14.1",
|
|
61
|
-
"@stacks/transactions": "7.
|
|
79
|
+
"@stacks/transactions": "7.5.0",
|
|
62
80
|
"c32check": "^2.0.0",
|
|
63
81
|
"clarity-abi": "^0.1.0",
|
|
64
82
|
"ts-clarity": "^0.1.1"
|
|
65
|
-
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"analyze": "size-limit --why",
|
|
68
|
-
"build": "dts build",
|
|
69
|
-
"lint": "biome check .",
|
|
70
|
-
"size": "size-limit",
|
|
71
|
-
"start": "dts watch",
|
|
72
|
-
"test": "dts test",
|
|
73
|
-
"sample:counter": "tsx src/sample/counter.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"
|
|
80
83
|
}
|
|
81
|
-
}
|
|
84
|
+
}
|
package/src/ast.ts
CHANGED
|
@@ -50,7 +50,7 @@ export async function getContractAST(
|
|
|
50
50
|
export interface ParseContractOptions extends AstOptions {
|
|
51
51
|
sourceCode: string;
|
|
52
52
|
contractId: string;
|
|
53
|
-
clarityVersion?: '1' | '2' | '3' | '4';
|
|
53
|
+
clarityVersion?: '1' | '2' | '3' | '4' | '5' | '6';
|
|
54
54
|
epoch?: ClarityEpoch;
|
|
55
55
|
}
|
|
56
56
|
|