-
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
Replace ClientMap
with Client
in Account
#582
Conversation
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.
Thanks for the changes, looks good overall. I'm wondering whether we still need IdentitySetup::network
, though.
Fix doc comment backticks.
Automatically determine the network for AccountBuilder::create_identity using the configured Client.
Should we expose the |
What is the advantage of exposing the client? The network can be obtained through |
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.
Thanks for the changes! Looks good to me.
To be able to access the |
I see, that makes sense. In #574 a getter for the storage was added, so maybe something similar will be required for the client as well. |
Description of change
Refactors the
Account
to use a singleClient
rather than aClientMap
, since eachAccount
only manages a single identity (which can only live on a single network/Tangle). This change slightly simplifies theAccount
andAccountBuilder
.This also means an
Account
will not be able to create both mainnet and devnet identities by default, which was a side-effect ofClientMap
automatically creating clients for both those networks by default.A minor downside of this refactor is that
AccountSetup
always needs aClient
on creation, which is an async operation. Previously theClients
were constructed lazily by theClientMap
. However, this change only affects our internal tests as far as I can see.Minor change: the private Tangle examples now set the
primary_node
rather than justnode
since the behaviour fornode
differs between Rust and Wasm: on Wasm the node is considered "synchronised", while in Rust the node is considered "un-synchronised" until a background task (fromiota-client
) marks it as "synchronised". This causes the Rust private Tangle examples to throw an error (when pointing to a running private Tangle or devnet or mainnet) since it considers all nodes to be "un-synchronised". We useprimary_node
since it bypasses this check.Added
AccountBuilder::client_builder
(in addition toAccountBuilder::client
to allow building a singleClient
or sharing an existingArc<Client>
).Changed
AccountBuilder::client
to takeArc<Client>
instead of aClientBuilder
closure.AccountBuilder::create_identity
to use the network from the configuredClient
rather thanIdentitySetup
.AccountBuilder::load_identity
to throw an error if the DID network does not match theClient
network, which would throw an error when publishing the document anyway.Client::publish_document
to throw an error if the DID network differs from theClient
network.Client::publish_diff
to throw an error if the DID network differs from theClient
network.Removed
Account::set_client
.IdentitySetup::network
.Links to any relevant issues
Fixes issue #531
Type of change
How the change has been tested
All tests and examples pass locally.
Change checklist