Skip to content

fix: Fix Trezor signing and connecting#26882

Merged
Gudahtt merged 1 commit intodevelopfrom
fix-trezor-connections
Sep 4, 2024
Merged

fix: Fix Trezor signing and connecting#26882
Gudahtt merged 1 commit intodevelopfrom
fix-trezor-connections

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Sep 4, 2024

Description

Trezor signing and connecting was broken in a recent change that included an update to the @trezor/connect-web library (in #26143). The patch had to be rewritten as part of that update, but in this rewrite an underscore was missed in referencing a variable (the patch used this.settings rather than this._settings).

Additionally, two more changes have been applied to ensure the modified settings are used everywhere. One was present in the original patch but missing from the patch in #26143. The other was not present in the original patch (#23763) because the affected line was added in the library update, but it seems equally necessary.

Open in GitHub Codespaces

Related issues

Fixes #26875

Manual testing steps

Follow reproduction steps in #26875

Screenshots/Recordings

Before

See https://www.loom.com/share/3e1f3d2cc57247a5b02e0ff8d61babb8?sid=1b17e423-16cf-4260-a1ed-674441e25b3a

After:

Screen.Recording.2024-09-03.at.21.55.10.mov

(I stopped partway through connecting, I was already past the point of it crashing by then).

Pre-merge author checklist

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.

@Gudahtt Gudahtt added team-accounts-framework Accounts team team-extension-platform Extension Platform team team-hardware-wallets-deprecated DEPRECATED: please use "team-accounts-framework" instead labels Sep 4, 2024
@Gudahtt Gudahtt force-pushed the fix-trezor-connections branch from 1daedb7 to eb0766e Compare September 4, 2024 00:18
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the underscore was missing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same settings object is referenced here, so we'd want to use the same modifications. This was present in the original patch

Copy link
Copy Markdown
Member Author

@Gudahtt Gudahtt Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second call to events_2.POPUP.INIT was not present in v9.2.2, but it is present here in v9.3.0

See:
9.2.2: https://npmfs.com/package/@trezor/connect-web/9.2.2/lib/popup/index.js
9.3.0: https://npmfs.com/package/@trezor/connect-web/9.3.0/lib/popup/index.js

Trezor signing and connecting was broken in a recent change that
included an update to the `@trezor/connect-web` library (in #26143).
The patch had to be rewritten as part of that update, but in this
rewrite an underscore was missed in referencing a variable (the patch
used `this.settings` rather than `this._settings`).

Additionally, two more changes have been applied to ensure the modified
settings are used everywhere. One was present in the original patch but
missing from the patch in #26143. The other was not present in the
original patch (#23763) because the affected line was added in the
library update, but it seems equally necessary.

Fixes #26875
@Gudahtt Gudahtt force-pushed the fix-trezor-connections branch from eb0766e to 11d653e Compare September 4, 2024 00:22
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 4, 2024

@Gudahtt Gudahtt marked this pull request as ready for review September 4, 2024 00:29
@Gudahtt Gudahtt requested a review from a team as a code owner September 4, 2024 00:29
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.15%. Comparing base (1801174) to head (11d653e).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26882   +/-   ##
========================================
  Coverage    70.15%   70.15%           
========================================
  Files         1425     1425           
  Lines        49600    49600           
  Branches     13877    13877           
========================================
  Hits         34795    34795           
  Misses       14805    14805           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [11d653e]
Page Load Metrics (1634 ± 84 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint20921861572354170
domContentLoaded14332061161115273
load14412201163417584
domInteractive147434178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 84 Bytes (0.00%)

Copy link
Copy Markdown
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I have reviewed all code and manually tested both connecting trezor and signing+sending a transaction with trezor

Copy link
Copy Markdown
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and it works!

Copy link
Copy Markdown
Contributor

@MajorLift MajorLift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and successfully tested connecting trezor. Thanks for fixing this so quickly @Gudahtt! Just had one question:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we not using modifiedSettings in this branch both here and in the original patch because we want a longer request timeout for handshake events?

@@ -240,7 +241,7 @@ class PopupManager extends events_1.default {
         else if (message.type === events_2.POPUP.CORE_LOADED) {
+            var modifiedSettings = Object.assign({}, this.settings, { env: 'webextension' });
             this.channel.postMessage({
                 type: events_2.POPUP.HANDSHAKE,
-                payload: { settings: this.settings },
+                payload: { settings: modifiedSettings },
             });
             (_a = this.handshakePromise) === null || _a === void 0 ? void 0 : _a.resolve();
         }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. Maybe we should be using it here as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this for now, but this is worth following up on

@Gudahtt Gudahtt merged commit 97e0030 into develop Sep 4, 2024
@Gudahtt Gudahtt deleted the fix-trezor-connections branch September 4, 2024 11:15
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 4, 2024
@gauthierpetetin gauthierpetetin added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 11, 2024
@Gudahtt Gudahtt added release-12.1.2 Issue or pull request that will be included in release 12.1.2 and removed release-12.5.0 Issue or pull request that will be included in release 12.5.0 labels Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.1.2 Issue or pull request that will be included in release 12.1.2 team-accounts-framework Accounts team team-extension-platform Extension Platform team team-hardware-wallets-deprecated DEPRECATED: please use "team-accounts-framework" instead

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to add or sign Trezor account in v12.1.1

6 participants