From 2f2708f05adda3f1f73ad765196ca475c33b03d7 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Tue, 12 Nov 2024 19:17:04 +0530 Subject: [PATCH 01/17] Adding e2e for signature decoding --- app/scripts/metamask-controller.js | 3 +- builds.yml | 4 +-- privacy-snapshot.json | 2 ++ test/e2e/tests/confirmations/helpers.ts | 36 +++++++++++++++++++ .../confirmations/signatures/permit.spec.ts | 32 +++++++++++++++++ .../signatures/signature-helpers.ts | 29 +++++++++++++++ .../typed-sign-v4-simulation.test.tsx | 7 ++-- .../hooks/useDecodedSignatureMetrics.test.ts | 1 - .../hooks/useDecodedSignatureMetrics.ts | 2 +- 9 files changed, 105 insertions(+), 11 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 1f907d94a976..f9669f8358b3 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2046,8 +2046,7 @@ export default class MetamaskController extends EventEmitter { decodingApiUrl: process.env.DECODING_API_URL, isDecodeSignatureRequestEnabled: () => this.preferencesController.state.useExternalServices === true && - this.preferencesController.state.useTransactionSimulations && - process.env.ENABLE_SIGNATURE_DECODING === true, + this.preferencesController.state.useTransactionSimulations, }); this.signatureController.hub.on( diff --git a/builds.yml b/builds.yml index 75f6f4b462c6..89387fd70d18 100644 --- a/builds.yml +++ b/builds.yml @@ -235,10 +235,8 @@ env: # Used to enable confirmation redesigned pages - ENABLE_CONFIRMATION_REDESIGN: '' - # Used to enable signature decoding - - ENABLE_SIGNATURE_DECODING: '' # URL of the decoding API used to provide additional data from signature requests - - DECODING_API_URL: null + - DECODING_API_URL: 'https://qtgdj2huxh.execute-api.us-east-2.amazonaws.com/uat/v1' # Determines if feature flagged Settings Page - Developer Options should be used - ENABLE_SETTINGS_PAGE_DEV_OPTIONS: false # Used for debugging changes to the phishing warning page. diff --git a/privacy-snapshot.json b/privacy-snapshot.json index 36249b132bca..caaf4b62fb0a 100644 --- a/privacy-snapshot.json +++ b/privacy-snapshot.json @@ -48,6 +48,8 @@ "price.api.cx.metamask.io", "proxy.api.cx.metamask.io", "proxy.dev-api.cx.metamask.io", + "qtgdj2huxh.execute-api.us-east-2.amazonaws.com", + "https://signature-insights.api.cx.metamask.io", "raw.githubusercontent.com", "registry.npmjs.org", "responsive-rpc.test", diff --git a/test/e2e/tests/confirmations/helpers.ts b/test/e2e/tests/confirmations/helpers.ts index 2b1078549c5b..93677fe5eca9 100644 --- a/test/e2e/tests/confirmations/helpers.ts +++ b/test/e2e/tests/confirmations/helpers.ts @@ -9,6 +9,9 @@ import { MockedEndpoint, Mockttp } from '../../mock-e2e'; import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; import { Driver } from '../../webdriver/driver'; +export const DECODING_E2E_API_URL = + 'https://qtgdj2huxh.execute-api.us-east-2.amazonaws.com/uat/v1'; + export async function scrollAndConfirmAndAssertConfirm(driver: Driver) { await driver.clickElementSafe('.confirm-scroll-to-bottom__button'); await driver.clickElement('[data-testid="confirm-footer-button"]'); @@ -59,6 +62,33 @@ async function createMockSegmentEvent(mockServer: Mockttp, eventName: string) { })); } +async function createMockSignatureDecodingEvent(mockServer: Mockttp) { + return await mockServer + .forPost(`${DECODING_E2E_API_URL}/signature`) + .thenCallback(() => ({ + statusCode: 200, + json: { + stateChanges: [ + { + assetType: 'NATIVE', + changeType: 'RECEIVE', + address: '', + amount: '900000000000000000', + contractAddress: '', + }, + { + assetType: 'ERC721', + changeType: 'LISTING', + address: '', + amount: '', + contractAddress: '0xafd4896984CA60d2feF66136e57f958dCe9482d5', + tokenID: '2101', + }, + ], + }, + })); +} + export async function mockSignatureApproved( mockServer: Mockttp, withAnonEvents = false, @@ -75,6 +105,7 @@ export async function mockSignatureApproved( await createMockSegmentEvent(mockServer, 'Account Details Opened'), ...anonEvents, await createMockSegmentEvent(mockServer, 'Signature Approved'), + await createMockSignatureDecodingEvent(mockServer), ]; } @@ -92,6 +123,11 @@ export async function mockSignatureRejected( return [ await createMockSegmentEvent(mockServer, 'Signature Requested'), await createMockSegmentEvent(mockServer, 'Signature Rejected'), + await createMockSignatureDecodingEvent(mockServer), ...anonEvents, ]; } + +export async function mockPermitDecoding(mockServer: Mockttp) { + return [await createMockSignatureDecodingEvent(mockServer)]; +} diff --git a/test/e2e/tests/confirmations/signatures/permit.spec.ts b/test/e2e/tests/confirmations/signatures/permit.spec.ts index f6c8fc972b5f..53e13fab589b 100644 --- a/test/e2e/tests/confirmations/signatures/permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/permit.spec.ts @@ -11,6 +11,7 @@ import { import { Ganache } from '../../../seeder/ganache'; import { Driver } from '../../../webdriver/driver'; import { + mockPermitDecoding, mockSignatureApproved, mockSignatureRejected, scrollAndConfirmAndAssertConfirm, @@ -67,6 +68,8 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) { signatureType: 'eth_signTypedData_v4', primaryType: 'Permit', uiCustomizations: ['redesigned_confirmation', 'permit'], + decodingChangeTypes: ['RECEIVE', 'LISTING'], + decodingResponse: 'CHANGE', }); await assertVerifiedResults(driver, publicAddress); @@ -106,11 +109,40 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) { primaryType: 'Permit', uiCustomizations: ['redesigned_confirmation', 'permit'], location: 'confirmation', + decodingChangeTypes: ['RECEIVE', 'LISTING'], + decodingResponse: 'CHANGE', }); }, mockSignatureRejected, ); }); + + it('display decoding information if available', async function () { + await withTransactionEnvelopeTypeFixtures( + this.test?.fullTitle(), + TransactionEnvelopeType.legacy, + async ({ driver }: TestSuiteArguments) => { + await unlockWallet(driver); + await openDapp(driver); + await driver.clickElement('#signPermit'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const simulationSection = driver.findElement({ + text: 'Estimated changes', + }); + const receiveChange = driver.findElement({ text: 'You receive' }); + const listChange = driver.findElement({ text: 'You list' }); + const listChangeValue = driver.findElement({ text: '#2101' }); + + assert.ok(await simulationSection, 'Estimated changes'); + assert.ok(await receiveChange, 'You receive'); + assert.ok(await listChange, 'You list'); + assert.ok(await listChangeValue, '#2101'); + + await driver.delay(10000); + }, + mockPermitDecoding, + ); + }); }); async function assertInfoValues(driver: Driver) { diff --git a/test/e2e/tests/confirmations/signatures/signature-helpers.ts b/test/e2e/tests/confirmations/signatures/signature-helpers.ts index d360c46cf921..e0b9ebbb56b5 100644 --- a/test/e2e/tests/confirmations/signatures/signature-helpers.ts +++ b/test/e2e/tests/confirmations/signatures/signature-helpers.ts @@ -243,6 +243,8 @@ function assertEventPropertiesMatch( const actualProperties = { ...event.properties }; const expectedProps = { ...expectedProperties }; + compareDecodingAPIResponse(actualProperties, expectedProps, eventName); + compareSecurityAlertResponse(actualProperties, expectedProps, eventName); assert(event, `${eventName} event not found`); @@ -277,6 +279,33 @@ function compareSecurityAlertResponse( } } +function compareDecodingAPIResponse( + actualProperties: Record, + expectedProperties: Record, + eventName: string, +) { + if ( + eventName === 'Signature Rejected' || + eventName === 'Signature Approved' + ) { + assert.deepStrictEqual( + actualProperties.decoding_change_types, + expectedProperties.decoding_change_types, + `${eventName} event properties do not match: decoding_change_types is ${actualProperties.decoding_change_types}`, + ); + assert.equal( + actualProperties.decoding_response, + expectedProperties.decoding_response, + `${eventName} event properties do not match: decoding_response is ${actualProperties.decoding_response}`, + ); + } + // Remove the property from both objects to avoid comparison + delete expectedProperties.decoding_change_types; + delete expectedProperties.decoding_response; + delete actualProperties.decoding_change_types; + delete actualProperties.decoding_response; +} + export async function clickHeaderInfoBtn(driver: Driver) { await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx index 36d20e30fc66..b0b76c61c0c4 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx @@ -21,6 +21,7 @@ jest.mock('../../../../../../../store/actions', () => { getTokenStandardAndDetails: jest .fn() .mockResolvedValue({ decimals: 2, standard: 'ERC20' }), + updateEventFragment: jest.fn(), }; }); @@ -113,7 +114,6 @@ describe('PermitSimulation', () => { await waitFor(() => { expect(queryByTestId('30')).not.toBeInTheDocument(); - expect(queryByTestId('Estimated changes')).toBeInTheDocument(); expect( queryByTestId( "You're giving the spender permission to spend this many tokens from your account.", @@ -132,18 +132,17 @@ describe('PermitSimulation', () => { const mockStore = configureMockStore([])(state); await act(async () => { - const { findByText } = renderWithConfirmContextProvider( + const { container, findByText } = renderWithConfirmContextProvider( , mockStore, ); expect(await findByText('Estimated changes')).toBeInTheDocument(); expect(await findByText('Spending cap')).toBeInTheDocument(); - expect(await findByText('1,461,501,637,3...')).toBeInTheDocument(); }); }); - it.only('should render decoding simulation for seaport request', async () => { + it('should render decoding simulation for seaport request', async () => { const state = getMockTypedSignConfirmStateForRequest(seaportSignatureMsg); const mockStore = configureMockStore([])(state); diff --git a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts index c0023104ba8b..c5de7ea59d2b 100644 --- a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts +++ b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts @@ -22,7 +22,6 @@ const decodingData: DecodingData = { }; describe('useDecodedSignatureMetrics', () => { - process.env.ENABLE_SIGNATURE_DECODING = 'true'; it('should not call updateSignatureEventFragment if decodingLoading is true', async () => { const state = getMockTypedSignConfirmStateForRequest({ ...permitSignatureMsg, diff --git a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts index 1bf508bce655..0d88135cd1d4 100644 --- a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts +++ b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts @@ -26,7 +26,7 @@ export function useDecodedSignatureMetrics() { : DecodingResponseType.NoChange); useEffect(() => { - if (decodingLoading || !process.env.ENABLE_SIGNATURE_DECODING) { + if (decodingLoading) { return; } From 4c5ee470952a183e57db2ec36a5239dff6dae77d Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 27 Nov 2024 22:30:28 +0530 Subject: [PATCH 02/17] update --- test/e2e/tests/confirmations/signatures/nft-permit.spec.ts | 4 ++++ .../typed-sign-v4-simulation.test.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts b/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts index de70d25b359b..9d95cf1d5631 100644 --- a/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/nft-permit.spec.ts @@ -68,6 +68,8 @@ describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) { signatureType: 'eth_signTypedData_v4', primaryType: 'Permit', uiCustomizations: ['redesigned_confirmation', 'permit'], + decodingChangeTypes: ['RECEIVE', 'LISTING'], + decodingResponse: 'CHANGE', }); await assertVerifiedResults(driver, publicAddress); @@ -111,6 +113,8 @@ describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) { primaryType: 'Permit', uiCustomizations: ['redesigned_confirmation', 'permit'], location: 'confirmation', + decodingChangeTypes: ['RECEIVE', 'LISTING'], + decodingResponse: 'CHANGE', }); }, mockSignatureRejected, diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx index b0b76c61c0c4..276269c4016a 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx @@ -132,7 +132,7 @@ describe('PermitSimulation', () => { const mockStore = configureMockStore([])(state); await act(async () => { - const { container, findByText } = renderWithConfirmContextProvider( + const { findByText } = renderWithConfirmContextProvider( , mockStore, ); From 387b64acd0b515ac891d4bb47887418498f766ec Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 27 Nov 2024 22:39:07 +0530 Subject: [PATCH 03/17] update --- .../typed-sign-v4-simulation.tsx | 2 +- .../hooks/useDecodedSignatureMetrics.test.ts | 29 ++++++++++++++++--- .../hooks/useDecodedSignatureMetrics.ts | 4 +-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx index ebea09e18f15..a9a54697162a 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx @@ -42,7 +42,7 @@ const TypedSignV4Simulation: React.FC = () => { const { currentConfirmation } = useConfirmContext(); const isPermit = isPermitSignatureRequest(currentConfirmation); const supportedByDecodingAPI = isSupportedByDecodingAPI(currentConfirmation); - useDecodedSignatureMetrics(); + useDecodedSignatureMetrics(supportedByDecodingAPI); if (!supportedByDecodingAPI) { return null; diff --git a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts index c5de7ea59d2b..b378343bc274 100644 --- a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts +++ b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.test.ts @@ -22,6 +22,27 @@ const decodingData: DecodingData = { }; describe('useDecodedSignatureMetrics', () => { + it('should not call updateSignatureEventFragment if supportedByDecodingAPI is false', async () => { + const state = getMockTypedSignConfirmStateForRequest({ + ...permitSignatureMsg, + decodingLoading: false, + }); + + const mockUpdateSignatureEventFragment = jest.fn(); + jest + .spyOn(SignatureEventFragment, 'useSignatureEventFragment') + .mockImplementation(() => ({ + updateSignatureEventFragment: mockUpdateSignatureEventFragment, + })); + + renderHookWithConfirmContextProvider( + () => useDecodedSignatureMetrics(false), + state, + ); + + expect(mockUpdateSignatureEventFragment).toHaveBeenCalledTimes(0); + }); + it('should not call updateSignatureEventFragment if decodingLoading is true', async () => { const state = getMockTypedSignConfirmStateForRequest({ ...permitSignatureMsg, @@ -36,7 +57,7 @@ describe('useDecodedSignatureMetrics', () => { })); renderHookWithConfirmContextProvider( - () => useDecodedSignatureMetrics(), + () => useDecodedSignatureMetrics(true), state, ); @@ -57,7 +78,7 @@ describe('useDecodedSignatureMetrics', () => { })); renderHookWithConfirmContextProvider( - () => useDecodedSignatureMetrics(), + () => useDecodedSignatureMetrics(true), state, ); @@ -85,7 +106,7 @@ describe('useDecodedSignatureMetrics', () => { })); renderHookWithConfirmContextProvider( - () => useDecodedSignatureMetrics(), + () => useDecodedSignatureMetrics(true), state, ); @@ -119,7 +140,7 @@ describe('useDecodedSignatureMetrics', () => { })); renderHookWithConfirmContextProvider( - () => useDecodedSignatureMetrics(), + () => useDecodedSignatureMetrics(true), state, ); diff --git a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts index 0d88135cd1d4..98fd07984a9d 100644 --- a/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts +++ b/ui/pages/confirmations/hooks/useDecodedSignatureMetrics.ts @@ -10,7 +10,7 @@ enum DecodingResponseType { NoChange = 'NO_CHANGE', } -export function useDecodedSignatureMetrics() { +export function useDecodedSignatureMetrics(supportedByDecodingAPI: boolean) { const { updateSignatureEventFragment } = useSignatureEventFragment(); const { currentConfirmation } = useConfirmContext(); const { decodingLoading, decodingData } = currentConfirmation; @@ -26,7 +26,7 @@ export function useDecodedSignatureMetrics() { : DecodingResponseType.NoChange); useEffect(() => { - if (decodingLoading) { + if (decodingLoading || !supportedByDecodingAPI) { return; } From 43e57e71d5a24e42588c79e2b81e20071d579327 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 14:55:42 +0530 Subject: [PATCH 04/17] update --- .../decoded-simulation/decoded-simulation.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/decoded-simulation/decoded-simulation.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/decoded-simulation/decoded-simulation.tsx index 53295852c566..55197e689600 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/decoded-simulation/decoded-simulation.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/decoded-simulation/decoded-simulation.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { DecodingDataChangeType, DecodingDataStateChange, @@ -103,14 +103,18 @@ const DecodedSimulation: React.FC = () => { const chainId = currentConfirmation.chainId as Hex; const { decodingLoading, decodingData } = currentConfirmation; - const stateChangeFragment = (decodingData?.stateChanges ?? []).map( - (change: DecodingDataStateChange) => ( - - ), + const stateChangeFragment = useMemo( + () => + (decodingData?.stateChanges ?? []).map( + (change: DecodingDataStateChange) => ( + + ), + ), + [decodingData?.stateChanges], ); return ( From 25c2b712b9c040a4a39daaa1be72d8559845c0d5 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 16:13:42 +0530 Subject: [PATCH 05/17] update --- .../info/__snapshots__/info.test.tsx.snap | 15 +--- .../__snapshots__/typed-sign.test.tsx.snap | 45 ++--------- .../typed-sign-v4-simulation.test.tsx | 55 ++++++++----- .../typed-sign-v4-simulation.tsx | 38 +-------- .../info/typed-sign/typed-sign.test.tsx | 3 + .../confirm/info/typed-sign/typed-sign.tsx | 15 +--- .../__snapshots__/confirm.test.tsx.snap | 15 +--- .../useTypesSignSimulationEnabledInfo.test.ts | 78 +++++++++++++++++++ .../useTypesSignSimulationEnabledInfo.ts | 66 ++++++++++++++++ 9 files changed, 200 insertions(+), 130 deletions(-) create mode 100644 ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts create mode 100644 ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts diff --git a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap index 5bd747959256..bdcc3e7db452 100644 --- a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap @@ -1386,30 +1386,19 @@ exports[`Info renders info section for typed sign request 1`] = ` data-testid="confirmation_message-section" >
-
diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap index edb33ff6fea3..20998032a049 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap @@ -1102,30 +1102,19 @@ exports[`TypedSignInfo renders origin for typed sign data request 1`] = ` data-testid="confirmation_message-section" >
-
@@ -2047,30 +2036,19 @@ exports[`TypedSignInfo should render message for typed sign v3 request 1`] = ` data-testid="confirmation_message-section" >
-
@@ -2619,30 +2597,19 @@ exports[`TypedSignInfo should render message for typed sign v4 request 1`] = ` data-testid="confirmation_message-section" >
-
diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx index 276269c4016a..756d54f57a9b 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.test.tsx @@ -46,11 +46,16 @@ describe('PermitSimulation', () => { }); it('should render default simulation if decoding api does not return result', async () => { - const state = getMockTypedSignConfirmStateForRequest({ - ...permitSignatureMsg, - decodingLoading: false, - decodingData: undefined, - }); + const state = getMockTypedSignConfirmStateForRequest( + { + ...permitSignatureMsg, + decodingLoading: false, + decodingData: undefined, + }, + { + metamask: { useTransactionSimulations: true }, + }, + ); const mockStore = configureMockStore([])(state); await act(async () => { @@ -70,17 +75,22 @@ describe('PermitSimulation', () => { }); it('should render default simulation if decoding api returns error', async () => { - const state = getMockTypedSignConfirmStateForRequest({ - ...permitSignatureMsg, - decodingLoading: false, - decodingData: { - stateChanges: null, - error: { - message: 'some error', - type: 'SOME_ERROR', + const state = getMockTypedSignConfirmStateForRequest( + { + ...permitSignatureMsg, + decodingLoading: false, + decodingData: { + stateChanges: null, + error: { + message: 'some error', + type: 'SOME_ERROR', + }, }, }, - }); + { + metamask: { useTransactionSimulations: true }, + }, + ); const mockStore = configureMockStore([])(state); await act(async () => { @@ -124,11 +134,14 @@ describe('PermitSimulation', () => { }); it('should render decoding simulation for permits', async () => { - const state = getMockTypedSignConfirmStateForRequest({ - ...permitSignatureMsg, - decodingLoading: false, - decodingData, - }); + const state = getMockTypedSignConfirmStateForRequest( + { + ...permitSignatureMsg, + decodingLoading: false, + decodingData, + }, + { metamask: { useTransactionSimulations: true } }, + ); const mockStore = configureMockStore([])(state); await act(async () => { @@ -143,7 +156,9 @@ describe('PermitSimulation', () => { }); it('should render decoding simulation for seaport request', async () => { - const state = getMockTypedSignConfirmStateForRequest(seaportSignatureMsg); + const state = getMockTypedSignConfirmStateForRequest(seaportSignatureMsg, { + metamask: { useTransactionSimulations: true }, + }); const mockStore = configureMockStore([])(state); await act(async () => { diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx index a9a54697162a..84b52ddae635 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx @@ -1,50 +1,20 @@ import React from 'react'; -import { PRIMARY_TYPES_PERMIT } from '../../../../../../../../shared/constants/signatures'; -import { parseTypedDataMessage } from '../../../../../../../../shared/modules/transaction.utils'; import { SignatureRequestType } from '../../../../../types/confirm'; import { isPermitSignatureRequest } from '../../../../../utils'; import { useConfirmContext } from '../../../../../context/confirm'; import { useDecodedSignatureMetrics } from '../../../../../hooks/useDecodedSignatureMetrics'; import { DecodedSimulation } from './decoded-simulation'; import { PermitSimulation } from './permit-simulation'; - -const NON_PERMIT_SUPPORTED_TYPES_SIGNS = [ - { - domainName: 'Seaport', - primaryTypeList: ['BulkOrder'], - versionList: ['1.4', '1.5', '1.6'], - }, - { - domainName: 'Seaport', - primaryTypeList: ['OrderComponents'], - }, -]; - -const isSupportedByDecodingAPI = (signatureRequest: SignatureRequestType) => { - const { - domain: { name, version }, - primaryType, - } = parseTypedDataMessage( - (signatureRequest as SignatureRequestType).msgParams?.data as string, - ); - const isPermit = PRIMARY_TYPES_PERMIT.includes(primaryType); - const nonPermitSupportedTypes = NON_PERMIT_SUPPORTED_TYPES_SIGNS.some( - ({ domainName, primaryTypeList, versionList }) => - name === domainName && - primaryTypeList.includes(primaryType) && - (!versionList || versionList.includes(version)), - ); - return isPermit || nonPermitSupportedTypes; -}; +import { useTypesSignSimulationEnabledInfo } from '../../../../../hooks/useTypesSignSimulationEnabledInfo'; const TypedSignV4Simulation: React.FC = () => { const { currentConfirmation } = useConfirmContext(); const isPermit = isPermitSignatureRequest(currentConfirmation); - const supportedByDecodingAPI = isSupportedByDecodingAPI(currentConfirmation); - useDecodedSignatureMetrics(supportedByDecodingAPI); + const isSimulationSupported = useTypesSignSimulationEnabledInfo(); + useDecodedSignatureMetrics(isSimulationSupported === true); - if (!supportedByDecodingAPI) { + if (!isSimulationSupported) { return null; } diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.test.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.test.tsx index 68f3c011f338..56421561ccd2 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.test.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.test.tsx @@ -14,6 +14,7 @@ import { permitSignatureMsg, permitSignatureMsgWithNoDeadline, unapprovedTypedSignMsgV3, + unapprovedTypedSignMsgV4, } from '../../../../../../../test/data/confirmations/typed_sign'; import { renderWithConfirmContextProvider } from '../../../../../../../test/lib/confirmations/render-helpers'; import * as snapUtils from '../../../../../../helpers/utils/snaps'; @@ -147,6 +148,7 @@ describe('TypedSignInfo', () => { it('displays "requestFromInfoSnap" tooltip when origin is a snap', async () => { const mockState = getMockTypedSignConfirmStateForRequest({ + ...unapprovedTypedSignMsgV4, id: '123', type: TransactionType.signTypedData, chainId: '0x5', @@ -170,6 +172,7 @@ describe('TypedSignInfo', () => { it('displays "requestFromInfo" tooltip when origin is not a snap', async () => { const mockState = getMockTypedSignConfirmStateForRequest({ + ...unapprovedTypedSignMsgV4, id: '123', type: TransactionType.signTypedData, chainId: '0x5', diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.tsx index 0937e0dc1117..d21ed2b1fca9 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.tsx @@ -1,9 +1,7 @@ import React from 'react'; -import { useSelector } from 'react-redux'; import { isValidAddress } from 'ethereumjs-util'; import { ConfirmInfoAlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row'; -import { MESSAGE_TYPE } from '../../../../../../../shared/constants/app'; import { parseTypedDataMessage } from '../../../../../../../shared/modules/transaction.utils'; import { RowAlertKey } from '../../../../../../components/app/confirm/info/row/constants'; import { @@ -21,7 +19,7 @@ import { isPermitSignatureRequest, } from '../../../../utils'; import { useConfirmContext } from '../../../../context/confirm'; -import { selectUseTransactionSimulations } from '../../../../selectors/preferences'; +import { useTypesSignSimulationEnabledInfo } from '../../../../hooks/useTypesSignSimulationEnabledInfo'; import { ConfirmInfoRowTypedSignData } from '../../row/typed-sign-data/typedSignData'; import { isSnapId } from '../../../../../../helpers/utils/snaps'; import { SigningInWithRow } from '../shared/sign-in-with-row/sign-in-with-row'; @@ -30,9 +28,7 @@ import { TypedSignV4Simulation } from './typed-sign-v4-simulation'; const TypedSignInfo: React.FC = () => { const t = useI18nContext(); const { currentConfirmation } = useConfirmContext(); - const useTransactionSimulations = useSelector( - selectUseTransactionSimulations, - ); + const isSimulationSupported = useTypesSignSimulationEnabledInfo(); if (!currentConfirmation?.msgParams) { return null; @@ -44,9 +40,6 @@ const TypedSignInfo: React.FC = () => { } = parseTypedDataMessage(currentConfirmation.msgParams.data as string); const isPermit = isPermitSignatureRequest(currentConfirmation); - const isTypedSignV4 = - currentConfirmation.msgParams.signatureMethod === - MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4; const isOrder = isOrderSignatureRequest(currentConfirmation); const tokenContract = isPermit || isOrder ? verifyingContract : undefined; const { decimalsNumber } = useGetTokenStandardAndDetails(tokenContract); @@ -60,7 +53,7 @@ const TypedSignInfo: React.FC = () => { return ( <> - {isTypedSignV4 && useTransactionSimulations && } + {isSimulationSupported && } {isPermit && ( <> @@ -91,7 +84,7 @@ const TypedSignInfo: React.FC = () => { diff --git a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap index ee656d5ebb53..e7e2e499dfe9 100644 --- a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap +++ b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap @@ -1927,30 +1927,19 @@ exports[`Confirm should match snapshot for signature - typed sign - V4 1`] = ` data-testid="confirmation_message-section" >
-
diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts new file mode 100644 index 000000000000..3c82d45a02e4 --- /dev/null +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts @@ -0,0 +1,78 @@ +import { + DecodingData, + DecodingDataChangeType, +} from '@metamask/signature-controller'; + +import { getMockTypedSignConfirmStateForRequest } from '../../../../test/data/confirmations/helper'; +import { renderHookWithConfirmContextProvider } from '../../../../test/lib/confirmations/render-helpers'; +import { + permitSignatureMsg, + permitSingleSignatureMsg, + seaportSignatureMsg, + unapprovedTypedSignMsgV3, +} from '../../../../test/data/confirmations/typed_sign'; +import * as SignatureEventFragment from './useSignatureEventFragment'; +import { useTypesSignSimulationEnabledInfo } from './useTypesSignSimulationEnabledInfo'; + +describe('useTypesSignSimulationEnabledInfo', () => { + it('return false if user has disabled simulations', async () => { + const state = getMockTypedSignConfirmStateForRequest( + permitSingleSignatureMsg, + { + metamask: { useTransactionSimulations: false }, + }, + ); + + const { result } = renderHookWithConfirmContextProvider( + () => useTypesSignSimulationEnabledInfo(), + state, + ); + + expect(result.current).toBe(false); + }); + + it('return false if request is not types sign V4', async () => { + const state = getMockTypedSignConfirmStateForRequest( + unapprovedTypedSignMsgV3, + { + metamask: { useTransactionSimulations: true }, + }, + ); + + const { result } = renderHookWithConfirmContextProvider( + () => useTypesSignSimulationEnabledInfo(), + state, + ); + + expect(result.current).toBe(false); + }); + + it('return true for typed sign v4 permit request', async () => { + const state = getMockTypedSignConfirmStateForRequest( + permitSingleSignatureMsg, + { + metamask: { useTransactionSimulations: true }, + }, + ); + + const { result } = renderHookWithConfirmContextProvider( + () => useTypesSignSimulationEnabledInfo(), + state, + ); + + expect(result.current).toBe(true); + }); + + it('return true for typed sign v4 seaport request', async () => { + const state = getMockTypedSignConfirmStateForRequest(seaportSignatureMsg, { + metamask: { useTransactionSimulations: true }, + }); + + const { result } = renderHookWithConfirmContextProvider( + () => useTypesSignSimulationEnabledInfo(), + state, + ); + + expect(result.current).toBe(true); + }); +}); diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts new file mode 100644 index 000000000000..b691fb5c0675 --- /dev/null +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -0,0 +1,66 @@ +import { useMemo } from 'react'; + +import { MESSAGE_TYPE } from '../../../../shared/constants/app'; +import { parseTypedDataMessage } from '../../../../shared/modules/transaction.utils'; +import { SignatureRequestType } from '../types/confirm'; +import { isPermitSignatureRequest } from '../utils'; +import { useConfirmContext } from '../context/confirm'; +import { useSelector } from 'react-redux'; +import { selectUseTransactionSimulations } from '../selectors/preferences'; + +const NON_PERMIT_SUPPORTED_TYPES_SIGNS = [ + { + domainName: 'Seaport', + primaryTypeList: ['BulkOrder'], + versionList: ['1.4', '1.5', '1.6'], + }, + { + domainName: 'Seaport', + primaryTypeList: ['OrderComponents'], + }, +]; + +const isNonPermitSupportedByDecodingAPI = ( + signatureRequest: SignatureRequestType, +) => { + const data = (signatureRequest as SignatureRequestType).msgParams + ?.data as string; + if (!data) { + return false; + } + const { + domain: { name, version }, + primaryType, + } = parseTypedDataMessage(data); + return NON_PERMIT_SUPPORTED_TYPES_SIGNS.some( + ({ domainName, primaryTypeList, versionList }) => + name === domainName && + primaryTypeList.includes(primaryType) && + (!versionList || versionList.includes(version)), + ); +}; + +export function useTypesSignSimulationEnabledInfo() { + const { currentConfirmation } = useConfirmContext(); + const useTransactionSimulations = useSelector( + selectUseTransactionSimulations, + ); + + const isTypedSignV4 = + currentConfirmation?.msgParams?.signatureMethod === + MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4; + const isPermit = isPermitSignatureRequest(currentConfirmation); + const nonPermitSupportedByDecodingAPI = + isNonPermitSupportedByDecodingAPI(currentConfirmation); + + return useMemo(() => { + if (!currentConfirmation) { + return undefined; + } + return ( + useTransactionSimulations && + isTypedSignV4 && + (isPermit || nonPermitSupportedByDecodingAPI) + ); + }, [isTypedSignV4, isPermit, nonPermitSupportedByDecodingAPI]); +} From 15d97c7a1509821e6c355ff2ebd143d7fa29da6b Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 16:25:53 +0530 Subject: [PATCH 06/17] update --- .../hooks/useTypesSignSimulationEnabledInfo.test.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts index 3c82d45a02e4..5636927782d0 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts @@ -1,17 +1,10 @@ -import { - DecodingData, - DecodingDataChangeType, -} from '@metamask/signature-controller'; - import { getMockTypedSignConfirmStateForRequest } from '../../../../test/data/confirmations/helper'; import { renderHookWithConfirmContextProvider } from '../../../../test/lib/confirmations/render-helpers'; import { - permitSignatureMsg, permitSingleSignatureMsg, seaportSignatureMsg, unapprovedTypedSignMsgV3, } from '../../../../test/data/confirmations/typed_sign'; -import * as SignatureEventFragment from './useSignatureEventFragment'; import { useTypesSignSimulationEnabledInfo } from './useTypesSignSimulationEnabledInfo'; describe('useTypesSignSimulationEnabledInfo', () => { From 7bc13b20a52fc081a21f2dc2648d78fbabf57088 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 16:43:24 +0530 Subject: [PATCH 07/17] update --- .../confirmations/signatures/permit-seaport.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/integration/confirmations/signatures/permit-seaport.test.tsx b/test/integration/confirmations/signatures/permit-seaport.test.tsx index be4f6b6064d2..5f142e32201f 100644 --- a/test/integration/confirmations/signatures/permit-seaport.test.tsx +++ b/test/integration/confirmations/signatures/permit-seaport.test.tsx @@ -1,4 +1,4 @@ -import { act, screen } from '@testing-library/react'; +import { act, fireEvent, screen } from '@testing-library/react'; import nock from 'nock'; import mockMetaMaskState from '../../data/integration-init-state.json'; import { integrationTestRender } from '../../../lib/render-helpers'; @@ -112,6 +112,8 @@ describe('Permit Seaport Tests', () => { it('renders offer and consideration details', async () => { await renderSeaportSignature(); + fireEvent.click(screen.getByTestId('sectionCollapseButton')); + const offers = await screen.findByTestId('confirmation_data-offer-index-2'); const offerDetails0 = offers.querySelector( '[data-testid="confirmation_data-0-index-0"]', From 651e0b2bd583bf803155ae48d94d5ba951f405ed Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 17:05:00 +0530 Subject: [PATCH 08/17] update --- .../typed-sign-v4-simulation/typed-sign-v4-simulation.tsx | 2 +- .../confirmations/hooks/useTypesSignSimulationEnabledInfo.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx index 84b52ddae635..ce2c8b54c04a 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/typed-sign-v4-simulation.tsx @@ -4,9 +4,9 @@ import { SignatureRequestType } from '../../../../../types/confirm'; import { isPermitSignatureRequest } from '../../../../../utils'; import { useConfirmContext } from '../../../../../context/confirm'; import { useDecodedSignatureMetrics } from '../../../../../hooks/useDecodedSignatureMetrics'; +import { useTypesSignSimulationEnabledInfo } from '../../../../../hooks/useTypesSignSimulationEnabledInfo'; import { DecodedSimulation } from './decoded-simulation'; import { PermitSimulation } from './permit-simulation'; -import { useTypesSignSimulationEnabledInfo } from '../../../../../hooks/useTypesSignSimulationEnabledInfo'; const TypedSignV4Simulation: React.FC = () => { const { currentConfirmation } = useConfirmContext(); diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts index b691fb5c0675..3bfdd7ebc470 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -1,12 +1,12 @@ import { useMemo } from 'react'; +import { useSelector } from 'react-redux'; import { MESSAGE_TYPE } from '../../../../shared/constants/app'; import { parseTypedDataMessage } from '../../../../shared/modules/transaction.utils'; import { SignatureRequestType } from '../types/confirm'; import { isPermitSignatureRequest } from '../utils'; -import { useConfirmContext } from '../context/confirm'; -import { useSelector } from 'react-redux'; import { selectUseTransactionSimulations } from '../selectors/preferences'; +import { useConfirmContext } from '../context/confirm'; const NON_PERMIT_SUPPORTED_TYPES_SIGNS = [ { From 8161757e7ca4cf94ac307ebb11ce6478abd9da79 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 17:09:37 +0530 Subject: [PATCH 09/17] update --- .../confirmations/signatures/permit-seaport.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/confirmations/signatures/permit-seaport.test.tsx b/test/integration/confirmations/signatures/permit-seaport.test.tsx index 5f142e32201f..7829a2714b57 100644 --- a/test/integration/confirmations/signatures/permit-seaport.test.tsx +++ b/test/integration/confirmations/signatures/permit-seaport.test.tsx @@ -92,6 +92,8 @@ describe('Permit Seaport Tests', () => { it('renders message details section', async () => { await renderSeaportSignature(); + fireEvent.click(screen.getByTestId('sectionCollapseButton')); + const messageDetailsSection = await screen.findByTestId( 'confirmation_message-section', ); From 82d4af6df1efe6bf3c12770e844f8d02de77cd37 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 17:31:24 +0530 Subject: [PATCH 10/17] update --- builds.yml | 2 +- test/e2e/tests/confirmations/signatures/permit.spec.ts | 1 + .../confirmations/hooks/useTypesSignSimulationEnabledInfo.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builds.yml b/builds.yml index 3963aeda93e5..5bbe17480496 100644 --- a/builds.yml +++ b/builds.yml @@ -236,7 +236,7 @@ env: # Used to enable confirmation redesigned pages - ENABLE_CONFIRMATION_REDESIGN: '' # URL of the decoding API used to provide additional data from signature requests - - DECODING_API_URL: 'https://qtgdj2huxh.execute-api.us-east-2.amazonaws.com/uat/v1' + - DECODING_API_URL: 'https://signature-insights.api.cx.metamask.io/v1' # Determines if feature flagged Settings Page - Developer Options should be used - ENABLE_SETTINGS_PAGE_DEV_OPTIONS: false # Used for debugging changes to the phishing warning page. diff --git a/test/e2e/tests/confirmations/signatures/permit.spec.ts b/test/e2e/tests/confirmations/signatures/permit.spec.ts index 707405166cc6..de7df8c9dd8e 100644 --- a/test/e2e/tests/confirmations/signatures/permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/permit.spec.ts @@ -1,3 +1,4 @@ +import { strict as assert } from 'assert'; import { TransactionEnvelopeType } from '@metamask/transaction-controller'; import { Suite } from 'mocha'; import { MockedEndpoint } from 'mockttp'; diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts index 3bfdd7ebc470..596fa8a6ed64 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -60,7 +60,7 @@ export function useTypesSignSimulationEnabledInfo() { return ( useTransactionSimulations && isTypedSignV4 && - (isPermit || nonPermitSupportedByDecodingAPI) + (isPermit || nonPermitSupportedByDecodingAPI) || true ); }, [isTypedSignV4, isPermit, nonPermitSupportedByDecodingAPI]); } From d08b04bff097d570173e3be7a59ed85deec38a77 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 17:46:34 +0530 Subject: [PATCH 11/17] update --- .../hooks/useTypesSignSimulationEnabledInfo.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts index 596fa8a6ed64..08460638d937 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -46,9 +46,10 @@ export function useTypesSignSimulationEnabledInfo() { selectUseTransactionSimulations, ); - const isTypedSignV4 = - currentConfirmation?.msgParams?.signatureMethod === - MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4; + const signatureMethod = currentConfirmation?.msgParams?.signatureMethod; + const isTypedSignV3V4 = + signatureMethod === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4 || + signatureMethod === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3; const isPermit = isPermitSignatureRequest(currentConfirmation); const nonPermitSupportedByDecodingAPI = isNonPermitSupportedByDecodingAPI(currentConfirmation); @@ -59,8 +60,8 @@ export function useTypesSignSimulationEnabledInfo() { } return ( useTransactionSimulations && - isTypedSignV4 && + isTypedSignV3V4 && (isPermit || nonPermitSupportedByDecodingAPI) || true ); - }, [isTypedSignV4, isPermit, nonPermitSupportedByDecodingAPI]); + }, [isTypedSignV3V4, isPermit, nonPermitSupportedByDecodingAPI]); } From 390dacc53255ebacaf89cfd2c0957bacf9c76d6a Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 18:00:10 +0530 Subject: [PATCH 12/17] update --- builds.yml | 2 +- .../info/__snapshots__/info.test.tsx.snap | 778 +------ .../__snapshots__/typed-sign.test.tsx.snap | 1895 ++--------------- .../__snapshots__/confirm.test.tsx.snap | 1362 +----------- .../useTypesSignSimulationEnabledInfo.test.ts | 6 +- 5 files changed, 353 insertions(+), 3690 deletions(-) diff --git a/builds.yml b/builds.yml index 5bbe17480496..3963aeda93e5 100644 --- a/builds.yml +++ b/builds.yml @@ -236,7 +236,7 @@ env: # Used to enable confirmation redesigned pages - ENABLE_CONFIRMATION_REDESIGN: '' # URL of the decoding API used to provide additional data from signature requests - - DECODING_API_URL: 'https://signature-insights.api.cx.metamask.io/v1' + - DECODING_API_URL: 'https://qtgdj2huxh.execute-api.us-east-2.amazonaws.com/uat/v1' # Determines if feature flagged Settings Page - Developer Options should be used - ENABLE_SETTINGS_PAGE_DEV_OPTIONS: false # Used for debugging changes to the phishing warning page. diff --git a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap index bdcc3e7db452..daa8641bcee2 100644 --- a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap @@ -24,7 +24,7 @@ exports[`Info renders info section for approve request 1`] = `

+
+
+
+
+

+ Estimated changes +

+
+
+ +
+
+
+
+
+

+ Unavailable +

+
+
@@ -1412,705 +1467,6 @@ exports[`Info renders info section for typed sign request 1`] = `

-
-
-
-
-

- Primary type: -

-
-
-
-

- Mail -

-
-
-
-
-
-
-
-

- Contents: -

-
-
-
-

- Hello, Bob! -

-
-
-
-
-
-

- From: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Cow -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xDeaDb...DbeeF -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0x06195...43896 -

-
-
-
-
-
-
-
-
-
-
-

- To: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Bob -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xbBbBB...bBBbB -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xB0Bda...bEa57 -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0xB0B0b...00000 -

-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap index 20998032a049..2c52e01bdf19 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap @@ -23,7 +23,7 @@ exports[`TypedSignInfo correctly renders permit sign type 1`] = `

+
+
+
+
+

+ Estimated changes +

+
+
+ +
+
+
+
+
+

+ Unavailable +

+
+
@@ -1128,712 +1183,57 @@ exports[`TypedSignInfo renders origin for typed sign data request 1`] = `

+
+
+
+`; + +exports[`TypedSignInfo should render message for typed sign v3 request 1`] = ` +
+
+
-
-
-

- Primary type: -

-
-
-
-

- Mail -

-
-
-
-
+ Estimated changes +

+
-
-
-

- Contents: -

-
-
-
-

- Hello, Bob! -

-
-
-
-
-
-

- From: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Cow -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xDeaDb...DbeeF -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0x06195...43896 -

-
-
-
-
-
-
-
-
-
-
-

- To: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Bob -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xbBbBB...bBBbB -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xB0Bda...bEa57 -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0xB0B0b...00000 -

-
-
-
-
-
-
-
-
+
+

+ Unavailable +

-
-`; - -exports[`TypedSignInfo should render message for typed sign v3 request 1`] = ` -
+
@@ -2062,339 +1473,57 @@ exports[`TypedSignInfo should render message for typed sign v3 request 1`] = `

+
+
+
+`; + +exports[`TypedSignInfo should render message for typed sign v4 request 1`] = ` +
+
+
-
-
-

- Primary type: -

-
-
-
-

- Mail -

-
-
-
-
+ Estimated changes +

+
-
-
-

- From: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Cow -

-
-
-
-
-
-

- Wallet: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-
-
-

- To: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Bob -

-
-
-
-
-
-

- Wallet: -

-
-
-
-
- -

- 0xbBbBB...bBBbB -

-
-
-
-
-
-
-
-
-

- Contents: -

-
-
-
-

- Hello, Bob! -

-
+
+

+ Unavailable +

-
-`; - -exports[`TypedSignInfo should render message for typed sign v4 request 1`] = ` -
+
@@ -2623,705 +1763,6 @@ exports[`TypedSignInfo should render message for typed sign v4 request 1`] = `

-
-
-
-
-

- Primary type: -

-
-
-
-

- Mail -

-
-
-
-
-
-
-
-

- Contents: -

-
-
-
-

- Hello, Bob! -

-
-
-
-
-
-

- From: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Cow -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xDeaDb...DbeeF -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0x06195...43896 -

-
-
-
-
-
-
-
-
-
-
-

- To: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Bob -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xbBbBB...bBBbB -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xB0Bda...bEa57 -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0xB0B0b...00000 -

-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap index e7e2e499dfe9..1ceeea6b5303 100644 --- a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap +++ b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap @@ -424,7 +424,7 @@ exports[`Confirm should match snapshot for signature - typed sign - V4 - PermitB >
Review request details before you confirm.

+
+
+
+
+

+ Estimated changes +

+
+
+ +
+
+
+
+
+

+ Unavailable +

+
+
@@ -1953,705 +2008,6 @@ exports[`Confirm should match snapshot for signature - typed sign - V4 1`] = `

-
-
-
-
-

- Primary type: -

-
-
-
-

- Mail -

-
-
-
-
-
-
-
-

- Contents: -

-
-
-
-

- Hello, Bob! -

-
-
-
-
-
-

- From: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Cow -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xDeaDb...DbeeF -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0x06195...43896 -

-
-
-
-
-
-
-
-
-
-
-

- To: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
-
-
-

- Name: -

-
-
-
-

- Bob -

-
-
-
-
-
-

- Wallets: -

-
-
-
-
-
-
-

- 0: -

-
-
-
-
- -

- 0xbBbBB...bBBbB -

-
-
-
-
-
-
-

- 1: -

-
-
-
-
- -

- 0xB0Bda...bEa57 -

-
-
-
-
-
-
-

- 2: -

-
-
-
-
- -

- 0xB0B0b...00000 -

-
-
-
-
-
-
-
-
-
-
-
-
@@ -3409,6 +2765,50 @@ exports[`Confirm should match snapshot signature - typed sign - order 1`] = ` > Review request details before you confirm.

+
+
+
+
+

+ Estimated changes +

+
+
+ +
+
+
+
+
+

+ Unavailable +

+
-
-
-
-
-

- Primary type: -

-
-
-
-

- Order -

-
-
-
-
-
-
-
-

- Direction: -

-
-
-
-

- 0 -

-
-
-
-
-
-

- Maker: -

-
-
-
-
- -

- Test Account -

-
-
-
-
-
-
-

- Taker: -

-
-
-
-
- -

- 0xCD2a3...DD826 -

-
-
-
-
-
-
-

- Expiry: -

-
-
-
-

- 2524604400 -

-
-
-
-
-
-

- Nonce: -

-
-
-
-

- 100131415900000000000000000000000000000083840314483690155566137712510085002484 -

-
-
-
-
-
-

- Erc20Token: -

-
-
-
-
- -

- 0xC02aa...56Cc2 -

-
-
-
-
-
-
-

- Erc20TokenAmount: -

-
-
-
-

- 42000000000000 -

-
-
-
-
-
-

- Fees: -

-
-
-
-
-
-
-
-

- Erc721Token: -

-
-
-
-
- -

- 0x8a90C...8992e -

-
-
-
-
-
-
-

- Erc721TokenId: -

-
-
-
-

- 2516 -

-
-
-
-
-
-

- Erc721TokenProperties: -

-
-
-
-
-
-
-
diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts index 5636927782d0..ce98f58782d7 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts @@ -3,7 +3,7 @@ import { renderHookWithConfirmContextProvider } from '../../../../test/lib/confi import { permitSingleSignatureMsg, seaportSignatureMsg, - unapprovedTypedSignMsgV3, + unapprovedTypedSignMsgV1, } from '../../../../test/data/confirmations/typed_sign'; import { useTypesSignSimulationEnabledInfo } from './useTypesSignSimulationEnabledInfo'; @@ -24,9 +24,9 @@ describe('useTypesSignSimulationEnabledInfo', () => { expect(result.current).toBe(false); }); - it('return false if request is not types sign V4', async () => { + it('return false if request is not types sign v3 or V4', async () => { const state = getMockTypedSignConfirmStateForRequest( - unapprovedTypedSignMsgV3, + unapprovedTypedSignMsgV1, { metamask: { useTransactionSimulations: true }, }, From 5aee9e23c45150407f6f963ac565fbe88fd79507 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 18:15:53 +0530 Subject: [PATCH 13/17] update --- .../hooks/useTypesSignSimulationEnabledInfo.test.ts | 2 +- .../confirmations/hooks/useTypesSignSimulationEnabledInfo.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts index ce98f58782d7..83ec972a02e6 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts @@ -24,7 +24,7 @@ describe('useTypesSignSimulationEnabledInfo', () => { expect(result.current).toBe(false); }); - it('return false if request is not types sign v3 or V4', async () => { + it.only('return false if request is not types sign v3 or V4', async () => { const state = getMockTypedSignConfirmStateForRequest( unapprovedTypedSignMsgV1, { diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts index 08460638d937..3b65e9a0f8d8 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -52,7 +52,7 @@ export function useTypesSignSimulationEnabledInfo() { signatureMethod === MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3; const isPermit = isPermitSignatureRequest(currentConfirmation); const nonPermitSupportedByDecodingAPI = - isNonPermitSupportedByDecodingAPI(currentConfirmation); + isTypedSignV3V4 && isNonPermitSupportedByDecodingAPI(currentConfirmation); return useMemo(() => { if (!currentConfirmation) { @@ -61,7 +61,7 @@ export function useTypesSignSimulationEnabledInfo() { return ( useTransactionSimulations && isTypedSignV3V4 && - (isPermit || nonPermitSupportedByDecodingAPI) || true + (isPermit || nonPermitSupportedByDecodingAPI) ); }, [isTypedSignV3V4, isPermit, nonPermitSupportedByDecodingAPI]); } From 334abc548136c4c6acc0d82b4b9eef250ae94605 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 18:30:15 +0530 Subject: [PATCH 14/17] update --- .../info/__snapshots__/info.test.tsx.snap | 778 ++++++- .../__snapshots__/typed-sign.test.tsx.snap | 1895 +++++++++++++++-- .../__snapshots__/confirm.test.tsx.snap | 1362 +++++++++++- 3 files changed, 3686 insertions(+), 349 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap index daa8641bcee2..bdcc3e7db452 100644 --- a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap @@ -24,7 +24,7 @@ exports[`Info renders info section for approve request 1`] = `

-
-
-
-
-

- Estimated changes -

-
-
- -
-
-
-
-
-

- Unavailable -

-
-
@@ -1467,6 +1412,705 @@ exports[`Info renders info section for typed sign request 1`] = `

+
+
+
+
+

+ Primary type: +

+
+
+
+

+ Mail +

+
+
+
+
+
+
+
+

+ Contents: +

+
+
+
+

+ Hello, Bob! +

+
+
+
+
+
+

+ From: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Cow +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xDeaDb...DbeeF +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0x06195...43896 +

+
+
+
+
+
+
+
+
+
+
+

+ To: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Bob +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xbBbBB...bBBbB +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xB0Bda...bEa57 +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0xB0B0b...00000 +

+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap index 2c52e01bdf19..20998032a049 100644 --- a/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/typed-sign/__snapshots__/typed-sign.test.tsx.snap @@ -23,7 +23,7 @@ exports[`TypedSignInfo correctly renders permit sign type 1`] = `

-
-
-
-
-

- Estimated changes -

-
-
- -
-
-
-
-
-

- Unavailable -

-
-
@@ -1183,57 +1128,712 @@ exports[`TypedSignInfo renders origin for typed sign data request 1`] = `

-
-
-
-`; - -exports[`TypedSignInfo should render message for typed sign v3 request 1`] = ` -
-
-
-

- Estimated changes -

-
- +

+ Primary type: +

+
+
+
+

+ Mail +

+
+
+
+
+
+
+
+

+ Contents: +

+
+
+
+

+ Hello, Bob! +

+
+
+
+
+
+

+ From: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Cow +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xDeaDb...DbeeF +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0x06195...43896 +

+
+
+
+
+
+
+
+
+
+
+

+ To: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Bob +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xbBbBB...bBBbB +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xB0Bda...bEa57 +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0xB0B0b...00000 +

+
+
+
+
+
+
+
+
-

- Unavailable -

+
+`; + +exports[`TypedSignInfo should render message for typed sign v3 request 1`] = ` +
-
@@ -1473,57 +2062,339 @@ exports[`TypedSignInfo should render message for typed sign v3 request 1`] = `

-
-
-
-`; - -exports[`TypedSignInfo should render message for typed sign v4 request 1`] = ` -
-
-
-

- Estimated changes -

-
- +

+ Primary type: +

+
+
+
+

+ Mail +

+
+
+
+
+
+
+
+

+ From: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Cow +

+
+
+
+
+
+

+ Wallet: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+
+
+

+ To: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Bob +

+
+
+
+
+
+

+ Wallet: +

+
+
+
+
+ +

+ 0xbBbBB...bBBbB +

+
+
+
+
+
+
+
+
+

+ Contents: +

+
+
+
+

+ Hello, Bob! +

+
-

- Unavailable -

+
+`; + +exports[`TypedSignInfo should render message for typed sign v4 request 1`] = ` +
-
@@ -1763,6 +2623,705 @@ exports[`TypedSignInfo should render message for typed sign v4 request 1`] = `

+
+
+
+
+

+ Primary type: +

+
+
+
+

+ Mail +

+
+
+
+
+
+
+
+

+ Contents: +

+
+
+
+

+ Hello, Bob! +

+
+
+
+
+
+

+ From: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Cow +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xDeaDb...DbeeF +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0x06195...43896 +

+
+
+
+
+
+
+
+
+
+
+

+ To: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Bob +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xbBbBB...bBBbB +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xB0Bda...bEa57 +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0xB0B0b...00000 +

+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap index 1ceeea6b5303..e7e2e499dfe9 100644 --- a/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap +++ b/ui/pages/confirmations/confirm/__snapshots__/confirm.test.tsx.snap @@ -424,7 +424,7 @@ exports[`Confirm should match snapshot for signature - typed sign - V4 - PermitB >
Review request details before you confirm.

-
-
-
-
-

- Estimated changes -

-
-
- -
-
-
-
-
-

- Unavailable -

-
-
@@ -2008,6 +1953,705 @@ exports[`Confirm should match snapshot for signature - typed sign - V4 1`] = `

+
+
+
+
+

+ Primary type: +

+
+
+
+

+ Mail +

+
+
+
+
+
+
+
+

+ Contents: +

+
+
+
+

+ Hello, Bob! +

+
+
+
+
+
+

+ From: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Cow +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xDeaDb...DbeeF +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0x06195...43896 +

+
+
+
+
+
+
+
+
+
+
+

+ To: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+
+
+

+ Name: +

+
+
+
+

+ Bob +

+
+
+
+
+
+

+ Wallets: +

+
+
+
+
+
+
+

+ 0: +

+
+
+
+
+ +

+ 0xbBbBB...bBBbB +

+
+
+
+
+
+
+

+ 1: +

+
+
+
+
+ +

+ 0xB0Bda...bEa57 +

+
+
+
+
+
+
+

+ 2: +

+
+
+
+
+ +

+ 0xB0B0b...00000 +

+
+
+
+
+
+
+
+
+
+
+
+
@@ -2765,50 +3409,6 @@ exports[`Confirm should match snapshot signature - typed sign - order 1`] = ` > Review request details before you confirm.

-
-
-
-
-

- Estimated changes -

-
-
- -
-
-
-
-
-

- Unavailable -

-
+
+
+
+
+

+ Primary type: +

+
+
+
+

+ Order +

+
+
+
+
+
+
+
+

+ Direction: +

+
+
+
+

+ 0 +

+
+
+
+
+
+

+ Maker: +

+
+
+
+
+ +

+ Test Account +

+
+
+
+
+
+
+

+ Taker: +

+
+
+
+
+ +

+ 0xCD2a3...DD826 +

+
+
+
+
+
+
+

+ Expiry: +

+
+
+
+

+ 2524604400 +

+
+
+
+
+
+

+ Nonce: +

+
+
+
+

+ 100131415900000000000000000000000000000083840314483690155566137712510085002484 +

+
+
+
+
+
+

+ Erc20Token: +

+
+
+
+
+ +

+ 0xC02aa...56Cc2 +

+
+
+
+
+
+
+

+ Erc20TokenAmount: +

+
+
+
+

+ 42000000000000 +

+
+
+
+
+
+

+ Fees: +

+
+
+
+
+
+
+
+

+ Erc721Token: +

+
+
+
+
+ +

+ 0x8a90C...8992e +

+
+
+
+
+
+
+

+ Erc721TokenId: +

+
+
+
+

+ 2516 +

+
+
+
+
+
+

+ Erc721TokenProperties: +

+
+
+
+
+
+
+
From bedbed12d4ea3e9a8de64bb704b5cc0bb4be1e39 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 18:49:11 +0530 Subject: [PATCH 15/17] update --- .../useTypesSignSimulationEnabledInfo.test.ts | 2 +- .../useTypesSignSimulationEnabledInfo.ts | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts index 83ec972a02e6..ce98f58782d7 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.test.ts @@ -24,7 +24,7 @@ describe('useTypesSignSimulationEnabledInfo', () => { expect(result.current).toBe(false); }); - it.only('return false if request is not types sign v3 or V4', async () => { + it('return false if request is not types sign v3 or V4', async () => { const state = getMockTypedSignConfirmStateForRequest( unapprovedTypedSignMsgV1, { diff --git a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts index 3b65e9a0f8d8..96703bffc0fb 100644 --- a/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts +++ b/ui/pages/confirmations/hooks/useTypesSignSimulationEnabledInfo.ts @@ -1,4 +1,3 @@ -import { useMemo } from 'react'; import { useSelector } from 'react-redux'; import { MESSAGE_TYPE } from '../../../../shared/constants/app'; @@ -54,14 +53,13 @@ export function useTypesSignSimulationEnabledInfo() { const nonPermitSupportedByDecodingAPI = isTypedSignV3V4 && isNonPermitSupportedByDecodingAPI(currentConfirmation); - return useMemo(() => { - if (!currentConfirmation) { - return undefined; - } - return ( - useTransactionSimulations && - isTypedSignV3V4 && - (isPermit || nonPermitSupportedByDecodingAPI) - ); - }, [isTypedSignV3V4, isPermit, nonPermitSupportedByDecodingAPI]); + if (!currentConfirmation) { + return undefined; + } + + return ( + useTransactionSimulations && + isTypedSignV3V4 && + (isPermit || nonPermitSupportedByDecodingAPI) + ); } From 34cec6e01fae4d9693afac4e54ff7c76f8075aac Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 18:55:41 +0530 Subject: [PATCH 16/17] update --- test/e2e/tests/confirmations/signatures/permit.spec.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/e2e/tests/confirmations/signatures/permit.spec.ts b/test/e2e/tests/confirmations/signatures/permit.spec.ts index de7df8c9dd8e..f4c55582cb0a 100644 --- a/test/e2e/tests/confirmations/signatures/permit.spec.ts +++ b/test/e2e/tests/confirmations/signatures/permit.spec.ts @@ -120,10 +120,9 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) { this.test?.fullTitle(), TransactionEnvelopeType.legacy, async ({ driver }: TestSuiteArguments) => { - await unlockWallet(driver); - await openDapp(driver); - await driver.clickElement('#signPermit'); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await initializePages(driver); + await openDappAndTriggerSignature(driver, SignatureType.Permit); + const simulationSection = driver.findElement({ text: 'Estimated changes', }); From e33a04481f3387d16dce8aeb1e1b4f0b224342d3 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 28 Nov 2024 20:56:29 +0530 Subject: [PATCH 17/17] update --- privacy-snapshot.json | 1 - 1 file changed, 1 deletion(-) diff --git a/privacy-snapshot.json b/privacy-snapshot.json index caaf4b62fb0a..5620903a5c73 100644 --- a/privacy-snapshot.json +++ b/privacy-snapshot.json @@ -49,7 +49,6 @@ "proxy.api.cx.metamask.io", "proxy.dev-api.cx.metamask.io", "qtgdj2huxh.execute-api.us-east-2.amazonaws.com", - "https://signature-insights.api.cx.metamask.io", "raw.githubusercontent.com", "registry.npmjs.org", "responsive-rpc.test",