From 4cf2bd519549942db2ef1eff9a18eeda1ec8f0ca Mon Sep 17 00:00:00 2001 From: ci-bot Date: Wed, 1 Oct 2025 14:39:03 +0900 Subject: [PATCH 1/2] fix fileupload logic --- .env.local | 8 +-- .../src/app/services/noirPluginClient.ts | 54 ++++++++++++++++--- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.env.local b/.env.local index a95c2b55888..524358da7f8 100644 --- a/.env.local +++ b/.env.local @@ -3,7 +3,7 @@ account_passphrase= account_password= NODE_OPTIONS=--max-old-space-size=4096 WALLET_CONNECT_PROJECT_ID= -NOIR_COMPILER_BASE_URL_DEV= -NOIR_COMPILER_BASE_URL_PROD= -NOIR_COMPILER_WS_URL_DEV= -NOIR_COMPILER_WS_URL_PROD= +NOIR_COMPILER_BASE_URL_DEV=https://noir.zkdev.net +NOIR_COMPILER_BASE_URL_PROD=https://noir.zkdev.net +NOIR_COMPILER_WS_URL_DEV=wss://noir.zkdev.net/ws/ +NOIR_COMPILER_WS_URL_PROD=wss://noir.zkdev.net/ws/ diff --git a/apps/noir-compiler/src/app/services/noirPluginClient.ts b/apps/noir-compiler/src/app/services/noirPluginClient.ts index 23ed1e4909b..9487fa10829 100644 --- a/apps/noir-compiler/src/app/services/noirPluginClient.ts +++ b/apps/noir-compiler/src/app/services/noirPluginClient.ts @@ -61,12 +61,13 @@ export class NoirPluginClient extends PluginClient { } } - async setupNargoToml(): Promise { + async setupNargoToml(projectRoot: string): Promise { + const tomlPath = projectRoot === '/' ? 'Nargo.toml' : `${projectRoot}/Nargo.toml` // @ts-ignore - const nargoTomlExists = await this.call('fileManager', 'exists', 'Nargo.toml') + const nargoTomlExists = await this.call('fileManager', 'exists', tomlPath) if (!nargoTomlExists) { - await this.call('fileManager', 'writeFile', 'Nargo.toml', DEFAULT_TOML_CONFIG) + await this.call('fileManager', 'writeFile', tomlPath, DEFAULT_TOML_CONFIG) } } @@ -77,6 +78,29 @@ export class NoirPluginClient extends PluginClient { return `req_${timestamp}_${random}` } + async findProjectRoot(filePath: string): Promise { + const srcIndex = filePath.lastIndexOf('/src/') + + if (srcIndex === -1) { + console.error(`File is not located within a 'src' directory: ${filePath}`) + return null + } + + const potentialRoot = filePath.substring(0, srcIndex) + const tomlPath = potentialRoot ? `${potentialRoot}/Nargo.toml` : 'Nargo.toml' + + // @ts-ignore + const tomlExists = await this.call('fileManager', 'exists', tomlPath) + + if (tomlExists) { + const projectRoot = potentialRoot || '/' + return projectRoot + } else { + console.error(`'Nargo.toml' not found at the expected project root: '${potentialRoot || '/'}'.`) + return null + } + } + async compile(path: string): Promise { try { const requestID = this.generateRequestID() @@ -86,15 +110,28 @@ export class NoirPluginClient extends PluginClient { path, id: requestID } + if (this.ws.readyState === WebSocket.OPEN) { + const projectRoot = await this.findProjectRoot(path) + + if (projectRoot === null) { + const errorMsg = `Invalid project structure for '${path}'. A '.nr' file must be inside a 'src' folder, and a 'Nargo.toml' file must exist in the project root directory.` + this.call('terminal', 'log', { type: 'error', value: errorMsg }) + this.emit('statusChanged', { key: 'error', title: 'Invalid project structure', type: 'error' }) + this.internalEvents.emit('noir_compiling_errored', new Error(errorMsg)) + return + } + this.ws.send(JSON.stringify({ requestId: requestID })) this.internalEvents.emit('noir_compiling_start') this.emit('statusChanged', { key: 'loading', title: 'Compiling Noir Program...', type: 'info' }) // @ts-ignore this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path }) - await this.setupNargoToml() + + await this.setupNargoToml(projectRoot) + // @ts-ignore - const zippedProject: Blob = await this.call('fileManager', 'download', '/', false, ['build']) + const zippedProject: Blob = await this.call('fileManager', 'download', projectRoot, false, ['build']) const formData = new FormData() formData.append('file', zippedProject, `${extractNameFromKey(path)}.zip`) @@ -108,8 +145,11 @@ export class NoirPluginClient extends PluginClient { } else { const { compiledJson, proverToml } = response.data - this.call('fileManager', 'writeFile', 'build/program.json', compiledJson) - this.call('fileManager', 'writeFile', 'build/prover.toml', proverToml) + const buildPath = projectRoot === '/' ? 'build' : `${projectRoot}/build` + + this.call('fileManager', 'writeFile', `${buildPath}/program.json`, compiledJson) + this.call('fileManager', 'writeFile', `${buildPath}/prover.toml`, proverToml) + this.internalEvents.emit('noir_compiling_done') this.emit('statusChanged', { key: 'succeed', title: 'Noir circuit compiled successfully', type: 'success' }) // @ts-ignore From 4df66ddd66d151b7b1a1a5bbbf6e6a9e4861f9ee Mon Sep 17 00:00:00 2001 From: ci-bot Date: Wed, 1 Oct 2025 14:48:16 +0900 Subject: [PATCH 2/2] remove .env.local --- .env.local | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .env.local diff --git a/.env.local b/.env.local deleted file mode 100644 index 524358da7f8..00000000000 --- a/.env.local +++ /dev/null @@ -1,9 +0,0 @@ -gist_token= -account_passphrase= -account_password= -NODE_OPTIONS=--max-old-space-size=4096 -WALLET_CONNECT_PROJECT_ID= -NOIR_COMPILER_BASE_URL_DEV=https://noir.zkdev.net -NOIR_COMPILER_BASE_URL_PROD=https://noir.zkdev.net -NOIR_COMPILER_WS_URL_DEV=wss://noir.zkdev.net/ws/ -NOIR_COMPILER_WS_URL_PROD=wss://noir.zkdev.net/ws/