@@ -12,6 +12,7 @@ import {
1212import {
1313 type ABIParameter ,
1414 type ABIParameterVisibility ,
15+ ARTIFACT_VERSION_BEFORE_INJECTION ,
1516 type AbiType ,
1617 type BasicValue ,
1718 type ContractArtifact ,
@@ -51,6 +52,10 @@ export function contractArtifactFromBuffer(buffer: Buffer): ContractArtifact {
5152 */
5253export function loadContractArtifact ( input : NoirCompiledContract ) : ContractArtifact {
5354 if ( isContractArtifact ( input ) ) {
55+ // TODO(F-557): Remove this fallback once pre-version artifacts are no longer tested.
56+ if ( ! ( input as unknown as Record < string , unknown > ) . aztecVersion ) {
57+ return { ...input , aztecVersion : ARTIFACT_VERSION_BEFORE_INJECTION } ;
58+ }
5459 return input ;
5560 }
5661 return generateContractArtifact ( input ) ;
@@ -276,10 +281,9 @@ function getStorageLayout(input: NoirCompiledContract) {
276281}
277282
278283/**
279- * Given a Nargo output generates an Aztec-compatible contract artifact.
284+ * Given a post-processed Nargo output defined as `contract` generates an Aztec-compatible contract artifact.
285+ *
280286 * Does not include public bytecode, apart from the public_dispatch function.
281- * @param compiled - Noir build output.
282- * @returns Aztec contract build artifact.
283287 */
284288function generateContractArtifact ( contract : NoirCompiledContract ) : ContractArtifact {
285289 try {
@@ -288,6 +292,7 @@ function generateContractArtifact(contract: NoirCompiledContract): ContractArtif
288292 }
289293 return ContractArtifactSchema . parse ( {
290294 name : contract . name ,
295+ aztecVersion : contract . aztec_version ,
291296 functions : contract . functions . filter ( f => retainBytecode ( f ) ) . map ( f => generateFunctionArtifact ( f , contract ) ) ,
292297 nonDispatchPublicFunctions : contract . functions
293298 . filter ( f => ! retainBytecode ( f ) )
@@ -302,15 +307,15 @@ function generateContractArtifact(contract: NoirCompiledContract): ContractArtif
302307}
303308
304309/**
305- * Given a Nargo output generates an Aztec-compatible contract artifact.
310+ * Given a post-processed Nargo output defined as `contract` generates an Aztec-compatible contract artifact.
311+ *
306312 * Retains all public bytecode.
307- * @param compiled - Noir build output.
308- * @returns Aztec contract build artifact.
309313 */
310314function generateContractArtifactForPublic ( contract : NoirCompiledContract ) : ContractArtifact {
311315 try {
312316 return ContractArtifactSchema . parse ( {
313317 name : contract . name ,
318+ aztecVersion : contract . aztec_version ,
314319 functions : contract . functions . map ( f => generateFunctionArtifact ( f , contract ) ) ,
315320 nonDispatchPublicFunctions : contract . functions
316321 . filter ( f => ! retainBytecode ( f ) )
0 commit comments