-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Use messenger actions instead of KeyringController
as constructor param
#1593
Conversation
Have you considered using actions instead, via the messaging system? As we migrate each controller to BaseControllerV2 and the controller messenger, the intent was to eventually replace all of these controller-method-constructor-parameters with actions. That way the messenger types represent a complete mapping of all controller relationships. |
Actions needed in this PR have been added to |
5304e78
to
6c82a88
Compare
4a4de0a
to
95d3e1f
Compare
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.
LGTM
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.
LGTM!
694f606
to
4774fe3
Compare
KeyringController
KeyringController
as constructor param
I'm not sure I see the value in this. The benefit of the callbacks is we are entirely decoupled from the signing itself as we can provide any logic we need and the client doesn't even have to use the In the mobile client for example, we manipulate the arguments to support the core I appreciate we're now using the core Perhaps the interface is poorly named, but the |
I am not sure I follow. How does this limit the controller to a single signer? You could still invoke other types of signatures within For context, we have been trying to avoid passing entire controllers as constructor parameters for many years now because we found it makes it difficult to understand how the controllers depend on each other. Quite a few times we've tried to make a breaking change to a controller and missed a spot where it was used because of controller references being passed around with different names, making them easier to miss. The messaging system itself was a solution to this problem as well; the goal being eventually that once all inter-controller communication is through this system, we could see in one single place how they relate to each other (and maybe even generate an image!), and use the type system to keep it up-to-date. |
Apologies for the confusion, I'm not referring to the types of signatures as in Previously, it was explicitly defined by the My worry is simply that by replacing it with the messenger, are we not coupling it further and saying the only thing that can sign things for the I agree with the principle that if you want to explicitly communicate with a controller, it is best to use the messenger, but is it the best use case here where the interface is simple and already explicitly defined and typed? To reframe my concern with another example, consider all the places we need to get the chain ID. This is a simple contract where we have no arguments but need to retrieve a string or a number. We typically use a constructor callback argument so it can be abstracted away, but would you argue it would be be better to use the messenger for that to request it from the |
I was interpreting the code on Though on that subject, I'm not sure we want to abstract signing from keyrings either. Keyrings are signers, that is effectively their sole purpose. Even snap keyrings are going to be exposed via the keyring controller. And the keyring controller itself acts to decouple individual keyrings from other parts of the codebase that require signatures. Could you elaborate further on the need for another intermediary interface/abstraction? I can't think of how that might be useful. |
I didn't have a specific use case in mind, I'm just trying to think of each controller as decoupled as possible. The interface existed initially to abstract the variations between the extension and core keyring controllers but as we're now using the core one exclusively, I do agree it would have minimal benefit here if the core Thanks for the discussion Mark, all seems good after all 😄 |
4774fe3
to
d387a9c
Compare
Explanation
The
SignatureController
accepts an entireKeyringController
instance as a constructor option, but would be better to use messenger actions instead, since this controller is a BaseControllerV2.References
@metamask/eth-keyring-controller
interactions metamask-extension#20510Changelog
@metamask/signature-controller
keyringController
constructor option: messenger actions are now being usedChecklist