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

Update to iota-client 2.0.1-rc.4 and iota-client-wasm 0.5.0-alpha.6 #1088

Merged
merged 35 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
257dcb6
Fixed Rust
Oct 27, 2022
fa56d95
fixed re-export
Oct 27, 2022
e1a6daf
Make cargo check work in bindings
Oct 27, 2022
8f38e48
Merge branch 'main' of github.com:iotaledger/identity.rs
Nov 1, 2022
dda417d
Merge branch 'main' of github.com:iotaledger/identity.rs
Nov 3, 2022
11197f0
adapted to latest iota client changes
Nov 3, 2022
a31ce6c
fixed conversion
Nov 3, 2022
a6b9799
Added debug logging. To be removed
Nov 5, 2022
c87efe3
Merge remote-tracking branch 'origin/main' into origin/integrate-late…
Nov 17, 2022
20af8a4
started incorporating ProtocolParametersDto
Nov 17, 2022
30582e7
fixed compilation
Nov 18, 2022
ec22f0b
removed redundant imports
Nov 18, 2022
4510ce5
allowed 7 character network names to make example run
Nov 18, 2022
efdd3ec
Use bech32_hrp in get_network_hrp
Nov 18, 2022
8d47335
removed redundant dependencies from examples
Nov 18, 2022
15f125e
move to the latest commit on iota.rs
Nov 18, 2022
0a89192
fix import
Nov 18, 2022
5c683b3
save local work before merging main
Nov 21, 2022
a88e452
merged origin/main
Nov 21, 2022
088ecff
made cargo check run
Nov 21, 2022
3052f5d
fixed bindings
Nov 21, 2022
eef6dfb
Changed Rust library to use new iota-client and iota-types releases
Nov 22, 2022
364ea29
removed logging
Nov 22, 2022
b26a6c2
fixed clippy
Nov 23, 2022
c45fd31
deleted redundant main.rs
Nov 23, 2022
8dcae77
removed leftover comments
Nov 23, 2022
3ed0182
Depend on new @iota/iota-client-wasm from npm
Nov 23, 2022
dda8aa8
Switch back to localhost based endpoints
Nov 23, 2022
cc4a992
resolved merge conflicts
Nov 23, 2022
94a09d0
ran npm install
Nov 23, 2022
aed7150
removed redundant dependency
Nov 23, 2022
540ef5c
remove iota-client-wasm from direct dependencies
Nov 23, 2022
5f0667d
update README
Nov 23, 2022
f5febb3
Removed spacing in Cargo.toml
Nov 24, 2022
5e64c76
fixed formatting
Nov 24, 2022
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
5 changes: 3 additions & 2 deletions bindings/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ crate-type = ["cdylib", "rlib"]
async-trait = { version = "0.1", default-features = false }
console_error_panic_hook = { version = "0.1" }
futures = { version = "0.3" }
# Pin until iota-client v2.0.1-rc.4 is released
iota-types = { version = "=1.0.0-rc.1", default-features = false, features = ["block", "api", "dto", "std"] }

iota-types = { version = "1.0.0-rc.3", default-features = false, features = ["block", "api", "dto", "std"] }

js-sys = { version = "0.3.60" }
proc_typescript = { version = "0.1.0", path = "./proc_typescript" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const API_ENDPOINT = "http://127.0.0.1:14265";
/** Demonstrate how to create a DID Document. */
async function main() {
// Create a new client with the given network endpoint.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
52 changes: 30 additions & 22 deletions bindings/wasm/docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ See <code>IVerifierOptions</code>.</p>
## Members

<dl>
<dt><a href="#StateMetadataEncoding">StateMetadataEncoding</a></dt>
<dd></dd>
<dt><a href="#StatusCheck">StatusCheck</a></dt>
<dd><p>Controls validation behaviour when checking whether or not a credential has been revoked by its
<a href="https://www.w3.org/TR/vc-data-model/#status"><code>credentialStatus</code></a>.</p>
Expand Down Expand Up @@ -148,8 +150,6 @@ This variant is the default used if no other variant is specified when construct
<dd></dd>
<dt><a href="#MethodRelationship">MethodRelationship</a></dt>
<dd></dd>
<dt><a href="#StateMetadataEncoding">StateMetadataEncoding</a></dt>
<dd></dd>
</dl>

## Functions
Expand Down Expand Up @@ -510,13 +510,13 @@ A method-agnostic DID Document.
* [.properties()](#CoreDocument+properties) ⇒ <code>Map.&lt;string, any&gt;</code>
* [.setPropertyUnchecked(key, value)](#CoreDocument+setPropertyUnchecked)
* [.service()](#CoreDocument+service) ⇒ [<code>Array.&lt;CoreService&gt;</code>](#CoreService)
* [.insertService(service)](#CoreDocument+insertService) ⇒ <code>boolean</code>
* [.removeService(didUrl)](#CoreDocument+removeService) ⇒ <code>boolean</code>
* [.insertService(service)](#CoreDocument+insertService)
* [.removeService(didUrl)](#CoreDocument+removeService) ⇒ [<code>CoreService</code>](#CoreService) \| <code>undefined</code>
* [.resolveService(query)](#CoreDocument+resolveService) ⇒ [<code>CoreService</code>](#CoreService) \| <code>undefined</code>
* [.methods(scope)](#CoreDocument+methods) ⇒ [<code>Array.&lt;CoreVerificationMethod&gt;</code>](#CoreVerificationMethod)
* [.verificationRelationships()](#CoreDocument+verificationRelationships) ⇒ <code>Array.&lt;(CoreDIDUrl\|CoreVerificationMethod)&gt;</code>
* [.insertMethod(method, scope)](#CoreDocument+insertMethod)
* [.removeMethod(did)](#CoreDocument+removeMethod)
* [.removeMethod(did)](#CoreDocument+removeMethod) ⇒ [<code>CoreVerificationMethod</code>](#CoreVerificationMethod) \| <code>undefined</code>
* [.resolveMethod(query, scope)](#CoreDocument+resolveMethod) ⇒ [<code>CoreVerificationMethod</code>](#CoreVerificationMethod) \| <code>undefined</code>
* [.attachMethodRelationship(didUrl, relationship)](#CoreDocument+attachMethodRelationship) ⇒ <code>boolean</code>
* [.detachMethodRelationship(didUrl, relationship)](#CoreDocument+detachMethodRelationship) ⇒ <code>boolean</code>
Expand Down Expand Up @@ -550,6 +550,12 @@ Returns a copy of the DID Document `id`.
### coreDocument.setId(id)
Sets the DID of the document.

### Warning

Changing the identifier can drastically alter the results of
[`Self::resolve_method`](CoreDocument::resolve_method()),
[`Self::resolve_service`](CoreDocument::resolve_service()) and the related [DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm.

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

| Param | Type |
Expand Down Expand Up @@ -642,6 +648,7 @@ Sets a custom property in the DID Document.
If the value is set to `null`, the custom property will be removed.

### WARNING

This method can overwrite existing properties like `id` and result in an invalid document.

**Kind**: instance method of [<code>CoreDocument</code>](#CoreDocument)
Expand All @@ -659,10 +666,10 @@ Returns a set of all [CoreService](#CoreService) in the document.
**Kind**: instance method of [<code>CoreDocument</code>](#CoreDocument)
<a name="CoreDocument+insertService"></a>

### coreDocument.insertService(service) ⇒ <code>boolean</code>
### coreDocument.insertService(service)
Add a new [CoreService](#CoreService) to the document.

Returns `true` if the service was added.
Errors if there already exists a service or verification method with the same id.

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

Expand All @@ -672,7 +679,7 @@ Returns `true` if the service was added.

<a name="CoreDocument+removeService"></a>

### coreDocument.removeService(didUrl) ⇒ <code>boolean</code>
### coreDocument.removeService(didUrl) ⇒ [<code>CoreService</code>](#CoreService) \| <code>undefined</code>
Remoce a [CoreService](#CoreService) identified by the given [CoreDIDUrl](#CoreDIDUrl) from the document.

Returns `true` if the service was removed.
Expand Down Expand Up @@ -729,7 +736,7 @@ Adds a new `method` to the document in the given `scope`.

<a name="CoreDocument+removeMethod"></a>

### coreDocument.removeMethod(did)
### coreDocument.removeMethod(did) ⇒ [<code>CoreVerificationMethod</code>](#CoreVerificationMethod) \| <code>undefined</code>
Removes all references to the specified Verification Method.

**Kind**: instance method of [<code>CoreDocument</code>](#CoreDocument)
Expand Down Expand Up @@ -1980,12 +1987,12 @@ Deserializes an instance from a JSON object.
* [.properties()](#IotaDocument+properties) ⇒ <code>Map.&lt;string, any&gt;</code>
* [.setPropertyUnchecked(key, value)](#IotaDocument+setPropertyUnchecked)
* [.service()](#IotaDocument+service) ⇒ [<code>Array.&lt;IotaService&gt;</code>](#IotaService)
* [.insertService(service)](#IotaDocument+insertService) ⇒ <code>boolean</code>
* [.removeService(did)](#IotaDocument+removeService) ⇒ <code>boolean</code>
* [.insertService(service)](#IotaDocument+insertService)
* [.removeService(did)](#IotaDocument+removeService) ⇒ [<code>IotaService</code>](#IotaService) \| <code>undefined</code>
* [.resolveService(query)](#IotaDocument+resolveService) ⇒ [<code>IotaService</code>](#IotaService) \| <code>undefined</code>
* [.methods(scope)](#IotaDocument+methods) ⇒ [<code>Array.&lt;IotaVerificationMethod&gt;</code>](#IotaVerificationMethod)
* [.insertMethod(method, scope)](#IotaDocument+insertMethod)
* [.removeMethod(did)](#IotaDocument+removeMethod)
* [.removeMethod(did)](#IotaDocument+removeMethod) ⇒ [<code>IotaVerificationMethod</code>](#IotaVerificationMethod) \| <code>undefined</code>
* [.resolveMethod(query, scope)](#IotaDocument+resolveMethod) ⇒ [<code>IotaVerificationMethod</code>](#IotaVerificationMethod) \| <code>undefined</code>
* [.attachMethodRelationship(didUrl, relationship)](#IotaDocument+attachMethodRelationship) ⇒ <code>boolean</code>
* [.detachMethodRelationship(didUrl, relationship)](#IotaDocument+detachMethodRelationship) ⇒ <code>boolean</code>
Expand All @@ -2012,7 +2019,7 @@ Deserializes an instance from a JSON object.
* _static_
* [.newWithId(id)](#IotaDocument.newWithId) ⇒ [<code>IotaDocument</code>](#IotaDocument)
* [.unpackFromOutput(did, aliasOutput, allowEmpty, tokenSupply)](#IotaDocument.unpackFromOutput) ⇒ [<code>IotaDocument</code>](#IotaDocument)
* [.unpackFromBlock(network, block, protocolResponseJson)](#IotaDocument.unpackFromBlock) ⇒ [<code>Array.&lt;IotaDocument&gt;</code>](#IotaDocument)
* [.unpackFromBlock(network, block, protocol_parameters)](#IotaDocument.unpackFromBlock) ⇒ [<code>Array.&lt;IotaDocument&gt;</code>](#IotaDocument)
* [.fromJSON(json)](#IotaDocument.fromJSON) ⇒ [<code>IotaDocument</code>](#IotaDocument)

<a name="new_IotaDocument_new"></a>
Expand Down Expand Up @@ -2071,6 +2078,7 @@ Sets a custom property in the DID Document.
If the value is set to `null`, the custom property will be removed.

### WARNING

This method can overwrite existing properties like `id` and result in an invalid document.

**Kind**: instance method of [<code>IotaDocument</code>](#IotaDocument)
Expand All @@ -2088,7 +2096,7 @@ Return a set of all [IotaService](#IotaService) in the document.
**Kind**: instance method of [<code>IotaDocument</code>](#IotaDocument)
<a name="IotaDocument+insertService"></a>

### iotaDocument.insertService(service) ⇒ <code>boolean</code>
### iotaDocument.insertService(service)
Add a new [IotaService](#IotaService) to the document.

Returns `true` if the service was added.
Expand All @@ -2101,7 +2109,7 @@ Returns `true` if the service was added.

<a name="IotaDocument+removeService"></a>

### iotaDocument.removeService(did) ⇒ <code>boolean</code>
### iotaDocument.removeService(did) ⇒ [<code>IotaService</code>](#IotaService) \| <code>undefined</code>
Remove a [IotaService](#IotaService) identified by the given [IotaDIDUrl](#IotaDIDUrl) from the document.

Returns `true` if a service was removed.
Expand Down Expand Up @@ -2152,7 +2160,7 @@ Adds a new `method` to the document in the given `scope`.

<a name="IotaDocument+removeMethod"></a>

### iotaDocument.removeMethod(did)
### iotaDocument.removeMethod(did) ⇒ [<code>IotaVerificationMethod</code>](#IotaVerificationMethod) \| <code>undefined</code>
Removes all references to the specified Verification Method.

**Kind**: instance method of [<code>IotaDocument</code>](#IotaDocument)
Expand Down Expand Up @@ -2438,7 +2446,7 @@ encoded in the `AliasId` alone.

<a name="IotaDocument.unpackFromBlock"></a>

### IotaDocument.unpackFromBlock(network, block, protocolResponseJson) ⇒ [<code>Array.&lt;IotaDocument&gt;</code>](#IotaDocument)
### IotaDocument.unpackFromBlock(network, block, protocol_parameters) ⇒ [<code>Array.&lt;IotaDocument&gt;</code>](#IotaDocument)
Returns all DID documents of the Alias Outputs contained in the block's transaction payload
outputs, if any.

Expand All @@ -2452,7 +2460,7 @@ Errors if any Alias Output does not contain a valid or empty DID Document.
| --- | --- |
| network | <code>string</code> |
| block | <code>IBlock</code> |
| protocolResponseJson | <code>string</code> |
| protocol_parameters | <code>INodeInfoProtocol</code> |

<a name="IotaDocument.fromJSON"></a>

Expand Down Expand Up @@ -4055,6 +4063,10 @@ This is possible because Ed25519 is birationally equivalent to Curve25519 used b
| --- | --- |
| publicKey | <code>Uint8Array</code> |

<a name="StateMetadataEncoding"></a>

## StateMetadataEncoding
**Kind**: global variable
<a name="StatusCheck"></a>

## StatusCheck
Expand Down Expand Up @@ -4141,10 +4153,6 @@ Return after the first error occurs.

## MethodRelationship
**Kind**: global variable
<a name="StateMetadataEncoding"></a>

## StateMetadataEncoding
**Kind**: global variable
<a name="start"></a>

## start()
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/0_create_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function createIdentity(): Promise<{
walletAddressBech32: string;
did: IotaDID;
}> {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/1_update_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { API_ENDPOINT, createDid } from "../util";

/** Demonstrates how to update a DID document in an existing Alias Output. */
export async function updateIdentity() {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/2_resolve_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { API_ENDPOINT, createDid } from "../util";

/** Demonstrates how to resolve an existing DID in an Alias Output. */
export async function resolveIdentity() {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/3_deactivate_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { API_ENDPOINT, createDid } from "../util";

/** Demonstrates how to deactivate a DID in an Alias Output. */
export async function deactivateIdentity() {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/4_delete_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { API_ENDPOINT, createDid } from "../util";

/** Demonstrates how to delete a DID in an Alias Output, reclaiming the storage deposit. */
export async function deleteIdentity() {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/5_create_vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { API_ENDPOINT, createDid } from "../util";
* This Verifiable Credential can be verified by anyone, allowing Alice to take control of it and share it with whomever they please.
*/
export async function createVC() {
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/6_create_vp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function createVP() {
// Step 1: Create identities for the issuer and the holder.
// ===========================================================================

const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/0_basic/7_revoke_vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function revokeVC() {
// Create a Verifiable Credential.
// ===========================================================================

const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function didControlsDid() {
// ========================================================

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function didIssuesNft() {
// ==============================================

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/1_advanced/2_nft_owns_did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function nftOwnsDid() {
// =============================

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function didIssuesTokens() {
// ===========================================

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/examples/src/1_advanced/4_key_exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function keyExchange() {
// ==============================

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function customResolution() {
};

// Create a new Client to interact with the IOTA ledger.
const client = await Client.new({
const client = new Client({
primaryNode: API_ENDPOINT,
localPow: true,
});
Expand Down
15 changes: 11 additions & 4 deletions bindings/wasm/lib/iota_identity_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
IUTXOInput,
TransactionHelper,
} from "@iota/iota.js";
import type { INodeInfoProtocol } from "@iota/types";
import type { Client, INodeInfoWrapper, SecretManager } from "~iota-client-wasm";

/** Provides operations for IOTA DID Documents with Alias Outputs. */
Expand Down Expand Up @@ -47,14 +48,22 @@ export class IotaIdentityClient implements IIotaIdentityClient {
return info.nodeInfo.protocol.rentStructure;
}

async getTokenSupply(): Promise<BigInt> {
async getTokenSupply(): Promise<string> {
return await this.client.getTokenSupply();
}

/*
async getProtocolResponse(): Promise<string> {
return await this.client.getProtocolResponse();
}

*/

async getProtocolParameters(): Promise<INodeInfoProtocol> {
const protocolParameters: INodeInfoProtocol = await this.client.getProtocolParameters();
return protocolParameters;
}

/** Create a DID with a new Alias Output containing the given `document`.
*
* The `address` will be set as the state controller and governor unlock conditions.
Expand Down Expand Up @@ -114,15 +123,13 @@ export class IotaIdentityClient implements IIotaIdentityClient {
*/
async publishDidOutput(secretManager: SecretManager, aliasOutput: IAliasOutput): Promise<IotaDocument> {
const networkHrp = await this.getNetworkHrp();

// Publish block.
const [blockId, block] = await this.client.buildAndPostBlock(secretManager, {
outputs: [aliasOutput],
});
await this.client.retryUntilIncluded(blockId);

const protocolParams = await this.client.getProtocolResponse();

const protocolParams = await this.client.getProtocolParameters();
// Extract document with computed AliasId.
const documents = IotaDocument.unpackFromBlock(networkHrp, block, protocolParams);
if (documents.length < 1) {
Expand Down
Loading