feat: add `getSigningBytes`
MODIFY
signer-npm/src/lib.rs
signer-npm/src/lib.rs
@@ -996,3 +996,17 @@ pub fn get_cid(signed_message: JsValue) -> Result<String, JsValue> {
Ok(result)
}
+
+#[wasm_bindgen(js_name = getSigningBytes)]
+pub fn get_signing_bytes(unsigned_message: JsValue) -> Result<Vec<u8>, JsValue> {
+ set_panic_hook();
+
+ let unsigned_message_api: UnsignedMessageAPI = unsigned_message
+ .into_serde()
+ .map_err(|e| JsValue::from(format!("Error parsing parameters: {}", e)))?;
+
+ let result = filecoin_signer::get_signing_bytes(unsigned_message_api)
+ .map_err(|e| JsValue::from(format!("Error getting the cid: {}", e)))?;
+
+ Ok(result)
+}

MODIFY
signer/src/lib.rs
signer/src/lib.rs
@@ -1217,3 +1217,16 @@ pub fn get_cid(signed_message_api: SignedMessageAPI) -> Result<String, SignerErr
Ok(cid.to_string())
}
+
+/// Return the bytes to sign of an unsigned message
+///
+/// # Arguments
+///
+/// * `unsigned_message_api` - The unsigned message;
+pub fn get_signing_bytes(unsigned_message_api: UnsignedMessageAPI) -> Result<Vec<u8>, SignerError> {
+ let unsigned_message = UnsignedMessage::try_from(&unsigned_message_api)?;
+
+ let bytes = unsigned_message.to_signing_bytes();
+
+ Ok(bytes)
+}

feat: add `getSigningBytes`