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: Change visibility of AmountRow in contract interaction #29131

Merged
merged 7 commits into from
Dec 12, 2024

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Dec 12, 2024

Description

This PR makes two visibility change on AmountRow in transaction details.

  • Regardless of the amount or simulated value, if transaction details is toggled, it must show AmountRow
  • Whenever the Amount being sent doesn't match with a 5% buffer what we're displaying in the "You send" row of simulations UI for contract interactions, AmountRow must be visible.

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3783

Manual testing steps

Scenario I

  1. Trigger a contract interaction
  2. Enable advanced view
  3. With this change, you should now see the Amount row on the advanced view displaying the native asset value that is being sent along with the transaction.

Scenario II

  1. Trigger a contract interaction with the below payload (this payload should make the amount being sent don't match "You send" value within simulations)
  2. With this change, you should now see the Amount row on the default view displaying the native asset value that is being sent along with the transaction.
    { to: "0x4805a248c9611c22a43ce956489c9aadb6108433", value: "0xDE0B6B3A7640000", data: "0x3158952e", }

Screenshots/Recordings

Before

After

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.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Dec 12, 2024
@OGPoyraz OGPoyraz marked this pull request as ready for review December 12, 2024 11:28
@OGPoyraz OGPoyraz requested a review from a team as a code owner December 12, 2024 11:28
@@ -27,3 +33,80 @@ export const getAmountColors = (credit?: boolean, debit?: boolean) => {
}
return { color, backgroundColor };
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it would be good to add unit tests to these util methods

const simulationDataMock = {
tokenBalanceChanges: [],
nativeBalanceChange: {
difference: '0x3782dace9d900000' as Hex,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use decimal test number constants and convert them to hex using a util, so the numbers are human readable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Make sense, done in 9a6e27a

): boolean {
const value = transactionMeta?.txParams?.value ?? '0x0';
const nativeBalanceChange =
transactionMeta?.simulationData?.nativeBalanceChange;
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be nice to test cover util methods also

@metamaskbot
Copy link
Collaborator

Builds ready [7b160db]
Page Load Metrics (1728 ± 63 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15492064172712962
domContentLoaded15372029169912460
load15502064172813263
domInteractive258543168
backgroundConnect864292010
firstReactRender1876442311
getState56218178
initialActions01000
loadScripts11551551128610651
setupStore6431084
uiStartup17862348197114971
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.51 KiB (0.02%)
  • common: 0 Bytes (0.00%)

@@ -36,3 +41,103 @@ describe('getIsRevokeSetApprovalForAll', () => {
expect(actual).toEqual(true);
});
});

describe('hasValueAndNativeBalanceMismatch', () => {
Copy link
Contributor

@jpuri jpuri Dec 12, 2024

Choose a reason for hiding this comment

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

Nit: if method is simulation specific and places in utils, may be we name it as something simulationHasValueAndNativeBalanceMismatch

@OGPoyraz OGPoyraz enabled auto-merge December 12, 2024 12:50
@metamaskbot
Copy link
Collaborator

Builds ready [fcc975e]
Page Load Metrics (1826 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint25622171742372178
domContentLoaded15232163179415574
load15342224182615876
domInteractive278139157
backgroundConnect989332411
firstReactRender17188705024
getState593222713
initialActions01000
loadScripts10951662132714368
setupStore65411105
uiStartup182130172262323155
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.51 KiB (0.02%)
  • common: 0 Bytes (0.00%)

@OGPoyraz OGPoyraz added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit acdf7c6 Dec 12, 2024
77 checks passed
@OGPoyraz OGPoyraz deleted the 3783-changes-to-when-we-display-the-amount-row branch December 12, 2024 13:44
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2024
@metamaskbot metamaskbot added the release-12.10.1 Issue or pull request that will be included in release 12.10.1 label Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.10.1 Issue or pull request that will be included in release 12.10.1 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants