From 51a5320bc9487caae395a536e44a8825d8237ab6 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 13 Aug 2024 16:03:23 -0400 Subject: [PATCH 01/35] feat: added AccountWatcher as preinstalled snap and added to menu list --- app/_locales/en/messages.json | 3 + .../lib/snap-keyring/account-watcher-snap.ts | 8 +++ app/scripts/snaps/preinstalled-snaps.ts | 2 + package.json | 1 + .../account-list-menu/account-list-menu.tsx | 40 ++++++++++- yarn.lock | 68 ++++++++++++++++++- 6 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 app/scripts/lib/snap-keyring/account-watcher-snap.ts diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 13406d331c36..80e9841c9551 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -344,6 +344,9 @@ "addressCopied": { "message": "Address copied!" }, + "addWatchOnlyAccount": { + "message": "Watch Ethereum account (Beta)" + }, "advanced": { "message": "Advanced" }, diff --git a/app/scripts/lib/snap-keyring/account-watcher-snap.ts b/app/scripts/lib/snap-keyring/account-watcher-snap.ts new file mode 100644 index 000000000000..3775dcd28405 --- /dev/null +++ b/app/scripts/lib/snap-keyring/account-watcher-snap.ts @@ -0,0 +1,8 @@ +import { SnapId } from '@metamask/snaps-sdk'; +import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json'; + +export const ACCOUNT_WATCHER_SNAP_ID: SnapId = + AccountWatcherSnap.snapId as SnapId; + +export const ACCOUNT_WATCHER_NAME: string = + AccountWatcherSnap.manifest.proposedName; diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index ee3bb06c6242..dcae8b708c9b 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,11 +1,13 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; +import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json'; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) import BitcoinWalletSnap from '@metamask/bitcoin-wallet-snap/dist/preinstalled-snap.json'; ///: END:ONLY_INCLUDE_IF const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ MessageSigningSnap as PreinstalledSnap, + AccountWatcherSnap as PreinstalledSnap, ///: BEGIN:ONLY_INCLUDE_IF(build-flask) BitcoinWalletSnap as PreinstalledSnap, ///: END:ONLY_INCLUDE_IF diff --git a/package.json b/package.json index d8b69ce36eba..1139e1b9d9ec 100644 --- a/package.json +++ b/package.json @@ -304,6 +304,7 @@ "@metamask-institutional/transaction-update": "^0.2.5", "@metamask-institutional/types": "^1.1.0", "@metamask/abi-utils": "^2.0.2", + "@metamask/account-watcher": "^4.0.2", "@metamask/accounts-controller": "^17.2.0", "@metamask/address-book-controller": "^4.0.1", "@metamask/announcement-controller": "^6.1.0", diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx index 2074d307f602..63cb2e18658e 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.tsx +++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx @@ -92,6 +92,11 @@ import { AccountConnections, MergedInternalAccount, } from '../../../selectors/selectors.types'; +import { + ACCOUNT_WATCHER_NAME, + ACCOUNT_WATCHER_SNAP_ID, +} from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap'; +import SnapHome from '../../../pages/snaps/snap-view/snap-home'; import { HiddenAccountList } from './hidden-account-list'; const ACTION_MODES = { @@ -101,6 +106,8 @@ const ACTION_MODES = { MENU: 'menu', // Displays the add account form controls ADD: 'add', + // Displays the add account form controls (for watch-only account) + ADD_WATCH_ONLY: 'add-watch-only', ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // Displays the add account form controls (for bitcoin account) ADD_BITCOIN: 'add-bitcoin', @@ -124,6 +131,8 @@ export const getActionTitle = ( ) => { switch (actionMode) { case ACTION_MODES.ADD: + case ACTION_MODES.MENU: + case ACTION_MODES.ADD_WATCH_ONLY: return t('addAccount'); ///: BEGIN:ONLY_INCLUDE_IF(build-flask) case ACTION_MODES.ADD_BITCOIN: @@ -131,8 +140,6 @@ export const getActionTitle = ( case ACTION_MODES.ADD_BITCOIN_TESTNET: return t('addAccount'); ///: END:ONLY_INCLUDE_IF - case ACTION_MODES.MENU: - return t('addAccount'); case ACTION_MODES.IMPORT: return t('importAccount'); default: @@ -218,6 +225,22 @@ export const AccountListMenu = ({ ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled); ///: END:ONLY_INCLUDE_IF + // TODO: implement toggle and selector for this + const isAddWatchAccountEnabled = true; + const handleAddWatchAccount = async () => { + await trackEvent({ + category: MetaMetricsEventCategory.Navigation, + event: MetaMetricsEventName.AccountAddSelected, + properties: { + account_type: MetaMetricsEventAccountType.Snap, + snap_id: ACCOUNT_WATCHER_SNAP_ID, + snap_name: ACCOUNT_WATCHER_NAME, + location: 'Main Menu', + }, + }); + onClose(); + history.push(`/snaps/view/${encodeURIComponent(ACCOUNT_WATCHER_SNAP_ID)}`); + }; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) const bitcoinSupportEnabled = useSelector(getIsBitcoinSupportEnabled); const bitcoinTestnetSupportEnabled = useSelector( @@ -340,6 +363,19 @@ export const AccountListMenu = ({ {t('addNewAccount')} + {isAddWatchAccountEnabled && ( + + + {t('addWatchOnlyAccount')} + + + )} { ///: BEGIN:ONLY_INCLUDE_IF(build-flask) bitcoinSupportEnabled && ( diff --git a/yarn.lock b/yarn.lock index 6b6eeebf591b..997266b60319 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2440,7 +2440,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.2.1": +"@ethereumjs/tx@npm:^5.1.0, @ethereumjs/tx@npm:^5.2.1": version: 5.3.0 resolution: "@ethereumjs/tx@npm:5.3.0" dependencies: @@ -2463,7 +2463,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": +"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": version: 9.0.3 resolution: "@ethereumjs/util@npm:9.0.3" dependencies: @@ -4817,6 +4817,21 @@ __metadata: languageName: node linkType: hard +"@metamask/account-watcher@npm:^4.0.2": + version: 4.0.2 + resolution: "@metamask/account-watcher@npm:4.0.2" + dependencies: + "@ethereumjs/tx": "npm:^5.1.0" + "@ethereumjs/util": "npm:^9.0.1" + "@metamask/keyring-api": "npm:^4.0.1" + "@metamask/snaps-sdk": "npm:^6.2.1" + "@metamask/utils": "npm:^8.3.0" + ethers: "npm:^5.7.2" + uuid: "npm:^9.0.0" + checksum: 10/661dd1758ba9c90a14b40b5156114bbbd5a6917ab8e5aa202e9599fdb0bff4c03c4050c564c573685de217549e971403b119919421dd039e06dffeb2c51f3e62 + languageName: node + linkType: hard + "@metamask/accounts-controller@npm:^17.2.0": version: 17.2.0 resolution: "@metamask/accounts-controller@npm:17.2.0" @@ -5605,6 +5620,18 @@ __metadata: languageName: node linkType: hard +"@metamask/json-rpc-middleware-stream@npm:^6.0.2": + version: 6.0.2 + resolution: "@metamask/json-rpc-middleware-stream@npm:6.0.2" + dependencies: + "@metamask/json-rpc-engine": "npm:^7.3.2" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^8.3.0" + readable-stream: "npm:^3.6.2" + checksum: 10/eb6fc179959206abeba8b12118757d55cc0028681566008a4005b570d21a9369795452e1bdb672fc9858f46a4e9ed5c996cfff0e85b47cef8bf39a6edfee8f1e + 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" @@ -5630,6 +5657,20 @@ __metadata: languageName: node linkType: hard +"@metamask/keyring-api@npm:^4.0.1": + version: 4.0.2 + resolution: "@metamask/keyring-api@npm:4.0.2" + dependencies: + "@metamask/providers": "npm:^15.0.0" + "@metamask/snaps-sdk": "npm:^3.1.1" + "@metamask/utils": "npm:^8.3.0" + "@types/uuid": "npm:^9.0.1" + superstruct: "npm:^1.0.3" + uuid: "npm:^9.0.0" + checksum: 10/8f6dc3b4913803eba8e22228ac6307ca66247900d70755a6dd457c2037b9fb6d3979da472a08e24ccdd81c28c68db3ad41219d915e5e8442ef640a3c0c46b261 + languageName: node + linkType: hard + "@metamask/keyring-api@npm:^6.1.1": version: 6.4.0 resolution: "@metamask/keyring-api@npm:6.4.0" @@ -6136,6 +6177,26 @@ __metadata: languageName: node linkType: hard +"@metamask/providers@npm:^15.0.0": + version: 15.0.0 + resolution: "@metamask/providers@npm:15.0.0" + dependencies: + "@metamask/json-rpc-engine": "npm:^7.3.2" + "@metamask/json-rpc-middleware-stream": "npm:^6.0.2" + "@metamask/object-multiplex": "npm:^2.0.0" + "@metamask/rpc-errors": "npm:^6.2.1" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^8.3.0" + detect-browser: "npm:^5.2.0" + extension-port-stream: "npm:^3.0.0" + fast-deep-equal: "npm:^3.1.3" + is-stream: "npm:^2.0.0" + readable-stream: "npm:^3.6.2" + webextension-polyfill: "npm:^0.10.0" + checksum: 10/d022fe6d2db577fcd299477f19dd1a0ca88baeae542d8a80330694d004bffc289eecf7008c619408c819de8f43eb9fc989b27e266a5961ffd43cb9c2ec749dd5 + languageName: node + linkType: hard + "@metamask/providers@npm:^17.0.0": version: 17.0.0 resolution: "@metamask/providers@npm:17.0.0" @@ -18449,7 +18510,7 @@ __metadata: languageName: node linkType: hard -"ethers@npm:^5.7.0": +"ethers@npm:^5.7.0, ethers@npm:^5.7.2": version: 5.7.2 resolution: "ethers@npm:5.7.2" dependencies: @@ -25858,6 +25919,7 @@ __metadata: "@metamask-institutional/transaction-update": "npm:^0.2.5" "@metamask-institutional/types": "npm:^1.1.0" "@metamask/abi-utils": "npm:^2.0.2" + "@metamask/account-watcher": "npm:^4.0.2" "@metamask/accounts-controller": "npm:^17.2.0" "@metamask/address-book-controller": "npm:^4.0.1" "@metamask/announcement-controller": "npm:^6.1.0" From 9293af31b28949fefe482cdbfd9188396df39d38 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 13 Aug 2024 17:34:47 -0400 Subject: [PATCH 02/35] feat: put 'Watch Ethereum account (Beta)' behind experimental settings toggle --- app/_locales/en/messages.json | 13 +++++-- app/scripts/controllers/preferences.js | 13 +++++++ app/scripts/lib/setupSentry.js | 1 + app/scripts/metamask-controller.js | 4 ++ shared/constants/metametrics.ts | 1 + test/data/mock-state.json | 1 + ...rs-after-init-opt-in-background-state.json | 1 + .../errors-after-init-opt-in-ui-state.json | 1 + .../account-list-menu/account-list-menu.tsx | 13 ++++--- .../experimental-tab.component.tsx | 37 +++++++++++++++++++ .../experimental-tab.container.ts | 5 +++ .../experimental-tab/experimental-tab.test.js | 2 +- ui/selectors/selectors.js | 4 ++ ui/store/actions.ts | 8 ++++ 14 files changed, 94 insertions(+), 10 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 80e9841c9551..3f17dd84ef6b 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -252,6 +252,9 @@ "addEthereumChainWarningModalTitle": { "message": "You are adding a new RPC provider for Ethereum Mainnet" }, + "addEthereumWatchOnlyAccount": { + "message": "Watch Ethereum account (Beta)" + }, "addFriendsAndAddresses": { "message": "Add friends and addresses you trust" }, @@ -344,9 +347,6 @@ "addressCopied": { "message": "Address copied!" }, - "addWatchOnlyAccount": { - "message": "Watch Ethereum account (Beta)" - }, "advanced": { "message": "Advanced" }, @@ -6480,6 +6480,13 @@ "message": "$1 The third party could spend your entire token balance without further notice or consent. Protect yourself by customizing a lower spending cap.", "description": "$1 is a warning icon with text 'Be careful' in 'warning' colour" }, + "watchEthereumAccountsDescription": { + "message": "Turning this option on will give you the ability to watch Ethereum accounts via a public address or ENS name. For feedback on this Beta feature please complete this $1.", + "description": "$1 is the link to a product feedback form" + }, + "watchEthereumAccountsToggle": { + "message": "Watch Ethereum Accounts (Beta)" + }, "weak": { "message": "Weak" }, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 25fe00d91e08..88dd81fb8e38 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -58,6 +58,7 @@ export default class PreferencesController { useRequestQueue: true, openSeaEnabled: true, // todo set this to true securityAlertsEnabled: true, + watchEthereumAccountEnabled: false, bitcoinSupportEnabled: false, bitcoinTestnetSupportEnabled: false, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) @@ -292,6 +293,18 @@ export default class PreferencesController { } ///: END:ONLY_INCLUDE_IF + /** + * Setter for the `watchEthereumAccountEnabled` property. + * + * @param {boolean} watchEthereumAccountEnabled - Whether or not the user wants to + * enable the "Watch Ethereum account (Beta)" button. + */ + setWatchEthereumAccountEnabled(watchEthereumAccountEnabled) { + this.store.updateState({ + watchEthereumAccountEnabled, + }); + } + /** * Setter for the `bitcoinSupportEnabled` property. * diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 0ced613c1636..a9eb0bd914e9 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -434,6 +434,7 @@ export const SENTRY_UI_STATE = { welcomeScreenSeen: true, confirmationExchangeRates: true, useSafeChainsListValidation: true, + watchEthereumAccountEnabled: true, bitcoinSupportEnabled: false, bitcoinTestnetSupportEnabled: false, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index f185d227d9ee..c90956e1bd9c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3081,6 +3081,10 @@ export default class MetamaskController extends EventEmitter { preferencesController, ), ///: END:ONLY_INCLUDE_IF + setWatchEthereumAccountEnabled: + preferencesController.setWatchEthereumAccountEnabled.bind( + preferencesController, + ), setBitcoinSupportEnabled: preferencesController.setBitcoinSupportEnabled.bind( preferencesController, diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 69571f2725ac..6f70e8c86e19 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -529,6 +529,7 @@ export enum MetaMetricsEventName { EncryptionPublicKeyApproved = 'Encryption Approved', EncryptionPublicKeyRejected = 'Encryption Rejected', EncryptionPublicKeyRequested = 'Encryption Requested', + EthereumWatchAccountsToggled = 'Ethereum Watch Accounts Toggled', ExternalLinkClicked = 'External Link Clicked', KeyExportSelected = 'Key Export Selected', KeyExportRequested = 'Key Export Requested', diff --git a/test/data/mock-state.json b/test/data/mock-state.json index cbd53b0fe68d..1f217e915821 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -1873,6 +1873,7 @@ } ], "addSnapAccountEnabled": false, + "watchEthereumAccountEnabled": false, "bitcoinSupportEnabled": false, "bitcoinTestnetSupportEnabled": false, "pendingApprovals": { diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 115960a2d9f6..b09c41e87fca 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -183,6 +183,7 @@ "useRequestQueue": true, "openSeaEnabled": false, "securityAlertsEnabled": "boolean", + "watchEthereumAccountEnabled": "boolean", "bitcoinSupportEnabled": "boolean", "bitcoinTestnetSupportEnabled": "boolean", "addSnapAccountEnabled": "boolean", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index fd06e9c24ac2..4f4c3c3dcb51 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -117,6 +117,7 @@ "useRequestQueue": true, "openSeaEnabled": false, "securityAlertsEnabled": "boolean", + "watchEthereumAccountEnabled": "boolean", "bitcoinSupportEnabled": "boolean", "bitcoinTestnetSupportEnabled": "boolean", "addSnapAccountEnabled": "boolean", diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx index 63cb2e18658e..21bc177cb48f 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.tsx +++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx @@ -64,6 +64,7 @@ import { getOriginOfCurrentTab, getSelectedInternalAccount, getUpdatedAndSortedAccounts, + getIsWatchEthereumAccountEnabled, } from '../../../selectors'; import { setSelectedAccount } from '../../../store/actions'; import { @@ -96,7 +97,6 @@ import { ACCOUNT_WATCHER_NAME, ACCOUNT_WATCHER_SNAP_ID, } from '../../../../app/scripts/lib/snap-keyring/account-watcher-snap'; -import SnapHome from '../../../pages/snaps/snap-view/snap-home'; import { HiddenAccountList } from './hidden-account-list'; const ACTION_MODES = { @@ -225,8 +225,9 @@ export const AccountListMenu = ({ ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled); ///: END:ONLY_INCLUDE_IF - // TODO: implement toggle and selector for this - const isAddWatchAccountEnabled = true; + const isAddWatchEthereumAccountEnabled = useSelector( + getIsWatchEthereumAccountEnabled, + ); const handleAddWatchAccount = async () => { await trackEvent({ category: MetaMetricsEventCategory.Navigation, @@ -363,16 +364,16 @@ export const AccountListMenu = ({ {t('addNewAccount')} - {isAddWatchAccountEnabled && ( + {isAddWatchEthereumAccountEnabled && ( - {t('addWatchOnlyAccount')} + {t('addEthereumWatchOnlyAccount')} )} diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 089cd71c03d4..aa51ab7b6157 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -34,6 +34,8 @@ import { SurveyUrl } from '../../../../shared/constants/urls'; ///: END:ONLY_INCLUDE_IF type ExperimentalTabProps = { + watchAccountEnabled: boolean; + setWatchAccountEnabled: (value: boolean) => void; bitcoinSupportEnabled: boolean; setBitcoinSupportEnabled: (value: boolean) => void; bitcoinTestnetSupportEnabled: boolean; @@ -261,6 +263,40 @@ export default class ExperimentalTab extends PureComponent }); } + renderWatchAccountToggle() { + const { t, trackEvent } = this.context; + const { watchAccountEnabled, setWatchAccountEnabled } = this.props; + + return this.renderToggleSection({ + title: t('watchEthereumAccountsToggle'), + description: t('watchEthereumAccountsDescription', [ + + {t('form')} + , + ]), + toggleValue: watchAccountEnabled, + toggleCallback: (value) => { + trackEvent({ + event: MetaMetricsEventName.EthereumWatchAccountsToggled, + category: MetaMetricsEventCategory.Settings, + properties: { + enabled: !value, + }, + }); + setWatchAccountEnabled(!value); + }, + toggleContainerDataTestId: 'watch-account-toggle-div', + toggleDataTestId: 'watch-account-toggle', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + }); + } + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // We're only setting the code fences here since // we should remove it for the feature release @@ -349,6 +385,7 @@ export default class ExperimentalTab extends PureComponent this.renderKeyringSnapsToggle() ///: END:ONLY_INCLUDE_IF } + {this.renderWatchAccountToggle()} { ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // We're only setting the code fences here since diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.ts b/ui/pages/settings/experimental-tab/experimental-tab.container.ts index b348bb325d9f..f4d408565bfd 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.container.ts +++ b/ui/pages/settings/experimental-tab/experimental-tab.container.ts @@ -12,6 +12,7 @@ import { setFeatureNotificationsEnabled, setRedesignedConfirmationsEnabled, setRedesignedTransactionsEnabled, + setWatchEthereumAccountEnabled, } from '../../../store/actions'; import { getIsBitcoinSupportEnabled, @@ -24,6 +25,7 @@ import { getFeatureNotificationsEnabled, getRedesignedConfirmationsEnabled, getRedesignedTransactionsEnabled, + getIsWatchEthereumAccountEnabled, } from '../../../selectors'; import type { MetaMaskReduxDispatch, @@ -35,6 +37,7 @@ const mapStateToProps = (state: MetaMaskReduxState) => { const petnamesEnabled = getPetnamesEnabled(state); const featureNotificationsEnabled = getFeatureNotificationsEnabled(state); return { + watchAccountEnabled: getIsWatchEthereumAccountEnabled(state), bitcoinSupportEnabled: getIsBitcoinSupportEnabled(state), bitcoinTestnetSupportEnabled: getIsBitcoinTestnetSupportEnabled(state), ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) @@ -50,6 +53,8 @@ const mapStateToProps = (state: MetaMaskReduxState) => { const mapDispatchToProps = (dispatch: MetaMaskReduxDispatch) => { return { + setWatchAccountEnabled: (value: boolean) => + setWatchEthereumAccountEnabled(value), setBitcoinSupportEnabled: (value: boolean) => setBitcoinSupportEnabled(value), setBitcoinTestnetSupportEnabled: (value: boolean) => diff --git a/ui/pages/settings/experimental-tab/experimental-tab.test.js b/ui/pages/settings/experimental-tab/experimental-tab.test.js index 0f7619cdac01..784b2dc3b5d3 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.test.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.test.js @@ -30,7 +30,7 @@ describe('ExperimentalTab', () => { const { getAllByRole } = render(); const toggle = getAllByRole('checkbox'); - expect(toggle).toHaveLength(7); + expect(toggle).toHaveLength(8); }); it('enables add account snap', async () => { diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index fe9058f8a71a..5e533a80f011 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -2313,6 +2313,10 @@ export function getIsAddSnapAccountEnabled(state) { } ///: END:ONLY_INCLUDE_IF +export function getIsWatchEthereumAccountEnabled(state) { + return state.metamask.watchEthereumAccountEnabled; +} + /** * Get the state of the `bitcoinSupportEnabled` flag. * diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 697464e5b9a9..2c9c86479d08 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4953,6 +4953,14 @@ export function setSecurityAlertsEnabled(val: boolean): void { } } +export async function setWatchEthereumAccountEnabled(value: boolean) { + try { + await submitRequestToBackground('setWatchEthereumAccountEnabled', [value]); + } catch (error) { + logErrorWithMessage(error); + } +} + export async function setBitcoinSupportEnabled(value: boolean) { try { await submitRequestToBackground('setBitcoinSupportEnabled', [value]); From 6169fe028181862dab8a77f76272f27672f02ce8 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 13 Aug 2024 17:42:09 -0400 Subject: [PATCH 03/35] feat: renamed metric to 'WatchEthereumAccountsToggled' --- shared/constants/metametrics.ts | 2 +- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 6f70e8c86e19..1abc22ce2ef4 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -529,7 +529,6 @@ export enum MetaMetricsEventName { EncryptionPublicKeyApproved = 'Encryption Approved', EncryptionPublicKeyRejected = 'Encryption Rejected', EncryptionPublicKeyRequested = 'Encryption Requested', - EthereumWatchAccountsToggled = 'Ethereum Watch Accounts Toggled', ExternalLinkClicked = 'External Link Clicked', KeyExportSelected = 'Key Export Selected', KeyExportRequested = 'Key Export Requested', @@ -628,6 +627,7 @@ export enum MetaMetricsEventName { WalletSetupCanceled = 'Wallet Setup Canceled', WalletSetupFailed = 'Wallet Setup Failed', WalletCreated = 'Wallet Created', + WatchEthereumAccountsToggled = 'Watch Ethereum Accounts Toggled', ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) DeeplinkClicked = 'Deeplink Clicked', ConnectCustodialAccountClicked = 'Connect Custodial Account Clicked', diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index aa51ab7b6157..b888ac31efbe 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -282,7 +282,7 @@ export default class ExperimentalTab extends PureComponent toggleValue: watchAccountEnabled, toggleCallback: (value) => { trackEvent({ - event: MetaMetricsEventName.EthereumWatchAccountsToggled, + event: MetaMetricsEventName.WatchEthereumAccountsToggled, category: MetaMetricsEventCategory.Settings, properties: { enabled: !value, From 9efcdffbcf195670528fa784fde5f1019533dc4b Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 13 Aug 2024 18:09:59 -0400 Subject: [PATCH 04/35] fix: setupSentry state --- app/scripts/lib/setupSentry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index a9eb0bd914e9..a140b1e7aa59 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -434,7 +434,7 @@ export const SENTRY_UI_STATE = { welcomeScreenSeen: true, confirmationExchangeRates: true, useSafeChainsListValidation: true, - watchEthereumAccountEnabled: true, + watchEthereumAccountEnabled: false, bitcoinSupportEnabled: false, bitcoinTestnetSupportEnabled: false, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) From 64c5b1cf97d50cd768c2f1303c54fbc1b71b6d95 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Wed, 14 Aug 2024 10:07:52 -0400 Subject: [PATCH 05/35] feat: updated copy and changed to eye icon --- app/_locales/en/messages.json | 2 +- .../account-list-menu/account-list-menu.tsx | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 3f17dd84ef6b..3cfd9bbf74bd 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -253,7 +253,7 @@ "message": "You are adding a new RPC provider for Ethereum Mainnet" }, "addEthereumWatchOnlyAccount": { - "message": "Watch Ethereum account (Beta)" + "message": "Watch an Ethereum account (Beta)" }, "addFriendsAndAddresses": { "message": "Add friends and addresses you trust" diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx index 21bc177cb48f..85ae0fcdefd6 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.tsx +++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx @@ -364,19 +364,6 @@ export const AccountListMenu = ({ {t('addNewAccount')} - {isAddWatchEthereumAccountEnabled && ( - - - {t('addEthereumWatchOnlyAccount')} - - - )} { ///: BEGIN:ONLY_INCLUDE_IF(build-flask) bitcoinSupportEnabled && ( @@ -537,6 +524,19 @@ export const AccountListMenu = ({ ///: END:ONLY_INCLUDE_IF } + {isAddWatchEthereumAccountEnabled && ( + + + {t('addEthereumWatchOnlyAccount')} + + + )} ) : null} {actionMode === ACTION_MODES.LIST ? ( From e08a9b1eef3b6165cb0ea96f25843ba07d0c1155 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Wed, 14 Aug 2024 18:07:20 -0400 Subject: [PATCH 06/35] feat: updated account-watcher to 4.0.3 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ead71a7e9eed..cb0f5638125c 100644 --- a/package.json +++ b/package.json @@ -300,7 +300,7 @@ "@metamask-institutional/transaction-update": "^0.2.5", "@metamask-institutional/types": "^1.1.0", "@metamask/abi-utils": "^2.0.2", - "@metamask/account-watcher": "^4.0.2", + "@metamask/account-watcher": "^4.0.3", "@metamask/accounts-controller": "^17.2.0", "@metamask/address-book-controller": "^4.0.1", "@metamask/announcement-controller": "^6.1.0", diff --git a/yarn.lock b/yarn.lock index aaab01463857..5bd20229f27a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -154,16 +154,16 @@ __metadata: linkType: hard "@babel/eslint-parser@npm:^7.23.10": - version: 7.23.10 - resolution: "@babel/eslint-parser@npm:7.23.10" + version: 7.25.1 + resolution: "@babel/eslint-parser@npm:7.25.1" dependencies: "@nicolo-ribaudo/eslint-scope-5-internals": "npm:5.1.1-v1" eslint-visitor-keys: "npm:^2.1.0" semver: "npm:^6.3.1" peerDependencies: "@babel/core": ^7.11.0 - eslint: ^7.5.0 || ^8.0.0 - checksum: 10/eb62ad6a1098836331317be978ebd5991a9257d58118062f252b002e995b4f35b76a5dc976b07d84d21e64c8395587a044c5e6e444b3b69ab53e50a18facf2af + eslint: ^7.5.0 || ^8.0.0 || ^9.0.0 + checksum: 10/9a2ddab3accd391a1eb95cb1ea655daa8603515d0f17081c542db8621c6bbbc65aa3b9b96b779854eed80cc8664a8969d7ac54479e8738876c0be5d26fd66efa languageName: node linkType: hard @@ -4817,9 +4817,9 @@ __metadata: languageName: node linkType: hard -"@metamask/account-watcher@npm:^4.0.2": - version: 4.0.2 - resolution: "@metamask/account-watcher@npm:4.0.2" +"@metamask/account-watcher@npm:^4.0.3": + version: 4.0.3 + resolution: "@metamask/account-watcher@npm:4.0.3" dependencies: "@ethereumjs/tx": "npm:^5.1.0" "@ethereumjs/util": "npm:^9.0.1" @@ -4828,7 +4828,7 @@ __metadata: "@metamask/utils": "npm:^8.3.0" ethers: "npm:^5.7.2" uuid: "npm:^9.0.0" - checksum: 10/661dd1758ba9c90a14b40b5156114bbbd5a6917ab8e5aa202e9599fdb0bff4c03c4050c564c573685de217549e971403b119919421dd039e06dffeb2c51f3e62 + checksum: 10/16b7991446f586c2a78f8f520de5ca2482514f5803e04f24caee1c729b61c3403370d3fe19134ce11d8d78dd97699f6e3c3d55ce56260c17dd6714eaa16e4924 languageName: node linkType: hard @@ -26046,7 +26046,7 @@ __metadata: "@metamask-institutional/transaction-update": "npm:^0.2.5" "@metamask-institutional/types": "npm:^1.1.0" "@metamask/abi-utils": "npm:^2.0.2" - "@metamask/account-watcher": "npm:^4.0.2" + "@metamask/account-watcher": "npm:^4.0.3" "@metamask/accounts-controller": "npm:^17.2.0" "@metamask/address-book-controller": "npm:^4.0.1" "@metamask/announcement-controller": "npm:^6.1.0" From 0f3e0e3c4f526dd342f97aba9e0f1378f59a8470 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Thu, 15 Aug 2024 11:44:09 -0400 Subject: [PATCH 07/35] feat: added width styling to the create-named-snap-account component --- .../create-named-snap-account.tsx | 2 +- .../create-named-snap-account/index.scss | 29 +++++++++++++++++++ .../multichain/multichain-components.scss | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 ui/components/multichain/create-named-snap-account/index.scss diff --git a/ui/components/multichain/create-named-snap-account/create-named-snap-account.tsx b/ui/components/multichain/create-named-snap-account/create-named-snap-account.tsx index ac0650dc6d93..194a8c6399df 100644 --- a/ui/components/multichain/create-named-snap-account/create-named-snap-account.tsx +++ b/ui/components/multichain/create-named-snap-account/create-named-snap-account.tsx @@ -73,7 +73,7 @@ export const CreateNamedSnapAccount: React.FC = ({ }, []); return ( - + {t('addAccountToMetaMask')} diff --git a/ui/components/multichain/create-named-snap-account/index.scss b/ui/components/multichain/create-named-snap-account/index.scss new file mode 100644 index 000000000000..f799195dc1f8 --- /dev/null +++ b/ui/components/multichain/create-named-snap-account/index.scss @@ -0,0 +1,29 @@ +@use "design-system"; + +.name-snap-account-page { + $height-screen-sm-max: 100%; + $width-screen-sm-min: 85vw; + $width-screen-md-min: 80vw; + $width-screen-lg-min: 62vw; + + width: 100%; + flex-flow: column nowrap; + margin: 0 auto; + + @include design-system.screen-sm-max { + height: $height-screen-sm-max; + } + + @include design-system.screen-sm-min { + width: $width-screen-sm-min; + } + + @include design-system.screen-md-min { + width: $width-screen-md-min; + } + + @include design-system.screen-lg-min { + width: $width-screen-lg-min; + } +} + diff --git a/ui/components/multichain/multichain-components.scss b/ui/components/multichain/multichain-components.scss index c4b043c69b1f..5fda42a8141f 100644 --- a/ui/components/multichain/multichain-components.scss +++ b/ui/components/multichain/multichain-components.scss @@ -17,6 +17,7 @@ @import 'app-header'; @import 'connected-accounts-menu'; @import 'connected-site-menu'; +@import 'create-named-snap-account'; @import 'token-list-item'; @import 'network-list-item'; @import 'network-list-item-menu'; From 263d5965b77062647a0a7fbb4d0035a585fbd499 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Thu, 15 Aug 2024 11:59:28 -0400 Subject: [PATCH 08/35] chore: updated snapshots --- .../__snapshots__/create-named-snap-account.test.js.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/pages/confirmations/confirmation/templates/__snapshots__/create-named-snap-account.test.js.snap b/ui/pages/confirmations/confirmation/templates/__snapshots__/create-named-snap-account.test.js.snap index 4419807e6fc1..501815d53f4e 100644 --- a/ui/pages/confirmations/confirmation/templates/__snapshots__/create-named-snap-account.test.js.snap +++ b/ui/pages/confirmations/confirmation/templates/__snapshots__/create-named-snap-account.test.js.snap @@ -9,7 +9,7 @@ exports[`create-named-snap-account confirmation matches snapshot 1`] = ` class="confirmation-page__content" >
Date: Thu, 15 Aug 2024 14:49:58 -0400 Subject: [PATCH 09/35] fix: merge conflicts with develop --- app/scripts/snaps/preinstalled-snaps.ts | 2 + yarn.lock | 146 +++++++++++++++++++++++- 2 files changed, 146 insertions(+), 2 deletions(-) diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index e44682963f61..3fcfcb7493e9 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,5 +1,6 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; +import AccountWatcherSnap from '@metamask/account-watcher/dist/preinstalled-snap.json'; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) import BitcoinWalletSnap from '@metamask/bitcoin-wallet-snap/dist/preinstalled-snap.json'; ///: END:ONLY_INCLUDE_IF @@ -7,6 +8,7 @@ import BitcoinWalletSnap from '@metamask/bitcoin-wallet-snap/dist/preinstalled-s // The casts here are less than ideal but we expect the SnapController to validate the inputs. const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ MessageSigningSnap as unknown as PreinstalledSnap, + AccountWatcherSnap as unknown as PreinstalledSnap, ///: BEGIN:ONLY_INCLUDE_IF(build-flask) BitcoinWalletSnap as unknown as PreinstalledSnap, ///: END:ONLY_INCLUDE_IF diff --git a/yarn.lock b/yarn.lock index a66ead175712..e884aed56385 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2391,6 +2391,15 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/common@npm:^4.4.0": + version: 4.4.0 + resolution: "@ethereumjs/common@npm:4.4.0" + dependencies: + "@ethereumjs/util": "npm:^9.1.0" + checksum: 10/dd5cc78575a762b367601f94d6af7e36cb3a5ecab45eec0c1259c433e755a16c867753aa88f331e3963791a18424ad0549682a3a6a0a160640fe846db6ce8014 + languageName: node + linkType: hard + "@ethereumjs/rlp@npm:^4.0.0, @ethereumjs/rlp@npm:^4.0.1": version: 4.0.1 resolution: "@ethereumjs/rlp@npm:4.0.1" @@ -2440,6 +2449,18 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/tx@npm:^5.1.0": + version: 5.4.0 + resolution: "@ethereumjs/tx@npm:5.4.0" + dependencies: + "@ethereumjs/common": "npm:^4.4.0" + "@ethereumjs/rlp": "npm:^5.0.2" + "@ethereumjs/util": "npm:^9.1.0" + ethereum-cryptography: "npm:^2.2.1" + checksum: 10/8d2c0a69ab37015f945f9de065cfb9f05e8e79179efeed725ea0a14760c3eb8ff900bcf915bb71ec29fe2f753db35d1b78a15ac4ddec489e87c995dec1ba6e85 + languageName: node + linkType: hard + "@ethereumjs/tx@npm:^5.2.1": version: 5.3.0 resolution: "@ethereumjs/tx@npm:5.3.0" @@ -2463,6 +2484,16 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.1.0": + version: 9.1.0 + resolution: "@ethereumjs/util@npm:9.1.0" + dependencies: + "@ethereumjs/rlp": "npm:^5.0.2" + ethereum-cryptography: "npm:^2.2.1" + checksum: 10/4e22c4081c63eebb808eccd54f7f91cd3407f4cac192da5f30a0d6983fe07d51f25e6a9d08624f1376e604bb7dce574aafcf0fbf0becf42f62687c11e710ac41 + languageName: node + linkType: hard + "@ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": version: 9.0.3 resolution: "@ethereumjs/util@npm:9.0.3" @@ -4817,6 +4848,21 @@ __metadata: languageName: node linkType: hard +"@metamask/account-watcher@npm:^4.0.3": + version: 4.0.3 + resolution: "@metamask/account-watcher@npm:4.0.3" + dependencies: + "@ethereumjs/tx": "npm:^5.1.0" + "@ethereumjs/util": "npm:^9.0.1" + "@metamask/keyring-api": "npm:^4.0.1" + "@metamask/snaps-sdk": "npm:^6.2.1" + "@metamask/utils": "npm:^8.3.0" + ethers: "npm:^5.7.2" + uuid: "npm:^9.0.0" + checksum: 10/16b7991446f586c2a78f8f520de5ca2482514f5803e04f24caee1c729b61c3403370d3fe19134ce11d8d78dd97699f6e3c3d55ce56260c17dd6714eaa16e4924 + languageName: node + linkType: hard + "@metamask/accounts-controller@npm:^17.2.0": version: 17.2.0 resolution: "@metamask/accounts-controller@npm:17.2.0" @@ -5605,6 +5651,18 @@ __metadata: languageName: node linkType: hard +"@metamask/json-rpc-middleware-stream@npm:^6.0.2": + version: 6.0.2 + resolution: "@metamask/json-rpc-middleware-stream@npm:6.0.2" + dependencies: + "@metamask/json-rpc-engine": "npm:^7.3.2" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^8.3.0" + readable-stream: "npm:^3.6.2" + checksum: 10/eb6fc179959206abeba8b12118757d55cc0028681566008a4005b570d21a9369795452e1bdb672fc9858f46a4e9ed5c996cfff0e85b47cef8bf39a6edfee8f1e + languageName: node + linkType: hard + "@metamask/json-rpc-middleware-stream@npm:^8.0.1, @metamask/json-rpc-middleware-stream@npm:^8.0.2": version: 8.0.2 resolution: "@metamask/json-rpc-middleware-stream@npm:8.0.2" @@ -5630,6 +5688,20 @@ __metadata: languageName: node linkType: hard +"@metamask/keyring-api@npm:^4.0.1": + version: 4.0.2 + resolution: "@metamask/keyring-api@npm:4.0.2" + dependencies: + "@metamask/providers": "npm:^15.0.0" + "@metamask/snaps-sdk": "npm:^3.1.1" + "@metamask/utils": "npm:^8.3.0" + "@types/uuid": "npm:^9.0.1" + superstruct: "npm:^1.0.3" + uuid: "npm:^9.0.0" + checksum: 10/8f6dc3b4913803eba8e22228ac6307ca66247900d70755a6dd457c2037b9fb6d3979da472a08e24ccdd81c28c68db3ad41219d915e5e8442ef640a3c0c46b261 + languageName: node + linkType: hard + "@metamask/keyring-api@npm:^6.1.1": version: 6.4.0 resolution: "@metamask/keyring-api@npm:6.4.0" @@ -6168,6 +6240,26 @@ __metadata: languageName: node linkType: hard +"@metamask/providers@npm:^15.0.0": + version: 15.0.0 + resolution: "@metamask/providers@npm:15.0.0" + dependencies: + "@metamask/json-rpc-engine": "npm:^7.3.2" + "@metamask/json-rpc-middleware-stream": "npm:^6.0.2" + "@metamask/object-multiplex": "npm:^2.0.0" + "@metamask/rpc-errors": "npm:^6.2.1" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^8.3.0" + detect-browser: "npm:^5.2.0" + extension-port-stream: "npm:^3.0.0" + fast-deep-equal: "npm:^3.1.3" + is-stream: "npm:^2.0.0" + readable-stream: "npm:^3.6.2" + webextension-polyfill: "npm:^0.10.0" + checksum: 10/d022fe6d2db577fcd299477f19dd1a0ca88baeae542d8a80330694d004bffc289eecf7008c619408c819de8f43eb9fc989b27e266a5961ffd43cb9c2ec749dd5 + languageName: node + linkType: hard + "@metamask/providers@npm:^17.1.2": version: 17.1.2 resolution: "@metamask/providers@npm:17.1.2" @@ -6745,6 +6837,15 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": + version: 1.4.2 + resolution: "@noble/curves@npm:1.4.2" + dependencies: + "@noble/hashes": "npm:1.4.0" + checksum: 10/f433a2e8811ae345109388eadfa18ef2b0004c1f79417553241db4f0ad0d59550be6298a4f43d989c627e9f7551ffae6e402a4edf0173981e6da95fc7cab5123 + languageName: node + linkType: hard + "@noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0": version: 1.4.0 resolution: "@noble/curves@npm:1.4.0" @@ -6768,7 +6869,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0": +"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" checksum: 10/e156e65794c473794c52fa9d06baf1eb20903d0d96719530f523cc4450f6c721a957c544796e6efd0197b2296e7cd70efeb312f861465e17940a3e3c7e0febc6 @@ -7913,6 +8014,13 @@ __metadata: languageName: node linkType: hard +"@scure/base@npm:~1.1.6": + version: 1.1.7 + resolution: "@scure/base@npm:1.1.7" + checksum: 10/fc50ffaab36cb46ff9fa4dc5052a06089ab6a6707f63d596bb34aaaec76173c9a564ac312a0b981b5e7a5349d60097b8878673c75d6cbfc4da7012b63a82099b + languageName: node + linkType: hard + "@scure/bip32@npm:1.1.0": version: 1.1.0 resolution: "@scure/bip32@npm:1.1.0" @@ -7935,6 +8043,17 @@ __metadata: languageName: node linkType: hard +"@scure/bip32@npm:1.4.0": + version: 1.4.0 + resolution: "@scure/bip32@npm:1.4.0" + dependencies: + "@noble/curves": "npm:~1.4.0" + "@noble/hashes": "npm:~1.4.0" + "@scure/base": "npm:~1.1.6" + checksum: 10/6cd5062d902564d9e970597ec8b1adacb415b2eadfbb95aee1a1a0480a52eb0de4d294d3753aa8b48548064c9795ed108d348a31a8ce3fc88785377bb12c63b9 + languageName: node + linkType: hard + "@scure/bip39@npm:1.1.0": version: 1.1.0 resolution: "@scure/bip39@npm:1.1.0" @@ -7955,6 +8074,16 @@ __metadata: languageName: node linkType: hard +"@scure/bip39@npm:1.3.0": + version: 1.3.0 + resolution: "@scure/bip39@npm:1.3.0" + dependencies: + "@noble/hashes": "npm:~1.4.0" + "@scure/base": "npm:~1.1.6" + checksum: 10/7d71fd58153de22fe8cd65b525f6958a80487bc9d0fbc32c71c328aeafe41fa259f989d2f1e0fa4fdfeaf83b8fcf9310d52ed9862987e46c2f2bfb9dd8cf9fc1 + languageName: node + linkType: hard + "@segment/loosely-validate-event@npm:^2.0.0": version: 2.0.0 resolution: "@segment/loosely-validate-event@npm:2.0.0" @@ -18495,6 +18624,18 @@ __metadata: languageName: node linkType: hard +"ethereum-cryptography@npm:^2.2.1": + version: 2.2.1 + resolution: "ethereum-cryptography@npm:2.2.1" + dependencies: + "@noble/curves": "npm:1.4.2" + "@noble/hashes": "npm:1.4.0" + "@scure/bip32": "npm:1.4.0" + "@scure/bip39": "npm:1.3.0" + checksum: 10/ab123bbfe843500ac2d645ce9edc4bc814962ffb598db6bf8bf01fbecac656e6c81ff4cf2472f1734844bbcbad2bf658d8b699cb7248d768e0f06ae13ecf43b8 + languageName: node + linkType: hard + "ethereum-ens-network-map@npm:^1.0.2": version: 1.0.2 resolution: "ethereum-ens-network-map@npm:1.0.2" @@ -18544,7 +18685,7 @@ __metadata: languageName: node linkType: hard -"ethers@npm:^5.7.0": +"ethers@npm:^5.7.0, ethers@npm:^5.7.2": version: 5.7.2 resolution: "ethers@npm:5.7.2" dependencies: @@ -25971,6 +26112,7 @@ __metadata: "@metamask-institutional/transaction-update": "npm:^0.2.5" "@metamask-institutional/types": "npm:^1.1.0" "@metamask/abi-utils": "npm:^2.0.2" + "@metamask/account-watcher": "npm:^4.0.3" "@metamask/accounts-controller": "npm:^17.2.0" "@metamask/address-book-controller": "npm:^4.0.1" "@metamask/announcement-controller": "npm:^6.1.0" From bdd38c839e596d69ca6d238b823b6fbc2c476b46 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Thu, 15 Aug 2024 15:02:36 -0400 Subject: [PATCH 10/35] feat: redirect to default route from back button on snap homepage for preinstalled snap --- ui/pages/snaps/snap-view/snap-view.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/pages/snaps/snap-view/snap-view.js b/ui/pages/snaps/snap-view/snap-view.js index f0f71374d4ca..c14bb8d972d3 100644 --- a/ui/pages/snaps/snap-view/snap-view.js +++ b/ui/pages/snaps/snap-view/snap-view.js @@ -8,7 +8,7 @@ import { Display, JustifyContent, } from '../../../helpers/constants/design-system'; -import { SNAPS_ROUTE } from '../../../helpers/constants/routes'; +import { DEFAULT_ROUTE, SNAPS_ROUTE } from '../../../helpers/constants/routes'; import { getSnaps, getPermissions } from '../../../selectors'; import { ButtonIcon, @@ -65,7 +65,9 @@ function SnapView() { }; const handleBackClick = () => { - if (showSettings && hasHomePage) { + if (snap.preinstalled) { + history.push(DEFAULT_ROUTE); + } else if (showSettings && hasHomePage) { setShowSettings(false); } else { history.push(SNAPS_ROUTE); From fd8a1c38d4adeac135b02a2eb72060f9c1327b9c Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Thu, 15 Aug 2024 15:10:15 -0400 Subject: [PATCH 11/35] chore: yarn dedupe --- yarn.lock | 115 ++++++------------------------------------------------ 1 file changed, 13 insertions(+), 102 deletions(-) diff --git a/yarn.lock b/yarn.lock index e884aed56385..2b923dc9d9a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2382,16 +2382,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.3.0": - version: 4.3.0 - resolution: "@ethereumjs/common@npm:4.3.0" - dependencies: - "@ethereumjs/util": "npm:^9.0.3" - checksum: 10/90f7fe1ba6827b65cd25e9bb4adf07a117ea554a950bb364d5fd9873cb770d383addb0ad34839a91fbec22ebc25516c6fb7e70ae0198c78f933920bf39797a94 - languageName: node - linkType: hard - -"@ethereumjs/common@npm:^4.4.0": +"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.4.0": version: 4.4.0 resolution: "@ethereumjs/common@npm:4.4.0" dependencies: @@ -2449,7 +2440,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.1.0": +"@ethereumjs/tx@npm:^5.1.0, @ethereumjs/tx@npm:^5.2.1": version: 5.4.0 resolution: "@ethereumjs/tx@npm:5.4.0" dependencies: @@ -2461,18 +2452,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.2.1": - version: 5.3.0 - resolution: "@ethereumjs/tx@npm:5.3.0" - dependencies: - "@ethereumjs/common": "npm:^4.3.0" - "@ethereumjs/rlp": "npm:^5.0.2" - "@ethereumjs/util": "npm:^9.0.3" - ethereum-cryptography: "npm:^2.1.3" - checksum: 10/4eb48e763d81ea0978648367d61c568c8d10f769c1ea7d32307ebe02299d4fa9fe5d7bf794ec1ee22e92edef6bfe1f459d5816e1c62d3f93602d931807ca488b - languageName: node - linkType: hard - "@ethereumjs/util@npm:^8.0.0, @ethereumjs/util@npm:^8.0.5, @ethereumjs/util@npm:^8.1.0": version: 8.1.0 resolution: "@ethereumjs/util@npm:8.1.0" @@ -2484,7 +2463,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.1.0": +"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.1.0": version: 9.1.0 resolution: "@ethereumjs/util@npm:9.1.0" dependencies: @@ -2494,16 +2473,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": - version: 9.0.3 - resolution: "@ethereumjs/util@npm:9.0.3" - dependencies: - "@ethereumjs/rlp": "npm:^5.0.2" - ethereum-cryptography: "npm:^2.1.3" - checksum: 10/d9c313a0672e0b4842ba80e2f413ccd5302c3942dc4ed718d6e3faab89c4eeeaaeb6661e9275679c22b83b1cb6502ea772e1c837d105b6a9faf5957a59bc3e4c - languageName: node - linkType: hard - "@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.5.0, @ethersproject/abi@npm:^5.6.4, @ethersproject/abi@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/abi@npm:5.7.0" @@ -6828,16 +6797,7 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.3.0, @noble/curves@npm:~1.3.0": - version: 1.3.0 - resolution: "@noble/curves@npm:1.3.0" - dependencies: - "@noble/hashes": "npm:1.3.3" - checksum: 10/f3cbdd1af00179e30146eac5539e6df290228fb857a7a8ba36d1a772cbe59288a2ca83d06f175d3446ef00db3a80d7fd8b8347f7de9c2d4d5bf3865d8bb78252 - languageName: node - linkType: hard - -"@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": +"@noble/curves@npm:1.4.2, @noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0, @noble/curves@npm:~1.4.0": version: 1.4.2 resolution: "@noble/curves@npm:1.4.2" dependencies: @@ -6846,15 +6806,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0": - version: 1.4.0 - resolution: "@noble/curves@npm:1.4.0" - dependencies: - "@noble/hashes": "npm:1.4.0" - checksum: 10/b21b30a36ff02bfcc0f5e6163d245cdbaf7f640511fff97ccf83fc207ee79cfd91584b4d97977374de04cb118a55eb63a7964c82596a64162bbc42bc685ae6d9 - languageName: node - linkType: hard - "@noble/hashes@npm:1.1.2": version: 1.1.2 resolution: "@noble/hashes@npm:1.1.2" @@ -6862,13 +6813,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d - languageName: node - linkType: hard - "@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" @@ -6883,6 +6827,13 @@ __metadata: languageName: node linkType: hard +"@noble/hashes@npm:~1.3.2": + version: 1.3.3 + resolution: "@noble/hashes@npm:1.3.3" + checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d + languageName: node + linkType: hard + "@noble/secp256k1@npm:1.6.3, @noble/secp256k1@npm:~1.6.0": version: 1.6.3 resolution: "@noble/secp256k1@npm:1.6.3" @@ -8007,14 +7958,7 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.4": - version: 1.1.6 - resolution: "@scure/base@npm:1.1.6" - checksum: 10/814fd1cce24f1e152751fabca2853d26aaa96ff8a9349c43d9aebc3b3d8ca88dd902966e1c289590a37f35d4c4436c6aedb1b386924b2909072045af4c3e9fe4 - languageName: node - linkType: hard - -"@scure/base@npm:~1.1.6": +"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.6": version: 1.1.7 resolution: "@scure/base@npm:1.1.7" checksum: 10/fc50ffaab36cb46ff9fa4dc5052a06089ab6a6707f63d596bb34aaaec76173c9a564ac312a0b981b5e7a5349d60097b8878673c75d6cbfc4da7012b63a82099b @@ -8032,17 +7976,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip32@npm:1.3.3": - version: 1.3.3 - resolution: "@scure/bip32@npm:1.3.3" - dependencies: - "@noble/curves": "npm:~1.3.0" - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.4" - checksum: 10/4b8b75567866ff7d6b3ba154538add02d2951e9433e8dd7f0014331ac500cda5a88fe3d39b408fcc36e86b633682013f172b967af022c2e4e4ab07336801d688 - languageName: node - linkType: hard - "@scure/bip32@npm:1.4.0": version: 1.4.0 resolution: "@scure/bip32@npm:1.4.0" @@ -8064,16 +7997,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.2.2": - version: 1.2.2 - resolution: "@scure/bip39@npm:1.2.2" - dependencies: - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.4" - checksum: 10/f71aceda10a7937bf3779fd2b4c4156c95ec9813269470ddca464cb8ab610d2451b173037f4b1e6dac45414e406e7adc7b5814c51279f4474d5d38140bbee542 - languageName: node - linkType: hard - "@scure/bip39@npm:1.3.0": version: 1.3.0 resolution: "@scure/bip39@npm:1.3.0" @@ -18612,19 +18535,7 @@ __metadata: languageName: node linkType: hard -"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.1.3": - version: 2.1.3 - resolution: "ethereum-cryptography@npm:2.1.3" - dependencies: - "@noble/curves": "npm:1.3.0" - "@noble/hashes": "npm:1.3.3" - "@scure/bip32": "npm:1.3.3" - "@scure/bip39": "npm:1.2.2" - checksum: 10/cc5aa9a4368dc1dd7680ba921957c098ced7b3d7dbb1666334013ab2f8d4cd25a785ad84e66fd9f5c5a9b6de337930ea24ff8c722938f36a9c00cec597ca16b5 - languageName: node - linkType: hard - -"ethereum-cryptography@npm:^2.2.1": +"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.2.1": version: 2.2.1 resolution: "ethereum-cryptography@npm:2.2.1" dependencies: From 4d963aaecc95b757cb852e8849644ea143da134a Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Thu, 15 Aug 2024 18:40:27 -0400 Subject: [PATCH 12/35] feat: useCallback for 'handleAddWatchAccount' --- .../multichain/account-list-menu/account-list-menu.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.tsx b/ui/components/multichain/account-list-menu/account-list-menu.tsx index 549afffc434b..abffdb83afe5 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.tsx +++ b/ui/components/multichain/account-list-menu/account-list-menu.tsx @@ -228,7 +228,7 @@ export const AccountListMenu = ({ const isAddWatchEthereumAccountEnabled = useSelector( getIsWatchEthereumAccountEnabled, ); - const handleAddWatchAccount = async () => { + const handleAddWatchAccount = useCallback(async () => { await trackEvent({ category: MetaMetricsEventCategory.Navigation, event: MetaMetricsEventName.AccountAddSelected, @@ -241,7 +241,7 @@ export const AccountListMenu = ({ }); onClose(); history.push(`/snaps/view/${encodeURIComponent(ACCOUNT_WATCHER_SNAP_ID)}`); - }; + }, [trackEvent, onClose, history]); ///: BEGIN:ONLY_INCLUDE_IF(build-flask) const bitcoinSupportEnabled = useSelector(getIsBitcoinSupportEnabled); const bitcoinTestnetSupportEnabled = useSelector( From 217b60d472c8440ce065338ce711aa2d5453db82 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Fri, 16 Aug 2024 09:08:19 -0400 Subject: [PATCH 13/35] feat: added not removable to conditional in back button --- ui/pages/snaps/snap-view/snap-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/snaps/snap-view/snap-view.js b/ui/pages/snaps/snap-view/snap-view.js index c14bb8d972d3..669b9d79dc52 100644 --- a/ui/pages/snaps/snap-view/snap-view.js +++ b/ui/pages/snaps/snap-view/snap-view.js @@ -65,7 +65,7 @@ function SnapView() { }; const handleBackClick = () => { - if (snap.preinstalled) { + if (snap.preinstalled && !snap.removable) { history.push(DEFAULT_ROUTE); } else if (showSettings && hasHomePage) { setShowSettings(false); From 35c1736277e0bbcf177a0237dd4d1a6ce7000f7a Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Fri, 16 Aug 2024 13:11:53 -0400 Subject: [PATCH 14/35] feat: updated account-watcher to 4.1.0 with hidden flag --- package.json | 2 +- ui/pages/snaps/snap-view/snap-view.js | 2 +- yarn.lock | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fb335f536417..c0bc42664b1d 100644 --- a/package.json +++ b/package.json @@ -297,7 +297,7 @@ "@metamask-institutional/transaction-update": "^0.2.5", "@metamask-institutional/types": "^1.1.0", "@metamask/abi-utils": "^2.0.2", - "@metamask/account-watcher": "^4.0.3", + "@metamask/account-watcher": "^4.1.0", "@metamask/accounts-controller": "^17.2.0", "@metamask/address-book-controller": "^4.0.1", "@metamask/announcement-controller": "^6.1.0", diff --git a/ui/pages/snaps/snap-view/snap-view.js b/ui/pages/snaps/snap-view/snap-view.js index dbf4a9fa4961..a913a1387527 100644 --- a/ui/pages/snaps/snap-view/snap-view.js +++ b/ui/pages/snaps/snap-view/snap-view.js @@ -65,7 +65,7 @@ function SnapView() { }; const handleBackClick = () => { - if (snap.preinstalled && !snap.removable) { + if (snap.preinstalled && snap.hidden) { history.push(DEFAULT_ROUTE); } else if (showSettings && hasHomePage) { setShowSettings(false); diff --git a/yarn.lock b/yarn.lock index 695da7f66a40..dd3c0a5d4204 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4827,9 +4827,9 @@ __metadata: languageName: node linkType: hard -"@metamask/account-watcher@npm:^4.0.3": - version: 4.0.3 - resolution: "@metamask/account-watcher@npm:4.0.3" +"@metamask/account-watcher@npm:^4.1.0": + version: 4.1.0 + resolution: "@metamask/account-watcher@npm:4.1.0" dependencies: "@ethereumjs/tx": "npm:^5.1.0" "@ethereumjs/util": "npm:^9.0.1" @@ -4838,7 +4838,7 @@ __metadata: "@metamask/utils": "npm:^8.3.0" ethers: "npm:^5.7.2" uuid: "npm:^9.0.0" - checksum: 10/16b7991446f586c2a78f8f520de5ca2482514f5803e04f24caee1c729b61c3403370d3fe19134ce11d8d78dd97699f6e3c3d55ce56260c17dd6714eaa16e4924 + checksum: 10/51c150cc1a703c6726f7c11eb6b4906636a5c33cf25c2b60c7d120e67483fae37ac79ba46a5156518cb9666c2c64fea00f1d6ec23faa266b28a814c4fcefa561 languageName: node linkType: hard @@ -26040,7 +26040,7 @@ __metadata: "@metamask-institutional/transaction-update": "npm:^0.2.5" "@metamask-institutional/types": "npm:^1.1.0" "@metamask/abi-utils": "npm:^2.0.2" - "@metamask/account-watcher": "npm:^4.0.3" + "@metamask/account-watcher": "npm:^4.1.0" "@metamask/accounts-controller": "npm:^17.2.0" "@metamask/address-book-controller": "npm:^4.0.1" "@metamask/announcement-controller": "npm:^6.1.0" From 1bd6ac01321cd4c2e2016f09839548ef6542dd05 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 11:18:27 -0400 Subject: [PATCH 15/35] chore: update lavamoat --- lavamoat/build-system/policy.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index 0dcb0cc02724..b9781e48445f 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -2117,7 +2117,8 @@ "chokidar>normalize-path": true, "chokidar>readdirp": true, "del>is-glob": true, - "eslint>glob-parent": true + "eslint>glob-parent": true, + "tsx>fsevents": true } }, "chokidar>anymatch": { @@ -8849,6 +8850,13 @@ "typescript": true } }, + "tsx>fsevents": { + "globals": { + "console.assert": true, + "process.platform": true + }, + "native": true + }, "typescript": { "builtin": { "buffer.Buffer": true, From 4ff4fc0c0c7107808a711833ad0f461a917996be Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 11:43:48 -0400 Subject: [PATCH 16/35] feat: added start of create-watch-account.spec.ts --- .../e2e/accounts/create-watch-account.spec.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/e2e/accounts/create-watch-account.spec.ts diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts new file mode 100644 index 000000000000..c7608eee0973 --- /dev/null +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -0,0 +1,57 @@ +import { Suite } from 'mocha'; + +import FixtureBuilder from '../fixture-builder'; +import { + defaultGanacheOptions, + unlockWallet, + WINDOW_TITLES, + withFixtures, +} from '../helpers'; +import { Driver } from '../webdriver/driver'; + +/** + * Starts the flow to create a watch account. + * + * @param driver - The WebDriver instance used to control the browser. + * @returns A promise that resolves when the setup steps are complete. + */ +async function startCreateWatchAccountFlow(driver: Driver): Promise { + await unlockWallet(driver); + + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-add-watch-only-account"]', + ); + + // Wait until dialog is opened before proceeding + await driver.waitAndSwitchToWindowWithTitle(3, WINDOW_TITLES.Dialog); +} + +describe('Account-watcher snap', function (this: Suite) { + it("user can add watch account via snap by clicking 'Watch an Ethereum account'", async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // start the add watch account flow and switch to dialog window + await startCreateWatchAccountFlow(driver); + + await driver.fill( + '[placeholder="Enter a public address or ENS name"]', + 'vitalik.eth', + ); + await driver.clickElement({ text: 'Watch account', tag: 'button' }); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'vitalik.eth', + }); + }, + ); + }); +}); From bacdef4aafefd77a996b215f5c81ed6938ee97e0 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 11:51:38 -0400 Subject: [PATCH 17/35] feat: updated lavamoat policy to match develop --- lavamoat/build-system/policy.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index b9781e48445f..0dcb0cc02724 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -2117,8 +2117,7 @@ "chokidar>normalize-path": true, "chokidar>readdirp": true, "del>is-glob": true, - "eslint>glob-parent": true, - "tsx>fsevents": true + "eslint>glob-parent": true } }, "chokidar>anymatch": { @@ -8850,13 +8849,6 @@ "typescript": true } }, - "tsx>fsevents": { - "globals": { - "console.assert": true, - "process.platform": true - }, - "native": true - }, "typescript": { "builtin": { "buffer.Buffer": true, From 8d2feb82f594b362d2ec36c9c8767455773c253c Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 12:22:26 -0400 Subject: [PATCH 18/35] feat: updated preferences controller fixtures --- test/e2e/accounts/create-snap-account.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 2a35b4b4c805..c3591fa48ed8 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -301,7 +301,11 @@ describe('Create Snap Account', function (this: Suite) { it('cancelling naming Snap account results in account not created', async function () { await withFixtures( { - fixtures: new FixtureBuilder().build(), + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .build(), ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, From e56f8c25ec5cee64dcfe12482771828f846c876d Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 12:39:55 -0400 Subject: [PATCH 19/35] feat: updated fixtures --- .../e2e/accounts/create-watch-account.spec.ts | 67 ++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index c7608eee0973..792e2a7730b8 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -9,6 +9,9 @@ import { } from '../helpers'; import { Driver } from '../webdriver/driver'; +const eoaAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; +const ensName = 'vitalik.eth'; + /** * Starts the flow to create a watch account. * @@ -31,10 +34,14 @@ async function startCreateWatchAccountFlow(driver: Driver): Promise { } describe('Account-watcher snap', function (this: Suite) { - it("user can add watch account via snap by clicking 'Watch an Ethereum account'", async function () { + it('user can add watch account with valid EOA address', async function () { await withFixtures( { - fixtures: new FixtureBuilder().build(), + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .build(), ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, @@ -42,11 +49,24 @@ describe('Account-watcher snap', function (this: Suite) { // start the add watch account flow and switch to dialog window await startCreateWatchAccountFlow(driver); + // fill in the ENS and click the watch account button await driver.fill( '[placeholder="Enter a public address or ENS name"]', - 'vitalik.eth', + eoaAddress, ); await driver.clickElement({ text: 'Watch account', tag: 'button' }); + // success screen should show account created + await driver.findElement({ + tag: 'h3', + text: 'Account created', + }); + await driver.findElement({ + css: '.multichain-account-list-item__account-name__button', + text: 'vitalik.eth', + }); + // click the okay button + await driver.clickElement('[data-testid="confirmation-submit-button"]'); + // switch back to the main window await driver.findElement({ css: '[data-testid="account-menu-icon"]', text: 'vitalik.eth', @@ -54,4 +74,45 @@ describe('Account-watcher snap', function (this: Suite) { }, ); }); + + it('user can add watch account with valid ENS name', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // start the add watch account flow and switch to dialog window + await startCreateWatchAccountFlow(driver); + + // fill in the ENS and click the watch account button + await driver.fill( + '[placeholder="Enter a public address or ENS name"]', + ensName, + ); + await driver.clickElement({ text: 'Watch account', tag: 'button' }); + // success screen should show account created + await driver.findElement({ + tag: 'h3', + text: 'Account created', + }); + await driver.findElement({ + css: '.multichain-account-list-item__account-name__button', + text: ensName, + }); + // click the okay button + await driver.clickElement('[data-testid="confirmation-submit-button"]'); + // switch back to the main window + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: ensName, + }); + }, + ); + }); }); From e647d43643d721bec9d3291ed14a26ba95e4f291 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 13:04:23 -0400 Subject: [PATCH 20/35] fix: yarn.lock --- yarn.lock | 115 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/yarn.lock b/yarn.lock index 628785910ec2..bb4d80fca23d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2392,7 +2392,16 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.4.0": +"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.3.0": + version: 4.3.0 + resolution: "@ethereumjs/common@npm:4.3.0" + dependencies: + "@ethereumjs/util": "npm:^9.0.3" + checksum: 10/90f7fe1ba6827b65cd25e9bb4adf07a117ea554a950bb364d5fd9873cb770d383addb0ad34839a91fbec22ebc25516c6fb7e70ae0198c78f933920bf39797a94 + languageName: node + linkType: hard + +"@ethereumjs/common@npm:^4.4.0": version: 4.4.0 resolution: "@ethereumjs/common@npm:4.4.0" dependencies: @@ -2450,7 +2459,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.1.0, @ethereumjs/tx@npm:^5.2.1": +"@ethereumjs/tx@npm:^5.1.0": version: 5.4.0 resolution: "@ethereumjs/tx@npm:5.4.0" dependencies: @@ -2462,6 +2471,18 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/tx@npm:^5.2.1": + version: 5.3.0 + resolution: "@ethereumjs/tx@npm:5.3.0" + dependencies: + "@ethereumjs/common": "npm:^4.3.0" + "@ethereumjs/rlp": "npm:^5.0.2" + "@ethereumjs/util": "npm:^9.0.3" + ethereum-cryptography: "npm:^2.1.3" + checksum: 10/4eb48e763d81ea0978648367d61c568c8d10f769c1ea7d32307ebe02299d4fa9fe5d7bf794ec1ee22e92edef6bfe1f459d5816e1c62d3f93602d931807ca488b + languageName: node + linkType: hard + "@ethereumjs/util@npm:^8.0.0, @ethereumjs/util@npm:^8.0.5, @ethereumjs/util@npm:^8.1.0": version: 8.1.0 resolution: "@ethereumjs/util@npm:8.1.0" @@ -2473,7 +2494,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.1.0": +"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.1.0": version: 9.1.0 resolution: "@ethereumjs/util@npm:9.1.0" dependencies: @@ -2483,6 +2504,16 @@ __metadata: languageName: node linkType: hard +"@ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": + version: 9.0.3 + resolution: "@ethereumjs/util@npm:9.0.3" + dependencies: + "@ethereumjs/rlp": "npm:^5.0.2" + ethereum-cryptography: "npm:^2.1.3" + checksum: 10/d9c313a0672e0b4842ba80e2f413ccd5302c3942dc4ed718d6e3faab89c4eeeaaeb6661e9275679c22b83b1cb6502ea772e1c837d105b6a9faf5957a59bc3e4c + languageName: node + linkType: hard + "@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.5.0, @ethersproject/abi@npm:^5.6.4, @ethersproject/abi@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/abi@npm:5.7.0" @@ -6827,7 +6858,16 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.4.2, @noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0, @noble/curves@npm:~1.4.0": +"@noble/curves@npm:1.3.0, @noble/curves@npm:~1.3.0": + version: 1.3.0 + resolution: "@noble/curves@npm:1.3.0" + dependencies: + "@noble/hashes": "npm:1.3.3" + checksum: 10/f3cbdd1af00179e30146eac5539e6df290228fb857a7a8ba36d1a772cbe59288a2ca83d06f175d3446ef00db3a80d7fd8b8347f7de9c2d4d5bf3865d8bb78252 + languageName: node + linkType: hard + +"@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": version: 1.4.2 resolution: "@noble/curves@npm:1.4.2" dependencies: @@ -6836,6 +6876,15 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0": + version: 1.4.0 + resolution: "@noble/curves@npm:1.4.0" + dependencies: + "@noble/hashes": "npm:1.4.0" + checksum: 10/b21b30a36ff02bfcc0f5e6163d245cdbaf7f640511fff97ccf83fc207ee79cfd91584b4d97977374de04cb118a55eb63a7964c82596a64162bbc42bc685ae6d9 + languageName: node + linkType: hard + "@noble/hashes@npm:1.1.2": version: 1.1.2 resolution: "@noble/hashes@npm:1.1.2" @@ -6843,6 +6892,13 @@ __metadata: languageName: node linkType: hard +"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.2": + version: 1.3.3 + resolution: "@noble/hashes@npm:1.3.3" + checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d + languageName: node + linkType: hard + "@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" @@ -6857,13 +6913,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d - languageName: node - linkType: hard - "@noble/secp256k1@npm:1.6.3, @noble/secp256k1@npm:~1.6.0": version: 1.6.3 resolution: "@noble/secp256k1@npm:1.6.3" @@ -7988,7 +8037,14 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.6": +"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.4": + version: 1.1.6 + resolution: "@scure/base@npm:1.1.6" + checksum: 10/814fd1cce24f1e152751fabca2853d26aaa96ff8a9349c43d9aebc3b3d8ca88dd902966e1c289590a37f35d4c4436c6aedb1b386924b2909072045af4c3e9fe4 + languageName: node + linkType: hard + +"@scure/base@npm:~1.1.6": version: 1.1.7 resolution: "@scure/base@npm:1.1.7" checksum: 10/fc50ffaab36cb46ff9fa4dc5052a06089ab6a6707f63d596bb34aaaec76173c9a564ac312a0b981b5e7a5349d60097b8878673c75d6cbfc4da7012b63a82099b @@ -8006,6 +8062,17 @@ __metadata: languageName: node linkType: hard +"@scure/bip32@npm:1.3.3": + version: 1.3.3 + resolution: "@scure/bip32@npm:1.3.3" + dependencies: + "@noble/curves": "npm:~1.3.0" + "@noble/hashes": "npm:~1.3.2" + "@scure/base": "npm:~1.1.4" + checksum: 10/4b8b75567866ff7d6b3ba154538add02d2951e9433e8dd7f0014331ac500cda5a88fe3d39b408fcc36e86b633682013f172b967af022c2e4e4ab07336801d688 + languageName: node + linkType: hard + "@scure/bip32@npm:1.4.0": version: 1.4.0 resolution: "@scure/bip32@npm:1.4.0" @@ -8027,6 +8094,16 @@ __metadata: languageName: node linkType: hard +"@scure/bip39@npm:1.2.2": + version: 1.2.2 + resolution: "@scure/bip39@npm:1.2.2" + dependencies: + "@noble/hashes": "npm:~1.3.2" + "@scure/base": "npm:~1.1.4" + checksum: 10/f71aceda10a7937bf3779fd2b4c4156c95ec9813269470ddca464cb8ab610d2451b173037f4b1e6dac45414e406e7adc7b5814c51279f4474d5d38140bbee542 + languageName: node + linkType: hard + "@scure/bip39@npm:1.3.0": version: 1.3.0 resolution: "@scure/bip39@npm:1.3.0" @@ -18536,7 +18613,19 @@ __metadata: languageName: node linkType: hard -"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.2.1": +"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.1.3": + version: 2.1.3 + resolution: "ethereum-cryptography@npm:2.1.3" + dependencies: + "@noble/curves": "npm:1.3.0" + "@noble/hashes": "npm:1.3.3" + "@scure/bip32": "npm:1.3.3" + "@scure/bip39": "npm:1.2.2" + checksum: 10/cc5aa9a4368dc1dd7680ba921957c098ced7b3d7dbb1666334013ab2f8d4cd25a785ad84e66fd9f5c5a9b6de337930ea24ff8c722938f36a9c00cec597ca16b5 + languageName: node + linkType: hard + +"ethereum-cryptography@npm:^2.2.1": version: 2.2.1 resolution: "ethereum-cryptography@npm:2.2.1" dependencies: From 43479d3c612e7ac8d60534c46c30c6853d0167b3 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 13:11:53 -0400 Subject: [PATCH 21/35] fix: yarn dedupe --- yarn.lock | 115 ++++++------------------------------------------------ 1 file changed, 13 insertions(+), 102 deletions(-) diff --git a/yarn.lock b/yarn.lock index bb4d80fca23d..628785910ec2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2392,16 +2392,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.3.0": - version: 4.3.0 - resolution: "@ethereumjs/common@npm:4.3.0" - dependencies: - "@ethereumjs/util": "npm:^9.0.3" - checksum: 10/90f7fe1ba6827b65cd25e9bb4adf07a117ea554a950bb364d5fd9873cb770d383addb0ad34839a91fbec22ebc25516c6fb7e70ae0198c78f933920bf39797a94 - languageName: node - linkType: hard - -"@ethereumjs/common@npm:^4.4.0": +"@ethereumjs/common@npm:^4.2.0, @ethereumjs/common@npm:^4.4.0": version: 4.4.0 resolution: "@ethereumjs/common@npm:4.4.0" dependencies: @@ -2459,7 +2450,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.1.0": +"@ethereumjs/tx@npm:^5.1.0, @ethereumjs/tx@npm:^5.2.1": version: 5.4.0 resolution: "@ethereumjs/tx@npm:5.4.0" dependencies: @@ -2471,18 +2462,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/tx@npm:^5.2.1": - version: 5.3.0 - resolution: "@ethereumjs/tx@npm:5.3.0" - dependencies: - "@ethereumjs/common": "npm:^4.3.0" - "@ethereumjs/rlp": "npm:^5.0.2" - "@ethereumjs/util": "npm:^9.0.3" - ethereum-cryptography: "npm:^2.1.3" - checksum: 10/4eb48e763d81ea0978648367d61c568c8d10f769c1ea7d32307ebe02299d4fa9fe5d7bf794ec1ee22e92edef6bfe1f459d5816e1c62d3f93602d931807ca488b - languageName: node - linkType: hard - "@ethereumjs/util@npm:^8.0.0, @ethereumjs/util@npm:^8.0.5, @ethereumjs/util@npm:^8.1.0": version: 8.1.0 resolution: "@ethereumjs/util@npm:8.1.0" @@ -2494,7 +2473,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.1.0": +"@ethereumjs/util@npm:^9.0.1, @ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.1.0": version: 9.1.0 resolution: "@ethereumjs/util@npm:9.1.0" dependencies: @@ -2504,16 +2483,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^9.0.2, @ethereumjs/util@npm:^9.0.3": - version: 9.0.3 - resolution: "@ethereumjs/util@npm:9.0.3" - dependencies: - "@ethereumjs/rlp": "npm:^5.0.2" - ethereum-cryptography: "npm:^2.1.3" - checksum: 10/d9c313a0672e0b4842ba80e2f413ccd5302c3942dc4ed718d6e3faab89c4eeeaaeb6661e9275679c22b83b1cb6502ea772e1c837d105b6a9faf5957a59bc3e4c - languageName: node - linkType: hard - "@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.5.0, @ethersproject/abi@npm:^5.6.4, @ethersproject/abi@npm:^5.7.0": version: 5.7.0 resolution: "@ethersproject/abi@npm:5.7.0" @@ -6858,16 +6827,7 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.3.0, @noble/curves@npm:~1.3.0": - version: 1.3.0 - resolution: "@noble/curves@npm:1.3.0" - dependencies: - "@noble/hashes": "npm:1.3.3" - checksum: 10/f3cbdd1af00179e30146eac5539e6df290228fb857a7a8ba36d1a772cbe59288a2ca83d06f175d3446ef00db3a80d7fd8b8347f7de9c2d4d5bf3865d8bb78252 - languageName: node - linkType: hard - -"@noble/curves@npm:1.4.2, @noble/curves@npm:~1.4.0": +"@noble/curves@npm:1.4.2, @noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0, @noble/curves@npm:~1.4.0": version: 1.4.2 resolution: "@noble/curves@npm:1.4.2" dependencies: @@ -6876,15 +6836,6 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:^1.2.0, @noble/curves@npm:^1.4.0": - version: 1.4.0 - resolution: "@noble/curves@npm:1.4.0" - dependencies: - "@noble/hashes": "npm:1.4.0" - checksum: 10/b21b30a36ff02bfcc0f5e6163d245cdbaf7f640511fff97ccf83fc207ee79cfd91584b4d97977374de04cb118a55eb63a7964c82596a64162bbc42bc685ae6d9 - languageName: node - linkType: hard - "@noble/hashes@npm:1.1.2": version: 1.1.2 resolution: "@noble/hashes@npm:1.1.2" @@ -6892,13 +6843,6 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.3.3, @noble/hashes@npm:~1.3.2": - version: 1.3.3 - resolution: "@noble/hashes@npm:1.3.3" - checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d - languageName: node - linkType: hard - "@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" @@ -6913,6 +6857,13 @@ __metadata: languageName: node linkType: hard +"@noble/hashes@npm:~1.3.2": + version: 1.3.3 + resolution: "@noble/hashes@npm:1.3.3" + checksum: 10/1025ddde4d24630e95c0818e63d2d54ee131b980fe113312d17ed7468bc18f54486ac86c907685759f8a7e13c2f9b9e83ec7b67d1cc20836f36b5e4a65bb102d + languageName: node + linkType: hard + "@noble/secp256k1@npm:1.6.3, @noble/secp256k1@npm:~1.6.0": version: 1.6.3 resolution: "@noble/secp256k1@npm:1.6.3" @@ -8037,14 +7988,7 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.4": - version: 1.1.6 - resolution: "@scure/base@npm:1.1.6" - checksum: 10/814fd1cce24f1e152751fabca2853d26aaa96ff8a9349c43d9aebc3b3d8ca88dd902966e1c289590a37f35d4c4436c6aedb1b386924b2909072045af4c3e9fe4 - languageName: node - linkType: hard - -"@scure/base@npm:~1.1.6": +"@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.1.0, @scure/base@npm:~1.1.3, @scure/base@npm:~1.1.6": version: 1.1.7 resolution: "@scure/base@npm:1.1.7" checksum: 10/fc50ffaab36cb46ff9fa4dc5052a06089ab6a6707f63d596bb34aaaec76173c9a564ac312a0b981b5e7a5349d60097b8878673c75d6cbfc4da7012b63a82099b @@ -8062,17 +8006,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip32@npm:1.3.3": - version: 1.3.3 - resolution: "@scure/bip32@npm:1.3.3" - dependencies: - "@noble/curves": "npm:~1.3.0" - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.4" - checksum: 10/4b8b75567866ff7d6b3ba154538add02d2951e9433e8dd7f0014331ac500cda5a88fe3d39b408fcc36e86b633682013f172b967af022c2e4e4ab07336801d688 - languageName: node - linkType: hard - "@scure/bip32@npm:1.4.0": version: 1.4.0 resolution: "@scure/bip32@npm:1.4.0" @@ -8094,16 +8027,6 @@ __metadata: languageName: node linkType: hard -"@scure/bip39@npm:1.2.2": - version: 1.2.2 - resolution: "@scure/bip39@npm:1.2.2" - dependencies: - "@noble/hashes": "npm:~1.3.2" - "@scure/base": "npm:~1.1.4" - checksum: 10/f71aceda10a7937bf3779fd2b4c4156c95ec9813269470ddca464cb8ab610d2451b173037f4b1e6dac45414e406e7adc7b5814c51279f4474d5d38140bbee542 - languageName: node - linkType: hard - "@scure/bip39@npm:1.3.0": version: 1.3.0 resolution: "@scure/bip39@npm:1.3.0" @@ -18613,19 +18536,7 @@ __metadata: languageName: node linkType: hard -"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.1.3": - version: 2.1.3 - resolution: "ethereum-cryptography@npm:2.1.3" - dependencies: - "@noble/curves": "npm:1.3.0" - "@noble/hashes": "npm:1.3.3" - "@scure/bip32": "npm:1.3.3" - "@scure/bip39": "npm:1.2.2" - checksum: 10/cc5aa9a4368dc1dd7680ba921957c098ced7b3d7dbb1666334013ab2f8d4cd25a785ad84e66fd9f5c5a9b6de337930ea24ff8c722938f36a9c00cec597ca16b5 - languageName: node - linkType: hard - -"ethereum-cryptography@npm:^2.2.1": +"ethereum-cryptography@npm:^2.0.0, ethereum-cryptography@npm:^2.1.2, ethereum-cryptography@npm:^2.2.1": version: 2.2.1 resolution: "ethereum-cryptography@npm:2.2.1" dependencies: From 96f81e7ce0e7f5edacd0e05cd548a467ca96b15f Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 13:26:21 -0400 Subject: [PATCH 22/35] feat: updated lavamoat policies --- lavamoat/browserify/beta/policy.json | 40 ++++----------------------- lavamoat/browserify/flask/policy.json | 40 ++++----------------------- lavamoat/browserify/main/policy.json | 40 ++++----------------------- lavamoat/browserify/mmi/policy.json | 40 ++++----------------------- lavamoat/build-system/policy.json | 10 ++++++- 5 files changed, 33 insertions(+), 137 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 176ea14f5a6f..e7798ba313fc 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index 0dcb0cc02724..b9781e48445f 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -2117,7 +2117,8 @@ "chokidar>normalize-path": true, "chokidar>readdirp": true, "del>is-glob": true, - "eslint>glob-parent": true + "eslint>glob-parent": true, + "tsx>fsevents": true } }, "chokidar>anymatch": { @@ -8849,6 +8850,13 @@ "typescript": true } }, + "tsx>fsevents": { + "globals": { + "console.assert": true, + "process.platform": true + }, + "native": true + }, "typescript": { "builtin": { "buffer.Buffer": true, From 9f79954c9572f918b299085dba2b59766420861d Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 13:34:04 -0400 Subject: [PATCH 23/35] Revert "feat: updated lavamoat policies" This reverts commit 96f81e7ce0e7f5edacd0e05cd548a467ca96b15f. --- lavamoat/browserify/beta/policy.json | 40 +++++++++++++++++++++++---- lavamoat/browserify/flask/policy.json | 40 +++++++++++++++++++++++---- lavamoat/browserify/main/policy.json | 40 +++++++++++++++++++++++---- lavamoat/browserify/mmi/policy.json | 40 +++++++++++++++++++++++---- lavamoat/build-system/policy.json | 10 +------ 5 files changed, 137 insertions(+), 33 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 07d5bd2bf207..553a572e3793 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -174,16 +174,44 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, - "@metamask/message-signing-snap>@noble/curves": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@metamask/message-signing-snap>@noble/curves": true, - "@metamask/utils>@scure/base": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, + "@metamask/utils>@scure/base": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 07d5bd2bf207..553a572e3793 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -174,16 +174,44 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, - "@metamask/message-signing-snap>@noble/curves": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@metamask/message-signing-snap>@noble/curves": true, - "@metamask/utils>@scure/base": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, + "@metamask/utils>@scure/base": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 07d5bd2bf207..553a572e3793 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -174,16 +174,44 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, - "@metamask/message-signing-snap>@noble/curves": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@metamask/message-signing-snap>@noble/curves": true, - "@metamask/utils>@scure/base": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, + "@metamask/utils>@scure/base": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index e7798ba313fc..176ea14f5a6f 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -174,16 +174,44 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, - "@metamask/message-signing-snap>@noble/curves": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@metamask/message-signing-snap>@noble/curves": true, - "@metamask/utils>@scure/base": true, - "@noble/hashes": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, + "@metamask/utils>@scure/base": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { + "globals": { + "TextEncoder": true + }, + "packages": { + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true + } + }, + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { + "globals": { + "TextEncoder": true, + "crypto": true } }, "@ethersproject/abi": { diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index b9781e48445f..0dcb0cc02724 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -2117,8 +2117,7 @@ "chokidar>normalize-path": true, "chokidar>readdirp": true, "del>is-glob": true, - "eslint>glob-parent": true, - "tsx>fsevents": true + "eslint>glob-parent": true } }, "chokidar>anymatch": { @@ -8850,13 +8849,6 @@ "typescript": true } }, - "tsx>fsevents": { - "globals": { - "console.assert": true, - "process.platform": true - }, - "native": true - }, "typescript": { "builtin": { "buffer.Buffer": true, From 0efea14218a1705ca399b879757d1c1803f478bb Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Mon, 19 Aug 2024 17:46:22 +0000 Subject: [PATCH 24/35] Update LavaMoat policies --- lavamoat/browserify/beta/policy.json | 40 ++++----------------------- lavamoat/browserify/flask/policy.json | 40 ++++----------------------- lavamoat/browserify/main/policy.json | 40 ++++----------------------- lavamoat/browserify/mmi/policy.json | 40 ++++----------------------- 4 files changed, 24 insertions(+), 136 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 553a572e3793..07d5bd2bf207 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 176ea14f5a6f..e7798ba313fc 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -174,44 +174,16 @@ "crypto": true }, "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": true, + "@metamask/message-signing-snap>@noble/curves": true, + "@noble/hashes": true } }, "@ethereumjs/tx>ethereum-cryptography>@scure/bip32": { "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": true, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true, - "@metamask/utils>@scure/base": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/curves": { - "globals": { - "TextEncoder": true - }, - "packages": { - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": true - } - }, - "@ethereumjs/tx>ethereum-cryptography>@scure/bip32>@noble/hashes": { - "globals": { - "TextEncoder": true, - "crypto": true + "@metamask/message-signing-snap>@noble/curves": true, + "@metamask/utils>@scure/base": true, + "@noble/hashes": true } }, "@ethersproject/abi": { From 37c825e2f9334ee74e4ea416bda1cc09c27c0d8d Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 15:13:59 -0400 Subject: [PATCH 25/35] feat: updated tests for putting extension on mainnet --- .../e2e/accounts/create-watch-account.spec.ts | 62 +++++++------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 792e2a7730b8..09f13cc7feb1 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -1,16 +1,13 @@ import { Suite } from 'mocha'; import FixtureBuilder from '../fixture-builder'; -import { - defaultGanacheOptions, - unlockWallet, - WINDOW_TITLES, - withFixtures, -} from '../helpers'; +import { multipleGanacheOptions, unlockWallet, withFixtures } from '../helpers'; import { Driver } from '../webdriver/driver'; +import { CHAIN_IDS } from '../../../shared/constants/network.ts'; const eoaAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; const ensName = 'vitalik.eth'; +const defaultWatchAccountLabel = 'Watched Account 1'; /** * Starts the flow to create a watch account. @@ -28,48 +25,41 @@ async function startCreateWatchAccountFlow(driver: Driver): Promise { await driver.clickElement( '[data-testid="multichain-account-menu-popover-add-watch-only-account"]', ); - - // Wait until dialog is opened before proceeding - await driver.waitAndSwitchToWindowWithTitle(3, WINDOW_TITLES.Dialog); } describe('Account-watcher snap', function (this: Suite) { it('user can add watch account with valid EOA address', async function () { await withFixtures( { - fixtures: new FixtureBuilder() + fixtures: new FixtureBuilder({ + inputChainId: CHAIN_IDS.MAINNET, + }) .withPreferencesControllerAndFeatureFlag({ watchEthereumAccountEnabled: true, }) + .withNetworkControllerOnMainnet() .build(), - ganacheOptions: defaultGanacheOptions, + ganacheOptions: multipleGanacheOptions, title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { // start the add watch account flow and switch to dialog window await startCreateWatchAccountFlow(driver); - // fill in the ENS and click the watch account button + // fill in the address and click the watch account button await driver.fill( '[placeholder="Enter a public address or ENS name"]', eoaAddress, ); await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // success screen should show account created - await driver.findElement({ - tag: 'h3', - text: 'Account created', - }); - await driver.findElement({ - css: '.multichain-account-list-item__account-name__button', - text: 'vitalik.eth', - }); - // click the okay button - await driver.clickElement('[data-testid="confirmation-submit-button"]'); - // switch back to the main window + // click the add account button on the naming screen + await driver.clickElement( + '[data-testid="submit-add-account-with-name"]', + ); + // check wallet now has the watched account with address resolved await driver.findElement({ css: '[data-testid="account-menu-icon"]', - text: 'vitalik.eth', + text: ensName, }); }, ); @@ -78,12 +68,15 @@ describe('Account-watcher snap', function (this: Suite) { it('user can add watch account with valid ENS name', async function () { await withFixtures( { - fixtures: new FixtureBuilder() + fixtures: new FixtureBuilder({ + inputChainId: CHAIN_IDS.MAINNET, + }) .withPreferencesControllerAndFeatureFlag({ watchEthereumAccountEnabled: true, }) + .withNetworkControllerOnMainnet() .build(), - ganacheOptions: defaultGanacheOptions, + ganacheOptions: multipleGanacheOptions, title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { @@ -96,17 +89,10 @@ describe('Account-watcher snap', function (this: Suite) { ensName, ); await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // success screen should show account created - await driver.findElement({ - tag: 'h3', - text: 'Account created', - }); - await driver.findElement({ - css: '.multichain-account-list-item__account-name__button', - text: ensName, - }); - // click the okay button - await driver.clickElement('[data-testid="confirmation-submit-button"]'); + // click the add account button on the naming screen + await driver.clickElement( + '[data-testid="submit-add-account-with-name"]', + ); // switch back to the main window await driver.findElement({ css: '[data-testid="account-menu-icon"]', From cb5db1bb4cc07f70e6bf757faa7a4131628d5bba Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 15:17:07 -0400 Subject: [PATCH 26/35] fix: changes in create-snap-account.spec --- test/e2e/accounts/create-snap-account.spec.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index c3591fa48ed8..2a35b4b4c805 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -301,11 +301,7 @@ describe('Create Snap Account', function (this: Suite) { it('cancelling naming Snap account results in account not created', async function () { await withFixtures( { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .build(), + fixtures: new FixtureBuilder().build(), ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, From 386face25249b9d9d2f77fa27b0efe49fd03d7f0 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 17:00:40 -0400 Subject: [PATCH 27/35] feat: updated test fixture builder --- test/e2e/accounts/create-watch-account.spec.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 09f13cc7feb1..1b87d78e2d3c 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -3,11 +3,9 @@ import { Suite } from 'mocha'; import FixtureBuilder from '../fixture-builder'; import { multipleGanacheOptions, unlockWallet, withFixtures } from '../helpers'; import { Driver } from '../webdriver/driver'; -import { CHAIN_IDS } from '../../../shared/constants/network.ts'; const eoaAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; const ensName = 'vitalik.eth'; -const defaultWatchAccountLabel = 'Watched Account 1'; /** * Starts the flow to create a watch account. @@ -31,9 +29,7 @@ describe('Account-watcher snap', function (this: Suite) { it('user can add watch account with valid EOA address', async function () { await withFixtures( { - fixtures: new FixtureBuilder({ - inputChainId: CHAIN_IDS.MAINNET, - }) + fixtures: new FixtureBuilder() .withPreferencesControllerAndFeatureFlag({ watchEthereumAccountEnabled: true, }) @@ -68,9 +64,7 @@ describe('Account-watcher snap', function (this: Suite) { it('user can add watch account with valid ENS name', async function () { await withFixtures( { - fixtures: new FixtureBuilder({ - inputChainId: CHAIN_IDS.MAINNET, - }) + fixtures: new FixtureBuilder() .withPreferencesControllerAndFeatureFlag({ watchEthereumAccountEnabled: true, }) From ef452c9ae33bf5455731854e838865465ad20b6e Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 17:19:45 -0400 Subject: [PATCH 28/35] feat: added failure comments --- test/e2e/accounts/create-watch-account.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 1b87d78e2d3c..b2c960e14a16 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -26,6 +26,7 @@ async function startCreateWatchAccountFlow(driver: Driver): Promise { } describe('Account-watcher snap', function (this: Suite) { + // ** Fails because cannot resolve address to expected ENS name ** it('user can add watch account with valid EOA address', async function () { await withFixtures( { @@ -55,12 +56,13 @@ describe('Account-watcher snap', function (this: Suite) { // check wallet now has the watched account with address resolved await driver.findElement({ css: '[data-testid="account-menu-icon"]', - text: ensName, + text: ensName, // shows default unresolved address name "Watched Account 1" }); }, ); }); + // ** Fails because cannot resolve ENS name to the expected address ** it('user can add watch account with valid ENS name', async function () { await withFixtures( { From 74b62a196c1569c3e572927bce2d2413fbe1beb1 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Mon, 19 Aug 2024 20:02:23 -0400 Subject: [PATCH 29/35] feat: finished adding e2e test cases for account-watcher --- .../e2e/accounts/create-watch-account.spec.ts | 319 ++++++++++++++++-- 1 file changed, 283 insertions(+), 36 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index b2c960e14a16..544cf0edeaf2 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -1,20 +1,25 @@ import { Suite } from 'mocha'; import FixtureBuilder from '../fixture-builder'; -import { multipleGanacheOptions, unlockWallet, withFixtures } from '../helpers'; +import { defaultGanacheOptions, unlockWallet, withFixtures } from '../helpers'; import { Driver } from '../webdriver/driver'; -const eoaAddress = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; -const ensName = 'vitalik.eth'; +const ACCOUNT_1 = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1'; +const EOA_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; +const SHORTENED_EOA_ADDRESS = '0xd8dA6...96045'; +const DEFAULT_WATCHED_ACCOUNT_NAME = 'Watched Account 1'; /** - * Starts the flow to create a watch account. + * Start the flow to create a watch account by clicking the account menu and selecting the option to add a watch account. * * @param driver - The WebDriver instance used to control the browser. - * @returns A promise that resolves when the setup steps are complete. + * @param unlockWalletFirst - Whether to unlock the wallet before starting the flow. */ -async function startCreateWatchAccountFlow(driver: Driver): Promise { - await unlockWallet(driver); +async function startCreateWatchAccountFlow( + driver: Driver, + unlockWalletFirst: boolean = true, +): Promise { + if (unlockWalletFirst) await unlockWallet(driver); await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( @@ -25,8 +30,42 @@ async function startCreateWatchAccountFlow(driver: Driver): Promise { ); } +/** + * Watches an EOA address. + * + * @param driver - The WebDriver instance used to control the browser. + * @param unlockWallet - Whether to unlock the wallet before watching the address. + * @param address - The EOA address to watch. + */ +async function watchEoaAddress( + driver: Driver, + unlockWallet: boolean = true, + address: string = EOA_ADDRESS, +): Promise { + await startCreateWatchAccountFlow(driver, unlockWallet); + await driver.fill( + '[placeholder="Enter a public address or ENS name"]', + address, + ); + await driver.clickElement({ text: 'Watch account', tag: 'button' }); + await driver.clickElement('[data-testid="submit-add-account-with-name"]'); +} + +/** + * Removes the selected account. + * + * @param driver - The WebDriver instance used to control the browser. + */ +async function removeSelectedAccount(driver: Driver): Promise { + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', + ); + await driver.clickElement('[data-testid="account-list-menu-remove"]'); + await driver.clickElement({ text: 'Remove', tag: 'button' }); +} + describe('Account-watcher snap', function (this: Suite) { - // ** Fails because cannot resolve address to expected ENS name ** it('user can add watch account with valid EOA address', async function () { await withFixtures( { @@ -36,34 +75,170 @@ describe('Account-watcher snap', function (this: Suite) { }) .withNetworkControllerOnMainnet() .build(), - ganacheOptions: multipleGanacheOptions, + ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { - // start the add watch account flow and switch to dialog window - await startCreateWatchAccountFlow(driver); + // watch EOA address + await watchEoaAddress(driver); - // fill in the address and click the watch account button - await driver.fill( - '[placeholder="Enter a public address or ENS name"]', - eoaAddress, + // new account should be displayed in the account list + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.findElement({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + }, + ); + }); + + it("'Send' 'Swap' and 'Bridge' buttons are disabled for watch accounts", async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch EOA address + await watchEoaAddress(driver); + + // 'Send' button should be disabled + await driver.findElement('[data-testid="eth-overview-send"][disabled]'); + await driver.findElement( + '[data-testid="eth-overview-send"].icon-button--disabled', + ); + + // 'Swap' button should be disabled + await driver.findElement( + '[data-testid="token-overview-button-swap"][disabled]', + ); + await driver.findElement( + '[data-testid="token-overview-button-swap"].icon-button--disabled', + ); + + // 'Bridge' button should be disabled + await driver.findElement( + '[data-testid="eth-overview-bridge"][disabled]', + ); + await driver.findElement( + '[data-testid="eth-overview-bridge"].icon-button--disabled', + ); + + // Check tooltips for disabled buttons + await driver.findElement( + '.icon-button--disabled [data-tooltipped][data-original-title="Not supported with this account."]', ); - await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // click the add account button on the naming screen + }, + ); + }); + + const invalidInputTests = [ + { + input: 'd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', + message: 'Invalid input', + description: 'missing 0x prefix', + }, + { + input: '0x123ABC', + message: 'Invalid address', + description: 'invalid address', + }, + { + input: 'invalid.eth', + message: 'Invalid ENS name', + description: 'invalid ENS name', + }, + { + input: ACCOUNT_1, + message: + "Unknown snap error: Account address '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1' already exists", + description: 'existing address', + }, + ]; + + invalidInputTests.forEach(({ input, message, description }) => { + it(`handles invalid input: ${description}`, async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await startCreateWatchAccountFlow(driver); + + await driver.fill( + '[placeholder="Enter a public address or ENS name"]', + input, + ); + await driver.clickElement({ text: 'Watch account', tag: 'button' }); + + // error message should be displayed by the snap + await driver.findElement({ + css: '.snap-ui-renderer__text', + text: message, + }); + }, + ); + }); + }); + + it('user cannot input private key of watched address', async function () { + const PRIVATE_KEY_TWO = + '0xf444f52ea41e3a39586d7069cb8e8233e9f6b9dea9cbb700cce69ae860661cc8'; + const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950'; + + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch EOA address + await watchEoaAddress(driver, true, ACCOUNT_2); + + // import private key of account 2 + await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( - '[data-testid="submit-add-account-with-name"]', + '[data-testid="multichain-account-menu-popover-action-button"]', ); - // check wallet now has the watched account with address resolved + await driver.clickElement({ text: 'Import account', tag: 'button' }); + await driver.findClickableElement('#private-key-box'); + await driver.fill('#private-key-box', PRIVATE_KEY_TWO); + await driver.clickElement( + '[data-testid="import-account-confirm-button"]', + ); + + // error message should be displayed await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: ensName, // shows default unresolved address name "Watched Account 1" + css: '.mm-box--color-error-default', + text: 'KeyringController - The account you are trying to import is a duplicate', }); }, ); }); - // ** Fails because cannot resolve ENS name to the expected address ** - it('user can add watch account with valid ENS name', async function () { + it('Show private key button is not displayed for watch accounts', async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -72,27 +247,99 @@ describe('Account-watcher snap', function (this: Suite) { }) .withNetworkControllerOnMainnet() .build(), - ganacheOptions: multipleGanacheOptions, + ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { - // start the add watch account flow and switch to dialog window - await startCreateWatchAccountFlow(driver); + // watch EOA address + await watchEoaAddress(driver); - // fill in the ENS and click the watch account button - await driver.fill( - '[placeholder="Enter a public address or ENS name"]', - ensName, - ); - await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // click the add account button on the naming screen + // click to view account details await driver.clickElement( - '[data-testid="submit-add-account-with-name"]', + '[data-testid="account-options-menu-button"]', ); - // switch back to the main window + await driver.clickElement('[data-testid="account-list-menu-details"]'); + // show private key button should not be displayed + await driver.assertElementNotPresent({ + css: 'button', + text: 'Show private key', + }); + }, + ); + }); + + it('removes a watch account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch EOA address + await watchEoaAddress(driver); + + // remove the selected watch account + await removeSelectedAccount(driver); + + // account should be removed from the account list + await driver.assertElementNotPresent({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.assertElementNotPresent({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + }, + ); + }); + + it('removes and re-adds a watch account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch EOA address + await watchEoaAddress(driver); + + // remove the selected watch account + await removeSelectedAccount(driver); + + // account should be removed from the account list + await driver.assertElementNotPresent({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.assertElementNotPresent({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + + // re-add the watch account + await watchEoaAddress(driver, false); + + // new account should be displayed in the account list await driver.findElement({ css: '[data-testid="account-menu-icon"]', - text: ensName, + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.findElement({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, }); }, ); From 52c35beaaeaa47811c69b048e93e67b666d9c58c Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 20 Aug 2024 10:22:27 -0400 Subject: [PATCH 30/35] feat: updated test descriptions and comments --- test/e2e/accounts/create-watch-account.spec.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 544cf0edeaf2..72bf2976331e 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -133,7 +133,7 @@ describe('Account-watcher snap', function (this: Suite) { '[data-testid="eth-overview-bridge"].icon-button--disabled', ); - // Check tooltips for disabled buttons + // check tooltips for disabled buttons await driver.findElement( '.icon-button--disabled [data-tooltipped][data-original-title="Not supported with this account."]', ); @@ -159,8 +159,7 @@ describe('Account-watcher snap', function (this: Suite) { }, { input: ACCOUNT_1, - message: - "Unknown snap error: Account address '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1' already exists", + message: `Unknown snap error: Account address '${ACCOUNT_1}' already exists`, description: 'existing address', }, ]; @@ -238,7 +237,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it('Show private key button is not displayed for watch accounts', async function () { + it("'Show private key' button is not displayed for watch accounts", async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -259,7 +258,7 @@ describe('Account-watcher snap', function (this: Suite) { '[data-testid="account-options-menu-button"]', ); await driver.clickElement('[data-testid="account-list-menu-details"]'); - // show private key button should not be displayed + // 'Show private key' button should not be displayed await driver.assertElementNotPresent({ css: 'button', text: 'Show private key', @@ -329,10 +328,10 @@ describe('Account-watcher snap', function (this: Suite) { text: SHORTENED_EOA_ADDRESS, }); - // re-add the watch account + // re-add the same watch account await watchEoaAddress(driver, false); - // new account should be displayed in the account list + // same account should be displayed in the account list await driver.findElement({ css: '[data-testid="account-menu-icon"]', text: DEFAULT_WATCHED_ACCOUNT_NAME, From bfdeca3c6b1f7ee9cba03c424318764932ed48de Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 20 Aug 2024 10:34:31 -0400 Subject: [PATCH 31/35] fix: ACCOUNT_1 address format --- test/e2e/accounts/create-watch-account.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 72bf2976331e..477ebbcf20b4 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -4,7 +4,7 @@ import FixtureBuilder from '../fixture-builder'; import { defaultGanacheOptions, unlockWallet, withFixtures } from '../helpers'; import { Driver } from '../webdriver/driver'; -const ACCOUNT_1 = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1'; +const ACCOUNT_1 = '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1'; const EOA_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; const SHORTENED_EOA_ADDRESS = '0xd8dA6...96045'; const DEFAULT_WATCHED_ACCOUNT_NAME = 'Watched Account 1'; From 166e2fbfd99d1fa11cf404a7f1ce5070a037c99f Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 20 Aug 2024 12:19:24 -0400 Subject: [PATCH 32/35] feat: updated test names to proper format --- test/e2e/accounts/create-watch-account.spec.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 477ebbcf20b4..53c4067de884 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -66,7 +66,7 @@ async function removeSelectedAccount(driver: Driver): Promise { } describe('Account-watcher snap', function (this: Suite) { - it('user can add watch account with valid EOA address', async function () { + it('adds watch account with valid EOA address', async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -95,7 +95,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it("'Send' 'Swap' and 'Bridge' buttons are disabled for watch accounts", async function () { + it("disables 'Send' 'Swap' and 'Bridge' buttons for watch accounts", async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -145,7 +145,7 @@ describe('Account-watcher snap', function (this: Suite) { { input: 'd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', message: 'Invalid input', - description: 'missing 0x prefix', + description: 'address missing 0x prefix', }, { input: '0x123ABC', @@ -196,7 +196,7 @@ describe('Account-watcher snap', function (this: Suite) { }); }); - it('user cannot input private key of watched address', async function () { + it('does not allow user to import private key of watched address', async function () { const PRIVATE_KEY_TWO = '0xf444f52ea41e3a39586d7069cb8e8233e9f6b9dea9cbb700cce69ae860661cc8'; const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950'; @@ -237,7 +237,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it("'Show private key' button is not displayed for watch accounts", async function () { + it("does not display 'Show private key' button for watch accounts", async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -267,7 +267,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it('removes a watch account', async function () { + it('removes a watched account', async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -299,7 +299,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it('removes and re-adds a watch account', async function () { + it('can remove and recreate a watched account', async function () { await withFixtures( { fixtures: new FixtureBuilder() From e1b1b48e67ba0c1028a0f5a1003033b952649ccc Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Tue, 20 Aug 2024 14:08:34 -0400 Subject: [PATCH 33/35] fix: lint --- test/e2e/accounts/create-watch-account.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 53c4067de884..6e9d06daf8d8 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -19,7 +19,9 @@ async function startCreateWatchAccountFlow( driver: Driver, unlockWalletFirst: boolean = true, ): Promise { - if (unlockWalletFirst) await unlockWallet(driver); + if (unlockWalletFirst) { + await unlockWallet(driver); + } await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( @@ -34,15 +36,15 @@ async function startCreateWatchAccountFlow( * Watches an EOA address. * * @param driver - The WebDriver instance used to control the browser. - * @param unlockWallet - Whether to unlock the wallet before watching the address. + * @param unlockWalletFirst - Whether to unlock the wallet before watching the address. * @param address - The EOA address to watch. */ async function watchEoaAddress( driver: Driver, - unlockWallet: boolean = true, + unlockWalletFirst: boolean = true, address: string = EOA_ADDRESS, ): Promise { - await startCreateWatchAccountFlow(driver, unlockWallet); + await startCreateWatchAccountFlow(driver, unlockWalletFirst); await driver.fill( '[placeholder="Enter a public address or ENS name"]', address, From 16dfd8593ee51a2296c40ce069d3e66800c60553 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Wed, 21 Aug 2024 14:05:28 -0400 Subject: [PATCH 34/35] feat: added experimental settings tests --- .../e2e/accounts/create-watch-account.spec.ts | 571 +++++++++++------- 1 file changed, 342 insertions(+), 229 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 6e9d06daf8d8..4c34f313118c 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -1,5 +1,6 @@ +import { strict as assert } from 'assert'; import { Suite } from 'mocha'; - +import messages from '../../../app/_locales/en/messages.json'; import FixtureBuilder from '../fixture-builder'; import { defaultGanacheOptions, unlockWallet, withFixtures } from '../helpers'; import { Driver } from '../webdriver/driver'; @@ -68,106 +69,148 @@ async function removeSelectedAccount(driver: Driver): Promise { } describe('Account-watcher snap', function (this: Suite) { - it('adds watch account with valid EOA address', async function () { - await withFixtures( + describe('Adding watch accounts', function () { + it('adds watch account with valid EOA address', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch an EOA address + await watchEoaAddress(driver); + + // new account should be displayed in the account list + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.findElement({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + }, + ); + }); + + it("disables 'Send' 'Swap' and 'Bridge' buttons for watch accounts", async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch an EOA address + await watchEoaAddress(driver); + + // 'Send' button should be disabled + await driver.findElement( + '[data-testid="eth-overview-send"][disabled]', + ); + await driver.findElement( + '[data-testid="eth-overview-send"].icon-button--disabled', + ); + + // 'Swap' button should be disabled + await driver.findElement( + '[data-testid="token-overview-button-swap"][disabled]', + ); + await driver.findElement( + '[data-testid="token-overview-button-swap"].icon-button--disabled', + ); + + // 'Bridge' button should be disabled + await driver.findElement( + '[data-testid="eth-overview-bridge"][disabled]', + ); + await driver.findElement( + '[data-testid="eth-overview-bridge"].icon-button--disabled', + ); + + // check tooltips for disabled buttons + await driver.findElement( + '.icon-button--disabled [data-tooltipped][data-original-title="Not supported with this account."]', + ); + }, + ); + }); + }); + + describe('Invalid input handling', function () { + const invalidInputTests = [ { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), + input: 'd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', + message: 'Invalid input', + description: 'address missing 0x prefix', }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver); - - // new account should be displayed in the account list - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: DEFAULT_WATCHED_ACCOUNT_NAME, - }); - await driver.findElement({ - css: '.mm-text--ellipsis', - text: SHORTENED_EOA_ADDRESS, - }); + { + input: '0x123ABC', + message: 'Invalid address', + description: 'invalid address', }, - ); - }); - - it("disables 'Send' 'Swap' and 'Bridge' buttons for watch accounts", async function () { - await withFixtures( { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), + input: 'invalid.eth', + message: 'Invalid ENS name', + description: 'invalid ENS name', }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver); - - // 'Send' button should be disabled - await driver.findElement('[data-testid="eth-overview-send"][disabled]'); - await driver.findElement( - '[data-testid="eth-overview-send"].icon-button--disabled', - ); + { + input: ACCOUNT_1, + message: `Unknown snap error: Account address '${ACCOUNT_1}' already exists`, + description: 'existing address', + }, + ]; - // 'Swap' button should be disabled - await driver.findElement( - '[data-testid="token-overview-button-swap"][disabled]', - ); - await driver.findElement( - '[data-testid="token-overview-button-swap"].icon-button--disabled', - ); + invalidInputTests.forEach(({ input, message, description }) => { + it(`handles invalid input: ${description}`, async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await startCreateWatchAccountFlow(driver); - // 'Bridge' button should be disabled - await driver.findElement( - '[data-testid="eth-overview-bridge"][disabled]', - ); - await driver.findElement( - '[data-testid="eth-overview-bridge"].icon-button--disabled', - ); + await driver.fill( + '[placeholder="Enter a public address or ENS name"]', + input, + ); + await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // check tooltips for disabled buttons - await driver.findElement( - '.icon-button--disabled [data-tooltipped][data-original-title="Not supported with this account."]', + // error message should be displayed by the snap + await driver.findElement({ + css: '.snap-ui-renderer__text', + text: message, + }); + }, ); - }, - ); + }); + }); }); - const invalidInputTests = [ - { - input: 'd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', - message: 'Invalid input', - description: 'address missing 0x prefix', - }, - { - input: '0x123ABC', - message: 'Invalid address', - description: 'invalid address', - }, - { - input: 'invalid.eth', - message: 'Invalid ENS name', - description: 'invalid ENS name', - }, - { - input: ACCOUNT_1, - message: `Unknown snap error: Account address '${ACCOUNT_1}' already exists`, - description: 'existing address', - }, - ]; - - invalidInputTests.forEach(({ input, message, description }) => { - it(`handles invalid input: ${description}`, async function () { + describe('Account management', function () { + it('does not allow user to import private key of watched address', async function () { + const PRIVATE_KEY_TWO = + '0xf444f52ea41e3a39586d7069cb8e8233e9f6b9dea9cbb700cce69ae860661cc8'; + const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950'; + await withFixtures( { fixtures: new FixtureBuilder() @@ -180,169 +223,239 @@ describe('Account-watcher snap', function (this: Suite) { title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { - await startCreateWatchAccountFlow(driver); + // watch an EOA address for ACCOUNT_2 + await watchEoaAddress(driver, true, ACCOUNT_2); - await driver.fill( - '[placeholder="Enter a public address or ENS name"]', - input, + // try to import private key of watched ACCOUNT_2 address + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + await driver.clickElement({ text: 'Import account', tag: 'button' }); + await driver.findClickableElement('#private-key-box'); + await driver.fill('#private-key-box', PRIVATE_KEY_TWO); + await driver.clickElement( + '[data-testid="import-account-confirm-button"]', ); - await driver.clickElement({ text: 'Watch account', tag: 'button' }); - // error message should be displayed by the snap + // error message should be displayed await driver.findElement({ - css: '.snap-ui-renderer__text', - text: message, + css: '.mm-box--color-error-default', + text: 'KeyringController - The account you are trying to import is a duplicate', }); }, ); }); - }); - it('does not allow user to import private key of watched address', async function () { - const PRIVATE_KEY_TWO = - '0xf444f52ea41e3a39586d7069cb8e8233e9f6b9dea9cbb700cce69ae860661cc8'; - const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950'; + it("does not display 'Show private key' button for watch accounts", async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch an EOA address + await watchEoaAddress(driver); - await withFixtures( - { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver, true, ACCOUNT_2); - - // import private key of account 2 - await driver.clickElement('[data-testid="account-menu-icon"]'); - await driver.clickElement( - '[data-testid="multichain-account-menu-popover-action-button"]', - ); - await driver.clickElement({ text: 'Import account', tag: 'button' }); - await driver.findClickableElement('#private-key-box'); - await driver.fill('#private-key-box', PRIVATE_KEY_TWO); - await driver.clickElement( - '[data-testid="import-account-confirm-button"]', - ); + // click to view account details + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + await driver.clickElement( + '[data-testid="account-list-menu-details"]', + ); + // 'Show private key' button should not be displayed + await driver.assertElementNotPresent({ + css: 'button', + text: 'Show private key', + }); + }, + ); + }); - // error message should be displayed - await driver.findElement({ - css: '.mm-box--color-error-default', - text: 'KeyringController - The account you are trying to import is a duplicate', - }); - }, - ); - }); + it('removes a watched account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch an EOA address + await watchEoaAddress(driver); - it("does not display 'Show private key' button for watch accounts", async function () { - await withFixtures( - { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver); + // remove the selected watched account + await removeSelectedAccount(driver); - // click to view account details - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - await driver.clickElement('[data-testid="account-list-menu-details"]'); - // 'Show private key' button should not be displayed - await driver.assertElementNotPresent({ - css: 'button', - text: 'Show private key', - }); - }, - ); - }); + // account should be removed from the account list + await driver.assertElementNotPresent({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.assertElementNotPresent({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + }, + ); + }); - it('removes a watched account', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver); + it('can remove and recreate a watched account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + watchEthereumAccountEnabled: true, + }) + .withNetworkControllerOnMainnet() + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + // watch an EOA address + await watchEoaAddress(driver); - // remove the selected watch account - await removeSelectedAccount(driver); + // remove the selected watched account + await removeSelectedAccount(driver); - // account should be removed from the account list - await driver.assertElementNotPresent({ - css: '[data-testid="account-menu-icon"]', - text: DEFAULT_WATCHED_ACCOUNT_NAME, - }); - await driver.assertElementNotPresent({ - css: '.mm-text--ellipsis', - text: SHORTENED_EOA_ADDRESS, - }); - }, - ); + // account should be removed from the account list + await driver.assertElementNotPresent({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.assertElementNotPresent({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + + // watch the same EOA address again + await watchEoaAddress(driver, false); + + // same account should be displayed in the account list + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: DEFAULT_WATCHED_ACCOUNT_NAME, + }); + await driver.findElement({ + css: '.mm-text--ellipsis', + text: SHORTENED_EOA_ADDRESS, + }); + }, + ); + }); }); - it('can remove and recreate a watched account', async function () { - await withFixtures( - { - fixtures: new FixtureBuilder() - .withPreferencesControllerAndFeatureFlag({ - watchEthereumAccountEnabled: true, - }) - .withNetworkControllerOnMainnet() - .build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - // watch EOA address - await watchEoaAddress(driver); + describe('Experimental toggle', function () { + const navigateToExperimentalSettings = async (driver: Driver) => { + await driver.clickElement('[data-testid="account-options-menu-button"]'); + await driver.clickElement({ text: 'Settings', tag: 'div' }); + await driver.clickElement({ text: 'Experimental', tag: 'div' }); + await driver.waitForSelector({ + text: messages.watchEthereumAccountsToggle.message, + tag: 'span', + }); + }; - // remove the selected watch account - await removeSelectedAccount(driver); + const getToggleState = async (driver: Driver): Promise => { + const toggleInput = await driver.findElement( + '[data-testid="watch-account-toggle"]', + ); + return toggleInput.isSelected(); + }; - // account should be removed from the account list - await driver.assertElementNotPresent({ - css: '[data-testid="account-menu-icon"]', - text: DEFAULT_WATCHED_ACCOUNT_NAME, + const toggleWatchAccountOptionAndCloseSettings = async (driver: Driver) => { + await driver.clickElement('[data-testid="watch-account-toggle-div"]'); + await driver.clickElement('button[aria-label="Close"]'); + }; + + const verifyWatchAccountOptionAndCloseMenu = async ( + driver: Driver, + shouldBePresent: boolean, + ) => { + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + if (shouldBePresent) { + await driver.waitForSelector({ + text: messages.addEthereumWatchOnlyAccount.message, + tag: 'button', }); + } else { await driver.assertElementNotPresent({ - css: '.mm-text--ellipsis', - text: SHORTENED_EOA_ADDRESS, + text: messages.addEthereumWatchOnlyAccount.message, + tag: 'button', }); + } + await driver.clickElement('button[aria-label="Close"]'); + }; - // re-add the same watch account - await watchEoaAddress(driver, false); + it("will show the 'Watch an Ethereum account (Beta)' option when setting is enabled", async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + await navigateToExperimentalSettings(driver); - // same account should be displayed in the account list - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: DEFAULT_WATCHED_ACCOUNT_NAME, - }); - await driver.findElement({ - css: '.mm-text--ellipsis', - text: SHORTENED_EOA_ADDRESS, - }); - }, - ); + // verify toggle is off by default + assert.equal( + await getToggleState(driver), + false, + 'Toggle should be off by default', + ); + + // enable the toggle + await toggleWatchAccountOptionAndCloseSettings(driver); + + // verify the 'Watch and Ethereum account (Beta)' option is available + await verifyWatchAccountOptionAndCloseMenu(driver, true); + }, + ); + }); + + it('disables and then re-enables the toggle and the option to add a watch-only account behaves as expected', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }) => { + await unlockWallet(driver); + await navigateToExperimentalSettings(driver); + + // enable the toggle + await toggleWatchAccountOptionAndCloseSettings(driver); + + // verify the 'Watch and Ethereum account (Beta)' option is available + await verifyWatchAccountOptionAndCloseMenu(driver, true); + + // navigate back to experimental settings + await navigateToExperimentalSettings(driver); + + // disable the toggle + await toggleWatchAccountOptionAndCloseSettings(driver); + + // verify the 'Watch and Ethereum account (Beta)' option is not available + await verifyWatchAccountOptionAndCloseMenu(driver, false); + }, + ); + }); }); }); From 8ea634493493a9ef7e33ba486333ee424ed51e26 Mon Sep 17 00:00:00 2001 From: Kate Johnson Date: Wed, 21 Aug 2024 14:11:43 -0400 Subject: [PATCH 35/35] feat: updated test descriptions --- test/e2e/accounts/create-watch-account.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/accounts/create-watch-account.spec.ts b/test/e2e/accounts/create-watch-account.spec.ts index 4c34f313118c..75be806a221c 100644 --- a/test/e2e/accounts/create-watch-account.spec.ts +++ b/test/e2e/accounts/create-watch-account.spec.ts @@ -69,7 +69,7 @@ async function removeSelectedAccount(driver: Driver): Promise { } describe('Account-watcher snap', function (this: Suite) { - describe('Adding watch accounts', function () { + describe('Adding watched accounts', function () { it('adds watch account with valid EOA address', async function () { await withFixtures( { @@ -429,7 +429,7 @@ describe('Account-watcher snap', function (this: Suite) { ); }); - it('disables and then re-enables the toggle and the option to add a watch-only account behaves as expected', async function () { + it('enables and then disables the toggle and the option to add a watch-only account behaves as expected', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(),