[DONE] Should Account Handle a Single Identity? #396
Replies: 1 comment 6 replies
-
Generally, I like the direction. It certainly simplifies the API of the I think we want to continue to have one stronghold, or more generally a Factory patternCreate an let account_config = /* ... */
let account_storage = AccountStorage::Stronghold(snapshot, Some(password));
let account_factory = AccountFactory::new(account_config, account_storage); and then instantiate account instances from the factory. The account instances inherit the storage and config from the factory. But how do we specify which identity an account manages? CreationSince I defined that an account should only represent a valid identity, the creation should happen on the factory, and return an let account = account_factory.create_identity(IdentityCreate::default()); UpdateWe want to update an identity that exists and that we have the keys for in our local stronghold. Now we need to somehow create an account that associates the new instance with the right keys in the storage. Something like let account = account_factory.load_account(did) This could be called loading, instantiating or anything else, but the point is we need some way to create an account that manages an existing identity. No-Factory approachIt's less obvious to me how this would work nicely without a factory. We want to instantiate new accounts directly from an let account = Account::create_identity(account_config, account_storage, IdentityCreate::default());
let account2 = Account::load_identity(account_config, account_storage, did); Seems like a mouthful to me, so the factory approach seems cleaner here. Was the thinking along the lines of such a factory or has the discussion gone in a different direction so far? Edit: At this point we could even rename the |
Beta Was this translation helpful? Give feedback.
-
Currently, the
Account
API allows for multiple identities. In order to allow this,Account
uses aHashMap
to match each identity to their tags. See the structures below:Although this might be convenient for certain use cases, this may also introduce unwanted complexity. Common operations would be more convenient when calling without a parameter. See the example below:
If
Account
were to handle a single identityupdate_identity
,delete_identy
, andresolve_identity
could be called without passing a parameter, we could also get rid of methods such aslist_identities
andfind_identity
. Other methods could also be simplified as well.For this change to be effective we should also make it easier to create new accounts. One idea would be to create a
AccountConfig
struct that would be configured with aStorage
,DidMethod
, and aClientMap
and that could be reused to create as many accounts as needed.Beta Was this translation helpful? Give feedback.
All reactions