|
|
@ -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' }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|