OutPointProcessMap PcdCommitments serialization
This commit is contained in:
parent
7403f9261a
commit
a3de9e4666
23
src/pcd.rs
23
src/pcd.rs
@ -170,26 +170,9 @@ impl Pcd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize, Tsify)]
|
||||||
pub struct PcdCommitments(#[serde(with = "hex_array_btree")] BTreeMap<String, [u8; 32]>);
|
#[tsify(into_wasm_abi)]
|
||||||
|
pub struct PcdCommitments(#[serde(with = "hex_array_btree")] #[tsify(type = "Record<string, string>")] 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()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PcdCommitments {
|
impl PcdCommitments {
|
||||||
/// Creates a new commitments map with both permissioned and public data, + roles
|
/// Creates a new commitments map with both permissioned and public data, + roles
|
||||||
|
@ -10,7 +10,8 @@ use crate::{pcd::Member, process::Process};
|
|||||||
#[tsify(from_wasm_abi)]
|
#[tsify(from_wasm_abi)]
|
||||||
pub struct OutPointMemberMap(#[serde(with = "members_map")] pub HashMap<OutPoint, Member>);
|
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>);
|
pub struct OutPointProcessMap(#[serde(with = "outpoint_map")] pub HashMap<OutPoint, Process>);
|
||||||
|
|
||||||
// These helper functions convert a [u8; 32] to/from a hex string.
|
// These helper functions convert a [u8; 32] to/from a hex string.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user