From 1547025a8d35dbdaebd1b11e899e8fe958df5fbe Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:05:32 +0200 Subject: [PATCH 1/8] Add Promise return type --- bindings/wasm/docs/api-reference.md | 70 ++++++++++++++++++++++++--- bindings/wasm/src/tangle/client.rs | 27 +++++++---- bindings/wasm/src/tangle/mod.rs | 2 + bindings/wasm/src/tangle/network.rs | 18 +++---- bindings/wasm/src/tangle/receipt.rs | 73 +++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 25 deletions(-) create mode 100644 bindings/wasm/src/tangle/receipt.rs diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 70ea91936e..1cd4890f2a 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -27,6 +27,8 @@
Network
+
Receipt
+
Service
Timestamp
@@ -67,9 +69,9 @@ * [new Client()](#new_Client_new) * _instance_ * [.network()](#Client+network) ⇒ [Network](#Network) - * [.publishDocument(document)](#Client+publishDocument) ⇒ Promise.<any> - * [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ Promise.<any> - * [.publishJSON(index, data)](#Client+publishJSON) ⇒ Promise.<any> + * [.publishDocument(document)](#Client+publishDocument) ⇒ [Promise.<Receipt>](#Receipt) + * [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ [Promise.<Receipt>](#Receipt) + * [.publishJSON(index, data)](#Client+publishJSON) ⇒ [Promise.<Receipt>](#Receipt) * [.resolve(did)](#Client+resolve) ⇒ Promise.<any> * [.resolveHistory(did)](#Client+resolveHistory) ⇒ Promise.<any> * [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ Promise.<any> @@ -92,7 +94,7 @@ Returns the `Client` Tangle network. **Kind**: instance method of [Client](#Client) -### client.publishDocument(document) ⇒ Promise.<any> +### client.publishDocument(document) ⇒ [Promise.<Receipt>](#Receipt) Publishes an `IotaDocument` to the Tangle. **Kind**: instance method of [Client](#Client) @@ -103,7 +105,7 @@ Publishes an `IotaDocument` to the Tangle. -### client.publishDiff(message_id, diff) ⇒ Promise.<any> +### client.publishDiff(message_id, diff) ⇒ [Promise.<Receipt>](#Receipt) Publishes a `DocumentDiff` to the Tangle. **Kind**: instance method of [Client](#Client) @@ -115,7 +117,7 @@ Publishes a `DocumentDiff` to the Tangle. -### client.publishJSON(index, data) ⇒ Promise.<any> +### client.publishJSON(index, data) ⇒ [Promise.<Receipt>](#Receipt) Publishes arbitrary JSON data to the specified index on the Tangle. **Kind**: instance method of [Client](#Client) @@ -1506,6 +1508,62 @@ Parses the provided string to a `Network`. ### Network.devnet() ⇒ [Network](#Network) **Kind**: static method of [Network](#Network) + + +## Receipt +**Kind**: global class + +* [Receipt](#Receipt) + * _instance_ + * [.network](#Receipt+network) ⇒ [Network](#Network) + * [.messageId](#Receipt+messageId) ⇒ string + * [.networkId](#Receipt+networkId) ⇒ string + * [.nonce](#Receipt+nonce) ⇒ string + * [.toJSON()](#Receipt+toJSON) ⇒ any + * _static_ + * [.fromJSON(json)](#Receipt.fromJSON) ⇒ [Receipt](#Receipt) + + + +### receipt.network ⇒ [Network](#Network) +Returns the associated IOTA Tangle `Network`. + +**Kind**: instance property of [Receipt](#Receipt) + + +### receipt.messageId ⇒ string +Returns the message `id`. + +**Kind**: instance property of [Receipt](#Receipt) + + +### receipt.networkId ⇒ string +Returns the message `network_id`. + +**Kind**: instance property of [Receipt](#Receipt) + + +### receipt.nonce ⇒ string +Returns the message `nonce`. + +**Kind**: instance property of [Receipt](#Receipt) + + +### receipt.toJSON() ⇒ any +Serializes a `Receipt` as a JSON object. + +**Kind**: instance method of [Receipt](#Receipt) + + +### Receipt.fromJSON(json) ⇒ [Receipt](#Receipt) +Deserializes a `Receipt` from a JSON object. + +**Kind**: static method of [Receipt](#Receipt) + +| Param | Type | +| --- | --- | +| json | any | + ## Service diff --git a/bindings/wasm/src/tangle/client.rs b/bindings/wasm/src/tangle/client.rs index 432591ba41..e2ffc1a75a 100644 --- a/bindings/wasm/src/tangle/client.rs +++ b/bindings/wasm/src/tangle/client.rs @@ -16,6 +16,7 @@ use identity::iota::IotaDocument; use identity::iota::MessageId; use identity::iota::TangleResolve; use js_sys::Promise; +use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::future_to_promise; @@ -25,7 +26,7 @@ use crate::did::WasmDocument; use crate::did::WasmDocumentDiff; use crate::error::Result; use crate::error::WasmResult; -use crate::tangle::Config; +use crate::tangle::{Config, PromiseReceipt, WasmReceipt}; use crate::tangle::WasmNetwork; #[wasm_bindgen] @@ -74,7 +75,7 @@ impl Client { /// Publishes an `IotaDocument` to the Tangle. #[wasm_bindgen(js_name = publishDocument)] - pub fn publish_document(&self, document: &JsValue) -> Result { + pub fn publish_document(&self, document: &JsValue) -> Result { let document: IotaDocument = document.into_serde().wasm_result()?; let client: Rc = self.client.clone(); @@ -82,16 +83,18 @@ impl Client { client .publish_document(&document) .await + .map(WasmReceipt) + .map(Into::into) .wasm_result() - .and_then(|receipt| JsValue::from_serde(&receipt).wasm_result()) }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } /// Publishes a `DocumentDiff` to the Tangle. #[wasm_bindgen(js_name = publishDiff)] - pub fn publish_diff(&self, message_id: &str, diff: WasmDocumentDiff) -> Result { + pub fn publish_diff(&self, message_id: &str, diff: WasmDocumentDiff) -> Result { let message: MessageId = MessageId::from_str(message_id).wasm_result()?; let client: Rc = self.client.clone(); @@ -99,16 +102,18 @@ impl Client { client .publish_diff(&message, diff.deref()) .await + .map(WasmReceipt) + .map(Into::into) .wasm_result() - .and_then(|receipt| JsValue::from_serde(&receipt).wasm_result()) }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } /// Publishes arbitrary JSON data to the specified index on the Tangle. #[wasm_bindgen(js_name = publishJSON)] - pub fn publish_json(&self, index: &str, data: &JsValue) -> Result { + pub fn publish_json(&self, index: &str, data: &JsValue) -> Result { let client: Rc = self.client.clone(); let index = index.to_owned(); @@ -117,11 +122,13 @@ impl Client { client .publish_json(&index, &value) .await + .map(WasmReceipt) + .map(Into::into) .wasm_result() - .and_then(|receipt| JsValue::from_serde(&receipt).wasm_result()) }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } #[wasm_bindgen] diff --git a/bindings/wasm/src/tangle/mod.rs b/bindings/wasm/src/tangle/mod.rs index 4014aeef58..deead3ff35 100644 --- a/bindings/wasm/src/tangle/mod.rs +++ b/bindings/wasm/src/tangle/mod.rs @@ -5,8 +5,10 @@ pub use self::client::*; pub use self::config::*; pub use self::message::*; pub use self::network::*; +pub use self::receipt::*; mod client; mod config; mod message; mod network; +mod receipt; diff --git a/bindings/wasm/src/tangle/network.rs b/bindings/wasm/src/tangle/network.rs index c5fd1928f4..76d7f48efa 100644 --- a/bindings/wasm/src/tangle/network.rs +++ b/bindings/wasm/src/tangle/network.rs @@ -1,7 +1,7 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use identity::iota::Network as IotaNetwork; +use identity::iota::Network; use wasm_bindgen::prelude::*; use crate::error::Result; @@ -9,24 +9,24 @@ use crate::error::WasmResult; #[wasm_bindgen(js_name = Network)] #[derive(Clone, Debug)] -pub struct WasmNetwork(IotaNetwork); +pub struct WasmNetwork(Network); #[wasm_bindgen(js_class = Network)] impl WasmNetwork { /// Parses the provided string to a `Network`. #[wasm_bindgen] pub fn try_from_name(name: String) -> Result { - IotaNetwork::try_from_name(name).map(Self).wasm_result() + Network::try_from_name(name).map(Self).wasm_result() } #[wasm_bindgen] pub fn mainnet() -> WasmNetwork { - Self(IotaNetwork::Mainnet) + Self(Network::Mainnet) } #[wasm_bindgen] pub fn devnet() -> WasmNetwork { - Self(IotaNetwork::Devnet) + Self(Network::Devnet) } /// Returns the node URL of the Tangle network. @@ -56,18 +56,18 @@ impl WasmNetwork { impl Default for WasmNetwork { fn default() -> Self { - IotaNetwork::default().into() + Network::default().into() } } -impl From for IotaNetwork { +impl From for Network { fn from(other: WasmNetwork) -> Self { other.0 } } -impl From for WasmNetwork { - fn from(other: IotaNetwork) -> Self { +impl From for WasmNetwork { + fn from(other: Network) -> Self { Self(other) } } diff --git a/bindings/wasm/src/tangle/receipt.rs b/bindings/wasm/src/tangle/receipt.rs new file mode 100644 index 0000000000..3d36bffd91 --- /dev/null +++ b/bindings/wasm/src/tangle/receipt.rs @@ -0,0 +1,73 @@ +// Copyright 2020-2021 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use identity::iota::Receipt; +use wasm_bindgen::prelude::*; + +use crate::error::Result; +use crate::error::WasmResult; +use crate::tangle::WasmNetwork; + +#[wasm_bindgen(js_name = Receipt, inspectable)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct WasmReceipt(pub(crate) Receipt); + +#[wasm_bindgen] +extern "C" { + // Workaround for Typescript type annotations on async function returns. + #[wasm_bindgen(typescript_type = "Promise")] + pub type PromiseReceipt; +} + +#[wasm_bindgen(js_class = Receipt)] +impl WasmReceipt { + /// Returns the associated IOTA Tangle `Network`. + #[wasm_bindgen(getter)] + pub fn network(&self) -> WasmNetwork { + WasmNetwork::from(self.0.network()) + } + + /// Returns the message `id`. + #[wasm_bindgen(getter = messageId)] + pub fn message_id(&self) -> String { + self.0.message_id().to_string() + } + + /// Returns the message `network_id`. + #[wasm_bindgen(getter = networkId)] + pub fn network_id(&self) -> String { + // NOTE: do not return u64 to avoid BigInt64Array/BigUint64Array compatibility issues. + self.0.network_id().to_string() + } + + /// Returns the message `nonce`. + #[wasm_bindgen(getter)] + pub fn nonce(&self) -> String { + // NOTE: do not return u64 to avoid BigInt64Array/BigUint64Array compatibility issues. + self.0.nonce().to_string() + } + + /// Serializes a `Receipt` as a JSON object. + #[wasm_bindgen(js_name = toJSON)] + pub fn to_json(&self) -> Result { + JsValue::from_serde(&self.0).wasm_result() + } + + /// Deserializes a `Receipt` from a JSON object. + #[wasm_bindgen(js_name = fromJSON)] + pub fn from_json(json: &JsValue) -> Result { + json.into_serde().map(Self).wasm_result() + } +} + +impl From for WasmReceipt { + fn from(receipt: Receipt) -> Self { + Self(receipt) + } +} + +impl From for Receipt { + fn from(receipt: WasmReceipt) -> Self { + receipt.0 + } +} From fe4110930e8b22e7ffb967ceb1a517cd768a0dd3 Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:14:35 +0200 Subject: [PATCH 2/8] Add Promise return type --- bindings/wasm/docs/api-reference.md | 4 ++-- bindings/wasm/src/did/mod.rs | 13 +++++++------ bindings/wasm/src/did/wasm_document.rs | 7 +++++++ bindings/wasm/src/tangle/client.rs | 16 +++++----------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 1cd4890f2a..711b198be7 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -72,7 +72,7 @@ * [.publishDocument(document)](#Client+publishDocument) ⇒ [Promise.<Receipt>](#Receipt) * [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ [Promise.<Receipt>](#Receipt) * [.publishJSON(index, data)](#Client+publishJSON) ⇒ [Promise.<Receipt>](#Receipt) - * [.resolve(did)](#Client+resolve) ⇒ Promise.<any> + * [.resolve(did)](#Client+resolve) ⇒ [Promise.<Document>](#Document) * [.resolveHistory(did)](#Client+resolveHistory) ⇒ Promise.<any> * [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ Promise.<any> * [.checkCredential(data)](#Client+checkCredential) ⇒ Promise.<any> @@ -129,7 +129,7 @@ Publishes arbitrary JSON data to the specified index on the Tangle. -### client.resolve(did) ⇒ Promise.<any> +### client.resolve(did) ⇒ [Promise.<Document>](#Document) **Kind**: instance method of [Client](#Client) | Param | Type | diff --git a/bindings/wasm/src/did/mod.rs b/bindings/wasm/src/did/mod.rs index 255413f5cf..3691801aa3 100644 --- a/bindings/wasm/src/did/mod.rs +++ b/bindings/wasm/src/did/mod.rs @@ -1,14 +1,15 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -mod wasm_did; -mod wasm_did_url; -mod wasm_document; -mod wasm_document_diff; -mod wasm_verification_method; - pub use self::wasm_did::WasmDID; pub use self::wasm_did_url::WasmDIDUrl; +pub use self::wasm_document::PromiseDocument; pub use self::wasm_document::WasmDocument; pub use self::wasm_document_diff::WasmDocumentDiff; pub use self::wasm_verification_method::WasmVerificationMethod; + +mod wasm_did; +mod wasm_did_url; +mod wasm_document; +mod wasm_document_diff; +mod wasm_verification_method; diff --git a/bindings/wasm/src/did/wasm_document.rs b/bindings/wasm/src/did/wasm_document.rs index d4c6eaa2a0..a649fbb4d4 100644 --- a/bindings/wasm/src/did/wasm_document.rs +++ b/bindings/wasm/src/did/wasm_document.rs @@ -39,6 +39,13 @@ use crate::service::Service; #[derive(Clone, Debug, PartialEq)] pub struct WasmDocument(pub(crate) IotaDocument); +#[wasm_bindgen] +extern "C" { + // Workaround for Typescript type annotations on async function returns. + #[wasm_bindgen(typescript_type = "Promise")] + pub type PromiseDocument; +} + #[wasm_bindgen(js_class = Document)] impl WasmDocument { /// Creates a new DID Document from the given `KeyPair`, network, and verification method diff --git a/bindings/wasm/src/tangle/client.rs b/bindings/wasm/src/tangle/client.rs index e2ffc1a75a..7cfdc73ff0 100644 --- a/bindings/wasm/src/tangle/client.rs +++ b/bindings/wasm/src/tangle/client.rs @@ -22,7 +22,7 @@ use wasm_bindgen_futures::future_to_promise; use crate::chain::DiffChainHistory; use crate::chain::WasmDocumentHistory; -use crate::did::WasmDocument; +use crate::did::{PromiseDocument, WasmDocument}; use crate::did::WasmDocumentDiff; use crate::error::Result; use crate::error::WasmResult; @@ -132,14 +132,7 @@ impl Client { } #[wasm_bindgen] - pub fn resolve(&self, did: &str) -> Result { - #[derive(Serialize)] - pub struct DocWrapper<'a> { - document: &'a IotaDocument, - #[serde(rename = "messageId")] - message_id: &'a MessageId, - } - + pub fn resolve(&self, did: &str) -> Result { let client: Rc = self.client.clone(); let did: IotaDID = did.parse().wasm_result()?; @@ -148,11 +141,12 @@ impl Client { .resolve(&did) .await .map(WasmDocument::from) - .map(JsValue::from) + .map(Into::into) .wasm_result() }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } /// Returns the message history of the given DID. From 8d4e61a64f8334149ed67e2710dcb192834d994a Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:22:40 +0200 Subject: [PATCH 3/8] Add Promise return type --- bindings/wasm/docs/api-reference.md | 8 ++++---- bindings/wasm/src/chain/document_history.rs | 13 +++++++++++++ bindings/wasm/src/chain/mod.rs | 4 +--- bindings/wasm/src/did/wasm_document.rs | 4 ++-- bindings/wasm/src/tangle/client.rs | 16 +++++++++------- bindings/wasm/src/tangle/receipt.rs | 2 +- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 711b198be7..ae97d4a3ae 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -73,8 +73,8 @@ * [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ [Promise.<Receipt>](#Receipt) * [.publishJSON(index, data)](#Client+publishJSON) ⇒ [Promise.<Receipt>](#Receipt) * [.resolve(did)](#Client+resolve) ⇒ [Promise.<Document>](#Document) - * [.resolveHistory(did)](#Client+resolveHistory) ⇒ Promise.<any> - * [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ Promise.<any> + * [.resolveHistory(did)](#Client+resolveHistory) ⇒ [Promise.<DocumentHistory>](#DocumentHistory) + * [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ [Promise.<DiffChainHistory>](#DiffChainHistory) * [.checkCredential(data)](#Client+checkCredential) ⇒ Promise.<any> * [.checkPresentation(data)](#Client+checkPresentation) ⇒ Promise.<any> * _static_ @@ -138,7 +138,7 @@ Publishes arbitrary JSON data to the specified index on the Tangle. -### client.resolveHistory(did) ⇒ Promise.<any> +### client.resolveHistory(did) ⇒ [Promise.<DocumentHistory>](#DocumentHistory) Returns the message history of the given DID. **Kind**: instance method of [Client](#Client) @@ -149,7 +149,7 @@ Returns the message history of the given DID. -### client.resolveDiffHistory(document) ⇒ Promise.<any> +### client.resolveDiffHistory(document) ⇒ [Promise.<DiffChainHistory>](#DiffChainHistory) Returns the `DiffChainHistory` of a diff chain starting from a document on the integration chain. diff --git a/bindings/wasm/src/chain/document_history.rs b/bindings/wasm/src/chain/document_history.rs index b86d4095cc..63a4765dfb 100644 --- a/bindings/wasm/src/chain/document_history.rs +++ b/bindings/wasm/src/chain/document_history.rs @@ -17,6 +17,19 @@ use crate::error::WasmResult; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct WasmDocumentHistory(DocumentHistory); +// Workaround for Typescript type annotations on async function returns. +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(typescript_type = "Promise")] + pub type PromiseDocumentHistory; + + #[wasm_bindgen(typescript_type = "Promise")] + pub type PromiseIntegrationChainHistory; + + #[wasm_bindgen(typescript_type = "Promise")] + pub type PromiseDiffChainHistory; +} + #[wasm_bindgen(js_class = DocumentHistory)] impl WasmDocumentHistory { /// Returns a `js_sys::Array` of integration chain `Documents`. diff --git a/bindings/wasm/src/chain/mod.rs b/bindings/wasm/src/chain/mod.rs index 3f287468bb..c566b05bb0 100644 --- a/bindings/wasm/src/chain/mod.rs +++ b/bindings/wasm/src/chain/mod.rs @@ -1,8 +1,6 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -pub use document_history::DiffChainHistory; -pub use document_history::IntegrationChainHistory; -pub use document_history::WasmDocumentHistory; +pub use document_history::*; mod document_history; diff --git a/bindings/wasm/src/did/wasm_document.rs b/bindings/wasm/src/did/wasm_document.rs index a649fbb4d4..95dadf12d6 100644 --- a/bindings/wasm/src/did/wasm_document.rs +++ b/bindings/wasm/src/did/wasm_document.rs @@ -10,8 +10,8 @@ use identity::crypto::merkle_key::Sha256; use identity::crypto::merkle_tree::Proof; use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::did::verifiable; use identity::did::MethodScope; +use identity::did::verifiable; use identity::iota::Error; use identity::iota::IotaDocument; use identity::iota::IotaVerificationMethod; @@ -39,9 +39,9 @@ use crate::service::Service; #[derive(Clone, Debug, PartialEq)] pub struct WasmDocument(pub(crate) IotaDocument); +// Workaround for Typescript type annotations on async function returns. #[wasm_bindgen] extern "C" { - // Workaround for Typescript type annotations on async function returns. #[wasm_bindgen(typescript_type = "Promise")] pub type PromiseDocument; } diff --git a/bindings/wasm/src/tangle/client.rs b/bindings/wasm/src/tangle/client.rs index 7cfdc73ff0..8d71aa5b10 100644 --- a/bindings/wasm/src/tangle/client.rs +++ b/bindings/wasm/src/tangle/client.rs @@ -20,7 +20,7 @@ use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::future_to_promise; -use crate::chain::DiffChainHistory; +use crate::chain::{DiffChainHistory, PromiseDiffChainHistory, PromiseDocumentHistory}; use crate::chain::WasmDocumentHistory; use crate::did::{PromiseDocument, WasmDocument}; use crate::did::WasmDocumentDiff; @@ -151,7 +151,7 @@ impl Client { /// Returns the message history of the given DID. #[wasm_bindgen(js_name = resolveHistory)] - pub fn resolve_history(&self, did: &str) -> Result { + pub fn resolve_history(&self, did: &str) -> Result { let did: IotaDID = did.parse().wasm_result()?; let client: Rc = self.client.clone(); @@ -160,11 +160,12 @@ impl Client { .resolve_history(&did) .await .map(WasmDocumentHistory::from) - .map(JsValue::from) + .map(Into::into) .wasm_result() }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } /// Returns the `DiffChainHistory` of a diff chain starting from a document on the @@ -173,7 +174,7 @@ impl Client { /// NOTE: the document must have been published to the tangle and have a valid message id and /// capability invocation method. #[wasm_bindgen(js_name = resolveDiffHistory)] - pub fn resolve_diff_history(&self, document: &WasmDocument) -> Result { + pub fn resolve_diff_history(&self, document: &WasmDocument) -> Result { let client: Rc = self.client.clone(); let iota_document: IotaDocument = document.0.clone(); @@ -182,11 +183,12 @@ impl Client { .resolve_diff_history(&iota_document) .await .map(DiffChainHistory::from) - .map(JsValue::from) + .map(Into::into) .wasm_result() }); - Ok(promise) + // WARNING: this does not validate the return type. Check carefully. + Ok(promise.unchecked_into::()) } /// Validates a credential with the DID Document from the Tangle. diff --git a/bindings/wasm/src/tangle/receipt.rs b/bindings/wasm/src/tangle/receipt.rs index 3d36bffd91..0b4efb2c17 100644 --- a/bindings/wasm/src/tangle/receipt.rs +++ b/bindings/wasm/src/tangle/receipt.rs @@ -12,9 +12,9 @@ use crate::tangle::WasmNetwork; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct WasmReceipt(pub(crate) Receipt); +// Workaround for Typescript type annotations on async function returns. #[wasm_bindgen] extern "C" { - // Workaround for Typescript type annotations on async function returns. #[wasm_bindgen(typescript_type = "Promise")] pub type PromiseReceipt; } From 53e32e57690dc22e45d27c8e54001e9ce8607247 Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:33:54 +0200 Subject: [PATCH 4/8] Update publishDocument to take Document instead of Any --- bindings/wasm/docs/api-reference.md | 2 +- bindings/wasm/examples/src/create_did.js | 2 +- bindings/wasm/examples/src/manipulate_did.js | 2 +- bindings/wasm/examples/src/merkle_key.js | 4 ++-- bindings/wasm/examples/src/private_tangle.js | 2 +- bindings/wasm/examples/src/resolve_history.js | 4 ++-- bindings/wasm/examples/src/revoke_vc.js | 2 +- bindings/wasm/src/tangle/client.rs | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index ae97d4a3ae..5ef6659c78 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -101,7 +101,7 @@ Publishes an `IotaDocument` to the Tangle. | Param | Type | | --- | --- | -| document | any | +| document | [Document](#Document) | diff --git a/bindings/wasm/examples/src/create_did.js b/bindings/wasm/examples/src/create_did.js index ef630ccb7b..d2f9556b74 100644 --- a/bindings/wasm/examples/src/create_did.js +++ b/bindings/wasm/examples/src/create_did.js @@ -29,7 +29,7 @@ async function createIdentity(clientConfig) { const client = Client.fromConfig(config); // Publish the Identity to the IOTA Network, this may take a few seconds to complete Proof-of-Work. - const receipt = await client.publishDocument(doc.toJSON()); + const receipt = await client.publishDocument(doc); doc.messageId = receipt.messageId; // Log the results. diff --git a/bindings/wasm/examples/src/manipulate_did.js b/bindings/wasm/examples/src/manipulate_did.js index b23d0606a3..99afbe41ca 100644 --- a/bindings/wasm/examples/src/manipulate_did.js +++ b/bindings/wasm/examples/src/manipulate_did.js @@ -51,7 +51,7 @@ async function manipulateIdentity(clientConfig) { doc.signSelf(key, doc.defaultSigningMethod().id.toString()); // Publish the Identity to the IOTA Network, this may take a few seconds to complete Proof-of-Work. - const updateReceipt = await client.publishDocument(doc.toJSON()); + const updateReceipt = await client.publishDocument(doc); // Log the results. logExplorerUrl("Identity Update:", clientConfig.network.toString(), updateReceipt.messageId); diff --git a/bindings/wasm/examples/src/merkle_key.js b/bindings/wasm/examples/src/merkle_key.js index c863f1d235..5234c9bed9 100644 --- a/bindings/wasm/examples/src/merkle_key.js +++ b/bindings/wasm/examples/src/merkle_key.js @@ -46,7 +46,7 @@ async function merkleKey(clientConfig) { // Publish the Identity to the IOTA Network and log the results. // This may take a few seconds to complete proof-of-work. - const receipt = await client.publishDocument(issuer.doc.toJSON()); + const receipt = await client.publishDocument(issuer.doc); logExplorerUrl("Identity Update:", clientConfig.network.toString(), receipt.messageId); // Prepare a credential subject indicating the degree earned by Alice @@ -84,7 +84,7 @@ async function merkleKey(clientConfig) { issuer.doc.previousMessageId = receipt.messageId; issuer.doc.updated = Timestamp.nowUTC(); issuer.doc.signSelf(issuer.key, issuer.doc.defaultSigningMethod().id.toString()); - const nextReceipt = await client.publishDocument(issuer.doc.toJSON()); + const nextReceipt = await client.publishDocument(issuer.doc); logExplorerUrl("Identity Update:", clientConfig.network.toString(), nextReceipt.messageId); // Check the verifiable credential is revoked diff --git a/bindings/wasm/examples/src/private_tangle.js b/bindings/wasm/examples/src/private_tangle.js index 07f86e7171..ad1d6b1622 100644 --- a/bindings/wasm/examples/src/private_tangle.js +++ b/bindings/wasm/examples/src/private_tangle.js @@ -39,7 +39,7 @@ async function createIdentityPrivateTangle(restURL, networkName) { const client = Client.fromConfig(config); // Publish the Identity to the IOTA Network, this may take a few seconds to complete Proof-of-Work. - const receipt = await client.publishDocument(doc.toJSON()); + const receipt = await client.publishDocument(doc); // Make sure the DID can be resolved on the private tangle const resolved = await client.resolve(doc.id.toString()); diff --git a/bindings/wasm/examples/src/resolve_history.js b/bindings/wasm/examples/src/resolve_history.js index 8e7235b0d3..460ef775f1 100644 --- a/bindings/wasm/examples/src/resolve_history.js +++ b/bindings/wasm/examples/src/resolve_history.js @@ -71,7 +71,7 @@ async function resolveHistory(clientConfig) { // Publish the updated DID Document to the Tangle, updating the integration chain. // This may take a few seconds to complete proof-of-work. - const intReceipt1 = await client.publishDocument(intDoc1.toJSON()); + const intReceipt1 = await client.publishDocument(intDoc1); // Log the results. logExplorerUrl("Int. Chain Update (1):", clientConfig.network.toString(), intReceipt1.messageId); @@ -175,7 +175,7 @@ async function resolveHistory(clientConfig) { intDoc2.previousMessageId = intReceipt1.messageId; intDoc2.updated = Timestamp.nowUTC(); intDoc2.signSelf(key, intDoc2.defaultSigningMethod().id.toString()); - const intReceipt2 = await client.publishDocument(intDoc2.toJSON()); + const intReceipt2 = await client.publishDocument(intDoc2); // Log the results. logExplorerUrl("Int. Chain Update (2):", clientConfig.network.toString(), intReceipt2.messageId); diff --git a/bindings/wasm/examples/src/revoke_vc.js b/bindings/wasm/examples/src/revoke_vc.js index 8c8ea1db1e..3b98b9dbc8 100644 --- a/bindings/wasm/examples/src/revoke_vc.js +++ b/bindings/wasm/examples/src/revoke_vc.js @@ -37,7 +37,7 @@ async function revokeVC(clientConfig) { issuer.doc.updated = Timestamp.nowUTC(); issuer.doc.signSelf(issuer.key, issuer.doc.defaultSigningMethod().id.toString()); // This is an integration chain update, so we publish the full document. - const {messageId} = await client.publishDocument(issuer.doc.toJSON()); + const {messageId} = await client.publishDocument(issuer.doc); // Log the resulting Identity update logExplorerUrl("Issuer Identity Update:", clientConfig.network.toString(), messageId); diff --git a/bindings/wasm/src/tangle/client.rs b/bindings/wasm/src/tangle/client.rs index 8d71aa5b10..79ad221501 100644 --- a/bindings/wasm/src/tangle/client.rs +++ b/bindings/wasm/src/tangle/client.rs @@ -75,8 +75,8 @@ impl Client { /// Publishes an `IotaDocument` to the Tangle. #[wasm_bindgen(js_name = publishDocument)] - pub fn publish_document(&self, document: &JsValue) -> Result { - let document: IotaDocument = document.into_serde().wasm_result()?; + pub fn publish_document(&self, document: &WasmDocument) -> Result { + let document: IotaDocument = document.0.clone(); let client: Rc = self.client.clone(); let promise: Promise = future_to_promise(async move { From 5717dff1505517b9c2ab44ab977c974e6afd2fc3 Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:49:10 +0200 Subject: [PATCH 5/8] Fix formatting --- bindings/wasm/src/did/wasm_document.rs | 2 +- bindings/wasm/src/tangle/client.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bindings/wasm/src/did/wasm_document.rs b/bindings/wasm/src/did/wasm_document.rs index 95dadf12d6..21066f9443 100644 --- a/bindings/wasm/src/did/wasm_document.rs +++ b/bindings/wasm/src/did/wasm_document.rs @@ -10,8 +10,8 @@ use identity::crypto::merkle_key::Sha256; use identity::crypto::merkle_tree::Proof; use identity::crypto::PrivateKey; use identity::crypto::PublicKey; -use identity::did::MethodScope; use identity::did::verifiable; +use identity::did::MethodScope; use identity::iota::Error; use identity::iota::IotaDocument; use identity::iota::IotaVerificationMethod; diff --git a/bindings/wasm/src/tangle/client.rs b/bindings/wasm/src/tangle/client.rs index 79ad221501..fefd72b596 100644 --- a/bindings/wasm/src/tangle/client.rs +++ b/bindings/wasm/src/tangle/client.rs @@ -16,18 +16,23 @@ use identity::iota::IotaDocument; use identity::iota::MessageId; use identity::iota::TangleResolve; use js_sys::Promise; -use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; +use wasm_bindgen::JsCast; use wasm_bindgen_futures::future_to_promise; -use crate::chain::{DiffChainHistory, PromiseDiffChainHistory, PromiseDocumentHistory}; +use crate::chain::DiffChainHistory; +use crate::chain::PromiseDiffChainHistory; +use crate::chain::PromiseDocumentHistory; use crate::chain::WasmDocumentHistory; -use crate::did::{PromiseDocument, WasmDocument}; +use crate::did::PromiseDocument; +use crate::did::WasmDocument; use crate::did::WasmDocumentDiff; use crate::error::Result; use crate::error::WasmResult; -use crate::tangle::{Config, PromiseReceipt, WasmReceipt}; +use crate::tangle::Config; +use crate::tangle::PromiseReceipt; use crate::tangle::WasmNetwork; +use crate::tangle::WasmReceipt; #[wasm_bindgen] #[derive(Debug)] From 1c06c4554265bce3356517f80c605c0a2b87f4ee Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 00:50:13 +0200 Subject: [PATCH 6/8] Fix README example --- bindings/wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/wasm/README.md b/bindings/wasm/README.md index 50e0d9db94..bf373ffa41 100644 --- a/bindings/wasm/README.md +++ b/bindings/wasm/README.md @@ -67,7 +67,7 @@ const client = identity.Client.fromConfig(config) // Publish the DID Document to the IOTA Tangle // The message can be viewed at https://explorer.iota.org//transaction/ -client.publishDocument(doc.toJSON()) +client.publishDocument(doc) .then((receipt) => { console.log("Tangle Message Receipt: ", receipt) console.log("Tangle Message Url:", doc.id.network.messageURL(receipt.messageId)) From 3f1541453bc0f9d26f21e33e4107320d90fde0f7 Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 09:28:59 +0200 Subject: [PATCH 7/8] Add Array return type annotations --- bindings/wasm/docs/api-reference.md | 48 +++++----- bindings/wasm/src/chain/document_history.rs | 100 ++++++++++++++------ 2 files changed, 93 insertions(+), 55 deletions(-) diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md index 5ef6659c78..4af8471601 100644 --- a/bindings/wasm/docs/api-reference.md +++ b/bindings/wasm/docs/api-reference.md @@ -610,24 +610,24 @@ Parses a `DIDUrl` from the input string. * [DiffChainHistory](#DiffChainHistory) * _instance_ - * [.chainData()](#DiffChainHistory+chainData) ⇒ Array.<any> - * [.spam()](#DiffChainHistory+spam) ⇒ Array.<any> + * [.chainData()](#DiffChainHistory+chainData) ⇒ [Array.<DocumentDiff>](#DocumentDiff) + * [.spam()](#DiffChainHistory+spam) ⇒ Array.<string> * [.toJSON()](#DiffChainHistory+toJSON) ⇒ any * _static_ * [.fromJSON(json)](#DiffChainHistory.fromJSON) ⇒ [DiffChainHistory](#DiffChainHistory) -### diffChainHistory.chainData() ⇒ Array.<any> -Returns a `js_sys::Array` of the chain objects. +### diffChainHistory.chainData() ⇒ [Array.<DocumentDiff>](#DocumentDiff) +Returns an `Array` of the diff chain `DocumentDiffs`. NOTE: this clones the field. **Kind**: instance method of [DiffChainHistory](#DiffChainHistory) -### diffChainHistory.spam() ⇒ Array.<any> -Returns a `js_sys::Array` of `MessageIds` as strings. +### diffChainHistory.spam() ⇒ Array.<string> +Returns an `Array` of `MessageIds` as strings. NOTE: this clones the field. @@ -1163,26 +1163,26 @@ A DID Document's history and current state. * [DocumentHistory](#DocumentHistory) * _instance_ - * [.integrationChainData()](#DocumentHistory+integrationChainData) ⇒ Array.<any> - * [.integrationChainSpam()](#DocumentHistory+integrationChainSpam) ⇒ Array.<any> - * [.diffChainData()](#DocumentHistory+diffChainData) ⇒ Array.<any> - * [.diffChainSpam()](#DocumentHistory+diffChainSpam) ⇒ Array.<any> + * [.integrationChainData()](#DocumentHistory+integrationChainData) ⇒ [Array.<Document>](#Document) + * [.integrationChainSpam()](#DocumentHistory+integrationChainSpam) ⇒ Array.<string> + * [.diffChainData()](#DocumentHistory+diffChainData) ⇒ [Array.<DocumentDiff>](#DocumentDiff) + * [.diffChainSpam()](#DocumentHistory+diffChainSpam) ⇒ Array.<string> * [.toJSON()](#DocumentHistory+toJSON) ⇒ any * _static_ * [.fromJSON(json)](#DocumentHistory.fromJSON) ⇒ [DocumentHistory](#DocumentHistory) -### documentHistory.integrationChainData() ⇒ Array.<any> -Returns a `js_sys::Array` of integration chain `Documents`. +### documentHistory.integrationChainData() ⇒ [Array.<Document>](#Document) +Returns an `Array` of integration chain `Documents`. NOTE: clones the data. **Kind**: instance method of [DocumentHistory](#DocumentHistory) -### documentHistory.integrationChainSpam() ⇒ Array.<any> -Returns a `js_sys::Array` of message id strings for "spam" messages on the same index +### documentHistory.integrationChainSpam() ⇒ Array.<string> +Returns an `Array` of message id strings for "spam" messages on the same index as the integration chain. NOTE: clones the data. @@ -1190,16 +1190,16 @@ NOTE: clones the data. **Kind**: instance method of [DocumentHistory](#DocumentHistory) -### documentHistory.diffChainData() ⇒ Array.<any> -Returns a `js_sys::Array` of diff chain `DocumentDiffs`. +### documentHistory.diffChainData() ⇒ [Array.<DocumentDiff>](#DocumentDiff) +Returns an `Array` of diff chain `DocumentDiffs`. NOTE: clones the data. **Kind**: instance method of [DocumentHistory](#DocumentHistory) -### documentHistory.diffChainSpam() ⇒ Array.<any> -Returns a `js_sys::Array` of message id strings for "spam" messages on the same index +### documentHistory.diffChainSpam() ⇒ Array.<string> +Returns an `Array` of message id strings for "spam" messages on the same index as the diff chain. NOTE: clones the data. @@ -1229,24 +1229,24 @@ Deserializes `DocumentHistory` from a JSON object. * [IntegrationChainHistory](#IntegrationChainHistory) * _instance_ - * [.chainData()](#IntegrationChainHistory+chainData) ⇒ Array.<any> - * [.spam()](#IntegrationChainHistory+spam) ⇒ Array.<any> + * [.chainData()](#IntegrationChainHistory+chainData) ⇒ [Array.<Document>](#Document) + * [.spam()](#IntegrationChainHistory+spam) ⇒ Array.<string> * [.toJSON()](#IntegrationChainHistory+toJSON) ⇒ any * _static_ * [.fromJSON(json)](#IntegrationChainHistory.fromJSON) ⇒ [IntegrationChainHistory](#IntegrationChainHistory) -### integrationChainHistory.chainData() ⇒ Array.<any> -Returns a `js_sys::Array` of the chain objects. +### integrationChainHistory.chainData() ⇒ [Array.<Document>](#Document) +Returns an `Array` of the integration chain `Documents`. NOTE: this clones the field. **Kind**: instance method of [IntegrationChainHistory](#IntegrationChainHistory) -### integrationChainHistory.spam() ⇒ Array.<any> -Returns a `js_sys::Array` of `MessageIds` as strings. +### integrationChainHistory.spam() ⇒ Array.<string> +Returns an `Array` of `MessageIds` as strings. NOTE: this clones the field. diff --git a/bindings/wasm/src/chain/document_history.rs b/bindings/wasm/src/chain/document_history.rs index 63a4765dfb..ce786dba2d 100644 --- a/bindings/wasm/src/chain/document_history.rs +++ b/bindings/wasm/src/chain/document_history.rs @@ -5,6 +5,7 @@ use identity::iota::ChainHistory; use identity::iota::DocumentDiff; use identity::iota::DocumentHistory; use identity::iota::IotaDocument; +use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use crate::did::WasmDocument; @@ -17,7 +18,7 @@ use crate::error::WasmResult; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct WasmDocumentHistory(DocumentHistory); -// Workaround for Typescript type annotations on async function returns. +// Workaround for Typescript type annotations on async function returns and arrays. #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "Promise")] @@ -28,15 +29,24 @@ extern "C" { #[wasm_bindgen(typescript_type = "Promise")] pub type PromiseDiffChainHistory; + + #[wasm_bindgen(typescript_type = "Array")] + pub type ArrayString; + + #[wasm_bindgen(typescript_type = "Array")] + pub type ArrayDocument; + + #[wasm_bindgen(typescript_type = "Array")] + pub type ArrayDocumentDiff; } #[wasm_bindgen(js_class = DocumentHistory)] impl WasmDocumentHistory { - /// Returns a `js_sys::Array` of integration chain `Documents`. + /// Returns an `Array` of integration chain `Documents`. /// /// NOTE: clones the data. #[wasm_bindgen(js_name = integrationChainData)] - pub fn integration_chain_data(&self) -> js_sys::Array { + pub fn integration_chain_data(&self) -> ArrayDocument { self .0 .integration_chain_data @@ -44,15 +54,16 @@ impl WasmDocumentHistory { .cloned() .map(WasmDocument::from) .map(JsValue::from) - .collect() + .collect::() + .unchecked_into::() } - /// Returns a `js_sys::Array` of message id strings for "spam" messages on the same index + /// Returns an `Array` of message id strings for "spam" messages on the same index /// as the integration chain. /// /// NOTE: clones the data. #[wasm_bindgen(js_name = integrationChainSpam)] - pub fn integration_chain_spam(&self) -> js_sys::Array { + pub fn integration_chain_spam(&self) -> ArrayString { self .0 .integration_chain_spam @@ -60,14 +71,15 @@ impl WasmDocumentHistory { .cloned() .map(|message_id| message_id.to_string()) .map(JsValue::from) - .collect() + .collect::() + .unchecked_into::() } - /// Returns a `js_sys::Array` of diff chain `DocumentDiffs`. + /// Returns an `Array` of diff chain `DocumentDiffs`. /// /// NOTE: clones the data. #[wasm_bindgen(js_name = diffChainData)] - pub fn diff_chain_data(&self) -> js_sys::Array { + pub fn diff_chain_data(&self) -> ArrayDocumentDiff { self .0 .diff_chain_data @@ -75,15 +87,16 @@ impl WasmDocumentHistory { .cloned() .map(WasmDocumentDiff::from) .map(JsValue::from) - .collect() + .collect::() + .unchecked_into::() } - /// Returns a `js_sys::Array` of message id strings for "spam" messages on the same index + /// Returns an `Array` of message id strings for "spam" messages on the same index /// as the diff chain. /// /// NOTE: clones the data. #[wasm_bindgen(js_name = diffChainSpam)] - pub fn diff_chain_spam(&self) -> js_sys::Array { + pub fn diff_chain_spam(&self) -> ArrayString { self .0 .diff_chain_spam @@ -91,7 +104,8 @@ impl WasmDocumentHistory { .cloned() .map(|message_id| message_id.to_string()) .map(JsValue::from) - .collect() + .collect::() + .unchecked_into::() } /// Serializes `DocumentHistory` as a JSON object. @@ -121,30 +135,53 @@ pub struct IntegrationChainHistory(ChainHistory); #[derive(Clone, Debug, Serialize, Deserialize)] pub struct DiffChainHistory(ChainHistory); +#[wasm_bindgen] +impl IntegrationChainHistory { + /// Returns an `Array` of the integration chain `Documents`. + /// + /// NOTE: this clones the field. + #[wasm_bindgen(js_name = chainData)] + pub fn chain_data(&self) -> ArrayDocument { + self + .0 + .chain_data + .iter() + .cloned() + .map(WasmDocument::from) + .map(JsValue::from) + .collect::() + .unchecked_into::() + } +} + +#[wasm_bindgen] +impl DiffChainHistory { + /// Returns an `Array` of the diff chain `DocumentDiffs`. + /// + /// NOTE: this clones the field. + #[wasm_bindgen(js_name = chainData)] + pub fn chain_data(&self) -> ArrayDocumentDiff { + self + .0 + .chain_data + .iter() + .cloned() + .map(WasmDocumentDiff::from) + .map(JsValue::from) + .collect::() + .unchecked_into::() + } +} + macro_rules! impl_wasm_chain_history { ($ident:ident, $ty:ty, $wasm_ty:ty) => { #[wasm_bindgen] impl $ident { - /// Returns a `js_sys::Array` of the chain objects. - /// - /// NOTE: this clones the field. - #[wasm_bindgen(js_name = chainData)] - pub fn chain_data(&self) -> js_sys::Array { - self - .0 - .chain_data - .iter() - .cloned() - .map(<$wasm_ty>::from) - .map(JsValue::from) - .collect() - } - - /// Returns a `js_sys::Array` of `MessageIds` as strings. + /// Returns an `Array` of `MessageIds` as strings. /// /// NOTE: this clones the field. #[wasm_bindgen] - pub fn spam(&self) -> js_sys::Array { + pub fn spam(&self) -> ArrayString { self .0 .spam @@ -152,7 +189,8 @@ macro_rules! impl_wasm_chain_history { .cloned() .map(|message_id| message_id.to_string()) .map(JsValue::from) - .collect() + .collect::() + .unchecked_into::() } /// Serializes as a JSON object. From 3ff249610708e4a01e1ca9a511fe0ca967331223 Mon Sep 17 00:00:00 2001 From: Craig Bester Date: Tue, 23 Nov 2021 10:17:01 +0200 Subject: [PATCH 8/8] Fix formatting --- bindings/wasm/src/chain/document_history.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/wasm/src/chain/document_history.rs b/bindings/wasm/src/chain/document_history.rs index ce786dba2d..5ba8f02777 100644 --- a/bindings/wasm/src/chain/document_history.rs +++ b/bindings/wasm/src/chain/document_history.rs @@ -5,8 +5,8 @@ use identity::iota::ChainHistory; use identity::iota::DocumentDiff; use identity::iota::DocumentHistory; use identity::iota::IotaDocument; -use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; +use wasm_bindgen::JsCast; use crate::did::WasmDocument; use crate::did::WasmDocumentDiff;