MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.52k stars 4.7k forks source link

feat: Throw when encountering unexpected RPC method hooks #24357

Closed rekmarks closed 1 week ago

rekmarks commented 2 weeks ago

Description

Removes RPC handler hooks that had become unused. In order to prevent this from occurring again, also adds a check to fail immediately on dapp connections if extraneous hooks are provided. Finally, adds tests for createMethodMiddleware.js.

Note for reviewers

Pre-merge author checklist

Pre-merge reviewer checklist

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 78.57143% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 67.46%. Comparing base (d27a233) to head (38cf3c7). Report is 50 commits behind head on develop.

:exclamation: Current head 38cf3c7 differs from pull request most recent head 2c1d1a3. Consider uploading reports for the commit 2c1d1a3 to get more accurate results

Files Patch % Lines
...ib/rpc-method-middleware/createMethodMiddleware.js 77.78% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #24357 +/- ## =========================================== + Coverage 67.37% 67.46% +0.09% =========================================== Files 1278 1286 +8 Lines 49881 50111 +230 Branches 12944 13006 +62 =========================================== + Hits 33605 33805 +200 - Misses 16276 16306 +30 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

metamaskbot commented 2 weeks ago
Builds ready [350a322]
Page Load Metrics (659 ± 503 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5512473147
domContentLoaded7161021
load4426916591048503
domInteractive7161021
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)
github-actions[bot] commented 2 weeks ago

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

metamaskbot commented 1 week ago
Builds ready [3a118aa]
Page Load Metrics (297 ± 345 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5410970126
domContentLoaded86112115
load432475297719345
domInteractive86012115
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)
metamaskbot commented 1 week ago
Builds ready [de5d01f]
Page Load Metrics (634 ± 553 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint58143832110
domContentLoaded8261242
load4735186341152553
domInteractive8261242
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)
metamaskbot commented 1 week ago
Builds ready [62bbc83]
Page Load Metrics (984 ± 668 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint751431022211
domContentLoaded106318126
load6137259841392668
domInteractive106318126
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)
legobeat commented 1 week ago

It does seem like this could be handled more consistently at the type level by TypeScript, but I'm assuming the issue is that there is still a lot of unmigrated js code that will benefit from this in the meantime?

rekmarks commented 1 week ago

@legobeat there's definitely unmigrated JS code, but also the types for the method middleware and its handler + hooks pattern are currently broken and implemented in 3 different repositories.

🙃We're all trying to find the guy who did this...

I may try to wrangle the types once this is in.

metamaskbot commented 1 week ago
Builds ready [38cf3c7]
Page Load Metrics (736 ± 563 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint68142882211
domContentLoaded9391594
load5530677361172563
domInteractive9391594
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)
metamaskbot commented 1 week ago
Builds ready [5edfc0d]
Page Load Metrics (745 ± 567 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint5914384209
domContentLoaded9281363
load4728937451181567
domInteractive9281363
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -260 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)