From f73e0599060a54dd31a29dd7fab0a784284b5121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Wed, 27 Mar 2024 14:10:51 +0000 Subject: [PATCH 01/27] fix: adds blockaid code fence (#23757) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Adds a missing code fence for blockaid. That causes a lint error: https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/75150/workflows/2e570da1-e6df-43d3-b516-f03ab998e234/jobs/2576017 ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- ui/pages/confirmations/confirm/confirm.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/pages/confirmations/confirm/confirm.tsx b/ui/pages/confirmations/confirm/confirm.tsx index 33074fe25d81..9bbe6fc2a0a6 100644 --- a/ui/pages/confirmations/confirm/confirm.tsx +++ b/ui/pages/confirmations/confirm/confirm.tsx @@ -13,7 +13,9 @@ import { Content, Page } from '../../../components/multichain/pages/page'; import { BackgroundColor } from '../../../helpers/constants/design-system'; import setCurrentConfirmation from '../hooks/setCurrentConfirmation'; import syncConfirmPath from '../hooks/syncConfirmPath'; +///: BEGIN:ONLY_INCLUDE_IF(blockaid) import { BlockaidAlert } from '../components/confirm/blockaid-alert'; +///: END:ONLY_INCLUDE_IF const Confirm = () => { setCurrentConfirmation(); From 1eeaf82aaaa2e432f4cacf6d45b69216f9b07c7e Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 27 Mar 2024 20:06:50 +0530 Subject: [PATCH 02/27] fix: display of reverse string in signature request message (#23751) --- .../components/confirm/info/info.tsx | 8 +- .../__snapshots__/personal-sign.test.tsx.snap | 74 +++++++++++++++++++ .../info/personal-sign/personal-sign.test.tsx | 23 ++++++ .../info/personal-sign/personal-sign.tsx | 9 ++- .../components/confirm/row/dataTree.tsx | 2 +- 5 files changed, 109 insertions(+), 7 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/info.tsx b/ui/pages/confirmations/components/confirm/info/info.tsx index 2c69873ef316..6e5c65a85add 100644 --- a/ui/pages/confirmations/components/confirm/info/info.tsx +++ b/ui/pages/confirmations/components/confirm/info/info.tsx @@ -11,10 +11,6 @@ import TypedSignV1Info from './typed-sign-v1/typed-sign-v1'; const Info: React.FC = () => { const currentConfirmation = useSelector(currentConfirmationSelector); - if (!currentConfirmation?.type) { - return null; - } - const ConfirmationInfoComponentMap = useMemo( () => ({ [TransactionType.personalSign]: () => PersonalSignInfo, @@ -29,6 +25,10 @@ const Info: React.FC = () => { [currentConfirmation], ); + if (!currentConfirmation?.type) { + return null; + } + const InfoComponent = ConfirmationInfoComponentMap[ currentConfirmation?.type as keyof typeof ConfirmationInfoComponentMap diff --git a/ui/pages/confirmations/components/confirm/info/personal-sign/__snapshots__/personal-sign.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/personal-sign/__snapshots__/personal-sign.test.tsx.snap index e893517a280b..c253ad8fe7c2 100644 --- a/ui/pages/confirmations/components/confirm/info/personal-sign/__snapshots__/personal-sign.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/personal-sign/__snapshots__/personal-sign.test.tsx.snap @@ -1,5 +1,79 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`PersonalSignInfo handle reverse string properly 1`] = ` +
+
+
+
+

+ Request from +

+
+
+ +
+
+
+
+

+ https://metamask.github.io +

+
+
+
+
+
+
+

+ Message +

+
+
+

+ Sign into \\u202E EVIL +

+
+
+
+
+`; + exports[`PersonalSignInfo renders correctly for personal sign request 1`] = `
{ const { container } = renderWithProvider(, mockStore); expect(container).toMatchInlineSnapshot(`
`); }); + + it('handle reverse string properly', () => { + const mockState = { + confirm: { + currentConfirmation: { + id: '0050d5b0-c023-11ee-a0cb-3390a510a0ab', + status: 'unapproved', + time: new Date().getTime(), + type: 'personal_sign', + securityProviderResponse: null, + msgParams: { + from: '0x8eeee1781fd885ff5ddef7789486676961873d12', + data: '0x5369676e20696e746f20e280ae204556494c', + origin: 'https://metamask.github.io', + siwe: { isSIWEMessage: false, parsedMessage: null }, + }, + }, + }, + }; + const mockStore = configureMockStore([])(mockState); + const { container } = renderWithProvider(, mockStore); + expect(container).toMatchSnapshot(); + }); }); diff --git a/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx b/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx index 0c195869e583..b671ec1766fa 100644 --- a/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx +++ b/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx @@ -13,7 +13,10 @@ import { BackgroundColor, BorderRadius, } from '../../../../../../helpers/constants/design-system'; -import { hexToText } from '../../../../../../helpers/utils/util'; +import { + hexToText, + sanitizeString, +} from '../../../../../../helpers/utils/util'; const PersonalSignInfo: React.FC = () => { const t = useI18nContext(); @@ -43,7 +46,9 @@ const PersonalSignInfo: React.FC = () => { > diff --git a/ui/pages/confirmations/components/confirm/row/dataTree.tsx b/ui/pages/confirmations/components/confirm/row/dataTree.tsx index 1d4776c99c55..acfa7c65c49c 100644 --- a/ui/pages/confirmations/components/confirm/row/dataTree.tsx +++ b/ui/pages/confirmations/components/confirm/row/dataTree.tsx @@ -34,7 +34,7 @@ export const DataTree = ({ data }: { data: Record }) => ( }) ? ( ) : ( - + )} ); From de76c5213a25be61d6340590887bed13750f10aa Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 27 Mar 2024 14:50:49 +0000 Subject: [PATCH 03/27] feat: Adds opensea to blockaid migration BannerAlert (#23743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This adds a notice to transaction and signature confirmations for users who have been automatically migrated from the security alerts by Open Sea to security alerts by Blockaid (see #23460) and are on networks that are not supported by Blockaid. The notice can be dismissed and is not shown again once that happens. The PR adds e2e tests to verify the change for simple send, token approval, personal signature, and contract interaction. We intend to remove this notice after a few releases. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23743?quickstart=1) ## **Related issues** Fixes: [#2134](https://app.zenhub.com/workspaces/-confirmations-secure-ux-6245e6e2348677001213b8d2/issues/gh/metamask/metamask-planning/2134) Related: [#23546](https://github.com/MetaMask/metamask-extension/pull/23546) and #23460 ## **Manual testing steps** 1. Checkout the extension on a commit prior to #23546 (for example, `112b155d59`) 2. Build the app and open metamask 3. Select security alerts by open sea Screenshot 2024-03-27 at 11 01 38 4. Checkout this branch, build and reload on the managing extensions page 5. Switch to Linea Goerli, or another network that is not currently supported by blockaid 6. Open the testdApp and trigger a new confirmation 7. The Banner Alert should show up ## **Screenshots/Recordings** ### **After** #### Simple Send Screenshot 2024-03-26 at 19 04 56 #### Token Approval Screenshot 2024-03-26 at 19 02 11 #### Personal Signature Screenshot 2024-03-26 at 19 00 04 #### Contract Interaction Screenshot 2024-03-26 at 19 07 44 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/_locales/en/messages.json | 9 ++ app/scripts/controllers/preferences.js | 9 ++ app/scripts/controllers/preferences.test.js | 17 +++ app/scripts/lib/setupSentry.js | 1 + app/scripts/metamask-controller.js | 4 + app/scripts/migrations/114.test.ts | 3 +- app/scripts/migrations/114.ts | 1 + ...migrate-opensea-to-blockaid-banner.spec.js | 135 ++++++++++++++++++ ...rs-after-init-opt-in-background-state.json | 1 + .../errors-after-init-opt-in-ui-state.json | 1 + .../signature-request-original.component.js | 39 +++++ .../signature-request-original.container.js | 15 ++ .../confirm-transaction-base.component.js | 35 +++++ .../confirm-transaction-base.container.js | 15 ++ .../token-allowance/token-allowance.js | 48 ++++++- ui/selectors/selectors.js | 16 +++ ui/selectors/selectors.test.js | 34 +++++ ui/store/actions.ts | 17 +++ 18 files changed, 398 insertions(+), 2 deletions(-) create mode 100644 test/e2e/tests/ppom/migrate-opensea-to-blockaid-banner.spec.js diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c7acae9705c9..0f8cb41d4e59 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -3317,6 +3317,15 @@ "openSeaNew": { "message": "OpenSea" }, + "openSeaToBlockaidBtnLabel": { + "message": "Explore Snaps" + }, + "openSeaToBlockaidDescription": { + "message": "Security alerts are no longer available on this network. Installing a Snap may improve your security." + }, + "openSeaToBlockaidTitle": { + "message": "Heads up!" + }, "operationFailed": { "message": "Operation Failed" }, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index b12f02c4da03..a3e9a56d9f19 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -53,6 +53,7 @@ export default class PreferencesController { eth_sign: false, }, useMultiAccountBalanceChecker: true, + hasDismissedOpenSeaToBlockaidBanner: false, useSafeChainsListValidation: true, // set to true means the dynamic list from the API is being used // set to false will be using the static list from contract-metadata @@ -192,6 +193,14 @@ export default class PreferencesController { this.store.updateState({ useMultiAccountBalanceChecker: val }); } + /** + * Setter for the `dismissOpenSeaToBlockaidBanner` property + * + */ + dismissOpenSeaToBlockaidBanner() { + this.store.updateState({ hasDismissedOpenSeaToBlockaidBanner: true }); + } + /** * Setter for the `useSafeChainsListValidation` property * diff --git a/app/scripts/controllers/preferences.test.js b/app/scripts/controllers/preferences.test.js index bca97e6657e9..4f666c03e527 100644 --- a/app/scripts/controllers/preferences.test.js +++ b/app/scripts/controllers/preferences.test.js @@ -199,6 +199,23 @@ describe('preferences controller', () => { }); }); + describe('dismissOpenSeaToBlockaidBanner', () => { + it('hasDismissedOpenSeaToBlockaidBanner should default to false', () => { + expect( + preferencesController.store.getState() + .hasDismissedOpenSeaToBlockaidBanner, + ).toStrictEqual(false); + }); + + it('should set the hasDismissedOpenSeaToBlockaidBanner property in state', () => { + preferencesController.dismissOpenSeaToBlockaidBanner(); + expect( + preferencesController.store.getState() + .hasDismissedOpenSeaToBlockaidBanner, + ).toStrictEqual(true); + }); + }); + describe('setUseSafeChainsListValidation', function () { it('should default to true', function () { const state = preferencesController.store.getState(); diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index ad1e0b9f22a7..b03a15a45dd3 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -237,6 +237,7 @@ export const SENTRY_BACKGROUND_STATE = { useTokenDetection: true, useRequestQueue: true, useTransactionSimulations: true, + hasDismissedOpenSeaToBlockaidBanner: true, }, SelectedNetworkController: { domains: false }, SignatureController: { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 5ab12ea3e351..3279b6acb348 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2879,6 +2879,10 @@ export default class MetamaskController extends EventEmitter { preferencesController.setUseMultiAccountBalanceChecker.bind( preferencesController, ), + dismissOpenSeaToBlockaidBanner: + preferencesController.dismissOpenSeaToBlockaidBanner.bind( + preferencesController, + ), setUseSafeChainsListValidation: preferencesController.setUseSafeChainsListValidation.bind( preferencesController, diff --git a/app/scripts/migrations/114.test.ts b/app/scripts/migrations/114.test.ts index 0184d753652f..10474bc2c262 100644 --- a/app/scripts/migrations/114.test.ts +++ b/app/scripts/migrations/114.test.ts @@ -21,7 +21,7 @@ describe('migration #114', () => { }); describe('deprecates transactionSecurityCheckEnabled in PreferencesController', () => { - it('sets securityAlertsEnabled to true if transactionSecurityCheckEnabled is true', async () => { + it('sets securityAlertsEnabled and hasMigratedFromOpenSeaToBlockaid to true if transactionSecurityCheckEnabled is true', async () => { const oldStorage = { PreferencesController: { transactionSecurityCheckEnabled: true, @@ -32,6 +32,7 @@ describe('migration #114', () => { const expectedState = { PreferencesController: { securityAlertsEnabled: true, + hasMigratedFromOpenSeaToBlockaid: true, }, }; diff --git a/app/scripts/migrations/114.ts b/app/scripts/migrations/114.ts index 9052e44a8efa..2288dc84d612 100644 --- a/app/scripts/migrations/114.ts +++ b/app/scripts/migrations/114.ts @@ -43,6 +43,7 @@ function transformState(state: Record) { ) { if (state.PreferencesController.transactionSecurityCheckEnabled) { state.PreferencesController.securityAlertsEnabled = true; + state.PreferencesController.hasMigratedFromOpenSeaToBlockaid = true; } delete state.PreferencesController.transactionSecurityCheckEnabled; diff --git a/test/e2e/tests/ppom/migrate-opensea-to-blockaid-banner.spec.js b/test/e2e/tests/ppom/migrate-opensea-to-blockaid-banner.spec.js new file mode 100644 index 000000000000..7cc1a78c7279 --- /dev/null +++ b/test/e2e/tests/ppom/migrate-opensea-to-blockaid-banner.spec.js @@ -0,0 +1,135 @@ +const { connectAccountToTestDapp } = require('../../accounts/common'); +const FixtureBuilder = require('../../fixture-builder'); +const { + defaultGanacheOptions, + unlockWallet, + withFixtures, + openDapp, + WINDOW_TITLES, +} = require('../../helpers'); + +describe('Migrate Opensea to Blockaid Banner @no-mmi', function () { + it('Shows up on simple send transaction', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesController({ hasMigratedFromOpenSeaToBlockaid: true }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await driver.navigate(); + await unlockWallet(driver); + await openDapp(driver); + + await connectAccountToTestDapp(driver); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + await driver.clickElement('#sendButton'); + await driver.delay(2000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.waitForSelector({ text: 'Heads up!', tag: 'p' }); + }, + ); + }); + + it('Shows up on token approval', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesController({ hasMigratedFromOpenSeaToBlockaid: true }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await driver.navigate(); + await unlockWallet(driver); + await openDapp(driver); + + await connectAccountToTestDapp(driver); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + await driver.findClickableElement('#createToken'); + await driver.clickElement('#createToken'); + await driver.delay(2000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.findClickableElements({ + text: 'Confirm', + tag: 'button', + }); + await driver.clickElement({ + text: 'Confirm', + tag: 'button', + }); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + await driver.clickElement({ text: 'Approve Tokens', tag: 'button' }); + await driver.delay(2000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.waitForSelector({ text: 'Heads up!', tag: 'p' }); + }, + ); + }); + + it('Shows up on personal signature', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesController({ hasMigratedFromOpenSeaToBlockaid: true }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await driver.navigate(); + await unlockWallet(driver); + await openDapp(driver); + + await connectAccountToTestDapp(driver); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + await driver.clickElement('#personalSign'); + await driver.delay(2000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.waitForSelector({ text: 'Heads up!', tag: 'p' }); + }, + ); + }); + + it('Shows up on contract interaction', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesController({ hasMigratedFromOpenSeaToBlockaid: true }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test.fullTitle(), + }, + async ({ driver }) => { + await driver.navigate(); + await unlockWallet(driver); + await openDapp(driver); + + await connectAccountToTestDapp(driver); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); + + await driver.clickElement('#deployMultisigButton'); + await driver.delay(2000); + + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + await driver.waitForSelector({ text: 'Heads up!', tag: 'p' }); + }, + ); + }); +}); diff --git a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json index 44aebd984800..85b35d794363 100644 --- a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json @@ -155,6 +155,7 @@ "addSnapAccountEnabled": "boolean", "advancedGasFee": {}, "featureFlags": {}, + "hasDismissedOpenSeaToBlockaidBanner": false, "incomingTransactionsPreferences": {}, "knownMethodData": "object", "currentLocale": "en", diff --git a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json index 4ecc3f0c42f9..d0d28f8cae09 100644 --- a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -74,6 +74,7 @@ "showAccountBanner": true, "trezorModel": null, "hadAdvancedGasFeesSetPriorToMigration92_3": false, + "hasDismissedOpenSeaToBlockaidBanner": false, "nftsDropdownState": {}, "termsOfUseLastAgreed": "number", "qrHardware": {}, diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js index 5afe027b3f65..fcf24c05237f 100644 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js +++ b/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js @@ -26,6 +26,7 @@ import { TextAlign, TextColor, Size, + Severity, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) IconColor, Display, @@ -36,6 +37,7 @@ import { } from '../../../../helpers/constants/design-system'; import { ButtonLink, + BannerAlert, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) Box, Icon, @@ -85,6 +87,10 @@ export default class SignatureRequestOriginal extends Component { mostRecentOverviewPage: PropTypes.string.isRequired, resolvePendingApproval: PropTypes.func.isRequired, completedTx: PropTypes.func.isRequired, + hasMigratedFromOpenSeaToBlockaid: PropTypes.bool.isRequired, + isNetworkSupportedByBlockaid: PropTypes.bool.isRequired, + hasDismissedOpenSeaToBlockaidBanner: PropTypes.bool.isRequired, + dismissOpenSeaToBlockaidBanner: PropTypes.func.isRequired, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) // Used to show a warning if the signing account is not the selected account // Largely relevant for contract wallet custodians @@ -129,6 +135,8 @@ export default class SignatureRequestOriginal extends Component { }; renderBody = () => { + const { t } = this.context; + let rows; const notice = `${this.context.t('youSign')}:`; @@ -150,6 +158,20 @@ export default class SignatureRequestOriginal extends Component { ? subjectMetadata?.[txData.msgParams.origin] : null; + const { + hasMigratedFromOpenSeaToBlockaid, + isNetworkSupportedByBlockaid, + hasDismissedOpenSeaToBlockaidBanner, + dismissOpenSeaToBlockaidBanner, + } = this.props; + const showOpenSeaToBlockaidBannerAlert = + hasMigratedFromOpenSeaToBlockaid && + !isNetworkSupportedByBlockaid && + !hasDismissedOpenSeaToBlockaidBanner; + const handleCloseOpenSeaToBlockaidBannerAlert = () => { + dismissOpenSeaToBlockaidBanner(); + }; + return (
{ @@ -162,6 +184,23 @@ export default class SignatureRequestOriginal extends Component { securityProviderResponse={txData.securityProviderResponse} /> )} + {showOpenSeaToBlockaidBannerAlert ? ( + + ) : null} { ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) this.props.selectedAccount.address === diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original.container.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original.container.js index 0d0b981c7409..2c671a10f94a 100644 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original.container.js +++ b/ui/pages/confirmations/components/signature-request-original/signature-request-original.container.js @@ -8,6 +8,7 @@ import { rejectPendingApproval, rejectAllMessages, completedTx, + dismissOpenSeaToBlockaidBanner, } from '../../../../store/actions'; ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) // eslint-disable-next-line import/order @@ -22,6 +23,9 @@ import { doesAddressRequireLedgerHidConnection, unconfirmedMessagesHashSelector, getTotalUnapprovedMessagesCount, + getIsNetworkSupportedByBlockaid, + getHasDismissedOpenSeaToBlockaidBanner, + getHasMigratedFromOpenSeaToBlockaid, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) getAccountType, getSelectedInternalAccount, @@ -44,6 +48,12 @@ function mapStateToProps(state, ownProps) { const messagesList = unconfirmedMessagesHashSelector(state); const messagesCount = getTotalUnapprovedMessagesCount(state); + const hasMigratedFromOpenSeaToBlockaid = + getHasMigratedFromOpenSeaToBlockaid(state); + const hasDismissedOpenSeaToBlockaidBanner = + getHasDismissedOpenSeaToBlockaidBanner(state); + const isNetworkSupportedByBlockaid = getIsNetworkSupportedByBlockaid(state); + return { requester: null, requesterAddress: null, @@ -55,6 +65,9 @@ function mapStateToProps(state, ownProps) { subjectMetadata: getSubjectMetadata(state), messagesList, messagesCount, + hasMigratedFromOpenSeaToBlockaid, + hasDismissedOpenSeaToBlockaidBanner, + isNetworkSupportedByBlockaid, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) accountType: getAccountType(state), selectedAccount: getSelectedInternalAccount(state), @@ -90,6 +103,8 @@ mapDispatchToProps = function (dispatch) { cancelAllApprovals: (messagesList) => { dispatch(rejectAllMessages(messagesList)); }, + dismissOpenSeaToBlockaidBanner: () => + dispatch(dismissOpenSeaToBlockaidBanner()), }; }; diff --git a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.component.js index 2e684d2dae67..75e971aee6aa 100644 --- a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.component.js @@ -65,6 +65,8 @@ import SnapAccountTransactionLoadingScreen from '../../snap-account-transaction- import { isHardwareKeyring } from '../../../helpers/utils/hardware'; import FeeDetailsComponent from '../components/fee-details-component/fee-details-component'; import { SimulationDetails } from '../components/simulation-details'; +import { BannerAlert } from '../../../components/component-library'; +import { Severity } from '../../../helpers/constants/design-system'; export default class ConfirmTransactionBase extends Component { static contextTypes = { @@ -168,6 +170,10 @@ export default class ConfirmTransactionBase extends Component { useMaxValue: PropTypes.bool, maxValue: PropTypes.string, isMultiLayerFeeNetwork: PropTypes.bool, + hasMigratedFromOpenSeaToBlockaid: PropTypes.bool, + hasDismissedOpenSeaToBlockaidBanner: PropTypes.bool, + dismissOpenSeaToBlockaidBanner: PropTypes.func, + isNetworkSupportedByBlockaid: PropTypes.bool, }; state = { @@ -393,6 +399,10 @@ export default class ConfirmTransactionBase extends Component { tokenSymbol, isUsingPaymaster, isMultiLayerFeeNetwork, + hasMigratedFromOpenSeaToBlockaid, + hasDismissedOpenSeaToBlockaidBanner, + dismissOpenSeaToBlockaidBanner, + isNetworkSupportedByBlockaid, } = this.props; const { t } = this.context; @@ -516,8 +526,33 @@ export default class ConfirmTransactionBase extends Component { /> ); + const showOpenSeaToBlockaidBannerAlert = + hasMigratedFromOpenSeaToBlockaid && + !isNetworkSupportedByBlockaid && + !hasDismissedOpenSeaToBlockaidBanner; + const handleCloseOpenSeaToBlockaidBannerAlert = () => { + dismissOpenSeaToBlockaidBanner(); + }; + return (
+ {showOpenSeaToBlockaidBannerAlert ? ( + + ) : null} diff --git a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js index 3bed74a7aabc..f4b74be4e688 100644 --- a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.container.js @@ -25,6 +25,7 @@ import { addToAddressBook, updateTransaction, updateEditableParams, + dismissOpenSeaToBlockaidBanner, } from '../../../store/actions'; import { isBalanceSufficient } from '../send/send.utils'; import { shortenAddress, valuesFor } from '../../../helpers/utils/util'; @@ -52,6 +53,9 @@ import { getUnapprovedTransactions, getInternalAccountByAddress, getApprovedAndSignedTransactions, + getHasDismissedOpenSeaToBlockaidBanner, + getHasMigratedFromOpenSeaToBlockaid, + getIsNetworkSupportedByBlockaid, } from '../../../selectors'; import { getMostRecentOverviewPage } from '../../../ducks/history/history'; import { @@ -269,6 +273,12 @@ const mapStateToProps = (state, ownProps) => { const isUserOpContractDeployError = fullTxData.isUserOperation && type === TransactionType.deployContract; + const hasMigratedFromOpenSeaToBlockaid = + getHasMigratedFromOpenSeaToBlockaid(state); + const hasDismissedOpenSeaToBlockaidBanner = + getHasDismissedOpenSeaToBlockaidBanner(state); + const isNetworkSupportedByBlockaid = getIsNetworkSupportedByBlockaid(state); + return { balance, fromAddress, @@ -335,6 +345,9 @@ const mapStateToProps = (state, ownProps) => { custodianPublishesTransaction, rpcUrl, ///: END:ONLY_INCLUDE_IF + hasMigratedFromOpenSeaToBlockaid, + hasDismissedOpenSeaToBlockaidBanner, + isNetworkSupportedByBlockaid, }; }; @@ -425,6 +438,8 @@ export const mapDispatchToProps = (dispatch) => { setWaitForConfirmDeepLinkDialog: (wait) => dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)), ///: END:ONLY_INCLUDE_IF + dismissOpenSeaToBlockaidBanner: () => + dispatch(dismissOpenSeaToBlockaidBanner()), }; }; diff --git a/ui/pages/confirmations/token-allowance/token-allowance.js b/ui/pages/confirmations/token-allowance/token-allowance.js index 63f977e7ae41..eed5a269a1f8 100644 --- a/ui/pages/confirmations/token-allowance/token-allowance.js +++ b/ui/pages/confirmations/token-allowance/token-allowance.js @@ -14,6 +14,7 @@ import { FLEX_DIRECTION, FontWeight, JustifyContent, + Severity, TextAlign, TextColor, TextVariant, @@ -36,6 +37,9 @@ import { getTargetAccountWithSendEtherInfo, getCustomNonceValue, getNextSuggestedNonce, + getHasMigratedFromOpenSeaToBlockaid, + getIsNetworkSupportedByBlockaid, + getHasDismissedOpenSeaToBlockaidBanner, } from '../../../selectors'; import { NETWORK_TO_NAME_MAP } from '../../../../shared/constants/network'; import { @@ -45,6 +49,7 @@ import { updateAndApproveTx, getNextNonce, updateCustomNonce, + dismissOpenSeaToBlockaidBanner, } from '../../../store/actions'; import { clearConfirmTransaction } from '../../../ducks/confirm-transaction/confirm-transaction.duck'; import { getMostRecentOverviewPage } from '../../../ducks/history/history'; @@ -71,7 +76,12 @@ import { useSimulationFailureWarning } from '../hooks/useSimulationFailureWarnin import SimulationErrorMessage from '../components/simulation-error-message'; import LedgerInstructionField from '../components/ledger-instruction-field/ledger-instruction-field'; import SecurityProviderBannerMessage from '../components/security-provider-banner-message/security-provider-banner-message'; -import { Icon, IconName, Text } from '../../../components/component-library'; +import { + BannerAlert, + Icon, + IconName, + Text, +} from '../../../components/component-library'; import { ConfirmPageContainerWarning } from '../components/confirm-page-container/confirm-page-container-content'; import CustomNonce from '../components/custom-nonce'; import FeeDetailsComponent from '../components/fee-details-component/fee-details-component'; @@ -336,6 +346,25 @@ export default function TokenAllowance({ txData.securityAlertResponse?.result_type === BlockaidResultType.Malicious ? 'danger-primary' : 'primary'; + + const hasMigratedFromOpenSeaToBlockaid = useSelector( + getHasMigratedFromOpenSeaToBlockaid, + ); + const isNetworkSupportedByBlockaid = useSelector( + getIsNetworkSupportedByBlockaid, + ); + const hasDismissedOpenSeaToBlockaidBanner = useSelector( + getHasDismissedOpenSeaToBlockaidBanner, + ); + + const showOpenSeaToBlockaidBannerAlert = + hasMigratedFromOpenSeaToBlockaid && + !isNetworkSupportedByBlockaid && + !hasDismissedOpenSeaToBlockaidBanner; + + const handleCloseOpenSeaToBlockaidBannerAlert = () => { + dispatch(dismissOpenSeaToBlockaidBanner()); + }; return ( @@ -387,6 +416,23 @@ export default function TokenAllowance({ ///: END:ONLY_INCLUDE_IF } + {showOpenSeaToBlockaidBannerAlert ? ( + + ) : null} {isSuspiciousResponse(txData?.securityProviderResponse) && ( { }); }); + describe('#getIsNetworkSupportedByBlockaid', () => { + it('returns true if current network is Linea', () => { + const modifiedMockState = { + ...mockState, + metamask: { + ...mockState.metamask, + providerConfig: { + ...mockState.metamask.providerConfig, + chainId: CHAIN_IDS.LINEA_MAINNET, + }, + }, + }; + const isSupported = + selectors.getIsNetworkSupportedByBlockaid(modifiedMockState); + expect(isSupported).toBe(true); + }); + + it('returns false if current network is Goerli', () => { + const modifiedMockState = { + ...mockState, + metamask: { + ...mockState.metamask, + providerConfig: { + ...mockState.metamask.providerConfig, + chainId: CHAIN_IDS.GOERLI, + }, + }, + }; + const isSupported = + selectors.getIsNetworkSupportedByBlockaid(modifiedMockState); + expect(isSupported).toBe(false); + }); + }); + describe('#getAllEnabledNetworks', () => { it('returns only Mainnet and Linea with showTestNetworks off', () => { const networks = selectors.getAllEnabledNetworks({ diff --git a/ui/store/actions.ts b/ui/store/actions.ts index e782f6e6a834..3205f3fd9d1b 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -3168,6 +3168,23 @@ export function setUseMultiAccountBalanceChecker( }; } +export function dismissOpenSeaToBlockaidBanner(): ThunkAction< + void, + MetaMaskReduxState, + unknown, + AnyAction +> { + return (dispatch: MetaMaskReduxDispatch) => { + // skipping loading indication as it blips in the UI and looks weird + log.debug(`background.dismissOpenSeaToBlockaidBanner`); + callBackgroundMethod('dismissOpenSeaToBlockaidBanner', [], (err) => { + if (err) { + dispatch(displayWarning(err)); + } + }); + }; +} + export function setUseSafeChainsListValidation( val: boolean, ): ThunkAction { From 7eeb14cee372e41eef8080dd6721d59bdf8d5d77 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Wed, 27 Mar 2024 16:46:18 +0100 Subject: [PATCH 04/27] chore: bump snaps packages (#23607) ## **Description** Bump snaps packages to latest. This PR should have no functional changes except for a bug fix that allows `maxRequestTime`. Aside from that, this PR is mostly meant to bring dependencies up to date for deduping. --------- Co-authored-by: MetaMask Bot --- builds.yml | 8 +- lavamoat/browserify/beta/policy.json | 27 ++++- lavamoat/browserify/desktop/policy.json | 79 +++++++----- lavamoat/browserify/flask/policy.json | 79 +++++++----- lavamoat/browserify/main/policy.json | 79 +++++++----- lavamoat/browserify/mmi/policy.json | 79 +++++++----- package.json | 16 +-- yarn.lock | 152 +++++++++++++++--------- 8 files changed, 339 insertions(+), 180 deletions(-) diff --git a/builds.yml b/builds.yml index 53802bf4d6f4..6b5516c56212 100644 --- a/builds.yml +++ b/builds.yml @@ -27,7 +27,7 @@ buildTypes: - SEGMENT_WRITE_KEY_REF: SEGMENT_PROD_WRITE_KEY - ALLOW_LOCAL_SNAPS: false - REQUIRE_SNAPS_ALLOWLIST: true - - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.3/index.html + - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.4/index.html - ACCOUNT_SNAPS_DIRECTORY_URL: https://snaps.metamask.io/account-management # Main build uses the default browser manifest manifestOverrides: false @@ -64,7 +64,7 @@ buildTypes: - SEGMENT_FLASK_WRITE_KEY - ALLOW_LOCAL_SNAPS: true - REQUIRE_SNAPS_ALLOWLIST: false - - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.3/index.html + - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.4/index.html - SUPPORT_LINK: https://metamask-flask.zendesk.com/hc - SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new - INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID @@ -85,7 +85,7 @@ buildTypes: - SEGMENT_FLASK_WRITE_KEY - ALLOW_LOCAL_SNAPS: true - REQUIRE_SNAPS_ALLOWLIST: false - - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.3/index.html + - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.4/index.html - SUPPORT_LINK: https://metamask-flask.zendesk.com/hc - SUPPORT_REQUEST_LINK: https://metamask-flask.zendesk.com/hc/en-us/requests/new - INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID @@ -107,7 +107,7 @@ buildTypes: - SEGMENT_WRITE_KEY_REF: SEGMENT_MMI_WRITE_KEY - ALLOW_LOCAL_SNAPS: false - REQUIRE_SNAPS_ALLOWLIST: true - - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.3/index.html + - IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/5.0.4/index.html - MMI_CONFIGURATION_SERVICE_URL: https://configuration.metamask-institutional.io/v2/configuration/default - SUPPORT_LINK: https://mmi-support.metamask.io/hc/en-us - SUPPORT_REQUEST_LINK: https://mmi-support.metamask.io/hc/en-us/requests/new diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 412cc6533928..68d3986f65ea 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1691,16 +1691,24 @@ "console.error": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller>@metamask/base-controller": true, "@metamask/permission-controller>@metamask/controller-utils": true, + "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/rpc-errors": true, "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, + "@metamask/permission-controller>@metamask/base-controller": { + "globals": { + "setTimeout": true + }, + "packages": { + "immer": true + } + }, "@metamask/permission-controller>@metamask/controller-utils": { "globals": { "URL": true, @@ -1719,6 +1727,21 @@ "eth-ens-namehash": true } }, + "@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { + "globals": { + "setTimeout": true + }, + "packages": { + "webpack>events": true + } + }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index e609830b484a..2c9464d222ab 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -1803,16 +1803,24 @@ "console.error": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller>@metamask/base-controller": true, "@metamask/permission-controller>@metamask/controller-utils": true, + "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/rpc-errors": true, "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, + "@metamask/permission-controller>@metamask/base-controller": { + "globals": { + "setTimeout": true + }, + "packages": { + "immer": true + } + }, "@metamask/permission-controller>@metamask/controller-utils": { "globals": { "URL": true, @@ -1831,6 +1839,21 @@ "eth-ens-namehash": true } }, + "@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { + "globals": { + "setTimeout": true + }, + "packages": { + "webpack>events": true + } + }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2150,12 +2173,13 @@ "setTimeout": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/object-multiplex": true, "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, + "@metamask/snaps-controllers>@metamask/base-controller": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2168,8 +2192,7 @@ "@metamask/snaps-utils": true, "@metamask/snaps-utils>@metamask/snaps-registry": true, "@metamask/utils": true, - "browserify>browserify-zlib": true, - "json-rpc-middleware-stream": true + "browserify>browserify-zlib": true } }, "@metamask/snaps-controllers-flask>nanoid": { @@ -2177,37 +2200,37 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { + "@metamask/snaps-controllers>@metamask/base-controller": { "globals": { - "console.error": true + "setTimeout": true }, "packages": { - "@metamask/base-controller": true, - "@metamask/providers>@metamask/json-rpc-engine": true, - "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, "immer": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine": { + "packages": { + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { "globals": { - "URL": true, - "console.error": true, - "fetch": true, "setTimeout": true }, "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true + "webpack>events": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { + "globals": { + "console.warn": true, + "setTimeout": true + }, + "packages": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/snaps-controllers>readable-stream": true } }, "@metamask/snaps-controllers>concat-stream": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 47480aee7b30..9af457e4b6bf 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1803,16 +1803,24 @@ "console.error": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller>@metamask/base-controller": true, "@metamask/permission-controller>@metamask/controller-utils": true, + "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/rpc-errors": true, "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, + "@metamask/permission-controller>@metamask/base-controller": { + "globals": { + "setTimeout": true + }, + "packages": { + "immer": true + } + }, "@metamask/permission-controller>@metamask/controller-utils": { "globals": { "URL": true, @@ -1831,6 +1839,21 @@ "eth-ens-namehash": true } }, + "@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { + "globals": { + "setTimeout": true + }, + "packages": { + "webpack>events": true + } + }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2202,12 +2225,13 @@ "setTimeout": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/object-multiplex": true, "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, + "@metamask/snaps-controllers>@metamask/base-controller": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2220,8 +2244,7 @@ "@metamask/snaps-utils": true, "@metamask/snaps-utils>@metamask/snaps-registry": true, "@metamask/utils": true, - "browserify>browserify-zlib": true, - "json-rpc-middleware-stream": true + "browserify>browserify-zlib": true } }, "@metamask/snaps-controllers-flask>nanoid": { @@ -2229,37 +2252,37 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { + "@metamask/snaps-controllers>@metamask/base-controller": { "globals": { - "console.error": true + "setTimeout": true }, "packages": { - "@metamask/base-controller": true, - "@metamask/providers>@metamask/json-rpc-engine": true, - "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, "immer": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine": { + "packages": { + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { "globals": { - "URL": true, - "console.error": true, - "fetch": true, "setTimeout": true }, "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true + "webpack>events": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { + "globals": { + "console.warn": true, + "setTimeout": true + }, + "packages": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/snaps-controllers>readable-stream": true } }, "@metamask/snaps-controllers>concat-stream": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 0f1fe36cefb0..330f55b87b35 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1718,16 +1718,24 @@ "console.error": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller>@metamask/base-controller": true, "@metamask/permission-controller>@metamask/controller-utils": true, + "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/rpc-errors": true, "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, + "@metamask/permission-controller>@metamask/base-controller": { + "globals": { + "setTimeout": true + }, + "packages": { + "immer": true + } + }, "@metamask/permission-controller>@metamask/controller-utils": { "globals": { "URL": true, @@ -1746,6 +1754,21 @@ "eth-ens-namehash": true } }, + "@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { + "globals": { + "setTimeout": true + }, + "packages": { + "webpack>events": true + } + }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2117,12 +2140,13 @@ "setTimeout": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/object-multiplex": true, "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, + "@metamask/snaps-controllers>@metamask/base-controller": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2135,8 +2159,7 @@ "@metamask/snaps-utils": true, "@metamask/snaps-utils>@metamask/snaps-registry": true, "@metamask/utils": true, - "browserify>browserify-zlib": true, - "json-rpc-middleware-stream": true + "browserify>browserify-zlib": true } }, "@metamask/snaps-controllers-flask>nanoid": { @@ -2144,37 +2167,37 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { + "@metamask/snaps-controllers>@metamask/base-controller": { "globals": { - "console.error": true + "setTimeout": true }, "packages": { - "@metamask/base-controller": true, - "@metamask/providers>@metamask/json-rpc-engine": true, - "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, "immer": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine": { + "packages": { + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { "globals": { - "URL": true, - "console.error": true, - "fetch": true, "setTimeout": true }, "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true + "webpack>events": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { + "globals": { + "console.warn": true, + "setTimeout": true + }, + "packages": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/snaps-controllers>readable-stream": true } }, "@metamask/snaps-controllers>concat-stream": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index bb26a83a2798..45fba03d97c0 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -1851,16 +1851,24 @@ "console.error": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller>@metamask/base-controller": true, "@metamask/permission-controller>@metamask/controller-utils": true, + "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/rpc-errors": true, "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, + "@metamask/permission-controller>@metamask/base-controller": { + "globals": { + "setTimeout": true + }, + "packages": { + "immer": true + } + }, "@metamask/permission-controller>@metamask/controller-utils": { "globals": { "URL": true, @@ -1879,6 +1887,21 @@ "eth-ens-namehash": true } }, + "@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, + "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { + "globals": { + "setTimeout": true + }, + "packages": { + "webpack>events": true + } + }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2250,12 +2273,13 @@ "setTimeout": true }, "packages": { - "@metamask/base-controller": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, - "@metamask/providers>@metamask/json-rpc-engine": true, "@metamask/providers>@metamask/object-multiplex": true, "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, + "@metamask/snaps-controllers>@metamask/base-controller": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2268,8 +2292,7 @@ "@metamask/snaps-utils": true, "@metamask/snaps-utils>@metamask/snaps-registry": true, "@metamask/utils": true, - "browserify>browserify-zlib": true, - "json-rpc-middleware-stream": true + "browserify>browserify-zlib": true } }, "@metamask/snaps-controllers-flask>nanoid": { @@ -2277,37 +2300,37 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { + "@metamask/snaps-controllers>@metamask/base-controller": { "globals": { - "console.error": true + "setTimeout": true }, "packages": { - "@metamask/base-controller": true, - "@metamask/providers>@metamask/json-rpc-engine": true, - "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, "immer": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller>@metamask/controller-utils": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine": { + "packages": { + "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { "globals": { - "URL": true, - "console.error": true, - "fetch": true, "setTimeout": true }, "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true + "webpack>events": true + } + }, + "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { + "globals": { + "console.warn": true, + "setTimeout": true + }, + "packages": { + "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/snaps-controllers>readable-stream": true } }, "@metamask/snaps-controllers>concat-stream": { diff --git a/package.json b/package.json index a5338a0892e6..2e83afbdf3a1 100644 --- a/package.json +++ b/package.json @@ -212,7 +212,7 @@ "nonce-tracker@npm:^3.0.0": "patch:nonce-tracker@npm%3A3.0.0#~/.yarn/patches/nonce-tracker-npm-3.0.0-c5e9a93f9d.patch", "@trezor/schema-utils@npm:1.0.1": "patch:@trezor/schema-utils@npm%3A1.0.1#~/.yarn/patches/@trezor-schema-utils-npm-1.0.1-70c2a68232.patch", "lavamoat-core@npm:^15.1.1": "patch:lavamoat-core@npm%3A15.1.1#~/.yarn/patches/lavamoat-core-npm-15.1.1-51fbe39988.patch", - "@metamask/snaps-sdk": "^3.1.1", + "@metamask/snaps-sdk": "^3.2.0", "@babel/runtime@npm:^7.7.6": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@babel/runtime@npm:^7.9.2": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@babel/runtime@npm:^7.12.5": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", @@ -302,9 +302,9 @@ "@metamask/network-controller": "patch:@metamask/network-controller@npm%3A18.0.1#~/.yarn/patches/@metamask-network-controller-npm-18.0.1-c4d0cfaecd.patch", "@metamask/notification-controller": "^3.0.0", "@metamask/obs-store": "^8.1.0", - "@metamask/permission-controller": "^8.0.0", + "@metamask/permission-controller": "^9.0.1", "@metamask/permission-log-controller": "^1.0.0", - "@metamask/phishing-controller": "^8.0.0", + "@metamask/phishing-controller": "^8.0.2", "@metamask/post-message-stream": "^8.0.0", "@metamask/ppom-validator": "^0.29.0", "@metamask/providers": "^14.0.2", @@ -315,11 +315,11 @@ "@metamask/selected-network-controller": "^9.0.0", "@metamask/signature-controller": "^12.0.0", "@metamask/smart-transactions-controller": "^6.2.2", - "@metamask/snaps-controllers": "^6.0.3", - "@metamask/snaps-execution-environments": "^5.0.3", - "@metamask/snaps-rpc-methods": "^7.0.1", - "@metamask/snaps-sdk": "^3.1.1", - "@metamask/snaps-utils": "^7.0.3", + "@metamask/snaps-controllers": "^6.0.4", + "@metamask/snaps-execution-environments": "^5.0.4", + "@metamask/snaps-rpc-methods": "^7.0.2", + "@metamask/snaps-sdk": "^3.2.0", + "@metamask/snaps-utils": "^7.0.4", "@metamask/transaction-controller": "^25.2.1", "@metamask/user-operation-controller": "^6.0.0", "@metamask/utils": "^8.2.1", diff --git a/yarn.lock b/yarn.lock index fac63ef22ec0..fc3acc5aa0ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4682,6 +4682,18 @@ __metadata: languageName: node linkType: hard +"@metamask/json-rpc-middleware-stream@npm:^7.0.1": + version: 7.0.1 + resolution: "@metamask/json-rpc-middleware-stream@npm:7.0.1" + dependencies: + "@metamask/json-rpc-engine": "npm:^8.0.1" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^8.3.0" + readable-stream: "npm:^3.6.2" + checksum: 1df955cd6c39fb40388e1b656b401d94da1a6c9a780be0b17cff7d6ed8d63a6960e0693c18778e7acc79e3eec183df524ca711d98e17e0eefbaab5f4fe8a2fc4 + languageName: node + linkType: hard + "@metamask/key-tree@npm:^9.0.0": version: 9.0.0 resolution: "@metamask/key-tree@npm:9.0.0" @@ -4991,7 +5003,7 @@ __metadata: languageName: node linkType: hard -"@metamask/permission-controller@npm:^8.0.0, @metamask/permission-controller@npm:^8.0.1": +"@metamask/permission-controller@npm:^8.0.1": version: 8.0.1 resolution: "@metamask/permission-controller@npm:8.0.1" dependencies: @@ -5010,6 +5022,25 @@ __metadata: languageName: node linkType: hard +"@metamask/permission-controller@npm:^9.0.1, @metamask/permission-controller@npm:^9.0.2": + version: 9.0.2 + resolution: "@metamask/permission-controller@npm:9.0.2" + dependencies: + "@metamask/base-controller": "npm:^5.0.1" + "@metamask/controller-utils": "npm:^9.0.1" + "@metamask/json-rpc-engine": "npm:^8.0.1" + "@metamask/rpc-errors": "npm:^6.2.1" + "@metamask/utils": "npm:^8.3.0" + "@types/deep-freeze-strict": "npm:^1.1.0" + deep-freeze-strict: "npm:^1.1.1" + immer: "npm:^9.0.6" + nanoid: "npm:^3.1.31" + peerDependencies: + "@metamask/approval-controller": ^6.0.0 + checksum: 8af8b2949f19ace5b2c2580b5291a5ee5745fad4d24b333f53477d9c5daddf2d53aeb05d15eb23338f60c78ad96a8033fcebf4e1d6d3e6a26640fd65dfce0660 + languageName: node + linkType: hard + "@metamask/permission-log-controller@npm:^1.0.0": version: 1.0.0 resolution: "@metamask/permission-log-controller@npm:1.0.0" @@ -5021,7 +5052,7 @@ __metadata: languageName: node linkType: hard -"@metamask/phishing-controller@npm:^8.0.0, @metamask/phishing-controller@npm:^8.0.1, @metamask/phishing-controller@npm:^8.0.2": +"@metamask/phishing-controller@npm:^8.0.1, @metamask/phishing-controller@npm:^8.0.2": version: 8.0.2 resolution: "@metamask/phishing-controller@npm:8.0.2" dependencies: @@ -5034,6 +5065,19 @@ __metadata: languageName: node linkType: hard +"@metamask/phishing-controller@npm:^9.0.1": + version: 9.0.1 + resolution: "@metamask/phishing-controller@npm:9.0.1" + dependencies: + "@metamask/base-controller": "npm:^5.0.1" + "@metamask/controller-utils": "npm:^9.0.1" + "@types/punycode": "npm:^2.1.0" + eth-phishing-detect: "npm:^1.2.0" + punycode: "npm:^2.1.1" + checksum: 6fc1c75e58f187a12eb042cb6c7f41a5c038e0fcf71d1e18f6b428f971c74961551b208fcd79885d7002b5ef5158264592cf0bb859018bacf7048a5fb6db25f3 + languageName: node + linkType: hard + "@metamask/phishing-warning@npm:^3.0.3": version: 3.0.3 resolution: "@metamask/phishing-warning@npm:3.0.3" @@ -5153,9 +5197,9 @@ __metadata: languageName: node linkType: hard -"@metamask/providers@npm:^15.0.0": - version: 15.0.0 - resolution: "@metamask/providers@npm:15.0.0" +"@metamask/providers@npm:^16.0.0": + version: 16.0.0 + resolution: "@metamask/providers@npm:16.0.0" dependencies: "@metamask/json-rpc-engine": "npm:^7.3.2" "@metamask/json-rpc-middleware-stream": "npm:^6.0.2" @@ -5169,7 +5213,7 @@ __metadata: is-stream: "npm:^2.0.0" readable-stream: "npm:^3.6.2" webextension-polyfill: "npm:^0.10.0" - checksum: d022fe6d2db577fcd299477f19dd1a0ca88baeae542d8a80330694d004bffc289eecf7008c619408c819de8f43eb9fc989b27e266a5961ffd43cb9c2ec749dd5 + checksum: 87dc29c91634bbe29a445f20e26edeb2f5e534af45f4a870608f73fcfd7aa28afe83974bbea632b61862ff8ca51f5322004ed79fc6d954b253155dc5f51488f5 languageName: node linkType: hard @@ -5370,58 +5414,58 @@ __metadata: languageName: node linkType: hard -"@metamask/snaps-controllers@npm:^6.0.3": - version: 6.0.3 - resolution: "@metamask/snaps-controllers@npm:6.0.3" +"@metamask/snaps-controllers@npm:^6.0.4": + version: 6.0.4 + resolution: "@metamask/snaps-controllers@npm:6.0.4" dependencies: - "@metamask/approval-controller": "npm:^5.1.3" - "@metamask/base-controller": "npm:^4.1.0" - "@metamask/json-rpc-engine": "npm:^7.3.3" + "@metamask/approval-controller": "npm:^6.0.1" + "@metamask/base-controller": "npm:^5.0.1" + "@metamask/json-rpc-engine": "npm:^8.0.1" + "@metamask/json-rpc-middleware-stream": "npm:^7.0.1" "@metamask/object-multiplex": "npm:^2.0.0" - "@metamask/permission-controller": "npm:^8.0.1" - "@metamask/phishing-controller": "npm:^8.0.2" + "@metamask/permission-controller": "npm:^9.0.2" + "@metamask/phishing-controller": "npm:^9.0.1" "@metamask/post-message-stream": "npm:^8.0.0" "@metamask/rpc-errors": "npm:^6.2.1" "@metamask/snaps-registry": "npm:^3.0.1" - "@metamask/snaps-rpc-methods": "npm:^7.0.1" - "@metamask/snaps-sdk": "npm:^3.1.1" - "@metamask/snaps-utils": "npm:^7.0.3" + "@metamask/snaps-rpc-methods": "npm:^7.0.2" + "@metamask/snaps-sdk": "npm:^3.2.0" + "@metamask/snaps-utils": "npm:^7.0.4" "@metamask/utils": "npm:^8.3.0" "@xstate/fsm": "npm:^2.0.0" browserify-zlib: "npm:^0.2.0" concat-stream: "npm:^2.0.0" get-npm-tarball-url: "npm:^2.0.3" immer: "npm:^9.0.6" - json-rpc-middleware-stream: "npm:^5.0.0" nanoid: "npm:^3.1.31" readable-stream: "npm:^3.6.2" readable-web-to-node-stream: "npm:^3.0.2" tar-stream: "npm:^3.1.7" peerDependencies: - "@metamask/snaps-execution-environments": ^5.0.3 + "@metamask/snaps-execution-environments": ^5.0.4 peerDependenciesMeta: "@metamask/snaps-execution-environments": optional: true - checksum: 620007bad7243840520fdbbcbc3395918513a8d6674e2bb40a6243f422f716eedbda4a5cea4e83ed125255cb6937673b8dc9114946eaa8094fd7825465b6f77d + checksum: 041e8ded3f6553b13e97eeddd17080ee98404df3672cedb7c08654674b0dc3b989babc89ecb841b270c49afc9146e1996191b1eddbf24fe10826069a32ab9287 languageName: node linkType: hard -"@metamask/snaps-execution-environments@npm:^5.0.3": - version: 5.0.3 - resolution: "@metamask/snaps-execution-environments@npm:5.0.3" +"@metamask/snaps-execution-environments@npm:^5.0.4": + version: 5.0.4 + resolution: "@metamask/snaps-execution-environments@npm:5.0.4" dependencies: - "@metamask/json-rpc-engine": "npm:^7.3.3" + "@metamask/json-rpc-engine": "npm:^8.0.1" "@metamask/object-multiplex": "npm:^2.0.0" "@metamask/post-message-stream": "npm:^8.0.0" - "@metamask/providers": "npm:^15.0.0" + "@metamask/providers": "npm:^16.0.0" "@metamask/rpc-errors": "npm:^6.2.1" - "@metamask/snaps-sdk": "npm:^3.1.1" - "@metamask/snaps-utils": "npm:^7.0.3" + "@metamask/snaps-sdk": "npm:^3.2.0" + "@metamask/snaps-utils": "npm:^7.0.4" "@metamask/utils": "npm:^8.3.0" nanoid: "npm:^3.1.31" readable-stream: "npm:^3.6.2" superstruct: "npm:^1.0.3" - checksum: 28e92324b9ec4ab91ffc711ab922f0b625975526475c4dbda5b3369c9904c6697a25e9241a63c2f03f1b48a5d61ae2dc5921715a52c6f70d40f5a64565a0930b + checksum: 3a0130879917a4bd620995b284436fd669e6e06ee0366f92b29b978a42cd6a976051223c4dfddd4efd8906567906cc9232911b478be85a080a5912ff4cac2934 languageName: node linkType: hard @@ -5469,33 +5513,33 @@ __metadata: languageName: node linkType: hard -"@metamask/snaps-rpc-methods@npm:^7.0.1": - version: 7.0.1 - resolution: "@metamask/snaps-rpc-methods@npm:7.0.1" +"@metamask/snaps-rpc-methods@npm:^7.0.2": + version: 7.0.2 + resolution: "@metamask/snaps-rpc-methods@npm:7.0.2" dependencies: "@metamask/key-tree": "npm:^9.0.0" - "@metamask/permission-controller": "npm:^8.0.1" + "@metamask/permission-controller": "npm:^9.0.2" "@metamask/rpc-errors": "npm:^6.2.1" - "@metamask/snaps-sdk": "npm:^3.0.1" - "@metamask/snaps-utils": "npm:^7.0.1" + "@metamask/snaps-sdk": "npm:^3.2.0" + "@metamask/snaps-utils": "npm:^7.0.4" "@metamask/utils": "npm:^8.3.0" "@noble/hashes": "npm:^1.3.1" superstruct: "npm:^1.0.3" - checksum: c85359e96fd8fc69bb05d538e19434c23be2ec90ea8080ade5eac173e11997e7c78b44e0c1231eb8bb15fbbc75c55763471c139b99ba5ae999b6daf7113e8250 + checksum: 4c2c1c2191c9d0703a6afd2e7fa5b52d5817c6ca6a18270436718ce4848ee878bb47495a452a3a2adc3e019cd366a46e3ca725d00483f2b85a1b567869c0c39c languageName: node linkType: hard -"@metamask/snaps-sdk@npm:^3.1.1": - version: 3.1.1 - resolution: "@metamask/snaps-sdk@npm:3.1.1" +"@metamask/snaps-sdk@npm:^3.2.0": + version: 3.2.0 + resolution: "@metamask/snaps-sdk@npm:3.2.0" dependencies: "@metamask/key-tree": "npm:^9.0.0" - "@metamask/providers": "npm:^15.0.0" + "@metamask/providers": "npm:^16.0.0" "@metamask/rpc-errors": "npm:^6.2.1" "@metamask/utils": "npm:^8.3.0" fast-xml-parser: "npm:^4.3.4" superstruct: "npm:^1.0.3" - checksum: c9fe4baf211f60b75800f28df27317a34c0dbea1e1c94e6a26b475e4854b08e058d8f66ebcdd1dd34620e4ba19a735b32c37eecd9937a3c73a5bdcdb71d8af67 + checksum: 989cb05cfb4eca5a676e4b4f0c3a720d9407bf67a60665dfba243c599255ebd84733505e2109146049ada9936254bcdb80d7ac887a2cffbbac2f9f6ecbdefb50 languageName: node linkType: hard @@ -5529,19 +5573,19 @@ __metadata: languageName: node linkType: hard -"@metamask/snaps-utils@npm:^7.0.1, @metamask/snaps-utils@npm:^7.0.3": - version: 7.0.3 - resolution: "@metamask/snaps-utils@npm:7.0.3" +"@metamask/snaps-utils@npm:^7.0.4": + version: 7.0.4 + resolution: "@metamask/snaps-utils@npm:7.0.4" dependencies: "@babel/core": "npm:^7.23.2" "@babel/types": "npm:^7.23.0" - "@metamask/base-controller": "npm:^4.1.0" + "@metamask/base-controller": "npm:^5.0.1" "@metamask/key-tree": "npm:^9.0.0" - "@metamask/permission-controller": "npm:^8.0.1" + "@metamask/permission-controller": "npm:^9.0.2" "@metamask/rpc-errors": "npm:^6.2.1" "@metamask/slip44": "npm:^3.1.0" "@metamask/snaps-registry": "npm:^3.0.1" - "@metamask/snaps-sdk": "npm:^3.1.1" + "@metamask/snaps-sdk": "npm:^3.2.0" "@metamask/utils": "npm:^8.3.0" "@noble/hashes": "npm:^1.3.1" "@scure/base": "npm:^1.1.1" @@ -5555,7 +5599,7 @@ __metadata: ses: "npm:^1.1.0" superstruct: "npm:^1.0.3" validate-npm-package-name: "npm:^5.0.0" - checksum: 224d53492453edbadd8bb4aaf4517e9d98a9dc41da51ee998346d0f9d661871888b3a2ca1b78580479fd7b26f2ad1da0e0fdb9a9a2edbdf22c8ce0d646acffdf + checksum: df5ae4979252adc966612c0341af4247eebcfebc5c20c934730dd28af88834b565441e1484d925ecb02d440bde439feab2a15fc1574493a1330ce7edf248b06e languageName: node linkType: hard @@ -24709,9 +24753,9 @@ __metadata: "@metamask/network-controller": "patch:@metamask/network-controller@npm%3A18.0.1#~/.yarn/patches/@metamask-network-controller-npm-18.0.1-c4d0cfaecd.patch" "@metamask/notification-controller": "npm:^3.0.0" "@metamask/obs-store": "npm:^8.1.0" - "@metamask/permission-controller": "npm:^8.0.0" + "@metamask/permission-controller": "npm:^9.0.1" "@metamask/permission-log-controller": "npm:^1.0.0" - "@metamask/phishing-controller": "npm:^8.0.0" + "@metamask/phishing-controller": "npm:^8.0.2" "@metamask/phishing-warning": "npm:^3.0.3" "@metamask/post-message-stream": "npm:^8.0.0" "@metamask/ppom-validator": "npm:^0.29.0" @@ -24723,11 +24767,11 @@ __metadata: "@metamask/selected-network-controller": "npm:^9.0.0" "@metamask/signature-controller": "npm:^12.0.0" "@metamask/smart-transactions-controller": "npm:^6.2.2" - "@metamask/snaps-controllers": "npm:^6.0.3" - "@metamask/snaps-execution-environments": "npm:^5.0.3" - "@metamask/snaps-rpc-methods": "npm:^7.0.1" - "@metamask/snaps-sdk": "npm:^3.1.1" - "@metamask/snaps-utils": "npm:^7.0.3" + "@metamask/snaps-controllers": "npm:^6.0.4" + "@metamask/snaps-execution-environments": "npm:^5.0.4" + "@metamask/snaps-rpc-methods": "npm:^7.0.2" + "@metamask/snaps-sdk": "npm:^3.2.0" + "@metamask/snaps-utils": "npm:^7.0.4" "@metamask/test-bundler": "npm:^1.0.0" "@metamask/test-dapp": "npm:^8.3.0" "@metamask/transaction-controller": "npm:^25.2.1" From f008c05a603ae0fcb4b952b0d2f801089f677c09 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Wed, 27 Mar 2024 17:29:37 +0100 Subject: [PATCH 05/27] chore: dedupe yarn.lock (#23765) ## **Description** I merged an old PR that was not brought up to date which caused a duplication in the yarn.lock. This PR fixes that. --------- Co-authored-by: MetaMask Bot --- lavamoat/browserify/beta/policy.json | 30 ++---------------- lavamoat/browserify/desktop/policy.json | 42 +++---------------------- lavamoat/browserify/flask/policy.json | 42 +++---------------------- lavamoat/browserify/main/policy.json | 42 +++---------------------- lavamoat/browserify/mmi/policy.json | 42 +++---------------------- yarn.lock | 2 +- 6 files changed, 19 insertions(+), 181 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 68d3986f65ea..4f9612776854 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1691,8 +1691,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, "@metamask/providers>@metamask/rpc-errors": true, @@ -1709,39 +1709,13 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "URL": true, - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true - } - }, "@metamask/permission-controller>@metamask/json-rpc-engine": { "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index 2c9464d222ab..a3b5340b8199 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -1803,8 +1803,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, "@metamask/providers>@metamask/rpc-errors": true, @@ -1821,39 +1821,13 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "URL": true, - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true - } - }, "@metamask/permission-controller>@metamask/json-rpc-engine": { "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2211,25 +2185,17 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { "globals": { "console.warn": true, "setTimeout": true }, "packages": { - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/snaps-controllers>readable-stream": true } }, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 9af457e4b6bf..7cc49716e4c9 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1803,8 +1803,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, "@metamask/providers>@metamask/rpc-errors": true, @@ -1821,39 +1821,13 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "URL": true, - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true - } - }, "@metamask/permission-controller>@metamask/json-rpc-engine": { "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2263,25 +2237,17 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { "globals": { "console.warn": true, "setTimeout": true }, "packages": { - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/snaps-controllers>readable-stream": true } }, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 330f55b87b35..e341937b4594 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1718,8 +1718,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, "@metamask/providers>@metamask/rpc-errors": true, @@ -1736,39 +1736,13 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "URL": true, - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true - } - }, "@metamask/permission-controller>@metamask/json-rpc-engine": { "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2178,25 +2152,17 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { "globals": { "console.warn": true, "setTimeout": true }, "packages": { - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/snaps-controllers>readable-stream": true } }, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 45fba03d97c0..b6ec21e4c0ac 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -1851,8 +1851,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, "@metamask/providers>@metamask/rpc-errors": true, @@ -1869,39 +1869,13 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "URL": true, - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask/controller-utils>@spruceid/siwe-parser": true, - "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, - "bn.js": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true - } - }, "@metamask/permission-controller>@metamask/json-rpc-engine": { "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, "@metamask/providers>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2311,25 +2285,17 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/providers>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, "@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": { "globals": { "console.warn": true, "setTimeout": true }, "packages": { - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/safe-event-emitter": true, + "@metamask/safe-event-emitter": true, "@metamask/snaps-controllers>readable-stream": true } }, diff --git a/yarn.lock b/yarn.lock index fc3acc5aa0ff..23db05adda35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4648,7 +4648,7 @@ __metadata: languageName: node linkType: hard -"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.1, @metamask/json-rpc-engine@npm:^7.3.2, @metamask/json-rpc-engine@npm:^7.3.3": +"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.1, @metamask/json-rpc-engine@npm:^7.3.2": version: 7.3.3 resolution: "@metamask/json-rpc-engine@npm:7.3.3" dependencies: From ba82436716ee08659e5c64281bf82e78a4e0c384 Mon Sep 17 00:00:00 2001 From: Derek Brans Date: Wed, 27 Mar 2024 13:11:13 -0400 Subject: [PATCH 06/27] fix: display native ticker and logo for current chain and render near-zero amounts in simulations (#23711) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** * near-zero amounts were being displayed as zero – we check if our rounding produces zero for non-zero values, in which case we display MIN_DISPLAY_AMOUNT. * add support for non-ETH native tokens. * added stories for small amount and non-ETH native token [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23711?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2295 Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2296 ## **Manual testing steps** Switch to a network where ETH is not the native token, e.g. Polygon or Optimism. 1. Prepare to send a very small amount of the native currency (like 0.000000001) to a random address (not your own wallet). 2. Before confirming you should see the amount `- <0.000001` in the native currency of the current chain. For polygon, that looks like: ![image](https://github.com/MetaMask/metamask-extension/assets/507015/be36947e-cd07-46f0-943c-25dcec35e0cc) ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- shared/modules/Numeric.test.ts | 18 +++ shared/modules/Numeric.ts | 7 + .../simulation-details.spec.ts | 2 +- ui/hooks/useCurrencyDisplay.js | 17 +-- .../simulation-details/amount-pill.test.tsx | 124 +++++++++++------- .../simulation-details/amount-pill.tsx | 21 ++- .../simulation-details/asset-pill.test.tsx | 48 ++++++- .../simulation-details/asset-pill.tsx | 51 +++---- .../simulation-details.stories.tsx | 39 ++++++ .../components/simulation-details/types.ts | 4 + .../simulation-details/useBalanceChanges.ts | 5 +- 11 files changed, 244 insertions(+), 92 deletions(-) diff --git a/shared/modules/Numeric.test.ts b/shared/modules/Numeric.test.ts index 90578aa8fe89..7f0795b6a40a 100644 --- a/shared/modules/Numeric.test.ts +++ b/shared/modules/Numeric.test.ts @@ -373,6 +373,24 @@ describe('Numeric', () => { }); }); + describe('isZero', () => { + it('should return true for positive zero', () => { + expect(new Numeric(0, 10).isZero()).toStrictEqual(true); + }); + + it('should return true for negative 0', () => { + expect(new Numeric(-0, 10).isZero()).toStrictEqual(true); + }); + + it('should return false for positive non-zero', () => { + expect(new Numeric(10, 10).isZero()).toStrictEqual(false); + }); + + it('should return false for negative non-zero', () => { + expect(new Numeric(-10, 10).isZero()).toStrictEqual(false); + }); + }); + describe('applyConversionRate', () => { it('should multiply the value by the conversionRate supplied', () => { expect( diff --git a/shared/modules/Numeric.ts b/shared/modules/Numeric.ts index bf877d7a6aeb..d7a87a0050d4 100644 --- a/shared/modules/Numeric.ts +++ b/shared/modules/Numeric.ts @@ -540,6 +540,13 @@ export class Numeric { return new Numeric(this.value.abs(), this.base, this.denomination); } + /** + * Checks if the Numeric value is zero. + */ + isZero() { + return this.value.isZero(); + } + greaterThan( comparator: Numeric | NumericValue, base?: NumericBase, diff --git a/test/e2e/tests/simulation-details/simulation-details.spec.ts b/test/e2e/tests/simulation-details/simulation-details.spec.ts index 20d59bb4fe22..0c3e514f88ad 100644 --- a/test/e2e/tests/simulation-details/simulation-details.spec.ts +++ b/test/e2e/tests/simulation-details/simulation-details.spec.ts @@ -91,7 +91,7 @@ export async function mockRequest( } -describe.skip('Simulation Details', () => { +describe('Simulation Details', () => { it('renders send eth transaction', async function (this: Mocha.Context) { const mockRequests = async (mockServer: MockttpServer) => { await mockRequest(mockServer, SEND_ETH_REQUEST_MOCK); diff --git a/ui/hooks/useCurrencyDisplay.js b/ui/hooks/useCurrencyDisplay.js index ca34d3560977..e6eded343fe6 100644 --- a/ui/hooks/useCurrencyDisplay.js +++ b/ui/hooks/useCurrencyDisplay.js @@ -12,6 +12,10 @@ import { TEST_NETWORK_TICKER_MAP } from '../../shared/constants/network'; import { Numeric } from '../../shared/modules/Numeric'; import { EtherDenomination } from '../../shared/constants/common'; +export const MIN_DISPLAY_AMOUNT = '<0.000001'; + +export const DEFAULT_PRECISION_DECIMALS = 6; + /** * Defines the shape of the options parameter for useCurrencyDisplay * @@ -53,7 +57,6 @@ export function useCurrencyDisplay( const isUserPreferredCurrency = currency === currentCurrency; const value = useMemo(() => { - let ethDisplayValue; if (displayValue) { return displayValue; } @@ -61,17 +64,15 @@ export function useCurrencyDisplay( currency === nativeCurrency || (!isUserPreferredCurrency && !nativeCurrency) ) { - ethDisplayValue = new Numeric(inputValue, 16, EtherDenomination.WEI) + const ethDisplayValue = new Numeric(inputValue, 16, EtherDenomination.WEI) .toDenomination(denomination || EtherDenomination.ETH) - .round(numberOfDecimals || 6) + .round(numberOfDecimals || DEFAULT_PRECISION_DECIMALS) .toBase(10) .toString(); - if (ethDisplayValue === '0' && inputValue && Number(inputValue) !== 0) { - ethDisplayValue = '<0.000001'; - } - - return ethDisplayValue; + return ethDisplayValue === '0' && inputValue && Number(inputValue) !== 0 + ? MIN_DISPLAY_AMOUNT + : ethDisplayValue; } else if (isUserPreferredCurrency && conversionRate) { return formatCurrency( getValueFromWeiHex({ diff --git a/ui/pages/confirmations/components/simulation-details/amount-pill.test.tsx b/ui/pages/confirmations/components/simulation-details/amount-pill.test.tsx index 91ef88a82489..41987258574f 100644 --- a/ui/pages/confirmations/components/simulation-details/amount-pill.test.tsx +++ b/ui/pages/confirmations/components/simulation-details/amount-pill.test.tsx @@ -3,7 +3,12 @@ import { render } from '@testing-library/react'; import { TokenStandard } from '../../../../../shared/constants/transaction'; import { Numeric } from '../../../../../shared/modules/Numeric'; import { AmountPill } from './amount-pill'; -import { Amount, TokenAssetIdentifier } from './types'; +import { + Amount, + AssetIdentifier, + NATIVE_ASSET_IDENTIFIER, + TokenAssetIdentifier, +} from './types'; const TOKEN_ID_MOCK = '0xabc'; @@ -22,29 +27,71 @@ const ERC1155_ASSET_MOCK: TokenAssetIdentifier = { tokenId: TOKEN_ID_MOCK, }; +const renderAndExpectText = ( + asset: AssetIdentifier, + amount: Amount, + expectedText: string, +): void => { + const { getByText } = render(); + expect(getByText(expectedText)).toBeInTheDocument(); +}; + describe('AmountPill', () => { - describe('ERC20', () => { - const cases = [ - { - isNegative: true, - numeric: new Numeric(-123.456, 10), - expected: '- 123.456', - }, - { - isNegative: false, - numeric: new Numeric(789.012, 10), - expected: '+ 789.012', - }, - ]; - it.each(cases)( - 'renders the correct sign and amount', + const nativeAndErc20Cases = [ + { + isNegative: true, + numeric: new Numeric(-123.456, 10), + expected: '- 123.456', + }, + { + isNegative: false, + numeric: new Numeric(789.012, 10), + expected: '+ 789.012', + }, + { + isNegative: true, + numeric: new Numeric(-0.000000001, 10), + expected: '- <0.000001', + }, + { + isNegative: false, + numeric: new Numeric(0.000000001, 10), + expected: '+ <0.000001', + }, + { + isNegative: true, + numeric: new Numeric(0, 10), + expected: '- 0', + }, + { + isNegative: false, + numeric: new Numeric(0, 10), + expected: '+ 0', + }, + ]; + + describe('Native', () => { + it.each(nativeAndErc20Cases)( + 'renders the correct sign and amount for $expected', ({ isNegative, numeric, expected }) => { - const amount = { isNegative, numeric } as Amount; + renderAndExpectText( + NATIVE_ASSET_IDENTIFIER, + { isNegative, numeric } as Amount, + expected, + ); + }, + ); + }); - const { getByText } = render( - , + describe('ERC20', () => { + it.each(nativeAndErc20Cases)( + 'renders the correct sign and amount for $expected', + ({ isNegative, numeric, expected }) => { + renderAndExpectText( + ERC20_ASSET_MOCK, + { isNegative, numeric } as Amount, + expected, ); - expect(getByText(expected)).toBeInTheDocument(); }, ); }); @@ -64,31 +111,15 @@ describe('AmountPill', () => { ]; it.each(cases)( - 'renders the token ID with just a plus or minus', + 'renders the token ID with just a plus or minus for $expected', ({ isNegative, numeric, expected }) => { - const amount = { - isNegative, - numeric, - } as Amount; - - const { getByText } = render( - , + renderAndExpectText( + ERC721_ASSET_MOCK, + { isNegative, numeric } as Amount, + expected, ); - expect(getByText(expected)).toBeInTheDocument(); }, ); - - it('does not render the amount', () => { - const amount = { - isNegative: true, - numeric: new Numeric(1, 10), - } as Amount; - - const { queryByText } = render( - , - ); - expect(queryByText('-')).not.toBeInTheDocument(); - }); }); describe('ERC1155', () => { @@ -111,14 +142,13 @@ describe('AmountPill', () => { ]; it.each(cases)( - 'renders the correct sign, amount, and token ID', + 'renders the correct sign, amount, and token ID for $expected', ({ isNegative, numeric, expected }) => { - const amount = { isNegative, numeric } as Amount; - - const { getByText } = render( - , + renderAndExpectText( + ERC1155_ASSET_MOCK, + { isNegative, numeric } as Amount, + expected, ); - expect(getByText(expected)).toBeInTheDocument(); }, ); }); diff --git a/ui/pages/confirmations/components/simulation-details/amount-pill.tsx b/ui/pages/confirmations/components/simulation-details/amount-pill.tsx index cddb4fb2e927..dae14400632e 100644 --- a/ui/pages/confirmations/components/simulation-details/amount-pill.tsx +++ b/ui/pages/confirmations/components/simulation-details/amount-pill.tsx @@ -11,8 +11,21 @@ import { } from '../../../../helpers/constants/design-system'; import { hexToDecimal } from '../../../../../shared/modules/conversion.utils'; import { TokenStandard } from '../../../../../shared/constants/transaction'; +import { + DEFAULT_PRECISION_DECIMALS, + MIN_DISPLAY_AMOUNT, +} from '../../../../hooks/useCurrencyDisplay'; import { Amount, AssetIdentifier } from './types'; +// Format an amount for display. +const formatAmount = (amount: Amount): string => { + const displayAmount = amount.numeric.abs().round(DEFAULT_PRECISION_DECIMALS); + + return displayAmount.isZero() && !amount.numeric.isZero() + ? MIN_DISPLAY_AMOUNT + : displayAmount.toString(); +}; + /** * Displays a pill with an amount and a background color indicating whether the amount * is an increase or decrease. @@ -35,13 +48,15 @@ export const AmountPill: React.FC<{ const amountParts: string[] = [amount.isNegative ? '-' : '+']; - const hideAmount = asset.standard === TokenStandard.ERC721; - if (!hideAmount) { - amountParts.push(amount.numeric.abs().round(6).toString()); + if (asset.standard !== TokenStandard.ERC721) { + // ERC721 amounts are always 1 and don't need to be displayed. + amountParts.push(formatAmount(amount)); } + if (asset.tokenId) { amountParts.push(`#${hexToDecimal(asset.tokenId)}`); } + return ( ({ + AvatarNetworkSize: { Sm: 'Sm' }, + AvatarNetwork: jest.fn(() => null), +})); jest.mock('../../../../components/app/name', () => ({ __esModule: true, @@ -16,12 +25,41 @@ describe('AssetPill', () => { jest.clearAllMocks(); }); - it('renders EthAssetPill when asset native', () => { - const asset: NativeAssetIdentifier = { standard: TokenStandard.none }; + describe('Native Asset', () => { + const cases = [ + { + chainId: CHAIN_IDS.MAINNET, + expected: { + ticker: 'ETH', + imgSrc: './images/eth_logo.svg', + }, + }, + { + chainId: CHAIN_IDS.POLYGON, + expected: { + ticker: 'MATIC', + imgSrc: './images/matic-token.svg', + }, + }, + ]; - render(); + it.each(cases)('renders chain $chainId', ({ chainId, expected }) => { + const store = configureStore({ + metamask: { providerConfig: { chainId, ticker: expected.ticker } }, + }); + + renderWithProvider(, store); + + expect(screen.getByText(expected.ticker)).toBeInTheDocument(); - expect(screen.getByText('ETH')).toBeInTheDocument(); + expect(AvatarNetwork).toHaveBeenCalledWith( + expect.objectContaining({ + name: expected.ticker, + src: expected.imgSrc, + }), + {}, + ); + }); }); it('renders Name component with correct props when asset standard is not none', () => { diff --git a/ui/pages/confirmations/components/simulation-details/asset-pill.tsx b/ui/pages/confirmations/components/simulation-details/asset-pill.tsx index 7b2fb0d47f53..cc4ba03d76e8 100644 --- a/ui/pages/confirmations/components/simulation-details/asset-pill.tsx +++ b/ui/pages/confirmations/components/simulation-details/asset-pill.tsx @@ -1,8 +1,9 @@ import React from 'react'; import { NameType } from '@metamask/name-controller'; +import { useSelector } from 'react-redux'; import { - AvatarToken, - AvatarTokenSize, + AvatarNetwork, + AvatarNetworkSize, Box, Text, } from '../../../../components/component-library'; @@ -16,31 +17,31 @@ import { } from '../../../../helpers/constants/design-system'; import Name from '../../../../components/app/name'; import { TokenStandard } from '../../../../../shared/constants/transaction'; -import { ETH_TOKEN_IMAGE_URL } from '../../../../../shared/constants/network'; +import { getNativeCurrencyImage } from '../../../../selectors'; +import { getNativeCurrency } from '../../../../ducks/metamask/metamask'; import { AssetIdentifier } from './types'; -const ETH_TICKER = 'ETH'; +const NativeAssetPill: React.FC = () => { + const ticker = useSelector(getNativeCurrency); + const imgSrc = useSelector(getNativeCurrencyImage); -const EthAssetPill: React.FC = () => ( - - - {ETH_TICKER} - -); + return ( + + + {ticker} + + ); +}; /** * Displays a pill with an asset's icon and name. @@ -50,7 +51,7 @@ const EthAssetPill: React.FC = () => ( */ export const AssetPill: React.FC<{ asset: AssetIdentifier }> = ({ asset }) => { if (asset.standard === TokenStandard.none) { - return ; + return ; } return ( = { title: 'Components/App/SimulationDetails', component: SimulationDetails, @@ -121,6 +133,33 @@ export const MultipleTokens: Story = { }, }; +export const SendSmallAmount: Story = { + args: { + simulationData: { + nativeBalanceChange: { + ...DUMMY_BALANCE_CHANGE, + difference: '0x123', + isDecrease: true, + }, + tokenBalanceChanges: [], + }, + }, +}; + +export const MaticNativeAsset: Story = { + args: { + simulationData: { + nativeBalanceChange: { + ...DUMMY_BALANCE_CHANGE, + difference: '0x123456', + isDecrease: true, + }, + tokenBalanceChanges: [], + }, + }, + decorators: [(story) => {story()}], +}; + export const ReceiveOnly: Story = { args: { diff --git a/ui/pages/confirmations/components/simulation-details/types.ts b/ui/pages/confirmations/components/simulation-details/types.ts index e1efc4d39f67..913873692b76 100644 --- a/ui/pages/confirmations/components/simulation-details/types.ts +++ b/ui/pages/confirmations/components/simulation-details/types.ts @@ -2,6 +2,10 @@ import { Hex } from '@metamask/utils'; import { TokenStandard } from '../../../../../shared/constants/transaction'; import { Numeric } from '../../../../../shared/modules/Numeric'; +export const NATIVE_ASSET_IDENTIFIER: NativeAssetIdentifier = { + standard: TokenStandard.none, +}; + /** * Describes an amount of fiat. */ diff --git a/ui/pages/confirmations/components/simulation-details/useBalanceChanges.ts b/ui/pages/confirmations/components/simulation-details/useBalanceChanges.ts index 9c9375510af1..85cbce9f091d 100644 --- a/ui/pages/confirmations/components/simulation-details/useBalanceChanges.ts +++ b/ui/pages/confirmations/components/simulation-details/useBalanceChanges.ts @@ -20,11 +20,10 @@ import { Amount, BalanceChange, FIAT_UNAVAILABLE, - NativeAssetIdentifier, + NATIVE_ASSET_IDENTIFIER, TokenAssetIdentifier, } from './types'; -const NATIVE_ASSET: NativeAssetIdentifier = { standard: TokenStandard.none }; const NATIVE_DECIMALS = 18; const ERC20_DEFAULT_DECIMALS = 18; const EMPTY_TOKEN_BALANCE_CHANGES: SimulationTokenBalanceChange[] = []; @@ -83,7 +82,7 @@ function getNativeBalanceChange( if (!nativeBalanceChange) { return undefined; } - const asset = NATIVE_ASSET; + const asset = NATIVE_ASSET_IDENTIFIER; const amount = getAssetAmount(nativeBalanceChange, NATIVE_DECIMALS); const fiatAmount = amount.numeric .applyConversionRate(nativeFiatRate) From d405dcc8f89adb7150d2b1bf14af41014b5d2800 Mon Sep 17 00:00:00 2001 From: jiexi Date: Wed, 27 Mar 2024 11:41:27 -0700 Subject: [PATCH 07/27] fix: Fix getProviderState networkVersion for request queue (#23590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Currently the globally selected network's networkId is being sent as the `networkVersion` to all dapps when request queue is enabled. This PR fixes this by making an appropriate `net_version` call when each dapp's inpage provider requires it. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23590?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2176 ## **Manual testing steps** 1. Enable request queue 2. Go to a dapp (Refresh the page if you had it opened before request queue was on) 3. use `wallet_switchEthereumChain` to make the dapp and globally selected networks different 3. check `window.ethereum.chainId` and `window.ethereum.networkVersion` values, they should match the dapp's network 1. Disable request queue 2. Go to a dapp (Refresh the page if you had it opened before request queue was on) 3. check `window.ethereum.chainId` and `window.ethereum.networkVersion` values, they should match the global network ## **Screenshots/Recordings** ### **Before** Request Queue On https://github.com/MetaMask/metamask-extension/assets/918701/6edde8d0-c911-4349-91f2-e7b5a18b32a8 ### **After** Request Queue On https://github.com/MetaMask/metamask-extension/assets/918701/3490e442-4562-458d-b138-59cb7c6f34b9 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Alex Donesky --- app/scripts/metamask-controller.js | 132 +++++++++++------------------ 1 file changed, 51 insertions(+), 81 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 3279b6acb348..a70d8b90d2ea 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -486,13 +486,7 @@ export default class MetamaskController extends EventEmitter { this.networkController.getProviderAndBlockTracker().provider; this.blockTracker = this.networkController.getProviderAndBlockTracker().blockTracker; - - // TODO: Delete when ready to remove `networkVersion` from provider object - this.deprecatedNetworkId = null; - networkControllerMessenger.subscribe( - 'NetworkController:networkDidChange', - () => this.updateDeprecatedNetworkId(), - ); + this.deprecatedNetworkVersions = {}; const tokenListMessenger = this.controllerMessenger.getRestricted({ name: 'TokenListController', @@ -2202,7 +2196,6 @@ export default class MetamaskController extends EventEmitter { } postOnboardingInitialization() { - this.updateDeprecatedNetworkId(); this.networkController.lookupNetwork(); } @@ -2676,20 +2669,21 @@ export default class MetamaskController extends EventEmitter { // subset of state for metamask inpage provider const publicConfigStore = new ObservableStore(); - const selectPublicState = (chainId, { isUnlocked }) => { + const selectPublicState = async ({ isUnlocked }) => { + const { chainId, networkVersion } = await this.getProviderNetworkState(); + return { isUnlocked, chainId, - networkVersion: this.deprecatedNetworkId ?? 'loading', + networkVersion: networkVersion ?? 'loading', }; }; - const updatePublicConfigStore = (memState) => { + const updatePublicConfigStore = async (memState) => { const networkStatus = memState.networksMetadata[memState.selectedNetworkClientId]?.status; - const { chainId } = this.networkController.state.providerConfig; if (networkStatus === NetworkStatus.Available) { - publicConfigStore.putState(selectPublicState(chainId, memState)); + publicConfigStore.putState(await selectPublicState(memState)); } }; @@ -2707,12 +2701,14 @@ export default class MetamaskController extends EventEmitter { * @returns {Promise<{ isUnlocked: boolean, networkVersion: string, chainId: string, accounts: string[] }>} An object with relevant state properties. */ async getProviderState(origin) { + const providerNetworkState = await this.getProviderNetworkState( + this.preferencesController.getUseRequestQueue() ? origin : undefined, + ); + return { isUnlocked: this.isUnlocked(), accounts: await this.getPermittedAccounts(origin), - ...this.getProviderNetworkState( - this.preferencesController.getUseRequestQueue() ? origin : undefined, - ), + ...providerNetworkState, }; } @@ -2722,71 +2718,41 @@ export default class MetamaskController extends EventEmitter { * @param {string} origin - The origin identifier for which network state is requested (default: 'metamask'). * @returns {object} An object containing important network state properties, including chainId and networkVersion. */ - getProviderNetworkState(origin = METAMASK_DOMAIN) { - let chainId; - if ( - this.preferencesController.getUseRequestQueue() && - origin !== METAMASK_DOMAIN - ) { - const networkClientId = this.controllerMessenger.call( - 'SelectedNetworkController:getNetworkClientIdForDomain', - origin, - ); - - const networkClient = this.controllerMessenger.call( - 'NetworkController:getNetworkClientById', - networkClientId, - ); - chainId = networkClient.configuration.chainId; - } else { - chainId = this.networkController.state.providerConfig.chainId; - } + async getProviderNetworkState(origin = METAMASK_DOMAIN) { + const networkClientId = this.controllerMessenger.call( + 'SelectedNetworkController:getNetworkClientIdForDomain', + origin, + ); - return { - chainId, - networkVersion: this.deprecatedNetworkId ?? 'loading', - }; - } + const networkClient = this.controllerMessenger.call( + 'NetworkController:getNetworkClientById', + networkClientId, + ); - /** - * TODO: Delete when ready to remove `networkVersion` from provider object - * Updates the `deprecatedNetworkId` value - */ - async updateDeprecatedNetworkId() { - try { - this.deprecatedNetworkId = await this.deprecatedGetNetworkId(); - } catch (error) { - console.error(error); - this.deprecatedNetworkId = null; - } - this._notifyChainChange(); - } + const { chainId } = networkClient.configuration; - /** - * TODO: Delete when ready to remove `networkVersion` from provider object - * Gets current networkId as returned by `net_version` - * - * @returns {string} The networkId for the current network or null on failure - * @throws Will throw if there is a problem getting the network version - */ - async deprecatedGetNetworkId() { - const ethQuery = this.controllerMessenger.call( - 'NetworkController:getEthQuery', - ); + const { completedOnboarding } = this.onboardingController.store.getState(); - if (!ethQuery) { - throw new Error('Provider has not been initialized'); + let networkVersion = this.deprecatedNetworkVersions[networkClientId]; + if (!networkVersion && completedOnboarding) { + const ethQuery = new EthQuery(networkClient.provider); + networkVersion = await new Promise((resolve) => { + ethQuery.sendAsync({ method: 'net_version' }, (error, result) => { + if (error) { + console.error(error); + resolve(null); + } else { + resolve(convertNetworkId(result)); + } + }); + }); + this.deprecatedNetworkVersions[networkClientId] = networkVersion; } - return new Promise((resolve, reject) => { - ethQuery.sendAsync({ method: 'net_version' }, (error, result) => { - if (error) { - reject(error); - } else { - resolve(convertNetworkId(result)); - } - }); - }); + return { + chainId, + networkVersion: networkVersion ?? 'loading', + }; } //============================================================================= @@ -5303,8 +5269,12 @@ export default class MetamaskController extends EventEmitter { Object.keys(this.connections).forEach((origin) => { Object.values(this.connections[origin]).forEach(async (conn) => { - if (conn.engine) { - conn.engine.emit('notification', await getPayload(origin)); + try { + if (conn.engine) { + conn.engine.emit('notification', await getPayload(origin)); + } + } catch (err) { + console.error(err); } }); }); @@ -5848,16 +5818,16 @@ export default class MetamaskController extends EventEmitter { this.permissionLogController.updateAccountsHistory(origin, newAccounts); } - _notifyChainChange() { + async _notifyChainChange() { if (this.preferencesController.getUseRequestQueue()) { - this.notifyAllConnections((origin) => ({ + this.notifyAllConnections(async (origin) => ({ method: NOTIFICATION_NAMES.chainChanged, - params: this.getProviderNetworkState(origin), + params: await this.getProviderNetworkState(origin), })); } else { this.notifyAllConnections({ method: NOTIFICATION_NAMES.chainChanged, - params: this.getProviderNetworkState(), + params: await this.getProviderNetworkState(), }); } } From 6ad313f6473261044cf20559a4e03cdc01f9572b Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Wed, 27 Mar 2024 16:35:34 -0400 Subject: [PATCH 08/27] chore: Enable `@typescript-eslint/no-explicit-any` as an error rule (#23531) --- .eslintrc.js | 1 + .../controllers/decrypt-message.test.ts | 22 ++++++++ app/scripts/controllers/decrypt-message.ts | 10 ++++ .../controllers/encryption-public-key.test.ts | 30 +++++++++++ .../controllers/encryption-public-key.ts | 10 ++++ app/scripts/controllers/mmi-controller.ts | 26 +++++++++ .../lib/AbstractPetnamesBridge.test.ts | 2 + .../AccountIdentitiesPetnamesBridge.test.ts | 6 +++ .../lib/AddressBookPetnamesBridge.test.ts | 4 ++ app/scripts/lib/AddressBookPetnamesBridge.ts | 10 ++++ app/scripts/lib/SnapsNameProvider.test.ts | 2 + .../lib/keyring-snaps-permissions.test.ts | 6 +++ .../lattice-offscreen-keyring.ts | 2 + app/scripts/lib/ppom/indexed-db-backend.ts | 12 +++++ app/scripts/lib/ppom/ppom-middleware.test.ts | 24 +++++++++ app/scripts/lib/ppom/ppom-middleware.ts | 2 + app/scripts/lib/ppom/ppom-util.ts | 2 + app/scripts/lib/snap-keyring/metrics.test.ts | 2 + app/scripts/lib/snap-keyring/snap-keyring.ts | 10 ++++ .../snap-keyring/utils/isBlockedUrl.test.ts | 2 + .../lib/snap-keyring/utils/showResult.ts | 4 ++ app/scripts/lib/transaction/metrics.test.ts | 54 +++++++++++++++++++ app/scripts/lib/transaction/metrics.ts | 30 +++++++++++ app/scripts/lib/transaction/mmi-hooks.test.ts | 20 +++++++ app/scripts/lib/transaction/mmi-hooks.ts | 2 + app/scripts/lib/transaction/util.test.ts | 2 + app/scripts/lib/transaction/util.ts | 4 ++ app/scripts/lib/util.ts | 2 + app/scripts/migrations/081.ts | 2 +- app/scripts/migrations/095.ts | 10 ++++ app/scripts/migrations/096.ts | 14 +++++ app/scripts/migrations/097.ts | 2 + app/scripts/migrations/098.ts | 2 + app/scripts/migrations/099.test.ts | 2 + app/scripts/migrations/099.ts | 4 ++ app/scripts/migrations/100.ts | 2 + app/scripts/migrations/102.ts | 4 ++ app/scripts/migrations/104.ts | 4 ++ app/scripts/migrations/105.ts | 6 +++ app/scripts/migrations/108.ts | 2 + app/scripts/migrations/109.ts | 2 + app/scripts/migrations/110.ts | 2 + app/scripts/migrations/111.ts | 2 + app/scripts/migrations/112.ts | 2 + app/scripts/migrations/114.ts | 2 + development/lib/build-type.d.ts | 2 + offscreen/scripts/callback-processor.ts | 4 ++ offscreen/scripts/ledger.ts | 2 + offscreen/scripts/trezor.ts | 2 + shared/constants/mmi-controller.ts | 20 +++++++ shared/lib/fetch-with-cache.ts | 4 ++ shared/lib/token-util.ts | 10 ++++ shared/modules/i18n.test.ts | 4 ++ shared/modules/i18n.ts | 6 +++ types/global.d.ts | 6 +++ types/react-tippy.d.ts | 4 ++ ui/components/app/confirm/info/info.test.tsx | 2 + ui/components/app/confirm/info/info.tsx | 2 + .../app/confirm/info/row/address.test.tsx | 2 + .../app/confirm/info/row/currency.test.tsx | 2 + .../hooks/useTokenExchangeRate.test.tsx | 2 + .../incoming-transaction-toggle.tsx | 10 ++++ .../transaction-already-confirmed.tsx | 6 +++ .../app/name/name-details/metrics.ts | 8 +++ .../app/name/name-details/name-details.tsx | 4 ++ .../keyring-snap-removal-warning.test.tsx | 2 + .../app/snaps/snap-ui-renderer/utils.ts | 2 + .../QuizContent/QuizContent.tsx | 2 + .../app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx | 2 + ui/components/app/srp-quiz-modal/types.ts | 2 + .../component-library/box/box.test.tsx | 2 + .../component-library/box/box.types.ts | 2 + .../checkbox/checkbox.types.ts | 4 ++ .../form-text-field/form-text-field.tsx | 2 + .../modal-content/modal-content.types.ts | 2 + .../modal-focus/modal-focus.tsx | 2 + .../select-button/select-button.types.ts | 6 +++ .../select-option/select-option.types.ts | 4 ++ .../select-wrapper/select-wrapper.tsx | 2 + .../select-wrapper/select-wrapper.types.ts | 28 ++++++++++ .../asset-balance/asset-balance-text.test.tsx | 6 +++ .../asset-balance/asset-balance-text.tsx | 2 + .../asset-picker-amount.test.tsx | 2 + .../asset-picker-modal/asset-picker-modal.tsx | 6 +++ .../asset-picker/asset-picker.test.tsx | 4 ++ .../asset-picker/asset-picker.tsx | 2 + .../connected-accounts-menu.tsx | 2 + .../connected-status/connected-status.tsx | 2 + .../pages/connections/connections.tsx | 16 ++++++ .../pages/send/components/content.tsx | 2 + .../multichain/pages/send/components/hex.tsx | 2 + .../pages/send/components/recipient.tsx | 2 + .../pages/send/components/your-accounts.tsx | 2 + .../permission-details-modal.tsx | 2 + ui/components/multichain/toast/toast.test.tsx | 2 + ui/components/ui/box/box.d.ts | 2 + .../currency-display.component.d.ts | 6 +++ .../ui/form-combo-field/form-combo-field.tsx | 12 +++++ ui/ducks/app/app.ts | 8 +++ ui/helpers/utils/tx-helper.ts | 14 +++++ ui/hooks/useDisplayName.test.ts | 2 + ui/hooks/useDisplayName.ts | 2 + ui/hooks/useFirstPartyContractName.test.ts | 2 + ui/hooks/useModalProps.test.ts | 2 + ui/hooks/useModalProps.ts | 4 ++ ui/hooks/useName.test.ts | 4 ++ ui/hooks/usePolling.ts | 4 ++ ui/hooks/useTheme.test.ts | 2 + .../confirm/blockaid-alert/blockaid-alert.tsx | 2 + .../components/confirm/footer/footer.test.tsx | 4 ++ .../components/confirm/nav/nav.test.tsx | 2 + .../typed-sign-data-v1/typedSignDataV1.tsx | 2 + .../typed-sign-data/typedSignData.test.tsx | 4 ++ .../useSimulationMetrics.test.ts | 10 ++++ .../useSimulationMetrics.ts | 2 + .../confirmation/ResultTemplate.test.ts | 6 +++ .../confirmation/ResultTemplate.ts | 8 +++ .../hooks/setCurrentConfirmation.test.tsx | 4 ++ ui/pages/confirmations/utils/confirm.test.ts | 4 ++ ui/pages/swaps/swaps.util.ts | 34 ++++++++++++ ui/store/actions.ts | 28 ++++++++++ ui/store/background-connection.ts | 10 ++++ ui/store/institutional/institution-actions.ts | 4 ++ .../institutional/institution-background.ts | 14 +++++ ui/store/store.ts | 4 ++ 125 files changed, 792 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index d57cc7bf7aef..53235d12c55a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -135,6 +135,7 @@ module.exports = { path.resolve(__dirname, '.eslintrc.typescript-compat.js'), ], rules: { + '@typescript-eslint/no-explicit-any': 'error', // this rule is new, but we didn't use it before, so it's off now '@typescript-eslint/no-duplicate-enum-values': 'off', '@typescript-eslint/no-shadow': [ diff --git a/app/scripts/controllers/decrypt-message.test.ts b/app/scripts/controllers/decrypt-message.test.ts index a1cb0a58f037..848fe3f9986d 100644 --- a/app/scripts/controllers/decrypt-message.test.ts +++ b/app/scripts/controllers/decrypt-message.test.ts @@ -38,6 +38,8 @@ const createMessengerMock = () => registerInitialEventPayload: jest.fn(), publish: jest.fn(), call: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any as jest.Mocked); const createDecryptMessageManagerMock = () => @@ -57,6 +59,8 @@ const createDecryptMessageManagerMock = () => hub: { on: jest.fn(), }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any as jest.Mocked); describe('DecryptMessageController', () => { @@ -81,6 +85,8 @@ describe('DecryptMessageController', () => { const mockMessengerAction = ( action: string, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any callback: (actionName: string, ...args: any[]) => any, ) => { messengerMock.call.mockImplementation((actionName, ...rest) => { @@ -100,9 +106,17 @@ describe('DecryptMessageController', () => { ); decryptMessageController = new MockDecryptMessageController({ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getState: getStateMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any keyringController: keyringControllerMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any messenger: messengerMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any metricsEvent: metricsEventMock as any, } as DecryptMessageControllerOptions); }); @@ -116,6 +130,8 @@ describe('DecryptMessageController', () => { decryptMessageController.update(() => ({ unapprovedDecryptMsgs: { [messageIdMock]: messageMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any, unapprovedDecryptMsgCount: 1, })); @@ -131,6 +147,8 @@ describe('DecryptMessageController', () => { it('should add unapproved messages', async () => { await decryptMessageController.newRequestDecryptMessage( messageMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any undefined as any, ); @@ -220,6 +238,8 @@ describe('DecryptMessageController', () => { const messageToDecrypt = { ...messageMock, data: messageDataMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; decryptMessageManagerMock.getMessage.mockReturnValue(messageToDecrypt); mockMessengerAction( @@ -271,6 +291,8 @@ describe('DecryptMessageController', () => { it('should be able to reject all unapproved messages', async () => { decryptMessageManagerMock.getUnapprovedMessages.mockReturnValue({ [messageIdMock]: messageMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); await decryptMessageController.rejectUnapproved('reason to cancel'); diff --git a/app/scripts/controllers/decrypt-message.ts b/app/scripts/controllers/decrypt-message.ts index 5dbb4d8b43c6..51bf9c4b1250 100644 --- a/app/scripts/controllers/decrypt-message.ts +++ b/app/scripts/controllers/decrypt-message.ts @@ -117,8 +117,12 @@ export type DecryptMessageControllerMessenger = RestrictedControllerMessenger< >; export type DecryptMessageControllerOptions = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getState: () => any; messenger: DecryptMessageControllerMessenger; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any metricsEvent: (payload: any, options?: any) => void; }; @@ -132,8 +136,12 @@ export default class DecryptMessageController extends BaseController< > { hub: EventEmitter; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private _getState: () => any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private _metricsEvent: (payload: any, options?: any) => void; private _decryptMessageManager: DecryptMessageManager; @@ -363,6 +371,8 @@ export default class DecryptMessageController extends BaseController< ) { messageManager.subscribe((state: MessageManagerState) => { const newMessages = this._migrateMessages( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any state.unapprovedMessages as any, ); this.update((draftState) => { diff --git a/app/scripts/controllers/encryption-public-key.test.ts b/app/scripts/controllers/encryption-public-key.test.ts index c36418abffb1..274f0c67d7e9 100644 --- a/app/scripts/controllers/encryption-public-key.test.ts +++ b/app/scripts/controllers/encryption-public-key.test.ts @@ -34,6 +34,8 @@ const messageMock = { status: 'unapproved', type: 'testType', rawSig: undefined, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any as AbstractMessage; const coreMessageMock = { @@ -56,6 +58,8 @@ const createMessengerMock = () => registerActionHandler: jest.fn(), publish: jest.fn(), call: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any as jest.Mocked); const createEncryptionPublicKeyManagerMock = () => @@ -71,6 +75,8 @@ const createEncryptionPublicKeyManagerMock = () => hub: { on: jest.fn(), }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any as jest.Mocked); describe('EncryptionPublicKeyController', () => { @@ -96,10 +102,20 @@ describe('EncryptionPublicKeyController', () => { ); encryptionPublicKeyController = new EncryptionPublicKeyController({ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any messenger: messengerMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getEncryptionPublicKey: getEncryptionPublicKeyMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getAccountKeyringType: getAccountKeyringTypeMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getState: getStateMock as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any metricsEvent: metricsEventMock as any, } as EncryptionPublicKeyControllerOptions); }); @@ -120,6 +136,8 @@ describe('EncryptionPublicKeyController', () => { encryptionPublicKeyController.update(() => ({ unapprovedEncryptionPublicKeyMsgs: { [messageIdMock]: messageMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any, unapprovedEncryptionPublicKeyMsgCount: 1, })); @@ -140,11 +158,15 @@ describe('EncryptionPublicKeyController', () => { [messageIdMock2]: messageMock, }; encryptionPublicKeyManagerMock.getUnapprovedMessages.mockReturnValueOnce( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any messages as any, ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore encryptionPublicKeyController.update(() => ({ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any unapprovedEncryptionPublicKeyMsgs: messages as any, })); }); @@ -353,6 +375,8 @@ describe('EncryptionPublicKeyController', () => { const mockListener = jest.fn(); encryptionPublicKeyController.hub.on('updateBadge', mockListener); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (encryptionPublicKeyManagerMock.hub.on as any).mock.calls[0][1](); expect(mockListener).toHaveBeenCalledTimes(1); @@ -361,6 +385,8 @@ describe('EncryptionPublicKeyController', () => { it('requires approval on unapproved message event from EncryptionPublicKeyManager', () => { messengerMock.call.mockResolvedValueOnce({}); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (encryptionPublicKeyManagerMock.hub.on as any).mock.calls[1][1]( messageParamsMock, ); @@ -379,12 +405,16 @@ describe('EncryptionPublicKeyController', () => { it('updates state on EncryptionPublicKeyManager state change', async () => { await encryptionPublicKeyManagerMock.subscribe.mock.calls[0][0]({ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any unapprovedMessages: { [messageIdMock]: coreMessageMock as any }, unapprovedMessagesCount: 3, }); expect(encryptionPublicKeyController.state).toEqual({ unapprovedEncryptionPublicKeyMsgs: { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any [messageIdMock]: stateMessageMock as any, }, unapprovedEncryptionPublicKeyMsgCount: 3, diff --git a/app/scripts/controllers/encryption-public-key.ts b/app/scripts/controllers/encryption-public-key.ts index 4bb019a10b72..2864bab34600 100644 --- a/app/scripts/controllers/encryption-public-key.ts +++ b/app/scripts/controllers/encryption-public-key.ts @@ -87,7 +87,11 @@ export type EncryptionPublicKeyControllerOptions = { messenger: EncryptionPublicKeyControllerMessenger; getEncryptionPublicKey: (address: string) => Promise; getAccountKeyringType: (account: string) => Promise; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getState: () => any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any metricsEvent: (payload: any, options?: any) => void; }; @@ -105,10 +109,14 @@ export default class EncryptionPublicKeyController extends BaseController< private _getAccountKeyringType: (account: string) => Promise; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private _getState: () => any; private _encryptionPublicKeyManager: EncryptionPublicKeyManager; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private _metricsEvent: (payload: any, options?: any) => void; /** @@ -352,6 +360,8 @@ export default class EncryptionPublicKeyController extends BaseController< ) { messageManager.subscribe((state: MessageManagerState) => { const newMessages = this._migrateMessages( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any state.unapprovedMessages as any, ); this.update((draftState) => { diff --git a/app/scripts/controllers/mmi-controller.ts b/app/scripts/controllers/mmi-controller.ts index b2d66f36afdf..4f8b77de2f52 100644 --- a/app/scripts/controllers/mmi-controller.ts +++ b/app/scripts/controllers/mmi-controller.ts @@ -48,6 +48,8 @@ type UpdateCustodianTransactionsParameters = { txList: string[]; custodyController: CustodyController; transactionUpdateController: TransactionUpdateController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any txStateManager: any; getPendingNonce: (address: string) => Promise; setTxHash: (txId: string, txHash: string) => void; @@ -58,6 +60,8 @@ export default class MMIController extends EventEmitter { public mmiConfigurationController: MmiConfigurationController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any public keyringController: any; public preferencesController: PreferencesController; @@ -68,8 +72,12 @@ export default class MMIController extends EventEmitter { private custodyController: CustodyController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private getState: () => any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private getPendingNonce: (address: string) => Promise; private accountTracker: AccountTracker; @@ -78,28 +86,42 @@ export default class MMIController extends EventEmitter { private networkController: NetworkController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private permissionController: any; private signatureController: SignatureController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private messenger: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private platform: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any private extension: any; private updateTransactionHash: (txId: string, txHash: string) => void; public trackTransactionEvents: ( args: { transactionMeta: TransactionMeta }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any event: any, ) => void; private txStateManager: { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getTransactions: (query?: any, opts?: any, fullTx?: boolean) => any[]; setTxStatusSigned: (txId: string) => void; setTxStatusSubmitted: (txId: string) => void; setTxStatusFailed: (txId: string) => void; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any updateTransaction: (txMeta: any) => void; }; @@ -171,6 +193,8 @@ export default class MMIController extends EventEmitter { async trackTransactionEventFromCustodianEvent( txMeta: TransactionMeta, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any event: any, ) { // transactionMetricsRequest parameter is already bound in the constructor @@ -322,6 +346,8 @@ export default class MMIController extends EventEmitter { string, { name: string; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any custodianDetails: any; labels: Label[]; token: string; diff --git a/app/scripts/lib/AbstractPetnamesBridge.test.ts b/app/scripts/lib/AbstractPetnamesBridge.test.ts index 608454b38afe..3347c90f13f5 100644 --- a/app/scripts/lib/AbstractPetnamesBridge.test.ts +++ b/app/scripts/lib/AbstractPetnamesBridge.test.ts @@ -94,6 +94,8 @@ function createNameControllerMock(state: NameControllerState) { function createMessengerMock(): jest.Mocked { return { subscribe: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; } diff --git a/app/scripts/lib/AccountIdentitiesPetnamesBridge.test.ts b/app/scripts/lib/AccountIdentitiesPetnamesBridge.test.ts index 6431381d7099..b7ac979f3a1c 100644 --- a/app/scripts/lib/AccountIdentitiesPetnamesBridge.test.ts +++ b/app/scripts/lib/AccountIdentitiesPetnamesBridge.test.ts @@ -105,16 +105,22 @@ function createNameControllerMock( return { state, setName: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; } function simulateSubscribe( messenger: jest.Mocked, stateChange: AccountsControllerState, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any patch: any[], ) { const listener = messenger.subscribe.mock.calls[0][1] as ( stateChange: AccountsControllerState, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any patch: any[], ) => void; listener(stateChange, patch); diff --git a/app/scripts/lib/AddressBookPetnamesBridge.test.ts b/app/scripts/lib/AddressBookPetnamesBridge.test.ts index c98e6a5e309e..f95726fba7b2 100644 --- a/app/scripts/lib/AddressBookPetnamesBridge.test.ts +++ b/app/scripts/lib/AddressBookPetnamesBridge.test.ts @@ -37,12 +37,16 @@ function createNameControllerMock( return { state, setName: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; } function createMessengerMock(): jest.Mocked { return { subscribe: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; } diff --git a/app/scripts/lib/AddressBookPetnamesBridge.ts b/app/scripts/lib/AddressBookPetnamesBridge.ts index e6f7e9813fa1..141814a9ef62 100644 --- a/app/scripts/lib/AddressBookPetnamesBridge.ts +++ b/app/scripts/lib/AddressBookPetnamesBridge.ts @@ -35,9 +35,13 @@ export class AddressBookPetnamesBridge extends AbstractPetnamesBridge { const entries: PetnameEntry[] = []; const { state } = this.#addressBookController; for (const chainId of Object.keys(state.addressBook)) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const chainEntries = state.addressBook[chainId as any]; for (const address of Object.keys(chainEntries)) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const entry = state.addressBook[chainId as any][address]; const normalizedChainId = chainId.toLowerCase(); const { name, isEns } = entry; @@ -64,11 +68,17 @@ export class AddressBookPetnamesBridge extends AbstractPetnamesBridge { */ protected updateSourceEntry(type: ChangeType, entry: PetnameEntry): void { if (type === ChangeType.DELETED) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any this.#addressBookController.delete(entry.variation as any, entry.value); } else { this.#addressBookController.set( entry.value, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any entry.name as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any entry.variation as any, ); } diff --git a/app/scripts/lib/SnapsNameProvider.test.ts b/app/scripts/lib/SnapsNameProvider.test.ts index 6d6f0dd6a120..25a5f22a3f80 100644 --- a/app/scripts/lib/SnapsNameProvider.test.ts +++ b/app/scripts/lib/SnapsNameProvider.test.ts @@ -94,6 +94,8 @@ function createMockMessenger({ return { call: callMock, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; } diff --git a/app/scripts/lib/keyring-snaps-permissions.test.ts b/app/scripts/lib/keyring-snaps-permissions.test.ts index afe4b40fefa6..3e457df2e258 100644 --- a/app/scripts/lib/keyring-snaps-permissions.test.ts +++ b/app/scripts/lib/keyring-snaps-permissions.test.ts @@ -15,6 +15,8 @@ describe('keyringSnapPermissionsBuilder', () => { registerActionHandler: jest.fn(), registerInitialEventPayload: jest.fn(), publish: jest.fn(), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any, state: {}, }); @@ -85,6 +87,8 @@ describe('keyringSnapPermissionsBuilder', () => { ])('"%s" cannot call any methods', (origin) => { const permissions = keyringSnapPermissionsBuilder( mockController, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any origin as any, ); expect(permissions()).toStrictEqual([]); @@ -106,6 +110,8 @@ describe('isProtocolAllowed', () => { [1, false], [0, false], [-1, false], + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ])('"%s" cannot call any methods', (origin: any, expected: boolean) => { expect(isProtocolAllowed(origin)).toBe(expected); }); diff --git a/app/scripts/lib/offscreen-bridge/lattice-offscreen-keyring.ts b/app/scripts/lib/offscreen-bridge/lattice-offscreen-keyring.ts index c690c1004382..27993e04d03c 100644 --- a/app/scripts/lib/offscreen-bridge/lattice-offscreen-keyring.ts +++ b/app/scripts/lib/offscreen-bridge/lattice-offscreen-keyring.ts @@ -61,6 +61,8 @@ class LatticeKeyringOffscreen extends LatticeKeyring { }); return creds; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { throw new Error(err); } diff --git a/app/scripts/lib/ppom/indexed-db-backend.ts b/app/scripts/lib/ppom/indexed-db-backend.ts index 41c5af2629d1..8fbf63c1aced 100644 --- a/app/scripts/lib/ppom/indexed-db-backend.ts +++ b/app/scripts/lib/ppom/indexed-db-backend.ts @@ -38,6 +38,8 @@ export class IndexedDBPPOMStorage implements StorageBackend { reject( new Error( `Failed to open database ${this.storeName}: ${ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (event.target as any)?.error }`, ), @@ -65,8 +67,12 @@ export class IndexedDBPPOMStorage implements StorageBackend { private async objectStoreAction( method: 'get' | 'delete' | 'put' | 'getAllKeys', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any args?: any, mode: IDBTransactionMode = 'readonly', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise { return new Promise((resolve, reject) => { this.#getObjectStore(mode) @@ -81,6 +87,8 @@ export class IndexedDBPPOMStorage implements StorageBackend { reject( new Error( `Error in indexDB operation ${method}: ${ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (event.target as any)?.error }`, ), @@ -95,6 +103,8 @@ export class IndexedDBPPOMStorage implements StorageBackend { async read(key: StorageKey, checksum: string): Promise { const event = await this.objectStoreAction('get', [key.name, key.chainId]); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const data = (event.target as any)?.result?.data; await validateChecksum(key, data, checksum); return data; @@ -119,6 +129,8 @@ export class IndexedDBPPOMStorage implements StorageBackend { async dir(): Promise { const event = await this.objectStoreAction('getAllKeys'); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (event.target as any)?.result.map(([name, chainId]: string[]) => ({ name, chainId, diff --git a/app/scripts/lib/ppom/ppom-middleware.test.ts b/app/scripts/lib/ppom/ppom-middleware.test.ts index ab64ea6a9a08..370acc51e944 100644 --- a/app/scripts/lib/ppom/ppom-middleware.test.ts +++ b/app/scripts/lib/ppom/ppom-middleware.test.ts @@ -26,10 +26,14 @@ Object.defineProperty(globalThis, 'performance', { }); const createMiddleWare = ( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any usePPOM?: any, options: { securityAlertsEnabled?: boolean; chainId?: Hex; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any mockUpdateSecurityAlertResponseByTxId?: any; } = { mockUpdateSecurityAlertResponseByTxId: () => undefined, @@ -60,9 +64,17 @@ const createMiddleWare = ( }; return createPPOMMiddleware( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ppomController as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any preferenceController as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any networkController as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any appStateController as any, mockUpdateSecurityAlertResponseByTxId, ); @@ -119,6 +131,8 @@ describe('PPOMMiddleware', () => { const ppom = { validateJsonRpc: validateMock, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (callback: any) => { callback(ppom); }; @@ -223,6 +237,8 @@ describe('PPOMMiddleware', () => { const ppom = { validateJsonRpc: () => undefined, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (callback: any) => { callback(ppom); }; @@ -237,6 +253,8 @@ describe('PPOMMiddleware', () => { }); it('calls next method when ppomController.usePPOM throws error', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (_callback: any) => { throw Error('Some error'); }; @@ -254,6 +272,8 @@ describe('PPOMMiddleware', () => { const ppom = { validateJsonRpc: validateMock, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (callback: any) => { callback(ppom); }; @@ -271,6 +291,8 @@ describe('PPOMMiddleware', () => { const ppom = { validateJsonRpc: validateMock, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (callback: any) => { callback(ppom); }; @@ -303,6 +325,8 @@ describe('PPOMMiddleware', () => { validateJsonRpc: validateMock, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const usePPOM = async (callback: any) => { callback(ppom); }; diff --git a/app/scripts/lib/ppom/ppom-middleware.ts b/app/scripts/lib/ppom/ppom-middleware.ts index ffb20a5b73b6..8992b3a37c07 100644 --- a/app/scripts/lib/ppom/ppom-middleware.ts +++ b/app/scripts/lib/ppom/ppom-middleware.ts @@ -63,6 +63,8 @@ export function createPPOMMiddleware< ppomController: PPOMController, preferencesController: PreferencesController, networkController: NetworkController, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any appStateController: any, updateSecurityAlertResponseByTxId: ( req: JsonRpcRequest & { diff --git a/app/scripts/lib/ppom/ppom-util.ts b/app/scripts/lib/ppom/ppom-util.ts index d0f9141996c0..95806d41bb4a 100644 --- a/app/scripts/lib/ppom/ppom-util.ts +++ b/app/scripts/lib/ppom/ppom-util.ts @@ -2,6 +2,8 @@ import { normalizeTransactionParams } from '@metamask/transaction-controller'; const METHOD_SEND_TRANSACTION = 'eth_sendTransaction'; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function normalizePPOMRequest(request: any) { if (request.method !== METHOD_SEND_TRANSACTION) { return request; diff --git a/app/scripts/lib/snap-keyring/metrics.test.ts b/app/scripts/lib/snap-keyring/metrics.test.ts index e0ef57fc2b59..fe49b2be73e4 100644 --- a/app/scripts/lib/snap-keyring/metrics.test.ts +++ b/app/scripts/lib/snap-keyring/metrics.test.ts @@ -3,6 +3,8 @@ import { getSnapAndHardwareInfoForMetrics } from './metrics'; describe('getSnapAndHardwareInfoForMetrics', () => { let getAccountType: jest.Mock; let getDeviceModel: jest.Mock; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any let messenger: any; beforeEach(() => { diff --git a/app/scripts/lib/snap-keyring/snap-keyring.ts b/app/scripts/lib/snap-keyring/snap-keyring.ts index 17683dee0a52..62b61c8ed335 100644 --- a/app/scripts/lib/snap-keyring/snap-keyring.ts +++ b/app/scripts/lib/snap-keyring/snap-keyring.ts @@ -51,14 +51,22 @@ export const snapKeyringBuilder = ( getSnapController: () => SnapController, persistKeyringHelper: () => Promise, setSelectedAccountHelper: (address: string) => void, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any removeAccountHelper: (address: string) => Promise, trackEvent: ( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any payload: Record, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any options?: Record, ) => void, getSnapName: (snapId: string) => string, ) => { const builder = (() => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any return new SnapKeyring(getSnapController() as any, { addressExists: async (address) => { const addresses = await controllerMessenger.call( @@ -348,6 +356,8 @@ export const snapKeyringBuilder = ( } }, }); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as any; builder.type = SnapKeyring.type; return builder; diff --git a/app/scripts/lib/snap-keyring/utils/isBlockedUrl.test.ts b/app/scripts/lib/snap-keyring/utils/isBlockedUrl.test.ts index 839176dca5a1..03d949a814d1 100644 --- a/app/scripts/lib/snap-keyring/utils/isBlockedUrl.test.ts +++ b/app/scripts/lib/snap-keyring/utils/isBlockedUrl.test.ts @@ -36,6 +36,8 @@ describe('isBlockedUrl', () => { [1, true], [0, true], [-1, true], + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ])('"%s" is blocked: %s', async (url: any, expected: boolean) => { const result = await isBlockedUrl( url, diff --git a/app/scripts/lib/snap-keyring/utils/showResult.ts b/app/scripts/lib/snap-keyring/utils/showResult.ts index c0b4c530ed09..086f9fe07174 100644 --- a/app/scripts/lib/snap-keyring/utils/showResult.ts +++ b/app/scripts/lib/snap-keyring/utils/showResult.ts @@ -42,6 +42,8 @@ export const showError = ( controllerMessenger: SnapKeyringBuilderMessenger, snapId: string, opts: ResultComponentOptions, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any properties: Record, ): Promise => { return controllerMessenger.call('ApprovalController:showError', { @@ -70,6 +72,8 @@ export const showSuccess = ( controllerMessenger: SnapKeyringBuilderMessenger, snapId: string, opts: ResultComponentOptions, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any properties: Record, ): Promise => { return controllerMessenger.call('ApprovalController:showSuccess', { diff --git a/app/scripts/lib/transaction/metrics.test.ts b/app/scripts/lib/transaction/metrics.test.ts index a4eb13918d7d..9163feefb291 100644 --- a/app/scripts/lib/transaction/metrics.test.ts +++ b/app/scripts/lib/transaction/metrics.test.ts @@ -68,6 +68,8 @@ const mockTransactionMetricsRequest = { getTokenStandardAndDetails: jest.fn(), getTransaction: jest.fn(), provider: provider as Provider, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any snapAndHardwareMessenger: jest.fn() as any, trackEvent: jest.fn(), } as TransactionMetricsRequest; @@ -77,9 +79,17 @@ describe('Transaction metrics', () => { mockChainId, mockNetworkId, mockTransactionMeta: TransactionMeta, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any mockTransactionMetaWithBlockaid: any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any expectedProperties: any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any expectedSensitiveProperties: any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any mockActionId: any; beforeEach(() => { @@ -160,6 +170,8 @@ describe('Transaction metrics', () => { describe('handleTransactionAdded', () => { it('should return if transaction meta is not defined', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any await handleTransactionAdded(mockTransactionMetricsRequest, {} as any); expect( mockTransactionMetricsRequest.createEventFragment, @@ -168,6 +180,8 @@ describe('Transaction metrics', () => { it('should create event fragment', async () => { await handleTransactionAdded(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMeta as any, actionId: mockActionId, }); @@ -195,6 +209,8 @@ describe('Transaction metrics', () => { }; await handleTransactionAdded(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMeta as any, actionId: mockActionId, }); @@ -221,6 +237,8 @@ describe('Transaction metrics', () => { it('should create event fragment with blockaid', async () => { await handleTransactionAdded(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMetaWithBlockaid as any, actionId: mockActionId, }); @@ -251,6 +269,8 @@ describe('Transaction metrics', () => { describe('handleTransactionApproved', () => { it('should return if transaction meta is not defined', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any await handleTransactionApproved(mockTransactionMetricsRequest, {} as any); expect( mockTransactionMetricsRequest.createEventFragment, @@ -265,6 +285,8 @@ describe('Transaction metrics', () => { it('should create, update, finalize event fragment', async () => { await handleTransactionApproved(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMeta as any, actionId: mockActionId, }); @@ -306,6 +328,8 @@ describe('Transaction metrics', () => { it('should create, update, finalize event fragment with blockaid', async () => { await handleTransactionApproved(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMetaWithBlockaid as any, actionId: mockActionId, }); @@ -362,6 +386,8 @@ describe('Transaction metrics', () => { describe('handleTransactionFailed', () => { it('should return if transaction meta is not defined', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any await handleTransactionFailed(mockTransactionMetricsRequest, {} as any); expect( mockTransactionMetricsRequest.createEventFragment, @@ -386,6 +412,8 @@ describe('Transaction metrics', () => { transactionMeta: mockTransactionMeta, actionId: mockActionId, error: mockErrorMessage, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -440,6 +468,8 @@ describe('Transaction metrics', () => { transactionMeta: mockTransactionMetaWithBlockaid, actionId: mockActionId, error: mockErrorMessage, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -503,6 +533,8 @@ describe('Transaction metrics', () => { transactionMeta: mockTransactionMeta, actionId: mockActionId, error: mockErrorMessage, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -550,6 +582,8 @@ describe('Transaction metrics', () => { it('should return if transaction meta is not defined', async () => { await handleTransactionConfirmed( mockTransactionMetricsRequest, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any, ); expect( @@ -573,6 +607,8 @@ describe('Transaction metrics', () => { await handleTransactionConfirmed(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMeta, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -629,6 +665,8 @@ describe('Transaction metrics', () => { await handleTransactionConfirmed(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMetaWithBlockaid, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -692,6 +730,8 @@ describe('Transaction metrics', () => { describe('handleTransactionDropped', () => { it('should return if transaction meta is not defined', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any await handleTransactionDropped(mockTransactionMetricsRequest, {} as any); expect( mockTransactionMetricsRequest.createEventFragment, @@ -708,6 +748,8 @@ describe('Transaction metrics', () => { await handleTransactionDropped(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMeta, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -756,6 +798,8 @@ describe('Transaction metrics', () => { await handleTransactionDropped(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMetaWithBlockaid, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-submitted-1'; @@ -817,6 +861,8 @@ describe('Transaction metrics', () => { describe('handleTransactionRejected', () => { it('should return if transaction meta is not defined', async () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any await handleTransactionRejected(mockTransactionMetricsRequest, {} as any); expect( mockTransactionMetricsRequest.createEventFragment, @@ -833,6 +879,8 @@ describe('Transaction metrics', () => { await handleTransactionRejected(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMeta, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-added-1'; @@ -876,6 +924,8 @@ describe('Transaction metrics', () => { await handleTransactionRejected(mockTransactionMetricsRequest, { transactionMeta: mockTransactionMetaWithBlockaid, actionId: mockActionId, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any); const expectedUniqueId = 'transaction-added-1'; @@ -934,6 +984,8 @@ describe('Transaction metrics', () => { it('should return if transaction meta is not defined', async () => { await handleTransactionSubmitted( mockTransactionMetricsRequest, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any {} as any, ); expect( @@ -943,6 +995,8 @@ describe('Transaction metrics', () => { it('should only create event fragment', async () => { await handleTransactionSubmitted(mockTransactionMetricsRequest, { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transactionMeta: mockTransactionMeta as any, actionId: mockActionId, }); diff --git a/app/scripts/lib/transaction/metrics.ts b/app/scripts/lib/transaction/metrics.ts index ece6c5d62317..1d6ec97bc51e 100644 --- a/app/scripts/lib/transaction/metrics.ts +++ b/app/scripts/lib/transaction/metrics.ts @@ -69,6 +69,8 @@ export type TransactionMetricsRequest = { // According to the type GasFeeState returned from getEIP1559GasFeeEstimates // doesn't include some properties used in buildEventFragmentProperties, // hence returning any here to avoid type errors. + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getEIP1559GasFeeEstimates(options?: FetchGasFeeEstimateOptions): Promise; getParticipateInMetrics: () => boolean; getSelectedAddress: () => string; @@ -81,6 +83,8 @@ export type TransactionMetricsRequest = { getTransaction: (transactionId: string) => TransactionMeta; provider: Provider; snapAndHardwareMessenger: SnapAndHardwareMessenger; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any trackEvent: (payload: any) => void; }; @@ -161,6 +165,8 @@ export const handleTransactionFailed = async ( return; } + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const extraParams = {} as Record; if (transactionEventPayload.error) { // This is a failed transaction @@ -191,6 +197,8 @@ export const handleTransactionConfirmed = async ( return; } + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const extraParams = {} as Record; const { transactionMeta } = transactionEventPayload; const { txReceipt } = transactionMeta; @@ -484,6 +492,8 @@ function createTransactionEventFragment({ eventName: TransactionMetaMetricsEvent; transactionEventPayload: TransactionEventPayload; transactionMetricsRequest: TransactionMetricsRequest; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any payload: any; }) { if ( @@ -597,6 +607,8 @@ function updateTransactionEventFragment({ eventName: TransactionMetaMetricsEvent; transactionEventPayload: TransactionEventPayload; transactionMetricsRequest: TransactionMetricsRequest; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any payload: any; }) { const uniqueId = getUniqueId(eventName, transactionMeta.id); @@ -666,6 +678,8 @@ async function createUpdateFinalizeTransactionEventFragment({ eventName: TransactionMetaMetricsEvent; transactionEventPayload: TransactionEventPayload; transactionMetricsRequest: TransactionMetricsRequest; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any extraParams?: Record; }) { const { properties, sensitiveProperties } = @@ -703,6 +717,8 @@ async function createUpdateFinalizeTransactionEventFragment({ } function hasFragment( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getEventFragmentById: (arg0: string) => any, eventName: TransactionMetaMetricsEvent, transactionMeta: TransactionMeta, @@ -731,6 +747,8 @@ async function buildEventFragmentProperties({ transactionMetricsRequest, extraParams = {}, }: { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any extraParams?: Record; transactionEventPayload: TransactionEventPayload; transactionMetricsRequest: TransactionMetricsRequest; @@ -770,6 +788,8 @@ async function buildEventFragmentProperties({ transactionMetricsRequest.getTokenStandardAndDetails, ); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const gasParams = {} as Record; if (isEIP1559Transaction(transactionMeta)) { @@ -934,6 +954,8 @@ async function buildEventFragmentProperties({ } ///: BEGIN:ONLY_INCLUDE_IF(blockaid) + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const blockaidProperties: any = getBlockaidMetricsProps(transactionMeta); if (blockaidProperties?.ui_customizations?.length > 0) { @@ -971,6 +993,8 @@ async function buildEventFragmentProperties({ ///: END:ONLY_INCLUDE_IF // ui_customizations must come after ...blockaidProperties ui_customizations: uiCustomizations.length > 0 ? uiCustomizations : null, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as Record; const snapAndHardwareInfo = await getSnapAndHardwareInfoForMetrics( @@ -997,6 +1021,8 @@ async function buildEventFragmentProperties({ transaction_replaced: transactionReplaced, ...extraParams, ...gasParamsInGwei, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as Record; if (transactionContractMethod === contractMethodNames.APPROVE) { @@ -1012,7 +1038,11 @@ async function buildEventFragmentProperties({ return { properties, sensitiveProperties }; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function getGasValuesInGWEI(gasParams: Record) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const gasValuesInGwei = {} as Record; for (const param in gasParams) { if (isHexString(gasParams[param])) { diff --git a/app/scripts/lib/transaction/mmi-hooks.test.ts b/app/scripts/lib/transaction/mmi-hooks.test.ts index 210c3093ada8..fee5dff83de5 100644 --- a/app/scripts/lib/transaction/mmi-hooks.test.ts +++ b/app/scripts/lib/transaction/mmi-hooks.test.ts @@ -13,6 +13,8 @@ describe('MMI hooks', () => { const custodyIdMocked = '123'; describe('afterTransactionSign', () => { it('returns false if txMeta has no custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { to: toMocked } as any; const signedEthTx = {}; const result = afterTransactionSign(txMeta, signedEthTx, jest.fn()); @@ -24,6 +26,8 @@ describe('MMI hooks', () => { custodyStatus: TransactionStatus.approved, custodyId: custodyIdMocked, txParams: { from: fromMocked }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; const signedEthTx = { custodian_transactionId: custodyIdMocked, @@ -47,12 +51,16 @@ describe('MMI hooks', () => { describe('beforeTransactionPublish', () => { it('returns true if txMeta has custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { custodyStatus: TransactionStatus.approved } as any; const result = beforeTransactionPublish(txMeta); expect(result).toBe(false); }); it('returns false if txMeta has no custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { to: toMocked } as any; const result = beforeTransactionPublish(txMeta); expect(result).toBe(true); @@ -61,12 +69,16 @@ describe('MMI hooks', () => { describe('getAdditionalSignArguments', () => { it('returns an array with txMeta when custodyStatus is truthy', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { custodyStatus: TransactionStatus.approved } as any; const result = getAdditionalSignArguments(txMeta); expect(result).toEqual([txMeta]); }); it('returns an empty array when custodyStatus is falsy', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { to: toMocked } as any; const result = getAdditionalSignArguments(txMeta); expect(result).toEqual([]); @@ -75,12 +87,16 @@ describe('MMI hooks', () => { describe('beforeTransactionApproveOnInit', () => { it('returns true if txMeta has custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { custodyStatus: TransactionStatus.approved } as any; const result = beforeTransactionApproveOnInit(txMeta); expect(result).toBe(false); }); it('returns false if txMeta has no custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { to: toMocked } as any; const result = beforeTransactionApproveOnInit(txMeta); expect(result).toBe(true); @@ -92,12 +108,16 @@ describe('MMI hooks', () => { const txMeta = { custodyStatus: TransactionStatus.approved, custodyId: 1, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; const result = beforeCheckPendingTransaction(txMeta); expect(result).toBe(false); }); it('returns false if txMeta has no custodyStatus', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const txMeta = { to: toMocked } as any; const result = beforeCheckPendingTransaction(txMeta); expect(result).toBe(true); diff --git a/app/scripts/lib/transaction/mmi-hooks.ts b/app/scripts/lib/transaction/mmi-hooks.ts index 92ea0cf792b9..d4dc3cc4dcda 100644 --- a/app/scripts/lib/transaction/mmi-hooks.ts +++ b/app/scripts/lib/transaction/mmi-hooks.ts @@ -9,6 +9,8 @@ import { TransactionMeta } from '@metamask/transaction-controller'; */ export function afterTransactionSign( txMeta: TransactionMeta, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any signedEthTx: any, addTransactionToWatchList: ( custodianTransactionId: string | undefined, diff --git a/app/scripts/lib/transaction/util.test.ts b/app/scripts/lib/transaction/util.test.ts index b69fec9ae959..9b31caff37e0 100644 --- a/app/scripts/lib/transaction/util.test.ts +++ b/app/scripts/lib/transaction/util.test.ts @@ -515,6 +515,8 @@ describe('Transaction Utils', () => { request.securityAlertsEnabled = true; request.chainId = '0x1'; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any request.ppomController.usePPOM = (callback: any) => callback(ppomMock); await addTransaction(request); diff --git a/app/scripts/lib/transaction/util.ts b/app/scripts/lib/transaction/util.ts index 34350d114d63..1781dd19a416 100644 --- a/app/scripts/lib/transaction/util.ts +++ b/app/scripts/lib/transaction/util.ts @@ -80,6 +80,8 @@ export type AddTransactionRequest = FinalAddTransactionRequest & { }; export type AddDappTransactionRequest = BaseAddTransactionRequest & { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any dappRequest: Record; }; @@ -272,6 +274,8 @@ async function addUserOperationWithController( } = request; const { maxFeePerGas, maxPriorityFeePerGas } = transactionParams; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { origin, requireApproval, type } = transactionOptions as any; const normalisedTransaction: TransactionParams = { diff --git a/app/scripts/lib/util.ts b/app/scripts/lib/util.ts index 77c2e8543b64..c523f6c03bbd 100644 --- a/app/scripts/lib/util.ts +++ b/app/scripts/lib/util.ts @@ -181,6 +181,8 @@ export const isValidDate = (d: Date | number) => { */ type DeferredPromise = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any promise: Promise; resolve?: () => void; reject?: () => void; diff --git a/app/scripts/migrations/081.ts b/app/scripts/migrations/081.ts index 0162a43b6e49..aa7e48a8c9fa 100644 --- a/app/scripts/migrations/081.ts +++ b/app/scripts/migrations/081.ts @@ -91,7 +91,7 @@ function transformState(state: Record) { // Adding the snap name to the wallet_snap permission's caveat value const snapId = permissionName.slice(snapPrefix.length); const caveat = ( - (updatedPermissions.wallet_snap as Record) + (updatedPermissions.wallet_snap as Record) .caveats as unknown[] )[0]; diff --git a/app/scripts/migrations/095.ts b/app/scripts/migrations/095.ts index 39128284e03f..6361bba388fc 100644 --- a/app/scripts/migrations/095.ts +++ b/app/scripts/migrations/095.ts @@ -35,7 +35,11 @@ function migrateData(state: Record): void { removeIncomingTransactionsControllerState(state); } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function moveIncomingTransactions(state: Record) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const incomingTransactions: Record = state.IncomingTransactionsController?.incomingTransactions || {}; @@ -46,6 +50,8 @@ function moveIncomingTransactions(state: Record) { const transactions = state.TransactionController?.transactions || {}; const updatedTransactions = Object.values(incomingTransactions).reduce( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (result: Record, tx: any) => { result[tx.id] = tx; return result; @@ -59,7 +65,11 @@ function moveIncomingTransactions(state: Record) { }; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function generateLastFetchedBlockNumbers(state: Record) { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const incomingTransactions: Record = state.IncomingTransactionsController?.incomingTransactions || {}; diff --git a/app/scripts/migrations/096.ts b/app/scripts/migrations/096.ts index 749956a726b2..b04b7613e008 100644 --- a/app/scripts/migrations/096.ts +++ b/app/scripts/migrations/096.ts @@ -4,6 +4,8 @@ import { CHAIN_IDS } from '../../../shared/constants/network'; type VersionedData = { meta: { version: number }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any data: Record; }; @@ -34,6 +36,8 @@ export async function migrate( } type NetworkConfiguration = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any chainId: Record; }; @@ -48,10 +52,18 @@ function transformState(state: Record) { return state; } const { PreferencesController, NetworkController } = state; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { featureFlags }: Record = PreferencesController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { showIncomingTransactions }: any = featureFlags; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { networkConfigurations }: Record = NetworkController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const addedNetwork: Record[] = Object.values(networkConfigurations).map( (network) => network.chainId, @@ -63,6 +75,8 @@ function transformState(state: Record) { CHAIN_IDS.SEPOLIA, CHAIN_IDS.LINEA_GOERLI, ]; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const allSavedNetworks: Record = [ ...mainNetworks, ...addedNetwork, diff --git a/app/scripts/migrations/097.ts b/app/scripts/migrations/097.ts index 9e99cf61b40a..56a11679449d 100644 --- a/app/scripts/migrations/097.ts +++ b/app/scripts/migrations/097.ts @@ -21,6 +21,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const transactionControllerState = state?.TransactionController || {}; const transactions = transactionControllerState?.transactions || {}; diff --git a/app/scripts/migrations/098.ts b/app/scripts/migrations/098.ts index 3085827b4c6a..2fe77148e052 100644 --- a/app/scripts/migrations/098.ts +++ b/app/scripts/migrations/098.ts @@ -25,6 +25,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const transactionControllerState = state?.TransactionController || {}; const transactions = transactionControllerState?.transactions || {}; diff --git a/app/scripts/migrations/099.test.ts b/app/scripts/migrations/099.test.ts index 1feba98e6fa3..3b98f4f72a26 100644 --- a/app/scripts/migrations/099.test.ts +++ b/app/scripts/migrations/099.test.ts @@ -72,6 +72,8 @@ describe('migration #99', () => { const newStorage = await migrate(oldStorage); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const migratedTransactions = (newStorage.data.TransactionController as any) .transactions; diff --git a/app/scripts/migrations/099.ts b/app/scripts/migrations/099.ts index 9464d19a64df..38018c97919d 100644 --- a/app/scripts/migrations/099.ts +++ b/app/scripts/migrations/099.ts @@ -24,6 +24,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const transactionControllerState = state?.TransactionController || {}; const transactions = transactionControllerState?.transactions || {}; @@ -33,6 +35,8 @@ function transformState(state: Record) { } const newTxs = Object.keys(transactions).reduce( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (txs: { [key: string]: any }, oldTransactionId) => { // Clone the transaction const transaction = cloneDeep(transactions[oldTransactionId]); diff --git a/app/scripts/migrations/100.ts b/app/scripts/migrations/100.ts index c9b4a99afceb..89dbe0d5670d 100644 --- a/app/scripts/migrations/100.ts +++ b/app/scripts/migrations/100.ts @@ -25,6 +25,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const addressBook = state?.AddressBookController?.addressBook ?? {}; const names = state?.NameController?.names?.ethereumAddress ?? {}; diff --git a/app/scripts/migrations/102.ts b/app/scripts/migrations/102.ts index 820e67605251..a1fde4f27f7f 100644 --- a/app/scripts/migrations/102.ts +++ b/app/scripts/migrations/102.ts @@ -23,6 +23,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const transactionControllerState = state?.TransactionController || {}; const transactions = transactionControllerState?.transactions || {}; @@ -32,6 +34,8 @@ function transformState(state: Record) { } const newTxs = Object.keys(transactions).reduce( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (txs: { [key: string]: any }, txId) => { // Clone the transaction const transaction = cloneDeep(transactions[txId]); diff --git a/app/scripts/migrations/104.ts b/app/scripts/migrations/104.ts index 340d167ccd5f..38ab3c0f57c8 100644 --- a/app/scripts/migrations/104.ts +++ b/app/scripts/migrations/104.ts @@ -22,6 +22,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const transactionControllerState = state?.TransactionController; @@ -32,6 +34,8 @@ function transformState(state: Record) { const transactionsObject = transactionControllerState?.transactions || {}; const transactionsArray = Object.values(transactionsObject).sort( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (a: any, b: any) => (a.time > b.time ? -1 : 1), // Descending ); diff --git a/app/scripts/migrations/105.ts b/app/scripts/migrations/105.ts index 10be55e69e0a..482bc5a73d15 100644 --- a/app/scripts/migrations/105.ts +++ b/app/scripts/migrations/105.ts @@ -48,6 +48,8 @@ function migrateData(state: Record): void { createSelectedAccountForAccountsController(state); } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function createDefaultAccountsController(state: Record) { state.AccountsController = { internalAccounts: { @@ -58,6 +60,8 @@ function createDefaultAccountsController(state: Record) { } function createInternalAccountsForAccountsController( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any state: Record, ) { const identities: { @@ -98,6 +102,8 @@ function createInternalAccountsForAccountsController( } function createSelectedAccountForAccountsController( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any state: Record, ) { const selectedAddress = state.PreferencesController?.selectedAddress; diff --git a/app/scripts/migrations/108.ts b/app/scripts/migrations/108.ts index 1ea75957b73a..4b12de5f9004 100644 --- a/app/scripts/migrations/108.ts +++ b/app/scripts/migrations/108.ts @@ -27,6 +27,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const addressBook = state?.AddressBookController?.addressBook ?? {}; const names = state?.NameController?.names?.ethereumAddress ?? {}; diff --git a/app/scripts/migrations/109.ts b/app/scripts/migrations/109.ts index 5c40b07d4b09..13e268b8e061 100644 --- a/app/scripts/migrations/109.ts +++ b/app/scripts/migrations/109.ts @@ -27,6 +27,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const identities: PreferencesControllerState['identities'] = state?.PreferencesController?.identities ?? {}; diff --git a/app/scripts/migrations/110.ts b/app/scripts/migrations/110.ts index bc941ac87695..7a677ed8b9cd 100644 --- a/app/scripts/migrations/110.ts +++ b/app/scripts/migrations/110.ts @@ -35,6 +35,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { const NetworkController = state?.NetworkController || {}; const provider = NetworkController?.providerConfig || {}; diff --git a/app/scripts/migrations/111.ts b/app/scripts/migrations/111.ts index a45c24fa168f..1a06e655cabb 100644 --- a/app/scripts/migrations/111.ts +++ b/app/scripts/migrations/111.ts @@ -28,6 +28,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { if (!hasProperty(state, 'SelectedNetworkController')) { return state; diff --git a/app/scripts/migrations/112.ts b/app/scripts/migrations/112.ts index 6313462be199..519be68c9ca3 100644 --- a/app/scripts/migrations/112.ts +++ b/app/scripts/migrations/112.ts @@ -26,6 +26,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { if (!hasProperty(state, 'SelectedNetworkController')) { return state; diff --git a/app/scripts/migrations/114.ts b/app/scripts/migrations/114.ts index 2288dc84d612..bed9c70a8850 100644 --- a/app/scripts/migrations/114.ts +++ b/app/scripts/migrations/114.ts @@ -26,6 +26,8 @@ export async function migrate( return versionedData; } +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any function transformState(state: Record) { if (!hasProperty(state, 'PreferencesController')) { return state; diff --git a/development/lib/build-type.d.ts b/development/lib/build-type.d.ts index dafc9e904764..7b23f19f27a6 100644 --- a/development/lib/build-type.d.ts +++ b/development/lib/build-type.d.ts @@ -1,5 +1,7 @@ import { Infer, Struct } from 'superstruct'; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type Unique> = ( struct: Struct[], Infer>, eq?: (a: Infer, b: Infer) => boolean, diff --git a/offscreen/scripts/callback-processor.ts b/offscreen/scripts/callback-processor.ts index 83b062811173..36fa3ae9f9c4 100644 --- a/offscreen/scripts/callback-processor.ts +++ b/offscreen/scripts/callback-processor.ts @@ -11,8 +11,12 @@ export class CallbackProcessor { currentMessageId = 0; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any messageCallbacks = new Map void>(); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any registerCallback(callback: (response?: any) => void) { this.currentMessageId += 1; this.messageCallbacks.set(this.currentMessageId, callback); diff --git a/offscreen/scripts/ledger.ts b/offscreen/scripts/ledger.ts index 6ed42b0dc858..89a317d8e811 100644 --- a/offscreen/scripts/ledger.ts +++ b/offscreen/scripts/ledger.ts @@ -50,6 +50,8 @@ export default function init() { msg: { target: string; action: LedgerAction; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any params: any; }, _sender, diff --git a/offscreen/scripts/trezor.ts b/offscreen/scripts/trezor.ts index 34274be8652c..e9482a03c575 100644 --- a/offscreen/scripts/trezor.ts +++ b/offscreen/scripts/trezor.ts @@ -18,6 +18,8 @@ export default function init() { msg: { target: string; action: TrezorAction; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any params: any; }, _sender, diff --git a/shared/constants/mmi-controller.ts b/shared/constants/mmi-controller.ts index 779c1aa99368..208a5a18a93a 100644 --- a/shared/constants/mmi-controller.ts +++ b/shared/constants/mmi-controller.ts @@ -11,30 +11,50 @@ import MetaMetricsController from '../../app/scripts/controllers/metametrics'; export type MMIControllerOptions = { mmiConfigurationController: MmiConfigurationController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any keyringController: any; preferencesController: PreferencesController; appStateController: AppStateController; transactionUpdateController: TransactionUpdateController; custodyController: CustodyController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any messenger: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getState: () => any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getPendingNonce: (address: string) => Promise; accountTracker: AccountTracker; metaMetricsController: MetaMetricsController; networkController: NetworkController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any permissionController: any; signatureController: SignatureController; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any platform: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any extension: any; updateTransactionHash: (txId: string, txHash: string) => void; trackTransactionEvents: ( args: { transactionMeta: TransactionMeta }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any event: any, ) => void; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any getTransactions: (query?: any, opts?: any, fullTx?: boolean) => any[]; setTxStatusSigned: (txId: string) => void; setTxStatusSubmitted: (txId: string) => void; setTxStatusFailed: (txId: string) => void; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any updateTransaction: (txMeta: any) => void; }; diff --git a/shared/lib/fetch-with-cache.ts b/shared/lib/fetch-with-cache.ts index 8a84ad76f8c4..598dd566b7d9 100644 --- a/shared/lib/fetch-with-cache.ts +++ b/shared/lib/fetch-with-cache.ts @@ -9,7 +9,11 @@ const fetchWithCache = async ({ functionName = '', }: { url: string; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any fetchOptions?: Record; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any cacheOptions?: Record; functionName: string; }) => { diff --git a/shared/lib/token-util.ts b/shared/lib/token-util.ts index 4f8e6b15b9df..18591b550ec7 100644 --- a/shared/lib/token-util.ts +++ b/shared/lib/token-util.ts @@ -17,6 +17,8 @@ import { Web3Provider } from '@ethersproject/providers'; * @param tokenData - ethers Interface token data. * @returns A decimal string value. */ +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function getTokenIdParam(tokenData: any = {}): string | undefined { return ( tokenData?.args?._tokenId?.toString() ?? tokenData?.args?.id?.toString() @@ -26,7 +28,11 @@ export function getTokenIdParam(tokenData: any = {}): string | undefined { export async function fetchTokenBalance( address: string, userAddress: string, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any provider: any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise { const ethersProvider = new Web3Provider(provider); const tokenContract = new Contract(address, abiERC20, ethersProvider); @@ -40,7 +46,11 @@ export async function fetchERC1155Balance( address: string, userAddress: string, tokenId: string, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any provider: any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise { if (!userAddress || !tokenId) { return null; diff --git a/shared/modules/i18n.test.ts b/shared/modules/i18n.test.ts index 3353e4732e64..7a52137b7dc8 100644 --- a/shared/modules/i18n.test.ts +++ b/shared/modules/i18n.test.ts @@ -307,6 +307,8 @@ describe('I18N Module', () => { RelativeTimeFormat: { __addLocaleData: addMock, }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; await loadRelativeTimeFormatLocaleData(`${localeCodeMock}_test`); @@ -324,6 +326,8 @@ describe('I18N Module', () => { RelativeTimeFormat: { __addLocaleData: addMock, }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; await loadRelativeTimeFormatLocaleData(`${localeCodeMock}_test`); diff --git a/shared/modules/i18n.ts b/shared/modules/i18n.ts index 84c433c58d8e..790d9da25313 100644 --- a/shared/modules/i18n.ts +++ b/shared/modules/i18n.ts @@ -20,6 +20,8 @@ export type I18NMessageDict = { [translationKey: string]: I18NMessage; }; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type I18NSubstitution = string | (() => any) | object; // A parameterized type (or generic type) of maps that use the same structure (translationKey) key @@ -104,10 +106,14 @@ export async function loadRelativeTimeFormatLocaleData( const languageTag = localeCode.split('_')[0]; if ( Intl.RelativeTimeFormat && + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any typeof (Intl.RelativeTimeFormat as any).__addLocaleData === 'function' && !relativeTimeFormatLocaleData.has(languageTag) ) { const localeData = await fetchRelativeTimeFormatData(languageTag); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (Intl.RelativeTimeFormat as any).__addLocaleData(localeData); relativeTimeFormatLocaleData.add(languageTag); } diff --git a/types/global.d.ts b/types/global.d.ts index 7a76ed7e1dd4..20311bb5f6c3 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -68,6 +68,8 @@ type sendMessage = { callback?: (response: Record) => void, ): void; ( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any message: any, options?: Record, callback?: (response: Record) => void, @@ -190,6 +192,8 @@ type sendMessage = { url: string; }; }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any callback: (response: { result: any; error?: Error }) => void, ); ( @@ -202,6 +206,8 @@ declare class Runtime { onMessage: { addListener: ( callback: ( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any message: any, sender: MessageSender, sendResponse: (response?: ResponseType) => void, diff --git a/types/react-tippy.d.ts b/types/react-tippy.d.ts index d03844e5c848..80ac4fa04073 100644 --- a/types/react-tippy.d.ts +++ b/types/react-tippy.d.ts @@ -47,7 +47,11 @@ declare module 'react-tippy' { followCursor?: boolean; inertia?: boolean; transitionFlip?: boolean; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any popperOptions?: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any html?: React.ReactElement; unmountHTMLWhenHide?: boolean; size?: Size; diff --git a/ui/components/app/confirm/info/info.test.tsx b/ui/components/app/confirm/info/info.test.tsx index a5af2548d1c9..113d964fd1f6 100644 --- a/ui/components/app/confirm/info/info.test.tsx +++ b/ui/components/app/confirm/info/info.test.tsx @@ -26,6 +26,8 @@ const mockRowConfigs: ConfirmInfoRowConfig[] = [ ]; describe('ConfirmInfo', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const render = (storeOverrides: Record = {}) => { const store = configureStore({ ...mockState.metamask, diff --git a/ui/components/app/confirm/info/info.tsx b/ui/components/app/confirm/info/info.tsx index 8c1c386de0c4..9edd0a22ec49 100644 --- a/ui/components/app/confirm/info/info.tsx +++ b/ui/components/app/confirm/info/info.tsx @@ -38,6 +38,8 @@ type ConfirmInfoTypeProps = | ConfirmInfoRowUrlProps | ConfirmInfoRowValueDoubleProps; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any const TYPE_TO_COMPONENT: Record = { [ConfirmInfoRowType.Address]: ({ address }: ConfirmInfoRowAddressProps) => { return ; diff --git a/ui/components/app/confirm/info/row/address.test.tsx b/ui/components/app/confirm/info/row/address.test.tsx index 5206c1b61ce2..4415541e02b5 100644 --- a/ui/components/app/confirm/info/row/address.test.tsx +++ b/ui/components/app/confirm/info/row/address.test.tsx @@ -8,6 +8,8 @@ import { ConfirmInfoRowAddress } from './address'; import { TEST_ADDRESS } from './constants'; const render = ( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any storeOverrides: Record = {}, address: string = TEST_ADDRESS, ) => { diff --git a/ui/components/app/confirm/info/row/currency.test.tsx b/ui/components/app/confirm/info/row/currency.test.tsx index ab1011ac178c..96db80ac989e 100644 --- a/ui/components/app/confirm/info/row/currency.test.tsx +++ b/ui/components/app/confirm/info/row/currency.test.tsx @@ -6,6 +6,8 @@ import configureStore from '../../../../../store/store'; import { ConfirmInfoRowCurrency } from './currency'; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any const render = (props: Record = {}) => { const store = configureStore({ metamask: { diff --git a/ui/components/app/currency-input/hooks/useTokenExchangeRate.test.tsx b/ui/components/app/currency-input/hooks/useTokenExchangeRate.test.tsx index f6c933797eae..22c0ddbd3011 100644 --- a/ui/components/app/currency-input/hooks/useTokenExchangeRate.test.tsx +++ b/ui/components/app/currency-input/hooks/useTokenExchangeRate.test.tsx @@ -25,6 +25,8 @@ const renderUseTokenExchangeRate = (tokenAddress?: string) => { }, }; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const wrapper = ({ children }: any) => ( {children} ); diff --git a/ui/components/app/incoming-trasaction-toggle/incoming-transaction-toggle.tsx b/ui/components/app/incoming-trasaction-toggle/incoming-transaction-toggle.tsx index c00defb09fae..3b44a56b262f 100644 --- a/ui/components/app/incoming-trasaction-toggle/incoming-transaction-toggle.tsx +++ b/ui/components/app/incoming-trasaction-toggle/incoming-transaction-toggle.tsx @@ -14,8 +14,12 @@ import { TEST_CHAINS } from '../../../../shared/constants/network'; import NetworkToggle from './network-toggle'; type IncomingTransactionToggleProps = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any wrapperRef?: PolymorphicRef; incomingTransactionsPreferences: Record; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any allNetworks: Record[]; setIncomingTransactionsPreferences: ( chainId: string, @@ -82,8 +86,14 @@ IncomingTransactionToggle.propTypes = { function generateIncomingNetworkPreferences( incomingTransactionsPreferences: Record, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any allNetworks: Record, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Record { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const incomingTxnPreferences: Record = {}; Object.keys(allNetworks).forEach((id) => { diff --git a/ui/components/app/modals/transaction-already-confirmed/transaction-already-confirmed.tsx b/ui/components/app/modals/transaction-already-confirmed/transaction-already-confirmed.tsx index 25605ddcdf71..1bd2afc75926 100644 --- a/ui/components/app/modals/transaction-already-confirmed/transaction-already-confirmed.tsx +++ b/ui/components/app/modals/transaction-already-confirmed/transaction-already-confirmed.tsx @@ -34,6 +34,8 @@ export default function TransactionAlreadyConfirmed() { const dispatch = useDispatch(); const transaction: TransactionMeta = useSelector( (state: MetaMaskReduxState) => + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (getTransaction as any)(state, originalTransactionId), ); const rpcPrefs: NetworkClientConfiguration = useSelector( @@ -43,7 +45,11 @@ export default function TransactionAlreadyConfirmed() { const viewTransaction = () => { // TODO: Fix getBlockExplorerLink arguments compatible with the actual controller types const blockExplorerLink = getBlockExplorerLink( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any transaction as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any rpcPrefs as any, ); global.platform.openTab({ diff --git a/ui/components/app/name/name-details/metrics.ts b/ui/components/app/name/name-details/metrics.ts index f6f28a337dff..fe539c1a5052 100644 --- a/ui/components/app/name/name-details/metrics.ts +++ b/ui/components/app/name/name-details/metrics.ts @@ -29,12 +29,18 @@ export function usePetnamesMetrics({ const trackPetnamesEvent = useCallback( ( event: MetaMetricsEventName, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any additionalProperties: Record = {}, ) => { const suggestedNameSources = [ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ...new Set(proposedNameOptions.map((option: any) => option.sourceId)), ]; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const properties: Record = { petname_category: type, suggested_names_sources: suggestedNameSources, @@ -57,6 +63,8 @@ export function usePetnamesMetrics({ const isCreated = !savedName?.length && name?.length; let event: MetaMetricsEventName | null = null; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any let additionalProperties: Record = {}; if (isDeleted) { diff --git a/ui/components/app/name/name-details/name-details.tsx b/ui/components/app/name/name-details/name-details.tsx index 25ec7f5ed407..bebfaa855675 100644 --- a/ui/components/app/name/name-details/name-details.tsx +++ b/ui/components/app/name/name-details/name-details.tsx @@ -156,6 +156,8 @@ function getInitialSources( function useProposedNames(value: string, type: NameType, chainId: string) { const dispatch = useDispatch(); const { proposedNames } = useName(value, type); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const updateInterval = useRef(); const [initialSources, setInitialSources] = useState(); @@ -174,6 +176,8 @@ function useProposedNames(value: string, type: NameType, chainId: string) { onlyUpdateAfterDelay: true, variation: chainId, }), + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any )) as any as UpdateProposedNamesResult; if (!initialSources) { diff --git a/ui/components/app/snaps/keyring-snap-removal-warning/keyring-snap-removal-warning.test.tsx b/ui/components/app/snaps/keyring-snap-removal-warning/keyring-snap-removal-warning.test.tsx index df696916274a..c89a8f28b280 100644 --- a/ui/components/app/snaps/keyring-snap-removal-warning/keyring-snap-removal-warning.test.tsx +++ b/ui/components/app/snaps/keyring-snap-removal-warning/keyring-snap-removal-warning.test.tsx @@ -40,6 +40,8 @@ const defaultArgs = { }; describe('Keyring Snap Remove Warning', () => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any let store: any; beforeAll(() => { store = configureMockStore()(mockStore); diff --git a/ui/components/app/snaps/snap-ui-renderer/utils.ts b/ui/components/app/snaps/snap-ui-renderer/utils.ts index 7e7d287efdd5..aef8873f09bc 100644 --- a/ui/components/app/snaps/snap-ui-renderer/utils.ts +++ b/ui/components/app/snaps/snap-ui-renderer/utils.ts @@ -57,6 +57,8 @@ export const mapToTemplate = (params: MapToTemplateParams) => { const { type } = params.element; const indexKey = generateKey(params.map, params.element); // @ts-expect-error This seems to be compatibility issue between superstruct and this repo. + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const mapped = COMPONENT_MAPPING[type](params as any); return { ...mapped, key: indexKey }; }; diff --git a/ui/components/app/srp-quiz-modal/QuizContent/QuizContent.tsx b/ui/components/app/srp-quiz-modal/QuizContent/QuizContent.tsx index c3f7ea1d2353..86f29680fa7d 100644 --- a/ui/components/app/srp-quiz-modal/QuizContent/QuizContent.tsx +++ b/ui/components/app/srp-quiz-modal/QuizContent/QuizContent.tsx @@ -60,6 +60,8 @@ export default function QuizContent({ key={idx} size={btn.size} onClick={btn.onClick} + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any variant={btn.variant as any} width={BlockSize.Full} data-testid={btn['data-testid']} diff --git a/ui/components/app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx b/ui/components/app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx index abcd2c1281bb..860a24b70052 100644 --- a/ui/components/app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx +++ b/ui/components/app/srp-quiz-modal/SRPQuiz/SRPQuiz.tsx @@ -57,6 +57,8 @@ const openSupportArticle = (): void => { }); }; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any export default function SRPQuiz(props: any) { const [stage, setStage] = useState(QuizStage.introduction); diff --git a/ui/components/app/srp-quiz-modal/types.ts b/ui/components/app/srp-quiz-modal/types.ts index c94526dee966..d8a304f74f0d 100644 --- a/ui/components/app/srp-quiz-modal/types.ts +++ b/ui/components/app/srp-quiz-modal/types.ts @@ -14,6 +14,8 @@ export type IQuizInformationProps = { /** * The icon to display in the modal should use component */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any icon?: any; /** * The image to display in the modal diff --git a/ui/components/component-library/box/box.test.tsx b/ui/components/component-library/box/box.test.tsx index 95774579fce7..7aa9125979df 100644 --- a/ui/components/component-library/box/box.test.tsx +++ b/ui/components/component-library/box/box.test.tsx @@ -2062,6 +2062,8 @@ describe('Box', () => { 1 item 2 items 3 items + {/* TODO: Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} too many items , ); diff --git a/ui/components/component-library/box/box.types.ts b/ui/components/component-library/box/box.types.ts index 1999409ee2b2..50090859171c 100644 --- a/ui/components/component-library/box/box.types.ts +++ b/ui/components/component-library/box/box.types.ts @@ -84,6 +84,8 @@ export type StylePropValueType = | undefined; export type ClassNamesObject = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; }; diff --git a/ui/components/component-library/checkbox/checkbox.types.ts b/ui/components/component-library/checkbox/checkbox.types.ts index 451db8027044..a2765a7ba39e 100644 --- a/ui/components/component-library/checkbox/checkbox.types.ts +++ b/ui/components/component-library/checkbox/checkbox.types.ts @@ -51,10 +51,14 @@ export interface CheckboxStyleUtilityProps extends StyleUtilityProps { /* * label is the string or ReactNode to be rendered next to the Checkbox */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any label?: any; /* * Use inputProps for additional props to be spread to the checkbox input element */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any inputProps?: any; // TODO: Replace with Box types when the syntax and typing is properly figured out. Needs to accept everything Box accepts /* * Use inputRef to pass a ref to the html input element diff --git a/ui/components/component-library/form-text-field/form-text-field.tsx b/ui/components/component-library/form-text-field/form-text-field.tsx index af7225cce981..9ee7b534a179 100644 --- a/ui/components/component-library/form-text-field/form-text-field.tsx +++ b/ui/components/component-library/form-text-field/form-text-field.tsx @@ -70,6 +70,8 @@ export const FormTextField: FormTextFieldComponent = React.forwardRef( display={Display.Flex} flexDirection={FlexDirection.Column} ref={ref} + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any {...(props as BoxProps)} > {label && ( diff --git a/ui/components/component-library/modal-content/modal-content.types.ts b/ui/components/component-library/modal-content/modal-content.types.ts index f59faf351c8d..cf8a77ce6fac 100644 --- a/ui/components/component-library/modal-content/modal-content.types.ts +++ b/ui/components/component-library/modal-content/modal-content.types.ts @@ -43,6 +43,8 @@ export interface ModalContentStyleUtilityProps extends StyleUtilityProps { /** * Additional props to pass to the dialog node inside of ModalContent component */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any modalDialogProps?: any; } diff --git a/ui/components/component-library/modal-focus/modal-focus.tsx b/ui/components/component-library/modal-focus/modal-focus.tsx index f8152d527435..d310d4701064 100644 --- a/ui/components/component-library/modal-focus/modal-focus.tsx +++ b/ui/components/component-library/modal-focus/modal-focus.tsx @@ -8,6 +8,8 @@ import type { ModalFocusProps } from './modal-focus.types'; */ const FocusTrap: typeof ReactFocusLock = + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (ReactFocusLock as any).default ?? ReactFocusLock; export const ModalFocus: React.FC = ({ diff --git a/ui/components/component-library/select-button/select-button.types.ts b/ui/components/component-library/select-button/select-button.types.ts index fdca7dbcd1ae..401544521a4f 100644 --- a/ui/components/component-library/select-button/select-button.types.ts +++ b/ui/components/component-library/select-button/select-button.types.ts @@ -34,6 +34,8 @@ export interface SelectButtonStyleUtilityProps extends StyleUtilityProps { * endAccessory: , * } */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any placeholder?: any; /* * Value for `SelectButton` component @@ -45,6 +47,8 @@ export interface SelectButtonStyleUtilityProps extends StyleUtilityProps { * endAccessory: , * } */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any value?: any; /* * DefaultValue for SelectButton component @@ -56,6 +60,8 @@ export interface SelectButtonStyleUtilityProps extends StyleUtilityProps { * endAccessory: , * } */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any defaultValue?: any; /* * isBlock boolean prop for SelectButton component to set display to block diff --git a/ui/components/component-library/select-option/select-option.types.ts b/ui/components/component-library/select-option/select-option.types.ts index a56aeda06e72..14b367e060a1 100644 --- a/ui/components/component-library/select-option/select-option.types.ts +++ b/ui/components/component-library/select-option/select-option.types.ts @@ -13,10 +13,14 @@ export interface SelectOptionStyleUtilityProps extends StyleUtilityProps { /* * Children of the SelectOption component */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any children?: any; /* * The value of the SelectOption component */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any value?: any; } diff --git a/ui/components/component-library/select-wrapper/select-wrapper.tsx b/ui/components/component-library/select-wrapper/select-wrapper.tsx index 1eae68f18b5f..054cdd032c69 100644 --- a/ui/components/component-library/select-wrapper/select-wrapper.tsx +++ b/ui/components/component-library/select-wrapper/select-wrapper.tsx @@ -29,6 +29,8 @@ export const SelectWrapper: SelectWrapperComponent = React.forwardRef( }: SelectWrapperProps, ref?: PolymorphicRef, ) => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const [uncontrolledValue, setUncontrolledValue] = useState(); const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(false); diff --git a/ui/components/component-library/select-wrapper/select-wrapper.types.ts b/ui/components/component-library/select-wrapper/select-wrapper.types.ts index 572b8192285e..eb6e0fb53b30 100644 --- a/ui/components/component-library/select-wrapper/select-wrapper.types.ts +++ b/ui/components/component-library/select-wrapper/select-wrapper.types.ts @@ -8,16 +8,30 @@ export type SelectContextType = { isOpen: boolean | undefined; onOpenChange: React.Dispatch>; isUncontrolledOpen: boolean; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any setIsUncontrolledOpen: React.Dispatch>; toggleUncontrolledOpen: () => void; isDanger?: boolean; isDisabled?: boolean; isMultiSelect?: boolean; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any value: any | null; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any onValueChange?: any; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any uncontrolledValue: any | null; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any setUncontrolledValue: React.Dispatch>; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any defaultValue: any | null; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any placeholder: any; }; @@ -36,21 +50,29 @@ export interface SelectWrapperStyleUtilityProps extends StyleUtilityProps { * Placeholder for SelectWrapper component to be displayed when no value or defaultValue is set. * Can be accessed within any component inside the SelectWrapper. */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any placeholder?: any; /** * Selected value of SelectWrapper component. * Can be accessed within any component inside the SelectWrapper. */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any value?: any; /** * Default value of SelectWrapper component. * Can be accessed within any component inside the SelectWrapper. */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any defaultValue?: any; /** * Callback function that is called when the value of the SelectWrapper component changes. * The new value is passed as an argument to the function. */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any onValueChange?: (newValue: any) => void; /** * isOpen boolean determines whether the SelectWrapper popover is open or closed. @@ -67,6 +89,8 @@ export interface SelectWrapperStyleUtilityProps extends StyleUtilityProps { /** * onOpenChange callback function is called when the SelectWrapper popover is opened or closed. */ + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any onOpenChange?: any; // TO DO: confirm type /** * Callback function that is called when the SelectWrapper component loses focus. @@ -78,7 +102,11 @@ export interface SelectWrapperStyleUtilityProps extends StyleUtilityProps { * SelectWrapper's popover will be anchored to this component. */ triggerComponent: React.ReactElement< + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any string | React.JSXElementConstructor > | null; diff --git a/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.test.tsx b/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.test.tsx index 2a3efa169d1c..421d8b285c84 100644 --- a/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.test.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.test.tsx @@ -66,6 +66,8 @@ describe('AssetBalanceText', () => { }; const { asFragment } = render( + {/* Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} , ); @@ -91,6 +93,8 @@ describe('AssetBalanceText', () => { }; const { getByText } = render( + {/* Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} , ); @@ -116,6 +120,8 @@ describe('AssetBalanceText', () => { const { getByText } = render( + {/* Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} , ); diff --git a/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.tsx b/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.tsx index 58db7089843b..1976c367dd51 100644 --- a/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-balance/asset-balance-text.tsx @@ -41,6 +41,8 @@ export function AssetBalanceText({ tokens: [{ address: asset.details?.address }], address: undefined, }); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const balanceString = (tokensWithBalances[0] as any)?.string; const balanceValue = useSelector(getSelectedAccountCachedBalance); diff --git a/ui/components/multichain/asset-picker-amount/asset-picker-amount.test.tsx b/ui/components/multichain/asset-picker-amount/asset-picker-amount.test.tsx index ea993969ccfc..46743ffce15b 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker-amount.test.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker-amount.test.tsx @@ -30,6 +30,8 @@ describe('AssetPickerAmount', () => { asset: { balance: '0x3635c9adc5dea00000', type: AssetType.NFT, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any error: null as any, details: { address: '0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e', diff --git a/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx b/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx index 37e524c5ec42..1b043e2f2313 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx @@ -177,6 +177,8 @@ export function AssetPickerModal({ const collectionsKeys = Object.keys(collections); const collectionsData = collectionsKeys.reduce((acc: unknown[], key) => { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const collection = (collections as any)[key]; const isMatchingQuery = collection.collectionName @@ -244,6 +246,8 @@ export function AssetPickerModal({ handleSearch(e.target.value)} error={false} autoFocus @@ -340,6 +344,8 @@ export function AssetPickerModal({ handleSearch(e.target.value)} error={false} autoFocus diff --git a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.test.tsx b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.test.tsx index 93a857e3c377..fe62996e1c7d 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.test.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.test.tsx @@ -8,7 +8,11 @@ import { AssetPicker } from './asset-picker'; const store = ( nativeTicker = 'NATIVE TICKER', + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any tokenList = {} as any, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any contractExchangeRates = {} as any, ) => configureStore({ diff --git a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx index ba000ff4ec39..bbd0d3222132 100644 --- a/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx +++ b/ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx @@ -40,6 +40,8 @@ export type AssetPickerProps = { export function AssetPicker({ asset, onAssetChange }: AssetPickerProps) { const nativeCurrencySymbol = useSelector(getNativeCurrency); const nativeCurrencyImageUrl = useSelector(getNativeCurrencyImage); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const tokenList: Record = useSelector(getTokenList); const ipfsGateway = useSelector(getIpfsGateway); diff --git a/ui/components/multichain/connected-accounts-menu/connected-accounts-menu.tsx b/ui/components/multichain/connected-accounts-menu/connected-accounts-menu.tsx index 963561e84e48..3a21a50e029b 100644 --- a/ui/components/multichain/connected-accounts-menu/connected-accounts-menu.tsx +++ b/ui/components/multichain/connected-accounts-menu/connected-accounts-menu.tsx @@ -27,6 +27,8 @@ import { import { PermissionDetailsModal } from '../permission-details-modal/permission-details-modal'; import { Identity } from './connected-accounts-menu.types'; +// TODO: Replace `any` with type +// eslint-disable-next-line @typescript-eslint/no-explicit-any const TsMenuItem = MenuItem as any; export const ConnectedAccountsMenu = ({ diff --git a/ui/components/multichain/connected-status/connected-status.tsx b/ui/components/multichain/connected-status/connected-status.tsx index 00b0121b20de..f5843931945c 100644 --- a/ui/components/multichain/connected-status/connected-status.tsx +++ b/ui/components/multichain/connected-status/connected-status.tsx @@ -22,6 +22,8 @@ export type ConnectedStatusProps = { isActive?: boolean; }; export type AddressConnectedSubjectMap = { + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any [address: string]: any; }; diff --git a/ui/components/multichain/pages/connections/connections.tsx b/ui/components/multichain/pages/connections/connections.tsx index e9e5d3470ba9..121b8216e40c 100644 --- a/ui/components/multichain/pages/connections/connections.tsx +++ b/ui/components/multichain/pages/connections/connections.tsx @@ -91,12 +91,18 @@ export const Connections = () => { const CONNECTED_ACCOUNTS_TAB_KEY = 'connected-accounts'; const activeTabOrigin: string = useSelector(getOriginOfCurrentTab); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const subjectMetadata: { [key: string]: any } = useSelector( getConnectedSitesList, ); const siteMetadata = useSelector(getSubjectMetadata); const connectedSiteMetadata = siteMetadata[activeTabOrigin]; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { openMetaMaskTabs } = useSelector((state: any) => state.appState); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const { id } = useSelector((state: any) => state.activeTab); const connectedAccounts = useSelector( @@ -108,10 +114,14 @@ export const Connections = () => { const permittedAccountsByOrigin = useSelector( getPermittedAccountsByOrigin, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any ) as { [key: string]: any[] }; const subjects = useSelector(getPermissionSubjects); const currentTabHasNoAccounts = !permittedAccountsByOrigin[activeTabOrigin]?.length; + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any let tabToConnect: { origin: any } = { origin: null }; if (activeTabOrigin && currentTabHasNoAccounts && !openMetaMaskTabs[id]) { tabToConnect = { @@ -153,6 +163,8 @@ export const Connections = () => { // In the mergeAccounts, we need the lastSelected value to determine which connectedAccount was last selected. const latestSelected = mergedAccounts.findIndex( + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any (_account: any, index: any) => { return ( index === @@ -160,6 +172,8 @@ export const Connections = () => { ( acc: string | number, cur: { metadata: { lastSelected: number } }, + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any i: any, ) => cur.metadata.lastSelected > @@ -228,6 +242,8 @@ export const Connections = () => { name={t('connectedaccountsTabKey')} padding={4} > + {/* TODO: Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} {mergedAccounts.map((account: AccountType, index: any) => { const connectedSites: ConnectedSites = {}; const connectedSite = connectedSites[account.address]?.find( diff --git a/ui/components/multichain/pages/send/components/content.tsx b/ui/components/multichain/pages/send/components/content.tsx index 43e05d92a893..b5c33c519e55 100644 --- a/ui/components/multichain/pages/send/components/content.tsx +++ b/ui/components/multichain/pages/send/components/content.tsx @@ -50,6 +50,8 @@ export const SendPageContent = ({ // Gas data const dispatch = useDispatch(); + // TODO: Replace `any` with type + // eslint-disable-next-line @typescript-eslint/no-explicit-any const handleSelectToken = async (token: any) => { if (token.type === AssetType.native) { dispatch( diff --git a/ui/components/multichain/pages/send/components/hex.tsx b/ui/components/multichain/pages/send/components/hex.tsx index 36e000372f68..af6b002ce173 100644 --- a/ui/components/multichain/pages/send/components/hex.tsx +++ b/ui/components/multichain/pages/send/components/hex.tsx @@ -16,6 +16,8 @@ export const SendHexData = () => {