From 7d62a0bfdd8d6243bcf390429fd799110a6a718e Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Fri, 5 May 2023 19:48:35 +0000 Subject: [PATCH 01/19] Version v10.31.0 --- CHANGELOG.md | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff018c396fdc..1cf21ebf4d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,180 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.31.0] +### Uncategorized +- Fix build types not overriding the manifest ([#19027](https://github.com/MetaMask/metamask-extension/pull/19027)) +- Bundle size reduction: Upgrading ethereumjs/tx and ethereumjs/common ([#18302](https://github.com/MetaMask/metamask-extension/pull/18302)) +- Master sync PR following v10.30.0 and v10.30.1 ([#19026](https://github.com/MetaMask/metamask-extension/pull/19026)) +- Fix #18984 - UX: Multichain - Network connection fixes ([#19000](https://github.com/MetaMask/metamask-extension/pull/19000)) +- [MMI] Applied code fencing in transactions and pending tx tracker controllers ([#17909](https://github.com/MetaMask/metamask-extension/pull/17909)) +- chore: refactor connect to dapp action in e2e ([#19015](https://github.com/MetaMask/metamask-extension/pull/19015)) +- Part of #18714: Replacing Typography consts with enums ([#19013](https://github.com/MetaMask/metamask-extension/pull/19013)) +- [MMI] Added compliance details modal and compliance details component ([#18118](https://github.com/MetaMask/metamask-extension/pull/18118)) +- Use core signature controller ([#18654](https://github.com/MetaMask/metamask-extension/pull/18654)) +- Merge branch 'develop' into master-sync +- Part of #17670: Replace Typography with Text component in smart-transaction-status.js ([#18743](https://github.com/MetaMask/metamask-extension/pull/18743)) +- Part of #17670 Replace Typography with Text component for 4 files. ([#18793](https://github.com/MetaMask/metamask-extension/pull/18793)) +- Update interactive-replacement-token-modal.js ([#19003](https://github.com/MetaMask/metamask-extension/pull/19003)) +- [MMI] Added code fencing in account details modal and selected accounts ([#18070](https://github.com/MetaMask/metamask-extension/pull/18070)) +- [FLASK] Don't show the title on Install/Update when it's loading ([#19012](https://github.com/MetaMask/metamask-extension/pull/19012)) +- UX Multichain: Fixed UI updates for header ([#19006](https://github.com/MetaMask/metamask-extension/pull/19006)) +- Update CODEOWNERS: remove requirement for supply-chain team to approv… ([#19014](https://github.com/MetaMask/metamask-extension/pull/19014)) +- UX: Multichain: Focus on test networks when setting is flipped on ([#18996](https://github.com/MetaMask/metamask-extension/pull/18996)) +- Update CODEOWNERS ([#19007](https://github.com/MetaMask/metamask-extension/pull/19007)) +- feature(17946): implement mv3 e2e for popup consistency after service worker restarted ([#19010](https://github.com/MetaMask/metamask-extension/pull/19010)) +- Changes in blockaid texts ([#19001](https://github.com/MetaMask/metamask-extension/pull/19001)) +- Part of #17670 & #18714: Replace Typography with Text component: token-allowance.js ([#18742](https://github.com/MetaMask/metamask-extension/pull/18742)) +- clean up and adds a code fence ([#19005](https://github.com/MetaMask/metamask-extension/pull/19005)) +- Fix #18990 - UX: Multichain - Copy Address Fixes ([#18993](https://github.com/MetaMask/metamask-extension/pull/18993)) +- eth_sign toggle Update in advanced settings ([#18848](https://github.com/MetaMask/metamask-extension/pull/18848)) +- e2e test for action metrics ([#18347](https://github.com/MetaMask/metamask-extension/pull/18347)) +- Migrates avatar base to TypeScript ([#18494](https://github.com/MetaMask/metamask-extension/pull/18494)) +- devDeps: pretty-error@2.1.1->2.1.2 ([#18868](https://github.com/MetaMask/metamask-extension/pull/18868)) +- Fix popover hiding ([#18843](https://github.com/MetaMask/metamask-extension/pull/18843)) +- Ensure we can successfully create prod builds with specific types ([#18991](https://github.com/MetaMask/metamask-extension/pull/18991)) +- UX: Multichain: Implement Account Details Popover ([#18811](https://github.com/MetaMask/metamask-extension/pull/18811)) +- UX Multichain: Account List Search Fix ([#18963](https://github.com/MetaMask/metamask-extension/pull/18963)) +- removed top border from list item ([#18959](https://github.com/MetaMask/metamask-extension/pull/18959)) +- UX Multichain: Fixed NaN USD issue under Eth when using Fiat ([#18981](https://github.com/MetaMask/metamask-extension/pull/18981)) +- Feat/srp metrics ([#18015](https://github.com/MetaMask/metamask-extension/pull/18015)) +- add scuttle exceptions for JSON and Date ([#18989](https://github.com/MetaMask/metamask-extension/pull/18989)) +- limit connections ([#18355](https://github.com/MetaMask/metamask-extension/pull/18355)) +- [MMI] Don't group transactions by nonce if they are custodial Tx ([#18982](https://github.com/MetaMask/metamask-extension/pull/18982)) +- adds custody page route to account routes ([#18985](https://github.com/MetaMask/metamask-extension/pull/18985)) +- Fixes the cancel-speedup-popover.js ([#18948](https://github.com/MetaMask/metamask-extension/pull/18948)) +- Part of #17670: Replace Typography with Text component in beta-header/index.js ([#18964](https://github.com/MetaMask/metamask-extension/pull/18964)) +- Delete two unused selectors ([#18904](https://github.com/MetaMask/metamask-extension/pull/18904)) +- Update messages.json ([#18897](https://github.com/MetaMask/metamask-extension/pull/18897)) +- Fixing broken responsive box background color prop and color fix ([#18978](https://github.com/MetaMask/metamask-extension/pull/18978)) +- Part of #17670: Replace Typography with Text component in: detected-token-values.js ([#18977](https://github.com/MetaMask/metamask-extension/pull/18977)) +- Use separate versions for Flask and Stable snaps ([#18875](https://github.com/MetaMask/metamask-extension/pull/18875)) +- fix ff diff generation ([#18824](https://github.com/MetaMask/metamask-extension/pull/18824)) +- fix: prevent cancel and speedup transactions to call accept approval ([#18846](https://github.com/MetaMask/metamask-extension/pull/18846)) +- [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) +- Clean up some code fencing around snaps ([#18802](https://github.com/MetaMask/metamask-extension/pull/18802)) +- UX: Multichain: Add maximum width for network picker in full screen mode ([#18879](https://github.com/MetaMask/metamask-extension/pull/18879)) +- UX: Multichain: Provide localization for the network menu ([#18880](https://github.com/MetaMask/metamask-extension/pull/18880)) +- Rename `provider` to `providerConfig` ([#18907](https://github.com/MetaMask/metamask-extension/pull/18907)) +- Bump Circle CI docker image ([#18914](https://github.com/MetaMask/metamask-extension/pull/18914)) +- Improving code formatting in component-library readme ([#18910](https://github.com/MetaMask/metamask-extension/pull/18910)) +- Fence snaps endowments and permissions for stable/flask ([#18847](https://github.com/MetaMask/metamask-extension/pull/18847)) +- Expand usage of `getProviderConfig` selector ([#18906](https://github.com/MetaMask/metamask-extension/pull/18906)) +- Discontinue use of deleted getProductionConfig function ([#18900](https://github.com/MetaMask/metamask-extension/pull/18900)) +- Simplify network controller unit test setup ([#18901](https://github.com/MetaMask/metamask-extension/pull/18901)) +- Adding deprecation notice to old Button component ([#18908](https://github.com/MetaMask/metamask-extension/pull/18908)) +- Part of #17670: Replace Typography with Text component for 'review-spending-cap' & 'tooltip.stories'. ([#18839](https://github.com/MetaMask/metamask-extension/pull/18839)) +- Transaction cleanup and fix TransactionDetailItem key not unique bug ([#18899](https://github.com/MetaMask/metamask-extension/pull/18899)) +- Part of #17670 Replace Typography with Text component in: signature-request-siwe-tag\index.js ([#18898](https://github.com/MetaMask/metamask-extension/pull/18898)) +- Part of #17670 , #18714 & #18651 for 3 files. ([#18752](https://github.com/MetaMask/metamask-extension/pull/18752)) +- Update pin-extension.js ([#18877](https://github.com/MetaMask/metamask-extension/pull/18877)) +- Part of #17670 Replace Typography with Text component in: nft-default-image.js ([#18894](https://github.com/MetaMask/metamask-extension/pull/18894)) +- Refactor provider config selector ([#18905](https://github.com/MetaMask/metamask-extension/pull/18905)) +- Show gas warning for legacy networks also ([#18871](https://github.com/MetaMask/metamask-extension/pull/18871)) +- Added code fences ([#18872](https://github.com/MetaMask/metamask-extension/pull/18872)) +- Part of #17670: Replace Typography with Text component for 11 files. ([#18837](https://github.com/MetaMask/metamask-extension/pull/18837)) +- Adding new icons ([#18870](https://github.com/MetaMask/metamask-extension/pull/18870)) +- Consistent message for third party requests across screens ([#18873](https://github.com/MetaMask/metamask-extension/pull/18873)) +- UX: Multichain: Set a maximum width on the network picker ([#18731](https://github.com/MetaMask/metamask-extension/pull/18731)) +- Terms of use e2e ([#18861](https://github.com/MetaMask/metamask-extension/pull/18861)) +- E2E: update selenium webdriver ([#18854](https://github.com/MetaMask/metamask-extension/pull/18854)) +- fix(18709): fix error when switching to linea testnet using wallet_sw… ([#18710](https://github.com/MetaMask/metamask-extension/pull/18710)) +- [MMI] Adds custodian icon next to metafox ([#18851](https://github.com/MetaMask/metamask-extension/pull/18851)) +- [MMI] Add the custody status text in the transaction status ([#18797](https://github.com/MetaMask/metamask-extension/pull/18797)) +- fix: remove firefox build for beta ([#18874](https://github.com/MetaMask/metamask-extension/pull/18874)) +- [MMI] adds some constants and necessary routes ([#17868](https://github.com/MetaMask/metamask-extension/pull/17868)) +- [MMI] Added confirm-remove-jwt component ([#18186](https://github.com/MetaMask/metamask-extension/pull/18186)) +- Fix in approve header to show correct account name ([#18849](https://github.com/MetaMask/metamask-extension/pull/18849)) +- deprecation notice ([#18859](https://github.com/MetaMask/metamask-extension/pull/18859)) +- devDeps: eslint@8.14.0,8.20.0->8.36.0 ([#18748](https://github.com/MetaMask/metamask-extension/pull/18748)) +- Adding price checker deactivation for Optimism ([#18833](https://github.com/MetaMask/metamask-extension/pull/18833)) +- Part of #17670: Replace Typography with Text component in RecoveryPhraseReminder ([#18639](https://github.com/MetaMask/metamask-extension/pull/18639)) +- Add snaps entries to CODEOWNERS ([#18825](https://github.com/MetaMask/metamask-extension/pull/18825)) +- Ux Multichain: Hide search input for single account ([#18798](https://github.com/MetaMask/metamask-extension/pull/18798)) +- UX: Multichain: Analytics ([#18674](https://github.com/MetaMask/metamask-extension/pull/18674)) +- update ses@0.18.4 ([#17521](https://github.com/MetaMask/metamask-extension/pull/17521)) +- [e2e] test-dapp update to `v6.0.0` ([#18844](https://github.com/MetaMask/metamask-extension/pull/18844)) +- Return state when calling EncryptionPublicKeyController.cancelEncryptionPublicKey ([#18845](https://github.com/MetaMask/metamask-extension/pull/18845)) +- [MMI] custody page component ([#18688](https://github.com/MetaMask/metamask-extension/pull/18688)) +- Update Snaps icon in settings search and fix missing icon ([#18803](https://github.com/MetaMask/metamask-extension/pull/18803)) +- [MMI] Add interactive-replacement-token-page ([#18683](https://github.com/MetaMask/metamask-extension/pull/18683)) +- Fix for wrong type being assigned to the transaction ([#18818](https://github.com/MetaMask/metamask-extension/pull/18818)) +- locales/ko: Fix some mistranslation and typo ([#18799](https://github.com/MetaMask/metamask-extension/pull/18799)) +- Strong tag support in Text component ([#18816](https://github.com/MetaMask/metamask-extension/pull/18816)) +- Update Button prop name type to variant ([#18774](https://github.com/MetaMask/metamask-extension/pull/18774)) +- Part of #17670 for file: detected-token-ignored-popover.js ([#18738](https://github.com/MetaMask/metamask-extension/pull/18738)) +- Update knobs to control: MetamaskTemplateRenderer ([#18677](https://github.com/MetaMask/metamask-extension/pull/18677)) +- devDeps: bumps source-map related dependencies ([#18830](https://github.com/MetaMask/metamask-extension/pull/18830)) +- devDeps: bump @storybook/* ([#18832](https://github.com/MetaMask/metamask-extension/pull/18832)) +- Consume Decrypt Message Manager from @metamask/message-manager ([#18379](https://github.com/MetaMask/metamask-extension/pull/18379)) +- Fix mv3 beta build ([#18690](https://github.com/MetaMask/metamask-extension/pull/18690)) +- UX: Remove Goerli buy link and disable button ([#18137](https://github.com/MetaMask/metamask-extension/pull/18137)) +- UX: Multichain: Fix Network Picker when Test Networks Disabled ([#18694](https://github.com/MetaMask/metamask-extension/pull/18694)) +- UX: Multichain: Focus on account search when menu appears ([#18705](https://github.com/MetaMask/metamask-extension/pull/18705)) +- deps: bump json5, loader-utils, minimist ([#18733](https://github.com/MetaMask/metamask-extension/pull/18733)) +- Unbreak CI checks ([#18813](https://github.com/MetaMask/metamask-extension/pull/18813)) +- Improve logging at build-time ([#18780](https://github.com/MetaMask/metamask-extension/pull/18780)) +- Enable editing L2 gas on optimism ([#18217](https://github.com/MetaMask/metamask-extension/pull/18217)) +- Adding ModalHeader component and updating PopoverHeader stories ([#18311](https://github.com/MetaMask/metamask-extension/pull/18311)) +- Policy formatting issue ([#18810](https://github.com/MetaMask/metamask-extension/pull/18810)) +- UX: Multichain: App header cleanups ([#18627](https://github.com/MetaMask/metamask-extension/pull/18627)) +- UX: Multichain: Use correct blockie or jazzicon in the account menu ([#18782](https://github.com/MetaMask/metamask-extension/pull/18782)) +- Part of #17670: Replace Typography with Text component for networks-list.js ([#18754](https://github.com/MetaMask/metamask-extension/pull/18754)) +- [FLASK] Expanded Snap authorship ([#18775](https://github.com/MetaMask/metamask-extension/pull/18775)) +- Fix diff generation for fitness functions ([#18508](https://github.com/MetaMask/metamask-extension/pull/18508)) +- deps: replace gulp-dart-sass with gulp-sass. ([#16302](https://github.com/MetaMask/metamask-extension/pull/16302)) +- feat: add yaml feature management ([#18125](https://github.com/MetaMask/metamask-extension/pull/18125)) +- [MMI] Created custody-confirm-link-modal component ([#18632](https://github.com/MetaMask/metamask-extension/pull/18632)) +- Update keystone links ([#18792](https://github.com/MetaMask/metamask-extension/pull/18792)) +- Part of #17670 for file custom-spending-cap-tooltip.js ([#18686](https://github.com/MetaMask/metamask-extension/pull/18686)) +- Part of #17670 for file network-statistics.js ([#18644](https://github.com/MetaMask/metamask-extension/pull/18644)) +- Update slippage-buttons.js ([#18745](https://github.com/MetaMask/metamask-extension/pull/18745)) +- Update fee-card.js ([#18746](https://github.com/MetaMask/metamask-extension/pull/18746)) +- Update settings-tab.component.js ([#18753](https://github.com/MetaMask/metamask-extension/pull/18753)) +- Worked on #17670 & #18714 for 7 files. ([#18789](https://github.com/MetaMask/metamask-extension/pull/18789)) +- [FLASK] Update permissions to use IconName and IconSize design system enum ([#18786](https://github.com/MetaMask/metamask-extension/pull/18786)) +- [MMI] Adds a warning if message signing account mismatches selected account ([#18659](https://github.com/MetaMask/metamask-extension/pull/18659)) +- Approvals selector refactor ([#18664](https://github.com/MetaMask/metamask-extension/pull/18664)) +- Use SIWE origin validation logic from @metamask/controller-utils ([#18518](https://github.com/MetaMask/metamask-extension/pull/18518)) +- devDeps: security updates roundup ([#18739](https://github.com/MetaMask/metamask-extension/pull/18739)) +- Revert "Shallow git clone (#18491)" ([#18491](https://github.com/MetaMask/metamask-extension/pull/18491)) +- Unit tests for various modals ([#18115](https://github.com/MetaMask/metamask-extension/pull/18115)) +- Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) +- Only build LavaMoat runtime once ([#18768](https://github.com/MetaMask/metamask-extension/pull/18768)) +- Some linting issues in the file custom spending cap tooltip.js ([#18687](https://github.com/MetaMask/metamask-extension/pull/18687)) +- Fix ICON_NAMES error for snaps settings ([#18784](https://github.com/MetaMask/metamask-extension/pull/18784)) +- Prevent new JS files in shared folder ([#17737](https://github.com/MetaMask/metamask-extension/pull/17737)) +- update icons to ts enum version ([#18698](https://github.com/MetaMask/metamask-extension/pull/18698)) +- Shallow git clone ([#18491](https://github.com/MetaMask/metamask-extension/pull/18491)) +- deps: bump serve-handler@6.1.3->6.1.5; minimatch@3.0.4->3.1.2 ([#18734](https://github.com/MetaMask/metamask-extension/pull/18734)) +- Bump `@metamask/slip44` to `3.0.0` ([#18773](https://github.com/MetaMask/metamask-extension/pull/18773)) +- [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719)) +- [FLASK] Add updated version of the Snaps settings UI ([#18438](https://github.com/MetaMask/metamask-extension/pull/18438)) +- Part of #17670: Replace Typography with Text component ([#18569](https://github.com/MetaMask/metamask-extension/pull/18569)) +- Part of 17670: Replace Typography with Text in detected-token-address.js ([#18435](https://github.com/MetaMask/metamask-extension/pull/18435)) +- Update knobs to controls in storybook: SelectQuotePopover ([#18671](https://github.com/MetaMask/metamask-extension/pull/18671)) +- Sign-in With Ethereum SIWE cleanup ([#18230](https://github.com/MetaMask/metamask-extension/pull/18230)) +- update ethereum provider endowment weight level and update install warning copy ([#18732](https://github.com/MetaMask/metamask-extension/pull/18732)) +- [MMI] Add-compliance-details component ([#18575](https://github.com/MetaMask/metamask-extension/pull/18575)) +- Updating Avatar components to forward refs ([#18678](https://github.com/MetaMask/metamask-extension/pull/18678)) +- Add "Do Not Merge" GH Action to block PRs with "DO-NOT-MERGE" label ([#18724](https://github.com/MetaMask/metamask-extension/pull/18724)) +- UX Multichain: Added product tour component ([#18571](https://github.com/MetaMask/metamask-extension/pull/18571)) +- Update outdated browser versions ([#18721](https://github.com/MetaMask/metamask-extension/pull/18721)) +- [MMI] Add transaction-failed functional component ([#18623](https://github.com/MetaMask/metamask-extension/pull/18623)) +- UX: Multichain: Network Menu: Set Focus on Selected Network ([#18706](https://github.com/MetaMask/metamask-extension/pull/18706)) +- TransactionUtils: update determineTransactionType method / contractInteraction support ([#18652](https://github.com/MetaMask/metamask-extension/pull/18652)) +- added new snaps wasm test ([#18696](https://github.com/MetaMask/metamask-extension/pull/18696)) +- Stop transpiling ES2020 libraries ([#18713](https://github.com/MetaMask/metamask-extension/pull/18713)) +- [MMI] update eth overview component ([#18625](https://github.com/MetaMask/metamask-extension/pull/18625)) +- [MMI] adds institutional duck to mmi folder ([#18578](https://github.com/MetaMask/metamask-extension/pull/18578)) +- [MMI] interactive replacement token notification ([#18620](https://github.com/MetaMask/metamask-extension/pull/18620)) +- Update tokens controller ([#18459](https://github.com/MetaMask/metamask-extension/pull/18459)) +- Fixing issue with gasLimit in transaction being 0 ([#18682](https://github.com/MetaMask/metamask-extension/pull/18682)) +- 17873 ledger instruction banner ([#17937](https://github.com/MetaMask/metamask-extension/pull/17937)) +- Show Bridge button in TokenOverview component ([#18630](https://github.com/MetaMask/metamask-extension/pull/18630)) +- deps/security: vm2@3.9.16->3.9.17 ([#18707](https://github.com/MetaMask/metamask-extension/pull/18707)) +- Confirm recovery phrase onboarding unit test ([#18250](https://github.com/MetaMask/metamask-extension/pull/18250)) + ## [10.30.1] ### Fixed - Disable Flask RPC test to fix failing build ([#19011](https://github.com/MetaMask/metamask-extension/pull/19011)) @@ -3711,7 +3885,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.30.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.31.0...HEAD +[10.31.0]: https://github.com/MetaMask/metamask-extension/compare/v10.30.1...v10.31.0 [10.30.1]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...v10.30.1 [10.30.0]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...v10.30.0 [10.29.0]: https://github.com/MetaMask/metamask-extension/compare/v10.28.3...v10.29.0 diff --git a/package.json b/package.json index afaf7c54acff..da342c4b8faf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.30.1", + "version": "10.31.0", "private": true, "repository": { "type": "git", From 4775a46e20c0a6d37c2641bd8d661e0475a94d19 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 16 May 2023 17:24:55 -0230 Subject: [PATCH 02/19] Run yarn:lavamoat auto for v10.31.0 --- lavamoat/build-system/policy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lavamoat/build-system/policy.json b/lavamoat/build-system/policy.json index d5b552bdc5ac..2782e3c962f9 100644 --- a/lavamoat/build-system/policy.json +++ b/lavamoat/build-system/policy.json @@ -7367,7 +7367,7 @@ }, "stylelint>postcss-html>htmlparser2>domutils>dom-serializer": { "packages": { - "stylelint>postcss-html>htmlparser2>domutils>dom-serializer>domelementtype": true, + "stylelint>postcss-html>htmlparser2>domelementtype": true, "stylelint>postcss-html>htmlparser2>entities": true } }, From 6f21e01bebcb35302687c497b30b5905f0fc6bbf Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Wed, 17 May 2023 10:06:06 -0700 Subject: [PATCH 03/19] Update v10.31.0 changelog (#19147) * [skip e2e] Update changelog for v10.31.0 Co-authored-by: Dan J Miller * Update CHANGELOG.md Co-authored-by: Frederik Bolding * Update CHANGELOG.md Co-authored-by: Frederik Bolding * Update CHANGELOG.md Co-authored-by: Frederik Bolding --------- Co-authored-by: Dan J Miller Co-authored-by: Frederik Bolding --- CHANGELOG.md | 190 ++++++--------------------------------------------- 1 file changed, 22 insertions(+), 168 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf21ebf4d79..a76e370c30d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,178 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.31.0] -### Uncategorized -- Fix build types not overriding the manifest ([#19027](https://github.com/MetaMask/metamask-extension/pull/19027)) -- Bundle size reduction: Upgrading ethereumjs/tx and ethereumjs/common ([#18302](https://github.com/MetaMask/metamask-extension/pull/18302)) -- Master sync PR following v10.30.0 and v10.30.1 ([#19026](https://github.com/MetaMask/metamask-extension/pull/19026)) -- Fix #18984 - UX: Multichain - Network connection fixes ([#19000](https://github.com/MetaMask/metamask-extension/pull/19000)) -- [MMI] Applied code fencing in transactions and pending tx tracker controllers ([#17909](https://github.com/MetaMask/metamask-extension/pull/17909)) -- chore: refactor connect to dapp action in e2e ([#19015](https://github.com/MetaMask/metamask-extension/pull/19015)) -- Part of #18714: Replacing Typography consts with enums ([#19013](https://github.com/MetaMask/metamask-extension/pull/19013)) -- [MMI] Added compliance details modal and compliance details component ([#18118](https://github.com/MetaMask/metamask-extension/pull/18118)) -- Use core signature controller ([#18654](https://github.com/MetaMask/metamask-extension/pull/18654)) -- Merge branch 'develop' into master-sync -- Part of #17670: Replace Typography with Text component in smart-transaction-status.js ([#18743](https://github.com/MetaMask/metamask-extension/pull/18743)) -- Part of #17670 Replace Typography with Text component for 4 files. ([#18793](https://github.com/MetaMask/metamask-extension/pull/18793)) -- Update interactive-replacement-token-modal.js ([#19003](https://github.com/MetaMask/metamask-extension/pull/19003)) -- [MMI] Added code fencing in account details modal and selected accounts ([#18070](https://github.com/MetaMask/metamask-extension/pull/18070)) -- [FLASK] Don't show the title on Install/Update when it's loading ([#19012](https://github.com/MetaMask/metamask-extension/pull/19012)) -- UX Multichain: Fixed UI updates for header ([#19006](https://github.com/MetaMask/metamask-extension/pull/19006)) -- Update CODEOWNERS: remove requirement for supply-chain team to approv… ([#19014](https://github.com/MetaMask/metamask-extension/pull/19014)) -- UX: Multichain: Focus on test networks when setting is flipped on ([#18996](https://github.com/MetaMask/metamask-extension/pull/18996)) -- Update CODEOWNERS ([#19007](https://github.com/MetaMask/metamask-extension/pull/19007)) -- feature(17946): implement mv3 e2e for popup consistency after service worker restarted ([#19010](https://github.com/MetaMask/metamask-extension/pull/19010)) -- Changes in blockaid texts ([#19001](https://github.com/MetaMask/metamask-extension/pull/19001)) -- Part of #17670 & #18714: Replace Typography with Text component: token-allowance.js ([#18742](https://github.com/MetaMask/metamask-extension/pull/18742)) -- clean up and adds a code fence ([#19005](https://github.com/MetaMask/metamask-extension/pull/19005)) -- Fix #18990 - UX: Multichain - Copy Address Fixes ([#18993](https://github.com/MetaMask/metamask-extension/pull/18993)) -- eth_sign toggle Update in advanced settings ([#18848](https://github.com/MetaMask/metamask-extension/pull/18848)) -- e2e test for action metrics ([#18347](https://github.com/MetaMask/metamask-extension/pull/18347)) -- Migrates avatar base to TypeScript ([#18494](https://github.com/MetaMask/metamask-extension/pull/18494)) -- devDeps: pretty-error@2.1.1->2.1.2 ([#18868](https://github.com/MetaMask/metamask-extension/pull/18868)) -- Fix popover hiding ([#18843](https://github.com/MetaMask/metamask-extension/pull/18843)) -- Ensure we can successfully create prod builds with specific types ([#18991](https://github.com/MetaMask/metamask-extension/pull/18991)) -- UX: Multichain: Implement Account Details Popover ([#18811](https://github.com/MetaMask/metamask-extension/pull/18811)) -- UX Multichain: Account List Search Fix ([#18963](https://github.com/MetaMask/metamask-extension/pull/18963)) -- removed top border from list item ([#18959](https://github.com/MetaMask/metamask-extension/pull/18959)) -- UX Multichain: Fixed NaN USD issue under Eth when using Fiat ([#18981](https://github.com/MetaMask/metamask-extension/pull/18981)) -- Feat/srp metrics ([#18015](https://github.com/MetaMask/metamask-extension/pull/18015)) -- add scuttle exceptions for JSON and Date ([#18989](https://github.com/MetaMask/metamask-extension/pull/18989)) -- limit connections ([#18355](https://github.com/MetaMask/metamask-extension/pull/18355)) -- [MMI] Don't group transactions by nonce if they are custodial Tx ([#18982](https://github.com/MetaMask/metamask-extension/pull/18982)) -- adds custody page route to account routes ([#18985](https://github.com/MetaMask/metamask-extension/pull/18985)) -- Fixes the cancel-speedup-popover.js ([#18948](https://github.com/MetaMask/metamask-extension/pull/18948)) -- Part of #17670: Replace Typography with Text component in beta-header/index.js ([#18964](https://github.com/MetaMask/metamask-extension/pull/18964)) -- Delete two unused selectors ([#18904](https://github.com/MetaMask/metamask-extension/pull/18904)) -- Update messages.json ([#18897](https://github.com/MetaMask/metamask-extension/pull/18897)) -- Fixing broken responsive box background color prop and color fix ([#18978](https://github.com/MetaMask/metamask-extension/pull/18978)) -- Part of #17670: Replace Typography with Text component in: detected-token-values.js ([#18977](https://github.com/MetaMask/metamask-extension/pull/18977)) -- Use separate versions for Flask and Stable snaps ([#18875](https://github.com/MetaMask/metamask-extension/pull/18875)) -- fix ff diff generation ([#18824](https://github.com/MetaMask/metamask-extension/pull/18824)) -- fix: prevent cancel and speedup transactions to call accept approval ([#18846](https://github.com/MetaMask/metamask-extension/pull/18846)) -- [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) -- Clean up some code fencing around snaps ([#18802](https://github.com/MetaMask/metamask-extension/pull/18802)) -- UX: Multichain: Add maximum width for network picker in full screen mode ([#18879](https://github.com/MetaMask/metamask-extension/pull/18879)) -- UX: Multichain: Provide localization for the network menu ([#18880](https://github.com/MetaMask/metamask-extension/pull/18880)) -- Rename `provider` to `providerConfig` ([#18907](https://github.com/MetaMask/metamask-extension/pull/18907)) -- Bump Circle CI docker image ([#18914](https://github.com/MetaMask/metamask-extension/pull/18914)) -- Improving code formatting in component-library readme ([#18910](https://github.com/MetaMask/metamask-extension/pull/18910)) -- Fence snaps endowments and permissions for stable/flask ([#18847](https://github.com/MetaMask/metamask-extension/pull/18847)) -- Expand usage of `getProviderConfig` selector ([#18906](https://github.com/MetaMask/metamask-extension/pull/18906)) -- Discontinue use of deleted getProductionConfig function ([#18900](https://github.com/MetaMask/metamask-extension/pull/18900)) -- Simplify network controller unit test setup ([#18901](https://github.com/MetaMask/metamask-extension/pull/18901)) -- Adding deprecation notice to old Button component ([#18908](https://github.com/MetaMask/metamask-extension/pull/18908)) -- Part of #17670: Replace Typography with Text component for 'review-spending-cap' & 'tooltip.stories'. ([#18839](https://github.com/MetaMask/metamask-extension/pull/18839)) -- Transaction cleanup and fix TransactionDetailItem key not unique bug ([#18899](https://github.com/MetaMask/metamask-extension/pull/18899)) -- Part of #17670 Replace Typography with Text component in: signature-request-siwe-tag\index.js ([#18898](https://github.com/MetaMask/metamask-extension/pull/18898)) -- Part of #17670 , #18714 & #18651 for 3 files. ([#18752](https://github.com/MetaMask/metamask-extension/pull/18752)) -- Update pin-extension.js ([#18877](https://github.com/MetaMask/metamask-extension/pull/18877)) -- Part of #17670 Replace Typography with Text component in: nft-default-image.js ([#18894](https://github.com/MetaMask/metamask-extension/pull/18894)) -- Refactor provider config selector ([#18905](https://github.com/MetaMask/metamask-extension/pull/18905)) -- Show gas warning for legacy networks also ([#18871](https://github.com/MetaMask/metamask-extension/pull/18871)) -- Added code fences ([#18872](https://github.com/MetaMask/metamask-extension/pull/18872)) -- Part of #17670: Replace Typography with Text component for 11 files. ([#18837](https://github.com/MetaMask/metamask-extension/pull/18837)) -- Adding new icons ([#18870](https://github.com/MetaMask/metamask-extension/pull/18870)) -- Consistent message for third party requests across screens ([#18873](https://github.com/MetaMask/metamask-extension/pull/18873)) -- UX: Multichain: Set a maximum width on the network picker ([#18731](https://github.com/MetaMask/metamask-extension/pull/18731)) -- Terms of use e2e ([#18861](https://github.com/MetaMask/metamask-extension/pull/18861)) -- E2E: update selenium webdriver ([#18854](https://github.com/MetaMask/metamask-extension/pull/18854)) -- fix(18709): fix error when switching to linea testnet using wallet_sw… ([#18710](https://github.com/MetaMask/metamask-extension/pull/18710)) -- [MMI] Adds custodian icon next to metafox ([#18851](https://github.com/MetaMask/metamask-extension/pull/18851)) -- [MMI] Add the custody status text in the transaction status ([#18797](https://github.com/MetaMask/metamask-extension/pull/18797)) -- fix: remove firefox build for beta ([#18874](https://github.com/MetaMask/metamask-extension/pull/18874)) -- [MMI] adds some constants and necessary routes ([#17868](https://github.com/MetaMask/metamask-extension/pull/17868)) -- [MMI] Added confirm-remove-jwt component ([#18186](https://github.com/MetaMask/metamask-extension/pull/18186)) -- Fix in approve header to show correct account name ([#18849](https://github.com/MetaMask/metamask-extension/pull/18849)) -- deprecation notice ([#18859](https://github.com/MetaMask/metamask-extension/pull/18859)) -- devDeps: eslint@8.14.0,8.20.0->8.36.0 ([#18748](https://github.com/MetaMask/metamask-extension/pull/18748)) -- Adding price checker deactivation for Optimism ([#18833](https://github.com/MetaMask/metamask-extension/pull/18833)) -- Part of #17670: Replace Typography with Text component in RecoveryPhraseReminder ([#18639](https://github.com/MetaMask/metamask-extension/pull/18639)) -- Add snaps entries to CODEOWNERS ([#18825](https://github.com/MetaMask/metamask-extension/pull/18825)) -- Ux Multichain: Hide search input for single account ([#18798](https://github.com/MetaMask/metamask-extension/pull/18798)) -- UX: Multichain: Analytics ([#18674](https://github.com/MetaMask/metamask-extension/pull/18674)) -- update ses@0.18.4 ([#17521](https://github.com/MetaMask/metamask-extension/pull/17521)) -- [e2e] test-dapp update to `v6.0.0` ([#18844](https://github.com/MetaMask/metamask-extension/pull/18844)) -- Return state when calling EncryptionPublicKeyController.cancelEncryptionPublicKey ([#18845](https://github.com/MetaMask/metamask-extension/pull/18845)) -- [MMI] custody page component ([#18688](https://github.com/MetaMask/metamask-extension/pull/18688)) -- Update Snaps icon in settings search and fix missing icon ([#18803](https://github.com/MetaMask/metamask-extension/pull/18803)) -- [MMI] Add interactive-replacement-token-page ([#18683](https://github.com/MetaMask/metamask-extension/pull/18683)) +### Added +- Add extra friction to enable eth_sign in advanced settings ([#18848](https://github.com/MetaMask/metamask-extension/pull/18848)) - Fix for wrong type being assigned to the transaction ([#18818](https://github.com/MetaMask/metamask-extension/pull/18818)) -- locales/ko: Fix some mistranslation and typo ([#18799](https://github.com/MetaMask/metamask-extension/pull/18799)) -- Strong tag support in Text component ([#18816](https://github.com/MetaMask/metamask-extension/pull/18816)) -- Update Button prop name type to variant ([#18774](https://github.com/MetaMask/metamask-extension/pull/18774)) -- Part of #17670 for file: detected-token-ignored-popover.js ([#18738](https://github.com/MetaMask/metamask-extension/pull/18738)) -- Update knobs to control: MetamaskTemplateRenderer ([#18677](https://github.com/MetaMask/metamask-extension/pull/18677)) -- devDeps: bumps source-map related dependencies ([#18830](https://github.com/MetaMask/metamask-extension/pull/18830)) -- devDeps: bump @storybook/* ([#18832](https://github.com/MetaMask/metamask-extension/pull/18832)) -- Consume Decrypt Message Manager from @metamask/message-manager ([#18379](https://github.com/MetaMask/metamask-extension/pull/18379)) -- Fix mv3 beta build ([#18690](https://github.com/MetaMask/metamask-extension/pull/18690)) -- UX: Remove Goerli buy link and disable button ([#18137](https://github.com/MetaMask/metamask-extension/pull/18137)) -- UX: Multichain: Fix Network Picker when Test Networks Disabled ([#18694](https://github.com/MetaMask/metamask-extension/pull/18694)) -- UX: Multichain: Focus on account search when menu appears ([#18705](https://github.com/MetaMask/metamask-extension/pull/18705)) -- deps: bump json5, loader-utils, minimist ([#18733](https://github.com/MetaMask/metamask-extension/pull/18733)) -- Unbreak CI checks ([#18813](https://github.com/MetaMask/metamask-extension/pull/18813)) -- Improve logging at build-time ([#18780](https://github.com/MetaMask/metamask-extension/pull/18780)) +- Update Snaps icon in settings search and fix missing icon ([#18803](https://github.com/MetaMask/metamask-extension/pull/18803)) +- Update Korean transactions ([#18799](https://github.com/MetaMask/metamask-extension/pull/18799)) +- Show Bridge button in TokenOverview component ([#18630](https://github.com/MetaMask/metamask-extension/pull/18630)) +- Update trezor-connect to v9. Introduced trezor changes are documented at [trezor-suite](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/CHANGELOG.md). ([#18302](https://github.com/MetaMask/metamask-extension/pull/18302)) + +### Changed +- Adding new icons ([#18870](https://github.com/MetaMask/metamask-extension/pull/18870)) +- Changed Chinese translation for "Average" password strength([#18897](https://github.com/MetaMask/metamask-extension/pull/18897)) +- Update Ledger instruction banner for transactions ([#17937](https://github.com/MetaMask/metamask-extension/pull/17937)) - Enable editing L2 gas on optimism ([#18217](https://github.com/MetaMask/metamask-extension/pull/18217)) -- Adding ModalHeader component and updating PopoverHeader stories ([#18311](https://github.com/MetaMask/metamask-extension/pull/18311)) -- Policy formatting issue ([#18810](https://github.com/MetaMask/metamask-extension/pull/18810)) -- UX: Multichain: App header cleanups ([#18627](https://github.com/MetaMask/metamask-extension/pull/18627)) -- UX: Multichain: Use correct blockie or jazzicon in the account menu ([#18782](https://github.com/MetaMask/metamask-extension/pull/18782)) -- Part of #17670: Replace Typography with Text component for networks-list.js ([#18754](https://github.com/MetaMask/metamask-extension/pull/18754)) -- [FLASK] Expanded Snap authorship ([#18775](https://github.com/MetaMask/metamask-extension/pull/18775)) -- Fix diff generation for fitness functions ([#18508](https://github.com/MetaMask/metamask-extension/pull/18508)) -- deps: replace gulp-dart-sass with gulp-sass. ([#16302](https://github.com/MetaMask/metamask-extension/pull/16302)) -- feat: add yaml feature management ([#18125](https://github.com/MetaMask/metamask-extension/pull/18125)) -- [MMI] Created custody-confirm-link-modal component ([#18632](https://github.com/MetaMask/metamask-extension/pull/18632)) - Update keystone links ([#18792](https://github.com/MetaMask/metamask-extension/pull/18792)) -- Part of #17670 for file custom-spending-cap-tooltip.js ([#18686](https://github.com/MetaMask/metamask-extension/pull/18686)) -- Part of #17670 for file network-statistics.js ([#18644](https://github.com/MetaMask/metamask-extension/pull/18644)) -- Update slippage-buttons.js ([#18745](https://github.com/MetaMask/metamask-extension/pull/18745)) -- Update fee-card.js ([#18746](https://github.com/MetaMask/metamask-extension/pull/18746)) -- Update settings-tab.component.js ([#18753](https://github.com/MetaMask/metamask-extension/pull/18753)) -- Worked on #17670 & #18714 for 7 files. ([#18789](https://github.com/MetaMask/metamask-extension/pull/18789)) -- [FLASK] Update permissions to use IconName and IconSize design system enum ([#18786](https://github.com/MetaMask/metamask-extension/pull/18786)) -- [MMI] Adds a warning if message signing account mismatches selected account ([#18659](https://github.com/MetaMask/metamask-extension/pull/18659)) -- Approvals selector refactor ([#18664](https://github.com/MetaMask/metamask-extension/pull/18664)) -- Use SIWE origin validation logic from @metamask/controller-utils ([#18518](https://github.com/MetaMask/metamask-extension/pull/18518)) -- devDeps: security updates roundup ([#18739](https://github.com/MetaMask/metamask-extension/pull/18739)) -- Revert "Shallow git clone (#18491)" ([#18491](https://github.com/MetaMask/metamask-extension/pull/18491)) -- Unit tests for various modals ([#18115](https://github.com/MetaMask/metamask-extension/pull/18115)) -- Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) -- Only build LavaMoat runtime once ([#18768](https://github.com/MetaMask/metamask-extension/pull/18768)) -- Some linting issues in the file custom spending cap tooltip.js ([#18687](https://github.com/MetaMask/metamask-extension/pull/18687)) -- Fix ICON_NAMES error for snaps settings ([#18784](https://github.com/MetaMask/metamask-extension/pull/18784)) -- Prevent new JS files in shared folder ([#17737](https://github.com/MetaMask/metamask-extension/pull/17737)) -- update icons to ts enum version ([#18698](https://github.com/MetaMask/metamask-extension/pull/18698)) -- Shallow git clone ([#18491](https://github.com/MetaMask/metamask-extension/pull/18491)) -- deps: bump serve-handler@6.1.3->6.1.5; minimatch@3.0.4->3.1.2 ([#18734](https://github.com/MetaMask/metamask-extension/pull/18734)) -- Bump `@metamask/slip44` to `3.0.0` ([#18773](https://github.com/MetaMask/metamask-extension/pull/18773)) +- Remove Goerli buy link and disable button ([#18137](https://github.com/MetaMask/metamask-extension/pull/18137)) +- [FLASK] Don't show the title on Install/Update when it's loading ([#19012](https://github.com/MetaMask/metamask-extension/pull/19012)) +- [FLASK] Add updated version of the Snaps settings UI ([#18438](https://github.com/MetaMask/metamask-extension/pull/18438), ([#18775](https://github.com/MetaMask/metamask-extension/pull/18775))) + +### Fixed +- Fix terms of use popover scroll button hiding when scollbar is at the bottom. ([#18843](https://github.com/MetaMask/metamask-extension/pull/18843)) +- Fix in approve header to show correct account name ([#18849](https://github.com/MetaMask/metamask-extension/pull/18849)) +- Fix error when switching to Linea testnet using wallet_switchEthereumChain ([#18710](https://github.com/MetaMask/metamask-extension/pull/18710)) +- Fix for persistant currency conversion on multi layer transactions when the show balance setting is off ([#18833](https://github.com/MetaMask/metamask-extension/pull/18833)) +- [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) +- [FLASK] Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) - [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719)) -- [FLASK] Add updated version of the Snaps settings UI ([#18438](https://github.com/MetaMask/metamask-extension/pull/18438)) -- Part of #17670: Replace Typography with Text component ([#18569](https://github.com/MetaMask/metamask-extension/pull/18569)) -- Part of 17670: Replace Typography with Text in detected-token-address.js ([#18435](https://github.com/MetaMask/metamask-extension/pull/18435)) -- Update knobs to controls in storybook: SelectQuotePopover ([#18671](https://github.com/MetaMask/metamask-extension/pull/18671)) -- Sign-in With Ethereum SIWE cleanup ([#18230](https://github.com/MetaMask/metamask-extension/pull/18230)) -- update ethereum provider endowment weight level and update install warning copy ([#18732](https://github.com/MetaMask/metamask-extension/pull/18732)) -- [MMI] Add-compliance-details component ([#18575](https://github.com/MetaMask/metamask-extension/pull/18575)) -- Updating Avatar components to forward refs ([#18678](https://github.com/MetaMask/metamask-extension/pull/18678)) -- Add "Do Not Merge" GH Action to block PRs with "DO-NOT-MERGE" label ([#18724](https://github.com/MetaMask/metamask-extension/pull/18724)) -- UX Multichain: Added product tour component ([#18571](https://github.com/MetaMask/metamask-extension/pull/18571)) -- Update outdated browser versions ([#18721](https://github.com/MetaMask/metamask-extension/pull/18721)) -- [MMI] Add transaction-failed functional component ([#18623](https://github.com/MetaMask/metamask-extension/pull/18623)) -- UX: Multichain: Network Menu: Set Focus on Selected Network ([#18706](https://github.com/MetaMask/metamask-extension/pull/18706)) -- TransactionUtils: update determineTransactionType method / contractInteraction support ([#18652](https://github.com/MetaMask/metamask-extension/pull/18652)) -- added new snaps wasm test ([#18696](https://github.com/MetaMask/metamask-extension/pull/18696)) -- Stop transpiling ES2020 libraries ([#18713](https://github.com/MetaMask/metamask-extension/pull/18713)) -- [MMI] update eth overview component ([#18625](https://github.com/MetaMask/metamask-extension/pull/18625)) -- [MMI] adds institutional duck to mmi folder ([#18578](https://github.com/MetaMask/metamask-extension/pull/18578)) -- [MMI] interactive replacement token notification ([#18620](https://github.com/MetaMask/metamask-extension/pull/18620)) -- Update tokens controller ([#18459](https://github.com/MetaMask/metamask-extension/pull/18459)) -- Fixing issue with gasLimit in transaction being 0 ([#18682](https://github.com/MetaMask/metamask-extension/pull/18682)) -- 17873 ledger instruction banner ([#17937](https://github.com/MetaMask/metamask-extension/pull/17937)) -- Show Bridge button in TokenOverview component ([#18630](https://github.com/MetaMask/metamask-extension/pull/18630)) -- deps/security: vm2@3.9.16->3.9.17 ([#18707](https://github.com/MetaMask/metamask-extension/pull/18707)) -- Confirm recovery phrase onboarding unit test ([#18250](https://github.com/MetaMask/metamask-extension/pull/18250)) ## [10.30.1] ### Fixed From 24c564a4c334fa4e900462b909e2e0af94de2a5c Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 19 May 2023 14:20:22 -0230 Subject: [PATCH 04/19] Changelog lint fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea568167562..2b892ad03208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) - [FLASK] Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) - [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719)) + ## [10.30.4] ### Fixed - Fix error upon submitting multiple requests that require approval ([#19050](https://github.com/MetaMask/metamask-extension/pull/19050)) From d746b58c90c8c5d7c6972e19b8a46f5cd8ce5a54 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 19 May 2023 16:31:32 -0230 Subject: [PATCH 05/19] Version v10.31.0-beta.0 From d2dba07eebd5700c76500e305d401ce32fdf1bdf Mon Sep 17 00:00:00 2001 From: Nidhi Kumari Date: Tue, 23 May 2023 22:54:17 +0530 Subject: [PATCH 06/19] UX Multichain: updated border top for activity list (#19176) * updated border top for activity list * updated border css via prop * fixed symbol * fixed lint errors * fix conditions * updated snapshot --- .../app/token-cell/__snapshots__/token-cell.test.js.snap | 2 +- .../transaction-list-item/transaction-list-item.component.js | 2 ++ .../list-item/__snapshots__/list-item.component.test.js.snap | 4 ++-- ui/components/ui/list-item/index.scss | 5 ++++- ui/components/ui/list-item/list-item.component.js | 5 +++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/components/app/token-cell/__snapshots__/token-cell.test.js.snap b/ui/components/app/token-cell/__snapshots__/token-cell.test.js.snap index 4d77ea5eeb8e..ab99b1f5f3cc 100644 --- a/ui/components/app/token-cell/__snapshots__/token-cell.test.js.snap +++ b/ui/components/app/token-cell/__snapshots__/token-cell.test.js.snap @@ -3,7 +3,7 @@ exports[`Token Cell should match snapshot 1`] = `
diff --git a/ui/components/app/transaction-list-item/transaction-list-item.component.js b/ui/components/app/transaction-list-item/transaction-list-item.component.js index dc99a7eac46a..f412e7fbc750 100644 --- a/ui/components/app/transaction-list-item/transaction-list-item.component.js +++ b/ui/components/app/transaction-list-item/transaction-list-item.component.js @@ -168,6 +168,7 @@ function TransactionListItemInner({ ]); const showCancelButton = !hasCancelled && isPending && !isUnapproved; + const showBorder = process.env.MULTICHAIN; return ( <> @@ -178,6 +179,7 @@ function TransactionListItemInner({ icon={ } + showBorder={showBorder} subtitle={

@@ -21,7 +21,7 @@ exports[`ListItem should match snapshot with no props 1`] = ` exports[`ListItem should match snapshot with props 1`] = `
Date: Wed, 24 May 2023 07:10:12 -0500 Subject: [PATCH 07/19] Fix #19139 - Allow user to switch network when loading networking fails (#19175) --- .../loading-network-screen/loading-network-screen.component.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/components/app/loading-network-screen/loading-network-screen.component.js b/ui/components/app/loading-network-screen/loading-network-screen.component.js index 23c1c309d0b9..5263f2a0f857 100644 --- a/ui/components/app/loading-network-screen/loading-network-screen.component.js +++ b/ui/components/app/loading-network-screen/loading-network-screen.component.js @@ -79,6 +79,7 @@ export default class LoadingNetworkScreen extends PureComponent { { window.clearTimeout(this.cancelCallTimeout); + this.setState({ showErrorScreen: false }); }} centerTitle title={ @@ -100,6 +101,7 @@ export default class LoadingNetworkScreen extends PureComponent { { window.clearTimeout(this.cancelCallTimeout); + this.setState({ showErrorScreen: false }); showNetworkDropdown(); }} variant={TextVariant.bodySm} From 6a7688b0d38479bf0b5eb885bdef920b4037012b Mon Sep 17 00:00:00 2001 From: Nidhi Kumari Date: Wed, 10 May 2023 19:11:03 +0530 Subject: [PATCH 08/19] removed mmi fencing from copy icon in header (#19087) * removed mmi fencing from copy icon * updated snapshot --- .../selected-account-component.test.js.snap | 8 -------- .../selected-account/selected-account.component.js | 13 ++----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/ui/components/app/selected-account/__snapshots__/selected-account-component.test.js.snap b/ui/components/app/selected-account/__snapshots__/selected-account-component.test.js.snap index 43e1f1a76604..6031f8d0ba5e 100644 --- a/ui/components/app/selected-account/__snapshots__/selected-account-component.test.js.snap +++ b/ui/components/app/selected-account/__snapshots__/selected-account-component.test.js.snap @@ -29,14 +29,6 @@ exports[`SelectedAccount Component should match snapshot 1`] = ` class="selected-account__address" > 0x0DC...E7bc - From ea321c964fa76aa615f1478d9775e5e6647974b4 Mon Sep 17 00:00:00 2001 From: Nicholas Ellul Date: Wed, 24 May 2023 11:17:00 -0400 Subject: [PATCH 09/19] Revert "limit connections (#18355)" (#19272) This reverts commit 8d2803c1790971230e92b0c9429bc00594073bd8. --- app/scripts/background.js | 46 +++++---------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 082a13b6734d..828973d848fe 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -32,7 +32,6 @@ import { import { checkForLastErrorAndLog } from '../../shared/modules/browser-runtime.utils'; import { isManifestV3 } from '../../shared/modules/mv3.utils'; import { maskObject } from '../../shared/modules/object.utils'; -import { getEnvironmentType, deferredPromise, getPlatform } from './lib/util'; import migrations from './migrations'; import Migrator from './lib/migrator'; import ExtensionPlatform from './platforms/extension'; @@ -51,6 +50,7 @@ import rawFirstTimeState from './first-time-state'; import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code'; import getObjStructure from './lib/getObjStructure'; import setupEnsIpfsResolver from './lib/ens-ipfs/setup'; +import { deferredPromise, getPlatform } from './lib/util'; /* eslint-enable import/first */ @@ -84,7 +84,6 @@ let popupIsOpen = false; let notificationIsOpen = false; let uiIsTriggering = false; const openMetamaskTabsIDs = {}; -const openMetamaskConnections = new Map(); const requestAccountTabIds = {}; let controller; @@ -185,28 +184,10 @@ let connectExternal; browser.runtime.onConnect.addListener(async (...args) => { // Queue up connection attempts here, waiting until after initialization await isInitialized; - const remotePort = args[0]; - const { sender } = remotePort; - const url = sender?.url; - const detectedProcessName = url ? getEnvironmentType(url) : ''; - - const connectionId = generateConnectionId(remotePort, detectedProcessName); - const openConnections = openMetamaskConnections.get(connectionId) || 0; - - if ( - openConnections === 0 || - (detectedProcessName === 'background' && openConnections < 2) - // 2 background connections are allowed, one for phishing warning page and one for the ledger bridge keyring - ) { - // This is set in `setupController`, which is called as part of initialization - connectRemote(...args); - openMetamaskConnections.set(connectionId, openConnections + 1); - } else { - throw new Error('CONNECTION_ALREADY_EXISTS'); - } + // This is set in `setupController`, which is called as part of initialization + connectRemote(...args); }); - browser.runtime.onConnectExternal.addListener(async (...args) => { // Queue up connection attempts here, waiting until after initialization await isInitialized; @@ -435,21 +416,6 @@ export async function loadStateFromPersistence() { return versionedData.data; } -function generateConnectionId(remotePort, detectedProcessName) { - const { sender } = remotePort; - const id = sender?.tab ? sender.tab.id : sender?.id; - if (!id || !detectedProcessName) { - console.error( - 'Must provide id and detectedProcessName to generate connection id.', - id, - detectedProcessName, - ); // eslint-disable-line no-console - throw new Error( - 'Must provide id and detectedProcessName to generate connection id.', - ); - } - return `${id}-${detectedProcessName}`; -} /** * Initializes the MetaMask Controller with any initial state and default language. * Configures platform-specific error reporting strategy. @@ -604,6 +570,7 @@ export function setupController( // communication with popup controller.isClientOpen = true; controller.setupTrustedCommunication(portStream, remotePort.sender); + if (isManifestV3) { // If we get a WORKER_KEEP_ALIVE message, we respond with an ACK remotePort.onMessage.addListener((message) => { @@ -618,11 +585,9 @@ export function setupController( }); } - const connectionId = generateConnectionId(remotePort, processName); if (processName === ENVIRONMENT_TYPE_POPUP) { popupIsOpen = true; endOfStream(portStream, () => { - openMetamaskConnections.set(connectionId, 0); popupIsOpen = false; const isClientOpen = isClientOpenStatus(); controller.isClientOpen = isClientOpen; @@ -632,8 +597,8 @@ export function setupController( if (processName === ENVIRONMENT_TYPE_NOTIFICATION) { notificationIsOpen = true; + endOfStream(portStream, () => { - openMetamaskConnections.set(connectionId, 0); notificationIsOpen = false; const isClientOpen = isClientOpenStatus(); controller.isClientOpen = isClientOpen; @@ -649,7 +614,6 @@ export function setupController( openMetamaskTabsIDs[tabId] = true; endOfStream(portStream, () => { - openMetamaskConnections.set(connectionId, 0); delete openMetamaskTabsIDs[tabId]; const isClientOpen = isClientOpenStatus(); controller.isClientOpen = isClientOpen; From c42d3920f8a3c778495544a0d91006b4f142b174 Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Thu, 25 May 2023 19:30:10 +0200 Subject: [PATCH 10/19] Show the right "balance needed" value if we fallback from STX to regular Swaps (#19230) * Show the right balance needed value if we fallback from STX to regular Swaps * Fix usage of StxErrorTypes --- ui/ducks/swaps/swaps.js | 8 ++++---- ui/pages/swaps/view-quote/view-quote.js | 18 ++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index 6f5252bc27e9..3a9a1f538be4 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -208,7 +208,7 @@ const slice = createSlice({ setCurrentSmartTransactionsError: (state, action) => { const errorType = Object.values(StxErrorTypes).includes(action.payload) ? action.payload - : StxErrorTypes.UNAVAILABLE; + : StxErrorTypes.unavailable; state.currentSmartTransactionsError = errorType; }, setSwapsSTXSubmitLoading: (state, action) => { @@ -554,7 +554,7 @@ const disableStxIfRegularTxInProgress = (dispatch, transactions) => { for (const transaction of transactions) { if (IN_PROGRESS_TRANSACTION_STATUSES.includes(transaction.status)) { dispatch( - setCurrentSmartTransactionsError(StxErrorTypes.REGULAR_TX_IN_PROGRESS), + setCurrentSmartTransactionsError(StxErrorTypes.regularTxPending), ); break; } @@ -939,7 +939,7 @@ export const signAndSendSwapsSmartTransaction = ({ if (!fees) { log.error('"fetchSwapsSmartTransactionFees" failed'); dispatch(setSwapsSTXSubmitLoading(false)); - dispatch(setCurrentSmartTransactionsError(StxErrorTypes.UNAVAILABLE)); + dispatch(setCurrentSmartTransactionsError(StxErrorTypes.unavailable)); return; } if (approveTxParams) { @@ -1329,7 +1329,7 @@ export function fetchSwapsSmartTransactionFees({ const errorObj = parseSmartTransactionsError(e.message); if ( fallbackOnNotEnoughFunds || - errorObj?.error !== StxErrorTypes.NOT_ENOUGH_FUNDS + errorObj?.error !== StxErrorTypes.notEnoughFunds ) { dispatch(setCurrentSmartTransactionsError(errorObj?.error)); } diff --git a/ui/pages/swaps/view-quote/view-quote.js b/ui/pages/swaps/view-quote/view-quote.js index 04cab751803d..6857b2037e6c 100644 --- a/ui/pages/swaps/view-quote/view-quote.js +++ b/ui/pages/swaps/view-quote/view-quote.js @@ -201,6 +201,8 @@ export default function ViewQuote() { ); const swapsNetworkConfig = useSelector(getSwapsNetworkConfig, shallowEqual); const unsignedTransaction = usedQuote.trade; + const isSmartTransaction = + currentSmartTransactionsEnabled && smartTransactionsOptInStatus; let gasFeeInputs; if (networkAndAccountSupports1559) { @@ -460,7 +462,7 @@ export default function ViewQuote() { : null; let ethBalanceNeededStx; - if (smartTransactionsError?.balanceNeededWei) { + if (isSmartTransaction && smartTransactionsError?.balanceNeededWei) { ethBalanceNeededStx = decWEIToDecETH( smartTransactionsError.balanceNeededWei - smartTransactionsError.currentBalanceWei, @@ -469,7 +471,7 @@ export default function ViewQuote() { const destinationToken = useSelector(getDestinationTokenInfo, isEqual); useEffect(() => { - if (currentSmartTransactionsEnabled && smartTransactionsOptInStatus) { + if (isSmartTransaction) { if (insufficientTokens) { dispatch(setBalanceError(true)); } else if (balanceError && !insufficientTokens) { @@ -485,8 +487,7 @@ export default function ViewQuote() { insufficientEth, balanceError, dispatch, - currentSmartTransactionsEnabled, - smartTransactionsOptInStatus, + isSmartTransaction, ]); useEffect(() => { @@ -522,10 +523,7 @@ export default function ViewQuote() { ethBalanceNeeded; // If it's a Smart Transaction and ETH balance is needed, we want to show a warning. - const isStxAndEthBalanceIsNeeded = - currentSmartTransactionsEnabled && - smartTransactionsOptInStatus && - ethBalanceNeededStx; + const isStxAndEthBalanceIsNeeded = isSmartTransaction && ethBalanceNeededStx; // Indicates if we should show to a user a warning about insufficient funds for swapping. const showInsufficientWarning = @@ -926,14 +924,14 @@ export default function ViewQuote() { ]); useEffect(() => { - if (currentSmartTransactionsEnabled && smartTransactionsOptInStatus) { + if (isSmartTransaction) { // Removes a smart transactions error when the component loads. dispatch({ type: SET_SMART_TRANSACTIONS_ERROR, payload: null, }); } - }, [currentSmartTransactionsEnabled, smartTransactionsOptInStatus, dispatch]); + }, [isSmartTransaction, dispatch]); return (
From a62de72aaadf49f09c81b80585bb1237826f80fe Mon Sep 17 00:00:00 2001 From: Daniel <80175477+dan437@users.noreply.github.com> Date: Thu, 25 May 2023 18:48:11 +0200 Subject: [PATCH 11/19] Styling fix and content update for Swaps (#19284) --- app/_locales/de/messages.json | 4 ---- app/_locales/el/messages.json | 4 ---- app/_locales/en/messages.json | 4 ---- app/_locales/es/messages.json | 4 ---- app/_locales/es_419/messages.json | 4 ---- app/_locales/fr/messages.json | 4 ---- app/_locales/hi/messages.json | 4 ---- app/_locales/id/messages.json | 4 ---- app/_locales/ja/messages.json | 4 ---- app/_locales/ko/messages.json | 4 ---- app/_locales/pt/messages.json | 4 ---- app/_locales/pt_BR/messages.json | 4 ---- app/_locales/ru/messages.json | 4 ---- app/_locales/tl/messages.json | 4 ---- app/_locales/tr/messages.json | 4 ---- app/_locales/vi/messages.json | 4 ---- app/_locales/zh_CN/messages.json | 4 ---- ui/pages/swaps/awaiting-signatures/awaiting-signatures.js | 2 +- ui/pages/swaps/fee-card/fee-card.js | 6 +----- ui/pages/swaps/fee-card/fee-card.stories.js | 1 - ui/pages/swaps/fee-card/fee-card.test.js | 6 +++--- .../loading-swaps-quotes-stories-metadata.test.js.snap | 2 +- ui/pages/swaps/slippage-buttons/slippage-buttons.js | 2 +- ui/pages/swaps/view-quote/view-quote.js | 3 --- 24 files changed, 7 insertions(+), 83 deletions(-) diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index b8b8c19df271..95969f006953 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -3585,10 +3585,6 @@ "message": "Sie benötigen $1 mehr $2, um diesen Swap abzuschließen", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Die besten $1 Kurse.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Keine Token verfügbar mit $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index 06ebced86cd0..7e71a3e0714c 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -3585,10 +3585,6 @@ "message": "Χρειάζεστε $1 περισσότερα $2 για να ολοκληρώσετε αυτήν την ανταλλαγή", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Το καλύτερο από $1 προσφορές.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Δεν υπάρχουν διαθέσιμα tokens που να ταιριάζουν σε $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 088fe8444aec..8369a9c822ac 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -4086,10 +4086,6 @@ "message": "You need $1 more $2 to complete this swap", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Best of $1 quotes.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "No tokens available matching $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 67a3b012ad9b..d70534f6d216 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -3585,10 +3585,6 @@ "message": "Necesita $1 más $2 para completar este canje", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Mejor cotización de $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "No hay tokens disponibles que coincidan con $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 98254c6fce0d..09876fb19604 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -2241,10 +2241,6 @@ "message": "Necesita $1 más $2 para realizar este canje", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Mejor cotización de $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "No hay tokens disponibles que coincidan con $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index b543b2114f00..b5bfda3f6340 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -3585,10 +3585,6 @@ "message": "Vous avez besoin de $1 $2 de plus pour effectuer ce swap", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Meilleures cotations de $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Aucun jeton disponible correspondant à $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index e9781a768b1c..8154c2b869a6 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -3585,10 +3585,6 @@ "message": "इस स्वैप को पूरा करने के लिए आपको अधिक $1 और $2 की आवश्यकता होगी", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "$1 उद्धरणों में से सर्वश्रेष्ठ।", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "$1 के मिलान वाले कोई भी टोकन उपलब्ध नहीं हैं", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index 97df69b6ff68..3aff4b7d6360 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -3585,10 +3585,6 @@ "message": "Anda memerlukan $1 $2 lagi untuk menyelesaikan swap", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Kuotasi terbaik dari $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Tidak ada token yang cocok yang tersedia $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index a3c0dd28e11b..51ddd57ad474 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -3585,10 +3585,6 @@ "message": "このスワップを完了させるには、さらに$1の$2が必要です。", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "最善の$1の見積もり。", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "$1と一致するトークンがありません", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index c4de64fc44df..a6748c52de6e 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -3585,10 +3585,6 @@ "message": "이 스왑을 완료하려면 $1개의 추가 $2이(가) 필요합니다.", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "$1의 최고 견적", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "$1와(과) 일치하는 토큰이 없습니다.", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index d52ed995db38..2c68d1dce67f 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -3585,10 +3585,6 @@ "message": "Você precisa de mais $1 $2 para concluir essa troca", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Melhores cotações de $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Nenhum token disponível correspondente a $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 6c949ccfc1d2..e0189eb647bc 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -2241,10 +2241,6 @@ "message": "Você precisa de mais $1 $2 para concluir essa troca", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Melhores cotações de $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Nenhum token disponível correspondente a $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 1b9a1a6e83c6..e6fbc965a81e 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -3585,10 +3585,6 @@ "message": "Вам нужно еще $1 $2 для завершения этого обмена", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Лучшие котировки $1.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Нет доступных токенов, соответствующих $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 479683256066..7567f49db61d 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -3585,10 +3585,6 @@ "message": "Kailangan mo ng $1 pa $2 para makumpleto ang pag-swap na ito", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Pinakamaganda ng $1 na quote.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Walang available na token na tumutugma sa $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index 1479da53fe0d..3b7156625749 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -3585,10 +3585,6 @@ "message": "Bu takası tamamlamak için $1 tane daha $2 gerekli", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "En iyi $1 teklifleri.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "$1 ile eşleşen token yok", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index 4bb67b89e33e..a29e2daa1723 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -3585,10 +3585,6 @@ "message": "Bạn cần $1 $2 nữa để hoàn tất giao dịch hoán đổi này", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "Tốt nhất trong $1 báo giá.", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "Không có token nào khớp với $1", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 3bbbf016536a..f63570154522 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -3585,10 +3585,6 @@ "message": "您还需要 $1 的 $2 来完成这笔交换", "description": "Tells the user how many more of a given token they need for a specific swap. $1 is an amount of tokens and $2 is the token symbol." }, - "swapBestOfNQuotes": { - "message": "$1 报价中最棒的。", - "description": "$1 is the number of quotes that the user can select from when opening the list of quotes on the 'view quote' screen" - }, "swapBuildQuotePlaceHolderText": { "message": "没有与 $1 匹配的代币", "description": "Tells the user that a given search string does not match any tokens in our token lists. $1 can be any string of text" diff --git a/ui/pages/swaps/awaiting-signatures/awaiting-signatures.js b/ui/pages/swaps/awaiting-signatures/awaiting-signatures.js index 7bf1ace5d965..dacb937294d9 100644 --- a/ui/pages/swaps/awaiting-signatures/awaiting-signatures.js +++ b/ui/pages/swaps/awaiting-signatures/awaiting-signatures.js @@ -102,7 +102,7 @@ export default function AwaitingSignatures() { {needsTwoConfirmations && ( <> - + {t('swapToConfirmWithHwWallet')}
    diff --git a/ui/pages/swaps/fee-card/fee-card.js b/ui/pages/swaps/fee-card/fee-card.js index 15317452098e..b4df3f0e6f54 100644 --- a/ui/pages/swaps/fee-card/fee-card.js +++ b/ui/pages/swaps/fee-card/fee-card.js @@ -29,7 +29,6 @@ export default function FeeCard({ numberOfQuotes, onQuotesClick, chainId, - isBestQuote, }) { const t = useContext(I18nContext); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); @@ -167,9 +166,7 @@ export default function FeeCard({ onClick={onQuotesClick} className="fee-card__quote-link-text" > - {isBestQuote - ? t('swapBestOfNQuotes', [numberOfQuotes]) - : t('swapNQuotesWithDot', [numberOfQuotes])} + {t('swapNQuotesWithDot', [numberOfQuotes])} )} {t('swapIncludesMMFee', [metaMaskFee])} @@ -202,5 +199,4 @@ FeeCard.propTypes = { onQuotesClick: PropTypes.func.isRequired, numberOfQuotes: PropTypes.number.isRequired, chainId: PropTypes.string.isRequired, - isBestQuote: PropTypes.bool, }; diff --git a/ui/pages/swaps/fee-card/fee-card.stories.js b/ui/pages/swaps/fee-card/fee-card.stories.js index b00e2084ee06..bd901a05c061 100644 --- a/ui/pages/swaps/fee-card/fee-card.stories.js +++ b/ui/pages/swaps/fee-card/fee-card.stories.js @@ -91,7 +91,6 @@ export default { metaMaskFee: '0.875', numberOfQuotes: 6, chainId: CHAIN_IDS.MAINNET, - isBestQuote: true, }, }; diff --git a/ui/pages/swaps/fee-card/fee-card.test.js b/ui/pages/swaps/fee-card/fee-card.test.js index 32b8addd9083..3af448cf3ceb 100644 --- a/ui/pages/swaps/fee-card/fee-card.test.js +++ b/ui/pages/swaps/fee-card/fee-card.test.js @@ -95,7 +95,7 @@ describe('FeeCard', () => { useSelector.mockImplementation(generateUseSelectorRouter()); const props = createProps(); const { getByText } = renderWithProvider(); - expect(getByText('Best of 6 quotes.')).toBeInTheDocument(); + expect(getByText('6 quotes.')).toBeInTheDocument(); expect(getByText('Estimated gas fee')).toBeInTheDocument(); expect(getByText('Max fee')).toBeInTheDocument(); expect(getByText(props.primaryFee.fee)).toBeInTheDocument(); @@ -116,7 +116,7 @@ describe('FeeCard', () => { maxFeePerGasDecGWEI: '4', }); const { getByText } = renderWithProvider(); - expect(getByText('Best of 6 quotes.')).toBeInTheDocument(); + expect(getByText('6 quotes.')).toBeInTheDocument(); expect(getByText('Estimated gas fee')).toBeInTheDocument(); expect(getByText('Max fee')).toBeInTheDocument(); expect(getByText(props.primaryFee.fee)).toBeInTheDocument(); @@ -138,7 +138,7 @@ describe('FeeCard', () => { const { getByText, queryByTestId } = renderWithProvider( , ); - expect(getByText('Best of 6 quotes.')).toBeInTheDocument(); + expect(getByText('6 quotes.')).toBeInTheDocument(); expect(getByText('Estimated gas fee')).toBeInTheDocument(); expect(getByText(props.primaryFee.fee)).toBeInTheDocument(); expect(getByText(props.secondaryFee.fee)).toBeInTheDocument(); diff --git a/ui/pages/swaps/loading-swaps-quotes/__snapshots__/loading-swaps-quotes-stories-metadata.test.js.snap b/ui/pages/swaps/loading-swaps-quotes/__snapshots__/loading-swaps-quotes-stories-metadata.test.js.snap index 66be56d52a69..6581c8123ee8 100644 --- a/ui/pages/swaps/loading-swaps-quotes/__snapshots__/loading-swaps-quotes-stories-metadata.test.js.snap +++ b/ui/pages/swaps/loading-swaps-quotes/__snapshots__/loading-swaps-quotes-stories-metadata.test.js.snap @@ -27,4 +27,4 @@ exports[`storiesMetadata matches expected values for storiesMetadata 1`] = ` "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASkAAAB5CAYAAABlYNfBAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAlASURBVHgB7d3/eeO2GcDx1336f3UThNcF4g3KLNA4HaDnywC5Xgeo6Q5Q+zpAz+kCd+0AJyUDxNcFTsoCsbtA3gIVFL0CIRGgKMm2vp/nwWPxF0hT4isABCERAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADhCJ4LeVLVyf05d+sylZy7dufSjS7OTk5OPgrXcufN/KpfO16zyfqhzmLGvEjOX7mWA9zgcVx3SwrXL916AvtwHa+TShUtT3cwvfxUCGSLuvJy4dLPh/H2Qgfhg4NIXOrw7l9659EJ6CMfVmPx+5vOCrYSgc6dlpi79SbBC50FquuG8+Qt2JAPQ3QUp65NLdY/jIkh1+LUgi/vwXLk/qWDz/6J/+Ov56p+9uCqXrtz2n7li/GvBoppzJvNzs8m5S9eyG/eyfM9KjGT1/V147tIH979duvf5UoB98gEq8c35dt03p5t/qumqzFvBohT1zpyXqUvnLr3U1ZLqIFU+bZekfInlXHoIefkq/9ma99jnnVVypiSFQei8/UmjC6rO3LZOfIiPuuoXLszn0Tn5h1kWX7RbV/mGDFKJfKtEsPo55zNCkMLWwgcwDlBVwfYXmnYqRypcmC+jC/PULIvbjhrZ0q6ClMnflwyvo+PuLAUSpLA194EZRx+8unD7qaaN5UiFC9qe108dy3+QLe06SIV9xMfdWZoiSOX5lSApfMBqM+vGNYhOJFO4CCoz61vzutbCgPcU6LK/Um1m/zNezaXvzPTpIzlX/rj/aqZ9H8RasDWC1Hrn0XTpHZsL83oi7TuDF3KcavPaX9g3iXXemNf+Yv9SHoe4c+fngq0RpNazF8bElaJmkilRiroMvYgnZp4vIQzSD+gR8QHnGzP9MT6vbtr/ic9Vr86S+2SOe2ZmE6QGQJBKCNULG0BupMxKKcpUE22Vz+d/NA3ooap3Ksv/2c94s251l/5tpkePqHo8EwyKIJV2Fk1/J5lSpSjz+n3HfuK8LnTeH8unRrag897yi7wO0V/LFzVeRfM2ndebaNs/CoC56C7NtHDbqdn2tmP5uCOvM13Vq4+VtrtSNLJn2n4M5kPG+mOz/k99q8e6h7t7sjzmW7OfHzKOi7t7HShJpdlq2EwyabsUlXqkY+XOlWzgqom+5DUxsy56Xqg2GPqn9xvZI10+7V8tZslq1Te5maze+fP/95k8fPY9ZTSDARCk0mwg+I/ks21RPhikLkT7wR1lBJ3X0XEV3RVMBM5G9s9X1+LG75wqtA/S9yaPB1vlC4H4PJr9vQBDS1SNcp/DOo+2e5G5XpWRd9ybuZYM4X+Zmu0O8uygtqt67wq2exdVh4pLkrq/zpzTaB+nGcdFda8DJam2KprOLbLnlKJy9pfSRMeRW5pqZH0j/l5oe8QDP+N97uYu/T2ady4PTPgf/XtSmdkTBj4cBkGq26xrhVCyqcyspiC/30iH0MfKVvtq7RhoLXyL23UuS/p6DSiupt0XBHDPX+i2yvd7eSBCSciPyOpLqPaLw0etrwXYBW2PXFBnbDM2608L8z+X/GOz+7nbVPWJqh5FdyiHohtGPCjII354t7hKpLsbquVa04MgNgV5Ud3rwKB3bVXJytp+xq+R3bk0+1o0or9OHJPvj1SZWYccbK82r+M7djn8Nv+SZR8rX5o6l+3Os8/DjxHW59GkdYPeLVzu++4pjoy2+ybVHeuPS0osukVJKmwfN6KfRssfRGN5OJaNIx4U5nPXNx9l+OBHjTaptrihfG2bUfhA1WZWI+XuCtdvZPUYrxLLq/B6JgdoLPc0PeLBRPqz7ViVPozHZBbPGH7lSk+/LRklA/mo7nV7tmFZY17n3tGLqwr/lQK+Ed1doD7wLILTohHd9zuqZLWx/M2BGssXbOdLH7W+36KkYPurLUZGmEh/76WsD9zCLPz9yN07HIRm9pNKrJf1pL62+0nV0oO2B+SLHaSx3Bxf16/BbOungmPZeT+pPpTqXhaqe21xda9as15jXs8k/yHkKpru+23cVY17KQeiyxEPKtmdxzQyArZAkIqEPkk2ULXapMK3nS05fVtQrfo8sb8+ftex/JUcTmrEg13s4xvBk0ebVNpMlg+K1onlTbTujeSrzOtepagQJBtZPQaf7BhV/i5lfcDGXBtE/WgQf5Dt+cDk+1nVYdq3x434WXIcHW3f5h+ZZXFb1FVBvqNo217dA7TdqbMy+dtb9VPd8+ifa9p/sp5/zMz7dWnetEk9blT30uISji0VNNGydaNLptTR9EQKhYurNrN+edwllChsW1Ul6V9d3qXUiAe5z+rluIn29WAekwH2Zl2JJ1GKKioJaftHJKvC7eOOmtM1642j/ZzKnmi74+Ugv0Ic5T+OSh+jjm0oSeHp0cRzctsEGW0HuLEUyt2/zn/mXXcVKDYcn0/xD39mdc0o3EdRlY8ghSdJ24+vvI2nC/O7iLYvuni13b+q6Vj/uuRCHoKmx3+qZEDhwn4WnYsPGdsQpPD06ObOiFVBPnEpqnTc9FF0LP71KGMbW+3qPUZ45jGmRjzYSQlOC38tmCD1uNFwvtm6DpE3uf2iQmCIq3aNlIlHNWgybrv75X820/7xnr/JbtXmdc445n3Foynwa8E4XtpuB1ItG773Ntr2WgroFo31pSWObWiPBu0t9rWo8q2UFDvWpySFp0nn1aY40ExdeqHrG679NhfaHhDttvTC1XY1ryrYNlUF+6QDBw8dYHC7Hvv0QfEmusBrWX98BCk8XWsC1cJYzY9uhunUaI19AtRFlEfxnbLEheA1MiBN33H7UnZI02NEXWWuS5DC06Ttnui5/HalAcpX82ywu5UedFk1mu7qYtD2iAfZIxQMsN/OmwNKkHrUaDgv4Bqr/W3855LfIDxx6Qu/XY/ny3ypyW8zC+kr6cHt1//xA+t9bfL60aW/yAB0ObidmPx31WDe2r3Mf4B1FtK9rB95wZ5Ln0oHG9wVfxwzkxA5EfQSvrFrmT/Q618vRkvwAcA/VjPhwVcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwJH7H5NlZI/0GQ+cAAAAAElFTkSuQmCC", }, } -`; +`; \ No newline at end of file diff --git a/ui/pages/swaps/slippage-buttons/slippage-buttons.js b/ui/pages/swaps/slippage-buttons/slippage-buttons.js index 59a1c23866bd..fe7e81f80c4c 100644 --- a/ui/pages/swaps/slippage-buttons/slippage-buttons.js +++ b/ui/pages/swaps/slippage-buttons/slippage-buttons.js @@ -210,7 +210,7 @@ export default function SlippageButtons({ {t('smartTransaction')} diff --git a/ui/pages/swaps/view-quote/view-quote.js b/ui/pages/swaps/view-quote/view-quote.js index 6857b2037e6c..4be72b2c6425 100644 --- a/ui/pages/swaps/view-quote/view-quote.js +++ b/ui/pages/swaps/view-quote/view-quote.js @@ -213,8 +213,6 @@ export default function ViewQuote() { }); } - const { isBestQuote } = usedQuote; - const fetchParamsSourceToken = fetchParams?.sourceToken; const additionalTrackingParams = { @@ -1034,7 +1032,6 @@ export default function ViewQuote() { } } chainId={chainId} - isBestQuote={isBestQuote} maxPriorityFeePerGasDecGWEI={hexWEIToDecGWEI( maxPriorityFeePerGas, )} From 00db93763bfe5973ae689d59f660628d520475a9 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Thu, 25 May 2023 16:00:56 -0700 Subject: [PATCH 12/19] Update Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b892ad03208..034155a79148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enable editing L2 gas on optimism ([#18217](https://github.com/MetaMask/metamask-extension/pull/18217)) - Update keystone links ([#18792](https://github.com/MetaMask/metamask-extension/pull/18792)) - Remove Goerli buy link and disable button ([#18137](https://github.com/MetaMask/metamask-extension/pull/18137)) +- No long show best quote, only present a list of quotes. ([#19284](https://github.com/MetaMask/metamask-extension/pull/19284)) - [FLASK] Don't show the title on Install/Update when it's loading ([#19012](https://github.com/MetaMask/metamask-extension/pull/19012)) - [FLASK] Add updated version of the Snaps settings UI ([#18438](https://github.com/MetaMask/metamask-extension/pull/18438), ([#18775](https://github.com/MetaMask/metamask-extension/pull/18775))) @@ -30,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix in approve header to show correct account name ([#18849](https://github.com/MetaMask/metamask-extension/pull/18849)) - Fix error when switching to Linea testnet using wallet_switchEthereumChain ([#18710](https://github.com/MetaMask/metamask-extension/pull/18710)) - Fix for persistant currency conversion on multi layer transactions when the show balance setting is off ([#18833](https://github.com/MetaMask/metamask-extension/pull/18833)) +- Show the right "balance needed" value if we fallback from STX to regular Swaps ([#19230](https://github.com/MetaMask/metamask-extension/pull/19230)) - [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) - [FLASK] Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) - [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719)) From edf2cc41cb5f7f9c82285cef3fc70be36e18bdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Mon, 29 May 2023 16:38:28 +0100 Subject: [PATCH 13/19] [MMI] adds mmi code fences to mm controller (#18279) * adds code fencing * MMI adds mmi-controller * MMI prettier * chore: create keyring builder for CustodyKeyrings * updates code fence to build-mmi * adds dependencies * fix import and prettier * lint * clean up * clean up * removes old methods and adds new * comment for now * adds two missing methods * runs yarn dedupe * adds missing import * bump target values * lavamoat policy update * bump values in coverage targets * prettier import order * coverage report update * clean up * yarn update * yarn dedupe * ran lavamoat:auto * adds zlib entry to storybook/main.js * adds browserify-zlib * clean up * clean up * prettier * prettier * eslint fix * fix paths * fix prettier * fix file name for mocha * adds to config * rename * adds file to configs * test lavamoat clean up * run dedupe * sets value in storybook main.js as false * runs lavamoat auto * updates mmi packages to lighter versions * updates mmi packages * lavamoat auto * adds finalized tx status * lavamoat auto * yarn dedupe * clean up * moving stuff into mmi controller * clean up * updates tresholds * yarn lock review * updates the mmi controller --------- Co-authored-by: Shane Terence Odlum --- .eslintrc.js | 2 + .mocharc.js | 1 + app/scripts/controllers/mmi-controller.js | 612 ++++++++++++++++++ .../controllers/mmi-controller.test.js | 129 ++++ app/scripts/metamask-controller.js | 203 +++++- app/scripts/mmi-keyring-builder-factory.js | 17 + coverage-targets.js | 8 +- jest.config.js | 1 + package.json | 5 + shared/constants/transaction.ts | 12 + yarn.lock | 45 +- 11 files changed, 1024 insertions(+), 11 deletions(-) create mode 100644 app/scripts/controllers/mmi-controller.js create mode 100644 app/scripts/controllers/mmi-controller.test.js create mode 100644 app/scripts/mmi-keyring-builder-factory.js diff --git a/.eslintrc.js b/.eslintrc.js index 89578fa19033..1236df167831 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -237,6 +237,7 @@ module.exports = { ], excludedFiles: [ 'app/scripts/controllers/app-state.test.js', + 'app/scripts/controllers/mmi-controller.test.js', 'app/scripts/controllers/network/**/*.test.js', 'app/scripts/controllers/permissions/**/*.test.js', 'app/scripts/lib/**/*.test.js', @@ -265,6 +266,7 @@ module.exports = { files: [ '**/__snapshots__/*.snap', 'app/scripts/controllers/app-state.test.js', + 'app/scripts/controllers/mmi-controller.test.js', 'app/scripts/controllers/network/**/*.test.js', 'app/scripts/controllers/network/**/*.test.ts', 'app/scripts/controllers/network/provider-api-tests/*.ts', diff --git a/.mocharc.js b/.mocharc.js index a34a05fc8129..a8843b0e1f45 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -8,6 +8,7 @@ module.exports = { './app/scripts/controllers/app-state.test.js', './app/scripts/controllers/network/**/*.test.js', './app/scripts/controllers/permissions/**/*.test.js', + './app/scripts/controllers/mmi-controller.test.js', './app/scripts/constants/error-utils.test.js', ], recursive: true, diff --git a/app/scripts/controllers/mmi-controller.js b/app/scripts/controllers/mmi-controller.js new file mode 100644 index 000000000000..35e56c3381da --- /dev/null +++ b/app/scripts/controllers/mmi-controller.js @@ -0,0 +1,612 @@ +import EventEmitter from 'events'; +import log from 'loglevel'; +import { captureException } from '@sentry/browser'; +import { + PersonalMessageManager, + TypedMessageManager, +} from '@metamask/message-manager'; +import { CUSTODIAN_TYPES } from '@metamask-institutional/custody-keyring'; +import { + updateCustodianTransactions, + custodianEventHandlerFactory, +} from '@metamask-institutional/extension'; +import { + REFRESH_TOKEN_CHANGE_EVENT, + INTERACTIVE_REPLACEMENT_TOKEN_CHANGE_EVENT, +} from '@metamask-institutional/sdk'; +import { handleMmiPortfolio } from '@metamask-institutional/portfolio-dashboard'; +import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils'; +import { CHAIN_IDS } from '../../../shared/constants/network'; +import { + BUILD_QUOTE_ROUTE, + CONNECT_HARDWARE_ROUTE, +} from '../../../ui/helpers/constants/routes'; +import { getPermissionBackgroundApiMethods } from './permissions'; + +export default class MMIController extends EventEmitter { + constructor(opts) { + super(); + + this.opts = opts; + this.mmiConfigurationController = opts.mmiConfigurationController; + this.keyringController = opts.keyringController; + this.txController = opts.txController; + this.securityProviderRequest = opts.securityProviderRequest; + this.preferencesController = opts.preferencesController; + this.appStateController = opts.appStateController; + this.transactionUpdateController = opts.transactionUpdateController; + this.custodyController = opts.custodyController; + this.institutionalFeaturesController = opts.institutionalFeaturesController; + this.getState = opts.getState; + this.getPendingNonce = opts.getPendingNonce; + this.accountTracker = opts.accountTracker; + this.metaMetricsController = opts.metaMetricsController; + this.networkController = opts.networkController; + this.permissionController = opts.permissionController; + this.platform = opts.platform; + this.extension = opts.extension; + + this.personalMessageManager = new PersonalMessageManager( + undefined, + undefined, + this.securityProviderRequest, + ); + this.typedMessageManager = new TypedMessageManager( + undefined, + undefined, + this.securityProviderRequest, + ); + + // Prepare event listener after transactionUpdateController gets initiated + this.transactionUpdateController.prepareEventListener( + this.custodianEventHandlerFactory.bind(this), + ); + + // Get configuration from MMIConfig controller + if (!process.env.IN_TEST) { + this.mmiConfigurationController.storeConfiguration().then(() => { + // This must happen after the configuration is fetched + // Otherwise websockets will always be disabled in the first run + + this.transactionUpdateController.subscribeToEvents(); + }); + } + } // End of constructor + + async persistKeyringsAfterRefreshTokenChange() { + this.keyringController.persistAllKeyrings(); + } + + async trackTransactionEventFromCustodianEvent(txMeta, event) { + this.txController._trackTransactionMetricsEvent(txMeta, event); + } + + async addKeyringIfNotExists(type) { + let keyring = await this.keyringController.getKeyringsByType(type)[0]; + if (!keyring) { + keyring = await this.keyringController.addNewKeyring(type); + } + return keyring; + } + + custodianEventHandlerFactory() { + return custodianEventHandlerFactory({ + log, + getState: () => this.getState(), + getPendingNonce: (address) => this.getPendingNonce(address), + setTxHash: (txId, txHash) => this.txController.setTxHash(txId, txHash), + typedMessageManager: this.typedMessageManager, + personalMessageManager: this.personalMessageManager, + txStateManager: this.txController.txStateManager, + custodyController: this.custodyController, + trackTransactionEvent: + this.trackTransactionEventFromCustodianEvent.bind(this), + }); + } + + async storeCustodianSupportedChains(address) { + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + const keyring = await this.addKeyringIfNotExists(custodyType); + + const supportedChains = await keyring.getSupportedChains(address); + + if (supportedChains?.status === 401) { + return; + } + + const accountDetails = this.custodyController.getAccountDetails(address); + + await this.custodyController.storeSupportedChainsForAddress( + toChecksumHexAddress(address), + supportedChains, + accountDetails.custodianName, + ); + } + + async onSubmitPassword() { + // Create a keyring for each custodian type + let addresses = []; + const custodyTypes = this.custodyController.getAllCustodyTypes(); + for (const type of custodyTypes) { + try { + const keyring = await this.addKeyringIfNotExists(type); + + keyring.on(REFRESH_TOKEN_CHANGE_EVENT, () => { + log.info(`Refresh token change event for ${type}`); + this.persistKeyringsAfterRefreshTokenChange(); + }); + + // Trigger this event, listen to sdk, sdk change the state and then Ui is listening for the state changed + keyring.on(INTERACTIVE_REPLACEMENT_TOKEN_CHANGE_EVENT, (payload) => { + log.info(`Interactive refresh token change event for ${payload}`); + this.appStateController.showInteractiveReplacementTokenBanner( + payload, + ); + }); + + // store the supported chains for this custodian type + const accounts = await keyring.getAccounts(); + addresses = addresses.concat(...accounts); + for (const address of accounts) { + try { + await this.storeCustodianSupportedChains(address); + } catch (error) { + captureException(error); + log.error('Error while unlocking extension.', error); + } + } + + const txList = this.txController.txStateManager.getTransactions( + {}, + [], + false, + ); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/ + + try { + updateCustodianTransactions({ + keyring, + type, + txList, + getPendingNonce: this.getPendingNonce.bind(this), + txStateManager: this.txController.txStateManager, + setTxHash: this.txController.setTxHash.bind(this.txController), + custodyController: this.custodyController, + transactionUpdateController: this.transactionUpdateController, + }); + } catch (error) { + log.error('Error doing offline transaction updates', error); + captureException(error); + } + } catch (error) { + log.error( + `Error while unlocking extension with custody type ${type}`, + error, + ); + captureException(error); + } + } + + try { + await this.mmiConfigurationController.storeConfiguration(); + } catch (error) { + log.error('Error while unlocking extension.', error); + } + + try { + await this.transactionUpdateController.subscribeToEvents(); + } catch (error) { + log.error('Error while unlocking extension.', error); + } + + const mmiConfigData = + await this.mmiConfigurationController.store.getState(); + + if ( + mmiConfigData && + mmiConfigData.mmiConfiguration.features?.websocketApi + ) { + this.transactionUpdateController.getCustomerProofForAddresses(addresses); + } + + try { + if (this.institutionalFeaturesController.getComplianceProjectId()) { + this.institutionalFeaturesController.startPolling(); + } + } catch (e) { + log.error('Failed to start Compliance polling'); + log.error(e); + } + } + + async connectCustodyAddresses(custodianType, custodianName, accounts) { + if (!custodianType) { + throw new Error('No custodian'); + } + + const custodian = CUSTODIAN_TYPES[custodianType.toUpperCase()]; + if (!custodian) { + throw new Error('No such custodian'); + } + + const newAccounts = Object.keys(accounts); + + // Check if any address is already added + const identities = Object.keys( + this.preferencesController.store.getState().identities, + ); + if (newAccounts.some((address) => identities.indexOf(address) !== -1)) { + throw new Error('Cannot import duplicate accounts'); + } + + const keyring = await this.addKeyringIfNotExists( + custodian.keyringClass.type, + ); + + keyring.on(REFRESH_TOKEN_CHANGE_EVENT, () => { + log.info(`Refresh token change event for ${keyring.type}`); + this.persistKeyringsAfterRefreshTokenChange(); + }); + + // Trigger this event, listen to sdk, sdk change the state and then Ui is listening for the state changed + keyring.on(INTERACTIVE_REPLACEMENT_TOKEN_CHANGE_EVENT, (payload) => { + log.info(`Interactive refresh token change event for ${payload}`); + this.appStateController.showInteractiveReplacementTokenBanner(payload); + }); + + if (!keyring) { + throw new Error('Unable to get keyring'); + } + const oldAccounts = await this.keyringController.getAccounts(); + + await keyring.setSelectedAddresses( + newAccounts.map((item) => ({ + address: toChecksumHexAddress(item), + name: accounts[item].name, + custodianDetails: accounts[item].custodianDetails, + labels: accounts[item].labels, + token: accounts[item].token, + apiUrl: accounts[item].apiUrl, + custodyType: custodian.keyringClass.type, + chainId: accounts[item].chainId, + })), + ); + this.custodyController.setAccountDetails( + newAccounts.map((item) => ({ + address: toChecksumHexAddress(item), + name: accounts[item].name, + custodianDetails: accounts[item].custodianDetails, + labels: accounts[item].labels, + apiUrl: accounts[item].apiUrl, + custodyType: custodian.keyringClass.type, + custodianName, + chainId: accounts[item].chainId, + })), + ); + + newAccounts.forEach( + async () => await this.keyringController.addNewAccount(keyring), + ); + + const allAccounts = await this.keyringController.getAccounts(); + + this.preferencesController.setAddresses(allAccounts); + const accountsToTrack = [ + ...new Set(oldAccounts.concat(allAccounts.map((a) => a.toLowerCase()))), + ]; + + allAccounts.forEach((address) => { + if (!oldAccounts.includes(address.toLowerCase())) { + const label = newAccounts + .filter((item) => item.toLowerCase() === address) + .map((item) => accounts[item].name)[0]; + this.preferencesController.setAccountLabel(address, label); + } + }); + + this.accountTracker.syncWithAddresses(accountsToTrack); + + for (const address of newAccounts) { + try { + await this.storeCustodianSupportedChains(address); + } catch (error) { + captureException(error); + } + } + + // FIXME: status maps are not a thing anymore + this.custodyController.storeCustodyStatusMap( + custodian.name, + keyring.getStatusMap(), + ); + + // MMI - get a WS stream for this account + const mmiConfigData = + await this.mmiConfigurationController.store.getState(); + + if ( + mmiConfigData && + mmiConfigData.mmiConfiguration.features?.websocketApi + ) { + this.transactionUpdateController.getCustomerProofForAddresses( + newAccounts, + ); + } + + return newAccounts; + } + + async getCustodianAccounts( + token, + apiUrl, + custodianType, + getNonImportedAccounts, + ) { + let currentCustodyType; + if (!custodianType) { + const address = this.preferencesController.getSelectedAddress(); + currentCustodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + } + + let keyring; + + if (custodianType) { + const custodian = CUSTODIAN_TYPES[custodianType.toUpperCase()]; + if (!custodian) { + throw new Error('No such custodian'); + } + + keyring = await this.addKeyringIfNotExists(custodian.keyringClass.type); + } else if (currentCustodyType) { + keyring = await this.addKeyringIfNotExists(currentCustodyType); + } else { + throw new Error('No custodian specified'); + } + + const accounts = await keyring.getCustodianAccounts( + token, + apiUrl, + null, + getNonImportedAccounts, + ); + return accounts; + } + + async getCustodianAccountsByAddress(token, apiUrl, address, custodianType) { + let keyring; + + if (custodianType) { + const custodian = CUSTODIAN_TYPES[custodianType.toUpperCase()]; + if (!custodian) { + throw new Error('No such custodian'); + } + + keyring = await this.addKeyringIfNotExists(custodian.keyringClass.type); + } else { + throw new Error('No custodian specified'); + } + + const accounts = await keyring.getCustodianAccounts(token, apiUrl, address); + return accounts; + } + + async getCustodianTransactionDeepLink(address, txId) { + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + const keyring = await this.addKeyringIfNotExists(custodyType); + return keyring.getTransactionDeepLink(address, txId); + } + + async getCustodianConfirmDeepLink(txId) { + const txMeta = this.txController.txStateManager.getTransaction(txId); + + const address = txMeta.txParams.from; + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + const keyring = await this.addKeyringIfNotExists(custodyType); + return { + deepLink: await keyring.getTransactionDeepLink( + txMeta.txParams.from, + txMeta.custodyId, + ), + custodyId: txMeta.custodyId, + }; + } + + async getCustodianSignMessageDeepLink(from, custodyTxId) { + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(from), + ); + const keyring = await this.addKeyringIfNotExists(custodyType); + return keyring.getTransactionDeepLink(from, custodyTxId); + } + + async getCustodianToken(custodianType) { + let currentCustodyType; + + const address = this.preferencesController.getSelectedAddress(); + + if (!custodianType) { + const resultCustody = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + currentCustodyType = resultCustody; + } + let keyring = await this.keyringController.getKeyringsByType( + currentCustodyType || `Custody - ${custodianType}`, + )[0]; + if (!keyring) { + keyring = await this.keyringController.addNewKeyring( + currentCustodyType || `Custody - ${custodianType}`, + ); + } + const { authDetails } = keyring.getAccountDetails(address); + return keyring ? authDetails.jwt || authDetails.refreshToken : ''; + } + + // Based on a custodian name, get all the tokens associated with that custodian + async getCustodianJWTList(custodianName) { + console.log('getCustodianJWTList', custodianName); + + const { identities } = this.preferencesController.store.getState(); + + const { mmiConfiguration } = + this.mmiConfigurationController.store.getState(); + + const addresses = Object.keys(identities); + const tokenList = []; + + const { custodians } = mmiConfiguration; + + const custodian = custodians.find((item) => item.name === custodianName); + + if (!custodian) { + return []; + } + + const keyrings = await this.keyringController.getKeyringsByType( + `Custody - ${custodian.type}`, + ); + + for (const address of addresses) { + for (const keyring of keyrings) { + // Narrow down to custodian Type + const accountDetails = keyring.getAccountDetails(address); + + if (!accountDetails) { + log.debug(`${address} does not belong to ${custodian.type} keyring`); + continue; + } + + const custodyAccountDetails = + this.custodyController.getAccountDetails(address); + + if ( + !custodyAccountDetails || + custodyAccountDetails.custodianName !== custodianName + ) { + log.debug(`${address} does not belong to ${custodianName} keyring`); + continue; + } + + const { authDetails } = accountDetails; + + let token; + if (authDetails.jwt) { + token = authDetails.jwt; + } else if (authDetails.refreshToken) { + token = authDetails.refreshToken; + } + + if (!tokenList.includes(token)) { + tokenList.push(token); + } + } + } + return tokenList; + } + + async getAllCustodianAccountsWithToken(custodyType, token) { + const keyring = await this.keyringController.getKeyringsByType( + `Custody - ${custodyType}`, + )[0]; + return keyring ? keyring.getAllAccountsWithToken(token) : []; + } + + async setCustodianNewRefreshToken({ address, newAuthDetails }) { + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + + const keyring = await this.addKeyringIfNotExists(custodyType); + + await keyring.replaceRefreshTokenAuthDetails(address, newAuthDetails); + } + + async handleMmiCheckIfTokenIsPresent(req) { + const { token, apiUrl } = req.params; + const custodyType = 'Custody - JSONRPC'; // Only JSONRPC is supported for now + + // This can only work if the extension is unlocked + await this.appStateController.getUnlockPromise(true); + + const keyring = await this.addKeyringIfNotExists(custodyType); + + return await this.custodyController.handleMmiCheckIfTokenIsPresent({ + token, + apiUrl, + keyring, + }); + } + + async setMmiPortfolioCookie() { + await this.appStateController.getUnlockPromise(true); + const keyringAccounts = await this.keyringController.getAccounts(); + const { identities } = this.preferencesController.store.getState(); + const { metaMetricsId } = this.metaMetricsController.store.getState(); + const getAccountDetails = (address) => + this.custodyController.getAccountDetails(address); + const extensionId = this.extension.runtime.id; + const networks = [ + ...this.preferencesController.getRpcMethodPreferences(), + { chainId: CHAIN_IDS.MAINNET }, + { chainId: CHAIN_IDS.GOERLI }, + ]; + + handleMmiPortfolio({ + keyringAccounts, + identities, + metaMetricsId, + networks, + getAccountDetails, + extensionId, + }); + } + + async setAccountAndNetwork(origin, address, chainId) { + await this.appStateController.getUnlockPromise(true); + const selectedAddress = this.preferencesController.getSelectedAddress(); + if (selectedAddress.toLowerCase() !== address.toLowerCase()) { + this.preferencesController.setSelectedAddress(address); + } + const selectedChainId = parseInt( + this.networkController.getCurrentChainId(), + 16, + ); + if (selectedChainId !== chainId && chainId === 1) { + this.networkController.setProviderType('mainnet'); + } else if (selectedChainId !== chainId) { + const network = this.preferencesController + .getFrequentRpcListDetail() + .find((item) => parseInt(item.chainId, 16) === chainId); + this.networkController.setRpcTarget( + network.rpcUrl, + network.chainId, + network.ticker, + network.nickname, + ); + } + getPermissionBackgroundApiMethods( + this.permissionController, + ).addPermittedAccount(origin, address); + + return true; + } + + async handleMmiOpenSwaps(origin, address, chainId) { + await this.setAccountAndNetwork(origin, address, chainId); + this.platform.openExtensionInBrowser(BUILD_QUOTE_ROUTE); + return true; + } + + async handleMmiOpenAddHardwareWallet() { + await this.appStateController.getUnlockPromise(true); + this.platform.openExtensionInBrowser(CONNECT_HARDWARE_ROUTE); + return true; + } +} diff --git a/app/scripts/controllers/mmi-controller.test.js b/app/scripts/controllers/mmi-controller.test.js new file mode 100644 index 000000000000..f6f9cc5f786c --- /dev/null +++ b/app/scripts/controllers/mmi-controller.test.js @@ -0,0 +1,129 @@ +/* eslint-disable */ +import { KeyringController } from '@metamask/eth-keyring-controller'; +import { MmiConfigurationController } from '@metamask-institutional/custody-keyring'; +import { TransactionUpdateController } from '@metamask-institutional/transaction-update'; + +import MMIController from './mmi-controller'; +import TransactionController from './transactions'; +import PreferencesController from './preferences'; +import AppStateController from './app-state'; + +describe('MMIController', function () { + let mmiController; + + beforeEach(function () { + mmiController = new MMIController({ + mmiConfigurationController: new MmiConfigurationController(), + keyringController: new KeyringController({ + initState: {}, + }), + transactionUpdateController: new TransactionUpdateController({ + getCustodyKeyring: jest.fn(), + }), + txController: new TransactionController({ + initState: {}, + provider: { + chainId: 'fail', + nickname: '', + rpcTarget: 'https://api.myetherwallet.com/eth', + ticker: 'ETH', + type: 'rinkeby', + }, + getCurrentChainId: jest.fn(), + getNetworkId: jest.fn(), + onNetworkStateChange: jest.fn(), + }), + preferencesController: new PreferencesController({ + initState: {}, + onInfuraIsBlocked: jest.fn(), + onInfuraIsUnblocked: jest.fn(), + provider: {}, + }), + appStateController: new AppStateController({ + addUnlockListener: jest.fn(), + isUnlocked: jest.fn(() => true), + initState: {}, + onInactiveTimeout: jest.fn(), + showUnlockRequest: jest.fn(), + preferencesStore: { + subscribe: jest.fn(), + getState: jest.fn(() => ({ + preferences: { + autoLockTimeLimit: 0, + }, + })), + }, + qrHardwareStore: { + subscribe: jest.fn(), + }, + messenger: { + call: jest.fn(() => ({ + catch: jest.fn(), + })), + }, + }), + custodianEventHandlerFactory: jest.fn(), + }); + }); + + describe('mmiController constructor', function () { + it('should instantiate correctly', function () { + expect(mmiController).toBeInstanceOf(MMIController); + }); + + it('should have all required properties', function () { + expect(mmiController.opts).toBeDefined(); + expect(mmiController.mmiConfigurationController).toBeDefined(); + expect(mmiController.preferencesController).toBeDefined(); + expect(mmiController.transactionUpdateController).toBeDefined(); + }); + }); + + describe('persistKeyringsAfterRefreshTokenChange', function () { + it('should call keyringController.persistAllKeyrings', async function () { + mmiController.keyringController.persistAllKeyrings = jest.fn(); + + await mmiController.persistKeyringsAfterRefreshTokenChange(); + + expect( + mmiController.keyringController.persistAllKeyrings, + ).toHaveBeenCalled(); + }); + }); + + describe('trackTransactionEventFromCustodianEvent', function () { + it('should call txController._trackTransactionMetricsEvent', function () { + const txMeta = {}; + const event = 'event'; + mmiController.txController._trackTransactionMetricsEvent = jest.fn(); + + mmiController.trackTransactionEventFromCustodianEvent(txMeta, event); + + expect( + mmiController.txController._trackTransactionMetricsEvent, + ).toHaveBeenCalledWith(txMeta, event); + }); + }); + + describe('custodianEventHandlerFactory', function () { + it('should call custodianEventHandlerFactory', async function () { + mmiController.custodianEventHandlerFactory = jest.fn(); + + mmiController.custodianEventHandlerFactory(); + + expect(mmiController.custodianEventHandlerFactory).toHaveBeenCalled(); + }); + }); + + describe('storeCustodianSupportedChains', function () { + it('should call storeCustodianSupportedChains', async function () { + mmiController.storeCustodianSupportedChains = jest.fn(); + + mmiController.storeCustodianSupportedChains('0x1'); + + expect(mmiController.storeCustodianSupportedChains).toHaveBeenCalledWith( + '0x1', + ); + }); + }); +}); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 892f0ec4df5f..09c7b88035a3 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -63,8 +63,28 @@ import { } from '@metamask/snaps-controllers'; ///: END:ONLY_INCLUDE_IN +///: BEGIN:ONLY_INCLUDE_IN(build-mmi) +import { + CUSTODIAN_TYPES, + MmiConfigurationController, +} from '@metamask-institutional/custody-keyring'; +import { InstitutionalFeaturesController } from '@metamask-institutional/institutional-features'; +import { CustodyController } from '@metamask-institutional/custody-controller'; +import { TransactionUpdateController } from '@metamask-institutional/transaction-update'; +///: END:ONLY_INCLUDE_IN import { SignatureController } from '@metamask/signature-controller'; + +///: BEGIN:ONLY_INCLUDE_IN(desktop) +// eslint-disable-next-line import/order +import { DesktopController } from '@metamask/desktop/dist/controllers/desktop'; +///: END:ONLY_INCLUDE_IN + import { ApprovalType } from '@metamask/controller-utils'; + +///: BEGIN:ONLY_INCLUDE_IN(build-mmi) +import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils'; +///: END:ONLY_INCLUDE_IN + import { AssetType, TransactionStatus, @@ -116,15 +136,16 @@ import { STATIC_MAINNET_TOKEN_LIST } from '../../shared/constants/tokens'; import { getTokenValueParam } from '../../shared/lib/metamask-controller-utils'; import { isManifestV3 } from '../../shared/modules/mv3.utils'; import { hexToDecimal } from '../../shared/modules/conversion.utils'; -///: BEGIN:ONLY_INCLUDE_IN(desktop) -// eslint-disable-next-line import/order -import { DesktopController } from '@metamask/desktop/dist/controllers/desktop'; -///: END:ONLY_INCLUDE_IN import { ACTION_QUEUE_METRICS_E2E_TEST } from '../../shared/constants/test-flags'; + import { onMessageReceived, checkForMultipleVersionsRunning, } from './detect-multiple-instances'; +///: BEGIN:ONLY_INCLUDE_IN(build-mmi) +import MMIController from './controllers/mmi-controller'; +import { mmiKeyringBuilderFactory } from './mmi-keyring-builder-factory'; +///: END:ONLY_INCLUDE_IN import ComposableObservableStore from './lib/ComposableObservableStore'; import AccountTracker from './lib/account-tracker'; import createDupeReqFilterMiddleware from './lib/createDupeReqFilterMiddleware'; @@ -264,6 +285,13 @@ export default class MetamaskController extends EventEmitter { ], }); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + this.mmiConfigurationController = new MmiConfigurationController({ + initState: initState.MmiConfigurationController, + mmiConfigurationServiceUrl: process.env.MMI_CONFIGURATION_SERVICE_URL, + }); + ///: END:ONLY_INCLUDE_IN + const networkControllerMessenger = this.controllerMessenger.getRestricted({ name: 'NetworkController', allowedEvents: [ @@ -273,6 +301,7 @@ export default class MetamaskController extends EventEmitter { 'NetworkController:infuraIsUnblocked', ], }); + this.networkController = new NetworkController({ messenger: networkControllerMessenger, state: initState.NetworkController, @@ -725,9 +754,21 @@ export default class MetamaskController extends EventEmitter { keyringOverrides?.lattice || LatticeKeyring, QRHardwareKeyring, ]; + additionalKeyrings = additionalKeyringTypes.map((keyringType) => keyringBuilderFactory(keyringType), ); + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + for (const custodianType of Object.keys(CUSTODIAN_TYPES)) { + additionalKeyrings.push( + mmiKeyringBuilderFactory( + CUSTODIAN_TYPES[custodianType].keyringClass, + { mmiConfigurationController: this.mmiConfigurationController }, + ), + ); + } + ///: END:ONLY_INCLUDE_IN } this.keyringController = new KeyringController({ @@ -984,6 +1025,22 @@ export default class MetamaskController extends EventEmitter { preferencesStore: this.preferencesController.store, }); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + this.custodyController = new CustodyController({ + initState: initState.CustodyController, + }); + this.institutionalFeaturesController = new InstitutionalFeaturesController({ + initState: initState.InstitutionalFeaturesController, + showConfirmRequest: opts.showUserConfirmation, + }); + this.transactionUpdateController = new TransactionUpdateController({ + initState: initState.TransactionUpdateController, + getCustodyKeyring: this.getCustodyKeyringIfExists.bind(this), + mmiConfigurationController: this.mmiConfigurationController, + captureException, + }); + ///: END:ONLY_INCLUDE_IN + this.backupController = new BackupController({ preferencesController: this.preferencesController, addressBookController: this.addressBookController, @@ -1054,6 +1111,9 @@ export default class MetamaskController extends EventEmitter { getDeviceModel: this.getDeviceModel.bind(this), getTokenStandardAndDetails: this.getTokenStandardAndDetails.bind(this), securityProviderRequest: this.securityProviderRequest.bind(this), + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + transactionUpdateController: this.transactionUpdateController, + ///: END:ONLY_INCLUDE_IN messenger: this.controllerMessenger.getRestricted({ name: 'TransactionController', allowedActions: [ @@ -1064,6 +1124,28 @@ export default class MetamaskController extends EventEmitter { }), }); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + this.mmiController = new MMIController({ + mmiConfigurationController: this.mmiConfigurationController, + keyringController: this.keyringController, + txController: this.txController, + securityProviderRequest: this.securityProviderRequest.bind(this), + preferencesController: this.preferencesController, + appStateController: this.appStateController, + transactionUpdateController: this.transactionUpdateController, + custodyController: this.custodyController, + institutionalFeaturesController: this.institutionalFeaturesController, + getState: this.getState.bind(this), + getPendingNonce: this.getPendingNonce.bind(this), + accountTracker: this.accountTracker, + metaMetricsController: this.metaMetricsController, + networkController: this.networkController, + permissionController: this.permissionController, + platform: this.platform, + extension: this.extension, + }); + ///: END:ONLY_INCLUDE_IN + this.txController.on(`tx:status-update`, async (txId, status) => { if ( status === TransactionStatus.confirmed || @@ -1431,6 +1513,13 @@ export default class MetamaskController extends EventEmitter { ///: BEGIN:ONLY_INCLUDE_IN(desktop) DesktopController: this.desktopController.store, ///: END:ONLY_INCLUDE_IN + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + CustodyController: this.custodyController.store, + InstitutionalFeaturesController: + this.institutionalFeaturesController.store, + MmiConfigurationController: this.mmiConfigurationController.store, + ///: END:ONLY_INCLUDE_IN ...resetOnRestartStore, }); @@ -1467,6 +1556,13 @@ export default class MetamaskController extends EventEmitter { ///: BEGIN:ONLY_INCLUDE_IN(desktop) DesktopController: this.desktopController.store, ///: END:ONLY_INCLUDE_IN + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + CustodyController: this.custodyController.store, + InstitutionalFeaturesController: + this.institutionalFeaturesController.store, + MmiConfigurationController: this.mmiConfigurationController.store, + ///: END:ONLY_INCLUDE_IN ...resetOnRestartStore, }, controllerMessenger: this.controllerMessenger, @@ -2236,6 +2332,72 @@ export default class MetamaskController extends EventEmitter { rejectPermissionsRequest: this.rejectPermissionsRequest, ...getPermissionBackgroundApiMethods(permissionController), + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + connectCustodyAddresses: + this.mmiController.connectCustodyAddresses.bind(this), + getCustodianAccounts: this.mmiController.getCustodianAccounts.bind(this), + getCustodianAccountsByAddress: + this.mmiController.getCustodianAccountsByAddress.bind(this), + getCustodianTransactionDeepLink: + this.mmiController.getCustodianTransactionDeepLink.bind(this), + getCustodianConfirmDeepLink: + this.mmiController.getCustodianConfirmDeepLink.bind(this), + getCustodianSignMessageDeepLink: + this.mmiController.getCustodianSignMessageDeepLink.bind(this), + getCustodianToken: this.mmiController.getCustodianToken.bind(this), + getCustodianJWTList: this.mmiController.getCustodianJWTList.bind(this), + setWaitForConfirmDeepLinkDialog: + this.custodyController.setWaitForConfirmDeepLinkDialog.bind( + this.custodyController, + ), + setCustodianConnectRequest: + this.custodyController.setCustodianConnectRequest.bind( + this.custodyController, + ), + getCustodianConnectRequest: + this.custodyController.getCustodianConnectRequest.bind( + this.custodyController, + ), + getAllCustodianAccountsWithToken: + this.mmiController.getAllCustodianAccountsWithToken.bind(this), + getMmiConfiguration: + this.mmiConfigurationController.getConfiguration.bind( + this.mmiConfigurationController, + ), + setComplianceAuthData: + this.institutionalFeaturesController.setComplianceAuthData.bind( + this.institutionalFeaturesController, + ), + deleteComplianceAuthData: + this.institutionalFeaturesController.deleteComplianceAuthData.bind( + this.institutionalFeaturesController, + ), + generateComplianceReport: + this.institutionalFeaturesController.generateComplianceReport.bind( + this.institutionalFeaturesController, + ), + syncReportsInProgress: + this.institutionalFeaturesController.syncReportsInProgress.bind( + this.institutionalFeaturesController, + ), + + removeConnectInstitutionalFeature: + this.institutionalFeaturesController.removeConnectInstitutionalFeature.bind( + this.institutionalFeaturesController, + ), + + getComplianceHistoricalReportsByAddress: + this.institutionalFeaturesController.getComplianceHistoricalReportsByAddress.bind( + this.institutionalFeaturesController, + ), + removeAddTokenConnectRequest: + this.institutionalFeaturesController.removeAddTokenConnectRequest.bind( + this.institutionalFeaturesController, + ), + setCustodianNewRefreshToken: + this.mmiController.setCustodianNewRefreshToken.bind(this), + ///: END:ONLY_INCLUDE_IN + ///: BEGIN:ONLY_INCLUDE_IN(snaps) // snaps removeSnapError: this.controllerMessenger.call.bind( @@ -2666,6 +2828,10 @@ export default class MetamaskController extends EventEmitter { async submitPassword(password) { await this.keyringController.submitPassword(password); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + this.mmiController.onSubmitPassword(); + ///: END:ONLY_INCLUDE_IN + try { await this.blockTracker.checkForLatestBlock(); } catch (error) { @@ -2785,6 +2951,16 @@ export default class MetamaskController extends EventEmitter { return keyring.mnemonic; } + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + async getCustodyKeyringIfExists(address) { + const custodyType = this.custodyController.getCustodyTypeByAddress( + toChecksumHexAddress(address), + ); + const keyring = this.keyringController.getKeyringsByType(custodyType)[0]; + return keyring?.getAccountDetails(address) ? keyring : undefined; + } + ///: END:ONLY_INCLUDE_IN + // // Hardware // @@ -3173,6 +3349,10 @@ export default class MetamaskController extends EventEmitter { // Remove account from the account tracker controller this.accountTracker.removeAccount([address]); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + this.custodyController.removeAccount(address); + ///: END:ONLY_INCLUDE_IN(build-mmi) + const keyring = await this.keyringController.getKeyringForAccount(address); // Remove account from the keyring await this.keyringController.removeAccount(address); @@ -3731,6 +3911,21 @@ export default class MetamaskController extends EventEmitter { this.alertController.setWeb3ShimUsageRecorded.bind( this.alertController, ), + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + handleMmiAuthenticate: + this.institutionalFeaturesController.handleMmiAuthenticate.bind( + this.institutionalFeaturesController, + ), + handleMmiCheckIfTokenIsPresent: + this.mmiController.handleMmiCheckIfTokenIsPresent.bind(this), + handleMmiPortfolio: this.mmiController.setMmiPortfolioCookie.bind(this), + handleMmiOpenSwaps: this.mmiController.handleMmiOpenSwaps.bind(this), + handleMmiSetAccountAndNetwork: + this.mmiController.setAccountAndNetwork.bind(this), + handleMmiOpenAddHardwareWallet: + this.mmiController.handleMmiOpenAddHardwareWallet.bind(this), + ///: END:ONLY_INCLUDE_IN }), ); diff --git a/app/scripts/mmi-keyring-builder-factory.js b/app/scripts/mmi-keyring-builder-factory.js new file mode 100644 index 000000000000..a532df071562 --- /dev/null +++ b/app/scripts/mmi-keyring-builder-factory.js @@ -0,0 +1,17 @@ +/** + * Get builder function for MMI keyrings which require an additional `opts` + * parameter, used to pass MMI configuration. + * + * Returns a builder function for `Keyring` with a `type` property. + * + * @param {Keyring} Keyring - The Keyring class for the builder. + * @param {Keyring} opts - Optional parameters to be passed to the builder. + * @returns {Function} A builder function for the given Keyring. + */ +export function mmiKeyringBuilderFactory(Keyring, opts) { + const builder = () => new Keyring(opts); + + builder.type = Keyring.type; + + return builder; +} diff --git a/coverage-targets.js b/coverage-targets.js index c9b4ac370798..bc651cd246bf 100644 --- a/coverage-targets.js +++ b/coverage-targets.js @@ -6,10 +6,10 @@ // subset of files to check against these targets. module.exports = { global: { - lines: 71.15, - branches: 59.17, - statements: 70.6, - functions: 63.82, + lines: 70.94, + branches: 59.11, + statements: 70.38, + functions: 63.65, }, transforms: { branches: 100, diff --git a/jest.config.js b/jest.config.js index 35c9f342cfa6..814ea874e9b1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -37,6 +37,7 @@ module.exports = { testMatch: [ '/app/scripts/constants/error-utils.test.js', '/app/scripts/controllers/app-state.test.js', + '/app/scripts/controllers/mmi-controller.test.js', '/app/scripts/controllers/network/**/*.test.js', '/app/scripts/controllers/network/**/*.test.ts', '/app/scripts/controllers/permissions/**/*.test.js', diff --git a/package.json b/package.json index 735079d222b4..c5dfbd8dffb8 100644 --- a/package.json +++ b/package.json @@ -216,8 +216,13 @@ "@keystonehq/metamask-airgapped-keyring": "^0.9.2", "@lavamoat/snow": "^1.5.0", "@material-ui/core": "^4.11.0", + "@metamask-institutional/custody-controller": "0.2.6", + "@metamask-institutional/custody-keyring": "0.0.23", "@metamask-institutional/extension": "^0.1.3", + "@metamask-institutional/institutional-features": "^1.1.8", "@metamask-institutional/portfolio-dashboard": "^1.1.3", + "@metamask-institutional/sdk": "^0.1.17", + "@metamask-institutional/transaction-update": "^0.1.21", "@metamask/address-book-controller": "^2.0.0", "@metamask/announcement-controller": "^3.0.0", "@metamask/approval-controller": "^2.1.0", diff --git a/shared/constants/transaction.ts b/shared/constants/transaction.ts index dad1a72e1a61..1d702140218c 100644 --- a/shared/constants/transaction.ts +++ b/shared/constants/transaction.ts @@ -165,6 +165,18 @@ export const IN_PROGRESS_TRANSACTION_STATUSES = [ TransactionStatus.pending, ]; +///: BEGIN:ONLY_INCLUDE_IN(build-mmi) +/** + * Status for finalized transactions. + */ +export const FINALIZED_TRANSACTION_STATUSES = [ + TransactionStatus.rejected, + TransactionStatus.failed, + TransactionStatus.dropped, + TransactionStatus.confirmed, +]; +///: END:ONLY_INCLUDE_IN + /** * Transaction Group Status is a MetaMask construct to track the status of groups * of transactions. diff --git a/yarn.lock b/yarn.lock index 1f2740503303..ea09b52aaf37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -62,6 +62,13 @@ __metadata: languageName: node linkType: hard +"@auth0/auth0-spa-js@npm:^2.0.4": + version: 2.0.5 + resolution: "@auth0/auth0-spa-js@npm:2.0.5" + checksum: 3354ccfb2cd85657f0fe584f769cc2646c03f58fbc67859220dc9f8c359e9118b3f141b7ed9e75088b55cbaf047ee0351d3d00f7df00e108905259ab8ea6fe62 + languageName: node + linkType: hard + "@aw-web-design/x-default-browser@npm:1.4.88": version: 1.4.88 resolution: "@aw-web-design/x-default-browser@npm:1.4.88" @@ -3660,7 +3667,7 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/custody-controller@npm:^0.2.5": +"@metamask-institutional/custody-controller@npm:0.2.6, @metamask-institutional/custody-controller@npm:^0.2.5": version: 0.2.6 resolution: "@metamask-institutional/custody-controller@npm:0.2.6" dependencies: @@ -3673,6 +3680,22 @@ __metadata: languageName: node linkType: hard +"@metamask-institutional/custody-keyring@npm:0.0.23": + version: 0.0.23 + resolution: "@metamask-institutional/custody-keyring@npm:0.0.23" + dependencies: + "@ethereumjs/tx": ^4.1.1 + "@ethereumjs/util": ^8.0.5 + "@metamask-institutional/configuration-client": ^1.0.6 + "@metamask-institutional/sdk": ^0.1.15 + "@metamask-institutional/types": ^1.0.2 + "@metamask/obs-store": ^8.0.0 + crypto: ^1.0.1 + lodash.clonedeep: ^4.5.0 + checksum: eae1003ddfd262526d28c23d6dbdfbc6d42879bb989c9bcf97416d3964aaa6ce202a0803c46256fb1afc1399592176ba2fdfcbd2043c4f1275f5079e067c3a78 + languageName: node + linkType: hard + "@metamask-institutional/custody-keyring@npm:^0.0.22": version: 0.0.22 resolution: "@metamask-institutional/custody-keyring@npm:0.0.22" @@ -3706,6 +3729,17 @@ __metadata: languageName: node linkType: hard +"@metamask-institutional/institutional-features@npm:^1.1.8": + version: 1.1.8 + resolution: "@metamask-institutional/institutional-features@npm:1.1.8" + dependencies: + "@auth0/auth0-spa-js": ^2.0.4 + "@metamask-institutional/custody-keyring": ^0.0.22 + "@metamask/obs-store": ^8.0.0 + checksum: 3942afd436673d19d16e139c4a989a7c099604b915ef63901ee77c52c9087848256d45db0b27950ac2181f9a9db16b231b3d9de89007c244db08b767668a617f + languageName: node + linkType: hard + "@metamask-institutional/portfolio-dashboard@npm:^1.1.3": version: 1.1.3 resolution: "@metamask-institutional/portfolio-dashboard@npm:1.1.3" @@ -3713,7 +3747,7 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/sdk@npm:^0.1.14, @metamask-institutional/sdk@npm:^0.1.15, @metamask-institutional/sdk@npm:^0.1.16": +"@metamask-institutional/sdk@npm:^0.1.14, @metamask-institutional/sdk@npm:^0.1.15, @metamask-institutional/sdk@npm:^0.1.16, @metamask-institutional/sdk@npm:^0.1.17": version: 0.1.17 resolution: "@metamask-institutional/sdk@npm:0.1.17" dependencies: @@ -3734,7 +3768,7 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/transaction-update@npm:^0.1.20": +"@metamask-institutional/transaction-update@npm:^0.1.20, @metamask-institutional/transaction-update@npm:^0.1.21": version: 0.1.21 resolution: "@metamask-institutional/transaction-update@npm:0.1.21" dependencies: @@ -23796,8 +23830,13 @@ __metadata: "@lavamoat/lavapack": ^5.0.0 "@lavamoat/snow": ^1.5.0 "@material-ui/core": ^4.11.0 + "@metamask-institutional/custody-controller": 0.2.6 + "@metamask-institutional/custody-keyring": 0.0.23 "@metamask-institutional/extension": ^0.1.3 + "@metamask-institutional/institutional-features": ^1.1.8 "@metamask-institutional/portfolio-dashboard": ^1.1.3 + "@metamask-institutional/sdk": ^0.1.17 + "@metamask-institutional/transaction-update": ^0.1.21 "@metamask/address-book-controller": ^2.0.0 "@metamask/announcement-controller": ^3.0.0 "@metamask/approval-controller": ^2.1.0 From 97a983418290cd97f2176ffda82887f053f1d8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Oliv=C3=A9?= Date: Mon, 29 May 2023 17:50:56 +0200 Subject: [PATCH 14/19] =?UTF-8?q?[MMI]=C2=A0Add=20confirm-transaction-base?= =?UTF-8?q?=20code=20fences=20(#18795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added code fences * Continue working on this ticket * Fixed policies * Added compliance-row component * Fixed tests and css * Fixed invalid locale * Fixing linting * Add optional check * Fixing issues * Fixed storybook * Added missing dependency * ran lavamoat auto * ran dedupe and lavamoat * lint * Removed compliance row * Removed unneeded package * Removed unneeded proptyes * updates mmi packages * updating lavamoat * formatting main * Fixed conflicts * updates lock file * Moved code fences to have them all in the same place * Updated yarn.lock and lavamoat * remove linebreak * Improved logic in order to not have many code fences and improve readability * Fixing proptypes issues with eslint * runs lavamoat auto * Testing fixes issue e2e tests * Testing issues * Reverting code fences container * Fixing issue with binding * Added code fences in proptypes * Reverting code fences --------- Co-authored-by: Antonio Regadas Co-authored-by: António Regadas --- lavamoat/browserify/beta/policy.json | 103 ++++++++ lavamoat/browserify/desktop/policy.json | 103 ++++++++ lavamoat/browserify/flask/policy.json | 103 ++++++++ lavamoat/browserify/main/policy.json | 103 ++++++++ .../confirm-transaction-base.component.js | 220 +++++++++++++----- .../confirm-transaction-base.container.js | 88 +++++-- ui/selectors/institutional/selectors.js | 13 ++ 7 files changed, 651 insertions(+), 82 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index f818bbd0ecf8..316c0bb86e51 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -783,6 +783,109 @@ "@babel/runtime": true } }, + "@metamask-institutional/extension": { + "globals": { + "console.log": true, + "fetch": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": { + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, + "@metamask/obs-store": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { + "globals": { + "console.log": true, + "console.warn": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true, + "@metamask/obs-store": true, + "browserify>crypto-browserify": true, + "browserify>events": true, + "gulp-sass>lodash.clonedeep": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { + "globals": { + "console.log": true, + "fetch": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk": { + "globals": { + "URLSearchParams": true, + "console.debug": true, + "console.log": true, + "console.warn": true, + "fetch": true + }, + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, + "browserify>crypto-browserify": true, + "browserify>events": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { + "globals": { + "crypto": true, + "define": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, + "browserify>buffer": true, + "browserify>crypto-browserify": true, + "browserify>process": true, + "lodash": true, + "mocha>ms": true, + "semver": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, + "browserify>buffer": true, + "browserify>process": true, + "browserify>stream-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, + "browserify>crypto-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { + "packages": { + "browserify>buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { + "packages": { + "ethereumjs-wallet>safe-buffer": true + } + }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index 5236b5b2658c..eb47cfbee84e 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -783,6 +783,109 @@ "@babel/runtime": true } }, + "@metamask-institutional/extension": { + "globals": { + "console.log": true, + "fetch": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": { + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, + "@metamask/obs-store": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { + "globals": { + "console.log": true, + "console.warn": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true, + "@metamask/obs-store": true, + "browserify>crypto-browserify": true, + "browserify>events": true, + "gulp-sass>lodash.clonedeep": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { + "globals": { + "console.log": true, + "fetch": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk": { + "globals": { + "URLSearchParams": true, + "console.debug": true, + "console.log": true, + "console.warn": true, + "fetch": true + }, + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, + "browserify>crypto-browserify": true, + "browserify>events": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { + "globals": { + "crypto": true, + "define": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, + "browserify>buffer": true, + "browserify>crypto-browserify": true, + "browserify>process": true, + "lodash": true, + "mocha>ms": true, + "semver": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, + "browserify>buffer": true, + "browserify>process": true, + "browserify>stream-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, + "browserify>crypto-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { + "packages": { + "browserify>buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { + "packages": { + "ethereumjs-wallet>safe-buffer": true + } + }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 5236b5b2658c..eb47cfbee84e 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -783,6 +783,109 @@ "@babel/runtime": true } }, + "@metamask-institutional/extension": { + "globals": { + "console.log": true, + "fetch": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": { + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, + "@metamask/obs-store": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { + "globals": { + "console.log": true, + "console.warn": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true, + "@metamask/obs-store": true, + "browserify>crypto-browserify": true, + "browserify>events": true, + "gulp-sass>lodash.clonedeep": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { + "globals": { + "console.log": true, + "fetch": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk": { + "globals": { + "URLSearchParams": true, + "console.debug": true, + "console.log": true, + "console.warn": true, + "fetch": true + }, + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, + "browserify>crypto-browserify": true, + "browserify>events": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { + "globals": { + "crypto": true, + "define": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, + "browserify>buffer": true, + "browserify>crypto-browserify": true, + "browserify>process": true, + "lodash": true, + "mocha>ms": true, + "semver": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, + "browserify>buffer": true, + "browserify>process": true, + "browserify>stream-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, + "browserify>crypto-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { + "packages": { + "browserify>buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { + "packages": { + "ethereumjs-wallet>safe-buffer": true + } + }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index f818bbd0ecf8..316c0bb86e51 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -783,6 +783,109 @@ "@babel/runtime": true } }, + "@metamask-institutional/extension": { + "globals": { + "console.log": true, + "fetch": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-controller": { + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, + "@metamask/obs-store": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { + "globals": { + "console.log": true, + "console.warn": true + }, + "packages": { + "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, + "@metamask-institutional/extension>@metamask-institutional/sdk": true, + "@metamask-institutional/extension>@metamask-institutional/types": true, + "@metamask/obs-store": true, + "browserify>crypto-browserify": true, + "browserify>events": true, + "gulp-sass>lodash.clonedeep": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { + "globals": { + "console.log": true, + "fetch": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk": { + "globals": { + "URLSearchParams": true, + "console.debug": true, + "console.log": true, + "console.warn": true, + "fetch": true + }, + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, + "browserify>crypto-browserify": true, + "browserify>events": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { + "globals": { + "crypto": true, + "define": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, + "browserify>buffer": true, + "browserify>crypto-browserify": true, + "browserify>process": true, + "lodash": true, + "mocha>ms": true, + "semver": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, + "browserify>buffer": true, + "browserify>process": true, + "browserify>stream-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { + "packages": { + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, + "browserify>crypto-browserify": true, + "browserify>util": true, + "ethereumjs-wallet>safe-buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { + "packages": { + "browserify>buffer": true + } + }, + "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { + "packages": { + "ethereumjs-wallet>safe-buffer": true + } + }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 6934f0b0423b..850b2e490889 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -133,13 +133,15 @@ export default class ConfirmTransactionBase extends Component { hardwareWalletRequiresConnection: PropTypes.bool, isMultiLayerFeeNetwork: PropTypes.bool, isBuyableChain: PropTypes.bool, - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - accountType: PropTypes.string, - isNoteToTraderSupported: PropTypes.bool, - ///: END:ONLY_INCLUDE_IN isApprovalOrRejection: PropTypes.bool, assetStandard: PropTypes.string, useCurrencyRateCheck: PropTypes.bool, + isNotification: PropTypes.bool, + accountType: PropTypes.string, + setWaitForConfirmDeepLinkDialog: PropTypes.func, + showTransactionsFailedModal: PropTypes.func, + showCustodianDeepLink: PropTypes.func, + isNoteToTraderSupported: PropTypes.bool, }; state = { @@ -593,36 +595,81 @@ export default class ConfirmTransactionBase extends Component { } handleSubmit() { + let submit = this.handleMainSubmit.bind(this); + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + submit = this.handleMMISubmit.bind(this); + ///: END:ONLY_INCLUDE_IN + + submit(); + } + + handleMainSubmit() { const { sendTransaction, txData, history, mostRecentOverviewPage, updateCustomNonce, - maxFeePerGas, - customTokenAmount, - dappProposedTokenAmount, - currentTokenBalance, - maxPriorityFeePerGas, - baseFeePerGas, - methodData, - addToAddressBookIfNew, - toAccounts, - toAddress, - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + } = this.props; + + this.updateTxData(); + + this.setState( + { + submitting: true, + submitError: null, + }, + () => { + this._removeBeforeUnload(); + + sendTransaction(txData) + .then(() => { + if (!this._isMounted) { + return; + } + + this.setState( + { + submitting: false, + }, + () => { + history.push(mostRecentOverviewPage); + updateCustomNonce(''); + }, + ); + }) + .catch((error) => { + if (!this._isMounted) { + return; + } + this.setState({ + submitting: false, + submitError: error.message, + }); + updateCustomNonce(''); + }); + }, + ); + } + + handleMMISubmit() { + const { + sendTransaction, + txData, + history, + mostRecentOverviewPage, + updateCustomNonce, + unapprovedTxCount, accountType, + isNotification, + setWaitForConfirmDeepLinkDialog, + showTransactionsFailedModal, + fromAddress, isNoteToTraderSupported, - ///: END:ONLY_INCLUDE_IN } = this.props; - const { - submitting, - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - noteText, - ///: END:ONLY_INCLUDE_IN - } = this.state; - const { name } = methodData; + const { noteText } = this.state; - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) if (accountType === 'custody') { txData.custodyStatus = 'created'; @@ -632,7 +679,92 @@ export default class ConfirmTransactionBase extends Component { }; } } - ///: END:ONLY_INCLUDE_IN + + this.updateTxData(); + + this.setState( + { + submitting: true, + submitError: null, + }, + () => { + this._removeBeforeUnload(); + + if (txData.custodyStatus) { + setWaitForConfirmDeepLinkDialog(true); + } + + sendTransaction(txData) + .then(() => { + if (!this._isMounted) { + return; + } + + if (txData.custodyStatus) { + this.props.showCustodianDeepLink({ + fromAddress, + closeNotification: isNotification && unapprovedTxCount === 1, + txId: txData.id, + onDeepLinkFetched: () => { + this.context.trackEvent({ + category: 'MMI', + event: 'Show deeplink for transaction', + }); + }, + onDeepLinkShown: () => { + this.props.clearConfirmTransaction(); + this.setState({ submitting: false }, () => { + history.push(mostRecentOverviewPage); + updateCustomNonce(''); + }); + }, + }); + } else { + this.setState( + { + submitting: false, + }, + () => { + history.push(mostRecentOverviewPage); + updateCustomNonce(''); + }, + ); + } + }) + .catch((error) => { + if (!this._isMounted) { + return; + } + + showTransactionsFailedModal(error.message, isNotification); + + this.setState({ + submitting: false, + submitError: error.message, + }); + setWaitForConfirmDeepLinkDialog(true); + updateCustomNonce(''); + }); + }, + ); + } + + updateTxData() { + const { + txData, + maxFeePerGas, + customTokenAmount, + dappProposedTokenAmount, + currentTokenBalance, + maxPriorityFeePerGas, + baseFeePerGas, + addToAddressBookIfNew, + toAccounts, + toAddress, + methodData, + } = this.props; + const { submitting } = this.state; + const { name } = methodData; if (txData.type === TransactionType.simpleSend) { addToAddressBookIfNew(toAddress, toAccounts); @@ -678,44 +810,6 @@ export default class ConfirmTransactionBase extends Component { maxPriorityFeePerGas, }; } - - this.setState( - { - submitting: true, - submitError: null, - }, - () => { - this._removeBeforeUnload(); - - sendTransaction(txData) - .then(() => { - if (!this._isMounted) { - return; - } - - this.setState( - { - submitting: false, - }, - () => { - history.push(mostRecentOverviewPage); - updateCustomNonce(''); - }, - ); - }) - .catch((error) => { - if (!this._isMounted) { - return; - } - - this.setState({ - submitting: false, - submitError: error.message, - }); - updateCustomNonce(''); - }); - }, - ); } handleSetApprovalForAll() { diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js index aba96a1d2f66..9514ccea68c7 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -1,7 +1,10 @@ import { connect } from 'react-redux'; import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; - +///: BEGIN:ONLY_INCLUDE_IN(build-mmi) +import { showCustodianDeepLink } from '@metamask-institutional/extension'; +import { mmiActionsFactory } from '../../store/institutional/institution-background'; +///: END:ONLY_INCLUDE_IN import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'; import { @@ -48,7 +51,12 @@ import { getSendToAccounts, getProviderConfig, } from '../../ducks/metamask/metamask'; -import { addHexPrefix } from '../../../app/scripts/lib/util'; +import { + addHexPrefix, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + getEnvironmentType, + ///: END:ONLY_INCLUDE_IN +} from '../../../app/scripts/lib/util'; import { parseStandardTokenTransactionData, @@ -63,8 +71,11 @@ import { import { getGasLoadingAnimationIsShowing } from '../../ducks/app/app'; import { isLegacyTransaction } from '../../helpers/utils/transactions.util'; import { CUSTOM_GAS_ESTIMATE } from '../../../shared/constants/gas'; + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) import { getAccountType } from '../../selectors/selectors'; +import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app'; +import { getIsNoteToTraderSupported } from '../../selectors/institutional/selectors'; ///: END:ONLY_INCLUDE_IN import { TransactionStatus, @@ -100,6 +111,11 @@ const mapStateToProps = (state, ownProps) => { const { id: paramsTransactionId } = params; const isMainnet = getIsMainnet(state); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const envType = getEnvironmentType(); + const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION; + ///: END:ONLY_INCLUDE_IN + const isGasEstimatesLoading = getIsGasEstimatesLoading(state); const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state); const isBuyableChain = getIsBuyableChain(state); @@ -199,29 +215,20 @@ const mapStateToProps = (state, ownProps) => { txParamsAreDappSuggested(fullTxData); const fromAddressIsLedger = isAddressLedger(state, fromAddress); const nativeCurrency = getNativeCurrency(state); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const accountType = getAccountType(state, fromAddress); + const fromChecksumHexAddress = toChecksumHexAddress(fromAddress); + const isNoteToTraderSupported = getIsNoteToTraderSupported( + state, + fromChecksumHexAddress, + ); + ///: END:ONLY_INCLUDE_IN const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(state, fromAddress); const isMultiLayerFeeNetwork = getIsMultiLayerFeeNetwork(state); - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - const accountType = getAccountType(state); - - const fromChecksumHexAddress = toChecksumHexAddress(fromAddress); - let isNoteToTraderSupported = false; - if ( - state.metamask.custodyAccountDetails && - state.metamask.custodyAccountDetails[fromChecksumHexAddress] - ) { - const { custodianName } = - state.metamask.custodyAccountDetails[fromChecksumHexAddress]; - isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find( - (custodian) => custodian.name === custodianName, - )?.isNoteToTraderSupported; - } - ///: END:ONLY_INCLUDE_IN - return { balance, fromAddress, @@ -275,11 +282,15 @@ const mapStateToProps = (state, ownProps) => { ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) accountType, isNoteToTraderSupported, + isNotification, ///: END:ONLY_INCLUDE_IN }; }; export const mapDispatchToProps = (dispatch) => { + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const mmiActions = mmiActionsFactory(); + ///: END:ONLY_INCLUDE_IN return { tryReverseResolveAddress: (address) => { return dispatch(tryReverseResolveAddress(address)); @@ -316,6 +327,45 @@ export const mapDispatchToProps = (dispatch) => { dispatch(addToAddressBook(hexPrefixedAddress, nickname)); } }, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + getCustodianConfirmDeepLink: (id) => + dispatch(mmiActions.getCustodianConfirmDeepLink(id)), + showCustodyConfirmLink: ({ link, address, closeNotification, custodyId }) => + dispatch( + mmiActions.showCustodyConfirmLink({ + link, + address, + closeNotification, + custodyId, + }), + ), + showTransactionsFailedModal: (errorMessage, closeNotification) => + dispatch( + showModal({ + name: 'TRANSACTION_FAILED', + errorMessage, + closeNotification, + }), + ), + showCustodianDeepLink: ({ + txId, + fromAddress, + closeNotification, + onDeepLinkFetched, + onDeepLinkShown, + }) => + showCustodianDeepLink({ + dispatch, + mmiActions, + txId, + fromAddress, + closeNotification, + onDeepLinkFetched, + onDeepLinkShown, + }), + setWaitForConfirmDeepLinkDialog: (wait) => + dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)), + ///: END:ONLY_INCLUDE_IN }; }; diff --git a/ui/selectors/institutional/selectors.js b/ui/selectors/institutional/selectors.js index f08295453c1b..d869b7f23201 100644 --- a/ui/selectors/institutional/selectors.js +++ b/ui/selectors/institutional/selectors.js @@ -78,3 +78,16 @@ export function getMMIConfiguration(state) { export function getInteractiveReplacementToken(state) { return state.metamask.interactiveReplacementToken || {}; } + +export function getIsNoteToTraderSupported(state, fromChecksumHexAddress) { + let isNoteToTraderSupported = false; + if (state.metamask.custodyAccountDetails?.[fromChecksumHexAddress]) { + const { custodianName } = + state.metamask.custodyAccountDetails[fromChecksumHexAddress]; + + isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find( + (custodian) => custodian.name === custodianName, + )?.isNoteToTraderSupported; + } + return isNoteToTraderSupported; +} From cdaa21b3cbcbe9834d8230a1a58a42d7ba9e9457 Mon Sep 17 00:00:00 2001 From: Dhruv <79097544+dhruvv173@users.noreply.github.com> Date: Tue, 30 May 2023 04:46:11 +0530 Subject: [PATCH 15/19] Changes to Popover folder (#19245) --- .../popover/popover.stories.tsx | 70 +++++++++---------- .../component-library/popover/popover.tsx | 4 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/ui/components/component-library/popover/popover.stories.tsx b/ui/components/component-library/popover/popover.stories.tsx index 776b13737253..ca297daf8a39 100644 --- a/ui/components/component-library/popover/popover.stories.tsx +++ b/ui/components/component-library/popover/popover.stories.tsx @@ -1,12 +1,12 @@ import React, { useState, useEffect } from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { StoryFn, Meta } from '@storybook/react'; import Box from '../../ui/box/box'; import { AlignItems, BackgroundColor, BorderColor, Color, - DISPLAY, + Display, JustifyContent, TextAlign, } from '../../../helpers/constants/design-system'; @@ -41,9 +41,9 @@ export default { args: { children: 'Popover', }, -} as ComponentMeta; +} as Meta; -const Template: ComponentStory = (args) => { +const Template: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [isOpen, setIsOpen] = useState(true); @@ -98,7 +98,7 @@ DefaultStory.args = { hasArrow: true, }; -export const ReferenceElement: ComponentStory = (args) => { +export const ReferenceElement: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -125,7 +125,7 @@ export const ReferenceElement: ComponentStory = (args) => { ); }; -export const Children: ComponentStory = (args) => { +export const Children: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -154,7 +154,7 @@ export const Children: ComponentStory = (args) => { ); }; -export const Position: ComponentStory = (args) => { +export const Position: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [referenceAutoElement, setReferenceAutoElement] = useState(); @@ -176,7 +176,7 @@ export const Position: ComponentStory = (args) => { minHeight: '400px', }} borderColor={BorderColor.borderDefault} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} marginBottom={4} @@ -185,7 +185,7 @@ export const Position: ComponentStory = (args) => { ref={setBoxRef} backgroundColor={BackgroundColor.primaryMuted} style={{ width: 400, height: 200 }} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} textAlign={TextAlign.Center} @@ -316,7 +316,7 @@ export const Position: ComponentStory = (args) => { width: '200vw', height: '200vh', }} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} > @@ -324,7 +324,7 @@ export const Position: ComponentStory = (args) => { ref={setRefAuto} backgroundColor={BackgroundColor.primaryMuted} style={{ width: 400, height: 200 }} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} textAlign={TextAlign.Center} @@ -346,7 +346,7 @@ export const Position: ComponentStory = (args) => { ); }; -export const IsPortal: ComponentStory = (args) => { +export const IsPortal: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -384,7 +384,7 @@ export const IsPortal: ComponentStory = (args) => { ); }; -export const HasArrow: ComponentStory = (args) => { +export const HasArrow: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -419,7 +419,7 @@ export const HasArrow: ComponentStory = (args) => { ); }; -export const IsOpen: ComponentStory = (args) => { +export const IsOpen: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [isOpen, setIsOpen] = useState(true); @@ -438,7 +438,7 @@ export const IsOpen: ComponentStory = (args) => { backgroundColor={BackgroundColor.primaryMuted} style={{ width: 200, height: 200 }} onClick={handleClick} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} > @@ -468,7 +468,7 @@ export const IsOpen: ComponentStory = (args) => { ); }; -export const Flip: ComponentStory = (args) => { +export const Flip: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -478,7 +478,7 @@ export const Flip: ComponentStory = (args) => { return ( @@ -486,7 +486,7 @@ export const Flip: ComponentStory = (args) => { ref={setBoxRef} backgroundColor={BackgroundColor.primaryMuted} style={{ width: 200, height: 200 }} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} > @@ -515,7 +515,7 @@ export const Flip: ComponentStory = (args) => { ); }; -export const PreventOverflow: ComponentStory = (args) => { +export const PreventOverflow: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -525,7 +525,7 @@ export const PreventOverflow: ComponentStory = (args) => { return ( @@ -533,7 +533,7 @@ export const PreventOverflow: ComponentStory = (args) => { ref={setBoxRef} backgroundColor={BackgroundColor.primaryMuted} style={{ width: 200, height: 200 }} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} textAlign={TextAlign.Center} @@ -563,7 +563,7 @@ export const PreventOverflow: ComponentStory = (args) => { ); }; -export const ReferenceHidden: ComponentStory = (args) => { +export const ReferenceHidden: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -573,14 +573,14 @@ export const ReferenceHidden: ComponentStory = (args) => { return ( = (args) => { ); }; -export const MatchWidth: ComponentStory = (args) => { +export const MatchWidth: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -640,7 +640,7 @@ export const MatchWidth: ComponentStory = (args) => { ); }; -export const Role: ComponentStory = (args) => { +export const Role: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -650,14 +650,14 @@ export const Role: ComponentStory = (args) => { return ( = (args) => { ); }; -export const Offset: ComponentStory = (args) => { +export const Offset: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const setBoxRef = (ref) => { @@ -696,14 +696,14 @@ export const Offset: ComponentStory = (args) => { return ( = (args) => { ); }; -export const onPressEscKey: ComponentStory = (args) => { +export const onPressEscKey: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [isOpen, setIsOpen] = useState(false); @@ -768,7 +768,7 @@ export const onPressEscKey: ComponentStory = (args) => { ); }; -export const WithPopoverHeader: ComponentStory = (args) => { +export const WithPopoverHeader: StoryFn = (args) => { const [refTitleElement, setRefTitleElement] = useState(); const [isOpen, setIsOpen] = useState(true); @@ -809,7 +809,7 @@ export const WithPopoverHeader: ComponentStory = (args) => { ); }; -export const MouseEventDemo: ComponentStory = (args) => { +export const MouseEventDemo: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [isOpen, setIsOpen] = useState(false); @@ -846,7 +846,7 @@ export const MouseEventDemo: ComponentStory = (args) => { ); }; -export const OnFocusBlur: ComponentStory = (args) => { +export const OnFocusBlur: StoryFn = (args) => { const [referenceElement, setReferenceElement] = useState(); const [isOpen, setIsOpen] = useState(false); diff --git a/ui/components/component-library/popover/popover.tsx b/ui/components/component-library/popover/popover.tsx index fb35f74014ce..992f48f75227 100644 --- a/ui/components/component-library/popover/popover.tsx +++ b/ui/components/component-library/popover/popover.tsx @@ -7,7 +7,7 @@ import { BackgroundColor, BorderColor, BorderRadius, - DISPLAY, + Display, JustifyContent, } from '../../../helpers/constants/design-system'; import Box from '../../ui/box/box'; @@ -112,7 +112,7 @@ export const Popover = ({ borderColor={BorderColor.borderMuted} className={classnames('mm-popover__arrow')} ref={setArrowElement} - display={DISPLAY.FLEX} + display={Display.Flex} justifyContent={JustifyContent.center} alignItems={AlignItems.center} style={styles.arrow} From f2356b29a5b8d1e51d614fceabed35d8ad7a1a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Tue, 30 May 2023 13:08:07 +0100 Subject: [PATCH 16/19] updates values (#19336) --- coverage-targets.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coverage-targets.js b/coverage-targets.js index bc651cd246bf..631a8b6e737d 100644 --- a/coverage-targets.js +++ b/coverage-targets.js @@ -6,10 +6,10 @@ // subset of files to check against these targets. module.exports = { global: { - lines: 70.94, - branches: 59.11, - statements: 70.38, - functions: 63.65, + lines: 70.85, + branches: 59.07, + statements: 70.3, + functions: 63.52, }, transforms: { branches: 100, From dfafdbb6bda8c86eae0b4c665707ff2477e99a7b Mon Sep 17 00:00:00 2001 From: legobeat <109787230+legobeat@users.noreply.github.com> Date: Tue, 30 May 2023 12:39:38 +0000 Subject: [PATCH 17/19] =?UTF-8?q?Revert=20"[MMI]=C2=A0Add=20confirm-transa?= =?UTF-8?q?ction-base=20code=20fences=20(#18795)"=20(#19328)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 97a983418290cd97f2176ffda82887f053f1d8e9. Co-authored-by: António Regadas --- lavamoat/browserify/beta/policy.json | 103 -------- lavamoat/browserify/desktop/policy.json | 103 -------- lavamoat/browserify/flask/policy.json | 103 -------- lavamoat/browserify/main/policy.json | 103 -------- .../confirm-transaction-base.component.js | 220 +++++------------- .../confirm-transaction-base.container.js | 88 ++----- ui/selectors/institutional/selectors.js | 13 -- 7 files changed, 82 insertions(+), 651 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 316c0bb86e51..f818bbd0ecf8 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -783,109 +783,6 @@ "@babel/runtime": true } }, - "@metamask-institutional/extension": { - "globals": { - "console.log": true, - "fetch": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": { - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, - "@metamask/obs-store": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { - "globals": { - "console.log": true, - "console.warn": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true, - "@metamask/obs-store": true, - "browserify>crypto-browserify": true, - "browserify>events": true, - "gulp-sass>lodash.clonedeep": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { - "globals": { - "console.log": true, - "fetch": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk": { - "globals": { - "URLSearchParams": true, - "console.debug": true, - "console.log": true, - "console.warn": true, - "fetch": true - }, - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, - "browserify>crypto-browserify": true, - "browserify>events": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { - "globals": { - "crypto": true, - "define": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, - "browserify>buffer": true, - "browserify>crypto-browserify": true, - "browserify>process": true, - "lodash": true, - "mocha>ms": true, - "semver": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, - "browserify>buffer": true, - "browserify>process": true, - "browserify>stream-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, - "browserify>crypto-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { - "packages": { - "browserify>buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { - "packages": { - "ethereumjs-wallet>safe-buffer": true - } - }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index eb47cfbee84e..5236b5b2658c 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -783,109 +783,6 @@ "@babel/runtime": true } }, - "@metamask-institutional/extension": { - "globals": { - "console.log": true, - "fetch": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": { - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, - "@metamask/obs-store": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { - "globals": { - "console.log": true, - "console.warn": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true, - "@metamask/obs-store": true, - "browserify>crypto-browserify": true, - "browserify>events": true, - "gulp-sass>lodash.clonedeep": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { - "globals": { - "console.log": true, - "fetch": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk": { - "globals": { - "URLSearchParams": true, - "console.debug": true, - "console.log": true, - "console.warn": true, - "fetch": true - }, - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, - "browserify>crypto-browserify": true, - "browserify>events": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { - "globals": { - "crypto": true, - "define": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, - "browserify>buffer": true, - "browserify>crypto-browserify": true, - "browserify>process": true, - "lodash": true, - "mocha>ms": true, - "semver": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, - "browserify>buffer": true, - "browserify>process": true, - "browserify>stream-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, - "browserify>crypto-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { - "packages": { - "browserify>buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { - "packages": { - "ethereumjs-wallet>safe-buffer": true - } - }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index eb47cfbee84e..5236b5b2658c 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -783,109 +783,6 @@ "@babel/runtime": true } }, - "@metamask-institutional/extension": { - "globals": { - "console.log": true, - "fetch": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": { - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, - "@metamask/obs-store": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { - "globals": { - "console.log": true, - "console.warn": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true, - "@metamask/obs-store": true, - "browserify>crypto-browserify": true, - "browserify>events": true, - "gulp-sass>lodash.clonedeep": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { - "globals": { - "console.log": true, - "fetch": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk": { - "globals": { - "URLSearchParams": true, - "console.debug": true, - "console.log": true, - "console.warn": true, - "fetch": true - }, - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, - "browserify>crypto-browserify": true, - "browserify>events": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { - "globals": { - "crypto": true, - "define": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, - "browserify>buffer": true, - "browserify>crypto-browserify": true, - "browserify>process": true, - "lodash": true, - "mocha>ms": true, - "semver": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, - "browserify>buffer": true, - "browserify>process": true, - "browserify>stream-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, - "browserify>crypto-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { - "packages": { - "browserify>buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { - "packages": { - "ethereumjs-wallet>safe-buffer": true - } - }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 316c0bb86e51..f818bbd0ecf8 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -783,109 +783,6 @@ "@babel/runtime": true } }, - "@metamask-institutional/extension": { - "globals": { - "console.log": true, - "fetch": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-controller": { - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": true, - "@metamask/obs-store": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring": { - "globals": { - "console.log": true, - "console.warn": true - }, - "packages": { - "@ethereumjs/tx>@ethereumjs/util": true, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true, - "@metamask-institutional/extension>@metamask-institutional/sdk": true, - "@metamask-institutional/extension>@metamask-institutional/types": true, - "@metamask/obs-store": true, - "browserify>crypto-browserify": true, - "browserify>events": true, - "gulp-sass>lodash.clonedeep": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": { - "globals": { - "console.log": true, - "fetch": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk": { - "globals": { - "URLSearchParams": true, - "console.debug": true, - "console.log": true, - "console.warn": true, - "fetch": true - }, - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true, - "browserify>crypto-browserify": true, - "browserify>events": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": { - "globals": { - "crypto": true, - "define": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true, - "browserify>buffer": true, - "browserify>crypto-browserify": true, - "browserify>process": true, - "lodash": true, - "mocha>ms": true, - "semver": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true, - "browserify>buffer": true, - "browserify>process": true, - "browserify>stream-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": { - "packages": { - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true, - "browserify>crypto-browserify": true, - "browserify>util": true, - "ethereumjs-wallet>safe-buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": { - "packages": { - "browserify>buffer": true - } - }, - "@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": { - "packages": { - "ethereumjs-wallet>safe-buffer": true - } - }, "@metamask/address-book-controller": { "packages": { "@metamask/base-controller": true, diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 850b2e490889..6934f0b0423b 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -133,15 +133,13 @@ export default class ConfirmTransactionBase extends Component { hardwareWalletRequiresConnection: PropTypes.bool, isMultiLayerFeeNetwork: PropTypes.bool, isBuyableChain: PropTypes.bool, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + accountType: PropTypes.string, + isNoteToTraderSupported: PropTypes.bool, + ///: END:ONLY_INCLUDE_IN isApprovalOrRejection: PropTypes.bool, assetStandard: PropTypes.string, useCurrencyRateCheck: PropTypes.bool, - isNotification: PropTypes.bool, - accountType: PropTypes.string, - setWaitForConfirmDeepLinkDialog: PropTypes.func, - showTransactionsFailedModal: PropTypes.func, - showCustodianDeepLink: PropTypes.func, - isNoteToTraderSupported: PropTypes.bool, }; state = { @@ -595,81 +593,36 @@ export default class ConfirmTransactionBase extends Component { } handleSubmit() { - let submit = this.handleMainSubmit.bind(this); - - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - submit = this.handleMMISubmit.bind(this); - ///: END:ONLY_INCLUDE_IN - - submit(); - } - - handleMainSubmit() { const { sendTransaction, txData, history, mostRecentOverviewPage, updateCustomNonce, - } = this.props; - - this.updateTxData(); - - this.setState( - { - submitting: true, - submitError: null, - }, - () => { - this._removeBeforeUnload(); - - sendTransaction(txData) - .then(() => { - if (!this._isMounted) { - return; - } - - this.setState( - { - submitting: false, - }, - () => { - history.push(mostRecentOverviewPage); - updateCustomNonce(''); - }, - ); - }) - .catch((error) => { - if (!this._isMounted) { - return; - } - this.setState({ - submitting: false, - submitError: error.message, - }); - updateCustomNonce(''); - }); - }, - ); - } - - handleMMISubmit() { - const { - sendTransaction, - txData, - history, - mostRecentOverviewPage, - updateCustomNonce, - unapprovedTxCount, + maxFeePerGas, + customTokenAmount, + dappProposedTokenAmount, + currentTokenBalance, + maxPriorityFeePerGas, + baseFeePerGas, + methodData, + addToAddressBookIfNew, + toAccounts, + toAddress, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) accountType, - isNotification, - setWaitForConfirmDeepLinkDialog, - showTransactionsFailedModal, - fromAddress, isNoteToTraderSupported, + ///: END:ONLY_INCLUDE_IN } = this.props; - const { noteText } = this.state; + const { + submitting, + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + noteText, + ///: END:ONLY_INCLUDE_IN + } = this.state; + const { name } = methodData; + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) if (accountType === 'custody') { txData.custodyStatus = 'created'; @@ -679,92 +632,7 @@ export default class ConfirmTransactionBase extends Component { }; } } - - this.updateTxData(); - - this.setState( - { - submitting: true, - submitError: null, - }, - () => { - this._removeBeforeUnload(); - - if (txData.custodyStatus) { - setWaitForConfirmDeepLinkDialog(true); - } - - sendTransaction(txData) - .then(() => { - if (!this._isMounted) { - return; - } - - if (txData.custodyStatus) { - this.props.showCustodianDeepLink({ - fromAddress, - closeNotification: isNotification && unapprovedTxCount === 1, - txId: txData.id, - onDeepLinkFetched: () => { - this.context.trackEvent({ - category: 'MMI', - event: 'Show deeplink for transaction', - }); - }, - onDeepLinkShown: () => { - this.props.clearConfirmTransaction(); - this.setState({ submitting: false }, () => { - history.push(mostRecentOverviewPage); - updateCustomNonce(''); - }); - }, - }); - } else { - this.setState( - { - submitting: false, - }, - () => { - history.push(mostRecentOverviewPage); - updateCustomNonce(''); - }, - ); - } - }) - .catch((error) => { - if (!this._isMounted) { - return; - } - - showTransactionsFailedModal(error.message, isNotification); - - this.setState({ - submitting: false, - submitError: error.message, - }); - setWaitForConfirmDeepLinkDialog(true); - updateCustomNonce(''); - }); - }, - ); - } - - updateTxData() { - const { - txData, - maxFeePerGas, - customTokenAmount, - dappProposedTokenAmount, - currentTokenBalance, - maxPriorityFeePerGas, - baseFeePerGas, - addToAddressBookIfNew, - toAccounts, - toAddress, - methodData, - } = this.props; - const { submitting } = this.state; - const { name } = methodData; + ///: END:ONLY_INCLUDE_IN if (txData.type === TransactionType.simpleSend) { addToAddressBookIfNew(toAddress, toAccounts); @@ -810,6 +678,44 @@ export default class ConfirmTransactionBase extends Component { maxPriorityFeePerGas, }; } + + this.setState( + { + submitting: true, + submitError: null, + }, + () => { + this._removeBeforeUnload(); + + sendTransaction(txData) + .then(() => { + if (!this._isMounted) { + return; + } + + this.setState( + { + submitting: false, + }, + () => { + history.push(mostRecentOverviewPage); + updateCustomNonce(''); + }, + ); + }) + .catch((error) => { + if (!this._isMounted) { + return; + } + + this.setState({ + submitting: false, + submitError: error.message, + }); + updateCustomNonce(''); + }); + }, + ); } handleSetApprovalForAll() { diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js index 9514ccea68c7..aba96a1d2f66 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -1,10 +1,7 @@ import { connect } from 'react-redux'; import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; -///: BEGIN:ONLY_INCLUDE_IN(build-mmi) -import { showCustodianDeepLink } from '@metamask-institutional/extension'; -import { mmiActionsFactory } from '../../store/institutional/institution-background'; -///: END:ONLY_INCLUDE_IN + import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'; import { @@ -51,12 +48,7 @@ import { getSendToAccounts, getProviderConfig, } from '../../ducks/metamask/metamask'; -import { - addHexPrefix, - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - getEnvironmentType, - ///: END:ONLY_INCLUDE_IN -} from '../../../app/scripts/lib/util'; +import { addHexPrefix } from '../../../app/scripts/lib/util'; import { parseStandardTokenTransactionData, @@ -71,11 +63,8 @@ import { import { getGasLoadingAnimationIsShowing } from '../../ducks/app/app'; import { isLegacyTransaction } from '../../helpers/utils/transactions.util'; import { CUSTOM_GAS_ESTIMATE } from '../../../shared/constants/gas'; - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) import { getAccountType } from '../../selectors/selectors'; -import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app'; -import { getIsNoteToTraderSupported } from '../../selectors/institutional/selectors'; ///: END:ONLY_INCLUDE_IN import { TransactionStatus, @@ -111,11 +100,6 @@ const mapStateToProps = (state, ownProps) => { const { id: paramsTransactionId } = params; const isMainnet = getIsMainnet(state); - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - const envType = getEnvironmentType(); - const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION; - ///: END:ONLY_INCLUDE_IN - const isGasEstimatesLoading = getIsGasEstimatesLoading(state); const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state); const isBuyableChain = getIsBuyableChain(state); @@ -215,20 +199,29 @@ const mapStateToProps = (state, ownProps) => { txParamsAreDappSuggested(fullTxData); const fromAddressIsLedger = isAddressLedger(state, fromAddress); const nativeCurrency = getNativeCurrency(state); - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - const accountType = getAccountType(state, fromAddress); - const fromChecksumHexAddress = toChecksumHexAddress(fromAddress); - const isNoteToTraderSupported = getIsNoteToTraderSupported( - state, - fromChecksumHexAddress, - ); - ///: END:ONLY_INCLUDE_IN const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(state, fromAddress); const isMultiLayerFeeNetwork = getIsMultiLayerFeeNetwork(state); + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + const accountType = getAccountType(state); + + const fromChecksumHexAddress = toChecksumHexAddress(fromAddress); + let isNoteToTraderSupported = false; + if ( + state.metamask.custodyAccountDetails && + state.metamask.custodyAccountDetails[fromChecksumHexAddress] + ) { + const { custodianName } = + state.metamask.custodyAccountDetails[fromChecksumHexAddress]; + isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find( + (custodian) => custodian.name === custodianName, + )?.isNoteToTraderSupported; + } + ///: END:ONLY_INCLUDE_IN + return { balance, fromAddress, @@ -282,15 +275,11 @@ const mapStateToProps = (state, ownProps) => { ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) accountType, isNoteToTraderSupported, - isNotification, ///: END:ONLY_INCLUDE_IN }; }; export const mapDispatchToProps = (dispatch) => { - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - const mmiActions = mmiActionsFactory(); - ///: END:ONLY_INCLUDE_IN return { tryReverseResolveAddress: (address) => { return dispatch(tryReverseResolveAddress(address)); @@ -327,45 +316,6 @@ export const mapDispatchToProps = (dispatch) => { dispatch(addToAddressBook(hexPrefixedAddress, nickname)); } }, - ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) - getCustodianConfirmDeepLink: (id) => - dispatch(mmiActions.getCustodianConfirmDeepLink(id)), - showCustodyConfirmLink: ({ link, address, closeNotification, custodyId }) => - dispatch( - mmiActions.showCustodyConfirmLink({ - link, - address, - closeNotification, - custodyId, - }), - ), - showTransactionsFailedModal: (errorMessage, closeNotification) => - dispatch( - showModal({ - name: 'TRANSACTION_FAILED', - errorMessage, - closeNotification, - }), - ), - showCustodianDeepLink: ({ - txId, - fromAddress, - closeNotification, - onDeepLinkFetched, - onDeepLinkShown, - }) => - showCustodianDeepLink({ - dispatch, - mmiActions, - txId, - fromAddress, - closeNotification, - onDeepLinkFetched, - onDeepLinkShown, - }), - setWaitForConfirmDeepLinkDialog: (wait) => - dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)), - ///: END:ONLY_INCLUDE_IN }; }; diff --git a/ui/selectors/institutional/selectors.js b/ui/selectors/institutional/selectors.js index d869b7f23201..f08295453c1b 100644 --- a/ui/selectors/institutional/selectors.js +++ b/ui/selectors/institutional/selectors.js @@ -78,16 +78,3 @@ export function getMMIConfiguration(state) { export function getInteractiveReplacementToken(state) { return state.metamask.interactiveReplacementToken || {}; } - -export function getIsNoteToTraderSupported(state, fromChecksumHexAddress) { - let isNoteToTraderSupported = false; - if (state.metamask.custodyAccountDetails?.[fromChecksumHexAddress]) { - const { custodianName } = - state.metamask.custodyAccountDetails[fromChecksumHexAddress]; - - isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find( - (custodian) => custodian.name === custodianName, - )?.isNoteToTraderSupported; - } - return isNoteToTraderSupported; -} From 8dc6bf1111161772939c7b439cb4ff127736f910 Mon Sep 17 00:00:00 2001 From: Danica Shen Date: Tue, 30 May 2023 13:44:56 +0100 Subject: [PATCH 18/19] feature(17901): fix address-book `Sends to an address book entry` e2e against MV3 build (#19330) * feature(17901): fix address-book `Sends to an address book entry` e2e against MV3 build * feature(17901): add balance guide for send-eth e2e as well --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- test/e2e/helpers.js | 20 +++++++++++++++++++ test/e2e/tests/address-book.spec.js | 10 ++++++++-- test/e2e/tests/contract-interactions.spec.js | 15 +++++++------- test/e2e/tests/metamask-responsive-ui.spec.js | 7 ++----- test/e2e/tests/navigate-transactions.spec.js | 13 ++++++------ test/e2e/tests/onboarding.spec.js | 7 ++----- test/e2e/tests/send-eth.spec.js | 11 ++++++++-- test/e2e/tests/send-hex-address.spec.js | 19 ++++++++---------- test/e2e/tests/simple-send.spec.js | 5 ++++- 9 files changed, 67 insertions(+), 40 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index aaa2d8b168e5..ed062a98ea62 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -511,6 +511,24 @@ const TEST_SEED_PHRASE = const TEST_SEED_PHRASE_TWO = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; +// Usually happens when onboarded to make sure the state is retrieved from metamaskState properly +const assertAccountBalanceForDOM = async (driver, ganacheServer) => { + const balance = await ganacheServer.getBalance(); + const balanceElement = await driver.findElement( + '[data-testid="eth-overview__primary-currency"]', + ); + assert.equal(`${balance}\nETH`, await balanceElement.getText()); +}; + +// Usually happens after txn is made +const locateAccountBalanceDOM = async (driver, ganacheServer) => { + const balance = await ganacheServer.getBalance(); + await driver.waitForSelector({ + css: '[data-testid="eth-overview__primary-currency"]', + text: `${balance} ETH`, + }); +}; + module.exports = { DAPP_URL, DAPP_ONE_URL, @@ -537,4 +555,6 @@ module.exports = { defaultGanacheOptions, sendTransaction, findAnotherAccountFromAccountList, + assertAccountBalanceForDOM, + locateAccountBalanceDOM, }; diff --git a/test/e2e/tests/address-book.spec.js b/test/e2e/tests/address-book.spec.js index af1214521712..b1c40f409384 100644 --- a/test/e2e/tests/address-book.spec.js +++ b/test/e2e/tests/address-book.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + assertAccountBalanceForDOM, +} = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); describe('Address Book', function () { @@ -12,6 +16,7 @@ describe('Address Book', function () { }, ], }; + it('Sends to an address book entry', async function () { await withFixtures( { @@ -33,11 +38,12 @@ describe('Address Book', function () { ganacheOptions, title: this.test.title, }, - async ({ driver }) => { + async ({ driver, ganacheServer }) => { await driver.navigate(); await driver.fill('#password', 'correct horse battery staple'); await driver.press('#password', driver.Key.ENTER); + await assertAccountBalanceForDOM(driver, ganacheServer); await driver.clickElement('[data-testid="eth-overview-send"]'); const recipientRowTitle = await driver.findElement( '.send__select-recipient-wrapper__group-item__title', diff --git a/test/e2e/tests/contract-interactions.spec.js b/test/e2e/tests/contract-interactions.spec.js index 780b21c5f3c4..02e95d7bdedc 100644 --- a/test/e2e/tests/contract-interactions.spec.js +++ b/test/e2e/tests/contract-interactions.spec.js @@ -1,5 +1,9 @@ -const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures, openDapp } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + openDapp, + locateAccountBalanceDOM, +} = require('../helpers'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); const FixtureBuilder = require('../fixture-builder'); @@ -89,12 +93,7 @@ describe('Deploy contract and call contract methods', function () { // renders the correct ETH balance await driver.switchToWindow(extension); - const balance = await ganacheServer.getBalance(); - const balanceElement = await driver.waitForSelector({ - css: '[data-testid="eth-overview__primary-currency"]', - text: balance, - }); - assert.equal(`${balance}\nETH`, await balanceElement.getText()); + await locateAccountBalanceDOM(driver, ganacheServer); }, ); }); diff --git a/test/e2e/tests/metamask-responsive-ui.spec.js b/test/e2e/tests/metamask-responsive-ui.spec.js index fe2ae4c1a41e..5d69b8c7c5cd 100644 --- a/test/e2e/tests/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/metamask-responsive-ui.spec.js @@ -3,6 +3,7 @@ const { TEST_SEED_PHRASE_TWO, convertToHexValue, withFixtures, + assertAccountBalanceForDOM, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -108,11 +109,7 @@ describe('MetaMask Responsive UI', function () { await driver.press('#confirm-password', driver.Key.ENTER); // balance renders - const balance = await ganacheServer.getBalance(); - await driver.waitForSelector({ - css: '[data-testid="eth-overview__primary-currency"]', - text: `${balance} ETH`, - }); + await assertAccountBalanceForDOM(driver, ganacheServer); }, ); }); diff --git a/test/e2e/tests/navigate-transactions.spec.js b/test/e2e/tests/navigate-transactions.spec.js index 438ef502829d..507071f4a24d 100644 --- a/test/e2e/tests/navigate-transactions.spec.js +++ b/test/e2e/tests/navigate-transactions.spec.js @@ -1,5 +1,10 @@ const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures, openDapp } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + openDapp, + locateAccountBalanceDOM, +} = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); describe('Navigate transactions', function () { @@ -227,11 +232,7 @@ describe('Navigate transactions', function () { // reject transactions await driver.clickElement({ text: 'Reject 4', tag: 'a' }); await driver.clickElement({ text: 'Reject all', tag: 'button' }); - const balance = await ganacheServer.getBalance(); - const balanceElement = await driver.findElement( - '[data-testid="eth-overview__primary-currency"]', - ); - assert.equal(`${balance}\nETH`, await balanceElement.getText()); + await locateAccountBalanceDOM(driver, ganacheServer); }, ); }); diff --git a/test/e2e/tests/onboarding.spec.js b/test/e2e/tests/onboarding.spec.js index a585d48962f4..e00b96a61541 100644 --- a/test/e2e/tests/onboarding.spec.js +++ b/test/e2e/tests/onboarding.spec.js @@ -9,6 +9,7 @@ const { importSRPOnboardingFlow, importWrongSRPOnboardingFlow, testSRPDropdownIterations, + assertAccountBalanceForDOM, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -304,11 +305,7 @@ describe('MetaMask onboarding', function () { ); assert.equal(await networkDisplay.getText(), networkName); - const balance = await secondaryGanacheServer.getBalance(); - const balanceElement = await driver.findElement( - '[data-testid="eth-overview__primary-currency"]', - ); - assert.equal(`${balance}\nETH`, await balanceElement.getText()); + await assertAccountBalanceForDOM(driver, secondaryGanacheServer); }, ); }); diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index dd2ae86500a4..7869e52cb705 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -1,6 +1,11 @@ const { strict: assert } = require('assert'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); -const { convertToHexValue, withFixtures, openDapp } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + openDapp, + assertAccountBalanceForDOM, +} = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); describe('Send ETH from inside MetaMask using default gas', function () { @@ -20,11 +25,13 @@ describe('Send ETH from inside MetaMask using default gas', function () { ganacheOptions, title: this.test.title, }, - async ({ driver }) => { + async ({ driver, ganacheServer }) => { await driver.navigate(); await driver.fill('#password', 'correct horse battery staple'); await driver.press('#password', driver.Key.ENTER); + await assertAccountBalanceForDOM(driver, ganacheServer); + await driver.clickElement('[data-testid="eth-overview-send"]'); await driver.fill( diff --git a/test/e2e/tests/send-hex-address.spec.js b/test/e2e/tests/send-hex-address.spec.js index c971f4f01bfe..b1d8edfad2e3 100644 --- a/test/e2e/tests/send-hex-address.spec.js +++ b/test/e2e/tests/send-hex-address.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + assertAccountBalanceForDOM, +} = require('../helpers'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); const FixtureBuilder = require('../fixture-builder'); @@ -133,11 +137,7 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { await driver.navigate(); await driver.fill('#password', 'correct horse battery staple'); await driver.press('#password', driver.Key.ENTER); - const balanceAfterDeployment = await ganacheServer.getBalance(); - await driver.waitForSelector({ - css: '[data-testid="eth-overview__primary-currency"]', - text: `${balanceAfterDeployment} ETH`, - }); + await assertAccountBalanceForDOM(driver, ganacheServer); // Send TST await driver.clickElement('[data-testid="home__asset-tab"]'); @@ -198,11 +198,8 @@ describe('Send ERC20 to a 40 character hexadecimal address', function () { await driver.navigate(); await driver.fill('#password', 'correct horse battery staple'); await driver.press('#password', driver.Key.ENTER); - const balanceAfterDeployment = await ganacheServer.getBalance(); - await driver.waitForSelector({ - css: '[data-testid="eth-overview__primary-currency"]', - text: `${balanceAfterDeployment} ETH`, - }); + + await assertAccountBalanceForDOM(driver, ganacheServer); // Send TST await driver.clickElement('[data-testid="home__asset-tab"]'); diff --git a/test/e2e/tests/simple-send.spec.js b/test/e2e/tests/simple-send.spec.js index b5b083ed800f..9e6293b74e1a 100644 --- a/test/e2e/tests/simple-send.spec.js +++ b/test/e2e/tests/simple-send.spec.js @@ -2,6 +2,7 @@ const { convertToHexValue, withFixtures, sendTransaction, + assertAccountBalanceForDOM, } = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); @@ -22,10 +23,12 @@ describe('Simple send', function () { ganacheOptions, title: this.test.title, }, - async ({ driver }) => { + async ({ driver, ganacheServer }) => { await driver.navigate(); await driver.fill('#password', 'correct horse battery staple'); await driver.press('#password', driver.Key.ENTER); + await assertAccountBalanceForDOM(driver, ganacheServer); + await sendTransaction( driver, '0x985c30949c92df7a0bd42e0f3e3d539ece98db24', From 49f8052b157374370ac71373708933c6e639944e Mon Sep 17 00:00:00 2001 From: Danica Shen Date: Tue, 30 May 2023 14:48:43 +0100 Subject: [PATCH 19/19] feature(17901): fix failing network error and remove duplicated e2e for mv3 (#19292) * feature(17901): fix failing network error e2e for mv3 * feature(17901): remove dapp interaction for duplication --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- test/e2e/mv3/dapp-interactions.spec.js | 72 -------------------------- test/e2e/tests/network-error.spec.js | 9 +++- 2 files changed, 8 insertions(+), 73 deletions(-) delete mode 100644 test/e2e/mv3/dapp-interactions.spec.js diff --git a/test/e2e/mv3/dapp-interactions.spec.js b/test/e2e/mv3/dapp-interactions.spec.js deleted file mode 100644 index 96dee4d8a67c..000000000000 --- a/test/e2e/mv3/dapp-interactions.spec.js +++ /dev/null @@ -1,72 +0,0 @@ -const { strict: assert } = require('assert'); -const { - convertToHexValue, - withFixtures, - openDapp, - SERVICE_WORKER_URL, -} = require('../helpers'); -const FixtureBuilder = require('../fixture-builder'); - -describe('MV3 - Dapp interactions', function () { - let windowHandles; - const ganacheOptions = { - accounts: [ - { - secretKey: - '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', - balance: convertToHexValue(25000000000000000000), - }, - ], - concurrent: { port: 8546, chainId: 1338 }, - }; - it('should continue to support dapp interactions after service worker re-start', async function () { - await withFixtures( - { - dapp: true, - fixtures: new FixtureBuilder() - .withPermissionControllerConnectedToTestDapp() - .build(), - ganacheOptions: { - ...ganacheOptions, - }, - title: this.test.title, - }, - async ({ driver }) => { - await driver.navigate(); - await driver.fill('#password', 'correct horse battery staple'); - await driver.press('#password', driver.Key.ENTER); - - await openDapp(driver); - - // Terminate Service Worker - await driver.openNewPage(SERVICE_WORKER_URL); - await driver.clickElement({ - text: 'Service workers', - tag: 'button', - }); - - await driver.clickElement({ - text: 'terminate', - tag: 'span', - }); - - // Trigger Notification - windowHandles = await driver.getAllWindowHandles(); - await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles); - await driver.clickElement('#addEthereumChain'); - await driver.waitUntilXWindowHandles(4); - await driver.switchToWindowWithTitle( - 'MetaMask Notification', - windowHandles, - ); - - const notification = await driver.isElementPresent({ - text: 'Allow this site to add a network?', - tag: 'h3', - }); - - assert.ok(notification, 'Dapp action does not appear in Metamask'); - }, - ); - }); -}); diff --git a/test/e2e/tests/network-error.spec.js b/test/e2e/tests/network-error.spec.js index 778d32b35cdb..31c47752b4f8 100644 --- a/test/e2e/tests/network-error.spec.js +++ b/test/e2e/tests/network-error.spec.js @@ -1,5 +1,9 @@ const { strict: assert } = require('assert'); -const { convertToHexValue, withFixtures } = require('../helpers'); +const { + convertToHexValue, + withFixtures, + regularDelayMs, +} = require('../helpers'); const FixtureBuilder = require('../fixture-builder'); describe('Gas API fallback', function () { @@ -79,6 +83,9 @@ describe('Gas API fallback', function () { await driver.clickElement({ text: 'Next', tag: 'button' }); + await driver.delay(regularDelayMs); + await driver.findElement('.transaction-alerts'); + const error = await driver.isElementPresent({ text: 'Network is busy. Gas prices are high and estimates are less accurate.', });