1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/store/actions.ts

4514 lines
121 KiB
TypeScript
Raw Normal View History

import { ReactFragment } from 'react';
import log from 'loglevel';
import { captureException } from '@sentry/browser';
import { capitalize, isEqual } from 'lodash';
import { ThunkAction } from 'redux-thunk';
import { Action, AnyAction } from 'redux';
import { ethErrors, serializeError } from 'eth-rpc-errors';
import { Hex, Json } from '@metamask/utils';
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
import { v4 as uuidV4 } from 'uuid';
///: END:ONLY_INCLUDE_IN
import {
AssetsContractController,
BalanceMap,
Nft,
Token,
} from '@metamask/assets-controllers';
import { PayloadAction } from '@reduxjs/toolkit';
import { GasFeeController } from '@metamask/gas-fee-controller';
import { PermissionsRequest } from '@metamask/permission-controller';
import { NonEmptyArray } from '@metamask/controller-utils';
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
import { HandlerType } from '@metamask/snaps-utils';
///: END:ONLY_INCLUDE_IN
import { getMethodDataAsync } from '../helpers/utils/transactions.util';
import switchDirection from '../../shared/lib/switch-direction';
import {
ENVIRONMENT_TYPE_NOTIFICATION,
ORIGIN_METAMASK,
POLLING_TOKEN_ENVIRONMENT_TYPES,
} from '../../shared/constants/app';
import { getEnvironmentType, addHexPrefix } from '../../app/scripts/lib/util';
import {
getMetaMaskAccounts,
getPermittedAccountsForCurrentTab,
getSelectedAddress,
hasTransactionPendingApprovals,
getApprovalFlows,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
getNotifications,
///: END:ONLY_INCLUDE_IN
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
getPermissionSubjects,
///: END:ONLY_INCLUDE_IN
} from '../selectors';
import {
computeEstimatedGasLimit,
initializeSendState,
resetSendState,
// NOTE: Until the send duck is typescript that this is importing a typedef
// that does not have an explicit export statement. lets see if it breaks the
// compiler
DraftTransaction,
} from '../ducks/send';
import { switchedToUnconnectedAccount } from '../ducks/alerts/unconnected-account';
import {
getProviderConfig,
getUnconnectedAccountAlertEnabledness,
} from '../ducks/metamask/metamask';
2021-05-17 23:19:39 +02:00
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
import {
HardwareDeviceNames,
LedgerTransportTypes,
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
LEDGER_USB_VENDOR_ID,
} from '../../shared/constants/hardware-wallets';
import {
MetaMetricsEventCategory,
MetaMetricsEventFragment,
MetaMetricsEventOptions,
MetaMetricsEventPayload,
MetaMetricsPageObject,
MetaMetricsPageOptions,
MetaMetricsPagePayload,
MetaMetricsReferrerObject,
} from '../../shared/constants/metametrics';
import { parseSmartTransactionsError } from '../pages/swaps/swaps.util';
import { isEqualCaseInsensitive } from '../../shared/modules/string-utils';
///: BEGIN:ONLY_INCLUDE_IN(snaps)
import { NOTIFICATIONS_EXPIRATION_DELAY } from '../helpers/constants/notifications';
///: END:ONLY_INCLUDE_IN
import {
fetchLocale,
loadRelativeTimeFormatLocaleData,
} from '../../shared/modules/i18n';
import { decimalToHex } from '../../shared/modules/conversion.utils';
import { TxGasFees, PriorityLevels } from '../../shared/constants/gas';
import {
TransactionMetaMetricsEvent,
TransactionType,
} from '../../shared/constants/transaction';
import { NetworkType, RPCDefinition } from '../../shared/constants/network';
import { EtherDenomination } from '../../shared/constants/common';
import {
isErrorWithMessage,
logErrorWithMessage,
} from '../../shared/modules/error';
import { TransactionMeta } from '../../app/scripts/controllers/incoming-transactions';
import { TxParams } from '../../app/scripts/controllers/transactions/tx-state-manager';
import { CustomGasSettings } from '../../app/scripts/controllers/transactions';
import { ThemeType } from '../../shared/constants/preferences';
import * as actionConstants from './actionConstants';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import { updateCustodyState } from './institutional/institution-actions';
///: END:ONLY_INCLUDE_IN
import {
generateActionId,
callBackgroundMethod,
submitRequestToBackground,
} from './action-queue';
import {
MetaMaskReduxDispatch,
MetaMaskReduxState,
TemporaryMessageDataType,
} from './store';
2020-11-03 00:41:28 +01:00
export function goHome() {
return {
type: actionConstants.GO_HOME,
};
}
// async actions
export function tryUnlockMetamask(
password: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
dispatch(unlockInProgress());
log.debug(`background.submitPassword`);
2018-03-03 22:08:10 +01:00
return new Promise<void>((resolve, reject) => {
callBackgroundMethod('submitPassword', [password], (error) => {
if (error) {
reject(error);
return;
}
2018-03-03 22:08:10 +01:00
resolve();
});
})
.then(() => {
dispatch(unlockSucceeded());
return forceUpdateMetamaskState(dispatch);
})
.then(() => {
dispatch(hideLoadingIndication());
})
2020-02-15 21:34:12 +01:00
.catch((err) => {
dispatch(unlockFailed(err.message));
dispatch(hideLoadingIndication());
return Promise.reject(err);
});
};
}
/**
* Adds a new account where all data is encrypted using the given password and
* where all addresses are generated from a given seed phrase.
*
* @param password - The password.
* @param seedPhrase - The seed phrase.
* @returns The updated state of the keyring controller.
*/
export function createNewVaultAndRestore(
password: string,
seedPhrase: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.createNewVaultAndRestore`);
// Encode the secret recovery phrase as an array of integers so that it is
// serialized as JSON properly.
const encodedSeedPhrase = Array.from(
Buffer.from(seedPhrase, 'utf8').values(),
);
// TODO: Add types for vault
let vault: any;
return new Promise<void>((resolve, reject) => {
callBackgroundMethod(
'createNewVaultAndRestore',
[password, encodedSeedPhrase],
(err, _vault) => {
if (err) {
reject(err);
return;
}
vault = _vault;
resolve();
},
);
})
.then(() => dispatch(unMarkPasswordForgotten()))
.then(() => {
dispatch(showAccountsPage());
dispatch(hideLoadingIndication());
return vault;
})
2020-02-15 21:34:12 +01:00
.catch((err) => {
dispatch(displayWarning(err.message));
dispatch(hideLoadingIndication());
return Promise.reject(err);
});
};
}
export function createNewVaultAndGetSeedPhrase(
password: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
try {
await createNewVault(password);
const seedPhrase = await verifySeedPhrase();
return seedPhrase;
} catch (error) {
dispatch(displayWarning(error));
if (isErrorWithMessage(error)) {
throw new Error(error.message);
} else {
throw error;
}
} finally {
dispatch(hideLoadingIndication());
}
};
}
export function unlockAndGetSeedPhrase(
password: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
try {
await submitPassword(password);
const seedPhrase = await verifySeedPhrase();
await forceUpdateMetamaskState(dispatch);
return seedPhrase;
} catch (error) {
dispatch(displayWarning(error));
if (isErrorWithMessage(error)) {
throw new Error(error.message);
} else {
throw error;
}
} finally {
dispatch(hideLoadingIndication());
}
};
}
export function submitPassword(password: string): Promise<void> {
return new Promise((resolve, reject) => {
callBackgroundMethod('submitPassword', [password], (error) => {
if (error) {
reject(error);
return;
}
resolve();
});
});
}
export function createNewVault(password: string): Promise<boolean> {
return new Promise((resolve, reject) => {
callBackgroundMethod('createNewVaultAndKeychain', [password], (error) => {
if (error) {
reject(error);
return;
}
resolve(true);
});
});
}
export function verifyPassword(password: string): Promise<boolean> {
return new Promise((resolve, reject) => {
callBackgroundMethod('verifyPassword', [password], (error) => {
if (error) {
reject(error);
return;
}
resolve(true);
});
});
}
export async function verifySeedPhrase() {
const encodedSeedPhrase = await submitRequestToBackground<string>(
'verifySeedPhrase',
);
return Buffer.from(encodedSeedPhrase).toString('utf8');
}
export function requestRevealSeedWords(
password: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.verifyPassword`);
try {
await verifyPassword(password);
const seedPhrase = await verifySeedPhrase();
return seedPhrase;
} finally {
dispatch(hideLoadingIndication());
}
};
2016-11-02 06:19:04 +01:00
}
export function tryReverseResolveAddress(
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return () => {
return new Promise<void>((resolve) => {
callBackgroundMethod('tryReverseResolveAddress', [address], (err) => {
if (err) {
logErrorWithMessage(err);
}
resolve();
});
});
};
}
export function resetAccount(): ThunkAction<
Promise<string>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
2018-01-31 09:33:15 +01:00
return new Promise<string>((resolve, reject) => {
callBackgroundMethod<string>('resetAccount', [], (err, account) => {
dispatch(hideLoadingIndication());
2018-05-31 01:17:40 +02:00
if (err) {
if (isErrorWithMessage(err)) {
dispatch(displayWarning(err.message));
}
reject(err);
return;
2018-05-31 01:17:40 +02:00
}
log.info(`Transaction history reset for ${account}`);
dispatch(showAccountsPage());
resolve(account as string);
});
});
};
2018-01-31 09:33:15 +01:00
}
export function removeAccount(
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
2018-07-11 06:20:40 +02:00
try {
await new Promise((resolve, reject) => {
callBackgroundMethod('removeAccount', [address], (error, account) => {
if (error) {
reject(error);
return;
}
resolve(account);
});
});
await forceUpdateMetamaskState(dispatch);
} catch (error) {
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
log.info(`Account removed: ${address}`);
dispatch(showAccountsPage());
};
2018-07-11 06:20:40 +02:00
}
export function importNewAccount(
strategy: string,
args: any[],
loadingMessage: ReactFragment,
): ThunkAction<
Promise<MetaMaskReduxState['metamask']>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
let newState;
dispatch(showLoadingIndication(loadingMessage));
try {
log.debug(`background.importAccountWithStrategy`);
await submitRequestToBackground('importAccountWithStrategy', [
strategy,
args,
]);
log.debug(`background.getState`);
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('getState');
} finally {
dispatch(hideLoadingIndication());
}
dispatch(updateMetamaskState(newState));
return newState;
};
}
export function addNewAccount(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug(`background.addNewAccount`);
return async (dispatch, getState) => {
const oldIdentities = getState().metamask.identities;
dispatch(showLoadingIndication());
let newIdentities;
try {
const { identities } = await submitRequestToBackground('addNewAccount', [
Object.keys(oldIdentities).length,
]);
newIdentities = identities;
} catch (error) {
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
2020-11-03 00:41:28 +01:00
const newAccountAddress = Object.keys(newIdentities).find(
(address) => !oldIdentities[address],
);
await forceUpdateMetamaskState(dispatch);
return newAccountAddress;
};
}
export function checkHardwareStatus(
deviceName: HardwareDeviceNames,
hdPath: string,
): ThunkAction<Promise<boolean>, MetaMaskReduxState, unknown, AnyAction> {
log.debug(`background.checkHardwareStatus`, deviceName, hdPath);
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
let unlocked = false;
try {
unlocked = await submitRequestToBackground<boolean>(
'checkHardwareStatus',
[deviceName, hdPath],
);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
await forceUpdateMetamaskState(dispatch);
return unlocked;
};
}
export function forgetDevice(
deviceName: HardwareDeviceNames,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
log.debug(`background.forgetDevice`, deviceName);
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
try {
await submitRequestToBackground('forgetDevice', [deviceName]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
await forceUpdateMetamaskState(dispatch);
};
}
// TODO: Define an Account Type for the return type of this method and anywhere
// else dealing with accounts.
export function connectHardware(
deviceName: HardwareDeviceNames,
page: string,
hdPath: string,
t: (key: string) => string,
): ThunkAction<
Promise<{ address: string }[]>,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug(`background.connectHardware`, deviceName, page, hdPath);
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
return async (dispatch, getState) => {
const { ledgerTransportType } = getState().metamask;
2020-11-03 00:41:28 +01:00
dispatch(
showLoadingIndication(`Looking for your ${capitalize(deviceName)}...`),
);
2018-06-10 09:52:32 +02:00
let accounts: { address: string }[];
try {
if (deviceName === HardwareDeviceNames.ledger) {
await submitRequestToBackground('establishLedgerTransportPreference');
}
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
if (
deviceName === HardwareDeviceNames.ledger &&
ledgerTransportType === LedgerTransportTypes.webhid
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
) {
const connectedDevices = await window.navigator.hid.requestDevice({
// The types for web hid were provided by @types/w3c-web-hid and may
// not be fully formed or correct, because LEDGER_USB_VENDOR_ID is a
// string and this integration with Navigator.hid works before
// TypeScript. As a note, on the next declaration we convert the
// LEDGER_USB_VENDOR_ID to a number for a different API so....
// TODO: Get David Walsh's opinion here
filters: [{ vendorId: LEDGER_USB_VENDOR_ID as unknown as number }],
Connect Ledger via WebHID (#12411) * Connect ledger via webhid if that option is available * Explicitly setting preference for webhid * Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences * Use single setLEdgerTransport preference methods and property * Temp * Lint fix * Unit test fix * Remove async keyword from setLedgerTransportPreference function definition in preferences controller * Fix ledgelive setting toggle logic * Migrate useLedgerLive preference property to ledgerTransportType * Use shared constants for ledger transport type enums * Use constant for ledger usb vendor id * Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection * Update eth-ledger-bridge-keyring to v0.9.0 * Only show ledger live transaction helper messages if using ledger live * Only show ledger live part of tutorial if ledger live setting is on * Fix ledger related prop type errors * Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid * Cleanup * Wrap ledger webhid device request in try/catch * Clean up * Lint fix * Ensure user can easily connect their ledger wallet when they need to. * Fix locales * Fix/improve locales changes * Remove unused isFirefox property from confirm-transaction-base.container.js * Disable transaction and message signing confirmation if ledger webhid requires connection * Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales * Drop .component from ledger-instruction-field file name * Move renderLedgerLiveStep to module scope * Remove ledgerLive from function and message names in ledger-instruction-field * Wrap ledger connection logic in ledger-instruction-field in try catch * Clean up signature-request.component.js * Check whether the signing address, and not the selected address, is a ledger account in singature-request.container * Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures * Improve webhid selection handling in select-ledger-transport-type onChange handler * Move metamask redux focused ledger selectors to metamask duck * Lint fix * Use async await in checkWebHidStatusRef.current * Remove unnecessary use of ref in ledger-instruction-field.js * Lint fix * Remove unnecessary try/catch in ledger-instruction-field.js * Check if from address, not selected address, is from a ledger account in confirm-approve * Move findKeyringForAddress to metamask duck * Fix typo in function name * Ensure isEqualCaseInsensitive handles possible differences in address casing * Fix Learn More link size in advanced settings tab * Update app/scripts/migrations/066.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add jsdoc comments for new selectors * Use jest.spyOn for mocking navigator in ledger webhid migration tests * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType * Fix font size of link in ledger connection description in advanced settings * Fix return type in setLedgerTransportPreference comment * Clean up connectHardware code for webhid connection in actions.js * Update app/scripts/migrations/066.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/ducks/metamask/metamask.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Add migration test for when useLedgerLive is true in a browser that supports webhid * Lint fix * Fix inline-link size Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 21:17:03 +02:00
});
const userApprovedWebHidConnection = connectedDevices.some(
(device) => device.vendorId === Number(LEDGER_USB_VENDOR_ID),
);
if (!userApprovedWebHidConnection) {
throw new Error(t('ledgerWebHIDNotConnectedErrorMessage'));
}
}
accounts = await submitRequestToBackground<{ address: string }[]>(
'connectHardware',
[deviceName, page, hdPath],
);
} catch (error) {
logErrorWithMessage(error);
if (
deviceName === HardwareDeviceNames.ledger &&
ledgerTransportType === LedgerTransportTypes.webhid &&
isErrorWithMessage(error) &&
error.message.match('Failed to open the device')
) {
dispatch(displayWarning(t('ledgerDeviceOpenFailureMessage')));
throw new Error(t('ledgerDeviceOpenFailureMessage'));
} else {
if (deviceName !== HardwareDeviceNames.qr) {
dispatch(displayWarning(error));
}
throw error;
}
} finally {
dispatch(hideLoadingIndication());
}
2018-06-10 09:52:32 +02:00
await forceUpdateMetamaskState(dispatch);
return accounts;
};
2018-06-10 09:52:32 +02:00
}
export function unlockHardwareWalletAccounts(
indexes: string[],
deviceName: HardwareDeviceNames,
hdPath: string,
hdPathDescription: string,
): ThunkAction<Promise<undefined>, MetaMaskReduxState, unknown, AnyAction> {
log.debug(
`background.unlockHardwareWalletAccount`,
indexes,
deviceName,
hdPath,
hdPathDescription,
);
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
2018-06-10 09:52:32 +02:00
for (const index of indexes) {
try {
await submitRequestToBackground('unlockHardwareWalletAccount', [
index,
deviceName,
hdPath,
hdPathDescription,
]);
} catch (err) {
logErrorWithMessage(err);
dispatch(displayWarning(err));
dispatch(hideLoadingIndication());
throw err;
}
}
dispatch(hideLoadingIndication());
return undefined;
};
2018-06-10 09:52:32 +02:00
}
export function showQrScanner(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
2020-11-03 00:41:28 +01:00
dispatch(
showModal({
name: 'QR_SCANNER',
}),
);
};
}
export function setCurrentCurrency(
currencyCode: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setCurrentCurrency`);
try {
await submitRequestToBackground('setCurrentCurrency', [currencyCode]);
await forceUpdateMetamaskState(dispatch);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
return;
} finally {
dispatch(hideLoadingIndication());
}
};
}
export function decryptMsgInline(
decryptedMsgData: TemporaryMessageDataType['msgParams'],
): ThunkAction<
Promise<TemporaryMessageDataType>,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug('action - decryptMsgInline');
return async (dispatch: MetaMaskReduxDispatch) => {
log.debug(`actions calling background.decryptMessageInline`);
let newState;
try {
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('decryptMessageInline', [decryptedMsgData]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
throw error;
}
dispatch(updateMetamaskState(newState));
return newState.unapprovedDecryptMsgs[decryptedMsgData.metamaskId];
};
}
export function decryptMsg(
decryptedMsgData: TemporaryMessageDataType['msgParams'],
): ThunkAction<
Promise<TemporaryMessageDataType['msgParams']>,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug('action - decryptMsg');
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`actions calling background.decryptMessage`);
let newState: MetaMaskReduxState['metamask'];
try {
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('decryptMessage', [decryptedMsgData]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
dispatch(updateMetamaskState(newState));
dispatch(completedTx(decryptedMsgData.metamaskId));
dispatch(closeCurrentNotificationWindow());
return decryptedMsgData;
};
}
export function encryptionPublicKeyMsg(
msgData: TemporaryMessageDataType['msgParams'],
): ThunkAction<
Promise<TemporaryMessageDataType['msgParams']>,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug('action - encryptionPublicKeyMsg');
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`actions calling background.encryptionPublicKey`);
let newState: MetaMaskReduxState['metamask'];
try {
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('encryptionPublicKey', [msgData]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
dispatch(updateMetamaskState(newState));
dispatch(completedTx(msgData.metamaskId));
dispatch(closeCurrentNotificationWindow());
return msgData;
};
}
export function updateCustomNonce(value: string) {
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
return {
type: actionConstants.UPDATE_CUSTOM_NONCE,
value,
};
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
}
const updateMetamaskStateFromBackground = (): Promise<
MetaMaskReduxState['metamask']
> => {
log.debug(`background.getState`);
return new Promise((resolve, reject) => {
callBackgroundMethod<MetaMaskReduxState['metamask']>(
'getState',
[],
(error, newState) => {
if (error) {
reject(error);
return;
}
resolve(newState as MetaMaskReduxState['metamask']);
},
);
});
};
/**
* TODO: update previousGasParams to use typed gas params object
* TODO: codeword: NOT_A_THUNK @brad-decker
*
* @param txId - MetaMask internal transaction id
* @param previousGasParams - Object of gas params to set as previous
*/
export function updatePreviousGasParams(
txId: number,
previousGasParams: Record<string, any>,
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async () => {
let updatedTransaction: TransactionMeta;
update gas fees (#13646) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 76 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> enforce that only the properties for the specific methid can be updated via the method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more parameters to updateSwapTransaction approvalTxId estimatedBaseFee Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas fees in edit-gas-popover. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove dup;icated method from rebase. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> unrelated change Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Force re-run workflow Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> UpdateTransaction should be renamed to updateGasFees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateGasFees in gas-modal-page-container. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> fix: update previous gas params update method add types to the jsdoc comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateTransactionGasFees should have been updatePreviousGasParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Previous gas fees can be updated for confirmed transactions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add updatePreviousGasParams to mocked functions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * we need to await the first dispatch before we call the second Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * update values to make tests pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * More changes to make e2e pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Need to wait a bit after save for changes to take effect. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove merge comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Await one dispatch before calling another Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * We don't need goHome anymore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Tests must use async...await syntax too since we have await in the useTranasctionFunction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add delay after button click for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait a moment after clicking save for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait after clicking save... Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Merge update transaction gas fees and transaction user settings Show loading indicator on edit gas popover Fix tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix JSDoc Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * updatePreviousGasParams should also return updated transaction meta. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-25 18:11:04 +01:00
try {
updatedTransaction = await submitRequestToBackground(
'updatePreviousGasParams',
[txId, previousGasParams],
update gas fees (#13646) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 76 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> enforce that only the properties for the specific methid can be updated via the method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more parameters to updateSwapTransaction approvalTxId estimatedBaseFee Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas fees in edit-gas-popover. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove dup;icated method from rebase. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> unrelated change Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Force re-run workflow Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> UpdateTransaction should be renamed to updateGasFees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateGasFees in gas-modal-page-container. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> fix: update previous gas params update method add types to the jsdoc comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateTransactionGasFees should have been updatePreviousGasParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Previous gas fees can be updated for confirmed transactions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add updatePreviousGasParams to mocked functions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * we need to await the first dispatch before we call the second Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * update values to make tests pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * More changes to make e2e pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Need to wait a bit after save for changes to take effect. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove merge comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Await one dispatch before calling another Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * We don't need goHome anymore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Tests must use async...await syntax too since we have await in the useTranasctionFunction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add delay after button click for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait a moment after clicking save for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait after clicking save... Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Merge update transaction gas fees and transaction user settings Show loading indicator on edit gas popover Fix tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix JSDoc Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * updatePreviousGasParams should also return updated transaction meta. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-25 18:11:04 +01:00
);
} catch (error) {
logErrorWithMessage(error);
update gas fees (#13646) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 76 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> enforce that only the properties for the specific methid can be updated via the method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more parameters to updateSwapTransaction approvalTxId estimatedBaseFee Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas fees in edit-gas-popover. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update Transaction Gas Fees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update gas settings and user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix unit tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove dup;icated method from rebase. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> unrelated change Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Force re-run workflow Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> UpdateTransaction should be renamed to updateGasFees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateGasFees in gas-modal-page-container. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> fix: update previous gas params update method add types to the jsdoc comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> updateTransactionGasFees should have been updatePreviousGasParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Previous gas fees can be updated for confirmed transactions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> add updatePreviousGasParams to mocked functions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * we need to await the first dispatch before we call the second Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * update values to make tests pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * More changes to make e2e pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Need to wait a bit after save for changes to take effect. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove merge comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Await one dispatch before calling another Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * We don't need goHome anymore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Tests must use async...await syntax too since we have await in the useTranasctionFunction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add delay after button click for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait a moment after clicking save for values to update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Wait after clicking save... Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Merge update transaction gas fees and transaction user settings Show loading indicator on edit gas popover Fix tests. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix JSDoc Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * updatePreviousGasParams should also return updated transaction meta. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-25 18:11:04 +01:00
throw error;
}
return updatedTransaction;
};
}
export function updateEditableParams(
txId: number,
editableParams: Partial<TxParams>,
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
let updatedTransaction: TransactionMeta;
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
try {
updatedTransaction = await submitRequestToBackground(
'updateEditableParams',
[txId, editableParams],
);
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
} catch (error) {
logErrorWithMessage(error);
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
throw error;
}
await forceUpdateMetamaskState(dispatch);
return updatedTransaction;
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
};
}
/**
* Appends new send flow history to a transaction
* TODO: codeword: NOT_A_THUNK @brad-decker
*
* @param txId - the id of the transaction to update
* @param currentSendFlowHistoryLength - sendFlowHistory entries currently
* @param sendFlowHistory - the new send flow history to append to the
* transaction
* @returns
*/
export function updateTransactionSendFlowHistory(
txId: number,
currentSendFlowHistoryLength: number,
sendFlowHistory: DraftTransaction['history'],
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async () => {
let updatedTransaction: TransactionMeta;
try {
updatedTransaction = await submitRequestToBackground(
'updateTransactionSendFlowHistory',
[txId, currentSendFlowHistoryLength, sendFlowHistory],
);
} catch (error) {
logErrorWithMessage(error);
throw error;
}
return updatedTransaction;
};
}
export async function backupUserData(): Promise<{
filename: string;
data: string;
}> {
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
let backedupData;
try {
backedupData = await submitRequestToBackground<{
filename: string;
data: string;
}>('backupUserData');
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
} catch (error) {
logErrorWithMessage(error);
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
throw error;
}
return backedupData;
}
export async function restoreUserData(jsonString: Json): Promise<true> {
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
try {
await submitRequestToBackground('restoreUserData', [jsonString]);
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
} catch (error) {
logErrorWithMessage(error);
3box Replacement (#15243) * Backup user data Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Tests for prependZero (utils.js) Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix advancedtab test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> backup controller tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Backup controller don't have a store. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore from file. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Advanced Tab tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> e2e tests for backup unit tests for restore. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix comments on PR. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> restore style Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> We should move the exportAsFile to a utility file in the shared/ directory Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move export as file to shared folder Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Refactor create download folder methods Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the backup/restore buttons closer to 3box Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Change descriptions Add to search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> refactor code to use if instead of && Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Restore button should change cursor to pointer. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix restore not uploading same file twice. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not backup these items in preferences identities lostIdentities selectedAddress Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Only update what is needed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fixed test for search Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * remove txError as it currently does nothing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove dispatch, not needed since we're not dispatching any actions. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Event should be title case. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make backup/restore normal async functions rename event as per product suggestion. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Use success Actionable message for success message and danger for error message Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change event name to match with backup Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * fix e2e Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-08-09 20:36:32 +02:00
throw error;
}
return true;
}
// TODO: codeword: NOT_A_THUNK @brad-decker
export function updateTransactionGasFees(
txId: number,
txGasFees: Partial<TxGasFees>,
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async () => {
let updatedTransaction: TransactionMeta;
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
try {
updatedTransaction = await submitRequestToBackground(
'updateTransactionGasFees',
[txId, txGasFees],
);
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
} catch (error) {
logErrorWithMessage(error);
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
throw error;
}
return updatedTransaction;
Update EIP1559 params. (#13652) * Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add more params to updateTransactionGasFees. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update eip1559 method to editableParams. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Mocha tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * add gasPrice to updateEditableParams Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove duplicated Params in notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * A few more tests to cover if transaction status is not unapproved transaction is passed more parameters than it requires. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Update EIP1559 params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * change method name to update editable params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Editable params should pass in the txParams and not the full tx object Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix jest tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Do not hideLoading since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Proper JSDOCs comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove gas settings from updateEditableParams since we already have a dedicated gas update method. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix duplicate codes from rebasing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-03-07 20:14:48 +01:00
};
}
export function updateTransaction(
txMeta: TransactionMeta,
dontShowLoadingIndicator: boolean,
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
!dontShowLoadingIndicator && dispatch(showLoadingIndication());
try {
await submitRequestToBackground('updateTransaction', [txMeta]);
} catch (error) {
dispatch(updateTransactionParams(txMeta.id, txMeta.txParams));
dispatch(hideLoadingIndication());
dispatch(goHome());
logErrorWithMessage(error);
throw error;
}
try {
dispatch(updateTransactionParams(txMeta.id, txMeta.txParams));
const newState = await updateMetamaskStateFromBackground();
dispatch(updateMetamaskState(newState));
dispatch(showConfTxPage({ id: txMeta.id }));
return txMeta;
} finally {
dispatch(hideLoadingIndication());
}
};
}
/**
* Action to create a new transaction in the controller and route to the
* confirmation page. Returns the newly created txMeta in case additional logic
* should be applied to the transaction after creation.
*
* @param txParams - The transaction parameters
* @param options
* @param options.sendFlowHistory - The history of the send flow at time of creation.
* @param options.type - The type of the transaction being added.
* @returns
*/
export function addTransactionAndRouteToConfirmationPage(
txParams: TxParams,
options?: {
sendFlowHistory?: DraftTransaction['history'];
type?: TransactionType;
},
): ThunkAction<
Promise<TransactionMeta | null>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
const actionId = generateActionId();
try {
log.debug('background.addTransaction');
const transactionMeta = await submitRequestToBackground<TransactionMeta>(
'addTransaction',
[txParams, { ...options, actionId, origin: ORIGIN_METAMASK }],
actionId,
);
dispatch(showConfTxPage());
return transactionMeta;
} catch (error) {
dispatch(hideLoadingIndication());
dispatch(displayWarning(error));
}
return null;
};
2020-10-06 20:28:38 +02:00
}
/**
* Wrapper around the promisifedBackground to create a new unapproved
* transaction in the background and return the newly created txMeta.
* This method does not show errors or route to a confirmation page and is
* used primarily for swaps functionality.
*
* @param txParams - the transaction parameters
* @param options - Additional options for the transaction.
* @param options.method
* @param options.requireApproval - Whether the transaction requires approval.
* @param options.swaps - Options specific to swaps transactions.
* @param options.swaps.hasApproveTx - Whether the swap required an approval transaction.
* @param options.swaps.meta - Additional transaction metadata required by swaps.
* @param options.type
* @returns
*/
export async function addTransactionAndWaitForPublish(
txParams: TxParams,
options: {
method?: string;
requireApproval?: boolean;
swaps?: { hasApproveTx?: boolean; meta?: Record<string, unknown> };
type?: TransactionType;
},
): Promise<TransactionMeta> {
log.debug('background.addTransactionAndWaitForPublish');
const actionId = generateActionId();
return await submitRequestToBackground<TransactionMeta>(
'addTransactionAndWaitForPublish',
[
txParams,
{
...options,
origin: ORIGIN_METAMASK,
actionId,
},
],
actionId,
);
}
export function updateAndApproveTx(
txMeta: TransactionMeta,
dontShowLoadingIndicator: boolean,
): ThunkAction<
Promise<TransactionMeta | null>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
!dontShowLoadingIndicator && dispatch(showLoadingIndication());
return new Promise((resolve, reject) => {
const actionId = generateActionId();
callBackgroundMethod(
'resolvePendingApproval',
[String(txMeta.id), { txMeta, actionId }, { waitForResult: true }],
(err) => {
dispatch(updateTransactionParams(txMeta.id, txMeta.txParams));
dispatch(resetSendState());
if (err) {
dispatch(goHome());
logErrorWithMessage(err);
reject(err);
return;
}
resolve(txMeta);
},
);
})
.then(() => updateMetamaskStateFromBackground())
2020-02-15 21:34:12 +01:00
.then((newState) => dispatch(updateMetamaskState(newState)))
.then(() => {
dispatch(resetSendState());
dispatch(completedTx(txMeta.id));
dispatch(hideLoadingIndication());
dispatch(updateCustomNonce(''));
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
dispatch(closeCurrentNotificationWindow());
///: END:ONLY_INCLUDE_IN
return txMeta;
})
.catch((err) => {
dispatch(hideLoadingIndication());
return Promise.reject(err);
});
};
}
export async function getTransactions(
filters: {
filterToCurrentNetwork?: boolean;
searchCriteria?: Partial<TransactionMeta> & Partial<TxParams>;
} = {},
): Promise<TransactionMeta[]> {
return await submitRequestToBackground<TransactionMeta[]>('getTransactions', [
filters,
]);
}
export function completedTx(
txId: number,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch({
type: actionConstants.COMPLETED_TX,
value: {
id: txId,
},
});
};
}
export function updateTransactionParams(txId: number, txParams: TxParams) {
2017-11-08 17:44:48 +01:00
return {
type: actionConstants.UPDATE_TRANSACTION_PARAMS,
id: txId,
2017-11-08 17:44:48 +01:00
value: txParams,
};
2017-11-08 17:44:48 +01:00
}
///: BEGIN:ONLY_INCLUDE_IN(snaps)
export function disableSnap(
snapId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('disableSnap', [snapId]);
await forceUpdateMetamaskState(dispatch);
};
}
export function enableSnap(
snapId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('enableSnap', [snapId]);
await forceUpdateMetamaskState(dispatch);
};
}
///: END:ONLY_INCLUDE_IN
// TODO: Clean this up.
///: BEGIN:ONLY_INCLUDE_IN(snaps)
export function removeSnap(
snapId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (
dispatch: MetaMaskReduxDispatch,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
getState,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(snaps)
) => {
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
dispatch(showLoadingIndication());
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
const subjects = getPermissionSubjects(getState()) as {
[k: string]: { permissions: Record<string, any> };
};
const isAccountsSnap =
subjects[snapId]?.permissions?.snap_manageAccounts !== undefined;
///: END:ONLY_INCLUDE_IN
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
///: BEGIN:ONLY_INCLUDE_IN(snaps)
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
try {
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
if (isAccountsSnap) {
const accounts = (await handleSnapRequest({
snapId,
origin: 'metamask',
handler: HandlerType.OnRpcRequest,
request: {
id: uuidV4(),
jsonrpc: '2.0',
method: 'keyring_listAccounts',
},
})) as unknown as any[];
for (const account of accounts) {
dispatch(removeAccount(account.address.toLowerCase()));
}
}
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(snaps)
await submitRequestToBackground('removeSnap', [snapId]);
await forceUpdateMetamaskState(dispatch);
} catch (error) {
dispatch(displayWarning(error));
throw error;
} finally {
dispatch(hideLoadingIndication());
}
};
}
export async function removeSnapError(msgData: string): Promise<void> {
return submitRequestToBackground('removeSnapError', [msgData]);
}
export async function handleSnapRequest(args: {
snapId: string;
origin: string;
handler: string;
request: {
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
id?: string;
jsonrpc: '2.0';
method: string;
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
params?: Record<string, any>;
};
}): Promise<void> {
return submitRequestToBackground('handleSnapRequest', [args]);
}
export function dismissNotifications(
ids: string[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('dismissNotifications', [ids]);
await forceUpdateMetamaskState(dispatch);
};
}
export function deleteExpiredNotifications(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch, getState) => {
const state = getState();
const notifications = getNotifications(state);
const notificationIdsToDelete = notifications
.filter((notification) => {
const expirationTime = new Date(
Date.now() - NOTIFICATIONS_EXPIRATION_DELAY,
);
return Boolean(
notification.readDate &&
new Date(notification.readDate) < expirationTime,
);
})
.map(({ id }) => id);
if (notificationIdsToDelete.length) {
await submitRequestToBackground('dismissNotifications', [
notificationIdsToDelete,
]);
await forceUpdateMetamaskState(dispatch);
}
};
}
export function markNotificationsAsRead(
ids: string[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('markNotificationsAsRead', [ids]);
await forceUpdateMetamaskState(dispatch);
};
}
export function revokeDynamicSnapPermissions(
snapId: string,
permissionNames: string[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('revokeDynamicSnapPermissions', [
snapId,
permissionNames,
]);
await forceUpdateMetamaskState(dispatch);
};
}
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(desktop)
export function setDesktopEnabled(desktopEnabled: boolean) {
return async () => {
try {
await submitRequestToBackground('setDesktopEnabled', [desktopEnabled]);
} catch (error) {
log.error(error);
}
};
}
export async function generateDesktopOtp() {
return await submitRequestToBackground('generateDesktopOtp');
}
export async function testDesktopConnection() {
return await submitRequestToBackground('testDesktopConnection');
}
export async function disableDesktop() {
return await submitRequestToBackground('disableDesktop');
}
///: END:ONLY_INCLUDE_IN
export function cancelDecryptMsg(
msgData: TemporaryMessageDataType,
): ThunkAction<
Promise<TemporaryMessageDataType>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
let newState;
try {
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('cancelDecryptMessage', [msgData.id]);
} finally {
dispatch(hideLoadingIndication());
}
dispatch(updateMetamaskState(newState));
dispatch(completedTx(msgData.id));
dispatch(closeCurrentNotificationWindow());
return msgData;
};
}
export function cancelEncryptionPublicKeyMsg(
msgData: TemporaryMessageDataType,
): ThunkAction<
Promise<TemporaryMessageDataType>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
let newState;
try {
newState = await submitRequestToBackground<
MetaMaskReduxState['metamask']
>('cancelEncryptionPublicKey', [msgData.id]);
} finally {
dispatch(hideLoadingIndication());
}
dispatch(updateMetamaskState(newState));
dispatch(completedTx(msgData.id));
dispatch(closeCurrentNotificationWindow());
return msgData;
};
}
export function cancelTx(
txMeta: TransactionMeta,
_showLoadingIndication = true,
): ThunkAction<
Promise<TransactionMeta>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
_showLoadingIndication && dispatch(showLoadingIndication());
return new Promise<void>((resolve, reject) => {
callBackgroundMethod(
'rejectPendingApproval',
[
String(txMeta.id),
ethErrors.provider.userRejectedRequest().serialize(),
],
(error) => {
if (error) {
reject(error);
return;
}
resolve();
},
);
})
.then(() => updateMetamaskStateFromBackground())
2020-02-15 21:34:12 +01:00
.then((newState) => dispatch(updateMetamaskState(newState)))
.then(() => {
dispatch(resetSendState());
dispatch(completedTx(txMeta.id));
dispatch(hideLoadingIndication());
dispatch(closeCurrentNotificationWindow());
return txMeta;
})
.catch((error) => {
dispatch(hideLoadingIndication());
throw error;
});
};
}
/**
* Cancels all of the given transactions
*
* @param txMetaList
* @returns
*/
export function cancelTxs(
txMetaList: TransactionMeta[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
try {
const txIds = txMetaList.map(({ id }) => id);
const cancellations = txIds.map(
(id) =>
new Promise<void>((resolve, reject) => {
callBackgroundMethod(
'rejectPendingApproval',
[
String(id),
ethErrors.provider.userRejectedRequest().serialize(),
],
(err) => {
if (err) {
reject(err);
return;
}
resolve();
},
);
}),
);
await Promise.all(cancellations);
const newState = await updateMetamaskStateFromBackground();
dispatch(updateMetamaskState(newState));
dispatch(resetSendState());
txIds.forEach((id) => {
dispatch(completedTx(id));
});
} finally {
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
closeNotificationPopup();
} else {
dispatch(hideLoadingIndication());
}
}
};
}
export function markPasswordForgotten(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await new Promise<void>((resolve, reject) => {
callBackgroundMethod('markPasswordForgotten', [], (error) => {
if (error) {
reject(error);
return;
}
resolve();
});
});
} finally {
// TODO: handle errors
dispatch(hideLoadingIndication());
await forceUpdateMetamaskState(dispatch);
}
};
}
export function unMarkPasswordForgotten(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
return new Promise<void>((resolve) => {
callBackgroundMethod('unMarkPasswordForgotten', [], () => {
resolve();
});
}).then(() => forceUpdateMetamaskState(dispatch));
};
}
2020-11-03 00:41:28 +01:00
export function closeWelcomeScreen() {
return {
type: actionConstants.CLOSE_WELCOME_SCREEN,
};
}
//
// unlock screen
//
2020-11-03 00:41:28 +01:00
export function unlockInProgress() {
return {
type: actionConstants.UNLOCK_IN_PROGRESS,
};
}
export function unlockFailed(message?: string) {
return {
type: actionConstants.UNLOCK_FAILED,
value: message,
};
}
export function unlockSucceeded(message?: string) {
return {
type: actionConstants.UNLOCK_SUCCEEDED,
value: message,
};
}
export function updateMetamaskState(
newState: MetaMaskReduxState['metamask'],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch, getState) => {
const state = getState();
const providerConfig = getProviderConfig(state);
const { metamask: currentState } = state;
const { currentLocale, selectedAddress } = currentState;
const {
currentLocale: newLocale,
selectedAddress: newSelectedAddress,
providerConfig: newProviderConfig,
} = newState;
if (currentLocale && newLocale && currentLocale !== newLocale) {
dispatch(updateCurrentLocale(newLocale));
}
if (selectedAddress !== newSelectedAddress) {
dispatch({ type: actionConstants.SELECTED_ADDRESS_CHANGED });
}
const newAddressBook =
newState.addressBook?.[newProviderConfig?.chainId] ?? {};
const oldAddressBook =
currentState.addressBook?.[providerConfig?.chainId] ?? {};
const newAccounts: { [address: string]: Record<string, any> } =
getMetaMaskAccounts({ metamask: newState });
const oldAccounts: { [address: string]: Record<string, any> } =
getMetaMaskAccounts({ metamask: currentState });
const newSelectedAccount = newAccounts[newSelectedAddress];
const oldSelectedAccount = newAccounts[selectedAddress];
// dispatch an ACCOUNT_CHANGED for any account whose balance or other
// properties changed in this update
Object.entries(oldAccounts).forEach(([address, oldAccount]) => {
if (!isEqual(oldAccount, newAccounts[address])) {
dispatch({
type: actionConstants.ACCOUNT_CHANGED,
payload: { account: newAccounts[address] },
});
}
});
// Also emit an event for the selected account changing, either due to a
// property update or if the entire account changes.
if (isEqual(oldSelectedAccount, newSelectedAccount) === false) {
dispatch({
type: actionConstants.SELECTED_ACCOUNT_CHANGED,
payload: { account: newSelectedAccount },
});
}
// We need to keep track of changing address book entries
if (isEqual(oldAddressBook, newAddressBook) === false) {
dispatch({
type: actionConstants.ADDRESS_BOOK_UPDATED,
payload: { addressBook: newAddressBook },
});
}
2021-07-08 22:23:00 +02:00
// track when gasFeeEstimates change
if (
isEqual(currentState.gasFeeEstimates, newState.gasFeeEstimates) === false
) {
dispatch({
type: actionConstants.GAS_FEE_ESTIMATES_UPDATED,
payload: {
gasFeeEstimates: newState.gasFeeEstimates,
gasEstimateType: newState.gasEstimateType,
},
});
}
dispatch({
type: actionConstants.UPDATE_METAMASK_STATE,
value: newState,
});
if (providerConfig.chainId !== newProviderConfig.chainId) {
dispatch({
type: actionConstants.CHAIN_CHANGED,
payload: newProviderConfig.chainId,
});
// We dispatch this action to ensure that the send state stays up to date
// after the chain changes. This async thunk will fail gracefully in the
// event that we are not yet on the send flow with a draftTransaction in
// progress.
dispatch(initializeSendState({ chainHasChanged: true }));
}
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
updateCustodyState(dispatch, newState, getState());
///: END:ONLY_INCLUDE_IN
};
}
const backgroundSetLocked = (): Promise<void> => {
return new Promise<void>((resolve, reject) => {
callBackgroundMethod('setLocked', [], (error) => {
if (error) {
reject(error);
return;
}
resolve();
});
});
};
export function lockMetamask(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
log.debug(`background.setLocked`);
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
return backgroundSetLocked()
.then(() => updateMetamaskStateFromBackground())
2020-02-15 21:34:12 +01:00
.catch((error) => {
dispatch(displayWarning(error.message));
return Promise.reject(error);
})
2020-02-15 21:34:12 +01:00
.then((newState) => {
dispatch(updateMetamaskState(newState));
dispatch(hideLoadingIndication());
dispatch({ type: actionConstants.LOCK_METAMASK });
})
.catch(() => {
dispatch(hideLoadingIndication());
dispatch({ type: actionConstants.LOCK_METAMASK });
});
};
}
async function _setSelectedAddress(address: string): Promise<void> {
log.debug(`background.setSelectedAddress`);
await submitRequestToBackground('setSelectedAddress', [address]);
}
export function setSelectedAddress(
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setSelectedAddress`);
try {
await _setSelectedAddress(address);
} catch (error) {
dispatch(displayWarning(error));
return;
} finally {
dispatch(hideLoadingIndication());
}
};
2017-10-12 19:29:03 +02:00
}
export function setSelectedAccount(
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch, getState) => {
dispatch(showLoadingIndication());
log.debug(`background.setSelectedAddress`);
const state = getState();
2022-07-31 20:26:40 +02:00
const unconnectedAccountAccountAlertIsEnabled =
getUnconnectedAccountAlertEnabledness(state);
const activeTabOrigin = state.activeTab.origin;
const selectedAddress = getSelectedAddress(state);
2022-07-31 20:26:40 +02:00
const permittedAccountsForCurrentTab =
getPermittedAccountsForCurrentTab(state);
2020-11-03 00:41:28 +01:00
const currentTabIsConnectedToPreviousAddress =
Boolean(activeTabOrigin) &&
permittedAccountsForCurrentTab.includes(selectedAddress);
2020-11-03 00:41:28 +01:00
const currentTabIsConnectedToNextAddress =
Boolean(activeTabOrigin) &&
permittedAccountsForCurrentTab.includes(address);
2020-11-03 00:41:28 +01:00
const switchingToUnconnectedAddress =
currentTabIsConnectedToPreviousAddress &&
!currentTabIsConnectedToNextAddress;
try {
await _setSelectedAddress(address);
await forceUpdateMetamaskState(dispatch);
} catch (error) {
dispatch(displayWarning(error));
return;
} finally {
dispatch(hideLoadingIndication());
}
2020-11-03 00:41:28 +01:00
if (
unconnectedAccountAccountAlertIsEnabled &&
switchingToUnconnectedAddress
) {
dispatch(switchedToUnconnectedAccount());
await setUnconnectedAccountAlertShown(activeTabOrigin);
}
};
}
export function addPermittedAccount(
origin: string,
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await new Promise<void>((resolve, reject) => {
callBackgroundMethod(
'addPermittedAccount',
[origin, address],
(error) => {
if (error) {
reject(error);
return;
}
resolve();
},
);
});
await forceUpdateMetamaskState(dispatch);
};
}
export function removePermittedAccount(
origin: string,
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await new Promise<void>((resolve, reject) => {
callBackgroundMethod(
'removePermittedAccount',
[origin, address],
(error) => {
if (error) {
reject(error);
return;
}
resolve();
},
);
});
await forceUpdateMetamaskState(dispatch);
};
}
2020-11-03 00:41:28 +01:00
export function showAccountsPage() {
return {
type: actionConstants.SHOW_ACCOUNTS_PAGE,
};
}
export function showConfTxPage({ id }: Partial<TransactionMeta> = {}) {
return {
type: actionConstants.SHOW_CONF_TX_PAGE,
id,
};
}
2020-11-03 00:41:28 +01:00
export function addToken(
address?: string,
symbol?: string,
decimals?: number,
image?: string,
dontShowLoadingIndicator?: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (!address) {
throw new Error('MetaMask - Cannot add token without address');
}
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('addToken', [
address,
symbol,
decimals,
image,
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
/**
* To add the tokens user selected to state
*
* @param tokensToImport
*/
export function addImportedTokens(
tokensToImport: Token[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await submitRequestToBackground('addImportedTokens', [tokensToImport]);
} catch (error) {
logErrorWithMessage(error);
} finally {
await forceUpdateMetamaskState(dispatch);
}
};
}
/**
* To add ignored token addresses to state
*
* @param options
* @param options.tokensToIgnore
* @param options.dontShowLoadingIndicator
*/
export function ignoreTokens({
tokensToIgnore,
dontShowLoadingIndicator = false,
}: {
tokensToIgnore: string[];
dontShowLoadingIndicator: boolean;
}): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
const _tokensToIgnore = Array.isArray(tokensToIgnore)
? tokensToIgnore
: [tokensToIgnore];
return async (dispatch: MetaMaskReduxDispatch) => {
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('ignoreTokens', [_tokensToIgnore]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
/**
* To fetch the ERC20 tokens with non-zero balance in a single call
*
* @param tokens
*/
export async function getBalancesInSingleCall(
tokens: string[],
): Promise<BalanceMap> {
return await submitRequestToBackground('getBalancesInSingleCall', [tokens]);
}
export function addNft(
address: string,
tokenID: string,
dontShowLoadingIndicator: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (!address) {
throw new Error('MetaMask - Cannot add NFT without address');
}
if (!tokenID) {
throw new Error('MetaMask - Cannot add NFT without tokenID');
}
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('addNft', [address, tokenID]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
export function addNftVerifyOwnership(
address: string,
tokenID: string,
dontShowLoadingIndicator: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (!address) {
throw new Error('MetaMask - Cannot add NFT without address');
}
if (!tokenID) {
throw new Error('MetaMask - Cannot add NFT without tokenID');
}
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('addNftVerifyOwnership', [
address,
tokenID,
]);
} catch (error) {
if (
isErrorWithMessage(error) &&
(error.message.includes('This NFT is not owned by the user') ||
error.message.includes('Unable to verify ownership'))
) {
throw error;
} else {
logErrorWithMessage(error);
dispatch(displayWarning(error));
}
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
export function removeAndIgnoreNft(
address: string,
tokenID: string,
dontShowLoadingIndicator: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (!address) {
throw new Error('MetaMask - Cannot ignore NFT without address');
}
if (!tokenID) {
throw new Error('MetaMask - Cannot ignore NFT without tokenID');
}
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('removeAndIgnoreNft', [address, tokenID]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
export function removeNft(
address: string,
tokenID: string,
dontShowLoadingIndicator: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (!address) {
throw new Error('MetaMask - Cannot remove NFT without address');
}
if (!tokenID) {
throw new Error('MetaMask - Cannot remove NFT without tokenID');
}
if (!dontShowLoadingIndicator) {
dispatch(showLoadingIndication());
}
try {
await submitRequestToBackground('removeNft', [address, tokenID]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning(error));
} finally {
await forceUpdateMetamaskState(dispatch);
dispatch(hideLoadingIndication());
}
};
}
export async function checkAndUpdateAllNftsOwnershipStatus() {
await submitRequestToBackground('checkAndUpdateAllNftsOwnershipStatus');
}
export async function isNftOwner(
ownerAddress: string,
nftAddress: string,
nftId: string,
): Promise<boolean> {
return await submitRequestToBackground('isNftOwner', [
ownerAddress,
nftAddress,
nftId,
]);
}
export async function checkAndUpdateSingleNftOwnershipStatus(nft: Nft) {
await submitRequestToBackground('checkAndUpdateSingleNftOwnershipStatus', [
nft,
false,
]);
}
// When we upgrade to TypeScript 4.5 this is part of the language. It will get
// the underlying type of a Promise generic type. So Awaited<Promise<void>> is
// void.
type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
export async function getTokenStandardAndDetails(
address: string,
userAddress: string,
tokenId: string,
): Promise<
Awaited<
ReturnType<AssetsContractController['getTokenStandardAndDetails']>
> & { balance?: string }
> {
return await submitRequestToBackground('getTokenStandardAndDetails', [
address,
userAddress,
tokenId,
]);
}
export function addTokens(
tokens: Token[] | { [address: string]: Token },
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
2017-09-22 03:44:52 +02:00
if (Array.isArray(tokens)) {
2020-11-03 00:41:28 +01:00
return Promise.all(
tokens.map(({ address, symbol, decimals }) =>
dispatch(addToken(address, symbol, decimals)),
),
);
2017-09-22 03:44:52 +02:00
}
return Promise.all(
2020-11-03 00:41:28 +01:00
Object.entries(tokens).map(([_, { address, symbol, decimals }]) =>
dispatch(addToken(address, symbol, decimals)),
),
);
};
2017-09-22 03:44:52 +02:00
}
export function clearPendingTokens(): Action {
return {
type: actionConstants.CLEAR_PENDING_TOKENS,
};
}
export function createCancelTransaction(
txId: number,
customGasSettings: CustomGasSettings,
options: { estimatedBaseFee?: string } = {},
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
log.debug('background.cancelTransaction');
let newTxId: number;
2018-09-09 19:07:23 +02:00
return (dispatch: MetaMaskReduxDispatch) => {
const actionId = generateActionId();
return new Promise<MetaMaskReduxState['metamask']>((resolve, reject) => {
callBackgroundMethod<MetaMaskReduxState['metamask']>(
'createCancelTransaction',
[txId, customGasSettings, { ...options, actionId }],
2020-11-03 00:41:28 +01:00
(err, newState) => {
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
2020-11-03 00:41:28 +01:00
}
if (newState) {
const { currentNetworkTxList } = newState;
const { id } =
currentNetworkTxList[currentNetworkTxList.length - 1];
newTxId = id;
resolve(newState);
}
2020-11-03 00:41:28 +01:00
},
actionId,
);
2018-09-09 19:07:23 +02:00
})
2020-02-15 21:34:12 +01:00
.then((newState) => dispatch(updateMetamaskState(newState)))
.then(() => newTxId);
};
2018-09-09 19:07:23 +02:00
}
export function createSpeedUpTransaction(
txId: string,
customGasSettings: CustomGasSettings,
options: { estimatedBaseFee?: string } = {},
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
log.debug('background.createSpeedUpTransaction');
let newTx: TransactionMeta;
return (dispatch: MetaMaskReduxDispatch) => {
const actionId = generateActionId();
return new Promise<MetaMaskReduxState['metamask']>((resolve, reject) => {
callBackgroundMethod<MetaMaskReduxState['metamask']>(
'createSpeedUpTransaction',
[txId, customGasSettings, { ...options, actionId }],
2020-11-03 00:41:28 +01:00
(err, newState) => {
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
2020-11-03 00:41:28 +01:00
}
if (newState) {
const { currentNetworkTxList } = newState;
newTx = currentNetworkTxList[currentNetworkTxList.length - 1];
resolve(newState);
}
2020-11-03 00:41:28 +01:00
},
actionId,
);
})
2020-02-15 21:34:12 +01:00
.then((newState) => dispatch(updateMetamaskState(newState)))
.then(() => newTx);
};
}
export function createRetryTransaction(
txId: string,
customGasSettings: CustomGasSettings,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
let newTx: TransactionMeta;
return (dispatch: MetaMaskReduxDispatch) => {
return new Promise<MetaMaskReduxState['metamask']>((resolve, reject) => {
const actionId = generateActionId();
callBackgroundMethod<MetaMaskReduxState['metamask']>(
'createSpeedUpTransaction',
[txId, customGasSettings, { actionId }],
2020-11-03 00:41:28 +01:00
(err, newState) => {
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
2020-11-03 00:41:28 +01:00
}
if (newState) {
const { currentNetworkTxList } = newState;
newTx = currentNetworkTxList[currentNetworkTxList.length - 1];
resolve(newState);
}
2020-11-03 00:41:28 +01:00
},
);
})
2020-02-15 21:34:12 +01:00
.then((newState) => dispatch(updateMetamaskState(newState)))
.then(() => newTx);
};
}
//
// config
//
export function setProviderType(
type: NetworkType,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setProviderType`, type);
try {
await submitRequestToBackground('setProviderType', [type]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had a problem changing networks!'));
}
};
}
export function upsertNetworkConfiguration(
{
rpcUrl,
chainId,
nickname,
rpcPrefs,
ticker = EtherDenomination.ETH,
}: {
rpcUrl: string;
chainId: string;
nickname: string;
rpcPrefs: RPCDefinition['rpcPrefs'];
ticker: string;
},
{
setActive,
source,
}: {
setActive: boolean;
source: string;
},
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch) => {
2020-11-03 00:41:28 +01:00
log.debug(
`background.upsertNetworkConfiguration: ${rpcUrl} ${chainId} ${ticker} ${nickname}`,
);
let networkConfigurationId;
try {
networkConfigurationId = await submitRequestToBackground(
'upsertNetworkConfiguration',
[
{ rpcUrl, chainId, ticker, nickname: nickname || rpcUrl, rpcPrefs },
{ setActive, source, referrer: ORIGIN_METAMASK },
],
);
} catch (error) {
log.error(error);
dispatch(displayWarning('Had a problem adding network!'));
}
return networkConfigurationId;
};
}
export function editAndSetNetworkConfiguration(
{
networkConfigurationId,
rpcUrl,
chainId,
nickname,
rpcPrefs,
ticker = EtherDenomination.ETH,
}: {
networkConfigurationId: string;
rpcUrl: string;
chainId: string;
nickname: string;
rpcPrefs: RPCDefinition['rpcPrefs'];
ticker: string;
},
{ source }: { source: string },
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch) => {
log.debug(
`background.removeNetworkConfiguration: ${networkConfigurationId}`,
);
try {
await submitRequestToBackground('removeNetworkConfiguration', [
networkConfigurationId,
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had a problem removing network!'));
return;
}
try {
await submitRequestToBackground('upsertNetworkConfiguration', [
{
rpcUrl,
chainId,
ticker,
nickname: nickname || rpcUrl,
rpcPrefs,
},
{ setActive: true, referrer: ORIGIN_METAMASK, source },
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had a problem changing networks!'));
}
};
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
}
export function setActiveNetwork(
networkConfigurationId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch) => {
log.debug(`background.setActiveNetwork: ${networkConfigurationId}`);
try {
await submitRequestToBackground('setActiveNetwork', [
networkConfigurationId,
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had a problem changing networks!'));
}
};
}
export function rollbackToPreviousProvider(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await submitRequestToBackground('rollbackToPreviousProvider');
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had a problem changing networks!'));
}
};
}
export function removeNetworkConfiguration(
networkConfigurationId: string,
): ThunkAction<Promise<void>, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch) => {
log.debug(
`background.removeNetworkConfiguration: ${networkConfigurationId}`,
);
return new Promise((resolve, reject) => {
callBackgroundMethod(
'removeNetworkConfiguration',
[networkConfigurationId],
(err) => {
if (err) {
logErrorWithMessage(err);
dispatch(displayWarning('Had a problem removing network!'));
reject(err);
return;
}
resolve();
},
);
});
};
}
// Calls the addressBookController to add a new address.
export function addToAddressBook(
recipient: string,
nickname = '',
memo = '',
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
log.debug(`background.addToAddressBook`);
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
return async (dispatch, getState) => {
const { chainId } = getProviderConfig(getState());
let set;
try {
set = await submitRequestToBackground('setAddressBook', [
2021-05-17 23:19:39 +02:00
toChecksumHexAddress(recipient),
2020-11-03 00:41:28 +01:00
nickname,
chainId,
memo,
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Address book failed to update'));
throw error;
}
if (!set) {
dispatch(displayWarning('Address book failed to update'));
}
};
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
}
/**
* @description Calls the addressBookController to remove an existing address.
* @param chainId
* @param addressToRemove - Address of the entry to remove from the address book
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
*/
export function removeFromAddressBook(
chainId: string,
addressToRemove: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
log.debug(`background.removeFromAddressBook`);
Address book send plus contact list (#6914) * Style Send Header * Move Send to-row to send view and restyle * Add "Recents" group to select recipient view * Rename SendToRow to AddRecipient * Basic UI and Layout * New ENSInput component * wip - fuzzy search for input * small refactor * Add Dialog * contact list initial * initial error on invalid address * clean up edit * Click to open modal * Create AddToAddressBookModal component * Modal styling and layout * modal i18n * Add to Addressbook * ens wip * ens wip * ENS Resolution * Reset input * Send to explicit address * Happy Path Complete * Add back error checking * Reset send-to when emptying input * Add back warning object * Fix linter * Fix unit test #1 - fix import paths * Remove dead tests * One more to go * Fix all unit tests * add unit test for reducers and actions * test rendering AddRecipient * Add tests for dialog boxes in AddRecipient * Add test for validating * Fix linter * Fix e2e tests * Token send e2e fix * Style View Contact * Style edit-contact * Fix e2e * Fix from-import-beta-ui e2e spec * Make section header say "add recipient” by default * Auto-focus add recipient input * Update placeholder text * Update input title font size * Auto advance to next step if user paste a valid address * Ellipsify address when recipient is selected * Fix app header background color on desktop * Give each form row a margin of 16px * Use .container/.component naming pattern for ens-input * Auto-focus on input when add to addressbook modal is opened; Save on Enter * Fix and add unit test * Fix selectors name in e2e tests * Correct e2e test token amount for address-book-send changes * Adds e2e test for editing a transaction * Delete test/integration/lib/send-new-ui.js * Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js * lint and revert to address as object keys * add chainId based on current network to address book entry * fix test * only display contacts for the current network * Improve ENS message when not found on current network * Add error to indicate when network does not support ENS * bump gaba * address book, resolve comments * Move contact-list to its own component * De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/ * Use contact-list component in contact-list-tab.component (i.e. in settings) * Improve/fix settings headers for popup and browser views * Lint fixes related to address book updates * Add 'My accounts' page to settings address book * Update add new contact button in settings to match floating circular design * Improve styles of view contact page * Improve styles and labels of the add-contact.component * Further lint fixes related to address book updates * Update unit tests as per address book updates * Ensure that contact list groups are sorted alphabetically * Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header * Decouple ens-input.component from send context * Add ens resolution to add contact screen in settings * Switching networks when an ens address is shown on send form removes the ens address. * Resolve send screen search for ensAddress to matching address book entry if it exists * Show resolved ens icon and address if exists (settings: add-contact.component) * Make the displayed and copied address in view-contact.component the checksummed address * Default alias state prop in AddToAddressBookModal to empty string * Use keyCode to detect enter key in AddToAddressBookModal * Ensure add-contact component properly updates after QR code detection * Fix display of all recents after clicking 'Load More' in contact list * Fix send screen contact searching after network switching * Code cleanup related to address book changes * Update unit tests for address book changes * Update ENS name not found on network message * Add ens registration error message * Cancel on edit mode takes user back to view screen * Adds support for memo to settings contact list view and edit screens * Modify designs of edit and view contact in popup environment * Update settings content list UX to show split columns in fullscreen and proper internal navigation * Correct background address book API usages in UI
2019-07-31 21:56:44 +02:00
return async () => {
await submitRequestToBackground('removeFromAddressBook', [
2020-11-03 00:41:28 +01:00
chainId,
2021-05-17 23:19:39 +02:00
toChecksumHexAddress(addressToRemove),
]);
};
}
export function showNetworkDropdown(): Action {
return {
type: actionConstants.NETWORK_DROPDOWN_OPEN,
};
}
2020-11-03 00:41:28 +01:00
export function hideNetworkDropdown() {
return {
type: actionConstants.NETWORK_DROPDOWN_CLOSE,
};
}
type ModalPayload = { name: string } & Record<string, any>;
export function showModal(payload: ModalPayload): PayloadAction<ModalPayload> {
return {
type: actionConstants.MODAL_OPEN,
payload,
};
}
export function hideModal(): Action {
return {
type: actionConstants.MODAL_CLOSE,
};
}
export function showImportNftsModal(): Action {
return {
type: actionConstants.IMPORT_NFTS_MODAL_OPEN,
};
}
export function hideImportNftsModal(): Action {
return {
type: actionConstants.IMPORT_NFTS_MODAL_CLOSE,
};
}
export function showIpfsModal(): Action {
return {
type: actionConstants.SHOW_IPFS_MODAL_OPEN,
};
}
export function hideIpfsModal(): Action {
return {
type: actionConstants.SHOW_IPFS_MODAL_CLOSE,
};
}
export function closeCurrentNotificationWindow(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
2021-02-25 23:25:51 +01:00
return (_, getState) => {
const state = getState();
const approvalFlows = getApprovalFlows(state);
2020-11-03 00:41:28 +01:00
if (
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
!hasTransactionPendingApprovals(state) &&
approvalFlows.length === 0
2020-11-03 00:41:28 +01:00
) {
closeNotificationPopup();
}
};
}
export function showAlert(msg: string): PayloadAction<string> {
2018-07-19 08:31:02 +02:00
return {
type: actionConstants.ALERT_OPEN,
payload: msg,
};
2018-07-19 08:31:02 +02:00
}
export function hideAlert(): Action {
2018-07-19 08:31:02 +02:00
return {
type: actionConstants.ALERT_CLOSE,
};
2018-07-19 08:31:02 +02:00
}
/**
* TODO: this should be moved somewhere else when it makese sense to do so
*/
interface NftDropDownState {
[address: string]: {
[chainId: string]: {
[nftAddress: string]: boolean;
};
};
}
export function updateNftDropDownState(
value: NftDropDownState,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('updateNftDropDownState', [value]);
await forceUpdateMetamaskState(dispatch);
};
}
interface QrCodeData {
// Address when a Ethereum Address has been detected
type?: 'address' | string;
// contains an address key when Ethereum Address detected
values?: { address?: string } & Json;
}
2018-08-08 21:42:25 +02:00
/**
* This action will receive two types of values via qrCodeData
* an object with the following structure {type, values}
* or null (used to clear the previous value)
*
* @param qrCodeData
2018-08-08 21:42:25 +02:00
*/
export function qrCodeDetected(
qrCodeData: QrCodeData,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await dispatch({
type: actionConstants.QR_CODE_DETECTED,
value: qrCodeData,
});
// If on the send page, the send slice will listen for the QR_CODE_DETECTED
// action and update its state. Address changes need to recompute gasLimit
// so we fire this method so that the send page gasLimit can be recomputed
dispatch(computeEstimatedGasLimit());
};
2018-07-25 02:32:20 +02:00
}
2017-08-02 22:32:02 +02:00
export function showLoadingIndication(
message?: string | ReactFragment,
): PayloadAction<string | ReactFragment | undefined> {
return {
type: actionConstants.SHOW_LOADING,
payload: message,
};
}
export function setHardwareWalletDefaultHdPath({
device,
path,
}: {
device: HardwareDeviceNames;
path: string;
}): PayloadAction<{ device: HardwareDeviceNames; path: string }> {
return {
type: actionConstants.SET_HARDWARE_WALLET_DEFAULT_HD_PATH,
payload: { device, path },
};
2018-08-14 01:29:43 +02:00
}
export function hideLoadingIndication(): Action {
return {
type: actionConstants.HIDE_LOADING,
};
}
export function displayWarning(payload: unknown): PayloadAction<string> {
if (isErrorWithMessage(payload)) {
return {
type: actionConstants.DISPLAY_WARNING,
payload: payload.message,
};
} else if (typeof payload === 'string') {
return {
type: actionConstants.DISPLAY_WARNING,
payload,
};
}
return {
type: actionConstants.DISPLAY_WARNING,
payload: `${payload}`,
};
}
2020-11-03 00:41:28 +01:00
export function hideWarning() {
return {
type: actionConstants.HIDE_WARNING,
};
}
export function exportAccount(
password: string,
address: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
2016-06-21 22:18:32 +02:00
return function (dispatch) {
dispatch(showLoadingIndication());
log.debug(`background.verifyPassword`);
return new Promise<string>((resolve, reject) => {
callBackgroundMethod('verifyPassword', [password], function (err) {
if (err) {
log.error('Error in verifying password.');
dispatch(hideLoadingIndication());
dispatch(displayWarning('Incorrect Password.'));
reject(err);
return;
}
log.debug(`background.exportAccount`);
callBackgroundMethod<string>(
'exportAccount',
[address, password],
function (err2, result) {
dispatch(hideLoadingIndication());
if (err2) {
logErrorWithMessage(err2);
dispatch(displayWarning('Had a problem exporting the account.'));
reject(err2);
return;
}
dispatch(showPrivateKey(result as string));
resolve(result as string);
},
);
});
});
};
}
export function exportAccounts(
password: string,
addresses: string[],
): ThunkAction<Promise<string[]>, MetaMaskReduxState, unknown, AnyAction> {
return function (dispatch) {
log.debug(`background.verifyPassword`);
return new Promise<string[]>((resolve, reject) => {
callBackgroundMethod('verifyPassword', [password], function (err) {
if (err) {
log.error('Error in submitting password.');
reject(err);
return;
}
log.debug(`background.exportAccounts`);
2020-11-03 00:41:28 +01:00
const accountPromises = addresses.map(
(address) =>
new Promise<string>((resolve2, reject2) =>
callBackgroundMethod<string>(
'exportAccount',
[address, password],
function (err2, result) {
if (err2) {
logErrorWithMessage(err2);
dispatch(
displayWarning('Had a problem exporting the account.'),
);
reject2(err2);
return;
}
resolve2(result as string);
},
),
2020-11-03 00:41:28 +01:00
),
);
resolve(Promise.all(accountPromises));
});
});
};
}
export function showPrivateKey(key: string): PayloadAction<string> {
return {
type: actionConstants.SHOW_PRIVATE_KEY,
payload: key,
};
}
export function setAccountLabel(
account: string,
label: string,
): ThunkAction<Promise<string>, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setAccountLabel`);
return new Promise((resolve, reject) => {
callBackgroundMethod('setAccountLabel', [account, label], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
}
dispatch({
type: actionConstants.SET_ACCOUNT_LABEL,
value: { account, label },
});
resolve(account);
});
});
};
}
export function clearAccountDetails(): Action {
return {
type: actionConstants.CLEAR_ACCOUNT_DETAILS,
};
}
export function showSendTokenPage(): Action {
2017-09-07 13:24:03 +02:00
return {
type: actionConstants.SHOW_SEND_TOKEN_PAGE,
};
2017-09-07 13:24:03 +02:00
}
// TODO: Lift to shared folder when it makes sense
interface TemporaryFeatureFlagDef {
[feature: string]: boolean;
}
interface TemporaryPreferenceFlagDef {
[preference: string]: boolean;
}
export function setFeatureFlag(
feature: string,
activated: boolean,
notificationType: string,
): ThunkAction<
Promise<TemporaryFeatureFlagDef>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
2017-11-14 17:04:55 +01:00
return new Promise((resolve, reject) => {
callBackgroundMethod<TemporaryFeatureFlagDef>(
'setFeatureFlag',
[feature, activated],
2020-11-03 00:41:28 +01:00
(err, updatedFeatureFlags) => {
dispatch(hideLoadingIndication());
2020-11-03 00:41:28 +01:00
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
2020-11-03 00:41:28 +01:00
}
notificationType && dispatch(showModal({ name: notificationType }));
resolve(updatedFeatureFlags as TemporaryFeatureFlagDef);
2020-11-03 00:41:28 +01:00
},
);
});
};
2017-11-14 17:04:55 +01:00
}
export function setPreference(
preference: string,
value: boolean | string,
): ThunkAction<
Promise<TemporaryPreferenceFlagDef>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
return new Promise<TemporaryPreferenceFlagDef>((resolve, reject) => {
callBackgroundMethod<TemporaryPreferenceFlagDef>(
'setPreference',
[preference, value],
(err, updatedPreferences) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
}
resolve(updatedPreferences as TemporaryPreferenceFlagDef);
},
);
});
};
}
export function setDefaultHomeActiveTabName(
value: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setDefaultHomeActiveTabName', [value]);
await forceUpdateMetamaskState(dispatch);
};
2020-05-25 21:01:28 +02:00
}
export function setUseNativeCurrencyAsPrimaryCurrencyPreference(
value: boolean,
) {
return setPreference('useNativeCurrencyAsPrimaryCurrency', value);
}
export function setHideZeroBalanceTokens(value: boolean) {
return setPreference('hideZeroBalanceTokens', value);
}
export function setShowFiatConversionOnTestnetsPreference(value: boolean) {
return setPreference('showFiatInTestnets', value);
}
export function setShowTestNetworks(value: boolean) {
Implement Network Switcher designs (#12260) * Show test networks toggle button in settings/advanced tab. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Apply toggle testnet settings and show/hide testnets when on/off Add localhost to testnet. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Show add network button Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Open full screen when add network is called. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Show custonm rpc before testnet rpcs lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test cases for network dropdown. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Test cases for toggle test networks in advanced tab component. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix Locales. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * E2E Tests: Custom RPC is now called Add Network Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fix Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * E2E: When Add Network button is clicked, wait for the full screen window to be visible Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * findVisibleElement should use a class. i.e start with a dot Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Hide Dropdown when Add Netwok is clicked. Only show full screen if it's not already showing. E2E tests passing. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix tests for jest Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Testnets are not being shown by default anymore, tests should use Mainnet instead. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Import Button from ui Change selector name to getShowTestnetworks Fix button to show full width Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix e2e tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove localhost from INFURA provider types. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix errors in Advanced Tab Component tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix unit tests for advanced tab component. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Remove deleted elements from e2e tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Make sure all tests passed. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-10-28 21:31:05 +02:00
return setPreference('showTestNetworks', value);
}
export function setAutoLockTimeLimit(value: boolean) {
return setPreference('autoLockTimeLimit', value);
}
export function setCompletedOnboarding(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
2019-03-29 05:51:54 +01:00
try {
await submitRequestToBackground('completeOnboarding');
dispatch(completeOnboarding());
} catch (err) {
dispatch(displayWarning(err));
throw err;
} finally {
dispatch(hideLoadingIndication());
}
};
}
2020-11-03 00:41:28 +01:00
export function completeOnboarding() {
return {
type: actionConstants.COMPLETE_ONBOARDING,
};
}
export function setMouseUserState(
isMouseUser: boolean,
): PayloadAction<boolean> {
return {
type: actionConstants.SET_MOUSE_USER_STATE,
payload: isMouseUser,
};
}
export async function forceUpdateMetamaskState(
dispatch: MetaMaskReduxDispatch,
) {
log.debug(`background.getState`);
let newState;
try {
newState = await submitRequestToBackground<MetaMaskReduxState['metamask']>(
'getState',
);
} catch (error) {
dispatch(displayWarning(error));
throw error;
}
dispatch(updateMetamaskState(newState));
return newState;
}
2017-10-16 07:28:25 +02:00
2020-11-03 00:41:28 +01:00
export function toggleAccountMenu() {
2017-10-16 07:28:25 +02:00
return {
type: actionConstants.TOGGLE_ACCOUNT_MENU,
};
2017-10-16 07:28:25 +02:00
}
2017-11-24 02:33:44 +01:00
export function toggleNetworkMenu() {
return {
type: actionConstants.TOGGLE_NETWORK_MENU,
};
}
export function setAccountDetailsAddress(address: string) {
return {
type: actionConstants.SET_ACCOUNT_DETAILS_ADDRESS,
payload: address,
};
}
export function setParticipateInMetaMetrics(
participationPreference: boolean,
): ThunkAction<
Promise<[boolean, string]>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setParticipateInMetaMetrics`);
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
return new Promise((resolve, reject) => {
callBackgroundMethod<string>(
'setParticipateInMetaMetrics',
[participationPreference],
(err, metaMetricsId) => {
log.debug(err);
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
}
/**
* We need to inform sentry that the user's optin preference may have
* changed. The logic to determine which way to toggle is in the
* toggleSession handler in setupSentry.js.
*/
window.sentry?.toggleSession();
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
dispatch({
type: actionConstants.SET_PARTICIPATE_IN_METAMETRICS,
value: participationPreference,
});
resolve([participationPreference, metaMetricsId as string]);
},
);
});
};
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
}
export function setUseBlockie(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseBlockie`);
callBackgroundMethod('setUseBlockie', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
2017-11-25 23:47:34 +01:00
}
export function setUseNonceField(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseNonceField`);
try {
await submitRequestToBackground('setUseNonceField', [val]);
} catch (error) {
dispatch(displayWarning(error));
}
dispatch(hideLoadingIndication());
};
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
}
export function setUsePhishDetect(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUsePhishDetect`);
callBackgroundMethod('setUsePhishDetect', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setUseMultiAccountBalanceChecker(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseMultiAccountBalanceChecker`);
callBackgroundMethod('setUseMultiAccountBalanceChecker', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setUseTokenDetection(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseTokenDetection`);
callBackgroundMethod('setUseTokenDetection', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setUseNftDetection(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseNftDetection`);
callBackgroundMethod('setUseNftDetection', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setUseCurrencyRateCheck(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setUseCurrencyRateCheck`);
callBackgroundMethod('setUseCurrencyRateCheck', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setOpenSeaEnabled(
val: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setOpenSeaEnabled`);
callBackgroundMethod('setOpenSeaEnabled', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
// DetectTokenController
export function detectNewTokens(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.detectNewTokens`);
await submitRequestToBackground('detectNewTokens');
dispatch(hideLoadingIndication());
await forceUpdateMetamaskState(dispatch);
};
}
export function detectNfts(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.detectNfts`);
await submitRequestToBackground('detectNfts');
dispatch(hideLoadingIndication());
await forceUpdateMetamaskState(dispatch);
};
}
export function setAdvancedGasFee(
val: { maxBaseFee?: Hex; priorityFee?: Hex } | null,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setAdvancedGasFee`);
callBackgroundMethod('setAdvancedGasFee', [val], (err) => {
dispatch(hideLoadingIndication());
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setTheme(
val: ThemeType,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
log.debug(`background.setTheme`);
try {
await submitRequestToBackground('setTheme', [val]);
} finally {
dispatch(hideLoadingIndication());
}
};
}
export function setIpfsGateway(
val: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setIpfsGateway`);
callBackgroundMethod('setIpfsGateway', [val], (err) => {
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setUseAddressBarEnsResolution(
val: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setUseAddressBarEnsResolution`);
callBackgroundMethod('setUseAddressBarEnsResolution', [val], (err) => {
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function updateCurrentLocale(
key: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
try {
await loadRelativeTimeFormatLocaleData(key);
const localeMessages = await fetchLocale(key);
const textDirection = await submitRequestToBackground<
'rtl' | 'ltr' | 'auto'
>('setCurrentLocale', [key]);
await switchDirection(textDirection);
dispatch(setCurrentLocale(key, localeMessages));
} catch (error) {
dispatch(displayWarning(error));
return;
} finally {
dispatch(hideLoadingIndication());
}
};
2018-03-16 01:29:45 +01:00
}
export function setCurrentLocale(
locale: string,
messages: {
[translationKey: string]: { message: string; description?: string };
},
): PayloadAction<{
locale: string;
messages: {
[translationKey: string]: { message: string; description?: string };
};
}> {
2018-03-16 01:29:45 +01:00
return {
type: actionConstants.SET_CURRENT_LOCALE,
payload: {
locale,
messages,
},
};
2018-03-16 01:29:45 +01:00
}
export function setPendingTokens(pendingTokens: {
customToken?: Token;
selectedTokens?: {
[address: string]: Token & { isCustom?: boolean; unlisted?: boolean };
};
tokenAddressList: string[];
}) {
const {
customToken,
selectedTokens = {},
tokenAddressList = [],
} = pendingTokens;
2020-11-03 00:41:28 +01:00
const tokens =
customToken?.address &&
customToken?.symbol &&
Boolean(customToken?.decimals >= 0 && customToken?.decimals <= 36)
? {
...selectedTokens,
[customToken.address]: {
...customToken,
isCustom: true,
},
}
: selectedTokens;
2018-05-20 08:04:19 +02:00
Object.keys(tokens).forEach((tokenAddress) => {
tokens[tokenAddress].unlisted = !tokenAddressList.find((addr) =>
isEqualCaseInsensitive(addr, tokenAddress),
);
});
2018-05-20 08:04:19 +02:00
return {
type: actionConstants.SET_PENDING_TOKENS,
2018-05-20 08:04:19 +02:00
payload: tokens,
};
}
2018-09-27 20:19:09 +02:00
2020-10-06 20:28:38 +02:00
// Swaps
export function setSwapsLiveness(
swapsLiveness: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsLiveness', [swapsLiveness]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setSwapsFeatureFlags(
featureFlags: TemporaryFeatureFlagDef,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsFeatureFlags', [featureFlags]);
await forceUpdateMetamaskState(dispatch);
};
}
export function fetchAndSetQuotes(
fetchParams: {
slippage: string;
sourceToken: string;
destinationToken: string;
value: string;
fromAddress: string;
balanceError: string;
sourceDecimals: number;
},
fetchParamsMetaData: {
sourceTokenInfo: Token;
destinationTokenInfo: Token;
accountBalance: string;
chainId: string;
},
): ThunkAction<
Promise<
[
{ destinationAmount: string; decimals: number; aggregator: string },
string,
]
>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
const [quotes, selectedAggId] = await submitRequestToBackground(
'fetchAndSetQuotes',
[fetchParams, fetchParamsMetaData],
);
await forceUpdateMetamaskState(dispatch);
return [quotes, selectedAggId];
};
2020-10-06 20:28:38 +02:00
}
export function setSelectedQuoteAggId(
aggId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSelectedQuoteAggId', [aggId]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setSwapsTokens(
tokens: Token[],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsTokens', [tokens]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function clearSwapsQuotes(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('clearSwapsQuotes');
2021-09-15 15:13:18 +02:00
await forceUpdateMetamaskState(dispatch);
};
}
export function resetBackgroundSwapsState(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('resetSwapsState');
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setCustomApproveTxData(
data: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setCustomApproveTxData', [data]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setSwapsTxGasPrice(
gasPrice: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsTxGasPrice', [gasPrice]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setSwapsTxGasLimit(
gasLimit: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsTxGasLimit', [gasLimit, true]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function updateCustomSwapsEIP1559GasParams({
gasLimit,
maxFeePerGas,
maxPriorityFeePerGas,
}: {
gasLimit: string;
maxFeePerGas: string;
maxPriorityFeePerGas: string;
}): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await Promise.all([
submitRequestToBackground('setSwapsTxGasLimit', [gasLimit]),
submitRequestToBackground('setSwapsTxMaxFeePerGas', [maxFeePerGas]),
submitRequestToBackground('setSwapsTxMaxFeePriorityPerGas', [
maxPriorityFeePerGas,
]),
]);
await forceUpdateMetamaskState(dispatch);
};
}
// Note that the type widening happening below will resolve when we switch gas
// constants to TypeScript, at which point we'll get better type safety.
// TODO: Remove this comment when gas constants is typescript
export function updateSwapsUserFeeLevel(
swapsCustomUserFeeLevel: PriorityLevels,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsUserFeeLevel', [
swapsCustomUserFeeLevel,
]);
await forceUpdateMetamaskState(dispatch);
};
}
export function setSwapsQuotesPollingLimitEnabled(
quotesPollingLimitEnabled: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsQuotesPollingLimitEnabled', [
2021-09-15 15:13:18 +02:00
quotesPollingLimitEnabled,
]);
2021-09-15 15:13:18 +02:00
await forceUpdateMetamaskState(dispatch);
};
}
export function safeRefetchQuotes(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('safeRefetchQuotes');
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function stopPollingForQuotes(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('stopPollingForQuotes');
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setBackgroundSwapRouteState(
routeState: '' | 'loading' | 'awaiting' | 'smartTransactionStatus',
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setBackgroundSwapRouteState', [
routeState,
]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function resetSwapsPostFetchState(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('resetPostFetchState');
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setSwapsErrorKey(
errorKey: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setSwapsErrorKey', [errorKey]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
export function setInitialGasEstimate(
initialAggId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('setInitialGasEstimate', [initialAggId]);
await forceUpdateMetamaskState(dispatch);
};
2020-10-06 20:28:38 +02:00
}
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
// Permissions
export function requestAccountsPermissionWithId(
origin: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
const id = await submitRequestToBackground(
'requestAccountsPermissionWithId',
[origin],
);
await forceUpdateMetamaskState(dispatch);
return id;
};
}
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
/**
* Approves the permissions request.
*
* @param request - The permissions request to approve.
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
*/
export function approvePermissionsRequest(
request: PermissionsRequest,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
callBackgroundMethod('approvePermissionsRequest', [request], (err) => {
if (err) {
dispatch(displayWarning(err));
}
forceUpdateMetamaskState(dispatch);
});
};
2018-09-27 20:19:09 +02:00
}
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
/**
* Rejects the permissions request with the given ID.
*
* @param requestId - The id of the request to be rejected
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
*/
export function rejectPermissionsRequest(
requestId: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
return new Promise((resolve, reject) => {
callBackgroundMethod('rejectPermissionsRequest', [requestId], (err) => {
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
}
forceUpdateMetamaskState(dispatch).then(resolve).catch(reject);
});
});
};
2018-09-27 20:19:09 +02:00
}
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
/**
* Clears the given permissions for the given origin.
*
* @param subjects
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
*/
export function removePermissionsFor(
subjects: Record<string, NonEmptyArray<string>>,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
callBackgroundMethod('removePermissionsFor', [subjects], (err) => {
if (err) {
dispatch(displayWarning(err));
}
});
};
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
}
///: BEGIN:ONLY_INCLUDE_IN(snaps)
[FLASK] BREAKING - snaps-monorepo@0.30.0 (#17718) * updated snap permission to wallet_snap, updated tests and added migration * updated snap packages * yarn.lock fix * fixed errors * override policy * update policy * undo override * updated localization message descriptions * updated lavamoat policy * more policy updates * update permission controller version * update policy * update fixture builder * updated code to include permission value to satisfy wallet_snap permission description call * fix import issue * update test-snaps version * added missing actions, added snap permission dedupe function * prettier fix * fix fencing * add more fencing * prettier fix * fix fencing (again) * added new action and selector and updated view snap accordingly * update test snaps website version * unfence request variable * add fencing * add optional chaining to fix type error * update migration # * remove old migration * prettier fix * fix migration test * fix fencing * added missing fencing * updated code to workaround fencing * update test-snaps site version and remove snap confirm test * update snap packages * update policies * fix merge marker issue * update test * more fixes * fix permissions * update test * fixed test * Bump test-snaps and iframe-execution-environment * remove unused snap permission from fixture builder * update policies * undo comment removal, update selector implementation * removed unnecessary function, updated migration, updated caveat action * remove optional chaining * fix type issue * more type fixes * fix migration test * remove isFlask check, make migration logic more robust * update coverage * Update LavaMoat policies * Update test/e2e/snaps/enums.js * add extra bail condition * Revert "add extra bail condition" This reverts commit b45c53dcfc6e6e35a5e283d4955d6d6ea9ca5965. * Revert "Revert "add extra bail condition"" This reverts commit cd2ded677935c9cdab0c02b6af55474c83727f60. * fix test * add SnapController entry to state object * updated permission name and caveat type with hardcoded values * add extra test for non-flask scenario * update lavamoat policies * fix locale messages * change coverage target * re-enable rpc snap test * revert locale message change * fix el message * reverted changes --------- Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2023-03-08 19:29:23 +01:00
/**
* Updates the caveat value for the specified origin, permission and caveat type.
*
* @param origin
* @param target
* @param caveatType
* @param caveatValue
*/
export function updateCaveat(
origin: string,
target: string,
caveatType: string,
caveatValue: Record<string, Json>,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch) => {
callBackgroundMethod(
'updateCaveat',
[origin, target, caveatType, caveatValue],
(err) => {
if (err) {
dispatch(displayWarning(err));
}
},
);
};
}
///: END:ONLY_INCLUDE_IN
2021-02-22 17:20:42 +01:00
// Pending Approvals
/**
* Resolves a pending approval and closes the current notification window if no
* further approvals are pending after the background state updates.
*
* @param id - The pending approval id
* @param [value] - The value required to confirm a pending approval
2021-02-22 17:20:42 +01:00
*/
export function resolvePendingApproval(
id: string,
value: unknown,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (_dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('resolvePendingApproval', [id, value]);
2021-02-22 17:20:42 +01:00
// Before closing the current window, check if any additional confirmations
// are added as a result of this confirmation being accepted
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
const { pendingApprovals } = await forceUpdateMetamaskState(_dispatch);
2021-02-22 17:20:42 +01:00
if (Object.values(pendingApprovals).length === 0) {
_dispatch(closeCurrentNotificationWindow());
2021-02-22 17:20:42 +01:00
}
///: END:ONLY_INCLUDE_IN
2021-02-22 17:20:42 +01:00
};
}
/**
* Rejects a pending approval and closes the current notification window if no
* further approvals are pending after the background state updates.
*
* @param id - The pending approval id
* @param [error] - The error to throw when rejecting the approval
2021-02-22 17:20:42 +01:00
*/
export function rejectPendingApproval(
id: string,
error: unknown,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
await submitRequestToBackground('rejectPendingApproval', [id, error]);
2021-02-22 17:20:42 +01:00
// Before closing the current window, check if any additional confirmations
// are added as a result of this confirmation being rejected
2021-02-25 23:25:51 +01:00
const { pendingApprovals } = await forceUpdateMetamaskState(dispatch);
2021-02-22 17:20:42 +01:00
if (Object.values(pendingApprovals).length === 0) {
dispatch(closeCurrentNotificationWindow());
}
};
}
/**
* Rejects all approvals for the given messages
*
* @param messageList - The list of messages to reject
*/
export function rejectAllMessages(
messageList: [],
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
const userRejectionError = serializeError(
ethErrors.provider.userRejectedRequest(),
);
await Promise.all(
messageList.map(
async ({ id }) =>
await submitRequestToBackground('rejectPendingApproval', [
id,
userRejectionError,
]),
),
);
const { pendingApprovals } = await forceUpdateMetamaskState(dispatch);
if (Object.values(pendingApprovals).length === 0) {
dispatch(closeCurrentNotificationWindow());
}
};
}
export function setFirstTimeFlowType(
type: 'create' | 'import',
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setFirstTimeFlowType`);
callBackgroundMethod('setFirstTimeFlowType', [type], (err) => {
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
if (err) {
dispatch(displayWarning(err));
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
}
});
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
dispatch({
type: actionConstants.SET_FIRST_TIME_FLOW_TYPE,
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
value: type,
});
};
Metametrics (#6171) * Add metametrics provider and util. * Add backend api and state for participating in metametrics. * Add frontend action for participating in metametrics. * Add metametrics opt-in screen. * Add metametrics events to first time flow. * Add metametrics events for route changes * Add metametrics events for send and confirm screens * Add metametrics events to dropdowns, transactions, log in and out, settings, sig requests and main screen * Ensures each log in is measured as a new visit by metametrics. * Ensure metametrics is called with an empty string for dimensions params if specified * Adds opt in metametrics modal after unlock for existing users * Adds settings page toggle for opting in and out of MetaMetrics * Switch metametrics dimensions to page level scope * Lint, test and translation fixes for metametrics. * Update design for metametrics opt-in screen * Complete responsive styling of metametrics-opt-in modal * Use new chart image on metrics opt in screens * Incorporate the metametrics opt-in screen into the new onboarding flow * Update e2e tests to accomodate metametrics changes * Mock out metametrics network requests in integration tests * Fix tx-list integration test to support metametrics provider. * Send number of tokens and accounts data with every metametrics event. * Update metametrics event descriptor schema and add new events. * Fix import tos bug and send gas button bug due to metametrics changes. * Various small fixes on the metametrics branch. * Add origin custom variable type to metametrics.util * Fix names of onboarding complete actions (metametrics). * Fix names of Metrics Options actions (metametrics). * Clean up code related to metametrics. * Fix bad merge conflict resolution and improve promise handling in sendMetaMetrics event and confrim tx base * Don't send a second metrics event if user has gone back during first time flow. * Collect metametrics on going back from onboarding create/import. * Add missing custom variable constants for metametrics * Fix metametrics provider * Make height of opt-in modal responsive. * Adjust text content for opt-in modal. * Update metametrics event names and clean up code in opt-in-modal * Put phishing warning step next to last in onboarding flow * Link terms of service on create and import screens of first time flow * Add subtext to options on the onboarding select action screen. * Fix styling of bullet points on end of onboarding screen. * Combine phishing warning and congratulations screens. * Fix placement of users if unlocking after an incomplete onboarding import flow. * Fix capitalization in opt-in screen * Fix last onboarding screen translations * Add link to 'Learn More' on the last screen of onboarding * Code clean up: metametrics branch * Update e2e tests for phishing warning step removal * e2e tests passing on metametrics branch * Different tracking urls for metametrics on development and prod
2019-03-05 16:45:01 +01:00
}
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
export function setSelectedNetworkConfigurationId(
networkConfigurationId: string,
): PayloadAction<string> {
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
return {
type: actionConstants.SET_SELECTED_NETWORK_CONFIGURATION_ID,
payload: networkConfigurationId,
};
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
}
export function setNewNetworkAdded({
networkConfigurationId,
nickname,
}: {
networkConfigurationId: string;
nickname: string;
}): PayloadAction<object> {
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
return {
type: actionConstants.SET_NEW_NETWORK_ADDED,
payload: { networkConfigurationId, nickname },
};
New settings custom rpc form (#6490) * Add networks tab to settings, with header. * Adds network list to settings network tab. * Adds form to settings networks tab and connects it to network list. * Network tab: form adding and editing working * Settings network form properly handles input errors * Add translations for settings network form * Clean up styles of settings network tab. * Add popup-view styles and behaviour to settings network tab. * Fix save button on settings network form * Adds 'Add Network' button and addMode to settings networks tab * Lint fix for settings networks tab addition * Fix navigation in settings networks tab. * Editing an rpcurl in networks tab does not create new network, just changes rpc of old * Fix layout of settings tabs other than network * Networks dropdown 'Custom Rpc' item links to networks tab in settings. * Update settings sidebar networks subheader. * Make networks tab buttons width consistent with input widths in extension view. * Fix settings screen subheader height in popup view * Fix height of add networks button in popup view * Add optional label to chainId and symbol form labels in networks setting tab * Style fixes for networks tab headers * Add ability to customize block explorer used by custom rpc * Stylistic improvements+fixes to custom rpc form. * Hide cancel button. * Highlight and show network form of provider by default. * Standardize network subheader name to 'Networks' * Update e2e tests for new settings network form * Update unit tests for new rpcPrefs prop * Extract blockexplorer url construction into method. * Fix broken styles on non-network tabs in popup mode * Fix block explorer url links for cases when provider in state has not been updated. * Fix vertical spacing of network form * Don't allow click of save button on network form if nothing has changed * Ensure add network button is shown in popup view * Lint fix for networks tab * Fix block explorer url preference setting. * Fix e2e tests for custom blockexplorer in account details modal changes. * Update integration test states to include frequentRpcList property * Fix some capitalizations in en/messages.json * Remove some console.logs added during custom rpc form work * Fix external account link text and url for modal and dropdown. * Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 19:27:14 +02:00
}
export function setNewNftAddedMessage(
newNftAddedMessage: string,
): PayloadAction<string> {
return {
type: actionConstants.SET_NEW_NFT_ADDED_MESSAGE,
payload: newNftAddedMessage,
};
}
export function setRemoveNftMessage(
removeNftMessage: string,
): PayloadAction<string> {
return {
type: actionConstants.SET_REMOVE_NFT_MESSAGE,
payload: removeNftMessage,
};
}
export function setNewTokensImported(
newTokensImported: string,
): PayloadAction<string> {
2022-05-09 19:47:06 +02:00
return {
type: actionConstants.SET_NEW_TOKENS_IMPORTED,
payload: newTokensImported,
2022-05-09 19:47:06 +02:00
};
}
export function setLastActiveTime(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return (dispatch: MetaMaskReduxDispatch) => {
callBackgroundMethod('setLastActiveTime', [], (err) => {
if (err) {
dispatch(displayWarning(err));
}
});
};
}
export function setDismissSeedBackUpReminder(
value: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
await submitRequestToBackground('setDismissSeedBackUpReminder', [value]);
dispatch(hideLoadingIndication());
};
}
export function setDisabledRpcMethodPreference(
methodName: string,
value: number,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
await submitRequestToBackground('setDisabledRpcMethodPreference', [
methodName,
value,
]);
dispatch(hideLoadingIndication());
};
}
export function getRpcMethodPreferences(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication());
await submitRequestToBackground('getRpcMethodPreferences', []);
dispatch(hideLoadingIndication());
};
}
export function setConnectedStatusPopoverHasBeenShown(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return () => {
callBackgroundMethod('setConnectedStatusPopoverHasBeenShown', [], (err) => {
if (isErrorWithMessage(err)) {
throw new Error(err.message);
}
});
};
}
export function setRecoveryPhraseReminderHasBeenShown() {
return () => {
callBackgroundMethod('setRecoveryPhraseReminderHasBeenShown', [], (err) => {
if (isErrorWithMessage(err)) {
throw new Error(err.message);
}
});
};
}
export function setRecoveryPhraseReminderLastShown(
lastShown: number,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return () => {
callBackgroundMethod(
'setRecoveryPhraseReminderLastShown',
[lastShown],
(err) => {
if (isErrorWithMessage(err)) {
throw new Error(err.message);
}
},
);
};
}
export function setTermsOfUseLastAgreed(lastAgreed: number) {
return async () => {
await submitRequestToBackground('setTermsOfUseLastAgreed', [lastAgreed]);
};
}
export function setOutdatedBrowserWarningLastShown(lastShown: number) {
return async () => {
await submitRequestToBackground('setOutdatedBrowserWarningLastShown', [
lastShown,
]);
};
}
export function getContractMethodData(
data = '',
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch, getState) => {
const prefixedData = addHexPrefix(data);
const fourBytePrefix = prefixedData.slice(0, 10);
if (fourBytePrefix.length < 10) {
return {};
}
const { knownMethodData } = getState().metamask;
2020-11-03 00:41:28 +01:00
if (
knownMethodData?.[fourBytePrefix] &&
Object.keys(knownMethodData[fourBytePrefix]).length !== 0
2020-11-03 00:41:28 +01:00
) {
return knownMethodData[fourBytePrefix];
}
log.debug(`loadingMethodData`);
const { name, params } = (await getMethodDataAsync(fourBytePrefix)) as {
name: string;
params: unknown;
};
callBackgroundMethod(
'addKnownMethodData',
[fourBytePrefix, { name, params }],
(err) => {
if (err) {
dispatch(displayWarning(err));
}
},
);
return { name, params };
};
}
export function setSeedPhraseBackedUp(
seedPhraseBackupState: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => {
log.debug(`background.setSeedPhraseBackedUp`);
return new Promise((resolve, reject) => {
callBackgroundMethod(
'setSeedPhraseBackedUp',
[seedPhraseBackupState],
(err) => {
if (err) {
dispatch(displayWarning(err));
reject(err);
return;
}
forceUpdateMetamaskState(dispatch).then(resolve).catch(reject);
},
);
});
};
}
3box integration 2.0 (#6972) * Adds threebox controller * Adds threebox approval modal * Fix unit tests and lint after addition of threebox * Correct threebox behaviour after rejecting request for backup; fixes e2e tests. * Update threebox controller for automatic syncing * Ensure frontend locale updates when preferences are changed via direct update within controller * Add toggle in settings for 3box syncing * Update threebox controller for latest 3box version * Delete unnecessary frontend changes for threebox integration * Backing up address book contacts with threebox * Update unit tests for 3box-integration additions * Only enable threebox by default for new wallets * Mock globals for correct unit tests * 3box '1.10.2' -> '^1.10.2' * Correct capilalization on 3Box * Use log.debug instead of console.log in threebox controller * Update yarn.lock * Remove edge build * Split 3box module into background deps js file * extra bundle opts for bg-libs * sync yarn.lock * new3Box logic * Show confirm threebox restore after import * Remove bg-libs.js from manifest file for dev builds * Switch 3Box controller to using the spaces api (instead of the profile api) * Finalize switching to spaces api and only restoring from 3box after import * Update metamask-controller-test.js for threebox controller changes * Make threebox modal style consistent with others and update success button wording * Use mock 3box when in test * Correct 3box modal header * Remove unnecessary property of threebox controller provider * Remove unnecessary method calls after restoration from 3box in the threebox-restore-confirm modal. * Replace setThreeBoxSyncingPermission calls in routes/index.js with turnThreeBoxSyncingOn * Replace erroneous use of with * Replace erroneous use of threeboxSyncing with threeBoxSyncingAllowed in advancted-tab directory * Lint fixes for 3box changes * Log errors encountered when updating 3Box * Remove unnecessary parameter from state update * Add timeout to initial 3Box sync The initial 3Box sync will now timeout after 1 minute. If the timeout is triggered, 3Box is disabled and cannot be re-enabled unless the initial sync does finally finish. If it never finishes, 3Box cannot be enabled unless the extension is reinstalled. The Advanced Settings page was updated to show this option as disabled in that circumstance, with a new discription explaining why it's disabled. The UI here could certainly be improved. Additionally, "on" and "off" labels were added to the toggle to match the other toggles on the Advanced Settings page. * Use non-minified 3Box module We had previously used the minified 3Box module to avoid a build error encountered when `envify` was processing the `libp2p` module (which is used by 3Box). The build would fail because `esprima` (used by `envify`) is incompatible with the object spread/rest operator (which is used in `libp2p`). That issue has been solved by adding a global Babelify transformation specifically for transpiling out the object rest/spread operator from dependencies. It has been targetted to only affect `libp2p` to avoid extending the build time too much. This workaround can be used until a new version of `esprima` is released that includes this bug fix. * Use app key addresses for threebox * Replace use of modal for confirming 3box restoration with a home notification * Adds e2e tests for restoring from threebox * Update eth-keyring-controller to 5.1.0 * Correct parameters passed to getAppKeyAddress in threebox.js * Add prefix to origin passed to getAppKeyAddress in threebox.js * Remove unused locale message. * Prevent CORS errors in firefox e2e tests * Ensure extraneous scripts are excluded from the local test dev build * Move threeBoxLastUpdate state from home.component to redux * Threebox PR code cleanup * Always use first address when initializing threebox * Replace setRestoredFromThreeBox api with setRestoredFromThreeBoxToFalse and setRestoredFromThreeBoxToTrue * Update development/metamaskbot-build-announce.js to include ui-libs and bg-libs in hard coded bundle list * Update test/e2e/threebox.spec.js to use new helpers added with pull #7144 * Make setFeatureFlag available on the ui window during testing * Hide threebox feature behind a feature flag that can only be activated via dev console * Remove unnecessary migration of threebox feature flag * Prevent this.init() call in threebox constructor if feature flag is not turned on * Prevent threebox notification from showing if feature flag is falsy * http://localhost/8889 -> http://localhost/* in gulp manifest:testing tasks
2019-09-16 19:11:01 +02:00
export function setNextNonce(nextNonce: string): PayloadAction<string> {
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
return {
type: actionConstants.SET_NEXT_NONCE,
payload: nextNonce,
};
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
}
/**
* This function initiates the nonceLock in the background for the given
* address, and returns the next nonce to use. It then calls setNextNonce which
* sets the nonce in state on the nextNonce key. NOTE: The nextNonce key is
* actually ephemeral application state. It does not appear to be part of the
* background state.
*
* TODO: move this to a different slice, MetaMask slice will eventually be
* deprecated because it should not contain any ephemeral/app state but just
* background state. In addition we should key nextNonce by address to prevent
* accidental usage of a stale nonce as the call to getNextNonce only works for
* the currently selected address.
*
* @returns
*/
export function getNextNonce(): ThunkAction<
Promise<string>,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch, getState) => {
const address = getState().metamask.selectedAddress;
let nextNonce;
try {
nextNonce = await submitRequestToBackground<string>('getNextNonce', [
address,
]);
} catch (error) {
dispatch(displayWarning(error));
throw error;
}
dispatch(setNextNonce(nextNonce));
return nextNonce;
};
Add advanced setting to enable editing nonce on confirmation screens (#7089) * Add UseNonce toggle * Get the toggle actually working and dispatching * Display nonce field on confirmation page * Remove console.log * Add placeholder * Set customNonceValue * Add nonce key/value to txParams * remove customNonceValue from component state * Use translation file and existing CSS class * Use existing TextField component * Remove console.log * Fix lint nits * Okay this sorta works? * Move nonce toggle to advanced tab * Set min to 0 * Wrap value in Number() * Add customNonceMap * Update custom nonce translation * Update styles * Reset CustomNonce * Fix lint * Get tests passing * Add customNonceValue to defaults * Fix test * Fix comments * Update tests * Use camel case * Ensure custom nonce can only be whole number * Correct font size for custom nonce input * UX improvements for custom nonce feature * Fix advanced-tab-component tests for custom nonce changes * Update title of nonce toggle in settings * Remove unused locale message * Cast custom nonce to string in confirm-transaction-base.component * Handle string conversion and invalid values for custom nonces in handler * Don't call getNonceLock in tx controller if there is a custom nonce * Set nonce details for cases where nonce is customized * Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction * Default nonceLock to empty object in approveTransaction * Reapply use on nonceLock in cases where customNonceValue in approveTransaction. * Show warning message if custom nonce is higher than MetaMask's next nonce * Fix e2e test failure caused by custom nonce and 3box toggle conflict * Update nonce warning message to include the suggested nonce * Handle nextNonce comparison and update logic in lifecycle * Default nonce field to suggested nonce * Clear custom nonce on reject or confirm * Fix bug where nonces are not shown in tx list on self sent transactions * Ensure custom nonce is reset after tx is created in background * Convert customNonceValue to number in approve tranasction controller * Lint fix * Call getNextNonce after updating custom nonce
2019-09-27 06:30:36 +02:00
}
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
export function setRequestAccountTabIds(requestAccountTabIds: {
[origin: string]: string;
}): PayloadAction<{
[origin: string]: string;
}> {
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
return {
type: actionConstants.SET_REQUEST_ACCOUNT_TABS,
payload: requestAccountTabIds,
};
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
}
export function getRequestAccountTabIds(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
const requestAccountTabIds = await submitRequestToBackground<{
[origin: string]: string;
}>('getRequestAccountTabIds');
dispatch(setRequestAccountTabIds(requestAccountTabIds));
};
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
}
export function setOpenMetamaskTabsIDs(openMetaMaskTabIDs: {
[tabId: string]: boolean;
}): PayloadAction<{ [tabId: string]: boolean }> {
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
return {
type: actionConstants.SET_OPEN_METAMASK_TAB_IDS,
payload: openMetaMaskTabIDs,
};
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
}
export function getOpenMetamaskTabsIds(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
const openMetaMaskTabIDs = await submitRequestToBackground<{
[tabId: string]: boolean;
}>('getOpenMetamaskTabsIds');
dispatch(setOpenMetamaskTabsIDs(openMetaMaskTabIDs));
};
Connect distinct accounts per site (#7004) * add PermissionsController remove provider approval controller integrate rpc-cap create PermissionsController move provider approval functionality to permissions controller add permissions approval ui, settings page add permissions activity and history move some functionality to metamask-inpage-provider rename siteMetadata -> domainMetadata add accountsChange notification to inpage provider move functionality to inpage provider update inpage provider Remove 'Connections' settings page (#7369) add hooks for exposing accounts in settings rename unused messages in non-English locales Add external extension id to metadata (#7396) update inpage provider, rpc-cap add eth_requestAccounts handling to background prevent notifying connections if extension is locked update inpage provider Fix lint errors add migration review fixes transaction controller review updates removed unused messages * Login Per Site UI (#7368) * LoginPerSite original UI changes to keep * First commit * Get necessary connected tab info for redirect and icon display for permissioned sites * Fix up designs and add missing features * Some lint fixes * More lint fixes * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Code cleanup for LoginPerSite-ui * Update e2e tests to use new connection flow * Fix display of connect screen and app header after login when connect request present * Update metamask-responsive-ui.spec for new item in accounts dropdown * Fix approve container by replacing approvedOrigins with domainMetaData * Adds test/e2e/permissions.spec.js * Correctly handle cancellation of a permissions request * Redirect to home after disconnecting all sites / cancelling all permissions * Fix display of site icons in menu * Fix height of permissions page container * Remove unused locale messages * Set default values for openExternalTabs and tabIdOrigins in account-menu.container * More code cleanup for LoginPerSite-ui * Use extensions api to close tab in permissions-connect * Remove unnecessary change in domIsReady() in contentscript * Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller. * Adds getOriginOfCurrentTab selector * Adds IconWithFallback component and substitutes for appropriate cases * Add and utilize font mixins * Remove unused method in disconnect-all.container.js * Simplify buttonSizeLarge code in page-container-footer.component.js * Add and utilize getAccountsWithLabels selector * Remove console.log in ui/app/store/actions.js * Change last connected time format to yyyy-M-d * Fix css associated with IconWithFallback change * Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes * Code cleanup for LoginPerSite-ui * Use reusable function for modifying openNonMetamaskTabsIDs in background.js * Enables automatic switching to connected account when connected domain is open * Prevent exploit of tabIdOriginMap in background.js * Remove unneeded code from contentscript.js * Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs * Design and styling fixes for LoginPerSite-ui * Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts * Front end changes to support display of lastConnected time in connected and permissions screens * Fix lint errors * Refactor structure of permissionsHistory * Fix default values and object modifications for domain and permissionsHistory related data * Fix connecting to new accounts from modal * Replace retweet.svg with connect-white.svg * Fix signature-request.spec * Update metamask-inpage-provider version * Fix permissions e2e tests * Remove unneeded delay from test/e2e/signature-request.spec.js * Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec * Use requestAccountTabIds strategy for determining tab id that opened a given window * Improve default values for permissions requests * Add some message descriptions to app/_locales/en/messages.json * Code clean up in permission controller * Stopped deep cloning object in mapObjectValues * Bump metamask-inpage-provider version * Add missing description in app/_locales/en/messages.json * Return promises from queryTabs and switchToTab of extension.js * Remove unused getAllPermissions function * Use default props in icon-with-fallback.component.js * Stop passing to permissions controller * Delete no longer used clear-approved-origins modal code * Remove duplicate imports in ui/app/components/app/index.scss * Use URL instead of regex in getOriginFromUrl() * Add runtime error checking to platform, promise based extension.tab methods * Support permission requests from external extensions * Improve font size and colour of the domain origin on the permission confirmation screen * Add support for toggling permissions * Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions * Remove unused code from LoginPerSite-ui branch * Ensure modal closes on Enter press for new-account-modal.component.js * Lint fix * fixup! Login Per Site UI (#7368) * Some code cleanup for LoginPerSite * Adds UX for connecting to dapps via the connected sites screen (#7593) * Adds UX for connecting to dapps via the connected sites screen * Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask * Delete unused permissions controller methods * Fixes two small bugs in the LoginPerSite ui (#7595) * Restore `providerRequest` message translations (#7600) This message was removed, but it was replaced with a very similar message called `likeToConnect`. The only difference is that the new message has "MetaMask" in it. Preserving these messages without "MetaMask" is probably better than deleting them, so these messages have all been restored and renamed to `likeToConnect`. * Login per site no sitemetadata fix (#7610) * Support connected sites for which we have no site metadata. * Change property containing subtitle info often populated by origin to a more accurate of purpose name * Lint fix * Improve disconnection modal messages (#7612) * Improve disconnectAccountModalDescription and disconnectAllModalDescription messages * Update disconnectAccountModalDescription app/_locales/en/messages.json Co-Authored-By: Mark Stacey <markjstacey@gmail.com> * Improve disconnectAccount modal message clarity * Adds cancel button to the account selection screen of the permissions request flow (#7613) * Fix eth_accounts permission language & selectability (#7614) * fix eth_accounts language & selectability * fix MetaMask capitalization in all messages * Close sidebar when opening connected sites (#7611) The 'Connected Sites' button in the accounts details now closes the sidebar, if it is open. This was accomplished by pulling the click handler for that button up to the wallet view component, where another button already followed a similar pattern of closing the sidebar. It seemed confusing to me that one handler was in the `AccountsDetails` container component, and one was handed down from above, so I added PropTypes to the container component. I'm not sure that the WalletView component is the best place for this logic, but I've put it there for now to be consistent with the add token button. * Reject permissions request upon tab close (#7618) Permissions requests are now rejected when the page is closed. This only applies to the full-screen view, as that is the view permission requests should be handled in. The case where the user deals with the request through a different view is handled in #7617 * Handle tab update failure (#7619) `extension.tabs.update` can sometimes fail if the user interacts with the tabs directly around the same time. The redirect flow has been updated to ensure that the permissions tab is still closed in that case. The user is on their own to find the dapp tab again in that case. * Login per site tab popup fixes (#7617) * Handle redirect in response to state update in permissions-connect * Ensure origin is available to permissions-connect subcomponents during redirect * Hide app bar whenever on redirect route * Improvements to handling of redirects in permissions-connect * Ensure permission request id change handling only happens when page is not null * Lint fix * Decouple confirm transaction screen from the selected address (#7622) * Avoid race condtion that could prevent contextual account switching (#7623) There was a race condition in the logic responsible for switching the selected account based upon the active tab. It was asynchronously querying the active tab, then assuming it had been retrieved later. The active tab info itself was already in the redux store in another spot, one that is guaranteed to be set before the UI renders. The race condition was avoided by deleting the duplicate state, and using the other active tab state. * Only redirect back to dapp if current tab is active (#7621) The "redirect back to dapp" behaviour can be disruptive when the permissions connect tab is not active. The purpose of the redirect was to maintain context between the dapp and the permissions request, but if the user has already moved to another tab, that no longer applies. * Fix JSX style lint errors * Remove unused state
2019-12-03 18:35:56 +01:00
}
export function setLedgerTransportPreference(
value: LedgerTransportTypes,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
2021-04-26 20:05:48 +02:00
dispatch(showLoadingIndication());
await submitRequestToBackground('setLedgerTransportPreference', [value]);
2021-04-26 20:05:48 +02:00
dispatch(hideLoadingIndication());
};
}
export async function attemptLedgerTransportCreation() {
return await submitRequestToBackground('attemptLedgerTransportCreation');
}
/**
* This method deduplicates error reports to sentry by maintaining a state
* object 'singleExceptions' in the app slice. The only place this state object
* is accessed from is within this method, to check if it has already seen and
* therefore tracked this error. This is to avoid overloading sentry with lots
* of duplicate errors.
*
* @param error
* @returns
*/
export function captureSingleException(
error: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch, getState) => {
const { singleExceptions } = getState().appState;
if (!(error in singleExceptions)) {
dispatch({
type: actionConstants.CAPTURE_SINGLE_EXCEPTION,
value: error,
});
captureException(Error(error));
}
};
}
// Wrappers around promisifedBackground
/**
* The "actions" below are not actions nor action creators. They cannot use
* dispatch nor should they be dispatched when used. Instead they can be
* called directly. These wrappers will be moved into their location at some
* point in the future.
*/
export function estimateGas(params: TxParams): Promise<Hex> {
return submitRequestToBackground('estimateGas', [params]);
}
export async function updateTokenType(
tokenAddress: string,
): Promise<Token | undefined> {
try {
return await submitRequestToBackground('updateTokenType', [tokenAddress]);
} catch (error) {
logErrorWithMessage(error);
}
return undefined;
}
2021-07-08 22:23:00 +02:00
/**
* initiates polling for gas fee estimates.
*
* @returns a unique identify of the polling request that can be used
* to remove that request from consideration of whether polling needs to
* continue.
2021-07-08 22:23:00 +02:00
*/
export function getGasFeeEstimatesAndStartPolling(): Promise<string> {
return submitRequestToBackground('getGasFeeEstimatesAndStartPolling');
2021-07-08 22:23:00 +02:00
}
/**
* Informs the GasFeeController that a specific token is no longer requiring
* gas fee estimates. If all tokens unsubscribe the controller stops polling.
*
* @param pollToken - Poll token received from calling
* `getGasFeeEstimatesAndStartPolling`.
2021-07-08 22:23:00 +02:00
*/
export function disconnectGasFeeEstimatePoller(pollToken: string) {
return submitRequestToBackground('disconnectGasFeeEstimatePoller', [
pollToken,
]);
2021-07-08 22:23:00 +02:00
}
export async function addPollingTokenToAppState(pollingToken: string) {
return submitRequestToBackground('addPollingTokenToAppState', [
pollingToken,
POLLING_TOKEN_ENVIRONMENT_TYPES[getEnvironmentType()],
]);
}
export async function removePollingTokenFromAppState(pollingToken: string) {
return submitRequestToBackground('removePollingTokenFromAppState', [
pollingToken,
POLLING_TOKEN_ENVIRONMENT_TYPES[getEnvironmentType()],
]);
}
export function getGasFeeTimeEstimate(
maxPriorityFeePerGas: string,
maxFeePerGas: string,
): Promise<ReturnType<GasFeeController['getTimeEstimate']>> {
return submitRequestToBackground('getGasFeeTimeEstimate', [
maxPriorityFeePerGas,
maxFeePerGas,
]);
}
export async function closeNotificationPopup() {
await submitRequestToBackground('markNotificationPopupAsAutomaticallyClosed');
global.platform.closeCurrentWindow();
}
2020-12-02 22:41:30 +01:00
/**
* @param payload - details of the event to track
* @param options - options for routing/handling of event
* @returns
2020-12-02 22:41:30 +01:00
*/
export function trackMetaMetricsEvent(
payload: MetaMetricsEventPayload,
options?: MetaMetricsEventOptions,
) {
return submitRequestToBackground('trackMetaMetricsEvent', [
{ ...payload, actionId: generateActionId() },
options,
]);
2020-12-02 22:41:30 +01:00
}
export function createEventFragment(
options: MetaMetricsEventFragment,
): Promise<string> {
const actionId = generateActionId();
return submitRequestToBackground('createEventFragment', [
{ ...options, actionId },
]);
2022-01-12 20:31:54 +01:00
}
export function createTransactionEventFragment(
transactionId: string,
event: TransactionMetaMetricsEvent,
): Promise<string> {
const actionId = generateActionId();
return submitRequestToBackground('createTransactionEventFragment', [
transactionId,
event,
actionId,
]);
}
export function updateEventFragment(
id: string,
payload: MetaMetricsEventFragment,
) {
return submitRequestToBackground('updateEventFragment', [id, payload]);
2022-01-12 20:31:54 +01:00
}
export function finalizeEventFragment(
id: string,
options?: {
abandoned?: boolean;
page?: MetaMetricsPageObject;
referrer?: MetaMetricsReferrerObject;
},
) {
return submitRequestToBackground('finalizeEventFragment', [id, options]);
2022-01-12 20:31:54 +01:00
}
2020-12-02 22:41:30 +01:00
/**
* @param payload - details of the page viewed
* @param options - options for handling the page view
2020-12-02 22:41:30 +01:00
*/
export function trackMetaMetricsPage(
payload: MetaMetricsPagePayload,
options: MetaMetricsPageOptions,
) {
return submitRequestToBackground('trackMetaMetricsPage', [
{ ...payload, actionId: generateActionId() },
options,
]);
2020-12-02 22:41:30 +01:00
}
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
export function updateViewedNotifications(notificationIdViewedStatusMap: {
[notificationId: string]: boolean;
}) {
return submitRequestToBackground('updateViewedNotifications', [
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
notificationIdViewedStatusMap,
]);
Whats new popup (#10583) * Add 'What's New' notification popup * Move selectors from shared/notifications into ui/ directory * Use keys for localized message in whats new notifications objects, to ensure notifications will be translated. * Remove unused swaps intro popup locale messages * Fix keys of whats new notification locales * Remove notifications messages and descriptions from comment in shared/notifications * Move notifcationActionFunctions to shared/notifications and make it stateless * Get notification data from constants instead of state in whats-new-popup * Code cleanup * Fix build quote reference to swapsEthToken, broken during rebase * Rename notificationFilters to notificationToExclude to clarify its purpose * Documentation for getSortedNotificationsToShow * Move notification action functions from shared/ to whats-new-popup.js * Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller * Update e2e tests for whats new popup changes * Updating migration files * Addressing feedback part 1 * Addressing feedback part 2 * Remove unnecessary div in whats-new-popup * Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector * Delete intro-popup directory and test files * Lint fix * Add notifiction state to address-entry fixture * Use two separate functions for rendering first and subsequent notifications in the whats-new-popup * Ensure that string literals are passed to t for whats new popup text * Update import-ui fixtures to include notificaiton controller state * Remove unnecessary, accidental change confirm-approve * Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification * Update whats-new-popup to use intersection observer api to detect if notification has been seen * Add notifications to send-edit and threebox e2e test fixtures * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update ui/app/selectors/selectors.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Clean up locale code for whats-new-popup notifications * Disconnect observers in whats-new-popup when their callback is first called * Add test case for migration 58 for when the AppStateController does not exist * Rename popover components containerRef to popoverWrapRef * Fix messages.json * Update notification messages and images * Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component * Only create one observer, and only after images have loaded, in whats-new-popup * Set width and height on whats-new-popup image, instead of setting state on img load * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Code clean up in whats new popup re: notification rendering and action functions * Code cleanup in render notification functions of whats-new-popup * Update ui/app/components/app/whats-new-popup/whats-new-popup.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * lint fix * Update and localize notification dates * Clean up date code in shred/notifications/index.js Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 18:51:41 +02:00
}
export async function setAlertEnabledness(
alertId: string,
enabledness: boolean,
) {
await submitRequestToBackground('setAlertEnabledness', [
alertId,
enabledness,
]);
}
export async function setUnconnectedAccountAlertShown(origin: string) {
await submitRequestToBackground('setUnconnectedAccountAlertShown', [origin]);
}
export async function setWeb3ShimUsageAlertDismissed(origin: string) {
await submitRequestToBackground('setWeb3ShimUsageAlertDismissed', [origin]);
}
// Smart Transactions Controller
export async function setSmartTransactionsOptInStatus(
optInState: boolean,
prevOptInState: boolean,
) {
trackMetaMetricsEvent({
actionId: generateActionId(),
event: 'STX OptIn',
category: MetaMetricsEventCategory.Swaps,
sensitiveProperties: {
stx_enabled: true,
current_stx_enabled: true,
stx_user_opt_in: optInState,
stx_prev_user_opt_in: prevOptInState,
},
});
await submitRequestToBackground('setSmartTransactionsOptInStatus', [
optInState,
]);
}
export function clearSmartTransactionFees() {
submitRequestToBackground('clearSmartTransactionFees');
}
export function fetchSmartTransactionFees(
unsignedTransaction: Partial<TxParams> & { chainId: string },
approveTxParams: TxParams,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
if (approveTxParams) {
approveTxParams.value = '0x0';
}
try {
const smartTransactionFees = await await submitRequestToBackground(
'fetchSmartTransactionFees',
[unsignedTransaction, approveTxParams],
);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: null,
});
return smartTransactionFees;
} catch (err) {
logErrorWithMessage(err);
if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) {
const errorObj = parseSmartTransactionsError(err.message);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: errorObj,
});
}
throw err;
}
};
}
interface TemporarySmartTransactionGasFees {
maxFeePerGas: string;
maxPriorityFeePerGas: string;
gas: string;
value: string;
}
const createSignedTransactions = async (
unsignedTransaction: Partial<TxParams> & { chainId: string },
fees: TemporarySmartTransactionGasFees[],
areCancelTransactions?: boolean,
): Promise<TxParams[]> => {
const unsignedTransactionsWithFees = fees.map((fee) => {
const unsignedTransactionWithFees = {
...unsignedTransaction,
maxFeePerGas: decimalToHex(fee.maxFeePerGas),
maxPriorityFeePerGas: decimalToHex(fee.maxPriorityFeePerGas),
gas: areCancelTransactions
? decimalToHex(21000) // It has to be 21000 for cancel transactions, otherwise the API would reject it.
: unsignedTransaction.gas,
value: unsignedTransaction.value,
};
if (areCancelTransactions) {
unsignedTransactionWithFees.to = unsignedTransactionWithFees.from;
unsignedTransactionWithFees.data = '0x';
}
return unsignedTransactionWithFees;
});
const signedTransactions = await submitRequestToBackground<TxParams[]>(
'approveTransactionsWithSameNonce',
[unsignedTransactionsWithFees],
);
return signedTransactions;
};
export function signAndSendSmartTransaction({
unsignedTransaction,
smartTransactionFees,
}: {
unsignedTransaction: Partial<TxParams> & { chainId: string };
smartTransactionFees: {
fees: TemporarySmartTransactionGasFees[];
cancelFees: TemporarySmartTransactionGasFees[];
};
}): ThunkAction<Promise<string>, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
const signedTransactions = await createSignedTransactions(
unsignedTransaction,
smartTransactionFees.fees,
);
const signedCanceledTransactions = await createSignedTransactions(
unsignedTransaction,
smartTransactionFees.cancelFees,
true,
);
try {
const response = await submitRequestToBackground<{ uuid: string }>(
'submitSignedTransactions',
[
{
signedTransactions,
signedCanceledTransactions,
txParams: unsignedTransaction,
},
],
); // Returns e.g.: { uuid: 'dP23W7c2kt4FK9TmXOkz1UM2F20' }
return response.uuid;
} catch (err) {
logErrorWithMessage(err);
if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) {
const errorObj = parseSmartTransactionsError(err.message);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: errorObj,
});
}
throw err;
}
};
}
export function updateSmartTransaction(
uuid: string,
txMeta: TransactionMeta,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await submitRequestToBackground('updateSmartTransaction', [
{
uuid,
...txMeta,
},
]);
} catch (err) {
logErrorWithMessage(err);
if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) {
const errorObj = parseSmartTransactionsError(err.message);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: errorObj,
});
}
throw err;
}
};
}
export function setSmartTransactionsRefreshInterval(
refreshInterval: number,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async () => {
try {
await submitRequestToBackground('setStatusRefreshInterval', [
refreshInterval,
]);
} catch (err) {
logErrorWithMessage(err);
}
};
}
export function cancelSmartTransaction(
uuid: string,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await submitRequestToBackground('cancelSmartTransaction', [uuid]);
} catch (err) {
logErrorWithMessage(err);
if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) {
const errorObj = parseSmartTransactionsError(err.message);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: errorObj,
});
}
throw err;
}
};
}
// TODO: codeword NOT_A_THUNK @brad-decker
export function fetchSmartTransactionsLiveness() {
return async () => {
try {
await submitRequestToBackground('fetchSmartTransactionsLiveness');
} catch (err) {
logErrorWithMessage(err);
}
};
}
export function dismissSmartTransactionsErrorMessage(): Action {
return {
type: actionConstants.DISMISS_SMART_TRANSACTIONS_ERROR_MESSAGE,
};
}
// App state
export function hideTestNetMessage() {
return submitRequestToBackground('setShowTestnetMessageInDropdown', [false]);
}
export function hideBetaHeader() {
return submitRequestToBackground('setShowBetaHeader', [false]);
}
UX Multichain: Added product tour component (#18571) * adding product tour component * updated control for prevIcon * updated app-header and product tour * updated css * updated message strings * updated tests * removed console statement * added selector for product tour * updated test * updated test * updated state with steps * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/product-tour-popover/product-tour-popover.scss Co-authored-by: Garrett Bear <gwhisten@gmail.com> * fixed lint errors * updated lint error * added changes for rtl support * added changes for rtl support * fixed lint errors * Some suggestions (#18676) * updated messages and indentation * fixed popup close on my final step * updated rtl classname condition --------- Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-04-21 17:28:18 +02:00
export function hideProductTour() {
return submitRequestToBackground('setShowProductTour', [false]);
}
// TODO: codeword NOT_A_THUNK @brad-decker
export function setTransactionSecurityCheckEnabled(
transactionSecurityCheckEnabled: boolean,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async () => {
try {
await submitRequestToBackground('setTransactionSecurityCheckEnabled', [
transactionSecurityCheckEnabled,
]);
} catch (error) {
logErrorWithMessage(error);
}
};
}
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
export function setSecurityAlertsEnabled(val: boolean): void {
try {
submitRequestToBackground('setSecurityAlertsEnabled', [val]);
} catch (error) {
logErrorWithMessage(error);
}
}
///: END:ONLY_INCLUDE_IN
export function setFirstTimeUsedNetwork(chainId: string) {
return submitRequestToBackground('setFirstTimeUsedNetwork', [chainId]);
2022-08-23 17:04:07 +02:00
}
// QR Hardware Wallets
export async function submitQRHardwareCryptoHDKey(cbor: Hex) {
await submitRequestToBackground('submitQRHardwareCryptoHDKey', [cbor]);
}
export async function submitQRHardwareCryptoAccount(cbor: Hex) {
await submitRequestToBackground('submitQRHardwareCryptoAccount', [cbor]);
}
export function cancelSyncQRHardware(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(hideLoadingIndication());
await submitRequestToBackground('cancelSyncQRHardware');
};
}
export async function submitQRHardwareSignature(requestId: string, cbor: Hex) {
await submitRequestToBackground('submitQRHardwareSignature', [
requestId,
cbor,
]);
}
export function cancelQRHardwareSignRequest(): ThunkAction<
void,
MetaMaskReduxState,
unknown,
AnyAction
> {
return async (dispatch: MetaMaskReduxDispatch) => {
dispatch(hideLoadingIndication());
await submitRequestToBackground('cancelQRHardwareSignRequest');
};
}
export function requestUserApproval({
origin,
type,
requestData,
}: {
origin: string;
type: string;
requestData: object;
}): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return async (dispatch: MetaMaskReduxDispatch) => {
try {
await submitRequestToBackground('requestUserApproval', [
{
origin,
type,
requestData,
},
]);
} catch (error) {
logErrorWithMessage(error);
dispatch(displayWarning('Had trouble requesting user approval'));
}
};
}
export async function getCurrentNetworkEIP1559Compatibility(): Promise<
boolean | undefined
> {
let networkEIP1559Compatibility;
try {
networkEIP1559Compatibility = await submitRequestToBackground<boolean>(
'getCurrentNetworkEIP1559Compatibility',
);
} catch (error) {
console.error(error);
}
return networkEIP1559Compatibility;
}
///: BEGIN:ONLY_INCLUDE_IN(snaps)
/**
* Set status of popover warning for the first snap installation.
*
* @param shown - True if popover has been shown.
* @returns Promise Resolved on successfully submitted background request.
*/
export function setSnapsInstallPrivacyWarningShownStatus(shown: boolean) {
return async () => {
await submitRequestToBackground(
'setSnapsInstallPrivacyWarningShownStatus',
[shown],
);
};
}
///: END:ONLY_INCLUDE_IN
[FLASK] Add Snaps Keyring (#19710) * flask - add restricted snap_manageAccounts * snap keyring: use local snap keyring instead of package * mvp snap-keyring * fixed the easier lint errors * fix missing permission text * add removal function * update snap keyring * update dep * update git link * update messages and remove snap keyring from lib * set snapprovider as soon as possible * chore: update snap keyring dependency * chore: pass SnapController to SnapKeyring constructor * chore: update deps and comment line (wip) * fix latest update for snaps and remove setController * update yarn lock * add routes * add messages * add message * add snap account detail page * add snap account card * add snap account page * update route * add background * use css grid * update snap text styling * fix lint * remove unused import * change manage link to go to snap * add types for react-router-dom * add link to settings * add breadcrumb to header * add popover * add prop types * add link to propTypes * fix icon in header and tag * update popover * update yarn.lock * add link to account list menu * update from deprecated * add add-snap-popup * use popoverheader * fix lint * update to use modal instead of popup * add install snap * remove export of DeferredPromise * change snap keyring to its own enum * update imports and fences * fix snapId and route * fix header and button for snapCard * hide app header on AddSnapAccountPage * update icon * match path to SnapAccountDetail * set getting started button to close modal * fix key prop warning * add By Metamask message * fix label * add fence to snapkeyringtype * update yarn.lock * refactor removeAccount and static snap list * update removeSnap * feat: remove associated accounts when snap is removed * add get snaps installed to snaps page * fix updateAvailable * add tests to ui components * update test * update scss * udpate config snap popup style * fixed https://www.notion.so/Show-pop-up-only-once-c6aa8494486a4ece8a5c5e35fea56ab5 * update accountListMenu click to open tab or push depending on environment * update yark.lock * remove unused uuid * update lock * update eth-snap-keyring * udpate install from snap page * update to install to use popup * use release versino of eth-snap-keyring * chore: bump snaps-utils version to `0.34.1-flask.1` * update configure snap * chore: update eth-snap-keyring * chore: update policies * fix: remove unused * fix: fix snap-account-detail-page test * fix: fix styles * chore: remove swappable-obj-proxy * fix: fix duplicate entry * fix: disable export private key for snaps account * feat: shuffle snap lists on every reload * fix: configure not popping up * refactor: snapsAddSnapAccountModalDismissal into action and selector * fix: E2BIG when running prettier * fix: lint default export or add-snap-account-modal * fix: lint, remove vendor prefix * fix: fix snapCreatedByMetamask to snapCreatedByMetaMask * Add `manageAccounts` RPC method (#19724) * Update dependencies * Remove snap-keyring-permissions * Update dependencies * Update dependencies * Update imports * removed portfolio link from wallet view (#19716) * removed portfolio link from wallet view * removed unused code * updated test * updated spec file * updated test * Validate LavaMoat policies on each PR (#19703) * Validate LavaMoat policies on each PR The LavaMoat policies are now validated on every PR. This makes it easier to validate policy changes, as they should always correspond with the changes made in the PR (unlike today, when they could be due to a change in platform or a previous PR). Closes #19680 * Update LavaMoat policies --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * fix(action): add required permissions to remove labels (#19728) * Fix dependencies * signature approved metrics e2e test (#19628) * Update dependencies * Integrate Snow with LavaMoat scuttling protection (#17969) * Update lavamoat policies * Security Provider cleanup (#19694) * security-prov: isFlaggedSecurityProviderResponse * security-prov: create shared/modules/util * security prov: rn isFlagged -> isSuspcious - util fn returns true if response is not verified and flagged * security prov: add util test and support undefined param * security prov: reorg util fn - no logic changes * Update LavaMoat policies (#19744) Update LavaMoat policies to match what CI expects. * Replacing deprecated constants & creating stories (#19686) * Replacing deprecated constants & creating stories * updating snapshot * fix: fix imports * chore: update policy.json * fix: move SmartTransactionController out of snaps code fence * fix: yarn.lock dedupe * fix: lavamoat policy * fix: update test * fix: remove snapshot, the list of snaps are always randomized. * fix: resole snaps-controller to use flask --------- Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: Monte Lai <monte.lai@consensys.net> * Update LavaMoat policies * chore: fix webapp policy.json * feat: add snap label test * feat: test to disable export private key for snap accounts * feat: add snap account link test in account-list-menu * fix: add fence for setSnapsAddSnapAccountModalDismissed * fix: remove comments * fix: move routes into snaps fence * feat: use snap registry * fix: account snap identification * chore: add `keyring-snaps` feature flag * fix: remove unneeded spread * Disable warn logs in content-script (#19754) * Use Yarn caching in GitHub Actions (#19662) GitHub actions that install dependencies will now also cache those dependencies using the standard strategy for Yarn (which is to hash the lockfile). This matches the module template (see https://github.com/MetaMask/metamask-module-template/pull/145 for details). This should have no functional impact except that this action will run faster when dependencies are unchanged. * Fixing misspelling in 10.28.0 changelog notes (#19756) * Add `tokenId` type validation in `wallet_watchAsset` middleware (#19738) * Remove unused GitHub Action workflow (#19660) This GitHub action workflow was disabled, but was still running setup steps. It has now been removed entirely. We can re-introduce it again later once the problem that led to it being disabled has been fixed. The associated npm script and JavaScript module have been removed as well. * Fix #847 - Don't show account address on token pages (#19740) Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> * Deprecating FormField and fixing console error (#19739) * Deprecating FormField and fixing console error * Updating snapshots * updated linea image for token and badge (#19717) * updated linea image for token and badge * replaced hardcoded string with constant * UI updates for contacts Page (#19646) * updated contacts flow update * json file updates * updated contacts edit and view list * keep contacts tab selected * lint fix * replaced hardcoded strings with constant * updated padding in box * Replacing deprecated components and fixing prop errors (#19745) * Use `snaps@0.35.2-flask.1` and `snaps@1.0.0-prerelease.1` (#19734) * snaps@0.35.0-flask.1 * Update LavaMoat policies * Update stable snaps packages to 1.0.0-prerelease.1 * Update LavaMoat policies * Fix lint * snaps@0.35.2 * Exclude snap_manageAccounts * Code fencing * Revert removing endowment:keyring exclusion * Bump iframe URLs * UX: Ensure multichain native token name is always shown (#19705) * UX: Ensure multichain native token name is always shown * Fix lint * UX Multichain: fixed padding for edit screen (#19707) * fixed padding for edit screen * Use network picker for header trigger * Fix swaps display * updated snapshot --------- Co-authored-by: David Walsh <davidwalsh83@gmail.com> * Bump @metamask/providers to v11.1.0 (#19762) * Bump @metamask/providers to v11.1.0 --------- Co-authored-by: Alex <adonesky@gmail.com> * Fix fallback gas estimation (#19746) * Fix fallback gas estimation Our fallback gas estimation was failing due to a bug in the `@metamask/controller-utils` package. This was causing gas estimation to fail completely on certain networks (those not supported by our gas estimation APIs and non EIP-1559 compatibile), and it was causing the fallback gas estimation operation (in case our API was down) to fail across all networks. Fixes https://github.com/MetaMask/metamask-extension/issues/19735 * Add e2e tests E2E tests have been added to capture gas estimation. Cases are added for our API, for the fallback estimate, and for non-EIP-1559 estimates. As part of this work, the legacy gas API had to be disabled. This was being used in e2e tests but was dead code in production. It needed to be disabled to ensure the code under test was reachable. * Fix gas API referenced in e2e test * Update unit test snapshots * Update Label component font weight from bold to medium (#19731) * Update Label component font weight from bold to medium * update snapshot * fix snapshots * fix snapshots 2 * Removeing deprecated constants for enums --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in CancelSpeedupPopover (#18638) * create story * replace Typography with Text component * review changes * replace CSS with props styling * use `Button` from `component-library` * tooltip HTML refactor with `component-library` components * remove whitespace in story * strong tag support within Text component * addresses #18651 * taken from #18752 as suggested in https://github.com/MetaMask/metamask-extension/pull/18638#discussion_r1176334805 * replace `strong` with new `Text as="strong"` * remove unneccessary css from fa564e3f036f1439f9f220cca23595b508760614 * add text variant definition * Updating text variant of button * restrore proper spacing between elements * Quick fix for test * Adding key --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Issue 17670 replace typography with text (#19433) * Replace Typograph with Text component in numeric-input-component.js * Replace Typography with Text component in signature-request-message.js * Replace Typography with Text component in signature-request.component.js * Replacing deprecating constants and fixing some signature story warnings * Updating snapshot * Fixing import --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Part of #18714: Replacing deprecated constants in `confirm-subtitle` folder (#19699) * repalcing deprecated constants * resolve issue * lint fixes --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> * Part of #17670: Replace Typography with Text component in: callout.js (#18912) * Part of #17670: Replace Typography with Text component in: callout.js * Update ui/components/ui/callout/callout.js Co-authored-by: Danica Shen <zhaodanica@gmail.com> * Update callout.js * Updating snapshot and deprecating component * Updating snapshot and deprecating component --------- Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Garrett Bear <gwhisten@gmail.com> * [MMI] Added code fences in whats new popup (#19581) * added code fences in whats new popup * Improved code * Added missing prop * Update LavaMoat policies * updated functions by using an options object for the rendering functions in order to bypass possible typsecript issues --------- Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> * Updated action list in token, NFTs and activity view (#19702) * updated ui for nft import button * updated no nft image found in the center * updated footer for all screens in tabs * removed no nft state from nft tab * updated snapshot * lint fix * fixed e2e tests * fixed prep build error * removed no nfts yet test * updated tabs * fixed prod error * updated no nft screen * changed button size to md * fix: change 'M' to '?' * fix: update fence to keyring-snaps * chore: rename folder * fix: typo * chore: remove logs * feat: add metamask developer constant * fix: sass keyring-snap path * chore: update yarn.lock * fix: remove alias * feat: add KEYRING_SNAPS_REGISTRY_URL env * fix: nested fence * feat: add snap manageAccount e2e (#19777) * feat: add snap manageAccount e2e * feat: update link * fix: lint * fix: get values of restrictedMethodPermissionBuilders * fix: add fence to perferences * fix: stop shuffle * fix: remove KEYRING_SNAPS_REGISTRY_URL from metamaskRc * fix: use permissions to determine account snaps * fix: remove shuffle * fix: add comments to fences in excluded snap permission. * chore: fix policy.json * fix: fix snap-account-detail test * fix: lint * fix: snap accoutn detail page test * Update LavaMoat policies * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.test.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: remove fence from isAbleToExportAccount * chore: remove comment line * fix: dismiss snap modal * fix: try catch for scroll * fix: icon for manageAccount * fix: update `handleSnapRequest` to make `params` optional and add `id` * fix: lint for uuid * fix: remove arg in saveSnapKeyring * fix: add fence for uuidV4 * chore: bump dep * fix: permission_manageAccounts message and icon * chore: update registry link * chore: convert address to lowercase * fix: change icon * chore: bump eth-snap-keyring * chore: update webapp policy.json * Update ui/pages/keyring-snaps/new-snap-account-page/new-snap-account-page.test.tsx Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> * fix: update fences * fix: nested fence * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update app/_locales/en/messages.json Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/components/multichain/account-details/account-details-display.js Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/header.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * Update ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com> * fix: rename and added jsdoc * fix: add fence to snap label * fix: remove comment * fix: change pixel to int and remove unused class * fix: lint * fix: create two tests for main and flask restricted methods * fix: remove fence in test * fix: lint header * feat: allow `metamask.github.io` in manifest * fix: remove comment * fix: rename isAbleToExportAccount * chore: use a more restrictive registry URL * fix: change to && not || * fix: remove unused * fix: move keyring snaps URL to Flask's base manifest * fix: use fetch instead of fetchWithCache * fix: lint --------- Co-authored-by: kumavis <aaron@kumavis.me> Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com> Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: Gauthier Petetin <gauthierpetetin@hotmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: weizman <weizmangal@gmail.com> Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> Co-authored-by: Dhruv <79097544+dhruvv173@users.noreply.github.com> Co-authored-by: ryanml <ryanlanese@gmail.com> Co-authored-by: Alex Donesky <adonesky@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: jiexi <jiexiluan@gmail.com> Co-authored-by: jainex <jainexp017@gmail.com> Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Garrett Bear <gwhisten@gmail.com> Co-authored-by: Ujwal Kumar <ujwalkumar95@gmail.com> Co-authored-by: rohit kerkar <129620973+rohiiittttt@users.noreply.github.com> Co-authored-by: Harsh Shukla <125105825+PrgrmrHarshShukla@users.noreply.github.com> Co-authored-by: Danica Shen <zhaodanica@gmail.com> Co-authored-by: Albert Olivé <albertolivecorbella@gmail.com> Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2023-06-29 15:24:08 +02:00
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
export async function setSnapsAddSnapAccountModalDismissed() {
await submitRequestToBackground('setSnapsAddSnapAccountModalDismissed', [
true,
]);
}
export async function updateSnapRegistry() {
await submitRequestToBackground('updateSnapRegistry', []);
}
///: END:ONLY_INCLUDE_IN