From 29094e0764cb7e86e23cba074be6b62914e6f125 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 18 Sep 2024 21:42:26 +0100 Subject: [PATCH] fix: Estimated fee in redesigned screens (#27250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cherry-pick: (#27247) `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. Screenshot 2024-09-18 at 13 40 13 Screenshot 2024-09-18 at 13 39 49 Screenshot 2024-09-18 at 13 37 13 - [ ] 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27250?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] 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. ## **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. --- app/scripts/controllers/swaps/swaps.test.ts | 1 - shared/modules/conversion.utils.ts | 2 +- .../transactions/contract-interaction.test.tsx | 8 ++++---- .../__snapshots__/contract-interaction.test.tsx.snap | 12 ++++++------ .../confirm/info/hooks/useFeeCalculations.test.ts | 12 ++++++------ .../confirm/info/hooks/useFeeCalculations.ts | 10 ++++++---- .../__snapshots__/gas-fees-details.test.tsx.snap | 4 ++-- .../__snapshots__/gas-fees-section.test.tsx.snap | 4 ++-- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/scripts/controllers/swaps/swaps.test.ts b/app/scripts/controllers/swaps/swaps.test.ts index b13b5dff40ca..8b2fbd22d032 100644 --- a/app/scripts/controllers/swaps/swaps.test.ts +++ b/app/scripts/controllers/swaps/swaps.test.ts @@ -1171,7 +1171,6 @@ describe('SwapsController', function () { const swapsQuotePrefetchingRefreshTime = 0; const swapsStxBatchStatusRefreshTime = 0; const swapsStxGetTransactionsRefreshTime = 0; - const swapsStxStatusDeadline = 0; swapsController.__test__updateState({ swapsState: { ...swapsController.state.swapsState, 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/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