Skip to content

Commit

Permalink
attempt at making oracle.ts behave
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jan 7, 2025
1 parent be28e07 commit 1d2256b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions yarn-project/simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,19 +412,19 @@ export class Oracle {
* @param tSize - The size of the serialized object to return.
* @returns The data found flag and the serialized object concatenated in one array.
*/
async load([contract]: ACVMField[], [key]: ACVMField[], [tSize]: ACVMField[]): Promise<ACVMField[]> {
async load([contract]: ACVMField[], [key]: ACVMField[], [tSize]: ACVMField[]) {
const processedContract = AztecAddress.fromField(fromACVMField(contract));
const processedKey = fromACVMField(key);
const values = await this.typedOracle.load(processedContract, processedKey);
if (values === null) {
// No data was found so we set the data-found flag to 0 and we pad with zeros get the correct return size.
const processedTSize = frToNumber(fromACVMField(tSize));
logger.debug(`No data found for key ${processedKey} in contract ${processedContract}`);
return [0, ...Array(processedTSize).fill(0)].map(toACVMField);
return [toACVMField(0), Array(processedTSize).fill(toACVMField(0))];
} else {
// Data was found so we set the data-found flag to 1 and return it along with the data.
logger.debug(`Returning data for key ${processedKey} in contract ${processedContract}. Data: [${values}]`);
return [1, ...values].map(toACVMField);
return [toACVMField(1), values.map(toACVMField)];
}
}
}

0 comments on commit 1d2256b

Please sign in to comment.