Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions yarn-project/acir-simulator/src/abi_coder/decoder.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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}`);
Expand Down