@stacks/clarinet-sdk-wasm 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,227 @@
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
+ }