From a90105d1a7a0cbf60c79a04ada25253ce4b801a5 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Wed, 17 Jul 2024 08:09:05 -0700 Subject: [PATCH 1/6] Bump `@metamask/utils` from `^9.0.0` to `^9.1.0` (#4529) ## Changelog ```md ### Changed - Bump `@metamask/utils` to `^9.1.0` ([#4529](https://github.com/MetaMask/core/pull/4529)) ``` ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- package.json | 2 +- packages/accounts-controller/package.json | 2 +- packages/address-book-controller/package.json | 2 +- packages/approval-controller/package.json | 2 +- packages/assets-controllers/package.json | 2 +- packages/base-controller/package.json | 2 +- packages/build-utils/package.json | 2 +- packages/chain-controller/package.json | 2 +- packages/controller-utils/package.json | 2 +- packages/ens-controller/package.json | 2 +- packages/eth-json-rpc-provider/package.json | 2 +- packages/gas-fee-controller/package.json | 2 +- packages/json-rpc-engine/package.json | 2 +- .../json-rpc-middleware-stream/package.json | 2 +- packages/keyring-controller/package.json | 2 +- packages/message-manager/package.json | 2 +- packages/name-controller/package.json | 2 +- packages/network-controller/package.json | 2 +- packages/notification-controller/package.json | 2 +- packages/permission-controller/package.json | 2 +- .../permission-log-controller/package.json | 2 +- packages/polling-controller/package.json | 2 +- .../queued-request-controller/package.json | 2 +- packages/rate-limit-controller/package.json | 2 +- .../selected-network-controller/package.json | 2 +- packages/signature-controller/package.json | 2 +- packages/transaction-controller/package.json | 2 +- .../user-operation-controller/package.json | 2 +- yarn.lock | 64 +++++++++---------- 29 files changed, 60 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 373cfcfa19..06e6718747 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@metamask/eth-block-tracker": "^9.0.3", "@metamask/eth-json-rpc-provider": "^4.1.1", "@metamask/json-rpc-engine": "^9.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/jest": "^27.4.1", "@types/node": "^16.18.54", "@typescript-eslint/eslint-plugin": "^5.62.0", diff --git a/packages/accounts-controller/package.json b/packages/accounts-controller/package.json index 18b6274f2c..5326548864 100644 --- a/packages/accounts-controller/package.json +++ b/packages/accounts-controller/package.json @@ -48,7 +48,7 @@ "@metamask/keyring-controller": "^17.1.1", "@metamask/snaps-sdk": "^4.2.0", "@metamask/snaps-utils": "^7.4.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "deepmerge": "^4.2.2", "ethereum-cryptography": "^2.1.2", "immer": "^9.0.6", diff --git a/packages/address-book-controller/package.json b/packages/address-book-controller/package.json index 1ab56d8f06..8d6a7b5515 100644 --- a/packages/address-book-controller/package.json +++ b/packages/address-book-controller/package.json @@ -43,7 +43,7 @@ "dependencies": { "@metamask/base-controller": "^6.0.1", "@metamask/controller-utils": "^11.0.1", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", diff --git a/packages/approval-controller/package.json b/packages/approval-controller/package.json index 6591961e9e..41f9dacc5a 100644 --- a/packages/approval-controller/package.json +++ b/packages/approval-controller/package.json @@ -43,7 +43,7 @@ "dependencies": { "@metamask/base-controller": "^6.0.1", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "nanoid": "^3.1.31" }, "devDependencies": { diff --git a/packages/assets-controllers/package.json b/packages/assets-controllers/package.json index 29adf9d52f..90c0863148 100644 --- a/packages/assets-controllers/package.json +++ b/packages/assets-controllers/package.json @@ -59,7 +59,7 @@ "@metamask/polling-controller": "^9.0.0", "@metamask/preferences-controller": "^13.0.0", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/bn.js": "^5.1.5", "@types/uuid": "^8.3.0", "async-mutex": "^0.5.0", diff --git a/packages/base-controller/package.json b/packages/base-controller/package.json index b1041791a6..7428a4bf2d 100644 --- a/packages/base-controller/package.json +++ b/packages/base-controller/package.json @@ -40,7 +40,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "immer": "^9.0.6" }, "devDependencies": { diff --git a/packages/build-utils/package.json b/packages/build-utils/package.json index c29a01942d..3ad00fe6d9 100644 --- a/packages/build-utils/package.json +++ b/packages/build-utils/package.json @@ -41,7 +41,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/eslint": "^8.44.7" }, "devDependencies": { diff --git a/packages/chain-controller/package.json b/packages/chain-controller/package.json index e8f530be79..f25ab7aefd 100644 --- a/packages/chain-controller/package.json +++ b/packages/chain-controller/package.json @@ -47,7 +47,7 @@ "@metamask/snaps-controllers": "^8.1.1", "@metamask/snaps-sdk": "^4.2.0", "@metamask/snaps-utils": "^7.4.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/packages/controller-utils/package.json b/packages/controller-utils/package.json index 1f7956dde2..d6a16f9c09 100644 --- a/packages/controller-utils/package.json +++ b/packages/controller-utils/package.json @@ -44,7 +44,7 @@ "@ethereumjs/util": "^8.1.0", "@metamask/eth-query": "^4.0.0", "@metamask/ethjs-unit": "^0.3.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@spruceid/siwe-parser": "2.1.0", "@types/bn.js": "^5.1.5", "bn.js": "^5.2.1", diff --git a/packages/ens-controller/package.json b/packages/ens-controller/package.json index ee2e25e303..8c70656c41 100644 --- a/packages/ens-controller/package.json +++ b/packages/ens-controller/package.json @@ -44,7 +44,7 @@ "@ethersproject/providers": "^5.7.0", "@metamask/base-controller": "^6.0.1", "@metamask/controller-utils": "^11.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "punycode": "^2.1.1" }, "devDependencies": { diff --git a/packages/eth-json-rpc-provider/package.json b/packages/eth-json-rpc-provider/package.json index 8c72005217..e9b81256e2 100644 --- a/packages/eth-json-rpc-provider/package.json +++ b/packages/eth-json-rpc-provider/package.json @@ -49,7 +49,7 @@ "@metamask/json-rpc-engine": "^9.0.1", "@metamask/rpc-errors": "^6.3.1", "@metamask/safe-event-emitter": "^3.0.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/packages/gas-fee-controller/package.json b/packages/gas-fee-controller/package.json index 3b307b6de4..7a7f61f5d0 100644 --- a/packages/gas-fee-controller/package.json +++ b/packages/gas-fee-controller/package.json @@ -47,7 +47,7 @@ "@metamask/ethjs-unit": "^0.3.0", "@metamask/network-controller": "^20.0.0", "@metamask/polling-controller": "^9.0.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/bn.js": "^5.1.5", "@types/uuid": "^8.3.0", "bn.js": "^5.2.1", diff --git a/packages/json-rpc-engine/package.json b/packages/json-rpc-engine/package.json index d94ee94185..5d05602a9d 100644 --- a/packages/json-rpc-engine/package.json +++ b/packages/json-rpc-engine/package.json @@ -52,7 +52,7 @@ "dependencies": { "@metamask/rpc-errors": "^6.3.1", "@metamask/safe-event-emitter": "^3.0.0", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@lavamoat/allow-scripts": "^3.0.4", diff --git a/packages/json-rpc-middleware-stream/package.json b/packages/json-rpc-middleware-stream/package.json index ff19a37c9b..d8384f1686 100644 --- a/packages/json-rpc-middleware-stream/package.json +++ b/packages/json-rpc-middleware-stream/package.json @@ -43,7 +43,7 @@ "dependencies": { "@metamask/json-rpc-engine": "^9.0.1", "@metamask/safe-event-emitter": "^3.0.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "readable-stream": "^3.6.2" }, "devDependencies": { diff --git a/packages/keyring-controller/package.json b/packages/keyring-controller/package.json index 29880d23a2..b3249d98ac 100644 --- a/packages/keyring-controller/package.json +++ b/packages/keyring-controller/package.json @@ -50,7 +50,7 @@ "@metamask/eth-simple-keyring": "^6.0.1", "@metamask/keyring-api": "^8.0.0", "@metamask/message-manager": "^10.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "async-mutex": "^0.5.0", "ethereumjs-wallet": "^1.0.1", "immer": "^9.0.6" diff --git a/packages/message-manager/package.json b/packages/message-manager/package.json index de3c905a0d..aad8212374 100644 --- a/packages/message-manager/package.json +++ b/packages/message-manager/package.json @@ -44,7 +44,7 @@ "@metamask/base-controller": "^6.0.1", "@metamask/controller-utils": "^11.0.1", "@metamask/eth-sig-util": "^7.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/uuid": "^8.3.0", "jsonschema": "^1.2.4", "uuid": "^8.3.2" diff --git a/packages/name-controller/package.json b/packages/name-controller/package.json index af55e19008..c86720d924 100644 --- a/packages/name-controller/package.json +++ b/packages/name-controller/package.json @@ -44,7 +44,7 @@ "dependencies": { "@metamask/base-controller": "^6.0.1", "@metamask/controller-utils": "^11.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "async-mutex": "^0.5.0" }, "devDependencies": { diff --git a/packages/network-controller/package.json b/packages/network-controller/package.json index 963b0e4755..b7a36ab82b 100644 --- a/packages/network-controller/package.json +++ b/packages/network-controller/package.json @@ -51,7 +51,7 @@ "@metamask/json-rpc-engine": "^9.0.1", "@metamask/rpc-errors": "^6.3.1", "@metamask/swappable-obj-proxy": "^2.2.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "async-mutex": "^0.5.0", "immer": "^9.0.6", "loglevel": "^1.8.1", diff --git a/packages/notification-controller/package.json b/packages/notification-controller/package.json index 22fe2dd6f3..82edfe2ee1 100644 --- a/packages/notification-controller/package.json +++ b/packages/notification-controller/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@metamask/base-controller": "^6.0.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "nanoid": "^3.1.31" }, "devDependencies": { diff --git a/packages/permission-controller/package.json b/packages/permission-controller/package.json index c0cb6d7021..b3b2d2ba68 100644 --- a/packages/permission-controller/package.json +++ b/packages/permission-controller/package.json @@ -45,7 +45,7 @@ "@metamask/controller-utils": "^11.0.1", "@metamask/json-rpc-engine": "^9.0.1", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/deep-freeze-strict": "^1.1.0", "deep-freeze-strict": "^1.1.1", "immer": "^9.0.6", diff --git a/packages/permission-log-controller/package.json b/packages/permission-log-controller/package.json index 7b80926888..97dde033db 100644 --- a/packages/permission-log-controller/package.json +++ b/packages/permission-log-controller/package.json @@ -43,7 +43,7 @@ "dependencies": { "@metamask/base-controller": "^6.0.1", "@metamask/json-rpc-engine": "^9.0.1", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", diff --git a/packages/polling-controller/package.json b/packages/polling-controller/package.json index 049a43f676..beea55795c 100644 --- a/packages/polling-controller/package.json +++ b/packages/polling-controller/package.json @@ -44,7 +44,7 @@ "@metamask/base-controller": "^6.0.1", "@metamask/controller-utils": "^11.0.1", "@metamask/network-controller": "^20.0.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "@types/uuid": "^8.3.0", "fast-json-stable-stringify": "^2.1.0", "uuid": "^8.3.2" diff --git a/packages/queued-request-controller/package.json b/packages/queued-request-controller/package.json index b259fbe86c..8ff9eeccfa 100644 --- a/packages/queued-request-controller/package.json +++ b/packages/queued-request-controller/package.json @@ -46,7 +46,7 @@ "@metamask/json-rpc-engine": "^9.0.1", "@metamask/rpc-errors": "^6.3.1", "@metamask/swappable-obj-proxy": "^2.2.0", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", diff --git a/packages/rate-limit-controller/package.json b/packages/rate-limit-controller/package.json index 6a86f566e8..e8e39e9ce4 100644 --- a/packages/rate-limit-controller/package.json +++ b/packages/rate-limit-controller/package.json @@ -43,7 +43,7 @@ "dependencies": { "@metamask/base-controller": "^6.0.1", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", diff --git a/packages/selected-network-controller/package.json b/packages/selected-network-controller/package.json index 9e4a69dd07..4d7467d690 100644 --- a/packages/selected-network-controller/package.json +++ b/packages/selected-network-controller/package.json @@ -46,7 +46,7 @@ "@metamask/network-controller": "^20.0.0", "@metamask/permission-controller": "^10.0.1", "@metamask/swappable-obj-proxy": "^2.2.0", - "@metamask/utils": "^9.0.0" + "@metamask/utils": "^9.1.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", diff --git a/packages/signature-controller/package.json b/packages/signature-controller/package.json index f304015ba6..bb2950ca71 100644 --- a/packages/signature-controller/package.json +++ b/packages/signature-controller/package.json @@ -48,7 +48,7 @@ "@metamask/logging-controller": "^5.0.0", "@metamask/message-manager": "^10.0.1", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/transaction-controller/package.json b/packages/transaction-controller/package.json index 41c54bfc6e..bf353cf107 100644 --- a/packages/transaction-controller/package.json +++ b/packages/transaction-controller/package.json @@ -57,7 +57,7 @@ "@metamask/network-controller": "^20.0.0", "@metamask/nonce-tracker": "^5.0.0", "@metamask/rpc-errors": "^6.3.1", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "async-mutex": "^0.5.0", "bn.js": "^5.2.1", "eth-method-registry": "^4.0.0", diff --git a/packages/user-operation-controller/package.json b/packages/user-operation-controller/package.json index fb12d59d4c..1b665d9509 100644 --- a/packages/user-operation-controller/package.json +++ b/packages/user-operation-controller/package.json @@ -52,7 +52,7 @@ "@metamask/polling-controller": "^9.0.0", "@metamask/rpc-errors": "^6.3.1", "@metamask/transaction-controller": "^35.0.0", - "@metamask/utils": "^9.0.0", + "@metamask/utils": "^9.1.0", "bn.js": "^5.2.1", "immer": "^9.0.6", "lodash": "^4.17.21", diff --git a/yarn.lock b/yarn.lock index 04b10cacf9..e28f4614f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2208,7 +2208,7 @@ __metadata: "@metamask/snaps-controllers": "npm:^8.1.1" "@metamask/snaps-sdk": "npm:^4.2.0" "@metamask/snaps-utils": "npm:^7.4.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/readable-stream": "npm:^2.3.0" deepmerge: "npm:^4.2.2" @@ -2244,7 +2244,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" "@metamask/controller-utils": "npm:^11.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -2290,7 +2290,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -2328,7 +2328,7 @@ __metadata: "@metamask/polling-controller": "npm:^9.0.0" "@metamask/preferences-controller": "npm:^13.0.0" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/bn.js": "npm:^5.1.5" "@types/jest": "npm:^27.4.1" "@types/lodash": "npm:^4.14.191" @@ -2404,7 +2404,7 @@ __metadata: resolution: "@metamask/base-controller@workspace:packages/base-controller" dependencies: "@metamask/auto-changelog": "npm:^3.4.4" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/sinon": "npm:^9.0.10" deepmerge: "npm:^4.2.2" @@ -2432,7 +2432,7 @@ __metadata: resolution: "@metamask/build-utils@workspace:packages/build-utils" dependencies: "@metamask/auto-changelog": "npm:^3.4.4" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/eslint": "npm:^8.44.7" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" @@ -2466,7 +2466,7 @@ __metadata: "@metamask/snaps-controllers": "npm:^8.1.1" "@metamask/snaps-sdk": "npm:^4.2.0" "@metamask/snaps-utils": "npm:^7.4.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/readable-stream": "npm:^2.3.0" deepmerge: "npm:^4.2.2" @@ -2530,7 +2530,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/eth-query": "npm:^4.0.0" "@metamask/ethjs-unit": "npm:^0.3.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@spruceid/siwe-parser": "npm:2.1.0" "@types/bn.js": "npm:^5.1.5" "@types/jest": "npm:^27.4.1" @@ -2563,7 +2563,7 @@ __metadata: "@metamask/eth-block-tracker": "npm:^9.0.3" "@metamask/eth-json-rpc-provider": "npm:^4.1.1" "@metamask/json-rpc-engine": "npm:^9.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/node": "npm:^16.18.54" "@typescript-eslint/eslint-plugin": "npm:^5.62.0" @@ -2626,7 +2626,7 @@ __metadata: "@metamask/base-controller": "npm:^6.0.1" "@metamask/controller-utils": "npm:^11.0.1" "@metamask/network-controller": "npm:^20.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -2779,7 +2779,7 @@ __metadata: "@metamask/json-rpc-engine": "npm:^9.0.1" "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/safe-event-emitter": "npm:^3.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" ethers: "npm:^6.12.0" @@ -3002,7 +3002,7 @@ __metadata: "@metamask/ethjs-unit": "npm:^0.3.0" "@metamask/network-controller": "npm:^20.0.0" "@metamask/polling-controller": "npm:^9.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/bn.js": "npm:^5.1.5" "@types/jest": "npm:^27.4.1" "@types/jest-when": "npm:^2.7.3" @@ -3053,7 +3053,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/safe-event-emitter": "npm:^3.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -3083,7 +3083,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/json-rpc-engine": "npm:^9.0.1" "@metamask/safe-event-emitter": "npm:^3.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/readable-stream": "npm:^2.3.0" deepmerge: "npm:^4.2.2" @@ -3147,7 +3147,7 @@ __metadata: "@metamask/keyring-api": "npm:^8.0.0" "@metamask/message-manager": "npm:^10.0.1" "@metamask/scure-bip39": "npm:^2.1.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" async-mutex: "npm:^0.5.0" deepmerge: "npm:^4.2.2" @@ -3190,7 +3190,7 @@ __metadata: "@metamask/base-controller": "npm:^6.0.1" "@metamask/controller-utils": "npm:^11.0.1" "@metamask/eth-sig-util": "npm:^7.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/uuid": "npm:^8.3.0" deepmerge: "npm:^4.2.2" @@ -3218,7 +3218,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" "@metamask/controller-utils": "npm:^11.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" async-mutex: "npm:^0.5.0" deepmerge: "npm:^4.2.2" @@ -3246,7 +3246,7 @@ __metadata: "@metamask/json-rpc-engine": "npm:^9.0.1" "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/swappable-obj-proxy": "npm:^2.2.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/jest-when": "npm:^2.7.3" "@types/lodash": "npm:^4.14.191" @@ -3285,7 +3285,7 @@ __metadata: dependencies: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -3369,7 +3369,7 @@ __metadata: "@metamask/controller-utils": "npm:^11.0.1" "@metamask/json-rpc-engine": "npm:^9.0.1" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/deep-freeze-strict": "npm:^1.1.0" "@types/jest": "npm:^27.4.1" deep-freeze-strict: "npm:^1.1.1" @@ -3412,7 +3412,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" "@metamask/json-rpc-engine": "npm:^9.0.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/deep-freeze-strict": "npm:^1.1.0" "@types/jest": "npm:^27.4.1" deep-freeze-strict: "npm:^1.1.1" @@ -3470,7 +3470,7 @@ __metadata: "@metamask/base-controller": "npm:^6.0.1" "@metamask/controller-utils": "npm:^11.0.1" "@metamask/network-controller": "npm:^20.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" "@types/uuid": "npm:^8.3.0" deepmerge: "npm:^4.2.2" @@ -3581,7 +3581,7 @@ __metadata: "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/selected-network-controller": "npm:^16.0.0" "@metamask/swappable-obj-proxy": "npm:^2.2.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" immer: "npm:^9.0.6" @@ -3606,7 +3606,7 @@ __metadata: "@metamask/auto-changelog": "npm:^3.4.4" "@metamask/base-controller": "npm:^6.0.1" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -3654,7 +3654,7 @@ __metadata: "@metamask/network-controller": "npm:^20.0.0" "@metamask/permission-controller": "npm:^10.0.1" "@metamask/swappable-obj-proxy": "npm:^2.2.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" immer: "npm:^9.0.6" @@ -3684,7 +3684,7 @@ __metadata: "@metamask/logging-controller": "npm:^5.0.0" "@metamask/message-manager": "npm:^10.0.1" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" deepmerge: "npm:^4.2.2" jest: "npm:^27.5.1" @@ -3855,7 +3855,7 @@ __metadata: "@metamask/network-controller": "npm:^20.0.0" "@metamask/nonce-tracker": "npm:^5.0.0" "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/bn.js": "npm:^5.1.5" "@types/jest": "npm:^27.4.1" "@types/node": "npm:^16.18.54" @@ -3898,7 +3898,7 @@ __metadata: "@metamask/polling-controller": "npm:^9.0.0" "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/transaction-controller": "npm:^35.0.0" - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^9.1.0" "@types/jest": "npm:^27.4.1" bn.js: "npm:^5.2.1" deepmerge: "npm:^4.2.2" @@ -3937,9 +3937,9 @@ __metadata: languageName: node linkType: hard -"@metamask/utils@npm:^9.0.0": - version: 9.0.0 - resolution: "@metamask/utils@npm:9.0.0" +"@metamask/utils@npm:^9.0.0, @metamask/utils@npm:^9.1.0": + version: 9.1.0 + resolution: "@metamask/utils@npm:9.1.0" dependencies: "@ethereumjs/tx": "npm:^4.2.0" "@metamask/superstruct": "npm:^3.1.0" @@ -3950,7 +3950,7 @@ __metadata: pony-cause: "npm:^2.1.10" semver: "npm:^7.5.4" uuid: "npm:^9.0.1" - checksum: 10/04a4eaba79e166fc6d23ecdba8b60625235a3a8c81fa615de64b845e74fa099ea7afd031060206c24809cfa161e7bca5aeb0bfd26079c5cbb82cb37f6a55ddb2 + checksum: 10/7335e151a51be92e86868dc48b3ee78c376d4edd5d758d334176027247637ab22839d8f663bd02542c0a19b05ecec456bedab5f36436689cf3d953ca36d91781 languageName: node linkType: hard From 30df5f0b86137f64f4e32fc39954a76a72ec65a7 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 17 Jul 2024 09:45:05 -0600 Subject: [PATCH 2/6] Release 177.0.0 (#4528) Release new version of `@metamask/phishing-controller`, which includes `PhishingDetector` from `eth-phishing-detect`. Note that support for IPFS CID blocking has also been added. --------- Co-authored-by: Jongsun Suh --- package.json | 2 +- packages/phishing-controller/CHANGELOG.md | 15 ++++++++++++++- packages/phishing-controller/package.json | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 06e6718747..583f3def98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/core-monorepo", - "version": "176.0.0", + "version": "177.0.0", "private": true, "description": "Monorepo for packages shared between MetaMask clients", "repository": { diff --git a/packages/phishing-controller/CHANGELOG.md b/packages/phishing-controller/CHANGELOG.md index 4c88127577..2559815808 100644 --- a/packages/phishing-controller/CHANGELOG.md +++ b/packages/phishing-controller/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.1.0] + +### Added + +- Port `PhishingDetector` from `eth-phishing-detector`; add TypeScript types ([#4137](https://github.com/MetaMask/core/pull/4137)) +- Add support for IPFS CID blocking to `PhishingDetector` ([#4465](https://github.com/MetaMask/core/pull/4465)) + +### Changed + +- Bump `@metamask/base-controller` to `^6.0.1` ([#4517](https://github.com/MetaMask/core/pull/4517)) +- Bump `@metamask/controller-utils` to `^11.0.1` ([#4517](https://github.com/MetaMask/core/pull/4517)) + ## [10.0.0] ### Changed @@ -198,7 +210,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@10.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@10.1.0...HEAD +[10.1.0]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@10.0.0...@metamask/phishing-controller@10.1.0 [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@9.0.4...@metamask/phishing-controller@10.0.0 [9.0.4]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@9.0.3...@metamask/phishing-controller@9.0.4 [9.0.3]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@9.0.2...@metamask/phishing-controller@9.0.3 diff --git a/packages/phishing-controller/package.json b/packages/phishing-controller/package.json index deece8d7b5..9326b8be4e 100644 --- a/packages/phishing-controller/package.json +++ b/packages/phishing-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/phishing-controller", - "version": "10.0.0", + "version": "10.1.0", "description": "Maintains a periodically updated list of approved and unapproved website origins", "keywords": [ "MetaMask", From 1edd3e86f5e7d1b65432447912ca97908217b400 Mon Sep 17 00:00:00 2001 From: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:46:44 +0200 Subject: [PATCH 3/6] fix: export TokenBalancesControllerState (#4535) --- packages/assets-controllers/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/assets-controllers/src/index.ts b/packages/assets-controllers/src/index.ts index e5fb477a02..a2e680fad3 100644 --- a/packages/assets-controllers/src/index.ts +++ b/packages/assets-controllers/src/index.ts @@ -52,6 +52,7 @@ export type { TokenBalancesControllerGetStateAction, TokenBalancesControllerEvents, TokenBalancesControllerStateChangeEvent, + TokenBalancesControllerState, } from './TokenBalancesController'; export { TokenBalancesController } from './TokenBalancesController'; export type { From f0530bb3e619c119a3d2aca3e1d6a672f86183b3 Mon Sep 17 00:00:00 2001 From: Dovydas Stankevicius Date: Thu, 18 Jul 2024 14:26:57 +0100 Subject: [PATCH 4/6] feat: removed node dependancy from profile-sync-sdk (#4539) ## Explanation Removed NodeJs dependency that was breaking the SDK usage on the client --- packages/profile-sync-controller/package.json | 1 - .../src/controllers/authentication/auth-snap-requests.ts | 6 +++--- yarn.lock | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/profile-sync-controller/package.json b/packages/profile-sync-controller/package.json index 65887acd4d..658ac12479 100644 --- a/packages/profile-sync-controller/package.json +++ b/packages/profile-sync-controller/package.json @@ -44,7 +44,6 @@ "@metamask/base-controller": "^6.0.1", "@metamask/snaps-controllers": "^8.1.1", "@metamask/snaps-sdk": "^4.2.0", - "@metamask/snaps-utils": "^7.4.0", "@noble/ciphers": "^0.5.2", "@noble/hashes": "^1.4.0", "immer": "^9.0.6", diff --git a/packages/profile-sync-controller/src/controllers/authentication/auth-snap-requests.ts b/packages/profile-sync-controller/src/controllers/authentication/auth-snap-requests.ts index 649c51a558..347e79800a 100644 --- a/packages/profile-sync-controller/src/controllers/authentication/auth-snap-requests.ts +++ b/packages/profile-sync-controller/src/controllers/authentication/auth-snap-requests.ts @@ -1,6 +1,6 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { HandleSnapRequest } from '@metamask/snaps-controllers'; import type { SnapId } from '@metamask/snaps-sdk'; -import { HandlerType } from '@metamask/snaps-utils'; type SnapRPCRequest = Parameters[0]; @@ -15,7 +15,7 @@ export function createSnapPublicKeyRequest(): SnapRPCRequest { return { snapId, origin: '', - handler: HandlerType.OnRpcRequest, + handler: 'onRpcRequest' as any, request: { method: 'getPublicKey', }, @@ -34,7 +34,7 @@ export function createSnapSignMessageRequest( return { snapId, origin: '', - handler: HandlerType.OnRpcRequest, + handler: 'onRpcRequest' as any, request: { method: 'signMessage', params: { message }, diff --git a/yarn.lock b/yarn.lock index e28f4614f4..1eef5f68e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3527,7 +3527,6 @@ __metadata: "@metamask/base-controller": "npm:^6.0.1" "@metamask/snaps-controllers": "npm:^8.1.1" "@metamask/snaps-sdk": "npm:^4.2.0" - "@metamask/snaps-utils": "npm:^7.4.0" "@noble/ciphers": "npm:^0.5.2" "@noble/hashes": "npm:^1.4.0" "@types/jest": "npm:^27.4.1" From 7969752025ef418a5ad72f250421e54bc81c1002 Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Thu, 18 Jul 2024 15:41:23 +0100 Subject: [PATCH 5/6] fix: notification services controller missing env vars (#4530) ## Explanation If platforms try to use this controller but pass invalid environment variables, we will make unnecessary calls to fetch feature announcements that will fail. (This mostly happens in Extension, where some controllers are in JS and do not provide type errors). NOTE - that a new service is being developed to deliver feature announcements, which might allow us to not require platforms to pass in an environment. ## References [NOTIFY-848](https://consensyssoftware.atlassian.net/browse/NOTIFY-848) ## Changelog ### `@metamask/notification-services-controller` - **CHANGED**: Updated notification mocks to use realistic tx hashes - **FIXED**: Logic to check feature announcement environment before fetching ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- .../__fixtures__/mock-raw-notifications.ts | 12 ++++++--- .../services/feature-announcements.test.ts | 25 +++++++++++++++++++ .../services/feature-announcements.ts | 14 +++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/packages/notification-services-controller/src/NotificationServicesController/__fixtures__/mock-raw-notifications.ts b/packages/notification-services-controller/src/NotificationServicesController/__fixtures__/mock-raw-notifications.ts index 69b1de3c61..9d0163b5b5 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/__fixtures__/mock-raw-notifications.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/__fixtures__/mock-raw-notifications.ts @@ -14,7 +14,8 @@ export function createMockNotificationEthSent(): OnChainRawNotification { chain_id: 1, block_number: 17485840, block_timestamp: '2022-03-01T00:00:00Z', - tx_hash: '0x881D40237659C251811CEC9c364ef91dC08D300C', + tx_hash: + '0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6', unread: true, created_at: '2022-03-01T00:00:00Z', address: '0x881D40237659C251811CEC9c364ef91dC08D300C', @@ -48,7 +49,8 @@ export function createMockNotificationEthReceived(): OnChainRawNotification { chain_id: 1, block_number: 17485840, block_timestamp: '2022-03-01T00:00:00Z', - tx_hash: '0x881D40237659C251811CEC9c364ef91dC08D300C', + tx_hash: + '0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6', unread: true, created_at: '2022-03-01T00:00:00Z', address: '0x881D40237659C251811CEC9c364ef91dC08D300C', @@ -82,7 +84,8 @@ export function createMockNotificationERC20Sent(): OnChainRawNotification { chain_id: 1, block_number: 17485840, block_timestamp: '2022-03-01T00:00:00Z', - tx_hash: '0x881D40237659C251811CEC9c364ef91dC08D300C', + tx_hash: + '0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6', unread: true, created_at: '2022-03-01T00:00:00Z', address: '0x881D40237659C251811CEC9c364ef91dC08D300C', @@ -122,7 +125,8 @@ export function createMockNotificationERC20Received(): OnChainRawNotification { chain_id: 1, block_number: 17485840, block_timestamp: '2022-03-01T00:00:00Z', - tx_hash: '0x881D40237659C251811CEC9c364ef91dC08D300C', + tx_hash: + '0xb2256b183f2fb3872f99294ab55fb03e6a479b0d4aca556a3b27568b712505a6', unread: true, created_at: '2022-03-01T00:00:00Z', address: '0x881D40237659C251811CEC9c364ef91dC08D300C', diff --git a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.test.ts b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.test.ts index 506f802022..55b1b85183 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.test.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.test.ts @@ -3,6 +3,10 @@ import { mockFetchFeatureAnnouncementNotifications } from '../__fixtures__/mockS import { TRIGGER_TYPES } from '../constants/notification-schema'; import { getFeatureAnnouncementNotifications } from './feature-announcements'; +// Mocked type for testing, allows overwriting TS to test erroneous values +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type MockedType = any; + jest.mock('@contentful/rich-text-html-renderer', () => ({ documentToHtmlString: jest .fn() @@ -20,6 +24,27 @@ describe('Feature Announcement Notifications', () => { jest.clearAllMocks(); }); + it('should return an empty array if invalid environment provided', async () => { + mockFetchFeatureAnnouncementNotifications(); + + const assertEnvEmpty = async ( + override: Partial, + ) => { + const result = await getFeatureAnnouncementNotifications({ + ...featureAnnouncementsEnv, + ...override, + }); + expect(result).toHaveLength(0); + }; + + await assertEnvEmpty({ accessToken: null as MockedType }); + await assertEnvEmpty({ platform: null as MockedType }); + await assertEnvEmpty({ spaceId: null as MockedType }); + await assertEnvEmpty({ accessToken: '' }); + await assertEnvEmpty({ platform: '' }); + await assertEnvEmpty({ spaceId: '' }); + }); + it('should return an empty array if fetch fails', async () => { const mockEndpoint = mockFetchFeatureAnnouncementNotifications({ status: 500, diff --git a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts index 02cd54753b..42d982e866 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts @@ -135,10 +135,14 @@ const fetchFeatureAnnouncementNotifications = async ( export async function getFeatureAnnouncementNotifications( env: Env, ): Promise { - const rawNotifications = await fetchFeatureAnnouncementNotifications(env); - const notifications = rawNotifications.map((notification) => - processFeatureAnnouncement(notification), - ); + if (env?.accessToken && env?.spaceId && env?.platform) { + const rawNotifications = await fetchFeatureAnnouncementNotifications(env); + const notifications = rawNotifications.map((notification) => + processFeatureAnnouncement(notification), + ); + + return notifications; + } - return notifications; + return []; } From 4bc736ac66625b751514491b04aa905f108fcfc3 Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Thu, 18 Jul 2024 15:46:37 +0100 Subject: [PATCH 6/6] fix: notification services controller - remove retries (#4531) ## Explanation These retries are not necessary, and also are performed on the UI. Also these retries at a controller level are introducing bottlenecks, as retrying can extend async calls making UI loading much longer. ## References [NOTIFY-860](https://consensyssoftware.atlassian.net/browse/NOTIFY-860) ## Changelog ### `@metamask/notification-services-controller` - **CHANGED**: removed internal retry logic as this is not necessary and also expensive (extends promises) - ****: Your change here ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- .../services/feature-announcements.ts | 53 ++++++------------- .../utils/utils.ts | 48 +---------------- 2 files changed, 16 insertions(+), 85 deletions(-) diff --git a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts index 42d982e866..957ea79848 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/services/feature-announcements.ts @@ -1,6 +1,5 @@ import { documentToHtmlString } from '@contentful/rich-text-html-renderer'; -import type { Entry, Asset } from 'contentful'; -import log from 'loglevel'; +import type { Entry, Asset, EntryCollection } from 'contentful'; import { TRIGGER_TYPES } from '../constants/notification-schema'; import { processFeatureAnnouncement } from '../processors/process-feature-announcement'; @@ -37,53 +36,30 @@ export type ContentfulResult = { items?: TypeFeatureAnnouncement[]; }; -const fetchFromContentful = async ( - url: string, - retries = 3, - retryDelay = 1000, -): Promise => { - let lastError: Error | null = null; - - for (let i = 0; i < retries; i++) { - try { - const response = await fetch(url); - if (!response.ok) { - throw new Error(`Fetch failed with status: ${response.status}`); - } - return await response.json(); - } catch (error) { - if (error instanceof Error) { - lastError = error; - } - if (i < retries - 1) { - await new Promise((resolve) => setTimeout(resolve, retryDelay)); - } - } - } - - log.error( - `Error fetching from Contentful after ${retries} retries:`, - lastError, - ); - return null; -}; +const getFeatureAnnouncementUrl = (env: Env) => + FEATURE_ANNOUNCEMENT_URL.replace(DEFAULT_SPACE_ID, env.spaceId) + .replace(DEFAULT_ACCESS_TOKEN, env.accessToken) + .replace(DEFAULT_CLIENT_ID, env.platform); const fetchFeatureAnnouncementNotifications = async ( env: Env, ): Promise => { - const url = FEATURE_ANNOUNCEMENT_URL.replace(DEFAULT_SPACE_ID, env.spaceId) - .replace(DEFAULT_ACCESS_TOKEN, env.accessToken) - .replace(DEFAULT_CLIENT_ID, env.platform); - const data = await fetchFromContentful(url); + const url = getFeatureAnnouncementUrl(env); + + const data = await fetch(url) + .then((r) => r.json()) + .catch(() => null); if (!data) { return []; } const findIncludedItem = (sysId: string) => { + const typedData: EntryCollection = + data; const item = - data?.includes?.Entry?.find((i: Entry) => i?.sys?.id === sysId) || - data?.includes?.Asset?.find((i: Asset) => i?.sys?.id === sysId); + typedData?.includes?.Entry?.find((i: Entry) => i?.sys?.id === sysId) || + typedData?.includes?.Asset?.find((i: Asset) => i?.sys?.id === sysId); return item ? item?.fields : null; }; @@ -94,6 +70,7 @@ const fetchFeatureAnnouncementNotifications = async ( const imageFields = fields.image ? (findIncludedItem(fields.image.sys.id) as ImageFields['fields']) : undefined; + const extensionLinkFields = fields.extensionLink ? (findIncludedItem( fields.extensionLink.sys.id, diff --git a/packages/notification-services-controller/src/NotificationServicesController/utils/utils.ts b/packages/notification-services-controller/src/NotificationServicesController/utils/utils.ts index de03d12e12..6e77d17a6e 100644 --- a/packages/notification-services-controller/src/NotificationServicesController/utils/utils.ts +++ b/packages/notification-services-controller/src/NotificationServicesController/utils/utils.ts @@ -1,4 +1,3 @@ -import log from 'loglevel'; import { v4 as uuidv4 } from 'uuid'; import { @@ -425,47 +424,6 @@ export function toggleUserStorageTriggerStatus( return userStorage; } -/** - * Attempts to fetch a resource from the network, retrying the request up to a specified number of times - * in case of failure, with a delay between attempts. - * - * @param url - The resource URL. - * @param options - The options for the fetch request. - * @param retries - Maximum number of retry attempts. Defaults to 3. - * @param retryDelay - Delay between retry attempts in milliseconds. Defaults to 1000. - * @returns A Promise resolving to the Response object. - * @throws Will throw an error if the request fails after the specified number of retries. - */ -async function fetchWithRetry( - url: string, - options: RequestInit, - retries = 3, - retryDelay = 1000, -): Promise { - for (let attempt = 1; attempt <= retries; attempt++) { - try { - const response = await fetch(url, options); - if (!response.ok) { - throw new Error(`Fetch failed with status: ${response.status}`); - } - return response; - } catch (error) { - log.error(`Attempt ${attempt} failed for fetch:`, error); - if (attempt < retries) { - await new Promise((resolve) => setTimeout(resolve, retryDelay)); - } else { - throw new Error( - `Fetching failed after ${retries} retries. Last error: ${ - error instanceof Error ? error.message : 'Unknown error' - }`, - ); - } - } - } - - throw new Error('Unexpected error in fetchWithRetry'); -} - /** * Performs an API call with automatic retries on failure. * @@ -473,8 +431,6 @@ async function fetchWithRetry( * @param endpoint - The URL of the API endpoint to call. * @param method - The HTTP method ('POST' or 'DELETE'). * @param body - The body of the request. It should be an object that can be serialized to JSON. - * @param retries - The number of retry attempts in case of failure (default is 3). - * @param retryDelay - The delay between retries in milliseconds (default is 1000). * @returns A Promise that resolves to the response of the fetch request. */ export async function makeApiCall( @@ -482,8 +438,6 @@ export async function makeApiCall( endpoint: string, method: 'POST' | 'DELETE', body: Body, - retries = 3, - retryDelay = 1000, ): Promise { const options: RequestInit = { method, @@ -494,5 +448,5 @@ export async function makeApiCall( body: JSON.stringify(body), }; - return fetchWithRetry(endpoint, options, retries, retryDelay); + return await fetch(endpoint, options); }