Add circom logs

pull/4481/head
ioedeveloper 10 months ago
parent f45142ad91
commit c28bb64910
  1. 24
      apps/circuit-compiler/src/app/services/circomPluginClient.ts
  2. 2
      package.json
  3. 5
      yarn.lock

@ -123,11 +123,15 @@ export class CircomPluginClient extends PluginClient {
async compile(path: string, compilationConfig?: CompilationConfig): Promise<void> { async compile(path: string, compilationConfig?: CompilationConfig): Promise<void> {
this.internalEvents.emit('circuit_compiling_start') this.internalEvents.emit('circuit_compiling_start')
// @ts-ignore
this.call('terminal', 'log', { type: 'info', value: 'Compiling ' + path })
const [parseErrors, filePathToId] = await this.parse(path) const [parseErrors, filePathToId] = await this.parse(path)
if (parseErrors && (parseErrors.length > 0)) { if (parseErrors && (parseErrors.length > 0)) {
if (parseErrors[0].type === 'Error') { if (parseErrors[0].type === 'Error') {
this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId) this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId)
// @ts-ignore
this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' })
return return
} else if (parseErrors[0].type === 'Warning') { } else if (parseErrors[0].type === 'Warning') {
this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId) this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId)
@ -147,6 +151,8 @@ export class CircomPluginClient extends PluginClient {
if (circuitProgram.length < 1) { if (circuitProgram.length < 1) {
const circuitErrors = circuitApi.report() const circuitErrors = circuitApi.report()
// @ts-ignore
this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' })
throw new Error(circuitErrors) throw new Error(circuitErrors)
} else { } else {
this.lastCompiledFile = path this.lastCompiledFile = path
@ -166,16 +172,26 @@ export class CircomPluginClient extends PluginClient {
} else { } else {
this.internalEvents.emit('circuit_compiling_done', []) 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<void> { async generateR1cs (path: string, compilationConfig?: CompilationConfig): Promise<void> {
this.internalEvents.emit('circuit_generating_r1cs_start') 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) const [parseErrors, filePathToId] = await this.parse(path)
if (parseErrors && (parseErrors.length > 0)) { if (parseErrors && (parseErrors.length > 0)) {
if (parseErrors[0].type === 'Error') { if (parseErrors[0].type === 'Error') {
this.internalEvents.emit('circuit_parsing_errored', parseErrors) this.internalEvents.emit('circuit_parsing_errored', parseErrors)
// @ts-ignore
this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' })
return return
} else if (parseErrors[0].type === 'Warning') { } else if (parseErrors[0].type === 'Warning') {
this.internalEvents.emit('circuit_parsing_warning', parseErrors) this.internalEvents.emit('circuit_parsing_warning', parseErrors)
@ -195,6 +211,8 @@ export class CircomPluginClient extends PluginClient {
if (r1csProgram.length < 1) { if (r1csProgram.length < 1) {
const r1csErrors = r1csApi.report() const r1csErrors = r1csApi.report()
// @ts-ignore
this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' })
throw new Error(r1csErrors) throw new Error(r1csErrors)
} else { } else {
this.internalEvents.emit('circuit_generating_r1cs_done') this.internalEvents.emit('circuit_generating_r1cs_done')
@ -203,6 +221,12 @@ export class CircomPluginClient extends PluginClient {
// @ts-ignore // @ts-ignore
await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) 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' })
} }
} }

@ -164,7 +164,7 @@
"brace": "^0.8.0", "brace": "^0.8.0",
"change-case": "^4.1.1", "change-case": "^4.1.1",
"chokidar": "^2.1.8", "chokidar": "^2.1.8",
"circom_wasm": "^0.2.0", "circom_wasm": "https://github.com/ioedeveloper/circom_wasm.git",
"color-support": "^1.1.3", "color-support": "^1.1.3",
"commander": "^9.4.1", "commander": "^9.4.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",

@ -10537,10 +10537,9 @@ circom_runtime@0.1.22:
dependencies: dependencies:
ffjavascript "0.2.57" ffjavascript "0.2.57"
circom_wasm@^0.2.0: "circom_wasm@https://github.com/ioedeveloper/circom_wasm.git":
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.0.tgz#c35537f0b1f5bfd3d88898306f46c3a3457e5589" resolved "https://github.com/ioedeveloper/circom_wasm.git#68473f2c1166d96e73513b0a2aac1afcd30b0111"
integrity sha512-eqDCbAXJQkKnrAg0Ow3bdaGciGTooRKL20941JGzX8IcqgHoGiZxaSLATkYy97dbmJFrxe8Wr+mOGnvdbqN9bw==
circular-json@^0.3.0: circular-json@^0.3.0:
version "0.3.3" version "0.3.3"

Loading…
Cancel
Save