diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index d62ae93d956..18b35f3338c 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -28,7 +28,11 @@ pub fn compile(src: String) -> JsValue { let compiled_program = noirc_driver::Driver::compile_file(path, language); ::from_serde(&compiled_program).unwrap() } + // Deserializes bytes into ACIR structure +#[deprecated( + note = "we have moved away from this serialization strategy. Call `acir_read_bytes` instead" +)] #[wasm_bindgen] pub fn acir_from_bytes(bytes: Vec) -> JsValue { console_error_panic_hook::set_once(); @@ -36,6 +40,9 @@ pub fn acir_from_bytes(bytes: Vec) -> JsValue { ::from_serde(&circuit).unwrap() } +#[deprecated( + note = "we have moved away from this serialization strategy. Call `acir_write_bytes` instead" +)] #[wasm_bindgen] pub fn acir_to_bytes(acir: JsValue) -> Vec { console_error_panic_hook::set_once(); @@ -43,6 +50,23 @@ pub fn acir_to_bytes(acir: JsValue) -> Vec { circuit.to_bytes() } +// Deserializes bytes into ACIR structure +#[wasm_bindgen] +pub fn acir_read_bytes(bytes: Vec) -> JsValue { + console_error_panic_hook::set_once(); + let circuit = Circuit::read(&*bytes).unwrap(); + ::from_serde(&circuit).unwrap() +} + +#[wasm_bindgen] +pub fn acir_write_bytes(acir: JsValue) -> Vec { + console_error_panic_hook::set_once(); + let circuit: Circuit = JsValueSerdeExt::into_serde(&acir).unwrap(); + let mut bytes = Vec::new(); + circuit.write(&mut bytes).unwrap(); + bytes +} + #[wasm_bindgen] pub fn build_info() -> JsValue { console_error_panic_hook::set_once();