Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate Wasm async function return types #501

Merged
merged 9 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<mainnet|devnet>/transaction/<messageId>
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))
Expand Down
132 changes: 95 additions & 37 deletions bindings/wasm/docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<dd></dd>
<dt><a href="#Network">Network</a></dt>
<dd></dd>
<dt><a href="#Receipt">Receipt</a></dt>
<dd></dd>
<dt><a href="#Service">Service</a></dt>
<dd></dd>
<dt><a href="#Timestamp">Timestamp</a></dt>
Expand Down Expand Up @@ -67,12 +69,12 @@
* [new Client()](#new_Client_new)
* _instance_
* [.network()](#Client+network) ⇒ [<code>Network</code>](#Network)
* [.publishDocument(document)](#Client+publishDocument) ⇒ <code>Promise.&lt;any&gt;</code>
* [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ <code>Promise.&lt;any&gt;</code>
* [.publishJSON(index, data)](#Client+publishJSON) ⇒ <code>Promise.&lt;any&gt;</code>
* [.resolve(did)](#Client+resolve) ⇒ <code>Promise.&lt;any&gt;</code>
* [.resolveHistory(did)](#Client+resolveHistory) ⇒ <code>Promise.&lt;any&gt;</code>
* [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ <code>Promise.&lt;any&gt;</code>
* [.publishDocument(document)](#Client+publishDocument) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
* [.publishDiff(message_id, diff)](#Client+publishDiff) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
* [.publishJSON(index, data)](#Client+publishJSON) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
* [.resolve(did)](#Client+resolve) ⇒ [<code>Promise.&lt;Document&gt;</code>](#Document)
* [.resolveHistory(did)](#Client+resolveHistory) ⇒ [<code>Promise.&lt;DocumentHistory&gt;</code>](#DocumentHistory)
* [.resolveDiffHistory(document)](#Client+resolveDiffHistory) ⇒ [<code>Promise.&lt;DiffChainHistory&gt;</code>](#DiffChainHistory)
* [.checkCredential(data)](#Client+checkCredential) ⇒ <code>Promise.&lt;any&gt;</code>
* [.checkPresentation(data)](#Client+checkPresentation) ⇒ <code>Promise.&lt;any&gt;</code>
* _static_
Expand All @@ -92,18 +94,18 @@ Returns the `Client` Tangle network.
**Kind**: instance method of [<code>Client</code>](#Client)
<a name="Client+publishDocument"></a>

### client.publishDocument(document) ⇒ <code>Promise.&lt;any&gt;</code>
### client.publishDocument(document) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
Publishes an `IotaDocument` to the Tangle.

**Kind**: instance method of [<code>Client</code>](#Client)

| Param | Type |
| --- | --- |
| document | <code>any</code> |
| document | [<code>Document</code>](#Document) |

<a name="Client+publishDiff"></a>

### client.publishDiff(message_id, diff) ⇒ <code>Promise.&lt;any&gt;</code>
### client.publishDiff(message_id, diff) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
Publishes a `DocumentDiff` to the Tangle.

**Kind**: instance method of [<code>Client</code>](#Client)
Expand All @@ -115,7 +117,7 @@ Publishes a `DocumentDiff` to the Tangle.

<a name="Client+publishJSON"></a>

### client.publishJSON(index, data) ⇒ <code>Promise.&lt;any&gt;</code>
### client.publishJSON(index, data) ⇒ [<code>Promise.&lt;Receipt&gt;</code>](#Receipt)
Publishes arbitrary JSON data to the specified index on the Tangle.

**Kind**: instance method of [<code>Client</code>](#Client)
Expand All @@ -127,7 +129,7 @@ Publishes arbitrary JSON data to the specified index on the Tangle.

<a name="Client+resolve"></a>

### client.resolve(did) ⇒ <code>Promise.&lt;any&gt;</code>
### client.resolve(did) ⇒ [<code>Promise.&lt;Document&gt;</code>](#Document)
**Kind**: instance method of [<code>Client</code>](#Client)

| Param | Type |
Expand All @@ -136,7 +138,7 @@ Publishes arbitrary JSON data to the specified index on the Tangle.

<a name="Client+resolveHistory"></a>

### client.resolveHistory(did) ⇒ <code>Promise.&lt;any&gt;</code>
### client.resolveHistory(did) ⇒ [<code>Promise.&lt;DocumentHistory&gt;</code>](#DocumentHistory)
Returns the message history of the given DID.

**Kind**: instance method of [<code>Client</code>](#Client)
Expand All @@ -147,7 +149,7 @@ Returns the message history of the given DID.

<a name="Client+resolveDiffHistory"></a>

### client.resolveDiffHistory(document) ⇒ <code>Promise.&lt;any&gt;</code>
### client.resolveDiffHistory(document) ⇒ [<code>Promise.&lt;DiffChainHistory&gt;</code>](#DiffChainHistory)
Returns the `DiffChainHistory` of a diff chain starting from a document on the
integration chain.

Expand Down Expand Up @@ -608,24 +610,24 @@ Parses a `DIDUrl` from the input string.

* [DiffChainHistory](#DiffChainHistory)
* _instance_
* [.chainData()](#DiffChainHistory+chainData) ⇒ <code>Array.&lt;any&gt;</code>
* [.spam()](#DiffChainHistory+spam) ⇒ <code>Array.&lt;any&gt;</code>
* [.chainData()](#DiffChainHistory+chainData) ⇒ [<code>Array.&lt;DocumentDiff&gt;</code>](#DocumentDiff)
* [.spam()](#DiffChainHistory+spam) ⇒ <code>Array.&lt;string&gt;</code>
* [.toJSON()](#DiffChainHistory+toJSON) ⇒ <code>any</code>
* _static_
* [.fromJSON(json)](#DiffChainHistory.fromJSON) ⇒ [<code>DiffChainHistory</code>](#DiffChainHistory)

<a name="DiffChainHistory+chainData"></a>

### diffChainHistory.chainData() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of the chain objects.
### diffChainHistory.chainData() ⇒ [<code>Array.&lt;DocumentDiff&gt;</code>](#DocumentDiff)
Returns an `Array` of the diff chain `DocumentDiffs`.

NOTE: this clones the field.

**Kind**: instance method of [<code>DiffChainHistory</code>](#DiffChainHistory)
<a name="DiffChainHistory+spam"></a>

### diffChainHistory.spam() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of `MessageIds` as strings.
### diffChainHistory.spam() ⇒ <code>Array.&lt;string&gt;</code>
Returns an `Array` of `MessageIds` as strings.

NOTE: this clones the field.

Expand Down Expand Up @@ -1161,43 +1163,43 @@ A DID Document's history and current state.

* [DocumentHistory](#DocumentHistory)
* _instance_
* [.integrationChainData()](#DocumentHistory+integrationChainData) ⇒ <code>Array.&lt;any&gt;</code>
* [.integrationChainSpam()](#DocumentHistory+integrationChainSpam) ⇒ <code>Array.&lt;any&gt;</code>
* [.diffChainData()](#DocumentHistory+diffChainData) ⇒ <code>Array.&lt;any&gt;</code>
* [.diffChainSpam()](#DocumentHistory+diffChainSpam) ⇒ <code>Array.&lt;any&gt;</code>
* [.integrationChainData()](#DocumentHistory+integrationChainData) ⇒ [<code>Array.&lt;Document&gt;</code>](#Document)
* [.integrationChainSpam()](#DocumentHistory+integrationChainSpam) ⇒ <code>Array.&lt;string&gt;</code>
* [.diffChainData()](#DocumentHistory+diffChainData) ⇒ [<code>Array.&lt;DocumentDiff&gt;</code>](#DocumentDiff)
* [.diffChainSpam()](#DocumentHistory+diffChainSpam) ⇒ <code>Array.&lt;string&gt;</code>
* [.toJSON()](#DocumentHistory+toJSON) ⇒ <code>any</code>
* _static_
* [.fromJSON(json)](#DocumentHistory.fromJSON) ⇒ [<code>DocumentHistory</code>](#DocumentHistory)

<a name="DocumentHistory+integrationChainData"></a>

### documentHistory.integrationChainData() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of integration chain `Documents`.
### documentHistory.integrationChainData() ⇒ [<code>Array.&lt;Document&gt;</code>](#Document)
Returns an `Array` of integration chain `Documents`.

NOTE: clones the data.

**Kind**: instance method of [<code>DocumentHistory</code>](#DocumentHistory)
<a name="DocumentHistory+integrationChainSpam"></a>

### documentHistory.integrationChainSpam() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of message id strings for "spam" messages on the same index
### documentHistory.integrationChainSpam() ⇒ <code>Array.&lt;string&gt;</code>
Returns an `Array` of message id strings for "spam" messages on the same index
as the integration chain.

NOTE: clones the data.

**Kind**: instance method of [<code>DocumentHistory</code>](#DocumentHistory)
<a name="DocumentHistory+diffChainData"></a>

### documentHistory.diffChainData() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of diff chain `DocumentDiffs`.
### documentHistory.diffChainData() ⇒ [<code>Array.&lt;DocumentDiff&gt;</code>](#DocumentDiff)
Returns an `Array` of diff chain `DocumentDiffs`.

NOTE: clones the data.

**Kind**: instance method of [<code>DocumentHistory</code>](#DocumentHistory)
<a name="DocumentHistory+diffChainSpam"></a>

### documentHistory.diffChainSpam() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of message id strings for "spam" messages on the same index
### documentHistory.diffChainSpam() ⇒ <code>Array.&lt;string&gt;</code>
Returns an `Array` of message id strings for "spam" messages on the same index
as the diff chain.

NOTE: clones the data.
Expand Down Expand Up @@ -1227,24 +1229,24 @@ Deserializes `DocumentHistory` from a JSON object.

* [IntegrationChainHistory](#IntegrationChainHistory)
* _instance_
* [.chainData()](#IntegrationChainHistory+chainData) ⇒ <code>Array.&lt;any&gt;</code>
* [.spam()](#IntegrationChainHistory+spam) ⇒ <code>Array.&lt;any&gt;</code>
* [.chainData()](#IntegrationChainHistory+chainData) ⇒ [<code>Array.&lt;Document&gt;</code>](#Document)
* [.spam()](#IntegrationChainHistory+spam) ⇒ <code>Array.&lt;string&gt;</code>
* [.toJSON()](#IntegrationChainHistory+toJSON) ⇒ <code>any</code>
* _static_
* [.fromJSON(json)](#IntegrationChainHistory.fromJSON) ⇒ [<code>IntegrationChainHistory</code>](#IntegrationChainHistory)

<a name="IntegrationChainHistory+chainData"></a>

### integrationChainHistory.chainData() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of the chain objects.
### integrationChainHistory.chainData() ⇒ [<code>Array.&lt;Document&gt;</code>](#Document)
Returns an `Array` of the integration chain `Documents`.

NOTE: this clones the field.

**Kind**: instance method of [<code>IntegrationChainHistory</code>](#IntegrationChainHistory)
<a name="IntegrationChainHistory+spam"></a>

### integrationChainHistory.spam() ⇒ <code>Array.&lt;any&gt;</code>
Returns a `js_sys::Array` of `MessageIds` as strings.
### integrationChainHistory.spam() ⇒ <code>Array.&lt;string&gt;</code>
Returns an `Array` of `MessageIds` as strings.

NOTE: this clones the field.

Expand Down Expand Up @@ -1506,6 +1508,62 @@ Parses the provided string to a `Network`.

### Network.devnet() ⇒ [<code>Network</code>](#Network)
**Kind**: static method of [<code>Network</code>](#Network)
<a name="Receipt"></a>

## Receipt
**Kind**: global class

* [Receipt](#Receipt)
* _instance_
* [.network](#Receipt+network) ⇒ [<code>Network</code>](#Network)
* [.messageId](#Receipt+messageId) ⇒ <code>string</code>
* [.networkId](#Receipt+networkId) ⇒ <code>string</code>
* [.nonce](#Receipt+nonce) ⇒ <code>string</code>
* [.toJSON()](#Receipt+toJSON) ⇒ <code>any</code>
* _static_
* [.fromJSON(json)](#Receipt.fromJSON) ⇒ [<code>Receipt</code>](#Receipt)

<a name="Receipt+network"></a>

### receipt.network ⇒ [<code>Network</code>](#Network)
Returns the associated IOTA Tangle `Network`.

**Kind**: instance property of [<code>Receipt</code>](#Receipt)
<a name="Receipt+messageId"></a>

### receipt.messageId ⇒ <code>string</code>
Returns the message `id`.

**Kind**: instance property of [<code>Receipt</code>](#Receipt)
<a name="Receipt+networkId"></a>

### receipt.networkId ⇒ <code>string</code>
Returns the message `network_id`.

**Kind**: instance property of [<code>Receipt</code>](#Receipt)
<a name="Receipt+nonce"></a>

### receipt.nonce ⇒ <code>string</code>
Returns the message `nonce`.

**Kind**: instance property of [<code>Receipt</code>](#Receipt)
<a name="Receipt+toJSON"></a>

### receipt.toJSON() ⇒ <code>any</code>
Serializes a `Receipt` as a JSON object.

**Kind**: instance method of [<code>Receipt</code>](#Receipt)
<a name="Receipt.fromJSON"></a>

### Receipt.fromJSON(json) ⇒ [<code>Receipt</code>](#Receipt)
Deserializes a `Receipt` from a JSON object.

**Kind**: static method of [<code>Receipt</code>](#Receipt)

| Param | Type |
| --- | --- |
| json | <code>any</code> |

<a name="Service"></a>

## Service
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/create_did.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/manipulate_did.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions bindings/wasm/examples/src/merkle_key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/private_tangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions bindings/wasm/examples/src/resolve_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/revoke_vc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading