diff --git a/ui/pages/confirmations/components/confirm/info/contract-interaction/contract-interaction.tsx b/ui/pages/confirmations/components/confirm/info/contract-interaction/contract-interaction.tsx index d7f5d6b5f77d..6e3ade942675 100644 --- a/ui/pages/confirmations/components/confirm/info/contract-interaction/contract-interaction.tsx +++ b/ui/pages/confirmations/components/confirm/info/contract-interaction/contract-interaction.tsx @@ -30,7 +30,7 @@ const ContractInteractionInfo = () => { /> - + {showAdvancedDetails && } ); diff --git a/ui/pages/confirmations/components/confirm/info/info.test.tsx b/ui/pages/confirmations/components/confirm/info/info.test.tsx index 24773ffdcccd..385c9fc3ee3d 100644 --- a/ui/pages/confirmations/components/confirm/info/info.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/info.test.tsx @@ -16,10 +16,7 @@ describe('Info', () => { }, }; const mockStore = configureMockStore([])(state); - const { container } = renderWithProvider( - , - mockStore, - ); + const { container } = renderWithProvider(, mockStore); expect(container).toMatchSnapshot(); }); @@ -31,10 +28,7 @@ describe('Info', () => { }, }; const mockStore = configureMockStore([])(state); - const { container } = renderWithProvider( - , - mockStore, - ); + const { container } = renderWithProvider(, mockStore); expect(container).toMatchSnapshot(); }); }); diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/__snapshots__/gas-fees-details.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/__snapshots__/gas-fees-details.test.tsx.snap index ab052a6f316c..3cd627373743 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/__snapshots__/gas-fees-details.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/__snapshots__/gas-fees-details.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` renders component for gas fees section with advanced details toggled off 1`] = ` +exports[` renders component for gas fees section 1`] = `
renders component for gas fees section with advanced
`; - -exports[` renders component for gas fees section with advanced details toggled on 1`] = ` -
-
-
-

- Estimated fee -

-
-
- -
-
-
-
-

- 0.004 ETH -

-

- $2.20 -

- -
-
-
-
-

- Speed -

-
-
-
-

- 🦊 Market -

-

- - ~ - 0 sec - -

-
-
-
-
-
-

- Max fee -

-
-
- -
-
-
-
-

- 0.0076 ETH -

-

- $4.23 -

-
-
-
-`; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.stories.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.stories.tsx index 1d19b3bcef5f..8717ace09647 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.stories.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.stories.tsx @@ -4,6 +4,7 @@ import { Provider } from 'react-redux'; import { genUnapprovedContractInteractionConfirmation } from '../../../../../../../../test/data/confirmations/contract-interaction'; import mockState from '../../../../../../../../test/data/mock-state.json'; import configureStore from '../../../../../../../store/store'; +import { AdvancedDetailsProvider } from '../../contexts/advanced-details-context'; import { GasFeesDetails } from './gas-fees-details'; function getStore() { @@ -33,24 +34,14 @@ const Story = { ), ], - argTypes: { - showAdvancedDetails: { - control: 'select', - options: [false, true], - }, - }, - args: { - showAdvancedDetails: false, - }, }; export default Story; -export const DefaultStory = (args) => ( - {}} - showAdvancedDetails={args.showAdvancedDetails} - /> +export const DefaultStory = () => ( + + {}} /> + ); DefaultStory.storyName = 'Default'; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.test.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.test.tsx index 144f7c0631d0..b4b0b17c567c 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.test.tsx @@ -6,6 +6,7 @@ import { genUnapprovedContractInteractionConfirmation } from '../../../../../../ import mockState from '../../../../../../../../test/data/mock-state.json'; import { renderWithProvider } from '../../../../../../../../test/lib/render-helpers'; import { getGasFeeTimeEstimate } from '../../../../../../../store/actions'; +import { AdvancedDetailsProvider } from '../../contexts/advanced-details-context'; import { GasFeesDetails } from './gas-fees-details'; jest.mock('../../../../../../../store/actions', () => ({ @@ -16,7 +17,7 @@ jest.mock('../../../../../../../store/actions', () => ({ describe('', () => { const middleware = [thunk]; - it('renders component for gas fees section with advanced details toggled off', async () => { + it('renders component for gas fees section', async () => { (getGasFeeTimeEstimate as jest.Mock).mockImplementation(() => Promise.resolve({ upperTimeBound: '1000' }), ); @@ -31,40 +32,11 @@ describe('', () => { let container; await act(async () => { const renderResult = renderWithProvider( - console.log('open popover')} - showAdvancedDetails={false} - />, - mockStore, - ); - container = renderResult.container; - - // Wait for any asynchronous operations to complete - await new Promise(setImmediate); - }); - - expect(container).toMatchSnapshot(); - }); - - it('renders component for gas fees section with advanced details toggled on', async () => { - (getGasFeeTimeEstimate as jest.Mock).mockImplementation(() => - Promise.resolve({ upperTimeBound: '1000' }), - ); - - const state = { - ...mockState, - confirm: { - currentConfirmation: genUnapprovedContractInteractionConfirmation(), - }, - }; - const mockStore = configureMockStore(middleware)(state); - let container; - await act(async () => { - const renderResult = renderWithProvider( - console.log('open popover')} - showAdvancedDetails={true} - />, + + console.log('open popover')} + /> + , mockStore, ); container = renderResult.container; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.tsx index 97acf7dd7ae7..4c6afa072882 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-details/gas-fees-details.tsx @@ -13,6 +13,7 @@ import { import { useI18nContext } from '../../../../../../../hooks/useI18nContext'; import { currentConfirmationSelector } from '../../../../../../../selectors'; import GasTiming from '../../../../gas-timing/gas-timing.component'; +import { useAdvancedDetailsHandler } from '../../contexts/advanced-details-context'; import { useEIP1559TxFees } from '../../hooks/useEIP1559TxFees'; import { useFeeCalculations } from '../../hooks/useFeeCalculations'; import { useSupportsEIP1559 } from '../../hooks/useSupportsEIP1559'; @@ -21,10 +22,8 @@ import { GasFeesRow } from '../gas-fees-row/gas-fees-row'; export const GasFeesDetails = ({ setShowCustomizeGasPopover, - showAdvancedDetails, }: { setShowCustomizeGasPopover: Dispatch>; - showAdvancedDetails: boolean; }) => { const t = useI18nContext(); @@ -49,6 +48,8 @@ export const GasFeesDetails = ({ maxFeeNative, } = useFeeCalculations(transactionMeta); + const { showAdvancedDetails } = useAdvancedDetailsHandler(); + if (!transactionMeta?.txParams) { return null; } diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/__snapshots__/gas-fees-section.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/__snapshots__/gas-fees-section.test.tsx.snap index f18c9ad511dd..9665e18a7f4e 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/__snapshots__/gas-fees-section.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/__snapshots__/gas-fees-section.test.tsx.snap @@ -2,7 +2,7 @@ exports[` does not render component for gas fees section 1`] = `
`; -exports[` renders component for gas fees section with advanced details toggled off 1`] = ` +exports[` renders component for gas fees section 1`] = `
renders component for gas fees section with advanced
`; - -exports[` renders component for gas fees section with advanced details toggled on 1`] = ` -
-
-
-
-

- Estimated fee -

-
-
- -
-
-
-
-

- 0.004 ETH -

-

- $2.20 -

- -
-
-
-
-

- Speed -

-
-
-
-

- 🦊 Market -

-

- - ~ - 0 sec - -

-
-
-
-
-
-

- Max fee -

-
-
- -
-
-
-
-

- 0.0076 ETH -

-

- $4.23 -

-
-
-
-
-`; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.stories.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.stories.tsx index f684744f4ebe..694d2b50dd10 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.stories.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.stories.tsx @@ -4,6 +4,7 @@ import { Provider } from 'react-redux'; import { genUnapprovedContractInteractionConfirmation } from '../../../../../../../../test/data/confirmations/contract-interaction'; import mockState from '../../../../../../../../test/data/mock-state.json'; import configureStore from '../../../../../../../store/store'; +import { AdvancedDetailsProvider } from '../../contexts/advanced-details-context'; import { GasFeesSection } from './gas-fees-section'; function getStore() { @@ -33,21 +34,14 @@ const Story = { ), ], - argTypes: { - showAdvancedDetails: { - control: 'select', - options: [false, true], - }, - }, - args: { - showAdvancedDetails: false, - }, }; export default Story; -export const DefaultStory = (args) => ( - +export const DefaultStory = () => ( + + + ); DefaultStory.storyName = 'Default'; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.test.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.test.tsx index 9245e160f1ec..a1253dbec8dc 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.test.tsx @@ -6,6 +6,7 @@ import { genUnapprovedContractInteractionConfirmation } from '../../../../../../ import mockState from '../../../../../../../../test/data/mock-state.json'; import { renderWithProvider } from '../../../../../../../../test/lib/render-helpers'; import { getGasFeeTimeEstimate } from '../../../../../../../store/actions'; +import { AdvancedDetailsProvider } from '../../contexts/advanced-details-context'; import { GasFeesSection } from './gas-fees-section'; jest.mock('../../../../../../../store/actions', () => ({ @@ -20,13 +21,15 @@ describe('', () => { const state = { ...mockState, confirm: { currentConfirmation: null } }; const mockStore = configureMockStore(middleware)(state); const { container } = renderWithProvider( - , + + + , mockStore, ); expect(container).toMatchSnapshot(); }); - it('renders component for gas fees section with advanced details toggled off', async () => { + it('renders component for gas fees section', async () => { (getGasFeeTimeEstimate as jest.Mock).mockImplementation(() => Promise.resolve({ upperTimeBound: '1000' }), ); @@ -41,34 +44,9 @@ describe('', () => { let container; await act(async () => { const renderResult = renderWithProvider( - , - mockStore, - ); - container = renderResult.container; - - // Wait for any asynchronous operations to complete - await new Promise(setImmediate); - }); - - expect(container).toMatchSnapshot(); - }); - - it('renders component for gas fees section with advanced details toggled on', async () => { - (getGasFeeTimeEstimate as jest.Mock).mockImplementation(() => - Promise.resolve({ upperTimeBound: '1000' }), - ); - - const state = { - ...mockState, - confirm: { - currentConfirmation: genUnapprovedContractInteractionConfirmation(), - }, - }; - const mockStore = configureMockStore(middleware)(state); - let container; - await act(async () => { - const renderResult = renderWithProvider( - , + + + , mockStore, ); container = renderResult.container; diff --git a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.tsx b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.tsx index a5ca77057b22..8d782cd4b9e7 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/gas-fees-section/gas-fees-section.tsx @@ -24,11 +24,7 @@ const LegacyTransactionGasModal = ({ ); }; -export const GasFeesSection = ({ - showAdvancedDetails, -}: { - showAdvancedDetails: boolean; -}) => { +export const GasFeesSection = () => { const transactionMeta = useSelector( currentConfirmationSelector, ) as TransactionMeta; @@ -47,10 +43,7 @@ export const GasFeesSection = ({ return ( - + {!supportsEIP1559 && showCustomizeGasPopover && (