From c8b81815f69f08b964a2e50ac5d4e9c60a29397e Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Tue, 7 Nov 2023 08:00:48 +0000 Subject: [PATCH 1/2] fix: stop CompileError from bubbling to the top --- .../noir-compiler/src/compile/noir/noir-wasm-compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts index 395ad4df9f3..f4122e4512f 100644 --- a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts +++ b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts @@ -105,6 +105,7 @@ export class NoirWasmContractCompiler { } catch (err) { if (err instanceof Error && err.name === 'CompileError') { this.#processCompileError(err as CompileError); + throw new Error('Compilation failed'); } throw err; @@ -121,7 +122,6 @@ export class NoirWasmContractCompiler { }; #processCompileError(err: CompileError): void { - this.#log('Error compiling contract'); for (const diag of err.diagnostics) { this.#log(` ${diag.message}`); const contents = this.#resolveFile(diag.file); From 9966ddc140ff36d6ac75579c279d22e8d34dfb6c Mon Sep 17 00:00:00 2001 From: Dan Lee Date: Mon, 6 Nov 2023 14:48:13 -0500 Subject: [PATCH 2/2] fix: revert "binary" to "bin" --- yarn-project/foundation/src/noir/noir_package_config.ts | 2 +- .../noir-compiler/src/compile/noir/noir-wasm-compiler.ts | 8 +++++++- yarn-project/noir-compiler/src/compile/noir/package.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/yarn-project/foundation/src/noir/noir_package_config.ts b/yarn-project/foundation/src/noir/noir_package_config.ts index a1cd84f37e1..af2345e20fb 100644 --- a/yarn-project/foundation/src/noir/noir_package_config.ts +++ b/yarn-project/foundation/src/noir/noir_package_config.ts @@ -13,7 +13,7 @@ const noirLocalDependencySchema = z.object({ const noirPackageConfigSchema = z.object({ package: z.object({ name: z.string().default(''), - type: z.enum(['lib', 'contract', 'binary']).default('binary'), + type: z.enum(['lib', 'contract', 'bin']).default('bin'), entry: z.string().optional(), description: z.string().optional(), authors: z.array(z.string()).optional(), diff --git a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts index f4122e4512f..03447e0f189 100644 --- a/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts +++ b/yarn-project/noir-compiler/src/compile/noir/noir-wasm-compiler.ts @@ -83,6 +83,12 @@ export class NoirWasmContractCompiler { * Compiles the project. */ public async compile(): Promise { + const isContract = this.#package.getType() === 'contract'; + // limit to contracts-only because the rest of the pipeline only supports processing contracts + if (!isContract) { + throw new Error('Noir project is not a contract'); + } + this.#debugLog(`Compiling contract at ${this.#package.getEntryPointPath()}`); await this.#dependencyManager.resolveDependencies(); this.#debugLog(`Dependencies: ${this.#dependencyManager.getPackageNames().join(', ')}`); @@ -90,7 +96,7 @@ export class NoirWasmContractCompiler { initializeResolver(this.#resolveFile); try { - const result = compile(this.#package.getEntryPointPath(), true, { + const result = compile(this.#package.getEntryPointPath(), isContract, { /* eslint-disable camelcase */ root_dependencies: this.#dependencyManager.getEntrypointDependencies(), library_dependencies: this.#dependencyManager.getLibraryDependencies(), diff --git a/yarn-project/noir-compiler/src/compile/noir/package.ts b/yarn-project/noir-compiler/src/compile/noir/package.ts index 730df27b675..c79fc662dd7 100644 --- a/yarn-project/noir-compiler/src/compile/noir/package.ts +++ b/yarn-project/noir-compiler/src/compile/noir/package.ts @@ -47,7 +47,7 @@ export class NoirPackage { entrypoint = 'lib.nr'; break; case 'contract': - case 'binary': + case 'bin': entrypoint = 'main.nr'; break; default: