From d097839b21c17aaa36a21b9eb0cf7c3d3af30893 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Mon, 11 Dec 2023 16:12:29 +0000 Subject: [PATCH] compile time error if ctor is missing --- yarn-project/noir-compiler/src/contract-interface-gen/abi.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts b/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts index df819ae6578..d97f66f1a43 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/abi.ts @@ -89,6 +89,10 @@ export function generateContractArtifact( { contract, debug }: NoirContractCompilationArtifacts, aztecNrVersion?: string, ): ContractArtifact { + const constructorArtifact = contract.functions.find(({ name }) => name === 'constructor'); + if (constructorArtifact === undefined) { + throw new Error('Contract must have a constructor function'); + } if (contract.functions.length > 2 ** FUNCTION_TREE_HEIGHT) { throw new Error(`Contract can only have a maximum of ${2 ** FUNCTION_TREE_HEIGHT} functions`); }