Skip to content

Commit

Permalink
fix: bump notification controllers (#11349)
Browse files Browse the repository at this point in the history
## **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**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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 <[email protected]>
Co-authored-by: Jonathan Ferreira <[email protected]>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 6e8d831 commit 3c757f3
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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();
Expand All @@ -42,7 +35,6 @@ describe('NetworkFeeField', () => {
const { toJSON } = render(
<NetworkFeeField
type={ModalFieldType.NETWORK_FEE}
{...MOCK_NOTIFICATION.data.network_fee}
isCollapsed={isCollapsed}
setIsCollapsed={setIsCollapsed}
getNetworkFees={() =>
Expand All @@ -58,7 +50,7 @@ describe('NetworkFeeField', () => {
chainId: '0x1',
})
}
notification={MOCK_NOTIFICATION as Notification}
notification={MOCK_NOTIFICATION}
/>,
);

Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/Notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ NotificationsView.navigationOptions = ({
/>
),
headerTitle: () => (
<Text variant={TextVariant.HeadingMD}>
<Text variant={TextVariant.HeadingMD} style={styles.title}>
{strings('app_settings.notifications_title')}
</Text>
),
Expand Down
1 change: 1 addition & 0 deletions app/components/Views/Notifications/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const styles = StyleSheet.create({
position: 'absolute',
},
icon: { marginHorizontal: 16 },
title: { alignSelf: 'center' },
});

export default styles;
15 changes: 11 additions & 4 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand Down
2 changes: 2 additions & 0 deletions app/declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
48 changes: 30 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand All @@ -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==
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -25455,6 +25454,14 @@ [email protected]:
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"

[email protected]:
version "0.1.11"
resolved "https://registry.yarnpkg.com/react-native-flash-message/-/react-native-flash-message-0.1.11.tgz#29be9e77847e6a540aee7ba46add0b9de43f52ff"
Expand Down Expand Up @@ -26704,6 +26711,11 @@ [email protected]:
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"
Expand Down

0 comments on commit 3c757f3

Please sign in to comment.