-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add Wasm Stardust Client #975
Conversation
Add allow_empty to StardustDocument::unpack.
Sort inputs. Add some block validation checks. Fix unlocking logic. Fix consumeAmount, remainderAmount calculations.
Remove timestamps when unpacking an empty DID Document.
…feat/wasm-shimmer-client
Rust Stardust tests are failing due to the runner being banned from the faucet API. https://github.com/iotaledger/identity.rs/runs/7902204219?check_suite_focus=true |
Co-authored-by: Eike Haß <eike-hass@web.de>
…ger/identity.rs into feat/wasm-shimmer-client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for the massive effort here!
/// This trait is not intended to be implemented directly, a blanket implementation is | ||
/// provided for [`StardustIdentityClient`] implementers. | ||
#[async_trait::async_trait(? Send)] | ||
pub trait StardustIdentityClientExt: StardustIdentityClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we do the renaming from stardust to iota, I assume we'll get rid of the "Stardust" prefix.
So just IdentityClientExt
or ClientIdentityExt
would be good for this trait.
Since the other part of the trait, what is currently called StardustClientExt
is used for modifying the ledger (publishing, deleting) we could call it ClientIdentityWriteExt
or something to clarify its modifying nature. Just throwing ideas around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just match whatever the name is on the Rust side, likely IotaClientExt
/IotaIdentityClient
, to avoid ambiguity with other DID methods in the future.
Probably just:
IotaClient
for theget_network_hrp
,get_alias_output
,get_rent_structure
methods (sinceiota-client
usesClient
).IotaIdentityClient
fornew_did_output
etc.IotaIdentityClientExt
/IotaIdentityPublish
forpublish_did_output
,delete_did_output
? I wouldn't useWrite
since it doesn't match the terminology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense 👍
// Deactivation may only be performed by the state controller of the Alias Output. | ||
let deactivated_output: AliasOutput = client.deactivate_did_output(&did).await?; | ||
|
||
// Optional: reduce and reclaim the storage deposit, sending the tokens to the state controller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does that work? If the tokens no longer needed for the storage deposit are not enough to cover the deposit for a new basic output, that would fail, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? iota.rs
will try choose another Basic Output to combine it with to avoid dust outputs. I wrote logic to that effect in the previous PR too. Yes it can fail otherwise, but it's not generally the concern of the library, hence why we don't do it automatically.
comment_width = 120 | ||
format_code_in_doc_comments = true | ||
license_template_path = ".license_template" | ||
max_width = 120 | ||
normalize_comments = false | ||
normalize_doc_attributes = false | ||
tab_spaces = 2 | ||
wrap_comments = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was that removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It kept giving problems due to being a symlink and rustfmt
uses the config file in parent directories automatically, so this was an unnecessary copy anyway.
"node-fetch": "^2.6.7" | ||
}, | ||
"peerDependencies": { | ||
"@cycraig/iota-client-wasm": "^0.5.0-alpha.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be moved to the @iota
namespace or will that happen if and when the iota.rs team takes over those bindings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When or if iota.rs
allows me to merge in the bindings. I just put it under my account to avoid polluting the global namespace for now, it can be changed to whatever.
Description of change
Add a client implementation for the Stardust Wasm bindings. The client helper traits are split following the suggestion in #963 (comment). The trait names are pretty arbitrary, open to suggestions.
Supersedes #969. Previous PR used @iota/iota.js, which does not currently implement automatic input and output selection, so that was previously manually implemented in TypeScript to match the behaviour of
iota.rs
in #969. To avoid maintaining that complex logic, we opted to go with Wasm bindings toiota.rs
ourselves.This uses unofficial iota.rs Wasm bindings, We chose not to use the official
iota.rs
Node.js bindings initially since they don't work in the browser and require Rust to install.This also requires importing several new
npm
packages:@iota/iota.js
, and@iota/types
. But we would need to import them if usingiota.js
oriota.rs
Node.js bindings too, unless we duplicate certain functionality from them (even then@iota/types
would still be required).Added
StardustIdentityClient
trait.StardustIdentityClientExt
trait."client"
feature for the new traits without theiota-client
dependency.WasmStardustIdentityClient
.StardustIdentityClient
TypeScript wrapper class.examples-stardust
Wasm examples.Changed
StardustClientExt
methods to theStardustIdentityClient
traits.extract_documents_from_block
function with publicStardustDocument::unpack_from_block
.StardustClientExt
to error on network mismatch.delete_did_output
to promote the block until included.delete_did_output
to transfer native tokens too.StardustDocument
to allow empty state metadata.doc
andmeta
, instead ofdocument
,metadata
.Links to any relevant issues
Resolves #950.
Type of change
How the change has been tested
Run the new Wasm Stardust examples:
Change checklist