Skip to content
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

Fix disabled 'eth_sign' event & add 'Request Disabled' event type #18007

Merged
merged 10 commits into from
Mar 14, 2023

Conversation

digiwand
Copy link
Contributor

@digiwand digiwand commented Mar 6, 2023

Explanation

Fixes #17974

  • Fixes bug where 'Signature Approved' event was incorrectly called when 'eth_sign' rpc method is called while the method is disabled by advanced settings
  • Replaces 'Signature Approved' event with new 'Signature Failed' event when the disabled 'eth_sign' event is called (spec discussed here in Slack)

note:

  1. sometimes, the 'Signature Failed' effect may be received before 'Signature Request', but the 'sent_at' time still records it being sent earlier.
  2. clean-up code, including more use of constants, is applied to this follow-up PR Fix Sign-in With Ethereum (SIWE) metametric, add tests, and clean RPC method middleware event logic #18008

Screenshots/Screencaps

Before

After

Screen Shot 2023-03-13 at 12 10 39 PM

Screen Shot 2023-03-13 at 12 10 45 PM

Manual Testing Steps

  1. Open Segment or open background console for check the network requests to Segment
  2. Disable the functionality of eth_sign from MetaMask Advanced Settings
  3. On another window, go to test dapp
  4. Connect to test dapp
  5. Click Eth Sign
  6. See Signature Request and Request Denied events are fired. Signature Approval should no longer be fired.

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@digiwand digiwand requested a review from a team as a code owner March 6, 2023 19:55
@digiwand digiwand requested a review from hmalik88 March 6, 2023 19:55
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

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.

@digiwand
Copy link
Contributor Author

digiwand commented Mar 7, 2023

moving back to draft. More discussions are being had to plan how we will want to handle this event

edit:
ready for review again. We removed the Signature Request event here as well 485e700

@digiwand digiwand marked this pull request as ready for review March 7, 2023 19:33
method === MESSAGE_TYPE.ETH_SIGN &&
res.error?.code === errorCodes.rpc.methodNotFound;

const isDisabledRequest = isDisabledEthSignAdvancedSetting;
Copy link
Contributor

Choose a reason for hiding this comment

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

hey, reason for duplicating the variable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey, I did this for readability down the line. hope it helps, unless it's just me - In that case, happy to change it back

jpuri
jpuri previously approved these changes Mar 8, 2023
Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

Great work 👍

jpuri
jpuri previously approved these changes Mar 8, 2023
@digiwand digiwand requested a review from jpuri March 8, 2023 15:53
@metamaskbot
Copy link
Collaborator

Builds ready [5aa2298]
Page Load Metrics (1703 ± 72 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint108155127136
domContentLoaded14571967166714168
load14571975170315072
domInteractive14571967166714168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 287 bytes
  • ui: 0 bytes
  • common: 36 bytes

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #18007 (bf06192) into develop (d0417da) will increase coverage by 0.00%.
The diff coverage is 71.43%.

@@           Coverage Diff            @@
##           develop   #18007   +/-   ##
========================================
  Coverage    63.44%   63.44%           
========================================
  Files          903      903           
  Lines        35267    35281   +14     
  Branches      8920     8925    +5     
========================================
+ Hits         22373    22383   +10     
- Misses       12894    12898    +4     
Impacted Files Coverage Δ
shared/constants/metametrics.js 100.00% <ø> (ø)
...p/scripts/lib/createRPCMethodTrackingMiddleware.js 81.25% <71.43%> (-1.68%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

jpuri
jpuri previously approved these changes Mar 9, 2023
blackdevelopa
blackdevelopa previously approved these changes Mar 13, 2023
Copy link
Contributor

@blackdevelopa blackdevelopa left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@seaona seaona left a comment

Choose a reason for hiding this comment

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

oh I am still seeing the Signature Requested and Signature Approved event sent to Segment, with eth_sign disabled and no Request Disabled event thrown.

I believe I have the last changes 🤔 : could you double check this behaviour to discard it's just me? 🙏 :

segment-eth-sign.mp4

@digiwand
Copy link
Contributor Author

oof, great catch @seaona!

Derp.. when we decided to exclude Signature Request, I updated the code and moved the res.error?.code check up, except the response, res, doesn't receive the values at this point...

I'm reworking this PR now

@metamaskbot
Copy link
Collaborator

Builds ready [bf06192]
Page Load Metrics (1625 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint98165127178
domContentLoaded13661966160313163
load13661966162513665
domInteractive13661966160313163
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 291 bytes
  • ui: 0 bytes
  • common: 36 bytes

@seaona
Copy link
Contributor

seaona commented Mar 14, 2023

thank you @digiwand ! Now I can see that whenever we have eth_sign disabled, the events are fired:

  • Signature Requested
  • Signature Failed
eth_sign_disabled.mp4

When we have eth_sign enabled, I can see the correct requests too:

  • Signature Requested
  • Signature Approved or
  • Signature Rejected

@digiwand digiwand merged commit 5468c2c into develop Mar 14, 2023
@digiwand digiwand deleted the fix-disabled-eth-sign-event branch March 14, 2023 18:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: When eth_sign is disabled we fire a Signature Approved event everytime we call the RPC method
6 participants