Skip to content

Commit

Permalink
use validation lib to enforce sorting and ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Nov 12, 2024
1 parent 130f512 commit 8c28605
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion yarn-project/foundation/src/abi/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,14 @@ export const ContractArtifactSchema: ZodFor<ContractArtifact> = z.object({
aztecNrVersion: z.string().optional(),
functions: z.array(FunctionArtifactSchema),
outputs: z.object({
structs: z.record(z.array(AbiTypeSchema)),
structs: z.record(z.array(AbiTypeSchema)).transform(structs => {
for (const [key, value] of Object.entries(structs)) {
if (key === 'events' || key === 'functions') {
structs[key] = (value as StructType[]).sort((a, b) => a.path > b.path ? -1 : 1);
}
}
return structs;
}),
globals: z.record(z.array(AbiValueSchema)),
}),
storageLayout: z.record(z.object({ slot: schemas.Fr })),
Expand Down

0 comments on commit 8c28605

Please sign in to comment.