Skip to content

Commit ab843c0

Browse files
authored
Merge branch 'main' into bump-dependencies-13-03-2024
2 parents 64db766 + 590c9db commit ab843c0

File tree

121 files changed

+4350
-1792
lines changed

Some content is hidden

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

121 files changed

+4350
-1792
lines changed

docs/contributing.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,11 @@ If you're developing your project locally and want to test changes to a package,
7272
7373
> **Example:**
7474
>
75-
> - If you're a member of MetaMask, your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and your clone of the `core` repo is at the same level as your project, add the following to `resolutions`:
75+
> - If your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and your clone of the `core` repo is at the same level as your project, add the following to `resolutions`:
7676
>
7777
> ```
7878
> "@metamask/controller-utils@^1.1.4": "file:../core/packages/controller-utils"
7979
> ```
80-
>
81-
> - If you are an individual contributor, your project uses NPM, `@metamask/assets-controllers` is listed in dependencies at `^3.4.7`, and your fork of the `core` repo is at the same level as your project, add the following to `overrides`:
82-
>
83-
> ```
84-
> "@metamask/assets-controllers@^3.4.7": "file:../core/packages/assets-controllers"
85-
> ```
8680
8781
4. Run `yarn install`.
8882
@@ -145,17 +139,11 @@ To use a preview build for a package within a project, you need to override the
145139
146140
> **Example:**
147141
>
148-
> - If you're a member of MetaMask, your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and you want to use the preview version `1.2.3-preview-e2df9b4`, add the following to `resolutions`:
142+
> - If your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and you want to use the preview version `1.2.3-preview-e2df9b4`, add the following to `resolutions`:
149143
>
150144
> ```
151145
> "@metamask/controller-utils@^1.1.4": "npm:@metamask-previews/controller-utils@1.2.3-preview-e2df9b4"
152146
> ```
153-
>
154-
> - If you are an individual contributor, your project uses NPM, `@metamask/assets-controllers` is listed in dependencies at `^3.4.7`, and you want to use the preview version `4.5.6-preview-bc2a997` published under `@foo`, add the following to `overrides`:
155-
>
156-
> ```
157-
> "@metamask/assets-controllers@^3.4.7": "npm:@foo/assets-controllers@4.5.6-preview-bc2a997"
158-
> ```
159147
160148
4. Run `yarn install`.
161149

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/core-monorepo",
3-
"version": "125.0.0",
3+
"version": "134.0.0",
44
"private": true,
55
"description": "Monorepo for packages shared between MetaMask clients",
66
"repository": {
@@ -85,7 +85,7 @@
8585
"simple-git-hooks": "^2.8.0",
8686
"ts-node": "^10.9.1",
8787
"tsup": "^8.0.2",
88-
"typescript": "~4.8.4",
88+
"typescript": "~4.9.5",
8989
"yargs": "^17.7.2"
9090
},
9191
"packageManager": "yarn@3.3.0",

packages/accounts-controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"ts-jest": "^27.1.4",
6464
"typedoc": "^0.24.8",
6565
"typedoc-plugin-missing-exports": "^2.0.0",
66-
"typescript": "~4.8.4"
66+
"typescript": "~4.9.5"
6767
},
6868
"peerDependencies": {
6969
"@metamask/keyring-controller": "^14.0.1",

packages/address-book-controller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"dependencies": {
4444
"@metamask/base-controller": "^5.0.1",
45-
"@metamask/controller-utils": "^9.0.1",
45+
"@metamask/controller-utils": "^9.0.2",
4646
"@metamask/utils": "^8.3.0"
4747
},
4848
"devDependencies": {
@@ -53,7 +53,7 @@
5353
"ts-jest": "^27.1.4",
5454
"typedoc": "^0.24.8",
5555
"typedoc-plugin-missing-exports": "^2.0.0",
56-
"typescript": "~4.8.4"
56+
"typescript": "~4.9.5"
5757
},
5858
"engines": {
5959
"node": ">=16.0.0"

packages/address-book-controller/src/AddressBookController.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ describe('AddressBookController', () => {
294294
).toBe(true);
295295
});
296296

297+
it('should return false to indicate an address book entry has NOT been deleted due to unsafe input', () => {
298+
const controller = new AddressBookController();
299+
// @ts-expect-error Suppressing error to test runtime behavior
300+
expect(controller.delete('__proto__', '0x01')).toBe(false);
301+
expect(controller.delete(toHex(1), 'constructor')).toBe(false);
302+
});
303+
297304
it('should return false to indicate an address book entry has NOT been deleted', () => {
298305
const controller = new AddressBookController();
299306
controller.set('0x32Be343B94f860124dC4fEe278FDCBD38C102D88', '0x00');

packages/address-book-controller/src/AddressBookController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BaseControllerV1 } from '@metamask/base-controller';
33
import {
44
normalizeEnsName,
55
isValidHexAddress,
6+
isSafeDynamicKey,
67
toChecksumHexAddress,
78
toHex,
89
} from '@metamask/controller-utils';
@@ -110,6 +111,7 @@ export class AddressBookController extends BaseControllerV1<
110111
delete(chainId: Hex, address: string) {
111112
address = toChecksumHexAddress(address);
112113
if (
114+
![chainId, address].every((key) => isSafeDynamicKey(key)) ||
113115
!isValidHexAddress(address) ||
114116
!this.state.addressBook[chainId] ||
115117
!this.state.addressBook[chainId][address]

packages/announcement-controller/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [6.1.0]
11+
12+
### Added
13+
14+
- Add `resetViewed` method to `AnnouncementController` to reset the `isShown` status for all announcements ([#4088](https://github.com/MetaMask/core/pull/4088))
15+
1016
## [6.0.1]
1117

1218
### Fixed
@@ -123,7 +129,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
123129

124130
All changes listed after this point were applied to this package following the monorepo conversion.
125131

126-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@6.0.1...HEAD
132+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@6.1.0...HEAD
133+
[6.1.0]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@6.0.1...@metamask/announcement-controller@6.1.0
127134
[6.0.1]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@6.0.0...@metamask/announcement-controller@6.0.1
128135
[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@5.0.2...@metamask/announcement-controller@6.0.0
129136
[5.0.2]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@5.0.1...@metamask/announcement-controller@5.0.2

packages/announcement-controller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/announcement-controller",
3-
"version": "6.0.1",
3+
"version": "6.1.0",
44
"description": "Manages in-app announcements",
55
"keywords": [
66
"MetaMask",
@@ -51,7 +51,7 @@
5151
"ts-jest": "^27.1.4",
5252
"typedoc": "^0.24.8",
5353
"typedoc-plugin-missing-exports": "^2.0.0",
54-
"typescript": "~4.8.4"
54+
"typescript": "~4.9.5"
5555
},
5656
"engines": {
5757
"node": ">=16.0.0"

packages/announcement-controller/src/AnnouncementController.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ describe('announcement controller', () => {
120120
expect(controller.state.announcements[3].isShown).toBe(false);
121121
});
122122

123+
describe('resetViewed', () => {
124+
it('resets all announcement isShown states to false', () => {
125+
const controller = new AnnouncementController({
126+
messenger: getRestrictedMessenger(),
127+
state: state2,
128+
allAnnouncements: allAnnouncements2,
129+
});
130+
131+
controller.updateViewed({ 1: true, 3: true });
132+
expect(controller.state.announcements[1].isShown).toBe(true);
133+
expect(controller.state.announcements[3].isShown).toBe(true);
134+
135+
controller.resetViewed();
136+
Object.values(controller.state.announcements).forEach((announcement) => {
137+
expect(announcement.isShown).toBe(false);
138+
});
139+
});
140+
});
141+
123142
describe('update viewed announcements', () => {
124143
it('should update isShown status', () => {
125144
const controller = new AnnouncementController({

packages/announcement-controller/src/AnnouncementController.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ export class AnnouncementController extends BaseController<
122122
});
123123
}
124124

125+
/**
126+
* Resets the isShown status for all announcements
127+
*/
128+
resetViewed(): void {
129+
this.update(({ announcements }) => {
130+
for (const announcement of Object.values(announcements)) {
131+
announcement.isShown = false;
132+
}
133+
});
134+
}
135+
125136
/**
126137
* Updates the status of the status of the specified announcements
127138
* once it is read by the user.

0 commit comments

Comments
 (0)