@stacks/clarinet-sdk-wasm-browser 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Clarity SDK WASM
2
+
3
+ This component exposes Clarinet features to a JS interface through wasm-bindgen. It's built with
4
+ wasm-pack.
5
+ It powers [@stacks/clarinet-sdk](https://npmjs.com/package/@stacks/clarinet-sdk) and
6
+ [@stacks/clarinet-sdk-browser](https://npmjs.com/package/@stacks/clarinet-sdk-browser).
7
+
8
+ ## Contributing
9
+
10
+ ### Build package
11
+
12
+ Install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/).
13
+
14
+ In the root directory of Clarinet, run the following command to build the packages for Node.js and
15
+ the browser. Under the hood, it will run `wasm-pack build` twice, once for each target.
16
+
17
+ ```sh
18
+ npm run build:sdk-wasm
19
+ ```
20
+
21
+ Alternatively, it's also possible to build the packages separately. It should only be done for
22
+ development purpose.
23
+
24
+ **Build for node**
25
+
26
+ ```sh
27
+ wasm-pack build --release --scope stacks --out-dir pkg-node --target nodejs
28
+ ```
29
+
30
+ **Build for the browser**
31
+
32
+ ```sh
33
+ wasm-pack build --release --scope stacks --out-dir pkg-browser --target web
34
+ ```
35
+
36
+ ### Release
37
+
38
+ The package is built twice with `wasm-pack` as it can't target `node` and `web` at the same time.
39
+ The following script will build for both target, it will also rename the package name for the
40
+ browser build.
41
+
42
+ ```sh
43
+ npm run build:sdk-wasm
44
+ ```
45
+
46
+ Once built, the packages can be released by running the following command. Note that by default we
47
+ release with the beta tag.
48
+
49
+ ```sh
50
+ npm run publish:sdk-wasm
51
+ ```
@@ -0,0 +1,340 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export type EpochString =
4
+ | "2.0"
5
+ | "2.05"
6
+ | "2.1"
7
+ | "2.2"
8
+ | "2.3"
9
+ | "2.4"
10
+ | "2.5"
11
+ | "3.0"
12
+ | "3.1"
13
+ | "3.2"
14
+ | "3.3";
15
+
16
+
17
+ type Atom = {
18
+ Atom: String;
19
+ };
20
+
21
+ type AtomValue = {
22
+ AtomValue: any;
23
+ };
24
+
25
+ type List = {
26
+ List: Expression[];
27
+ };
28
+
29
+ type LiteralValue = {
30
+ LiteralValue: any;
31
+ };
32
+
33
+ type Field = {
34
+ Field: any;
35
+ };
36
+
37
+ type TraitReference = {
38
+ TraitReference: any;
39
+ };
40
+
41
+ type ExpressionType = Atom | AtomValue | List | LiteralValue | Field | TraitReference;
42
+
43
+ type Span = {
44
+ start_line: number;
45
+ start_column: number;
46
+ end_line: number;
47
+ end_column: number;
48
+ };
49
+
50
+ type Expression = {
51
+ expr: ExpressionType;
52
+ id: number;
53
+ span: Span;
54
+ };
55
+
56
+ type IContractAST = {
57
+ contract_identifier: any;
58
+ pre_expressions: any[];
59
+ expressions: Expression[];
60
+ top_level_expression_sorting: number[];
61
+ referenced_traits: Map<any, any>;
62
+ implemented_traits: any[];
63
+ };
64
+
65
+ type ContractInterfaceFunctionAccess = "private" | "public" | "read_only";
66
+
67
+ type ContractInterfaceTupleEntryType = { name: string; type: ContractInterfaceAtomType };
68
+
69
+ type ContractInterfaceAtomType =
70
+ | "none"
71
+ | "int128"
72
+ | "uint128"
73
+ | "bool"
74
+ | "principal"
75
+ | { buffer: { length: number } }
76
+ | { "string-utf8": { length: number } }
77
+ | { "string-ascii": { length: number } }
78
+ | { tuple: ContractInterfaceTupleEntryType[] }
79
+ | { optional: ContractInterfaceAtomType }
80
+ | { response: { ok: ContractInterfaceAtomType; error: ContractInterfaceAtomType } }
81
+ | { list: { type: ContractInterfaceAtomType; length: number } }
82
+ | "trait_reference";
83
+
84
+ type ContractInterfaceFunctionArg = { name: string; type: ContractInterfaceAtomType };
85
+
86
+ type ContractInterfaceFunctionOutput = { type: ContractInterfaceAtomType };
87
+
88
+ type ContractInterfaceFunction = {
89
+ name: string;
90
+ access: ContractInterfaceFunctionAccess;
91
+ args: ContractInterfaceFunctionArg[];
92
+ outputs: ContractInterfaceFunctionOutput;
93
+ };
94
+
95
+ type ContractInterfaceVariableAccess = "constant" | "variable";
96
+
97
+ type ContractInterfaceVariable = {
98
+ name: string;
99
+ type: ContractInterfaceAtomType;
100
+ access: ContractInterfaceVariableAccess;
101
+ };
102
+
103
+ type ContractInterfaceMap = {
104
+ name: string;
105
+ key: ContractInterfaceAtomType;
106
+ value: ContractInterfaceAtomType;
107
+ };
108
+
109
+ type ContractInterfaceFungibleTokens = { name: string };
110
+
111
+ type ContractInterfaceNonFungibleTokens = { name: string; type: ContractInterfaceAtomType };
112
+
113
+ export type StacksEpochId =
114
+ | "Epoch10"
115
+ | "Epoch20"
116
+ | "Epoch2_05"
117
+ | "Epoch21"
118
+ | "Epoch22"
119
+ | "Epoch23"
120
+ | "Epoch24"
121
+ | "Epoch25"
122
+ | "Epoch30"
123
+ | "Epoch31"
124
+ | "Epoch32"
125
+ | "Epoch33";
126
+
127
+ export type ClarityVersionString = "Clarity1" | "Clarity2" | "Clarity3"| "Clarity4";
128
+
129
+ export type IContractInterface = {
130
+ functions: ContractInterfaceFunction[];
131
+ variables: ContractInterfaceVariable[];
132
+ maps: ContractInterfaceMap[];
133
+ fungible_tokens: ContractInterfaceFungibleTokens[];
134
+ non_fungible_tokens: ContractInterfaceNonFungibleTokens[];
135
+ epoch: StacksEpochId;
136
+ clarity_version: ClarityVersionString;
137
+ };
138
+
139
+ export class CallFnArgs {
140
+ free(): void;
141
+ constructor(contract: string, method: string, args: Uint8Array[], sender: string);
142
+ }
143
+ export class ContractOptions {
144
+ free(): void;
145
+ constructor(clarity_version?: number | null);
146
+ }
147
+ export class DeployContractArgs {
148
+ free(): void;
149
+ constructor(name: string, content: string, options: ContractOptions, sender: string);
150
+ }
151
+ export class SDK {
152
+ free(): void;
153
+ constructor(fs_request: Function, options?: SDKOptions | null);
154
+ static getDefaultEpoch(): EpochString;
155
+ getDefaultClarityVersionForCurrentEpoch(): ClarityVersionString;
156
+ initEmptySession(remote_data_settings: any): Promise<void>;
157
+ initSession(cwd: string, manifest_path: string): Promise<void>;
158
+ clearCache(): void;
159
+ setEpoch(epoch: EpochString): void;
160
+ getContractsInterfaces(): Map<string, IContractInterface>;
161
+ getContractSource(contract: string): string | undefined;
162
+ getContractAST(contract: string): IContractAST;
163
+ getAssetsMap(): Map<string, Map<string, bigint>>;
164
+ getAccounts(): Map<string, string>;
165
+ getDataVar(contract: string, var_name: string): string;
166
+ getBlockTime(): bigint;
167
+ getMapEntry(contract: string, map_name: string, map_key: Uint8Array): string;
168
+ callReadOnlyFn(args: CallFnArgs): TransactionRes;
169
+ deployContract(args: DeployContractArgs): TransactionRes;
170
+ transferSTX(args: TransferSTXArgs): TransactionRes;
171
+ callPublicFn(args: CallFnArgs): TransactionRes;
172
+ callPrivateFn(args: CallFnArgs): TransactionRes;
173
+ mineBlock(js_txs: Array<any>): any;
174
+ mineEmptyBlock(): number;
175
+ mineEmptyBlocks(count?: number | null): number;
176
+ mineEmptyStacksBlock(): number;
177
+ mineEmptyStacksBlocks(count?: number | null): number;
178
+ mineEmptyBurnBlock(): number;
179
+ mineEmptyBurnBlocks(count?: number | null): number;
180
+ runSnippet(snippet: string): string;
181
+ execute(snippet: string): TransactionRes;
182
+ executeCommand(snippet: string): string;
183
+ /**
184
+ * Returns the last contract call trace as a string, if available.
185
+ */
186
+ getLastContractCallTrace(): string | undefined;
187
+ setLocalAccounts(addresses: string[]): void;
188
+ mintSTX(recipient: string, amount: bigint): string;
189
+ setCurrentTestName(test_name: string): void;
190
+ collectReport(include_boot_contracts: boolean, boot_contracts_path: string): SessionReport;
191
+ enablePerformance(cost_field: string): void;
192
+ deployer: string;
193
+ readonly blockHeight: number;
194
+ readonly stacksBlockHeight: number;
195
+ readonly burnBlockHeight: number;
196
+ readonly currentEpoch: string;
197
+ }
198
+ export class SDKOptions {
199
+ free(): void;
200
+ constructor(track_costs: boolean, track_coverage: boolean, track_performance?: boolean | null);
201
+ trackCosts: boolean;
202
+ trackCoverage: boolean;
203
+ trackPerformance: boolean;
204
+ }
205
+ export class SessionReport {
206
+ private constructor();
207
+ free(): void;
208
+ coverage: string;
209
+ costs: string;
210
+ }
211
+ export class TransactionRes {
212
+ private constructor();
213
+ free(): void;
214
+ result: string;
215
+ events: string;
216
+ costs: string;
217
+ get performance(): string | undefined;
218
+ set performance(value: string | null | undefined);
219
+ }
220
+ export class TransferSTXArgs {
221
+ free(): void;
222
+ constructor(amount: bigint, recipient: string, sender: string);
223
+ }
224
+ export class TxArgs {
225
+ private constructor();
226
+ free(): void;
227
+ }
228
+
229
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
230
+
231
+ export interface InitOutput {
232
+ readonly memory: WebAssembly.Memory;
233
+ readonly __wbg_callfnargs_free: (a: number, b: number) => void;
234
+ readonly callfnargs_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
235
+ readonly __wbg_contractoptions_free: (a: number, b: number) => void;
236
+ readonly contractoptions_new: (a: number) => number;
237
+ readonly __wbg_deploycontractargs_free: (a: number, b: number) => void;
238
+ readonly deploycontractargs_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
239
+ readonly __wbg_transferstxargs_free: (a: number, b: number) => void;
240
+ readonly transferstxargs_new: (a: bigint, b: number, c: number, d: number, e: number) => number;
241
+ readonly __wbg_txargs_free: (a: number, b: number) => void;
242
+ readonly __wbg_transactionres_free: (a: number, b: number) => void;
243
+ readonly __wbg_get_transactionres_result: (a: number) => [number, number];
244
+ readonly __wbg_get_transactionres_events: (a: number) => [number, number];
245
+ readonly __wbg_get_transactionres_costs: (a: number) => [number, number];
246
+ readonly __wbg_set_transactionres_costs: (a: number, b: number, c: number) => void;
247
+ readonly __wbg_get_transactionres_performance: (a: number) => [number, number];
248
+ readonly __wbg_set_transactionres_performance: (a: number, b: number, c: number) => void;
249
+ readonly __wbg_sessionreport_free: (a: number, b: number) => void;
250
+ readonly __wbg_get_sessionreport_coverage: (a: number) => [number, number];
251
+ readonly __wbg_set_sessionreport_coverage: (a: number, b: number, c: number) => void;
252
+ readonly __wbg_get_sessionreport_costs: (a: number) => [number, number];
253
+ readonly __wbg_set_sessionreport_costs: (a: number, b: number, c: number) => void;
254
+ readonly __wbg_sdkoptions_free: (a: number, b: number) => void;
255
+ readonly __wbg_get_sdkoptions_trackCosts: (a: number) => number;
256
+ readonly __wbg_set_sdkoptions_trackCosts: (a: number, b: number) => void;
257
+ readonly __wbg_get_sdkoptions_trackCoverage: (a: number) => number;
258
+ readonly __wbg_set_sdkoptions_trackCoverage: (a: number, b: number) => void;
259
+ readonly __wbg_get_sdkoptions_trackPerformance: (a: number) => number;
260
+ readonly __wbg_set_sdkoptions_trackPerformance: (a: number, b: number) => void;
261
+ readonly sdkoptions_new: (a: number, b: number, c: number) => number;
262
+ readonly __wbg_sdk_free: (a: number, b: number) => void;
263
+ readonly __wbg_get_sdk_deployer: (a: number) => [number, number];
264
+ readonly __wbg_set_sdk_deployer: (a: number, b: number, c: number) => void;
265
+ readonly sdk_new: (a: any, b: number) => number;
266
+ readonly sdk_getDefaultEpoch: () => any;
267
+ readonly sdk_getDefaultClarityVersionForCurrentEpoch: (a: number) => any;
268
+ readonly sdk_initEmptySession: (a: number, b: any) => any;
269
+ readonly sdk_initSession: (a: number, b: number, c: number, d: number, e: number) => any;
270
+ readonly sdk_clearCache: (a: number) => void;
271
+ readonly sdk_blockHeight: (a: number) => number;
272
+ readonly sdk_burnBlockHeight: (a: number) => number;
273
+ readonly sdk_currentEpoch: (a: number) => [number, number];
274
+ readonly sdk_setEpoch: (a: number, b: any) => void;
275
+ readonly sdk_getContractsInterfaces: (a: number) => [number, number, number];
276
+ readonly sdk_getContractSource: (a: number, b: number, c: number) => [number, number];
277
+ readonly sdk_getContractAST: (a: number, b: number, c: number) => [number, number, number];
278
+ readonly sdk_getAssetsMap: (a: number) => [number, number, number];
279
+ readonly sdk_getAccounts: (a: number) => [number, number, number];
280
+ readonly sdk_getDataVar: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
281
+ readonly sdk_getBlockTime: (a: number) => bigint;
282
+ readonly sdk_getMapEntry: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
283
+ readonly sdk_callReadOnlyFn: (a: number, b: number) => [number, number, number];
284
+ readonly sdk_deployContract: (a: number, b: number) => [number, number, number];
285
+ readonly sdk_transferSTX: (a: number, b: number) => [number, number, number];
286
+ readonly sdk_callPublicFn: (a: number, b: number) => [number, number, number];
287
+ readonly sdk_callPrivateFn: (a: number, b: number) => [number, number, number];
288
+ readonly sdk_mineBlock: (a: number, b: any) => [number, number, number];
289
+ readonly sdk_mineEmptyBlock: (a: number) => number;
290
+ readonly sdk_mineEmptyBlocks: (a: number, b: number) => number;
291
+ readonly sdk_mineEmptyStacksBlock: (a: number) => [number, number, number];
292
+ readonly sdk_mineEmptyStacksBlocks: (a: number, b: number) => [number, number, number];
293
+ readonly sdk_mineEmptyBurnBlock: (a: number) => number;
294
+ readonly sdk_mineEmptyBurnBlocks: (a: number, b: number) => number;
295
+ readonly sdk_runSnippet: (a: number, b: number, c: number) => [number, number];
296
+ readonly sdk_execute: (a: number, b: number, c: number) => [number, number, number];
297
+ readonly sdk_executeCommand: (a: number, b: number, c: number) => [number, number];
298
+ readonly sdk_getLastContractCallTrace: (a: number) => [number, number];
299
+ readonly sdk_setLocalAccounts: (a: number, b: number, c: number) => void;
300
+ readonly sdk_mintSTX: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
301
+ readonly sdk_setCurrentTestName: (a: number, b: number, c: number) => void;
302
+ readonly sdk_collectReport: (a: number, b: number, c: number, d: number) => [number, number, number];
303
+ readonly sdk_enablePerformance: (a: number, b: number, c: number) => [number, number];
304
+ readonly sdk_stacksBlockHeight: (a: number) => number;
305
+ readonly __wbg_set_transactionres_result: (a: number, b: number, c: number) => void;
306
+ readonly __wbg_set_transactionres_events: (a: number, b: number, c: number) => void;
307
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
308
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
309
+ readonly __wbindgen_exn_store: (a: number) => void;
310
+ readonly __externref_table_alloc: () => number;
311
+ readonly __wbindgen_export_4: WebAssembly.Table;
312
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
313
+ readonly __wbindgen_export_6: WebAssembly.Table;
314
+ readonly __externref_table_dealloc: (a: number) => void;
315
+ readonly closure607_externref_shim: (a: number, b: number, c: any) => void;
316
+ readonly wasm_bindgen__convert__closures_____invoke__h663b0a1b4d0a0453: (a: number, b: number) => void;
317
+ readonly closure3298_externref_shim: (a: number, b: number, c: any, d: any) => void;
318
+ readonly __wbindgen_start: () => void;
319
+ }
320
+
321
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
322
+ /**
323
+ * Instantiates the given `module`, which can either be bytes or
324
+ * a precompiled `WebAssembly.Module`.
325
+ *
326
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
327
+ *
328
+ * @returns {InitOutput}
329
+ */
330
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
331
+
332
+ /**
333
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
334
+ * for everything else, calls `WebAssembly.instantiate` directly.
335
+ *
336
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
337
+ *
338
+ * @returns {Promise<InitOutput>}
339
+ */
340
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;