|
|
@ -10,6 +10,8 @@ import * as compilerV215 from 'circom_wasm/v2.1.5' |
|
|
|
import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' |
|
|
|
import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' |
|
|
|
import { CompilationConfig, CompilerReport, PrimeValue, ResolverOutput } from '../types' |
|
|
|
import { CompilationConfig, CompilerReport, PrimeValue, ResolverOutput } from '../types' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
const _paq = (window._paq = window._paq || []) |
|
|
|
export class CircomPluginClient extends PluginClient { |
|
|
|
export class CircomPluginClient extends PluginClient { |
|
|
|
public internalEvents: EventManager |
|
|
|
public internalEvents: EventManager |
|
|
|
private _compilationConfig: CompilationConfig = { |
|
|
|
private _compilationConfig: CompilationConfig = { |
|
|
@ -162,6 +164,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
const circuitErrors = circuitApi.report() |
|
|
|
const circuitErrors = circuitApi.report() |
|
|
|
|
|
|
|
|
|
|
|
this.logCompilerReport(circuitErrors) |
|
|
|
this.logCompilerReport(circuitErrors) |
|
|
|
|
|
|
|
_paq.push(['trackEvent', 'circuit-compiler', 'compile', 'Compilation failed']) |
|
|
|
throw new Error(circuitErrors) |
|
|
|
throw new Error(circuitErrors) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.lastCompiledFile = path |
|
|
|
this.lastCompiledFile = path |
|
|
@ -181,6 +184,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_compiling_done', []) |
|
|
|
this.internalEvents.emit('circuit_compiling_done', []) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_paq.push(['trackEvent', 'circuit-compiler', 'compile', 'Compilation successful']) |
|
|
|
circuitApi.log().map(log => { |
|
|
|
circuitApi.log().map(log => { |
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log }) |
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log }) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -222,6 +226,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
const r1csErrors = r1csApi.report() |
|
|
|
const r1csErrors = r1csApi.report() |
|
|
|
|
|
|
|
|
|
|
|
this.logCompilerReport(r1csErrors) |
|
|
|
this.logCompilerReport(r1csErrors) |
|
|
|
|
|
|
|
_paq.push(['trackEvent', 'circuit-compiler', 'generateR1cs', 'R1CS Generation failed']) |
|
|
|
throw new Error(r1csErrors) |
|
|
|
throw new Error(r1csErrors) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_done') |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_done') |
|
|
@ -230,6 +235,7 @@ 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) |
|
|
|
|
|
|
|
_paq.push(['trackEvent', 'circuit-compiler', 'generateR1cs', 'R1CS Generation successful']) |
|
|
|
r1csApi.log().map(log => { |
|
|
|
r1csApi.log().map(log => { |
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log }) |
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log }) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -250,6 +256,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
const witness = this.compiler ? await this.compiler.generate_witness(dataRead, input) : await generate_witness(dataRead, input) |
|
|
|
const witness = this.compiler ? await this.compiler.generate_witness(dataRead, input) : await generate_witness(dataRead, input) |
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true) |
|
|
|
await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true) |
|
|
|
|
|
|
|
_paq.push(['trackEvent', 'circuit-compiler', 'computeWitness', 'Witness computing successful']) |
|
|
|
this.internalEvents.emit('circuit_computing_witness_done') |
|
|
|
this.internalEvents.emit('circuit_computing_witness_done') |
|
|
|
this.emit('statusChanged', { key: 'succeed', title: 'witness computed successfully', type: 'success' }) |
|
|
|
this.emit('statusChanged', { key: 'succeed', title: 'witness computed successfully', type: 'success' }) |
|
|
|
} |
|
|
|
} |
|
|
|