Change new format for parsed report

pull/5370/head
ioedeveloper 1 year ago
parent 81aa41055c
commit 05e09396e7
  1. 21
      apps/circuit-compiler/src/app/services/circomPluginClient.ts

@ -2,7 +2,8 @@ import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview' import { createClient } from '@remixproject/plugin-webview'
import EventManager from 'events' import EventManager from 'events'
import pathModule from 'path' import pathModule from 'path'
import { parse, compile, generate_witness, generate_r1cs, compiler_list } from 'circom_wasm' // @ts-ignore
import { parse, compile, generate_witness, generate_r1cs, compiler_list } from '../../../pkg'
import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper' import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper'
import { CompilationConfig, CompilerReport } from '../types' import { CompilationConfig, CompilerReport } from '../types'
@ -42,8 +43,10 @@ export class CircomPluginClient extends PluginClient {
this.lastParsedFiles = await this.resolveDependencies(path, fileContent, this.lastParsedFiles) this.lastParsedFiles = await this.resolveDependencies(path, fileContent, this.lastParsedFiles)
const parsedOutput = parse(path, this.lastParsedFiles) const parsedOutput = parse(path, this.lastParsedFiles)
console.log('parsedOutput: ', parsedOutput)
try { try {
const result: CompilerReport[] = JSON.parse(parsedOutput) const result: CompilerReport[] = JSON.parse(parsedOutput.report())
const mapReportFilePathToId = {}
if (result.length === 0) { if (result.length === 0) {
// @ts-ignore // @ts-ignore
@ -53,7 +56,10 @@ export class CircomPluginClient extends PluginClient {
for (const report of result) { for (const report of result) {
for (const label in report.labels) { for (const label in report.labels) {
if (report.labels[label].file_id === '0') { const file_id = report.labels[label].file_id
mapReportFilePathToId[file_id] = parsedOutput.get_report_name(parseInt(file_id))
if (file_id === '0') {
// @ts-ignore // @ts-ignore
const startPosition: { lineNumber: number; column: number } = await this.call( const startPosition: { lineNumber: number; column: number } = await this.call(
'editor', 'editor',
@ -96,14 +102,9 @@ export class CircomPluginClient extends PluginClient {
await this.call('editor', 'clearErrorMarkers', [path]) await this.call('editor', 'clearErrorMarkers', [path])
} }
} }
const mapFilePathToId = {}
const filePaths = Object.keys(this.lastParsedFiles)
for (let index = 0; index < filePaths.length; index++) {
mapFilePathToId[index.toString()] = filePaths[index]
}
this.internalEvents.emit('circuit_parsing_done', result, mapFilePathToId) this.internalEvents.emit('circuit_parsing_done', result, mapReportFilePathToId)
return result return result
} catch (e) { } catch (e) {
throw new Error(e) throw new Error(e)

Loading…
Cancel
Save