From c28bb649103f2b09b02d8e47ef15530fa2d61af5 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 16 Jan 2024 15:49:06 +0100 Subject: [PATCH] Add circom logs --- .../src/app/services/circomPluginClient.ts | 24 +++++++++++++++++++ package.json | 2 +- yarn.lock | 5 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts index 3309fdd7ca..e54f12e507 100644 --- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts +++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts @@ -123,11 +123,15 @@ export class CircomPluginClient extends PluginClient { async compile(path: string, compilationConfig?: CompilationConfig): Promise { this.internalEvents.emit('circuit_compiling_start') + // @ts-ignore + this.call('terminal', 'log', { type: 'info', value: 'Compiling ' + path }) const [parseErrors, filePathToId] = await this.parse(path) if (parseErrors && (parseErrors.length > 0)) { if (parseErrors[0].type === 'Error') { this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId) + // @ts-ignore + this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' }) return } else if (parseErrors[0].type === 'Warning') { this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId) @@ -147,6 +151,8 @@ export class CircomPluginClient extends PluginClient { if (circuitProgram.length < 1) { const circuitErrors = circuitApi.report() + // @ts-ignore + this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' }) throw new Error(circuitErrors) } else { this.lastCompiledFile = path @@ -166,16 +172,26 @@ export class CircomPluginClient extends PluginClient { } else { this.internalEvents.emit('circuit_compiling_done', []) } + // @ts-ignore + circuitApi.log().map(log => { + log && this.call('terminal', 'log', { type: 'log', value: log }) + }) + // @ts-ignore + this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' }) } } async generateR1cs (path: string, compilationConfig?: CompilationConfig): Promise { this.internalEvents.emit('circuit_generating_r1cs_start') + // @ts-ignore + this.call('terminal', 'log', { type: 'info', value: 'Generating R1CS for ' + path }) const [parseErrors, filePathToId] = await this.parse(path) if (parseErrors && (parseErrors.length > 0)) { if (parseErrors[0].type === 'Error') { this.internalEvents.emit('circuit_parsing_errored', parseErrors) + // @ts-ignore + this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' }) return } else if (parseErrors[0].type === 'Warning') { this.internalEvents.emit('circuit_parsing_warning', parseErrors) @@ -195,6 +211,8 @@ export class CircomPluginClient extends PluginClient { if (r1csProgram.length < 1) { const r1csErrors = r1csApi.report() + // @ts-ignore + this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' }) throw new Error(r1csErrors) } else { this.internalEvents.emit('circuit_generating_r1cs_done') @@ -203,6 +221,12 @@ export class CircomPluginClient extends PluginClient { // @ts-ignore await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) + // @ts-ignore + r1csApi.log().map(log => { + log && this.call('terminal', 'log', { type: 'log', value: log }) + }) + // @ts-ignore + this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' }) } } diff --git a/package.json b/package.json index 5ae31e0e7f..ea8cd762c1 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,7 @@ "brace": "^0.8.0", "change-case": "^4.1.1", "chokidar": "^2.1.8", - "circom_wasm": "^0.2.0", + "circom_wasm": "https://github.com/ioedeveloper/circom_wasm.git", "color-support": "^1.1.3", "commander": "^9.4.1", "core-js": "^3.6.5", diff --git a/yarn.lock b/yarn.lock index 8ead0f4bb3..9e2f4c801c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10537,10 +10537,9 @@ circom_runtime@0.1.22: dependencies: ffjavascript "0.2.57" -circom_wasm@^0.2.0: +"circom_wasm@https://github.com/ioedeveloper/circom_wasm.git": version "0.2.0" - resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.0.tgz#c35537f0b1f5bfd3d88898306f46c3a3457e5589" - integrity sha512-eqDCbAXJQkKnrAg0Ow3bdaGciGTooRKL20941JGzX8IcqgHoGiZxaSLATkYy97dbmJFrxe8Wr+mOGnvdbqN9bw== + resolved "https://github.com/ioedeveloper/circom_wasm.git#68473f2c1166d96e73513b0a2aac1afcd30b0111" circular-json@^0.3.0: version "0.3.3"