circom-desktop

pull/5228/head
ioedeveloper 5 months ago committed by bunsenstraat
parent 092c7b9a88
commit 85b0a7d90d
  1. 1
      .gitignore
  2. 1
      apps/circuit-compiler/src/app/app.tsx
  3. 1
      apps/circuit-compiler/src/app/components/container.tsx
  4. 14
      apps/circuit-compiler/src/app/reducers/state.ts
  5. 16
      apps/circuit-compiler/src/app/services/circomPluginClient.ts
  6. 2
      apps/remixdesktop/log_input_signals.txt
  7. 1
      apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts

1
.gitignore vendored

@ -70,4 +70,5 @@ apps/remixdesktop/reports
apps/remixdesktop/logs/ apps/remixdesktop/logs/
apps/remixdesktop/bin/ apps/remixdesktop/bin/
apps/remixdesktop/circom-download apps/remixdesktop/circom-download
apps/remixdesktop/log_input_signals.txt
logs logs

@ -80,7 +80,6 @@ function App() {
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report }) dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: report })
}) })
plugin.internalEvents.on('download_success', (version) => { plugin.internalEvents.on('download_success', (version) => {
dispatch({ type: 'SET_COMPILER_VERSION', payload: version })
dispatch({ type: 'REMOVE_VERSION_FROM_DOWNLOAD_LIST', payload: version }) dispatch({ type: 'REMOVE_VERSION_FROM_DOWNLOAD_LIST', payload: version })
dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null }) dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null })
}) })

@ -31,6 +31,7 @@ export function Container () {
const handleVersionSelect = (version: string) => { const handleVersionSelect = (version: string) => {
circuitApp.plugin.compilerVersion = version circuitApp.plugin.compilerVersion = version
circuitApp.dispatch({ type: 'SET_COMPILER_VERSION', payload: version })
} }
const handleOpenErrorLocation = async (location: string, startRange: string) => { const handleOpenErrorLocation = async (location: string, startRange: string) => {

@ -1,10 +1,20 @@
import { PTAU_LIST } from '../actions/constant' import { PTAU_LIST } from '../actions/constant'
import { Actions, AppState } from '../types' import { Actions, AppState } from '../types'
import { compiler_list } from 'circom_wasm' import { compiler_list } from 'circom_wasm'
import isElectron from 'is-electron'
const VersionList = isElectron() ? { ...compiler_list.wasm_builds,
"latest": {
"name": "latest",
"version": "latest",
"repo": "",
"build_source": ""
}
} : compiler_list.wasm_builds
export const appInitialState: AppState = { export const appInitialState: AppState = {
version: compiler_list.latest, version: isElectron() ? "latest" : compiler_list.latest,
versionList: compiler_list.wasm_builds, versionList: VersionList,
versionDownloadList: [], versionDownloadList: [],
filePath: "", filePath: "",
filePathToId: {}, filePathToId: {},

@ -14,7 +14,7 @@ import isElectron from 'is-electron'
export class CircomPluginClient extends PluginClient { export class CircomPluginClient extends PluginClient {
public internalEvents: EventManager public internalEvents: EventManager
private _compilationConfig: CompilationConfig = { private _compilationConfig: CompilationConfig = {
version: "2.1.8", version: isElectron() ? "latest" : "2.1.8",
prime: "bn128" prime: "bn128"
} }
private lastCompiledCircuitPath: string = '' private lastCompiledCircuitPath: string = ''
@ -44,11 +44,12 @@ export class CircomPluginClient extends PluginClient {
} }
set compilerVersion (version: string) { set compilerVersion (version: string) {
if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version") if (!compiler_list.versions.includes(version) && version !== "latest") throw new Error("Unsupported compiler version")
this._compilationConfig.version = version this._compilationConfig.version = version
if (isElectron()) { if (isElectron()) {
const versionToInstall = version === 'latest' ? 'latest' : `v${version}`
// @ts-ignore // @ts-ignore
this.call('circom', 'install', `v${version}`).then(() => { this.call('circom', 'install', versionToInstall).then(() => {
this.internalEvents.emit('download_success', version) this.internalEvents.emit('download_success', version)
}).catch((e) => { }).catch((e) => {
this.internalEvents.emit('download_failed') this.internalEvents.emit('download_failed')
@ -151,8 +152,9 @@ export class CircomPluginClient extends PluginClient {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path }) this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path })
const { version, prime } = this._compilationConfig const { version, prime } = this._compilationConfig
const versionToInstall = version === 'latest' ? 'latest' : `v${version}`
// @ts-ignore // @ts-ignore
const { stdout, stderr } = await this.call('circom', 'run', path, `v${version}`, { prime: prime, wasm: "", inputs: "" }) const { stdout, stderr } = await this.call('circom', 'run', path, versionToInstall, { prime: prime, wasm: "", inputs: "" })
const fileName = extractNameFromKey(path) const fileName = extractNameFromKey(path)
this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('circom', 'wasm') this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('circom', 'wasm')
@ -234,8 +236,9 @@ export class CircomPluginClient extends PluginClient {
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', { type: 'log', value: 'Generating R1CS for ' + path }) this.call('terminal', 'log', { type: 'log', value: 'Generating R1CS for ' + path })
const { version, prime } = this._compilationConfig const { version, prime } = this._compilationConfig
const versionToInstall = version === 'latest' ? 'latest' : `v${version}`
// @ts-ignore // @ts-ignore
await this.call('circom', 'run', path, `v${version}`, { await this.call('circom', 'run', path, versionToInstall, {
prime: prime, prime: prime,
r1cs: "" r1cs: ""
}) })
@ -479,8 +482,9 @@ export class CircomPluginClient extends PluginClient {
if (!isElectron()) return [] if (!isElectron()) return []
else { else {
return await Promise.all(compiler_list.versions.map(async (version) => { return await Promise.all(compiler_list.versions.map(async (version) => {
const versionToInstall = version === 'latest' ? 'latest' : `v${version}`
// @ts-ignore // @ts-ignore
const exists = await this.call('circom', 'isVersionInstalled', `v${version}`) const exists = await this.call('circom', 'isVersionInstalled', versionToInstall)
if (!exists) return version if (!exists) return version
})) }))

@ -56,6 +56,7 @@ class CircomElectronPluginClient extends ElectronBasePluginClient {
const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/') const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/')
const outputDir = extractParentFromKey(filePath) + '/.bin' const outputDir = extractParentFromKey(filePath) + '/.bin'
this.call('terminal' as any, 'logHtml', `Compiling ${filePath} with circom compiler (${version})`)
return await circomCli.run(`${filePath} -l ${depPath} -o ${outputDir}`, version, options) return await circomCli.run(`${filePath} -l ${depPath} -o ${outputDir}`, version, options)
} }

Loading…
Cancel
Save