Skip to content

Commit

Permalink
add canonical cbor to wasm wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
rooooooooob committed Feb 6, 2024
1 parent b69a64a commit fc80de1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/wasm/src/wasm_wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,13 @@ macro_rules! impl_wasm_cbor_api {
cml_core::serialization::Serialize::to_cbor_bytes(&self.0)
}

/**
* Serialize this type to CBOR bytes using canonical CBOR encodings
*/
pub fn to_canonical_cbor_bytes(&self) -> Vec<u8> {
cml_core::serialization::Serialize::to_canonical_cbor_bytes(&self.0)
}

/**
* Create this type from CBOR bytes
*/
Expand All @@ -440,6 +447,13 @@ macro_rules! impl_wasm_cbor_api {
hex::encode(self.to_cbor_bytes())
}

/**
* Serialize this type to CBOR bytes using canonical CBOR encodings as hex bytes
*/
pub fn to_canonical_cbor_hex(&self) -> String {
hex::encode(self.to_canonical_cbor_bytes())
}

/**
* Create this type from the CBOR bytes encoded as a hex string.
* This is useful for interfacing with CIP30
Expand Down

0 comments on commit fc80de1

Please sign in to comment.