Skip to content

Commit

Permalink
chore: update Trezor Connect to v9.4.0, remove workarounds (#27112)
Browse files Browse the repository at this point in the history
This PR includes changes from PR #26749 by @martykan.
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

> With MV3, MetaMask started to use Trezor Connect inside an offscreen
environment, in a way that was previously unsupported and required a
workaround by patching the Trezor Connect library.
> 
> In recent versions of Trezor Connect, the library can handle working
in an offscreen environment correctly, without the need for the
workaround, which could cause issues with compatibility.
> 
> This PR removes the patch and updates the Trezor Connect library to
the latest version (v9.4.0).
> The change in manifest.json is due to new URL parameters, Firefox
needs the asterisk at the end to match the URL with them.
> I haven't removed the WebUSB device request which was added on
MetaMask's side in relation to the workaround, since it can improve UX
of the pairing process, but it could be removed if desired.
> 
> The dependency update affects Lavamoat, I am including the policy
changes in my commit, however let me know if you would like me to remove
them and handle them using your own process.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27112?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

> 1. Open accounts dropdown, "Add hardware wallet"
> 2. Select Trezor
> 3. Follow prompts to connect the device
> 4. See a list of accounts from the Trezor

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
vthomas13 authored Oct 11, 2024
1 parent a4484f2 commit 39e0251
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 354 deletions.
57 changes: 0 additions & 57 deletions .yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch

This file was deleted.

2 changes: 1 addition & 1 deletion app/manifest/v2/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"all_frames": true
},
{
"matches": ["*://connect.trezor.io/*/popup.html"],
"matches": ["*://connect.trezor.io/*/popup.html*"],
"js": ["vendor/trezor/content-script.js"]
}
],
Expand Down
2 changes: 1 addition & 1 deletion app/manifest/v3/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"all_frames": true
},
{
"matches": ["*://connect.trezor.io/*/popup.html"],
"matches": ["*://connect.trezor.io/*/popup.html*"],
"js": ["vendor/trezor/content-script.js"]
}
],
Expand Down
73 changes: 34 additions & 39 deletions lavamoat/build-system/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@
"@babel/core": true,
"@babel/core>@babel/helper-module-transforms>@babel/helper-module-imports": true,
"@babel/core>@babel/helper-module-transforms>@babel/helper-simple-access": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true,
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": true,
"depcheck>@babel/traverse": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
Expand Down Expand Up @@ -478,7 +477,7 @@
"@babel/preset-env>@babel/helper-plugin-utils": true,
"@babel/preset-env>@babel/plugin-syntax-async-generators": true,
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-environment-visitor": true
}
},
"@babel/preset-env>@babel/plugin-transform-async-to-generator": {
Expand All @@ -494,14 +493,14 @@
"@babel/core": true,
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator>@babel/helper-wrap-function": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-environment-visitor": true
}
},
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator>@babel/helper-wrap-function": {
"packages": {
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-function-name": true
}
},
"@babel/preset-env>@babel/plugin-transform-block-scoped-functions": {
Expand Down Expand Up @@ -535,19 +534,25 @@
"@babel/core>@babel/helper-compilation-targets": true,
"@babel/preset-env>@babel/helper-plugin-utils": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-environment-visitor": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-function-name": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers": true,
"@babel/preset-env>@babel/plugin-transform-classes>globals": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true,
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": true
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-split-export-declaration": true,
"@babel/preset-env>@babel/plugin-transform-classes>globals": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": {
"packages": {
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-function-name": {
"packages": {
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": {
"packages": {
"@babel/core>@babel/types": true
Expand All @@ -558,14 +563,19 @@
"@babel/core": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true
"depcheck>@babel/traverse": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": {
"packages": {
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-split-export-declaration": {
"packages": {
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-computed-properties": {
"packages": {
"@babel/core": true,
Expand Down Expand Up @@ -673,7 +683,7 @@
"packages": {
"@babel/core>@babel/helper-compilation-targets": true,
"@babel/preset-env>@babel/helper-plugin-utils": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-function-name": true
}
},
"@babel/preset-env>@babel/plugin-transform-json-strings": {
Expand Down Expand Up @@ -716,10 +726,15 @@
"@babel/core": true,
"@babel/core>@babel/helper-module-transforms": true,
"@babel/preset-env>@babel/helper-plugin-utils": true,
"depcheck>@babel/traverse>@babel/helper-hoist-variables": true,
"@babel/preset-env>@babel/plugin-transform-modules-systemjs>@babel/helper-hoist-variables": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
"@babel/preset-env>@babel/plugin-transform-modules-systemjs>@babel/helper-hoist-variables": {
"packages": {
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-modules-umd": {
"builtin": {
"path.basename": true,
Expand Down Expand Up @@ -811,9 +826,7 @@
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": true,
"@babel/preset-env>@babel/plugin-transform-private-methods>@babel/helper-create-class-features-plugin>semver": true,
"@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true,
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": true
"depcheck>@babel/traverse": true
}
},
"@babel/preset-env>@babel/plugin-transform-private-methods>@babel/helper-create-class-features-plugin>semver": {
Expand Down Expand Up @@ -1042,6 +1055,7 @@
"@babel/preset-env>@babel/helper-plugin-utils": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true,
"@babel/preset-env>@babel/plugin-transform-private-methods>@babel/helper-create-class-features-plugin": true,
"@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true,
"@babel/preset-typescript>@babel/plugin-transform-typescript>@babel/plugin-syntax-typescript": true
}
},
Expand Down Expand Up @@ -2346,32 +2360,13 @@
"@babel/code-frame": true,
"@babel/core>@babel/generator": true,
"@babel/core>@babel/parser": true,
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true,
"babel/preset-env>b@babel/types": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true,
"depcheck>@babel/traverse>@babel/helper-hoist-variables": true,
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": true,
"depcheck>@babel/traverse>globals": true,
"nock>debug": true
}
},
"depcheck>@babel/traverse>@babel/helper-function-name": {
"packages": {
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true
}
},
"depcheck>@babel/traverse>@babel/helper-hoist-variables": {
"packages": {
"@babel/core>@babel/types": true
}
},
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": {
"packages": {
"@babel/core>@babel/types": true
}
},
"depcheck>cosmiconfig>parse-json": {
"packages": {
"@babel/code-frame": true,
Expand Down Expand Up @@ -6333,10 +6328,10 @@
"packages": {
"@babel/code-frame": true,
"@babel/core>@babel/generator": true,
"depcheck>@babel/traverse>@babel/helper-environment-visitor": true,
"depcheck>@babel/traverse>@babel/helper-function-name": true,
"depcheck>@babel/traverse>@babel/helper-hoist-variables": true,
"depcheck>@babel/traverse>@babel/helper-split-export-declaration": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-environment-visitor": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-function-name": true,
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-split-export-declaration": true,
"@babel/preset-env>@babel/plugin-transform-modules-systemjs>@babel/helper-hoist-variables": true,
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>@babel/parser": true,
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>@babel/types": true,
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>globals": true,
Expand Down
2 changes: 1 addition & 1 deletion offscreen/scripts/trezor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function init() {

TrezorConnectSDK.init({
...msg.params,
env: 'web',
env: 'webextension',
}).then(() => {
sendResponse();
});
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
"@babel/runtime@npm:^7.8.4": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
"@spruceid/siwe-parser@npm:1.1.3": "patch:@spruceid/siwe-parser@npm%3A2.1.0#~/.yarn/patches/@spruceid-siwe-parser-npm-2.1.0-060b7ede7a.patch",
"@spruceid/siwe-parser@npm:2.1.0": "patch:@spruceid/siwe-parser@npm%3A2.1.0#~/.yarn/patches/@spruceid-siwe-parser-npm-2.1.0-060b7ede7a.patch",
"@trezor/connect-web@npm:^9.2.2": "patch:@trezor/connect-web@npm%3A9.2.2#~/.yarn/patches/@trezor-connect-web-npm-9.2.2-a4de8e45fc.patch",
"ts-mixer@npm:^6.0.3": "patch:ts-mixer@npm%3A6.0.4#~/.yarn/patches/ts-mixer-npm-6.0.4-5d9747bdf5.patch",
"sucrase@npm:3.34.0": "^3.35.0",
"@expo/config/glob": "^10.3.10",
Expand All @@ -262,7 +261,6 @@
"@metamask/message-manager": "^10.1.0",
"@metamask/gas-fee-controller@npm:^15.1.1": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch",
"@metamask/nonce-tracker@npm:^5.0.0": "patch:@metamask/nonce-tracker@npm%3A5.0.0#~/.yarn/patches/@metamask-nonce-tracker-npm-5.0.0-d81478218e.patch",
"@trezor/connect-web@npm:^9.1.11": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch",
"@metamask/network-controller@npm:^17.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch",
"@metamask/network-controller@npm:^19.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch",
"@metamask/network-controller@npm:^20.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch",
Expand Down Expand Up @@ -371,7 +369,7 @@
"@sentry/types": "^8.33.1",
"@sentry/utils": "^8.33.1",
"@swc/core": "1.4.11",
"@trezor/connect-web": "patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch",
"@trezor/connect-web": "^9.4.0",
"@zxing/browser": "^0.1.4",
"@zxing/library": "0.20.0",
"await-semaphore": "^0.1.1",
Expand Down
Loading

0 comments on commit 39e0251

Please sign in to comment.