From 903bec611899396ff48a954ad3e01fddbe9046be Mon Sep 17 00:00:00 2001
From: Pedro Figueiredo
Date: Wed, 18 Sep 2024 14:56:23 +0100
Subject: [PATCH 1/3] fix: Estimated fee in redesigned screens (#27247)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
`maxFeePerGas`, `maxPriorityFeePerGas` and `estimatedBaseFee` are
decimal values that should be converted before being used inside
`multiplyHexes` and `addHexes`. `estimatedBaseFee` also needs to be
converted to wei.
[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27247?quickstart=1)
Fixes:
1. Go to this page...
2.
3.
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] 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.
---
shared/modules/conversion.utils.ts | 2 +-
.../contract-interaction.test.tsx | 8 +-
.../__snapshots__/approve.test.tsx.snap | 796 ++++++++++++++++++
.../contract-interaction.test.tsx.snap | 12 +-
.../info/hooks/useFeeCalculations.test.ts | 12 +-
.../confirm/info/hooks/useFeeCalculations.ts | 10 +-
.../gas-fees-details.test.tsx.snap | 4 +-
.../gas-fees-section.test.tsx.snap | 4 +-
8 files changed, 823 insertions(+), 25 deletions(-)
create mode 100644 ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
diff --git a/shared/modules/conversion.utils.ts b/shared/modules/conversion.utils.ts
index d9fd2262f843..75da336eb8e6 100644
--- a/shared/modules/conversion.utils.ts
+++ b/shared/modules/conversion.utils.ts
@@ -4,7 +4,7 @@ import { addHexPrefix, BN } from 'ethereumjs-util';
import { EtherDenomination } from '../constants/common';
import { Numeric, NumericValue } from './Numeric';
-export function decGWEIToHexWEI(decGWEI: number) {
+export function decGWEIToHexWEI(decGWEI: NumericValue) {
return new Numeric(decGWEI, 10, EtherDenomination.GWEI)
.toBase(16)
.toDenomination(EtherDenomination.WEI)
diff --git a/test/integration/confirmations/transactions/contract-interaction.test.tsx b/test/integration/confirmations/transactions/contract-interaction.test.tsx
index da015494fecf..75fbc41ce81d 100644
--- a/test/integration/confirmations/transactions/contract-interaction.test.tsx
+++ b/test/integration/confirmations/transactions/contract-interaction.test.tsx
@@ -280,10 +280,10 @@ describe('Contract Interaction Confirmation', () => {
expect(editGasFeesRow).toHaveTextContent('Estimated fee');
const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field');
- expect(firstGasField).toHaveTextContent('0.0084 ETH');
+ expect(firstGasField).toHaveTextContent('0.0001 ETH');
const editGasFeeNativeCurrency =
within(editGasFeesRow).getByTestId('native-currency');
- expect(editGasFeeNativeCurrency).toHaveTextContent('$28.50');
+ expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47');
expect(editGasFeesRow).toContainElement(getByTestId('edit-gas-fee-icon'));
const gasFeeSpeed = within(gasFeesSection).getByTestId(
@@ -375,8 +375,8 @@ describe('Contract Interaction Confirmation', () => {
const maxFee = getByTestId('gas-fee-details-max-fee');
expect(gasFeesSection).toContainElement(maxFee);
expect(maxFee).toHaveTextContent('Max fee');
- expect(maxFee).toHaveTextContent('0.2313 ETH');
- expect(maxFee).toHaveTextContent('$787.37');
+ expect(maxFee).toHaveTextContent('0.0023 ETH');
+ expect(maxFee).toHaveTextContent('$7.72');
const nonceSection = getByTestId('advanced-details-nonce-section');
expect(nonceSection).toBeInTheDocument();
diff --git a/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
new file mode 100644
index 000000000000..34fd469e0571
--- /dev/null
+++ b/ui/pages/confirmations/components/confirm/info/approve/__snapshots__/approve.test.tsx.snap
@@ -0,0 +1,796 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` renders component for approve request 1`] = `
+
+
+
+
+
+ Estimated changes
+
+
+
+
+
+ You're giving someone else permission to withdraw NFTs from your account.
+
+
+
+
+
+
+
+
+
+
+
+
+ 0x07614...3ad68
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0x2e0D7...5d09B
+
+
+
+
+
+
+
+
+
+ metamask.github.io
+
+
+
+
+
+
+ Interacting with
+
+
+
+
+
+
+
+ 0x07614...3ad68
+
+
+
+
+
+
+
+
+
+
+
+ 0.0001 ETH
+
+
+ $0.04
+
+
+
+
+
+
+
+
+
+ 🦊 Market
+
+
+
+ ~
+ 0 sec
+
+
+
+
+
+
+
+
+
+ 0.0011 ETH
+
+
+ $0.60
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0x2e0D7...5d09B
+
+
+
+
+
+
+
+
+`;
diff --git a/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap
index 2089d8e8f027..1f5570a11688 100644
--- a/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap
+++ b/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap
@@ -265,13 +265,13 @@ exports[` renders component for contract interaction
class="mm-box mm-text mm-text--body-md mm-box--margin-right-1 mm-box--color-text-default"
data-testid="first-gas-field"
>
- 0.004 ETH
+ 0.0001 ETH
- $2.20
+ $0.04
renders component for contract interaction
class="mm-box mm-text mm-text--body-md mm-box--margin-right-1 mm-box--color-text-default"
data-testid="first-gas-field"
>
- 0.004 ETH
+ 0.0001 ETH
- $2.20
+ $0.04
renders component for contract interaction
class="mm-box mm-text mm-text--body-md mm-box--margin-right-1 mm-box--color-text-default"
data-testid="first-gas-field"
>
- 0.004 ETH
+ 0.0001 ETH
- $2.20
+ $0.04