From 3c757f316f7830106b1bcc9d3d1f0ae3d43832e5 Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Mon, 23 Sep 2024 10:59:05 +0100 Subject: [PATCH] fix: bump notification controllers (#11349) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This is a branch off from a revert. Slowly adding back commits to see where the e2e android tests fail. ## **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. --------- Co-authored-by: JSoufer Co-authored-by: Jonathan Ferreira <44679989+Jonathansoufer@users.noreply.github.com> --- .../Details/Fields/NetworkFeeField.test.tsx | 20 +++----- app/components/Views/Notifications/index.tsx | 2 +- app/components/Views/Notifications/styles.ts | 1 + app/core/Engine.ts | 15 ++++-- app/declarations/index.d.ts | 2 + ios/Podfile.lock | 6 +++ package.json | 5 +- yarn.lock | 48 ++++++++++++------- 8 files changed, 60 insertions(+), 39 deletions(-) diff --git a/app/components/Views/Notifications/Details/Fields/NetworkFeeField.test.tsx b/app/components/Views/Notifications/Details/Fields/NetworkFeeField.test.tsx index de32edec86b..7d2b8274b0d 100644 --- a/app/components/Views/Notifications/Details/Fields/NetworkFeeField.test.tsx +++ b/app/components/Views/Notifications/Details/Fields/NetworkFeeField.test.tsx @@ -1,17 +1,10 @@ import React from 'react'; import { render } from '@testing-library/react-native'; import NetworkFeeField from './NetworkFeeField'; -import { OnChainRawNotificationsWithNetworkFields } from '@metamask/notification-services-controller/dist/types/NotificationServicesController/types'; -import { - ModalFieldType, - type Notification, -} from '../../../../../util/notifications'; -import { NotificationServicesController } from '@metamask/notification-services-controller'; +import { ModalFieldType } from '../../../../../util/notifications'; +import { processNotification } from '@metamask/notification-services-controller/notification-services'; +import { createMockNotificationEthReceived } from '@metamask/notification-services-controller/notification-services/mocks'; -const { - Processors: { processNotification }, - Mocks, -} = NotificationServicesController; jest.mock('../../../../../util/notifications/methods/common', () => ({ getNetworkFees: () => Promise.resolve({ @@ -27,8 +20,8 @@ jest.mock('../../../../../util/notifications/methods/common', () => ({ })); const MOCK_NOTIFICATION = processNotification( - Mocks.createMockNotificationEthReceived(), -) as OnChainRawNotificationsWithNetworkFields; + createMockNotificationEthReceived(), +); describe('NetworkFeeField', () => { const setIsCollapsed = jest.fn(); @@ -42,7 +35,6 @@ describe('NetworkFeeField', () => { const { toJSON } = render( @@ -58,7 +50,7 @@ describe('NetworkFeeField', () => { chainId: '0x1', }) } - notification={MOCK_NOTIFICATION as Notification} + notification={MOCK_NOTIFICATION} />, ); diff --git a/app/components/Views/Notifications/index.tsx b/app/components/Views/Notifications/index.tsx index a38ffeb1b50..f794c4ba76d 100644 --- a/app/components/Views/Notifications/index.tsx +++ b/app/components/Views/Notifications/index.tsx @@ -143,7 +143,7 @@ NotificationsView.navigationOptions = ({ /> ), headerTitle: () => ( - + {strings('app_settings.notifications_title')} ), diff --git a/app/components/Views/Notifications/styles.ts b/app/components/Views/Notifications/styles.ts index fa14c20c8d2..a803a435637 100644 --- a/app/components/Views/Notifications/styles.ts +++ b/app/components/Views/Notifications/styles.ts @@ -12,6 +12,7 @@ const styles = StyleSheet.create({ position: 'absolute', }, icon: { marginHorizontal: 16 }, + title: { alignSelf: 'center' }, }); export default styles; diff --git a/app/core/Engine.ts b/app/core/Engine.ts index ad57c2edab8..bdc0bb50bd3 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-shadow */ import Crypto from 'react-native-quick-crypto'; +import { scrypt } from 'react-native-fast-crypto'; import { AccountTrackerController, AccountTrackerState, @@ -1230,7 +1231,6 @@ class Engine { const authenticationController = new AuthenticationController.Controller({ state: initialState.AuthenticationController, - // @ts-expect-error TODO: Resolve mismatch between base-controller versions. messenger: this.controllerMessenger.getRestricted({ name: 'AuthenticationController', allowedActions: [ @@ -1252,7 +1252,6 @@ class Engine { const userStorageController = new UserStorageController.Controller({ getMetaMetricsState: () => MetaMetrics.getInstance().isEnabled(), state: initialState.UserStorageController, - // @ts-expect-error TODO: Resolve mismatch between base-controller versions. messenger: this.controllerMessenger.getRestricted({ name: 'UserStorageController', allowedActions: [ @@ -1265,14 +1264,22 @@ class Engine { 'AuthenticationController:performSignIn', 'NotificationServicesController:disableNotificationServices', 'NotificationServicesController:selectIsNotificationServicesEnabled', + 'KeyringController:addNewAccount', + 'AccountsController:listAccounts', + 'AccountsController:updateAccountMetadata', + ], + allowedEvents: [ + 'KeyringController:lock', + 'KeyringController:unlock', + 'AccountsController:accountAdded', + 'AccountsController:accountRenamed', ], - allowedEvents: ['KeyringController:unlock', 'KeyringController:lock'], }), + nativeScryptCrypto: scrypt, }); const notificationServicesController = new NotificationServicesController.Controller({ - // @ts-expect-error TODO: Resolve mismatch between base-controller versions. messenger: this.controllerMessenger.getRestricted({ name: 'NotificationServicesController', allowedActions: [ diff --git a/app/declarations/index.d.ts b/app/declarations/index.d.ts index 04d7a1238f9..094baa70c44 100644 --- a/app/declarations/index.d.ts +++ b/app/declarations/index.d.ts @@ -6,6 +6,8 @@ declare module '@metamask/react-native-payments/lib/js/__mocks__'; declare module 'react-native-fade-in-image'; +declare module 'react-native-fast-crypto'; + declare module 'react-native-minimizer'; declare module 'xhr2'; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index de82cd678de..8c3ab2ee96c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -532,6 +532,8 @@ PODS: - React-Core - react-native-cookies (6.2.1): - React-Core + - react-native-fast-crypto (2.2.0): + - React - react-native-flipper (0.263.0): - React-Core - react-native-get-random-values (1.8.0): @@ -854,6 +856,7 @@ DEPENDENCIES: - react-native-camera (from `../node_modules/react-native-camera`) - "react-native-compat (from `../node_modules/@walletconnect/react-native-compat`)" - "react-native-cookies (from `../node_modules/@react-native-cookies/cookies`)" + - react-native-fast-crypto (from `../node_modules/react-native-fast-crypto`) - react-native-flipper (from `../node_modules/react-native-flipper`) - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) - react-native-gzip (from `../node_modules/react-native-gzip`) @@ -1029,6 +1032,8 @@ EXTERNAL SOURCES: :path: "../node_modules/@walletconnect/react-native-compat" react-native-cookies: :path: "../node_modules/@react-native-cookies/cookies" + react-native-fast-crypto: + :path: "../node_modules/react-native-fast-crypto" react-native-flipper: :path: "../node_modules/react-native-flipper" react-native-get-random-values: @@ -1228,6 +1233,7 @@ SPEC CHECKSUMS: react-native-camera: b8cc03e2feec0c04403d0998e37cf519d8fd4c6f react-native-compat: 8b6a38155e778a20a008aea837efd00e099b6fe8 react-native-cookies: f54fcded06bb0cda05c11d86788020b43528a26c + react-native-fast-crypto: 5943c42466b86ad70be60d3a5f64bd22251e5d9e react-native-flipper: 6cfd5991388121f7f96fc5171b93380f97ebb3c6 react-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a react-native-gzip: c5e87ee9e359f02350e3a2ee52eb35eddc398868 diff --git a/package.json b/package.json index fc5edcea51e..6f6a443a937 100644 --- a/package.json +++ b/package.json @@ -170,13 +170,13 @@ "@metamask/logging-controller": "^3.0.0", "@metamask/message-signing-snap": "^0.3.3", "@metamask/network-controller": "^20.1.0", - "@metamask/notification-services-controller": "^0.2.1", + "@metamask/notification-services-controller": "^0.8.0", "@metamask/permission-controller": "^11.0.0", "@metamask/phishing-controller": "^9.0.0", "@metamask/post-message-stream": "^8.0.0", "@metamask/ppom-validator": "0.32.0", "@metamask/preferences-controller": "^11.0.0", - "@metamask/profile-sync-controller": "^0.2.1", + "@metamask/profile-sync-controller": "^0.8.1", "@metamask/react-native-actionsheet": "2.4.2", "@metamask/react-native-button": "^3.0.0", "@metamask/react-native-payments": "^2.0.0", @@ -303,6 +303,7 @@ "react-native-elevated-view": "0.0.6", "react-native-emoji": "1.3.1", "react-native-fade-in-image": "1.4.1", + "react-native-fast-crypto": "^2.2.0", "react-native-flash-message": "0.1.11", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^1.10.3", diff --git a/yarn.lock b/yarn.lock index 1196f6a5531..2530ce065b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4781,16 +4781,15 @@ "@ethersproject/providers" "^5.7.2" async-mutex "^0.3.1" -"@metamask/notification-services-controller@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@metamask/notification-services-controller/-/notification-services-controller-0.2.1.tgz#aa36275d20f71297d73c33055e88bf55b33ac4d9" - integrity sha512-TvQAiA38a8j0r7amNQivi4itFFfuNAGrCWJUGbKqyu/rZiS2itTFLXchhazGu1H8TK3lxOx9r7C/RfRYwkuDpA== +"@metamask/notification-services-controller@^0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@metamask/notification-services-controller/-/notification-services-controller-0.8.0.tgz#f57943f364b22c679d692df7048355bbd557cc31" + integrity sha512-S1PrCwe6k4wv32qvpfueeSVjWp/AMMizLWGBzsbLaM3ElkK+aAeVkP0UARuHHt/IlXxvbpjeSvYIe8GINPn9Pw== dependencies: "@contentful/rich-text-html-renderer" "^16.5.2" - "@metamask/base-controller" "^6.0.2" - "@metamask/controller-utils" "^11.0.2" + "@metamask/base-controller" "^7.0.1" + "@metamask/controller-utils" "^11.3.0" bignumber.js "^4.1.0" - contentful "^10.3.6" firebase "^10.11.0" loglevel "^1.8.1" uuid "^8.3.2" @@ -4974,14 +4973,14 @@ "@metamask/base-controller" "^5.0.2" "@metamask/controller-utils" "^9.1.0" -"@metamask/profile-sync-controller@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@metamask/profile-sync-controller/-/profile-sync-controller-0.2.1.tgz#b9e4d951ba357c7b26dd4ad68049635f1b6947e1" - integrity sha512-F4domapXsNmN2LmEUzOGTWPoTmlorlebCnh8LW6JxbIQuqgyi+sKpfE0zb2M60Z8AYR6v+qnjw7X47CS9HHupQ== +"@metamask/profile-sync-controller@^0.8.1": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@metamask/profile-sync-controller/-/profile-sync-controller-0.8.1.tgz#f2c5c89710286ad885756fe887405edb51fd3d81" + integrity sha512-kD9NxAJxly1ngD8RE6wK+hGIDhoHwYG5RBqP3rRAdtr2pOVlCFAbNVFZjfjFyEK8fpOw+5qwhR3h0yKzjVrzaw== dependencies: - "@metamask/base-controller" "^6.0.2" - "@metamask/snaps-sdk" "^6.1.1" - "@metamask/snaps-utils" "^7.8.1" + "@metamask/base-controller" "^7.0.1" + "@metamask/snaps-sdk" "^6.5.0" + "@metamask/snaps-utils" "^8.1.1" "@noble/ciphers" "^0.5.2" "@noble/hashes" "^1.4.0" immer "^9.0.6" @@ -5278,7 +5277,7 @@ fast-xml-parser "^4.3.4" superstruct "^1.0.3" -"@metamask/snaps-sdk@^6.0.0", "@metamask/snaps-sdk@^6.1.0", "@metamask/snaps-sdk@^6.1.1", "@metamask/snaps-sdk@^6.4.0", "@metamask/snaps-sdk@^6.5.0", "@metamask/snaps-sdk@^6.5.1": +"@metamask/snaps-sdk@^6.0.0", "@metamask/snaps-sdk@^6.1.0", "@metamask/snaps-sdk@^6.4.0", "@metamask/snaps-sdk@^6.5.0", "@metamask/snaps-sdk@^6.5.1": version "6.5.1" resolved "https://registry.yarnpkg.com/@metamask/snaps-sdk/-/snaps-sdk-6.5.1.tgz#527691767d98c08c802656b020d5d94d6336623e" integrity sha512-uQEZZNjKwHZZfu9StwlmvTFle5MqiheO6AQctVhpYGJ1kjJ7Qwa+vJhMd0Ox1QI9C3qaUCqxOCDV0mpd1jPRKg== @@ -5289,7 +5288,7 @@ "@metamask/superstruct" "^3.1.0" "@metamask/utils" "^9.2.1" -"@metamask/snaps-utils@^7.7.0", "@metamask/snaps-utils@^7.8.0", "@metamask/snaps-utils@^7.8.1": +"@metamask/snaps-utils@^7.7.0", "@metamask/snaps-utils@^7.8.0": version "7.8.1" resolved "https://registry.yarnpkg.com/@metamask/snaps-utils/-/snaps-utils-7.8.1.tgz#d18f56ece8a1d4e9ff2e8e7645c3349cf08937bc" integrity sha512-v0xNoiWeJGHvtJqP0aU5dj+phqpV6vKCJoV5tNBXl8/AvMTaV2YL4SLO/z+PTo0RWZFplgAuuDsY254kAXi9Fw== @@ -13541,7 +13540,7 @@ buffer@^4.9.1: ieee754 "^1.1.4" isarray "^1.0.0" -buffer@^5.1.0, buffer@^5.2.0, buffer@^5.2.1, buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0: +buffer@^5.0.8, buffer@^5.1.0, buffer@^5.2.0, buffer@^5.2.1, buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -14592,7 +14591,7 @@ contentful-sdk-core@^8.1.0: p-throttle "^4.1.1" qs "^6.11.2" -contentful@^10.3.6, contentful@^10.8.7: +contentful@^10.8.7: version "10.12.10" resolved "https://registry.yarnpkg.com/contentful/-/contentful-10.12.10.tgz#b9c47e64febcc87975f2486d77c7d014402a437c" integrity sha512-YVc+aCvehjsJI8K/IglbLjEAl/fiyUzorCFrgR60R4v44VMa4wmFJTrY48x+YQ7DPKZw5MzFk1wgeG74fxCN2g== @@ -25455,6 +25454,14 @@ react-native-fade-in-image@1.4.1: react-mixin "^3.0.5" react-timer-mixin "^0.13.3" +react-native-fast-crypto@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/react-native-fast-crypto/-/react-native-fast-crypto-2.2.0.tgz#062014a563ef34af30e1969ae4ae4b5cd6ab9e44" + integrity sha512-JXQmnXGH3HpJYZrBsR7sL6cO/W3k1pHqTYbwnwTsJ8VUYXIsIEf1T0nMk6Z+XkQNI8RIQOeWJ9AuZLai4onHZg== + dependencies: + buffer "^5.0.8" + rfc4648 "^1.0.0" + react-native-flash-message@0.1.11: version "0.1.11" resolved "https://registry.yarnpkg.com/react-native-flash-message/-/react-native-flash-message-0.1.11.tgz#29be9e77847e6a540aee7ba46add0b9de43f52ff" @@ -26704,6 +26711,11 @@ revalidator@0.1.x: resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b" integrity sha1-/s5hv6DBtSoga9axgZgYS91SOjs= +rfc4648@^1.0.0: + version "1.5.3" + resolved "https://registry.yarnpkg.com/rfc4648/-/rfc4648-1.5.3.tgz#e62b81736c10361ca614efe618a566e93d0b41c0" + integrity sha512-MjOWxM065+WswwnmNONOT+bD1nXzY9Km6u3kzvnx8F8/HXGZdz3T6e6vZJ8Q/RIMUSp/nxqjH3GwvJDy8ijeQQ== + rfdc@^1.3.0, rfdc@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f"