From 1a0dc3b14c03c8a62b3fe3c0a9ef6d67dcb3234f Mon Sep 17 00:00:00 2001 From: tommasini <46944231+tommasini@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:23:50 +0000 Subject: [PATCH] chore: Address derived from SRP (#12528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Added an assertion that the selected address would be the same as the one derived from the SRP ## **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 Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.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-mobile/blob/main/.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. --- .../AesCryptoTestForm.test.tsx | 5 +++ .../AesCryptoTestForm/AesCryptoTestForm.tsx | 20 +++++++++- .../AesCryptoTestForm.test.tsx.snap | 38 +++++++++++++++++++ e2e/pages/Settings/AesCryptoTestForm.js | 6 +++ e2e/selectors/AesCrypto.selectors.js | 3 +- .../accounts/aes/encryption-with-key.spec.js | 6 +++ 6 files changed, 76 insertions(+), 2 deletions(-) diff --git a/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.test.tsx b/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.test.tsx index 162bb706cea..ec653e301a9 100644 --- a/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.test.tsx +++ b/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.test.tsx @@ -3,6 +3,11 @@ import { render } from '@testing-library/react-native'; import AesCryptoTestForm from './AesCryptoTestForm'; +jest.mock('react-redux', () => ({ + ...jest.requireActual('react-redux'), + useSelector: jest.fn(), +})); + jest.mock('@react-navigation/native', () => { const actualReactNavigation = jest.requireActual('@react-navigation/native'); return { diff --git a/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.tsx b/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.tsx index c2217f4e5a3..6768dbf1f0c 100644 --- a/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.tsx +++ b/app/components/Views/AesCryptoTestForm/AesCryptoTestForm.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useCallback } from 'react'; -import { SafeAreaView, ScrollView } from 'react-native'; +import { SafeAreaView, ScrollView, View } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { @@ -19,7 +19,13 @@ import { aesCryptoFormResponses, aesCryptoFormButtons, aesCryptoFormScrollIdentifier, + accountAddress, } from '../../../../e2e/selectors/AesCrypto.selectors'; +import Text, { + TextVariant, +} from '../../../component-library/components/Texts/Text'; +import { selectSelectedInternalAccountFormattedAddress } from '../../../selectors/accountsController'; +import { useSelector } from 'react-redux'; const AesCryptoTestForm = () => { const navigation = useNavigation(); @@ -35,6 +41,10 @@ const AesCryptoTestForm = () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const [keyEncryptedData, setKeyEncryptedData] = useState(); + const selectedFormattedAddress = useSelector( + selectSelectedInternalAccountFormattedAddress, + ); + useEffect(() => { const encryptorInstance = new Encryptor({ keyDerivationOptions: DERIVATION_OPTIONS_DEFAULT_OWASP2023, @@ -136,6 +146,14 @@ const AesCryptoTestForm = () => { return ( + + + Current selected address + + + {selectedFormattedAddress} + + + + + Current selected address + + +