Skip to content

Commit c162a8b

Browse files
authored
Merge branch 'main' into polling-controller-mixin
2 parents ddf7c70 + 7316e61 commit c162a8b

File tree

38 files changed

+261
-121
lines changed

38 files changed

+261
-121
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"rimraf": "^3.0.2",
6464
"simple-git-hooks": "^2.8.0",
6565
"ts-node": "^10.9.1",
66-
"typescript": "~4.6.3",
66+
"typescript": "~4.8.4",
6767
"which": "^3.0.0"
6868
},
6969
"packageManager": "[email protected]",

packages/accounts-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"ts-jest": "^27.1.4",
5151
"typedoc": "^0.23.15",
5252
"typedoc-plugin-missing-exports": "^0.23.0",
53-
"typescript": "~4.6.3"
53+
"typescript": "~4.8.4"
5454
},
5555
"peerDependencies": {
5656
"@metamask/keyring-controller": "^8.0.0"

packages/accounts-controller/src/AccountsController.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ export class AccountsController extends BaseControllerV2<
252252
currentState.internalAccounts.selectedAccount = account.id;
253253
});
254254

255-
this.messagingSystem.publish(`${this.name}:selectedAccountChange`, account);
255+
this.messagingSystem.publish(
256+
'AccountsController:selectedAccountChange',
257+
account,
258+
);
256259
}
257260

258261
/**

packages/address-book-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-jest": "^27.1.4",
4141
"typedoc": "^0.23.15",
4242
"typedoc-plugin-missing-exports": "^0.23.0",
43-
"typescript": "~4.6.3"
43+
"typescript": "~4.8.4"
4444
},
4545
"engines": {
4646
"node": ">=16.0.0"

packages/announcement-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ts-jest": "^27.1.4",
4040
"typedoc": "^0.23.15",
4141
"typedoc-plugin-missing-exports": "^0.23.0",
42-
"typescript": "~4.6.3"
42+
"typescript": "~4.8.4"
4343
},
4444
"engines": {
4545
"node": ">=16.0.0"

packages/approval-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"ts-jest": "^27.1.4",
4444
"typedoc": "^0.23.15",
4545
"typedoc-plugin-missing-exports": "^0.23.0",
46-
"typescript": "~4.6.3"
46+
"typescript": "~4.8.4"
4747
},
4848
"engines": {
4949
"node": ">=16.0.0"

packages/approval-controller/src/ApprovalController.test.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ describe('approval controller', () => {
462462

463463
describe('get', () => {
464464
it('gets entry', () => {
465+
// We only want to test the stored entity in the controller state hence disabling floating promises here.
466+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
465467
approvalController.add({
466468
id: 'foo',
467469
origin: 'bar.baz',
@@ -481,7 +483,13 @@ describe('approval controller', () => {
481483
});
482484

483485
it('returns undefined for non-existing entry', () => {
484-
approvalController.add({ id: 'foo', origin: 'bar.baz', type: 'type' });
486+
// We only want to test the stored entity in the controller state hence disabling floating promises here.
487+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
488+
approvalController.add({
489+
id: 'foo',
490+
origin: 'bar.baz',
491+
type: 'type',
492+
});
485493

486494
expect(approvalController.get('fizz')).toBeUndefined();
487495

@@ -495,8 +503,9 @@ describe('approval controller', () => {
495503
let addWithCatch: (args: any) => void;
496504

497505
beforeEach(() => {
498-
addWithCatch = (args: any) =>
506+
addWithCatch = (args: any) => {
499507
approvalController.add(args).catch(() => undefined);
508+
};
500509
});
501510

502511
it('validates input', () => {
@@ -627,8 +636,9 @@ describe('approval controller', () => {
627636
it('gets the total approval count', () => {
628637
expect(approvalController.getTotalApprovalCount()).toBe(0);
629638

630-
const addWithCatch = (args: any) =>
639+
const addWithCatch = (args: any) => {
631640
approvalController.add(args).catch(() => undefined);
641+
};
632642

633643
addWithCatch({ id: '1', origin: 'origin1', type: 'type0' });
634644
expect(approvalController.getTotalApprovalCount()).toBe(1);
@@ -654,8 +664,9 @@ describe('approval controller', () => {
654664
});
655665
expect(approvalController.getTotalApprovalCount()).toBe(0);
656666

657-
const addWithCatch = (args: any) =>
667+
const addWithCatch = (args: any) => {
658668
approvalController.add(args).catch(() => undefined);
669+
};
659670

660671
addWithCatch({ id: '1', origin: 'origin1', type: 'type0' });
661672
expect(approvalController.getTotalApprovalCount()).toBe(1);
@@ -698,8 +709,14 @@ describe('approval controller', () => {
698709
).toThrow(getInvalidHasTypeError());
699710
});
700711

701-
it('returns true for existing entry by id', () => {
702-
approvalController.add({ id: 'foo', origin: 'bar.baz', type: TYPE });
712+
it('returns true for existing entry by id', async () => {
713+
// We only want to check the stored entity is exist in the state hence disabling floating promises here.
714+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
715+
approvalController.add({
716+
id: 'foo',
717+
origin: 'bar.baz',
718+
type: TYPE,
719+
});
703720

704721
expect(approvalController.has({ id: 'foo' })).toBe(true);
705722
});

packages/assets-controllers/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@metamask/metamask-eth-abis": "3.0.0",
4242
"@metamask/network-controller": "^13.0.0",
4343
"@metamask/preferences-controller": "^4.4.1",
44-
"@metamask/rpc-errors": "^5.1.1",
44+
"@metamask/rpc-errors": "^6.0.0",
4545
"@metamask/utils": "^6.2.0",
4646
"@types/uuid": "^8.3.0",
4747
"async-mutex": "^0.2.6",
@@ -64,7 +64,7 @@
6464
"ts-jest": "^27.1.4",
6565
"typedoc": "^0.23.15",
6666
"typedoc-plugin-missing-exports": "^0.23.0",
67-
"typescript": "~4.6.3"
67+
"typescript": "~4.8.4"
6868
},
6969
"peerDependencies": {
7070
"@metamask/approval-controller": "^3.5.1",

packages/base-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ts-jest": "^27.1.4",
4242
"typedoc": "^0.23.15",
4343
"typedoc-plugin-missing-exports": "^0.23.0",
44-
"typescript": "~4.6.3"
44+
"typescript": "~4.8.4"
4545
},
4646
"engines": {
4747
"node": ">=16.0.0"

packages/composable-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-jest": "^27.1.4",
4141
"typedoc": "^0.23.15",
4242
"typedoc-plugin-missing-exports": "^0.23.0",
43-
"typescript": "~4.6.3"
43+
"typescript": "~4.8.4"
4444
},
4545
"engines": {
4646
"node": ">=16.0.0"

packages/controller-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"ts-jest": "^27.1.4",
4747
"typedoc": "^0.23.15",
4848
"typedoc-plugin-missing-exports": "^0.23.0",
49-
"typescript": "~4.6.3"
49+
"typescript": "~4.8.4"
5050
},
5151
"engines": {
5252
"node": ">=16.0.0"

packages/ens-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ts-jest": "^27.1.4",
4545
"typedoc": "^0.23.15",
4646
"typedoc-plugin-missing-exports": "^0.23.0",
47-
"typescript": "~4.6.3"
47+
"typescript": "~4.8.4"
4848
},
4949
"peerDependencies": {
5050
"@metamask/network-controller": "^13.0.0"

packages/gas-fee-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"ts-jest": "^27.1.4",
5252
"typedoc": "^0.23.15",
5353
"typedoc-plugin-missing-exports": "^0.23.0",
54-
"typescript": "~4.6.3"
54+
"typescript": "~4.8.4"
5555
},
5656
"peerDependencies": {
5757
"@metamask/network-controller": "^13.0.0"

packages/keyring-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"ts-jest": "^27.1.4",
5454
"typedoc": "^0.23.15",
5555
"typedoc-plugin-missing-exports": "^0.23.0",
56-
"typescript": "~4.6.3",
56+
"typescript": "~4.8.4",
5757
"uuid": "^8.3.2"
5858
},
5959
"peerDependencies": {

packages/keyring-controller/src/KeyringController.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1096,9 +1096,16 @@ export class KeyringController extends BaseControllerV2<
10961096
* @fires KeyringController:stateChange
10971097
*/
10981098
#fullUpdate() {
1099+
const { vault } = this.#keyring.store.getState();
1100+
const { keyrings, isUnlocked, encryptionKey, encryptionSalt } =
1101+
this.#keyring.memStore.getState();
1102+
10991103
this.update(() => ({
1100-
...this.#keyring.store.getState(),
1101-
...this.#keyring.memStore.getState(),
1104+
vault,
1105+
keyrings,
1106+
isUnlocked,
1107+
encryptionKey,
1108+
encryptionSalt,
11021109
}));
11031110
}
11041111

packages/logging-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-jest": "^27.1.4",
4141
"typedoc": "^0.23.15",
4242
"typedoc-plugin-missing-exports": "^0.23.0",
43-
"typescript": "~4.6.3"
43+
"typescript": "~4.8.4"
4444
},
4545
"engines": {
4646
"node": ">=16.0.0"

packages/message-manager/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"ts-jest": "^27.1.4",
4646
"typedoc": "^0.23.15",
4747
"typedoc-plugin-missing-exports": "^0.23.0",
48-
"typescript": "~4.6.3"
48+
"typescript": "~4.8.4"
4949
},
5050
"engines": {
5151
"node": ">=16.0.0"

packages/name-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"ts-jest": "^27.1.4",
4343
"typedoc": "^0.23.15",
4444
"typedoc-plugin-missing-exports": "^0.23.0",
45-
"typescript": "~4.6.3"
45+
"typescript": "~4.8.4"
4646
},
4747
"engines": {
4848
"node": ">=16.0.0"

packages/name-controller/src/providers/etherscan.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
NameProviderResult,
1010
} from '../types';
1111
import { NameType } from '../types';
12-
import { handleFetch } from '../util';
12+
import { handleFetch, assertIsError } from '../util';
1313

1414
const ID = 'etherscan';
1515
const LABEL = 'Etherscan (Verified Contract Name)';
@@ -134,7 +134,10 @@ export class EtherscanNameProvider implements NameProvider {
134134
}
135135
}
136136

137-
async #sendRequest(url: string) {
137+
async #sendRequest(url: string): Promise<{
138+
responseData?: EtherscanGetSourceCodeResponse;
139+
error?: Error;
140+
}> {
138141
try {
139142
log('Sending request', url);
140143

@@ -144,6 +147,7 @@ export class EtherscanNameProvider implements NameProvider {
144147

145148
return { responseData };
146149
} catch (error) {
150+
assertIsError(error);
147151
return { error };
148152
} finally {
149153
this.#lastRequestTime = Date.now();

packages/name-controller/src/util.ts

+16
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ export async function successfulFetch(request: string, options?: RequestInit) {
5757
}
5858
return response;
5959
}
60+
61+
/**
62+
* Assert that a value is an error. If it's not an error, throw an
63+
* error that wraps the given value.
64+
*
65+
* TODO: Migrate this to @metamask/utils
66+
*
67+
* @param error - The value that we expect to be an error.
68+
* @throws Throws an error wrapping the given value if it's not an error.
69+
*/
70+
export function assertIsError(error: unknown): asserts error is Error {
71+
if (error instanceof Error) {
72+
return;
73+
}
74+
throw new Error(`Invalid error of type '${typeof error}'`);
75+
}

packages/name-controller/src/utils.test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { graphQL } from './util';
1+
import { assertIsError, graphQL } from './util';
22

33
describe('Utils', () => {
44
describe('graphQL', () => {
@@ -51,4 +51,16 @@ describe('Utils', () => {
5151
);
5252
});
5353
});
54+
55+
describe('assertIsError', () => {
56+
it('does not throw if given an error', () => {
57+
expect(() => assertIsError(new Error('test'))).not.toThrow();
58+
});
59+
60+
it('throws if passed something that is not an error', () => {
61+
expect(() => assertIsError('test')).toThrow(
62+
`Invalid error of type 'string'`,
63+
);
64+
});
65+
});
5466
});

packages/network-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"ts-jest": "^27.1.4",
5959
"typedoc": "^0.23.15",
6060
"typedoc-plugin-missing-exports": "^0.23.0",
61-
"typescript": "~4.6.3"
61+
"typescript": "~4.8.4"
6262
},
6363
"engines": {
6464
"node": ">=16.0.0"

packages/notification-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ts-jest": "^27.1.4",
4242
"typedoc": "^0.23.15",
4343
"typedoc-plugin-missing-exports": "^0.23.0",
44-
"typescript": "~4.6.3"
44+
"typescript": "~4.8.4"
4545
},
4646
"engines": {
4747
"node": ">=16.0.0"

packages/permission-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"ts-jest": "^27.1.4",
4848
"typedoc": "^0.23.15",
4949
"typedoc-plugin-missing-exports": "^0.23.0",
50-
"typescript": "~4.6.3"
50+
"typescript": "~4.8.4"
5151
},
5252
"peerDependencies": {
5353
"@metamask/approval-controller": "^3.5.1"

packages/phishing-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ts-jest": "^27.1.4",
4545
"typedoc": "^0.23.15",
4646
"typedoc-plugin-missing-exports": "^0.23.0",
47-
"typescript": "~4.6.3"
47+
"typescript": "~4.8.4"
4848
},
4949
"engines": {
5050
"node": ">=16.0.0"

packages/polling-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"ts-jest": "^27.1.4",
4444
"typedoc": "^0.23.15",
4545
"typedoc-plugin-missing-exports": "^0.23.0",
46-
"typescript": "~4.6.3"
46+
"typescript": "~4.8.4"
4747
},
4848
"peerDependencies": {
4949
"@metamask/network-controller": "^13.0.0"

packages/preferences-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ts-jest": "^27.1.4",
4040
"typedoc": "^0.23.15",
4141
"typedoc-plugin-missing-exports": "^0.23.0",
42-
"typescript": "~4.6.3"
42+
"typescript": "~4.8.4"
4343
},
4444
"engines": {
4545
"node": ">=16.0.0"

packages/rate-limit-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-jest": "^27.1.4",
4141
"typedoc": "^0.23.15",
4242
"typedoc-plugin-missing-exports": "^0.23.0",
43-
"typescript": "~4.6.3"
43+
"typescript": "~4.8.4"
4444
},
4545
"engines": {
4646
"node": ">=16.0.0"

packages/selected-network-controller/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ts-jest": "^27.1.4",
4545
"typedoc": "^0.23.15",
4646
"typedoc-plugin-missing-exports": "^0.23.0",
47-
"typescript": "~4.6.3"
47+
"typescript": "~4.8.4"
4848
},
4949
"peerDependencies": {
5050
"@metamask/network-controller": "^13.0.0"

0 commit comments

Comments
 (0)