circom-desktop

circom-desktop
ioedeveloper 2 months ago
parent 5d6600a0ed
commit d81cedce71
  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/bin/
apps/remixdesktop/circom-download
apps/remixdesktop/log_input_signals.txt
logs

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

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

@ -1,10 +1,20 @@
import { PTAU_LIST } from '../actions/constant'
import { Actions, AppState } from '../types'
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 = {
version: compiler_list.latest,
versionList: compiler_list.wasm_builds,
version: isElectron() ? "latest" : compiler_list.latest,
versionList: VersionList,
versionDownloadList: [],
filePath: "",
filePathToId: {},

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

@ -56,6 +56,7 @@ class CircomElectronPluginClient extends ElectronBasePluginClient {
const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/')
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)
}

Loading…
Cancel
Save