Skip to content

[FLASK] Add signature insights#22485

Merged
hmalik88 merged 56 commits intodevelopfrom
hm/signature-insights
Feb 13, 2024
Merged

[FLASK] Add signature insights#22485
hmalik88 merged 56 commits intodevelopfrom
hm/signature-insights

Conversation

@hmalik88
Copy link
Copy Markdown
Contributor

@hmalik88 hmalik88 commented Jan 10, 2024

Per SIP-16, the signature insights implementation is being integrated.

Closes https://github.com/MetaMask/MetaMask-planning/issues/1778

Demo:

v2.mov

@github-actions
Copy link
Copy Markdown
Contributor

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 metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jan 10, 2024
@hmalik88 hmalik88 removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Jan 20, 2024
@hmalik88 hmalik88 added the team-snaps-deprecated DEPRECATED: please use "team-core-platform" instead label Jan 20, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [679285a]
Page Load Metrics (1198 ± 242 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint822861497134
domContentLoaded9185425024
load16021831198505242
domInteractive9185425024
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 1.15 KiB (0.02%)
  • common: -138 Bytes (-0.00%)

@hmalik88 hmalik88 added the flask label Jan 22, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [5a17f39]
Page Load Metrics (841 ± 54 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872141213215
domContentLoaded106323147
load737109084111354
domInteractive106323147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 186 Bytes (0.01%)
  • ui: 1.27 KiB (0.02%)
  • common: 993 Bytes (0.02%)

return () => {
cancelled = true;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's complaining otherwise
Screenshot 2024-02-07 at 7 08 23 AM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious, I didn't get that locally 🤔

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [6bb81a2]
Page Load Metrics (850 ± 20 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92166120199
domContentLoaded107827178
load7789358504120
domInteractive107827178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 186 Bytes (0.01%)
  • ui: 1.27 KiB (0.02%)
  • common: 993 Bytes (0.02%)

FrederikBolding
FrederikBolding previously approved these changes Feb 7, 2024
Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

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

Code and performance LGTM. I'm not entirely sure about the confirmation pages changes, so we should get those looked at.

Let's have:

  • Bowen do QA
  • Erik do design review
  • Someone from confirmations review and QA

this.setState({ showSignatureInsights: false });
}}
/>
)}
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.

Logic around setting showSignatureInsights can be moved into InsightWarnings or another component wrapping InsightWarnings.

This will avoid adding this state handling to all signature request pages individually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had decided to keep logic at the signature request page levels because some of the logic is dependent on other state such as showSignatureRequestWarning and didn't want to introduce more complexity.

///: BEGIN:ONLY_INCLUDE_IF(build-flask)
if (warnings?.length >= 1) {
return setIsShowingSigInsightWarnings(true);
}
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.

After signing page goes away, just curious is above code needed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is needed because this would lead to the insight warning modal opening for flask builds

jpuri
jpuri previously approved these changes Feb 7, 2024
GuillaumeRx
GuillaumeRx previously approved these changes Feb 7, 2024
Copy link
Copy Markdown
Contributor

@GuillaumeRx GuillaumeRx left a comment

Choose a reason for hiding this comment

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

LGTM

(NIT: I wonder if we could extract the insight warning logic in a hook to avoid code duplication. It seems like a lot of code is duplicated across all the different signature screens we have)

@hmalik88 hmalik88 dismissed stale reviews from GuillaumeRx, jpuri, and FrederikBolding via 157ecfe February 8, 2024 02:40
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [f04df1a]
Page Load Metrics (831 ± 31 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint88167120188
domContentLoaded10502184
load6999358316531
domInteractive10502184
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 186 Bytes (0.01%)
  • ui: 1.27 KiB (0.02%)
  • common: 993 Bytes (0.02%)

@seaona
Copy link
Copy Markdown
Member

seaona commented Feb 8, 2024

hi there 👋 , QA from Confirmations side is in progress and will take a couple of days. I will update this same comment with the findings.

1. No Insights in the First Signature on Personal Sign

Whenever I trigger a Personal Signature for the first time, I don't see the signature insights popup: after clicking sign, the signature is done.

no-warning-1st-signature.mp4

Repro:

  1. Install Signature Insights Snap
  2. Click the Reload button from extensions
  3. Unlock the Wallet
  4. Go to the test dapp
  5. Trigger a Personal Sign
  6. Accept --- see no inisghts have been displayed
  7. Try again -- now insights are correctly displayed

2. A Typed signature without domain address can bypass the Insights screen

Whenever I trigger a Typed Signature which does not have a verifying contract set, I can see how no Signature Insights are displayed.

This is related to this pre-existing issue and maybe it will be needed to fix separately 🤔 #21011

no-verifying-contract.mp4

Repro:

  1. Install Signature Insights Snap
  2. Trigger a Typed Signature with an empty domain address (you can comment the verifyingContract on the test dapp
  3. Click Sign
  4. See the signature is performed and no Signature Insights has been displayed

3. A couple of Small UI comments

I defer to the design and snaps teams to decide if that's the desired experience. Just reporting the behaviour I see:

3.1 Wrapping text

The Sign the request by metamask.github.io checkbox seems to be wrapped undesirably on eth_sign (it seems there is the same text length for eth_sign and the other signatures, but this one is wrapped)

Screenshot from 2024-02-08 12-57-41

Screenshot from 2024-02-08 12-57-53

3.2 Details for more than 1 snap

If I have 2 snaps giving Signature Insights, whenever the popup is open, I see 1 snap warning fully "unfolded" and the other one "folded"

2-warnings-1-unfolded.mp4

3.3 Scrolled down

Whenever the Signature Insights is open, I see that we are scrolled down to the bottom (you can see this easily if the warning is long enough). To confirm that's the desired behaviour with design

scrolled-bottom.mp4

4. Metric Events

It seems that the Snap Export Used { export: 'onSignature',...} event is not triggered in all signatures. Sometimes I see the event after some seconds and some times it does not appear at all.
Not sure if this is a pre-existing issue, or something new from this PR

snap-export-used-event.mp4

@seaona seaona added the DO-NOT-MERGE Pull requests that should not be merged label Feb 8, 2024
@FrederikBolding
Copy link
Copy Markdown
Member

@seaona

For 1 I believe this is simply a timing issue, we don't currently block the UI from proceeding while waiting for snaps to respond. We could if that is preferable, but currently don't.

For 2 I don't think this is a bug in the implementation but just how the example snap works, without a domain the example snap does not have any insight to show: https://github.com/MetaMask/snaps/blob/main/packages/examples/packages/signature-insights/src/index.ts#L84-L109

@seaona seaona removed the DO-NOT-MERGE Pull requests that should not be merged label Feb 9, 2024
@hmalik88
Copy link
Copy Markdown
Contributor Author

Merging with acknowledgement that the first point raised by @seaona is a prod blocker for transaction insights and signature insights. The UI issues will be addressed in a forthcoming PR. The inconsistency in the snap export event is due to throttling that we will remove for certain exports in another PR: #22917

@hmalik88 hmalik88 merged commit d47ae27 into develop Feb 13, 2024
@hmalik88 hmalik88 deleted the hm/signature-insights branch February 13, 2024 15:43
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2024
@metamaskbot metamaskbot added the release-11.12.0 Issue or pull request that will be included in release 11.12.0 label Feb 13, 2024
@ziedbrini ziedbrini added team-snaps-platform-deprecated DEPRECATED: please use "team-core-platform" instead (or "team-new-networks" for Solana snap issues) and removed team-snaps-deprecated DEPRECATED: please use "team-core-platform" instead labels Mar 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

flask INVALID-PR-TEMPLATE PR's body doesn't match template release-11.12.0 Issue or pull request that will be included in release 11.12.0 team-snaps-platform-deprecated DEPRECATED: please use "team-core-platform" instead (or "team-new-networks" for Solana snap issues)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants