identity.rs icon indicating copy to clipboard operation
identity.rs copied to clipboard

Add Wasm Stardust Client

Open cycraig opened this issue 2 years ago • 0 comments

Description of change

Add a client implementation for the Stardust Wasm bindings. The client helper traits are split following the suggestion in https://github.com/iotaledger/identity.rs/pull/963#discussion_r935140946. The trait names are pretty arbitrary, open to suggestions.

Note that this uses the @iota/iota.js package, which does not implement automatic input and output selection, so that was manually implemented in TypeScript to try match the behaviour of iota.rs. We have to use iota.js since it works in both the browser and Node.js, while iota.rs only maintains bindings for Node.js now.

The TypeScript client is not currently bundled in the package, that is being addressed in #971.

Added

  • Add StardustIdentityClient trait.
  • Add StardustIdentityClientExt trait.
  • Add "client" feature for the new traits without the iota-client dependency.
  • Add WasmStardustIdentityClient.
  • Add StardustIdentityClient TypeScript wrapper class.
  • Add examples-stardust Wasm examples.

Changed

  • Moved most StardustClientExt methods to the StardustIdentityClient traits.
  • Change StardustClientExt to error on network mismatch.
  • Change delete_did_output to promote the block until included.
  • Change delete_did_output to transfer native tokens too.
  • Change StardustDocument to allow empty state metadata.
  • Change state metadata fieldnames to use doc and meta, instead of document, metadata.

Links to any relevant issues

Part of #950.

Type of change

  • [ ] Bug fix (a non-breaking change which fixes an issue)
  • [ ] Enhancement (a non-breaking change which adds functionality)
  • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation Fix

How the change has been tested

The new Wasm Stardust examples include some asserts, most of this is manually tested through examples. If an output is incorrectly formed, the network just ignores it (appears to succeed, or rather "fails silently"), which makes it difficult to troubleshoot.

Change checklist

  • [x] I have followed the contribution guidelines for this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes

cycraig avatar Aug 03 '22 11:08 cycraig