diff --git a/yarn-project/acir-simulator/src/abi_coder/decoder.ts b/yarn-project/acir-simulator/src/abi_coder/decoder.ts index 9571f63a5aee..d83b0ed35eda 100644 --- a/yarn-project/acir-simulator/src/abi_coder/decoder.ts +++ b/yarn-project/acir-simulator/src/abi_coder/decoder.ts @@ -1,6 +1,11 @@ import { Fr } from '@aztec/foundation/fields'; import { ABIType, FunctionAbi } from '@aztec/foundation/abi'; +/** + * The type of our decoded ABI. + */ +type DecodedReturn = bigint | boolean | DecodedReturn[] | { [key: string]: DecodedReturn }; + /** * Decodes return values from a function call. * Missing support for integer and string. @@ -13,7 +18,7 @@ class ReturnValuesDecoder { * @param abiType - The type of the return value. * @returns The decoded return value. */ - private decodeReturn(abiType: ABIType): any { + private decodeReturn(abiType: ABIType): DecodedReturn { switch (abiType.kind) { case 'field': return this.getNextField().value; @@ -24,14 +29,14 @@ class ReturnValuesDecoder { for (let i = 0; i < abiType.length; i += 1) { array.push(this.decodeReturn(abiType.type)); } - break; + return array; } case 'struct': { - const struct: any = {}; + const struct: { [key: string]: DecodedReturn } = {}; for (const field of abiType.fields) { struct[field.name] = this.decodeReturn(field.type); } - break; + return struct; } default: throw new Error(`Unsupported type: ${abiType.kind}`);