Skip to content
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ use cairo_vm::vm::{
};
use conversions::byte_array::ByteArray;
use conversions::felt::{ToShortString, TryInferFormat};
use conversions::serde::NoLengthFeltVec;
use conversions::serde::deserialize::BufferReader;
use conversions::serde::serialize::CairoSerialize;
use conversions::serde::serialize::{CairoSerialize, SerializeToFeltVec};
use data_transformer::cairo_types::CairoU256;
use rand::prelude::StdRng;
use runtime::{
Expand Down Expand Up @@ -97,7 +98,13 @@ impl<'a> ExtensionLogic for ForgeExtension<'a> {
let output = self
.oracle_hint_service
.execute_cheatcode(oracle_selector, input_reader.into_remaining());
return Ok(CheatcodeHandlingResult::Handled(output));
let mut reader = BufferReader::new(&output);
let deserialized: Result<NoLengthFeltVec<Felt>, ByteArray> = reader.read()?;
let converted = deserialized
.map_err(|error| EnhancedHintError::OracleError { error })
.map(|r| r.serialize_to_vec());

return Ok(CheatcodeHandlingResult::Handled(converted?));
}

match selector {
Expand Down
2 changes: 2 additions & 0 deletions crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ pub enum EnhancedHintError {
StarknetApi(#[from] StarknetApiError),
#[error("Failed to parse {path} file")]
FileParsing { path: String },
#[error("{error}")]
Copy link
Member

@piotmag769 piotmag769 Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the conversion chain ByteArray -> String -> ByteArray a noop? It would be better to just have impl From<EnhancedHintError> for ByteArray at this point imo since this is what happens here

Copy link
Member Author

@cptartur cptartur Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's noop, or at least it should be. I'll try what you've suggested

OracleError { error: ByteArray },
}

impl From<BufferReadError> for EnhancedHintError {
Expand Down
Loading