-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworker.ts
46 lines (40 loc) · 1.63 KB
/
worker.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import wasmCairo, { compileStarknetContract, runTests, runCairoProgram, compileCairoProgram, greet } from 'wasm-cairo';
import * as Comlink from 'comlink';
interface ITestOptions {
cairoProgram: string;
allowWarnings: boolean;
filter: string;
includeIgnored: boolean;
ignored: boolean;
starknet: boolean;
runProfiler: string;
gasDisabled: boolean;
printResourceUsage: boolean;
}
class CairoWorker {
init = async () => {
await wasmCairo();
greet('Hello World');
}
constructor() {
this.init();
}
async runCairoProgram({cairoProgram, availableGas, printFullMemory, useDBGPrintHint, allWarnings = true, runProfiler = false}: any) {
const res = runCairoProgram(cairoProgram, availableGas, allWarnings, printFullMemory, runProfiler, useDBGPrintHint);
return res;
}
async compileCairoProgram({cairoProgram, replaceIds}: any) {
const res = compileCairoProgram(cairoProgram, replaceIds);
return res;
}
async compileStarknetContract({starknetContract, allowWarnings, replaceIds}: any) {
const res = compileStarknetContract(starknetContract, allowWarnings, replaceIds);
return res;
}
async runTests({cairoProgram, allowWarnings = true, filter = '', includeIgnored = true, ignored = true, starknet = false, runProfiler = '', gasDisabled = true, printResourceUsage = true, }: ITestOptions) {
const res = runTests(cairoProgram, allowWarnings, filter, includeIgnored, ignored, starknet, runProfiler, gasDisabled, printResourceUsage);
return res;
}
}
export {CairoWorker};
Comlink.expose(CairoWorker);