feat: Implement wallet initialization library#8838
Conversation
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Hmm. I wonder if "instances" sounds a bit too vague. It's true they are instances of classes, but then so are lots of other things. For context, we discussed a unified term for controllers and services in this PR: https://github.com/MetaMask/decisions/pull/41#discussion_r1809429486. I had some ideas such as "messaging actor" (or just "actor"), but I think "messenger client" was the least worst option (and the one that Mark also agreed upon). "Messageable" was also a contender. Any of these options appeal to you? |
mcmire
left a comment
There was a problem hiding this comment.
Going in a good direction. Here are some thoughts and comments.
| : unknown; | ||
|
|
||
| export type InitFunctionArguments<Instance, InstanceMessenger> = { | ||
| state: InstanceState<Instance>; |
There was a problem hiding this comment.
Hmm. Services don't have state. So does this make sense as an argument to all init functions?
(Edit: I guess init functions for services don't need to care about this, is that the thought?)
There was a problem hiding this comment.
I guess init functions for services don't need to care about this, is that the thought
Essentially yes. Though we may be able to tighten the typing a bit by making InstanceState be null or something for services.
|
@metamaskbot publish-previews |
@mcmire I haven't spent much time thinking about this, when the prototyping started I don't believe we had adopted "messenger client" on the MetaMask clients yet. If that already is our decided preferred naming, I can make changes, but "messenger client" seems similarly vague and maybe even an overloaded term considering API clients, the MetaMask clients themselves (extension/mobile) etc. |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Yeah, it's not not a perfect name for sure. I purposefully avoided using the term "messenger client" in my presentation for similar reasons. I don't think we have adopted the term widely, so we could come up with a different one and no one would bat an eye. I guess we could go with "instance" for now and maybe something else will pop out later. |
|
@FrederikBolding This looks pretty good to me so far. Let me know when this is out of draft. |
Explanation
This PR implements a narrowly-scoped (as compared to the original feature branch) version of the wallet initialization library that only includes initializing the
KeyringController. This can eventually be used to demonstrate the integration of the library into the clients and serves as the base for future work.Overall it works in a similarly to the initialization pattern used in extension and mobile today, with some differences:
InitializationConfiguration. This object contains both a function to setup the messenger and the instance.InitializationConfiguration.messengeris expected to have access to actions/events necessary to initialize and operate the instance.There is no way to access the instances directly.The
Walletinstance provides access to the instances within using themessengerwhile also exposing a limited set of useful properties likestateandcontrollerMetadata.References
https://consensyssoftware.atlassian.net/browse/WPC-999
Checklist