@stacks/clarinet-sdk 3.26.0 → 4.0.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 +5 -0
- package/dist/cjs/common/src/sdkProxy.d.ts +10 -18
- package/dist/cjs/common/src/sdkProxy.js +14 -15
- package/dist/cjs/common/src/sdkProxy.js.map +1 -1
- package/dist/cjs/common/src/sdkProxyHelpers.d.ts +90 -1
- package/dist/cjs/common/src/sdkProxyHelpers.js +66 -0
- package/dist/cjs/common/src/sdkProxyHelpers.js.map +1 -1
- package/dist/cjs/node/src/index.d.ts +1 -1
- package/dist/cjs/node/src/index.js.map +1 -1
- package/dist/cjs/node/src/syncDebugSimnet.d.ts +3 -3
- package/dist/cjs/node/src/syncDebugSimnet.js +55 -43
- package/dist/cjs/node/src/syncDebugSimnet.js.map +1 -1
- package/dist/esm/common/src/sdkProxy.d.ts +10 -18
- package/dist/esm/common/src/sdkProxy.js +15 -16
- package/dist/esm/common/src/sdkProxy.js.map +1 -1
- package/dist/esm/common/src/sdkProxyHelpers.d.ts +90 -1
- package/dist/esm/common/src/sdkProxyHelpers.js +62 -0
- package/dist/esm/common/src/sdkProxyHelpers.js.map +1 -1
- package/dist/esm/node/src/index.d.ts +1 -1
- package/dist/esm/node/src/index.js.map +1 -1
- package/dist/esm/node/src/syncDebugSimnet.d.ts +3 -3
- package/dist/esm/node/src/syncDebugSimnet.js +57 -45
- package/dist/esm/node/src/syncDebugSimnet.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,11 @@ You can use this SDK to:
|
|
|
14
14
|
- Get contract interfaces (available functions and data)
|
|
15
15
|
- Write unit tests for Clarity smart contracts
|
|
16
16
|
|
|
17
|
+
## Upgrading to 4.0
|
|
18
|
+
|
|
19
|
+
Read the [4.0 migration guide](https://github.com/stx-labs/clarinet/blob/main/components/clarinet-sdk/README.md#migrating-to-40)
|
|
20
|
+
for changed transaction results, mining behavior, and removed APIs.
|
|
21
|
+
|
|
17
22
|
## Installation
|
|
18
23
|
|
|
19
24
|
```sh
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { type CallFn, type CallReadOnlyFn, type DeployContract, type Execute, type GetDataVar, type GetMapEntry, type MineBlock, type TransferSTX } from "./sdkProxyHelpers.js";
|
|
2
|
-
type WasmTransactionRes = {
|
|
3
|
-
result: string;
|
|
4
|
-
events: string;
|
|
5
|
-
costs: string;
|
|
6
|
-
performance?: string;
|
|
7
|
-
};
|
|
1
|
+
import { type SerializedTransactionResult, type SerializedBlockTransactionResult, type BroadcastTransaction, type CallFn, type CallReadOnlyFn, type DeployContract, type Execute, type GetDataVar, type GetMapEntry, type MineBlock, type TransferSTX } from "./sdkProxyHelpers.js";
|
|
8
2
|
type ProxySdk = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
broadcastTransaction(rawHex: string): string;
|
|
4
|
+
callReadOnlyFn(args: unknown): SerializedTransactionResult;
|
|
5
|
+
callPublicFn(args: unknown): SerializedTransactionResult;
|
|
6
|
+
callPrivateFn(args: unknown): SerializedTransactionResult;
|
|
7
|
+
deployContract(args: unknown): SerializedTransactionResult;
|
|
8
|
+
execute(snippet: string): SerializedTransactionResult;
|
|
14
9
|
getDataVar(contract: string, varName: string): string;
|
|
15
10
|
getMapEntry(contract: string, mapName: string, mapKey: Uint8Array): string;
|
|
16
|
-
mineBlock(txs: unknown[]):
|
|
17
|
-
|
|
18
|
-
transferSTX(args: unknown): WasmTransactionRes;
|
|
11
|
+
mineBlock(txs: unknown[]): SerializedBlockTransactionResult[];
|
|
12
|
+
transferSTX(args: unknown): SerializedTransactionResult;
|
|
19
13
|
};
|
|
20
|
-
/** @deprecated use `simnet.execute(command)` instead */
|
|
21
|
-
type RunSnippet<S extends ProxySdk> = S["runSnippet"];
|
|
22
14
|
export type ProxiedSimnet<S extends ProxySdk> = {
|
|
23
|
-
[K in keyof S]: K extends "callReadOnlyFn" ? CallReadOnlyFn : K extends "callPublicFn" | "callPrivateFn" ? CallFn : K extends "execute" ? Execute : K extends "
|
|
15
|
+
[K in keyof S]: K extends "broadcastTransaction" ? BroadcastTransaction : K extends "callReadOnlyFn" ? CallReadOnlyFn : K extends "callPublicFn" | "callPrivateFn" ? CallFn : K extends "execute" ? Execute : K extends "deployContract" ? DeployContract : K extends "transferSTX" ? TransferSTX : K extends "mineBlock" ? MineBlock : K extends "getDataVar" ? GetDataVar : K extends "getMapEntry" ? GetMapEntry : S[K];
|
|
24
16
|
};
|
|
25
17
|
type ProxyBindings<ContractOptions> = {
|
|
26
18
|
CallFnArgs: new (contract: string, method: string, args: Uint8Array[], sender: string, postConditions?: string[], postConditionMode?: string) => unknown;
|
|
@@ -3,14 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createSessionProxy = createSessionProxy;
|
|
4
4
|
const transactions_1 = require("@stacks/transactions");
|
|
5
5
|
const sdkProxyHelpers_js_1 = require("./sdkProxyHelpers.js");
|
|
6
|
-
function parseTxResponse(response) {
|
|
7
|
-
return {
|
|
8
|
-
result: transactions_1.Cl.deserialize(response.result),
|
|
9
|
-
events: (0, sdkProxyHelpers_js_1.parseEvents)(response.events),
|
|
10
|
-
costs: (0, sdkProxyHelpers_js_1.parseCosts)(response.costs),
|
|
11
|
-
performance: response.performance,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
6
|
function createSessionProxy(bindings) {
|
|
15
7
|
const { CallFnArgs, ContractOptions, DeployContractArgs, TransferSTXArgs } = bindings;
|
|
16
8
|
return {
|
|
@@ -20,33 +12,40 @@ function createSessionProxy(bindings) {
|
|
|
20
12
|
const callFn = (contract, method, args, sender, options) => {
|
|
21
13
|
const { postConditions, postConditionMode } = (0, sdkProxyHelpers_js_1.serializePostConditions)(options);
|
|
22
14
|
const response = sdk[prop](new CallFnArgs(contract, method, args.map(transactions_1.serializeCVBytes), sender, postConditions, postConditionMode));
|
|
23
|
-
return
|
|
15
|
+
return (0, sdkProxyHelpers_js_1.parseTransactionResult)(response);
|
|
24
16
|
};
|
|
25
17
|
return callFn;
|
|
26
18
|
}
|
|
19
|
+
if (prop === "broadcastTransaction") {
|
|
20
|
+
const broadcast = (rawHex) => JSON.parse(sdk.broadcastTransaction(rawHex));
|
|
21
|
+
return broadcast;
|
|
22
|
+
}
|
|
27
23
|
if (prop === "execute") {
|
|
28
|
-
const execute = (snippet) =>
|
|
24
|
+
const execute = (snippet) => (0, sdkProxyHelpers_js_1.parseTransactionResult)(sdk.execute(snippet));
|
|
29
25
|
return execute;
|
|
30
26
|
}
|
|
31
27
|
if (prop === "deployContract") {
|
|
32
28
|
const deployContract = (name, content, options, sender, postConditionOptions) => {
|
|
29
|
+
const error = (0, sdkProxyHelpers_js_1.getClarityVersionInputError)(options?.clarityVersion);
|
|
30
|
+
if (error !== undefined)
|
|
31
|
+
throw new Error(error);
|
|
33
32
|
const rustOptions = options
|
|
34
33
|
? new ContractOptions(options.clarityVersion)
|
|
35
34
|
: new ContractOptions();
|
|
36
35
|
const { postConditions, postConditionMode } = (0, sdkProxyHelpers_js_1.serializePostConditions)(postConditionOptions);
|
|
37
|
-
return
|
|
36
|
+
return (0, sdkProxyHelpers_js_1.parseTransactionResult)(sdk.deployContract(new DeployContractArgs(name, content, rustOptions, sender, postConditions, postConditionMode)));
|
|
38
37
|
};
|
|
39
38
|
return deployContract;
|
|
40
39
|
}
|
|
41
40
|
if (prop === "transferSTX") {
|
|
42
41
|
const transferSTX = (amount, recipient, sender, options) => {
|
|
43
42
|
const { postConditions, postConditionMode } = (0, sdkProxyHelpers_js_1.serializePostConditions)(options);
|
|
44
|
-
return
|
|
43
|
+
return (0, sdkProxyHelpers_js_1.parseTransactionResult)(sdk.transferSTX(new TransferSTXArgs(BigInt(amount), recipient, sender, postConditions, postConditionMode)));
|
|
45
44
|
};
|
|
46
45
|
return transferSTX;
|
|
47
46
|
}
|
|
48
47
|
if (prop === "mineBlock") {
|
|
49
|
-
const mineBlock = (txs) => {
|
|
48
|
+
const mineBlock = (txs = []) => (0, sdkProxyHelpers_js_1.mineBlockWithValidatedVersions)(txs, (txs) => {
|
|
50
49
|
const serializedTxs = txs.map((tx) => {
|
|
51
50
|
if (tx.callPublicFn) {
|
|
52
51
|
return {
|
|
@@ -69,8 +68,8 @@ function createSessionProxy(bindings) {
|
|
|
69
68
|
}
|
|
70
69
|
return tx;
|
|
71
70
|
});
|
|
72
|
-
return sdk.mineBlock(serializedTxs).map(
|
|
73
|
-
};
|
|
71
|
+
return sdk.mineBlock(serializedTxs).map(sdkProxyHelpers_js_1.parseBlockTransactionResult);
|
|
72
|
+
});
|
|
74
73
|
return mineBlock;
|
|
75
74
|
}
|
|
76
75
|
if (prop === "getDataVar") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkProxy.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxy.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAE5D,
|
|
1
|
+
{"version":3,"file":"sdkProxy.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxy.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAE5D,6DAiB8B;AAgE9B,4BACE,QAAwC;IAExC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IAEtF,OAAO;QACL,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ;YACzB,MAAM,GAAG,GAAa,OAAO,CAAC;YAE9B,IAAI,IAAI,KAAK,gBAAgB,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,eAAe,EAAE,CAAC;gBACrF,MAAM,MAAM,GAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;oBACjE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,IAAA,4CAAuB,EAAC,OAAO,CAAC,CAAC;oBAC/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CACnB,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,+BAAgB,CAAC;iCACvD;6BACF,CAAC;wBACJ,CAAC;wBACD,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC;4BACtB,OAAO,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC;wBACtD,CAAC;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,CAAC;oBACH,OAAO,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,gDAA2B,CAAC,CAAC;gBACvE,CAAC,CAAC,CAAC;gBACL,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1B,MAAM,UAAU,GAAe,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,iBAAE,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBACpF,OAAO,UAAU,CAAC;YACpB,CAAC;YAED,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC7D,iBAAE,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAA,+BAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/E,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -26,6 +26,22 @@ export type ParsedTransactionResult = {
|
|
|
26
26
|
costs: ClarityCosts | null;
|
|
27
27
|
performance: string | undefined;
|
|
28
28
|
};
|
|
29
|
+
export type RawTransactionMetadata = {
|
|
30
|
+
txid: string;
|
|
31
|
+
fee: bigint;
|
|
32
|
+
nonce: bigint;
|
|
33
|
+
};
|
|
34
|
+
export type BroadcastTransactionResult = {
|
|
35
|
+
txid: string;
|
|
36
|
+
} | {
|
|
37
|
+
error: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
reason_data?: Record<string, unknown>;
|
|
40
|
+
txid?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Submit signed bytes to the mempool without executing or advancing the chain.
|
|
43
|
+
* Call `mineBlock()` to attempt inclusion; admission does not guarantee inclusion. */
|
|
44
|
+
export type BroadcastTransaction = (rawHex: string) => BroadcastTransactionResult;
|
|
29
45
|
/**
|
|
30
46
|
* Post-conditions to enforce on a simnet transaction.
|
|
31
47
|
*
|
|
@@ -48,13 +64,26 @@ export type CallReadOnlyFn = (contract: string, method: string, args: ClarityVal
|
|
|
48
64
|
export type DeployContractOptions = {
|
|
49
65
|
clarityVersion: ClarityVersion;
|
|
50
66
|
};
|
|
67
|
+
/** Deploy using the node's initialization rules. Success returns `(ok true)`,
|
|
68
|
+
* regardless of the initializer's final expression. */
|
|
51
69
|
export type DeployContract = (name: string, content: string, options: DeployContractOptions | null, sender: string, postConditionOptions?: PostConditionOptions) => ParsedTransactionResult;
|
|
70
|
+
/** Execute a native STX transfer. Invalid transfers (self-transfers, zero
|
|
71
|
+
* amounts and insufficient funds) throw without consuming a nonce. In
|
|
72
|
+
* `mineBlock`, they return a rejected outcome without consuming a
|
|
73
|
+
* nonce instead. */
|
|
52
74
|
export type TransferSTX = (amount: number | bigint, recipient: string, sender: string, options?: PostConditionOptions) => ParsedTransactionResult;
|
|
53
75
|
/**
|
|
54
76
|
* A transaction in a `mineBlock` batch. Post-conditions are already encoded,
|
|
55
77
|
* because the batch is handed to Wasm as plain JSON.
|
|
56
78
|
*/
|
|
57
79
|
export type Tx = {
|
|
80
|
+
broadcastTx: string;
|
|
81
|
+
callPublicFn?: never;
|
|
82
|
+
callPrivateFn?: never;
|
|
83
|
+
deployContract?: never;
|
|
84
|
+
transferSTX?: never;
|
|
85
|
+
} | {
|
|
86
|
+
broadcastTx?: never;
|
|
58
87
|
callPublicFn: {
|
|
59
88
|
contract: string;
|
|
60
89
|
method: string;
|
|
@@ -65,6 +94,7 @@ export type Tx = {
|
|
|
65
94
|
deployContract?: never;
|
|
66
95
|
transferSTX?: never;
|
|
67
96
|
} | {
|
|
97
|
+
broadcastTx?: never;
|
|
68
98
|
callPublicFn?: never;
|
|
69
99
|
callPrivateFn: {
|
|
70
100
|
contract: string;
|
|
@@ -75,6 +105,7 @@ export type Tx = {
|
|
|
75
105
|
deployContract?: never;
|
|
76
106
|
transferSTX?: never;
|
|
77
107
|
} | {
|
|
108
|
+
broadcastTx?: never;
|
|
78
109
|
callPublicFn?: never;
|
|
79
110
|
callPrivateFn?: never;
|
|
80
111
|
deployContract: {
|
|
@@ -85,6 +116,7 @@ export type Tx = {
|
|
|
85
116
|
} & SerializedPostConditions;
|
|
86
117
|
transferSTX?: never;
|
|
87
118
|
} | {
|
|
119
|
+
broadcastTx?: never;
|
|
88
120
|
callPublicFn?: never;
|
|
89
121
|
callPrivateFn?: never;
|
|
90
122
|
deployContract?: never;
|
|
@@ -94,6 +126,10 @@ export type Tx = {
|
|
|
94
126
|
sender: string;
|
|
95
127
|
} & SerializedPostConditions;
|
|
96
128
|
};
|
|
129
|
+
/** Check lossless u32 transport; Rust validates which Clarity versions are supported. */
|
|
130
|
+
export declare function getClarityVersionInputError(version: unknown): string | undefined;
|
|
131
|
+
/** Keep invalid versions as per-entry rejections, including when mining queued transactions. */
|
|
132
|
+
export declare function mineBlockWithValidatedVersions(txs: Tx[], mine: (txs: Tx[]) => BlockTransactionResult[]): BlockTransactionResult[];
|
|
97
133
|
export declare const tx: {
|
|
98
134
|
callPublicFn: (contract: string, method: string, args: ClarityValue[], sender: string, options?: PostConditionOptions) => Tx;
|
|
99
135
|
callPrivateFn: (contract: string, method: string, args: ClarityValue[], sender: string, options?: PostConditionOptions) => Tx;
|
|
@@ -102,7 +138,60 @@ export declare const tx: {
|
|
|
102
138
|
};
|
|
103
139
|
export declare function parseEvents(events: string): ClarityEvent[];
|
|
104
140
|
export declare function parseCosts(costs: string): ClarityCosts | null;
|
|
105
|
-
export type
|
|
141
|
+
export type FailureKind = "abort_by_response" | "abort_by_post_condition" | "runtime_error" | "analysis_error";
|
|
142
|
+
/** Signed entries carry their transaction metadata; convenience entries do not. */
|
|
143
|
+
export type MinedTransactionDetails = {
|
|
144
|
+
transaction?: RawTransactionMetadata | null;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* One outcome per selected queued transaction or explicit batch entry; rejected
|
|
148
|
+
* entries do not consume a nonce. Like a node's transaction receipt, an included
|
|
149
|
+
* failure's `execution` reports `(err none)`
|
|
150
|
+
* when execution produced no value, and post-condition aborts report the
|
|
151
|
+
* events they attempted, none of which were committed.
|
|
152
|
+
*/
|
|
153
|
+
export type BlockTransactionResult = MinedTransactionDetails & ({
|
|
154
|
+
status: "success";
|
|
155
|
+
execution: ParsedTransactionResult;
|
|
156
|
+
} | {
|
|
157
|
+
status: "included_failure";
|
|
158
|
+
kind: FailureKind;
|
|
159
|
+
error: string;
|
|
160
|
+
execution: ParsedTransactionResult;
|
|
161
|
+
} | {
|
|
162
|
+
status: "rejected";
|
|
163
|
+
error: string;
|
|
164
|
+
});
|
|
165
|
+
/** Advance one block and mine ready queued transactions, then explicit entries.
|
|
166
|
+
* Queued results precede explicit results, which retain input order. Rejections
|
|
167
|
+
* do not stop later entries; empty or entirely rejected batches still advance. */
|
|
168
|
+
export type MineBlock = (txs?: Array<Tx>) => BlockTransactionResult[];
|
|
169
|
+
export type SerializedTransactionResult = {
|
|
170
|
+
result: string;
|
|
171
|
+
events: string;
|
|
172
|
+
costs: string;
|
|
173
|
+
performance?: string;
|
|
174
|
+
};
|
|
175
|
+
export declare function parseTransactionResult(response: SerializedTransactionResult): ParsedTransactionResult;
|
|
176
|
+
export type SerializedBlockTransactionResult = {
|
|
177
|
+
transaction?: {
|
|
178
|
+
txid: string;
|
|
179
|
+
fee: string;
|
|
180
|
+
nonce: string;
|
|
181
|
+
} | null;
|
|
182
|
+
} & ({
|
|
183
|
+
status: "success";
|
|
184
|
+
execution: SerializedTransactionResult;
|
|
185
|
+
} | {
|
|
186
|
+
status: "included_failure";
|
|
187
|
+
kind: FailureKind;
|
|
188
|
+
error: string;
|
|
189
|
+
execution: SerializedTransactionResult;
|
|
190
|
+
} | {
|
|
191
|
+
status: "rejected";
|
|
192
|
+
error: string;
|
|
193
|
+
});
|
|
194
|
+
export declare function parseBlockTransactionResult(response: SerializedBlockTransactionResult): BlockTransactionResult;
|
|
106
195
|
export type Execute = (snippet: string) => ParsedTransactionResult;
|
|
107
196
|
export type GetDataVar = (contract: string, dataVar: string) => ClarityValue;
|
|
108
197
|
export type GetMapEntry = (contract: string, mapName: string, mapKey: ClarityValue) => ClarityValue;
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tx = void 0;
|
|
4
4
|
exports.serializePostConditions = serializePostConditions;
|
|
5
|
+
exports.getClarityVersionInputError = getClarityVersionInputError;
|
|
6
|
+
exports.mineBlockWithValidatedVersions = mineBlockWithValidatedVersions;
|
|
5
7
|
exports.parseEvents = parseEvents;
|
|
6
8
|
exports.parseCosts = parseCosts;
|
|
9
|
+
exports.parseTransactionResult = parseTransactionResult;
|
|
10
|
+
exports.parseBlockTransactionResult = parseBlockTransactionResult;
|
|
7
11
|
const transactions_1 = require("@stacks/transactions");
|
|
8
12
|
function serializePostConditions(options) {
|
|
9
13
|
const conditions = options?.postConditions;
|
|
@@ -30,6 +34,29 @@ function serializePostConditions(options) {
|
|
|
30
34
|
}),
|
|
31
35
|
};
|
|
32
36
|
}
|
|
37
|
+
/** Check lossless u32 transport; Rust validates which Clarity versions are supported. */
|
|
38
|
+
function getClarityVersionInputError(version) {
|
|
39
|
+
if (version === undefined)
|
|
40
|
+
return;
|
|
41
|
+
if (typeof version !== "number" ||
|
|
42
|
+
!Number.isInteger(version) ||
|
|
43
|
+
version < 0 ||
|
|
44
|
+
version > 0xffffffff) {
|
|
45
|
+
return "Invalid Clarity version: expected an unsigned 32-bit integer";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Keep invalid versions as per-entry rejections, including when mining queued transactions. */
|
|
49
|
+
function mineBlockWithValidatedVersions(txs, mine) {
|
|
50
|
+
const errors = txs.map((entry) => getClarityVersionInputError(entry.deployContract?.options?.clarityVersion));
|
|
51
|
+
const valid = txs.filter((_, index) => errors[index] === undefined);
|
|
52
|
+
const results = mine(valid);
|
|
53
|
+
const queuedCount = results.length - valid.length;
|
|
54
|
+
let index = queuedCount;
|
|
55
|
+
return [
|
|
56
|
+
...results.slice(0, queuedCount),
|
|
57
|
+
...errors.map((error) => error === undefined ? results[index++] : { status: "rejected", error }),
|
|
58
|
+
];
|
|
59
|
+
}
|
|
33
60
|
exports.tx = {
|
|
34
61
|
callPublicFn: (contract, method, args, sender, options) => ({
|
|
35
62
|
callPublicFn: { contract, method, args, sender, ...serializePostConditions(options) },
|
|
@@ -95,4 +122,43 @@ function parseCosts(costs) {
|
|
|
95
122
|
return null;
|
|
96
123
|
}
|
|
97
124
|
}
|
|
125
|
+
function parseTransactionResult(response) {
|
|
126
|
+
return {
|
|
127
|
+
result: transactions_1.Cl.deserialize(response.result),
|
|
128
|
+
events: parseEvents(response.events),
|
|
129
|
+
costs: parseCosts(response.costs),
|
|
130
|
+
performance: response.performance ?? undefined,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function parseBlockTransactionResult(response) {
|
|
134
|
+
const details = {};
|
|
135
|
+
if (response.transaction !== undefined) {
|
|
136
|
+
details.transaction =
|
|
137
|
+
response.transaction === null
|
|
138
|
+
? null
|
|
139
|
+
: {
|
|
140
|
+
txid: response.transaction.txid,
|
|
141
|
+
fee: BigInt(response.transaction.fee),
|
|
142
|
+
nonce: BigInt(response.transaction.nonce),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
switch (response.status) {
|
|
146
|
+
case "rejected":
|
|
147
|
+
return { ...details, status: "rejected", error: response.error };
|
|
148
|
+
case "success":
|
|
149
|
+
return {
|
|
150
|
+
...details,
|
|
151
|
+
status: "success",
|
|
152
|
+
execution: parseTransactionResult(response.execution),
|
|
153
|
+
};
|
|
154
|
+
case "included_failure":
|
|
155
|
+
return {
|
|
156
|
+
...details,
|
|
157
|
+
status: "included_failure",
|
|
158
|
+
kind: response.kind,
|
|
159
|
+
error: response.error,
|
|
160
|
+
execution: parseTransactionResult(response.execution),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
98
164
|
//# sourceMappingURL=sdkProxyHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkProxyHelpers.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxyHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdkProxyHelpers.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxyHelpers.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uDAW8B;AA2D9B,iCAAwC,OAA8B;IACpE,MAAM,UAAU,GAAG,OAAO,EAAE,cAAc,CAAC;IAC3C,MAAM,IAAI,GAAG,OAAO,EAAE,iBAAiB,CAAC;IAExC,8EAA8E;IAC9E,OAAO;QACL,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI;YAC9B,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;gBACpC,IAAI,OAAO,EAAE,KAAK,QAAQ;oBAAE,OAAO,EAAE,CAAC;gBACtC,OAAO,OAAO,EAAE,CAAC,IAAI,KAAK,QAAQ;oBAChC,CAAC,CAAC,IAAA,iCAAkB,EAAC,EAAmB,CAAC;oBACzC,CAAC,CAAC,IAAA,yCAA0B,EAAC,EAAuB,CAAC,CAAC;YAC1D,CAAC,CAAC;SACH,CAAC;QACF,GAAG,CA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
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { tx, type ClarityEvent, type ParsedTransactionResult, type DeployContractOptions, type Tx, type TransferSTX, } from "../../common/src/sdkProxyHelpers.js";
|
|
1
|
+
export { tx, type ClarityEvent, type ParsedTransactionResult, type BlockTransactionResult, type FailureKind, type BroadcastTransactionResult, type RawTransactionMetadata, type BroadcastTransaction, type DeployContractOptions, type Tx, type TransferSTX, } from "../../common/src/sdkProxyHelpers.js";
|
|
2
2
|
import type { SDK } from "@stacks/clarinet-sdk-wasm";
|
|
3
3
|
import { Simnet } from "./sdkProxy.js";
|
|
4
4
|
export { type Simnet } from "./sdkProxy.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0EAY6C;AAX3C,wGAAA,EAAE,OAAA;AAeJ,qCAA+B;AAC/B,+CAAwD;AACxD,6DAAyD;AAEzD,6DAA6D;AAI7D,MAAM,UAAU,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAEvD,0GAA0G;AAC1G,aAAa;AACb,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG;IACxB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC,CAAC;AAQK,KAAK,iBAAiB,OAAiB;IAC5C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC;IAChC,IAAI,UAAU,GAAG,IAAI,MAAM,CAAC,UAAU,CACpC,CAAC,CAAC,OAAO,EAAE,UAAU,EACrB,CAAC,CAAC,OAAO,EAAE,aAAa,EACxB,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAC5B,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,KAAK,CACtB,IAAI,MAAM,CAAC,GAAG,CAAC,YAAG,EAAE,UAAU,CAAC,EAC/B,IAAA,6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MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,6BAA6B;QAC7B,MAAM,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;QAC/E,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,UAAU,GAAG,YAAY,EAAE,CAAC;AAEzC,mDAI0B;AAHxB,kHAAA,gBAAgB,OAAA;AAChB,6GAAA,WAAW,OAAA"}
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
* from the Wasm SDK; coverage and cost reports are not supported.
|
|
9
9
|
*/
|
|
10
10
|
import { type ClarityValue } from "@stacks/transactions";
|
|
11
|
-
import { type ParsedTransactionResult, type Tx } from "../../common/src/sdkProxyHelpers.js";
|
|
11
|
+
import { type BlockTransactionResult, type BroadcastTransactionResult, type ParsedTransactionResult, type Tx } from "../../common/src/sdkProxyHelpers.js";
|
|
12
12
|
export type SyncDebugSimnet = {
|
|
13
13
|
readonly deployer: string;
|
|
14
14
|
readonly blockHeight: number;
|
|
15
15
|
readonly burnBlockHeight: number;
|
|
16
16
|
readonly stacksBlockHeight: number;
|
|
17
17
|
getAccounts(): Map<string, string>;
|
|
18
|
-
|
|
18
|
+
broadcastTransaction(rawHex: string): BroadcastTransactionResult;
|
|
19
|
+
mineBlock(txs?: Tx[]): BlockTransactionResult[];
|
|
19
20
|
mineEmptyBlock(count?: number): number;
|
|
20
21
|
mineEmptyStacksBlock(): number;
|
|
21
22
|
callPublicFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
22
23
|
callReadOnlyFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
23
24
|
callPrivateFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
24
25
|
execute(snippet: string): ParsedTransactionResult;
|
|
25
|
-
runSnippet(snippet: string): string;
|
|
26
26
|
getAssetsMap(): Map<string, Map<string, bigint>>;
|
|
27
27
|
getLastContractCallTrace(): string | undefined;
|
|
28
28
|
setCurrentTestName(name: string): void;
|
|
@@ -79,50 +79,62 @@ function createSyncDebugSimnet() {
|
|
|
79
79
|
// Debug mode does not support coverage/cost reports.
|
|
80
80
|
throw new Error("collectReport: coverage and cost reports are not supported in debug mode");
|
|
81
81
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
82
|
+
broadcastTransaction(rawHex) {
|
|
83
|
+
return send({ method: "broadcastTransaction", rawHex });
|
|
84
|
+
},
|
|
85
|
+
mineBlock(txs = []) {
|
|
86
|
+
return (0, sdkProxyHelpers_js_1.mineBlockWithValidatedVersions)(txs, (txs) => {
|
|
87
|
+
const serialized = txs.map((tx) => {
|
|
88
|
+
if (tx.broadcastTx !== undefined)
|
|
89
|
+
return { type: "broadcastTx", rawHex: tx.broadcastTx };
|
|
90
|
+
if (tx.callPublicFn) {
|
|
91
|
+
return {
|
|
92
|
+
type: "callPublicFn",
|
|
93
|
+
contract: tx.callPublicFn.contract,
|
|
94
|
+
function: tx.callPublicFn.method,
|
|
95
|
+
args: tx.callPublicFn.args.map(transactions_1.serializeCV),
|
|
96
|
+
sender: tx.callPublicFn.sender,
|
|
97
|
+
postConditions: tx.callPublicFn.postConditions,
|
|
98
|
+
postConditionMode: tx.callPublicFn.postConditionMode,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (tx.callPrivateFn) {
|
|
102
|
+
return {
|
|
103
|
+
type: "callPrivateFn",
|
|
104
|
+
contract: tx.callPrivateFn.contract,
|
|
105
|
+
function: tx.callPrivateFn.method,
|
|
106
|
+
args: tx.callPrivateFn.args.map(transactions_1.serializeCV),
|
|
107
|
+
sender: tx.callPrivateFn.sender,
|
|
108
|
+
postConditions: tx.callPrivateFn.postConditions,
|
|
109
|
+
postConditionMode: tx.callPrivateFn.postConditionMode,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (tx.deployContract) {
|
|
113
|
+
return {
|
|
114
|
+
type: "deployContract",
|
|
115
|
+
name: tx.deployContract.name,
|
|
116
|
+
content: tx.deployContract.content,
|
|
117
|
+
sender: tx.deployContract.sender,
|
|
118
|
+
options: tx.deployContract.options,
|
|
119
|
+
postConditions: tx.deployContract.postConditions,
|
|
120
|
+
postConditionMode: tx.deployContract.postConditionMode,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (tx.transferSTX) {
|
|
124
|
+
return {
|
|
125
|
+
type: "transferSTX",
|
|
126
|
+
amount: tx.transferSTX.amount,
|
|
127
|
+
recipient: tx.transferSTX.recipient,
|
|
128
|
+
sender: tx.transferSTX.sender,
|
|
129
|
+
postConditions: tx.transferSTX.postConditions,
|
|
130
|
+
postConditionMode: tx.transferSTX.postConditionMode,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { type: "unknown" };
|
|
134
|
+
});
|
|
135
|
+
const resp = send({ method: "mineBlock", txs: serialized });
|
|
136
|
+
return (resp.results ?? []).map(sdkProxyHelpers_js_1.parseBlockTransactionResult);
|
|
123
137
|
});
|
|
124
|
-
const resp = send({ method: "mineBlock", txs: serialized });
|
|
125
|
-
return (resp.results ?? []).map(parseTxResult);
|
|
126
138
|
},
|
|
127
139
|
callPublicFn(contract, method, args, sender) {
|
|
128
140
|
const resp = send({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDebugSimnet.js","sourceRoot":"","sources":["../../../../src/syncDebugSimnet.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"syncDebugSimnet.js","sourceRoot":"","sources":["../../../../src/syncDebugSimnet.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,uDAA0E;AAC1E,6DAAgD;AAChD,4EAY6C;AAS7C,SAAS,aAAa,CAAC,CAAiB;IACtC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACZ,CAAmC,CAAC,KAAK,IAAI,mCAAmC,CAClF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,iBAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,MAAM,EAAE,IAAA,gCAAW,EAAC,CAAC,CAAC,MAAM,CAAC;QAC7B,KAAK,EAAE,IAAA,+BAAU,EAAC,CAAC,CAAC,KAAK,CAAC;QAC1B,WAAW,EAAE,SAAS;KACvB,CAAC;AACJ,CAAC;AAED,qEAAqE;AACrE,SAAS,IAAI,CAAC,OAAgC;IAC5C,MAAM,GAAG,GAAG,IAAA,6BAAQ,EAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyD,CAAC;IACrF,IAAI,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,+EAA+E;AAC/E,SAAS,SAAS,CAAC,CAAe;IAChC,OAAO,iBAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACzB,CA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IAAI,GAAG,EAA+B,CAAC;YACrD,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;gBACpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;gBACxC,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;oBAClD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/B,CAAC;gBACD,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,wBAAwB;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,KAAK,CAAC,WAAW,CACf,GAAW,EACX,YAAoB,EACpB,OAMC;YAED,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import { type CallFn, type CallReadOnlyFn, type DeployContract, type Execute, type GetDataVar, type GetMapEntry, type MineBlock, type TransferSTX } from "./sdkProxyHelpers.js";
|
|
2
|
-
type WasmTransactionRes = {
|
|
3
|
-
result: string;
|
|
4
|
-
events: string;
|
|
5
|
-
costs: string;
|
|
6
|
-
performance?: string;
|
|
7
|
-
};
|
|
1
|
+
import { type SerializedTransactionResult, type SerializedBlockTransactionResult, type BroadcastTransaction, type CallFn, type CallReadOnlyFn, type DeployContract, type Execute, type GetDataVar, type GetMapEntry, type MineBlock, type TransferSTX } from "./sdkProxyHelpers.js";
|
|
8
2
|
type ProxySdk = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
broadcastTransaction(rawHex: string): string;
|
|
4
|
+
callReadOnlyFn(args: unknown): SerializedTransactionResult;
|
|
5
|
+
callPublicFn(args: unknown): SerializedTransactionResult;
|
|
6
|
+
callPrivateFn(args: unknown): SerializedTransactionResult;
|
|
7
|
+
deployContract(args: unknown): SerializedTransactionResult;
|
|
8
|
+
execute(snippet: string): SerializedTransactionResult;
|
|
14
9
|
getDataVar(contract: string, varName: string): string;
|
|
15
10
|
getMapEntry(contract: string, mapName: string, mapKey: Uint8Array): string;
|
|
16
|
-
mineBlock(txs: unknown[]):
|
|
17
|
-
|
|
18
|
-
transferSTX(args: unknown): WasmTransactionRes;
|
|
11
|
+
mineBlock(txs: unknown[]): SerializedBlockTransactionResult[];
|
|
12
|
+
transferSTX(args: unknown): SerializedTransactionResult;
|
|
19
13
|
};
|
|
20
|
-
/** @deprecated use `simnet.execute(command)` instead */
|
|
21
|
-
type RunSnippet<S extends ProxySdk> = S["runSnippet"];
|
|
22
14
|
export type ProxiedSimnet<S extends ProxySdk> = {
|
|
23
|
-
[K in keyof S]: K extends "callReadOnlyFn" ? CallReadOnlyFn : K extends "callPublicFn" | "callPrivateFn" ? CallFn : K extends "execute" ? Execute : K extends "
|
|
15
|
+
[K in keyof S]: K extends "broadcastTransaction" ? BroadcastTransaction : K extends "callReadOnlyFn" ? CallReadOnlyFn : K extends "callPublicFn" | "callPrivateFn" ? CallFn : K extends "execute" ? Execute : K extends "deployContract" ? DeployContract : K extends "transferSTX" ? TransferSTX : K extends "mineBlock" ? MineBlock : K extends "getDataVar" ? GetDataVar : K extends "getMapEntry" ? GetMapEntry : S[K];
|
|
24
16
|
};
|
|
25
17
|
type ProxyBindings<ContractOptions> = {
|
|
26
18
|
CallFnArgs: new (contract: string, method: string, args: Uint8Array[], sender: string, postConditions?: string[], postConditionMode?: string) => unknown;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Cl, serializeCVBytes } from "@stacks/transactions";
|
|
2
|
-
import {
|
|
3
|
-
function parseTxResponse(response) {
|
|
4
|
-
return {
|
|
5
|
-
result: Cl.deserialize(response.result),
|
|
6
|
-
events: parseEvents(response.events),
|
|
7
|
-
costs: parseCosts(response.costs),
|
|
8
|
-
performance: response.performance,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
2
|
+
import { parseBlockTransactionResult, getClarityVersionInputError, mineBlockWithValidatedVersions, parseTransactionResult, serializePostConditions, } from "./sdkProxyHelpers.js";
|
|
11
3
|
export function createSessionProxy(bindings) {
|
|
12
4
|
const { CallFnArgs, ContractOptions, DeployContractArgs, TransferSTXArgs } = bindings;
|
|
13
5
|
return {
|
|
@@ -17,33 +9,40 @@ export function createSessionProxy(bindings) {
|
|
|
17
9
|
const callFn = (contract, method, args, sender, options) => {
|
|
18
10
|
const { postConditions, postConditionMode } = serializePostConditions(options);
|
|
19
11
|
const response = sdk[prop](new CallFnArgs(contract, method, args.map(serializeCVBytes), sender, postConditions, postConditionMode));
|
|
20
|
-
return
|
|
12
|
+
return parseTransactionResult(response);
|
|
21
13
|
};
|
|
22
14
|
return callFn;
|
|
23
15
|
}
|
|
16
|
+
if (prop === "broadcastTransaction") {
|
|
17
|
+
const broadcast = (rawHex) => JSON.parse(sdk.broadcastTransaction(rawHex));
|
|
18
|
+
return broadcast;
|
|
19
|
+
}
|
|
24
20
|
if (prop === "execute") {
|
|
25
|
-
const execute = (snippet) =>
|
|
21
|
+
const execute = (snippet) => parseTransactionResult(sdk.execute(snippet));
|
|
26
22
|
return execute;
|
|
27
23
|
}
|
|
28
24
|
if (prop === "deployContract") {
|
|
29
25
|
const deployContract = (name, content, options, sender, postConditionOptions) => {
|
|
26
|
+
const error = getClarityVersionInputError(options?.clarityVersion);
|
|
27
|
+
if (error !== undefined)
|
|
28
|
+
throw new Error(error);
|
|
30
29
|
const rustOptions = options
|
|
31
30
|
? new ContractOptions(options.clarityVersion)
|
|
32
31
|
: new ContractOptions();
|
|
33
32
|
const { postConditions, postConditionMode } = serializePostConditions(postConditionOptions);
|
|
34
|
-
return
|
|
33
|
+
return parseTransactionResult(sdk.deployContract(new DeployContractArgs(name, content, rustOptions, sender, postConditions, postConditionMode)));
|
|
35
34
|
};
|
|
36
35
|
return deployContract;
|
|
37
36
|
}
|
|
38
37
|
if (prop === "transferSTX") {
|
|
39
38
|
const transferSTX = (amount, recipient, sender, options) => {
|
|
40
39
|
const { postConditions, postConditionMode } = serializePostConditions(options);
|
|
41
|
-
return
|
|
40
|
+
return parseTransactionResult(sdk.transferSTX(new TransferSTXArgs(BigInt(amount), recipient, sender, postConditions, postConditionMode)));
|
|
42
41
|
};
|
|
43
42
|
return transferSTX;
|
|
44
43
|
}
|
|
45
44
|
if (prop === "mineBlock") {
|
|
46
|
-
const mineBlock = (txs) => {
|
|
45
|
+
const mineBlock = (txs = []) => mineBlockWithValidatedVersions(txs, (txs) => {
|
|
47
46
|
const serializedTxs = txs.map((tx) => {
|
|
48
47
|
if (tx.callPublicFn) {
|
|
49
48
|
return {
|
|
@@ -66,8 +65,8 @@ export function createSessionProxy(bindings) {
|
|
|
66
65
|
}
|
|
67
66
|
return tx;
|
|
68
67
|
});
|
|
69
|
-
return sdk.mineBlock(serializedTxs).map(
|
|
70
|
-
};
|
|
68
|
+
return sdk.mineBlock(serializedTxs).map(parseBlockTransactionResult);
|
|
69
|
+
});
|
|
71
70
|
return mineBlock;
|
|
72
71
|
}
|
|
73
72
|
if (prop === "getDataVar") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkProxy.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"sdkProxy.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,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AAC;YACpB,CAAC;YAED,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;gBAC3B,MAAM,WAAW,GAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC7D,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/E,OAAO,WAAW,CAAC;YACrB,CAAC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -26,6 +26,22 @@ export type ParsedTransactionResult = {
|
|
|
26
26
|
costs: ClarityCosts | null;
|
|
27
27
|
performance: string | undefined;
|
|
28
28
|
};
|
|
29
|
+
export type RawTransactionMetadata = {
|
|
30
|
+
txid: string;
|
|
31
|
+
fee: bigint;
|
|
32
|
+
nonce: bigint;
|
|
33
|
+
};
|
|
34
|
+
export type BroadcastTransactionResult = {
|
|
35
|
+
txid: string;
|
|
36
|
+
} | {
|
|
37
|
+
error: string;
|
|
38
|
+
reason: string;
|
|
39
|
+
reason_data?: Record<string, unknown>;
|
|
40
|
+
txid?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Submit signed bytes to the mempool without executing or advancing the chain.
|
|
43
|
+
* Call `mineBlock()` to attempt inclusion; admission does not guarantee inclusion. */
|
|
44
|
+
export type BroadcastTransaction = (rawHex: string) => BroadcastTransactionResult;
|
|
29
45
|
/**
|
|
30
46
|
* Post-conditions to enforce on a simnet transaction.
|
|
31
47
|
*
|
|
@@ -48,13 +64,26 @@ export type CallReadOnlyFn = (contract: string, method: string, args: ClarityVal
|
|
|
48
64
|
export type DeployContractOptions = {
|
|
49
65
|
clarityVersion: ClarityVersion;
|
|
50
66
|
};
|
|
67
|
+
/** Deploy using the node's initialization rules. Success returns `(ok true)`,
|
|
68
|
+
* regardless of the initializer's final expression. */
|
|
51
69
|
export type DeployContract = (name: string, content: string, options: DeployContractOptions | null, sender: string, postConditionOptions?: PostConditionOptions) => ParsedTransactionResult;
|
|
70
|
+
/** Execute a native STX transfer. Invalid transfers (self-transfers, zero
|
|
71
|
+
* amounts and insufficient funds) throw without consuming a nonce. In
|
|
72
|
+
* `mineBlock`, they return a rejected outcome without consuming a
|
|
73
|
+
* nonce instead. */
|
|
52
74
|
export type TransferSTX = (amount: number | bigint, recipient: string, sender: string, options?: PostConditionOptions) => ParsedTransactionResult;
|
|
53
75
|
/**
|
|
54
76
|
* A transaction in a `mineBlock` batch. Post-conditions are already encoded,
|
|
55
77
|
* because the batch is handed to Wasm as plain JSON.
|
|
56
78
|
*/
|
|
57
79
|
export type Tx = {
|
|
80
|
+
broadcastTx: string;
|
|
81
|
+
callPublicFn?: never;
|
|
82
|
+
callPrivateFn?: never;
|
|
83
|
+
deployContract?: never;
|
|
84
|
+
transferSTX?: never;
|
|
85
|
+
} | {
|
|
86
|
+
broadcastTx?: never;
|
|
58
87
|
callPublicFn: {
|
|
59
88
|
contract: string;
|
|
60
89
|
method: string;
|
|
@@ -65,6 +94,7 @@ export type Tx = {
|
|
|
65
94
|
deployContract?: never;
|
|
66
95
|
transferSTX?: never;
|
|
67
96
|
} | {
|
|
97
|
+
broadcastTx?: never;
|
|
68
98
|
callPublicFn?: never;
|
|
69
99
|
callPrivateFn: {
|
|
70
100
|
contract: string;
|
|
@@ -75,6 +105,7 @@ export type Tx = {
|
|
|
75
105
|
deployContract?: never;
|
|
76
106
|
transferSTX?: never;
|
|
77
107
|
} | {
|
|
108
|
+
broadcastTx?: never;
|
|
78
109
|
callPublicFn?: never;
|
|
79
110
|
callPrivateFn?: never;
|
|
80
111
|
deployContract: {
|
|
@@ -85,6 +116,7 @@ export type Tx = {
|
|
|
85
116
|
} & SerializedPostConditions;
|
|
86
117
|
transferSTX?: never;
|
|
87
118
|
} | {
|
|
119
|
+
broadcastTx?: never;
|
|
88
120
|
callPublicFn?: never;
|
|
89
121
|
callPrivateFn?: never;
|
|
90
122
|
deployContract?: never;
|
|
@@ -94,6 +126,10 @@ export type Tx = {
|
|
|
94
126
|
sender: string;
|
|
95
127
|
} & SerializedPostConditions;
|
|
96
128
|
};
|
|
129
|
+
/** Check lossless u32 transport; Rust validates which Clarity versions are supported. */
|
|
130
|
+
export declare function getClarityVersionInputError(version: unknown): string | undefined;
|
|
131
|
+
/** Keep invalid versions as per-entry rejections, including when mining queued transactions. */
|
|
132
|
+
export declare function mineBlockWithValidatedVersions(txs: Tx[], mine: (txs: Tx[]) => BlockTransactionResult[]): BlockTransactionResult[];
|
|
97
133
|
export declare const tx: {
|
|
98
134
|
callPublicFn: (contract: string, method: string, args: ClarityValue[], sender: string, options?: PostConditionOptions) => Tx;
|
|
99
135
|
callPrivateFn: (contract: string, method: string, args: ClarityValue[], sender: string, options?: PostConditionOptions) => Tx;
|
|
@@ -102,7 +138,60 @@ export declare const tx: {
|
|
|
102
138
|
};
|
|
103
139
|
export declare function parseEvents(events: string): ClarityEvent[];
|
|
104
140
|
export declare function parseCosts(costs: string): ClarityCosts | null;
|
|
105
|
-
export type
|
|
141
|
+
export type FailureKind = "abort_by_response" | "abort_by_post_condition" | "runtime_error" | "analysis_error";
|
|
142
|
+
/** Signed entries carry their transaction metadata; convenience entries do not. */
|
|
143
|
+
export type MinedTransactionDetails = {
|
|
144
|
+
transaction?: RawTransactionMetadata | null;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* One outcome per selected queued transaction or explicit batch entry; rejected
|
|
148
|
+
* entries do not consume a nonce. Like a node's transaction receipt, an included
|
|
149
|
+
* failure's `execution` reports `(err none)`
|
|
150
|
+
* when execution produced no value, and post-condition aborts report the
|
|
151
|
+
* events they attempted, none of which were committed.
|
|
152
|
+
*/
|
|
153
|
+
export type BlockTransactionResult = MinedTransactionDetails & ({
|
|
154
|
+
status: "success";
|
|
155
|
+
execution: ParsedTransactionResult;
|
|
156
|
+
} | {
|
|
157
|
+
status: "included_failure";
|
|
158
|
+
kind: FailureKind;
|
|
159
|
+
error: string;
|
|
160
|
+
execution: ParsedTransactionResult;
|
|
161
|
+
} | {
|
|
162
|
+
status: "rejected";
|
|
163
|
+
error: string;
|
|
164
|
+
});
|
|
165
|
+
/** Advance one block and mine ready queued transactions, then explicit entries.
|
|
166
|
+
* Queued results precede explicit results, which retain input order. Rejections
|
|
167
|
+
* do not stop later entries; empty or entirely rejected batches still advance. */
|
|
168
|
+
export type MineBlock = (txs?: Array<Tx>) => BlockTransactionResult[];
|
|
169
|
+
export type SerializedTransactionResult = {
|
|
170
|
+
result: string;
|
|
171
|
+
events: string;
|
|
172
|
+
costs: string;
|
|
173
|
+
performance?: string;
|
|
174
|
+
};
|
|
175
|
+
export declare function parseTransactionResult(response: SerializedTransactionResult): ParsedTransactionResult;
|
|
176
|
+
export type SerializedBlockTransactionResult = {
|
|
177
|
+
transaction?: {
|
|
178
|
+
txid: string;
|
|
179
|
+
fee: string;
|
|
180
|
+
nonce: string;
|
|
181
|
+
} | null;
|
|
182
|
+
} & ({
|
|
183
|
+
status: "success";
|
|
184
|
+
execution: SerializedTransactionResult;
|
|
185
|
+
} | {
|
|
186
|
+
status: "included_failure";
|
|
187
|
+
kind: FailureKind;
|
|
188
|
+
error: string;
|
|
189
|
+
execution: SerializedTransactionResult;
|
|
190
|
+
} | {
|
|
191
|
+
status: "rejected";
|
|
192
|
+
error: string;
|
|
193
|
+
});
|
|
194
|
+
export declare function parseBlockTransactionResult(response: SerializedBlockTransactionResult): BlockTransactionResult;
|
|
106
195
|
export type Execute = (snippet: string) => ParsedTransactionResult;
|
|
107
196
|
export type GetDataVar = (contract: string, dataVar: string) => ClarityValue;
|
|
108
197
|
export type GetMapEntry = (contract: string, mapName: string, mapKey: ClarityValue) => ClarityValue;
|
|
@@ -24,6 +24,29 @@ export function serializePostConditions(options) {
|
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
/** Check lossless u32 transport; Rust validates which Clarity versions are supported. */
|
|
28
|
+
export function getClarityVersionInputError(version) {
|
|
29
|
+
if (version === undefined)
|
|
30
|
+
return;
|
|
31
|
+
if (typeof version !== "number" ||
|
|
32
|
+
!Number.isInteger(version) ||
|
|
33
|
+
version < 0 ||
|
|
34
|
+
version > 0xffffffff) {
|
|
35
|
+
return "Invalid Clarity version: expected an unsigned 32-bit integer";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Keep invalid versions as per-entry rejections, including when mining queued transactions. */
|
|
39
|
+
export function mineBlockWithValidatedVersions(txs, mine) {
|
|
40
|
+
const errors = txs.map((entry) => getClarityVersionInputError(entry.deployContract?.options?.clarityVersion));
|
|
41
|
+
const valid = txs.filter((_, index) => errors[index] === undefined);
|
|
42
|
+
const results = mine(valid);
|
|
43
|
+
const queuedCount = results.length - valid.length;
|
|
44
|
+
let index = queuedCount;
|
|
45
|
+
return [
|
|
46
|
+
...results.slice(0, queuedCount),
|
|
47
|
+
...errors.map((error) => error === undefined ? results[index++] : { status: "rejected", error }),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
27
50
|
export const tx = {
|
|
28
51
|
callPublicFn: (contract, method, args, sender, options) => ({
|
|
29
52
|
callPublicFn: { contract, method, args, sender, ...serializePostConditions(options) },
|
|
@@ -89,4 +112,43 @@ export function parseCosts(costs) {
|
|
|
89
112
|
return null;
|
|
90
113
|
}
|
|
91
114
|
}
|
|
115
|
+
export function parseTransactionResult(response) {
|
|
116
|
+
return {
|
|
117
|
+
result: Cl.deserialize(response.result),
|
|
118
|
+
events: parseEvents(response.events),
|
|
119
|
+
costs: parseCosts(response.costs),
|
|
120
|
+
performance: response.performance ?? undefined,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export function parseBlockTransactionResult(response) {
|
|
124
|
+
const details = {};
|
|
125
|
+
if (response.transaction !== undefined) {
|
|
126
|
+
details.transaction =
|
|
127
|
+
response.transaction === null
|
|
128
|
+
? null
|
|
129
|
+
: {
|
|
130
|
+
txid: response.transaction.txid,
|
|
131
|
+
fee: BigInt(response.transaction.fee),
|
|
132
|
+
nonce: BigInt(response.transaction.nonce),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
switch (response.status) {
|
|
136
|
+
case "rejected":
|
|
137
|
+
return { ...details, status: "rejected", error: response.error };
|
|
138
|
+
case "success":
|
|
139
|
+
return {
|
|
140
|
+
...details,
|
|
141
|
+
status: "success",
|
|
142
|
+
execution: parseTransactionResult(response.execution),
|
|
143
|
+
};
|
|
144
|
+
case "included_failure":
|
|
145
|
+
return {
|
|
146
|
+
...details,
|
|
147
|
+
status: "included_failure",
|
|
148
|
+
kind: response.kind,
|
|
149
|
+
error: response.error,
|
|
150
|
+
execution: parseTransactionResult(response.execution),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
92
154
|
//# sourceMappingURL=sdkProxyHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkProxyHelpers.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxyHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EAKF,iBAAiB,EAGjB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdkProxyHelpers.js","sourceRoot":"","sources":["../../../../../common/src/sdkProxyHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EAKF,iBAAiB,EAGjB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AA2D9B,MAAM,UAAU,uBAAuB,CAAC,OAA8B;IACpE,MAAM,UAAU,GAAG,OAAO,EAAE,cAAc,CAAC;IAC3C,MAAM,IAAI,GAAG,OAAO,EAAE,iBAAiB,CAAC;IAExC,8EAA8E;IAC9E,OAAO;QACL,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI;YAC9B,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,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AAC;QACnE,KAAK,SAAS;YACZ,OAAO;gBACL,GAAG,OAAO;gBACV,MAAM,EAAE,SAAS;gBACjB,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC;aACtD,CAAC;QACJ,KAAK,kBAAkB;YACrB,OAAO;gBACL,GAAG,OAAO;gBACV,MAAM,EAAE,kBAAkB;gBAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC;aACtD,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { tx, type ClarityEvent, type ParsedTransactionResult, type DeployContractOptions, type Tx, type TransferSTX, } from "../../common/src/sdkProxyHelpers.js";
|
|
1
|
+
export { tx, type ClarityEvent, type ParsedTransactionResult, type BlockTransactionResult, type FailureKind, type BroadcastTransactionResult, type RawTransactionMetadata, type BroadcastTransaction, type DeployContractOptions, type Tx, type TransferSTX, } from "../../common/src/sdkProxyHelpers.js";
|
|
2
2
|
import type { SDK } from "@stacks/clarinet-sdk-wasm";
|
|
3
3
|
import { Simnet } from "./sdkProxy.js";
|
|
4
4
|
export { type Simnet } from "./sdkProxy.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,GAWH,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAU,eAAe,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,M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AAE;QACF,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAClD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YAC5C,CAAC,CAAC,SAAS,CAAC;QAEd,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,4DAA4D;YAC5D,MAAM,iBAAiB,CAAC,SAAS,CAAC,CAAC;YACnC,IAAI,CAAC,WAAW,IAAI,OAAO,EAAE,CAAC;gBAC5B,WAAW,GAAG,qBAAqB,EAAE,CAAC;YACxC,CAAC;YACD,+EAA+E;YAC/E,MAAM,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;YACpE,OAAO,WAAgC,CAAC;QAC1C,CAAC;QAED,IAAI,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,6BAA6B;QAC7B,MAAM,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;QAC/E,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,EAAE,CAAC;AAEzC,OAAO,EACL,gBAAgB,EAChB,WAAW,GAEZ,MAAM,kBAAkB,CAAC"}
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
* from the Wasm SDK; coverage and cost reports are not supported.
|
|
9
9
|
*/
|
|
10
10
|
import { type ClarityValue } from "@stacks/transactions";
|
|
11
|
-
import { type ParsedTransactionResult, type Tx } from "../../common/src/sdkProxyHelpers.js";
|
|
11
|
+
import { type BlockTransactionResult, type BroadcastTransactionResult, type ParsedTransactionResult, type Tx } from "../../common/src/sdkProxyHelpers.js";
|
|
12
12
|
export type SyncDebugSimnet = {
|
|
13
13
|
readonly deployer: string;
|
|
14
14
|
readonly blockHeight: number;
|
|
15
15
|
readonly burnBlockHeight: number;
|
|
16
16
|
readonly stacksBlockHeight: number;
|
|
17
17
|
getAccounts(): Map<string, string>;
|
|
18
|
-
|
|
18
|
+
broadcastTransaction(rawHex: string): BroadcastTransactionResult;
|
|
19
|
+
mineBlock(txs?: Tx[]): BlockTransactionResult[];
|
|
19
20
|
mineEmptyBlock(count?: number): number;
|
|
20
21
|
mineEmptyStacksBlock(): number;
|
|
21
22
|
callPublicFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
22
23
|
callReadOnlyFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
23
24
|
callPrivateFn(contract: string, method: string, args: ClarityValue[], sender: string): ParsedTransactionResult;
|
|
24
25
|
execute(snippet: string): ParsedTransactionResult;
|
|
25
|
-
runSnippet(snippet: string): string;
|
|
26
26
|
getAssetsMap(): Map<string, Map<string, bigint>>;
|
|
27
27
|
getLastContractCallTrace(): string | undefined;
|
|
28
28
|
setCurrentTestName(name: string): void;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* breakpoints in .clar files. API coverage and transaction behavior differ
|
|
8
8
|
* from the Wasm SDK; coverage and cost reports are not supported.
|
|
9
9
|
*/
|
|
10
|
-
import { Cl } from "@stacks/transactions";
|
|
10
|
+
import { Cl, serializeCV } from "@stacks/transactions";
|
|
11
11
|
import { syncSend } from "./syncDebugSocket.js";
|
|
12
|
-
import { parseEvents, parseCosts, } from "../../common/src/sdkProxyHelpers.js";
|
|
12
|
+
import { parseEvents, mineBlockWithValidatedVersions, parseBlockTransactionResult, parseCosts, } from "../../common/src/sdkProxyHelpers.js";
|
|
13
13
|
function parseTxResult(r) {
|
|
14
14
|
if (!r.result) {
|
|
15
15
|
throw new Error(r.error ?? "transaction failed with no result");
|
|
@@ -76,50 +76,62 @@ export function createSyncDebugSimnet() {
|
|
|
76
76
|
// Debug mode does not support coverage/cost reports.
|
|
77
77
|
throw new Error("collectReport: coverage and cost reports are not supported in debug mode");
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
79
|
+
broadcastTransaction(rawHex) {
|
|
80
|
+
return send({ method: "broadcastTransaction", rawHex });
|
|
81
|
+
},
|
|
82
|
+
mineBlock(txs = []) {
|
|
83
|
+
return mineBlockWithValidatedVersions(txs, (txs) => {
|
|
84
|
+
const serialized = txs.map((tx) => {
|
|
85
|
+
if (tx.broadcastTx !== undefined)
|
|
86
|
+
return { type: "broadcastTx", rawHex: tx.broadcastTx };
|
|
87
|
+
if (tx.callPublicFn) {
|
|
88
|
+
return {
|
|
89
|
+
type: "callPublicFn",
|
|
90
|
+
contract: tx.callPublicFn.contract,
|
|
91
|
+
function: tx.callPublicFn.method,
|
|
92
|
+
args: tx.callPublicFn.args.map(serializeCV),
|
|
93
|
+
sender: tx.callPublicFn.sender,
|
|
94
|
+
postConditions: tx.callPublicFn.postConditions,
|
|
95
|
+
postConditionMode: tx.callPublicFn.postConditionMode,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (tx.callPrivateFn) {
|
|
99
|
+
return {
|
|
100
|
+
type: "callPrivateFn",
|
|
101
|
+
contract: tx.callPrivateFn.contract,
|
|
102
|
+
function: tx.callPrivateFn.method,
|
|
103
|
+
args: tx.callPrivateFn.args.map(serializeCV),
|
|
104
|
+
sender: tx.callPrivateFn.sender,
|
|
105
|
+
postConditions: tx.callPrivateFn.postConditions,
|
|
106
|
+
postConditionMode: tx.callPrivateFn.postConditionMode,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (tx.deployContract) {
|
|
110
|
+
return {
|
|
111
|
+
type: "deployContract",
|
|
112
|
+
name: tx.deployContract.name,
|
|
113
|
+
content: tx.deployContract.content,
|
|
114
|
+
sender: tx.deployContract.sender,
|
|
115
|
+
options: tx.deployContract.options,
|
|
116
|
+
postConditions: tx.deployContract.postConditions,
|
|
117
|
+
postConditionMode: tx.deployContract.postConditionMode,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (tx.transferSTX) {
|
|
121
|
+
return {
|
|
122
|
+
type: "transferSTX",
|
|
123
|
+
amount: tx.transferSTX.amount,
|
|
124
|
+
recipient: tx.transferSTX.recipient,
|
|
125
|
+
sender: tx.transferSTX.sender,
|
|
126
|
+
postConditions: tx.transferSTX.postConditions,
|
|
127
|
+
postConditionMode: tx.transferSTX.postConditionMode,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return { type: "unknown" };
|
|
131
|
+
});
|
|
132
|
+
const resp = send({ method: "mineBlock", txs: serialized });
|
|
133
|
+
return (resp.results ?? []).map(parseBlockTransactionResult);
|
|
120
134
|
});
|
|
121
|
-
const resp = send({ method: "mineBlock", txs: serialized });
|
|
122
|
-
return (resp.results ?? []).map(parseTxResult);
|
|
123
135
|
},
|
|
124
136
|
callPublicFn(contract, method, args, sender) {
|
|
125
137
|
const resp = send({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDebugSimnet.js","sourceRoot":"","sources":["../../../../src/syncDebugSimnet.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH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AAC;YACrD,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;gBACpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;gBACxC,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;oBAClD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/B,CAAC;gBACD,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,wBAAwB;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,KAAK,CAAC,WAAW,CACf,GAAW,EACX,YAAoB,EACpB,OAMC;YAED,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/clarinet-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Stacks Labs",
|
|
5
5
|
"description": "A SDK to interact with Clarity Smart Contracts in node.js",
|
|
6
6
|
"homepage": "https://stackslabs.com/clarinet",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"license": "GPL-3.0",
|
|
46
46
|
"readme": "./README.md",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@stacks/clarinet-sdk-wasm": "
|
|
48
|
+
"@stacks/clarinet-sdk-wasm": "4.0.0",
|
|
49
49
|
"@stacks/transactions": "7.6.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|