Skip to content

Commit 4fd64bb

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/metadata-access-token
2 parents 9a502b8 + 190e9e0 commit 4fd64bb

File tree

100 files changed

+2279
-1159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2279
-1159
lines changed

app/_locales/en/messages.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/scripts/app-init.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// We don't usually `import` files into `app-init.js` because we need to load
44
// "chunks" via `importScripts`; but in this case `promise-with-resolvers` file
55
// is so small we won't ever have a problem with these two files being "split".
6-
// Import to set up global `Promise.withResolvers` polyfill
7-
import '../../shared/lib/promise-with-resolvers';
6+
import { withResolvers } from '../../shared/lib/promise-with-resolvers';
87

98
// Represents if importAllScripts has been run
109
// eslint-disable-next-line
@@ -200,7 +199,7 @@ const registerInPageContentScript = async () => {
200199
*
201200
* @type {PromiseWithResolvers<chrome.runtime.InstalledDetails>}
202201
*/
203-
const deferredOnInstalledListener = Promise.withResolvers();
202+
const deferredOnInstalledListener = withResolvers();
204203
globalThis.stateHooks.onInstalledListener = deferredOnInstalledListener.promise;
205204

206205
/**

app/scripts/background.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import browser from 'webextension-polyfill';
1414
import { isObject, hasProperty } from '@metamask/utils';
1515
import PortStream from 'extension-port-stream';
1616
import { NotificationServicesController } from '@metamask/notification-services-controller';
17-
// Import to set up global `Promise.withResolvers` polyfill
18-
import '../../shared/lib/promise-with-resolvers';
17+
import { withResolvers } from '../../shared/lib/promise-with-resolvers';
1918
import { FirstTimeFlowType } from '../../shared/constants/onboarding';
2019

2120
import {
@@ -200,7 +199,7 @@ let rejectInitialization;
200199
* state of application initialization (or re-initialization).
201200
*/
202201
function setGlobalInitializers() {
203-
const deferred = Promise.withResolvers();
202+
const deferred = withResolvers();
204203
isInitialized = deferred.promise;
205204
resolveInitialization = deferred.resolve;
206205
rejectInitialization = deferred.reject;

app/scripts/controller-init/identity/user-storage-controller-init.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('UserStorageControllerInit', () => {
4949
expect(UserStorageControllerClassMock).toHaveBeenCalledWith({
5050
messenger: requestMock.controllerMessenger,
5151
state: requestMock.persistedState.UserStorageController,
52+
trace: expect.any(Function),
5253
config: {
5354
accountSyncing: {
5455
maxNumberOfAccountsToAdd: 100,

app/scripts/controller-init/identity/user-storage-controller-init.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
MetaMetricsEventCategory,
1111
MetaMetricsEventName,
1212
} from '../../../../shared/constants/metametrics';
13+
import { trace } from '../../../../shared/lib/trace';
1314

1415
/**
1516
* Initialize the UserStorage controller.
@@ -27,6 +28,8 @@ export const UserStorageControllerInit: ControllerInitFunction<
2728
const controller = new UserStorageController({
2829
messenger: controllerMessenger,
2930
state: persistedState.UserStorageController as UserStorageControllerState,
31+
// @ts-expect-error Controller uses string for names rather than enum
32+
trace,
3033
config: {
3134
accountSyncing: {
3235
maxNumberOfAccountsToAdd: isProduction() ? undefined : 100,

app/scripts/controller-init/messengers/identity/user-storage-controller-messenger.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ export function getUserStorageControllerMessenger(
104104
'AccountsController:listAccounts',
105105
'AccountsController:updateAccountMetadata',
106106
'AccountsController:updateAccounts',
107-
// Network Controller Requests
108-
'NetworkController:getState',
109-
'NetworkController:addNetwork',
110-
'NetworkController:removeNetwork',
111-
'NetworkController:updateNetwork',
112107
// Address Book Controller Requests
113108
'AddressBookController:list',
114109
'AddressBookController:set',

app/scripts/lib/operation-safener.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type DebounceSettings, type DebouncedFunc, debounce } from 'lodash';
22
import log from 'loglevel';
3+
import { withResolvers } from '../../../shared/lib/promise-with-resolvers';
34

45
export type { DebounceSettings } from 'lodash';
56

@@ -115,7 +116,7 @@ export class OperationSafener<O extends Op = Op> {
115116
// rejection from running `this.#bouncer.flush()` *is* an unhandled
116117
// rejection; we want it to bubble up to the process/window's
117118
// `unhandledRejection` listener, i.e., Sentry.
118-
const { promise, resolve } = Promise.withResolvers<void>();
119+
const { promise, resolve } = withResolvers<void>();
119120
finalInvocation.finally(resolve);
120121
this.#evacuating = promise;
121122
} else {

app/scripts/lib/rpc-method-middleware/handlers/request-accounts.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ describe('requestEthereumAccountsHandler', () => {
105105
it('blocks subsequent requests if there is currently a request waiting for the wallet to be unlocked', async () => {
106106
const { handler, getUnlockPromise, getAccounts, end, response } =
107107
createMockedHandler();
108-
const { promise, resolve } = Promise.withResolvers<void>();
108+
// `withResolvers` is supported by Node.js LTS. It's optional in global type due to older
109+
// browser support.
110+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
111+
const { promise, resolve } = Promise.withResolvers!<void>();
109112
getUnlockPromise.mockReturnValue(promise);
110113
getAccounts.mockReturnValue(['0xdead', '0xbeef']);
111114

app/scripts/lib/state-corruption/state-corruption-recovery.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('CorruptionHandler.handleStateCorruptionError', () => {
8484
method: '__INVALID__',
8585
},
8686
});
87-
} else if (message.data.method === 'RELOAD') {
87+
} else if (message.data.method === 'RELOAD_WINDOW') {
8888
reloadFn(ui);
8989
}
9090
});

0 commit comments

Comments
 (0)