Closed andrewpeters9 closed 1 year ago
@andrewpeters9 I want to make sure I understand:
Is this proposing that the webhid and webusb connections would be done from inside a service worker that is created in the contentscript?
@danjm It's proposing that the connections (WebHid + WebUSB) would be done client-side, but their Keyrings would be called by the service worker. I'll DM you regarding a quick chat.
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days. Thank you for your contributions.
This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions.
Describe the bug
Current interactions with hardware wallets, namely Trezor and Ledger wallets, are not supported by Chrome MV3 changes.
Steps to reproduce
Some of the ways the issue can be reproduced:
KeyringController
if a Trezor or Ledger hardware wallet is stored in thevault
connectHardware
and transaction-related requestsError messages or log output
No response
Version
develop-oct16
Build type
No response
Browser
Chrome
Operating system
MacOS
Hardware wallet
No response
Additional context
General approaches on how to solve the issue:
iframe
creations), and the loading of dynamic content (i.e. the Trezor connect popup). This would be done through the elaboration of the Keyrings, and use of APIs such asWebHID
andWebUSB
Why I believe # 2 is the better choice:
WebUSB
(in-dev in Chromium, but potential lack of consensus cross-browser?): https://chromestatus.com/feature/5200265459269632WebHID
(developed (behind flag), but no cross-browser signal yet): https://chromestatus.com/feature/6305751386554368eth-keyring-controller
code in the long-termSuggested approach can be summarised into one verbose sentence:
Why not run all Hardware Keyrings solely in the frontend?
ServiceWorker
'sServiceWorker
execution first will speed up overall executionServiceWorker
execution only if that's decided upon in the futureeth-keyring-controller
Brief Overview of what the approach would entail:
Non-
metamask-extension
changes:Move non-MV3 compatible constructor code into a new Keyring method, potentially
init()
orbuild()
constructor ()
s can't be turned into a promiseServiceWorker
-side without issueto improve compatibility, these lines of code would still be executed during instantiation by default, just not when a feature flag is used (our MV3 flag). e.g.:
Background Changes:
Wrap all Hardware keyrings with a proxy, e.g.
HardwareKeyring
orHardwareKeyringWrapper
that implements all keyring methods (either programmatically or explicitly). An example of this wrapper would look something like this:KeyringEventBatcher
KeyringController
in a new way like so:KeyringEventBatcher
mempool is cleared periodically (perhaps every 500ms, as I know there are some limitations to how frequentlyServiceWorker
's can send messages to the clientcallBackgroundMethod
then receives these execution requests from theKeyringEventBatcher
callBackgroundMethod
to pick out only Promise responses from theKeyringEventBatcher
(yet to be investigated how to best implement)KeyringEventBatcher
tocallBackgroundMethod
can then be controlled via something along the lines ofClientKeyringController
or something along those linesClient-Background Comms Changes:
Instead, a cleaner approach appears to be to persist the initial promise (the
callBackgroundMethod
promise), this can be done by:callBackgroundMethod
's, likely around https://github.com/MetaMask/metamask-extension/blob/develop/ui/store/action-queue/index.js#L133 or somewhere else in theaction-queue/index.js
file. The proxy can intercept promise resolves/reject, and communicate with aClientKeyringController
(if a certain method is passed along) before resolving the promiseIf there's no preference, then I believe # 2 would be a better choice as it affords the opportunity for background-initiated promises that aren't related to call stacks which have
callBackgroundMethod
in them - it also appears less intrusive.Diagram of Proposed Solution: