diff --git a/vm/src/vm/runners/cairo_pie.rs b/vm/src/vm/runners/cairo_pie.rs index 7444d76ecf..b822805eef 100644 --- a/vm/src/vm/runners/cairo_pie.rs +++ b/vm/src/vm/runners/cairo_pie.rs @@ -225,7 +225,7 @@ impl CairoPie { #[cfg(feature = "std")] pub fn from_zip_archive( mut zip: zip::ZipArchive, - ) -> Result { + ) -> Result { let metadata: CairoPieMetadata = parse_zip_file(zip.by_name("metadata.json")?)?; let execution_resources: ExecutionResources = parse_zip_file(zip.by_name("execution_resources.json")?)?; @@ -242,7 +242,7 @@ impl CairoPie { }; let memory = read_memory_file(zip.by_name("memory.bin")?, addr_size, felt_bytes)?; - Ok(CairoPie { + Ok(Self { metadata, memory, execution_resources, @@ -252,11 +252,19 @@ impl CairoPie { } #[cfg(feature = "std")] - pub fn from_file(path: &Path) -> Result { + pub fn from_bytes(bytes: &[u8]) -> Result { + let reader = std::io::Cursor::new(bytes); + let zip_archive = zip::ZipArchive::new(reader)?; + + Self::from_zip_archive(zip_archive) + } + + #[cfg(feature = "std")] + pub fn from_file(path: &Path) -> Result { let file = std::fs::File::open(path)?; let zip = zip::ZipArchive::new(file)?; - CairoPie::from_zip_archive(zip) + Self::from_zip_archive(zip) } }