Skip to content

Commit 8c28605

Browse files
author
sklppy88
committed
use validation lib to enforce sorting and ordering
1 parent 130f512 commit 8c28605

File tree

1 file changed

+8
-1
lines changed
  • yarn-project/foundation/src/abi

1 file changed

+8
-1
lines changed

yarn-project/foundation/src/abi/abi.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@ export const ContractArtifactSchema: ZodFor<ContractArtifact> = z.object({
358358
aztecNrVersion: z.string().optional(),
359359
functions: z.array(FunctionArtifactSchema),
360360
outputs: z.object({
361-
structs: z.record(z.array(AbiTypeSchema)),
361+
structs: z.record(z.array(AbiTypeSchema)).transform(structs => {
362+
for (const [key, value] of Object.entries(structs)) {
363+
if (key === 'events' || key === 'functions') {
364+
structs[key] = (value as StructType[]).sort((a, b) => a.path > b.path ? -1 : 1);
365+
}
366+
}
367+
return structs;
368+
}),
362369
globals: z.record(z.array(AbiValueSchema)),
363370
}),
364371
storageLayout: z.record(z.object({ slot: schemas.Fr })),

0 commit comments

Comments
 (0)