OutPointProcessMap PcdCommitments serialization

This commit is contained in:
NicolasCantu 2025-04-03 14:51:51 +02:00 committed by Nicolas Cantu
parent 7403f9261a
commit a3de9e4666
2 changed files with 5 additions and 21 deletions

View File

@ -170,26 +170,9 @@ impl Pcd {
}
}
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
pub struct PcdCommitments(#[serde(with = "hex_array_btree")] BTreeMap<String, [u8; 32]>);
impl Tsify for PcdCommitments {
type JsType = JsValue;
const DECL: &'static str = "Record<string, string>";
fn from_js<T: Into<wasm_bindgen::JsValue>>(js: T) -> serde_json::Result<Self>
where
Self: DeserializeOwned, {
serde_wasm_bindgen::from_value(js.into()).map_err(|e| serde_json::Error::custom(e.to_string()))
}
fn into_js(&self) -> serde_json::Result<Self::JsType>
where
Self: Serialize, {
serde_wasm_bindgen::to_value(self)
.map_err(|e| serde_json::Error::custom(e.to_string()))
}
}
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize, Tsify)]
#[tsify(into_wasm_abi)]
pub struct PcdCommitments(#[serde(with = "hex_array_btree")] #[tsify(type = "Record<string, string>")] BTreeMap<String, [u8; 32]>);
impl PcdCommitments {
/// Creates a new commitments map with both permissioned and public data, + roles

View File

@ -10,7 +10,8 @@ use crate::{pcd::Member, process::Process};
#[tsify(from_wasm_abi)]
pub struct OutPointMemberMap(#[serde(with = "members_map")] pub HashMap<OutPoint, Member>);
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Tsify)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct OutPointProcessMap(#[serde(with = "outpoint_map")] pub HashMap<OutPoint, Process>);
// These helper functions convert a [u8; 32] to/from a hex string.