Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/noir/noir_package_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ export class NoirWasmContractCompiler {
* Compiles the project.
*/
public async compile(): Promise<NoirCompilationArtifacts[]> {
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(', ')}`);

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(),
Expand All @@ -105,6 +111,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;
Expand All @@ -121,7 +128,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);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/noir-compiler/src/compile/noir/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class NoirPackage {
entrypoint = 'lib.nr';
break;
case 'contract':
case 'binary':
case 'bin':
entrypoint = 'main.nr';
break;
default:
Expand Down