From bbf6fe6442ae49350bbf80ccd6501f7b56cb2016 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 29 Oct 2024 21:00:31 +0000 Subject: [PATCH] Use separate path for dev and prod --- apps/circuit-compiler/src/app/app.tsx | 12 +++++++++++- .../src/plugins/circomElectronBasePlugin.ts | 15 +++++++++++---- apps/remixdesktop/src/tools/circom.ts | 12 ++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/apps/circuit-compiler/src/app/app.tsx b/apps/circuit-compiler/src/app/app.tsx index 6307b5041f..6d845b2e8e 100644 --- a/apps/circuit-compiler/src/app/app.tsx +++ b/apps/circuit-compiler/src/app/app.tsx @@ -52,6 +52,7 @@ function App() { signalInputs = (signalInputs || []).filter(input => input) dispatch({ type: 'SET_SIGNAL_INPUTS', payload: signalInputs }) dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) + dispatch({ type: 'SET_COMPILER_FEEDBACK', payload: null }) }) plugin.internalEvents.on('circuit_compiling_errored', compilerErrored) @@ -61,7 +62,16 @@ function App() { dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: null }) }) - plugin.internalEvents.on('circuit_computing_witness_errored', compilerErrored) + plugin.internalEvents.on('circuit_computing_witness_errored', (err) => { + dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' }) + try { + const report = JSON.parse(err.message) + + dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: report }) + } catch (e) { + dispatch({ type: 'SET_COMPUTE_FEEDBACK', payload: err.message }) + } + }) // parsing events plugin.internalEvents.on('circuit_parsing_done', (_, filePathToId) => { diff --git a/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts b/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts index de96076202..cb4f317d56 100644 --- a/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts +++ b/apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts @@ -48,13 +48,20 @@ class CircomElectronPluginClient extends ElectronBasePluginClient { if (!this.isCircomInstalled) await this.install(version) // @ts-ignore const wd = await this.call('fs', 'getWorkingDir') - const binDir = path.normalize(path.join(extractParentFromKey(filePath), '.bin')) + const binDir = path.join(wd, path.join(extractParentFromKey(filePath), '.bin')) // @ts-ignore - const outputDirExists = await this.call('fs', 'exists', binDir) + const outputDirExists = await this.call('fs', 'exists', path.join(extractParentFromKey(filePath), '.bin')) // @ts-ignore - if (!outputDirExists) await this.call('fs', 'mkdir', binDir) + if (!outputDirExists) await this.call('fs', 'mkdir', path.join(extractParentFromKey(filePath), '.bin')) + else { + // @ts-ignore + if (process.platform === 'win32' && 'wasm' in options) { + // @ts-ignore + await this.call('fs', 'rmdir', path.join(extractParentFromKey(filePath), '.bin', 'simple_js')) + } + } filePath = path.join(wd, filePath) - const depPath = path.normalize(path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/')) + const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/') const outputDir = process.platform !== 'win32' ? path.join(extractParentFromKey(filePath), '.bin') : binDir this.call('terminal' as any, 'logHtml', `Compiling ${filePath} with circom compiler (${version})`) diff --git a/apps/remixdesktop/src/tools/circom.ts b/apps/remixdesktop/src/tools/circom.ts index 8ef2b47a0f..dca7a972a1 100644 --- a/apps/remixdesktop/src/tools/circom.ts +++ b/apps/remixdesktop/src/tools/circom.ts @@ -35,13 +35,13 @@ async function downloadFile(url: string, dest: string) { export function getInstallationPath(version) { switch (process.platform) { case 'win32': - return path.join(app.getPath('temp'), 'circom-download', version, 'circom-windows-amd64.exe') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-windows-amd64.exe') : path.join(app.getAppPath(), 'circom-download', version, 'circom-windows-amd64.exe') case 'darwin': - return path.join(app.getAppPath(), 'circom-download', version, 'circom-macos-amd64') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-macos-amd64') : path.join(app.getAppPath(), 'circom-download', version, 'circom-macos-amd64') case 'linux': - return path.join(app.getAppPath(), 'circom-download', version, 'circom-linux-amd64') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'circom-download', version, 'circom-linux-amd64') : path.join(app.getAppPath(), 'circom-download', version, 'circom-linux-amd64') } } @@ -61,13 +61,13 @@ export function getInstallationUrl(version) { export function getLogInputSignalsPath() { switch (process.platform) { case 'win32': - return path.join(app.getPath('temp'), 'log_input_signals.txt') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'log_input_signals.txt') : path.join(app.getAppPath(), 'log_input_signals.txt') case 'darwin': - return path.join(app.getAppPath(), 'log_input_signals.txt') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'log_input_signals.txt') : path.join(app.getAppPath(), 'log_input_signals.txt') case 'linux': - return path.join(app.getAppPath(), 'log_input_signals.txt') + return process.env.NODE_ENV === 'production' ? path.join(app.getPath('temp'), 'log_input_signals.txt') : path.join(app.getAppPath(), 'log_input_signals.txt') } }