Skip to content

Commit 4856fc2

Browse files
committed
Merge branch 'main' into feat/disable-metametrics-basic-functionality
2 parents 557c96f + 584c13d commit 4856fc2

22 files changed

+765
-316
lines changed

app/scripts/controller-init/confirmations/ppom-controller-init.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function buildControllerMock(
3939
}
4040

4141
function buildInitRequestMock(): jest.Mocked<
42+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
4243
ControllerInitRequest<PPOMControllerMessenger, PPOMControllerInitMessenger>
4344
> {
4445
const baseControllerMessenger = new Messenger();

app/scripts/controller-init/confirmations/ppom-controller-init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { PPOMControllerInitMessenger } from '../messengers/ppom-controller-messe
99

1010
export const PPOMControllerInit: ControllerInitFunction<
1111
PPOMController,
12+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
1213
PPOMControllerMessenger,
1314
PPOMControllerInitMessenger
1415
> = (request) => {

app/scripts/controller-init/confirmations/transaction-controller-init.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function buildControllerMock(
3939

4040
function buildInitRequestMock(): jest.Mocked<
4141
ControllerInitRequest<
42+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
4243
TransactionControllerMessenger,
4344
TransactionControllerInitMessenger
4445
>

app/scripts/controller-init/confirmations/transaction-controller-init.ts

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { ControllerFlatState } from '../controller-list';
4848

4949
export const TransactionControllerInit: ControllerInitFunction<
5050
TransactionController,
51+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
5152
TransactionControllerMessenger,
5253
TransactionControllerInitMessenger
5354
> = (request) => {
@@ -188,6 +189,7 @@ function getApi(
188189

189190
function getControllers(
190191
request: ControllerInitRequest<
192+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
191193
TransactionControllerMessenger,
192194
TransactionControllerInitMessenger
193195
>,

app/scripts/controller-init/messengers/ppom-controller-messenger.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type PPOMControllerInitMessenger = ReturnType<
2121
export function getPPOMControllerMessenger(
2222
messenger: Messenger<MessengerActions, MessengerEvents>,
2323
): PPOMControllerMessenger {
24+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
2425
return messenger.getRestricted({
2526
name: 'PPOMController',
2627
allowedEvents: [

app/scripts/controller-init/messengers/transaction-controller-messenger.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export type TransactionControllerInitMessenger = ReturnType<
5656
export function getTransactionControllerMessenger(
5757
messenger: Messenger<MessengerActions, MessengerEvents>,
5858
): TransactionControllerMessenger {
59+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
5960
return messenger.getRestricted({
6061
name: 'TransactionController',
6162
allowedActions: [

app/scripts/controller-init/snaps/cronjob-controller-init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const CronjobControllerInit: ControllerInitFunction<
1919
// with the expected type.
2020
// TODO: Look into the type mismatch.
2121
state: persistedState.CronjobController,
22+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
2223
messenger: controllerMessenger,
2324
});
2425

app/scripts/controller-init/snaps/execution-service-init.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const ExecutionServiceInit: ControllerInitFunction<
5353
memStateKey: null,
5454
persistedStateKey: null,
5555
controller: new OffscreenExecutionService({
56+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
5657
messenger: controllerMessenger,
5758
setupSnapProvider,
5859
offscreenPromise,
@@ -67,6 +68,7 @@ export const ExecutionServiceInit: ControllerInitFunction<
6768
memStateKey: null,
6869
persistedStateKey: null,
6970
controller: new IframeExecutionService({
71+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
7072
messenger: controllerMessenger,
7173
iframeUrl: new URL(iframeUrl),
7274
setupSnapProvider,

app/scripts/controller-init/snaps/snap-insights-controller-init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const SnapInsightsControllerInit: ControllerInitFunction<
1919
// compatible with the expected type.
2020
// TODO: Look into the type mismatch.
2121
state: persistedState.SnapInsightsController,
22+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
2223
messenger: controllerMessenger,
2324
});
2425

app/scripts/controller-init/snaps/snap-interface-controller-init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const SnapInterfaceControllerInit: ControllerInitFunction<
1919
// with the expected type.
2020
// TODO: Look into the type mismatch.
2121
state: persistedState.SnapInterfaceController,
22+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
2223
messenger: controllerMessenger,
2324
});
2425

app/scripts/controller-init/snaps/snaps-registry-init.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const SnapsRegistryInit: ControllerInitFunction<
2222
// with the expected type.
2323
// TODO: Look into the type mismatch.
2424
state: persistedState.SnapsRegistry,
25+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
2526
messenger: controllerMessenger,
2627
refetchOnAllowlistMiss: requireAllowlist,
2728
});

app/scripts/controller-init/utils.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type ControllersToInitialize = 'PPOMController' | 'TransactionController';
4141
type InitFunction<Name extends ControllersToInitialize> =
4242
ControllerInitFunction<
4343
ControllerByName[Name],
44+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
4445
ReturnType<(typeof CONTROLLER_MESSENGERS)[Name]['getMessenger']>,
4546
ReturnType<(typeof CONTROLLER_MESSENGERS)[Name]['getInitMessenger']>
4647
>;
@@ -100,6 +101,7 @@ export function initControllers({
100101
const messengerCallbacks = CONTROLLER_MESSENGERS[controllerName];
101102

102103
const controllerMessengerCallback =
104+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
103105
messengerCallbacks?.getMessenger as ControllerMessengerCallback;
104106

105107
const initMessengerCallback =
@@ -118,7 +120,13 @@ export function initControllers({
118120
initMessenger,
119121
};
120122

121-
const result = initFunction(finalInitRequest);
123+
// TODO: Remove @ts-expect-error once base-controller version mismatch is resolved
124+
// Instead of suppressing all type errors, we'll be specific about the controllerMessenger mismatch
125+
const result = initFunction({
126+
...finalInitRequest,
127+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
128+
controllerMessenger: finalInitRequest.controllerMessenger,
129+
});
122130

123131
const {
124132
controller,

app/scripts/lib/ComposableObservableStore.test.js

+1-47
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
11
import { ObservableStore } from '@metamask/obs-store';
2-
import {
3-
BaseControllerV1,
4-
BaseController,
5-
Messenger,
6-
} from '@metamask/base-controller';
2+
import { BaseController, Messenger } from '@metamask/base-controller';
73
import ComposableObservableStore from './ComposableObservableStore';
84

9-
class OldExampleController extends BaseControllerV1 {
10-
name = 'OldExampleController';
11-
12-
defaultState = {
13-
baz: 'baz',
14-
};
15-
16-
constructor() {
17-
super();
18-
this.initialize();
19-
}
20-
21-
updateBaz(contents) {
22-
this.update({ baz: contents });
23-
}
24-
}
255
class ExampleController extends BaseController {
266
static defaultState = {
277
bar: 'bar',
@@ -81,17 +61,6 @@ describe('ComposableObservableStore', () => {
8161
expect(store.getState()).toStrictEqual({ TestStore: 'state' });
8262
});
8363

84-
it('should update structure with BaseControllerV1-based controller', () => {
85-
const messenger = new Messenger();
86-
const oldExampleController = new OldExampleController();
87-
const store = new ComposableObservableStore({
88-
controllerMessenger: messenger,
89-
});
90-
store.updateStructure({ OldExample: oldExampleController });
91-
oldExampleController.updateBaz('state');
92-
expect(store.getState()).toStrictEqual({ OldExample: { baz: 'state' } });
93-
});
94-
9564
it('should update structure with BaseController-based controller', () => {
9665
const messenger = new Messenger();
9766
const exampleController = new ExampleController({
@@ -113,21 +82,17 @@ describe('ComposableObservableStore', () => {
11382
const exampleController = new ExampleController({
11483
messenger,
11584
});
116-
const oldExampleController = new OldExampleController();
11785
const store = new ComposableObservableStore({
11886
controllerMessenger: messenger,
11987
});
12088
store.updateStructure({
12189
Example: exampleController,
122-
OldExample: oldExampleController,
12390
Store: exampleStore,
12491
});
12592
exampleStore.putState('state');
12693
exampleController.updateBar('state');
127-
oldExampleController.updateBaz('state');
12894
expect(store.getState()).toStrictEqual({
12995
Example: { bar: 'state', baz: 'baz' },
130-
OldExample: { baz: 'state' },
13196
Store: 'state',
13297
});
13398
});
@@ -138,23 +103,19 @@ describe('ComposableObservableStore', () => {
138103
const exampleController = new ExampleController({
139104
messenger,
140105
});
141-
const oldExampleController = new OldExampleController();
142106
exampleStore.putState('state');
143107
exampleController.updateBar('state');
144-
oldExampleController.updateBaz('state');
145108
const store = new ComposableObservableStore({
146109
controllerMessenger: messenger,
147110
});
148111

149112
store.updateStructure({
150113
Example: exampleController,
151-
OldExample: oldExampleController,
152114
Store: exampleStore,
153115
});
154116

155117
expect(store.getState()).toStrictEqual({
156118
Example: { bar: 'state', baz: 'baz' },
157-
OldExample: { baz: 'state' },
158119
Store: 'state',
159120
});
160121
});
@@ -182,24 +143,20 @@ describe('ComposableObservableStore', () => {
182143
const exampleController = new ExampleController({
183144
messenger,
184145
});
185-
const oldExampleController = new OldExampleController();
186146
exampleStore.putState('state');
187147
exampleController.updateBar('state');
188-
oldExampleController.updateBaz('state');
189148
const store = new ComposableObservableStore({
190149
controllerMessenger: messenger,
191150
persist: true,
192151
});
193152

194153
store.updateStructure({
195154
Example: exampleController,
196-
OldExample: oldExampleController,
197155
Store: exampleStore,
198156
});
199157

200158
expect(store.getState()).toStrictEqual({
201159
Example: { bar: 'state' },
202-
OldExample: { baz: 'state' },
203160
Store: 'state',
204161
});
205162
});
@@ -210,18 +167,15 @@ describe('ComposableObservableStore', () => {
210167
const barController = new ExampleController({
211168
messenger,
212169
});
213-
const bazController = new OldExampleController();
214170
const store = new ComposableObservableStore({
215171
config: {
216172
FooStore: fooStore,
217173
BarStore: barController,
218-
BazStore: bazController,
219174
},
220175
controllerMessenger: messenger,
221176
state: {
222177
FooStore: fooStore.getState(),
223178
BarStore: barController.state,
224-
BazStore: bazController.state,
225179
},
226180
});
227181
expect(store.getFlatState()).toStrictEqual({

app/scripts/lib/snap-keyring/snap-keyring.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ export const snapKeyringBuilder = (
126126
isSnapPreinstalled: (snapId: string) => boolean,
127127
) => {
128128
const builder = (() => {
129-
// TODO: Replace `any` with type
130-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
129+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
131130
return new SnapKeyring(controllerMessenger, {
132131
addressExists: async (address) => {
133132
const addresses = await controllerMessenger.call(

app/scripts/lib/transaction/smart-transactions.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function withRequest<ReturnValue>(
102102
});
103103

104104
const smartTransactionsController = new SmartTransactionsController({
105+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
105106
messenger: smartTransactionsControllerMessenger,
106107
getNonceLock: jest.fn(),
107108
confirmExternalTransaction: jest.fn(),
@@ -175,6 +176,7 @@ function withRequest<ReturnValue>(
175176

176177
return fn({
177178
request,
179+
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
178180
messenger: smartTransactionsControllerMessenger,
179181
startFlowSpy,
180182
addRequestSpy,

0 commit comments

Comments
 (0)