1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 11:46:13 +02:00
Commit Graph

76 Commits

Author SHA1 Message Date
Mark Stacey
53ec42d95f
Add switch to connected account alert (#8532)
Add alert suggesting that the user switch to a connected account. This
alert is displayed when the popup is opened over an active tab that is
connected to some account, but not the current selected account. The
user can choose to switch to a connected account, or dismiss the alert.

This alert is only shown once per account switch. So if the user
repeatedly opens the popup on a dapp without switching accounts, it'll
only be shown the first time. The alert also won't be shown if the user
has just dismissed an "Unconnected account" alert on this same dapp
and account, as that would be redundant.

The alert has a "Don't show me this again" checkbox that allows the
user to disable the alert. It can be re-enabled again on the Alerts
settings page.
2020-05-12 10:01:52 -03:00
Mark Stacey
c4fb514f3d
Allow disabling alerts (#8550)
The unconnected account alert can now be disabled. A "don't show this
again" checkbox has been added to the alert, which prevents that alert
from being shown in the future.

An alert settings page has been added to the settings as well. This
page allows the user to disable or enable any alert.
2020-05-08 16:45:52 -03:00
Mark Stacey
e3a62cd603
Simplify settings tab render functions (#8551)
These `render` functions were just calling `renderContent`. Instead the
`render` function now directly renders the content.
2020-05-07 21:55:25 -03:00
Erik Marks
e8fa0b7b5d
Consolidate and dedupe send selectors (#8506)
* consolidate & dedupe send selectors
2020-05-04 12:06:28 -07:00
Erik Marks
eacdb5d920
Move send selectors to selectors dir (#8505) 2020-05-04 11:27:14 -07:00
Erik Marks
786e82791e
Reorganize selectors directory (#8497) 2020-05-02 12:41:17 -07:00
Mark Stacey
7302a14341
Return Promise from removeFromAddressBook thunk (#8451)
`removeFromAddressBook` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

The callers were updated to `await` the completion of this operation.
2020-04-29 09:36:10 -03:00
Mark Stacey
e20ca4668e
Return Promise from addToAddressBook thunk (#8450)
`addToAddressBook` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

The callers of this action creator were updated to `await` the
completion of the operation. It was called just before redirecting the
user to a different page or closing a modal, and it seemed appropriate
to wait before doing those things.
2020-04-29 01:59:49 -03:00
ricky
45efbbecb7
Use new Copy icon (#8190)
* Use new Copy icon

* split props to two lines

* Add padding
2020-03-16 09:44:02 -04:00
Mark Stacey
47a7176e71
Use consistent variable name for classnames import (#8143)
The variable name `classnames` is generally what we use for this
module, and single-letter variable names are generally frowned upon.
2020-03-01 06:14:16 -04:00
Mark Stacey
ac4e1d4e26
Remove faux <header> elements (#8131)
We have been using the HTML `header` tag in various footers. The
`footer` tag is generally more appropriate for use in a footer.
2020-02-27 18:00:20 -04:00
ryanml
64aef5033d
Adding setting for disabling Eth Phishing Detection (#8125) 2020-02-27 02:29:41 -04:00
Whymarrh Whitby
169ab8adc9
Remove recompose (#8097) 2020-02-24 19:28:26 -03:30
Jenny Pollack
fd170ef8c0
Merge pull request #8062 from whymarrh/no-mixed-operators
Enable core ESLint no-mixed-operators rule
2020-02-17 21:08:06 -07:00
Mark Stacey
c6db54cc6d
Attempt ENS resolution on any valid domain name (#8059)
ENS currently supports a variety of tlds in addition to `.eth`, and
more will be supported in the future. Rather than hard-code a list of
supported ENS tlds, all valid domain names will now be interpreted as
potential ENS addresses in our address input component.

Closes #7978
2020-02-17 21:20:01 -04:00
Whymarrh Whitby
da0300d3b1 Enable core ESLint no-mixed-operators rule 2020-02-17 21:06:36 -03:30
Whymarrh Whitby
a78cf0ef3a Enable arrow-parens ESLint rule 2020-02-15 17:04:21 -03:30
Mark Stacey
dcc7d29511
Refactor QR scanner to move all error handling within component (#7885)
The QR scanner component error handling would sometimes redirect the
user to the wrong page. It was also confusingly handled in two places;
the action used to open the QR scanner, and the scanner component.
The error handling has now been corrected, simplified, and integrated
into the QR scanner component itself.

The old way of handling an error within the component was to close the
modal, then call the action to open it all over again. This action took
a route parameter, which instructed the action on which route to open
if the fullscreen UI needed to be opened (as the fullscreen UI is the
only one where the browser will show the camera permission prompt).

This redirection worked just fine for handling the initial opening
of the QR scanner modal. But for any subsequent errors the same action
was used with a _default route_, meaning the user could click "try
again" and find themselves on a completely different screen.

Instead, errors now trigger a state change instead of closing and re-
opening the modal. The permission checks in the action have been
integrated into the component as well.

One functional change is that the scenario where you have an invalid
QR code has been made an error. Previously this just showed the error
message below the video preview, but left the user with no way to try
again. There error page has a "Try again" button, so it seemed better
suited as an error. Also the message literally started with "Error:".

Another functional change is that _all_ errors during initialization
will result in the error UI being shown. Previously there was one error
case that would instead log to the console and leave the user stuck.
2020-02-13 16:07:50 -04:00
Whymarrh Whitby
4f3fc95d50
Update ESLint rules for test suite (#8023)
* Use @metamask/eslint-config@1.1.0
* Use eslint-plugin-mocha@6.2.2
* Mark root ESLint config as root
* Update Mocha ESLint rules with shared ESLint config
2020-02-11 13:21:13 -03:30
Thomas Huang
5d1c9313db
Various component tests and some conditional statements (#7765)
* Various component tests and some conditional statements

Conditional in account-menu in removeAccount when keyring sometimes is not initially provideed
Conditional on unlock-page when there is no target.getBoundingClientRect on the element.

* Update helpers

* Remove component debugging

* Add default params for render helpers

* Remove stubComponent for old Mascot
Changes in https://github.com/MetaMask/metamask-extension/pull/7893 has prevented the need to stub it out.

Change logout to lock in account-menu test
2020-01-30 11:34:45 -08:00
Mark Stacey
583b404e02
Switch to full lodash package, and update lodash (#7907)
* Update lodash

All versions of the full `lodash` package have been updated to 4.17.15.
The only exception is v4.17.14 which is pinned by `ganache-core`.

* Switch to using `lodash` instead of per-method packages

We have the full lodash package _ten times_ as a production transitive
dependency, so including per-method packages is not saving space (it
might instead result in slightly more space being used).
2020-01-27 12:45:48 -04:00
Mark Stacey
86c6280bc3
Remove unnecessary get environment type parameter (#7891)
* Remove unnecessary `getEnvironmentType` parameter

The default value of the first parameter is `window.location.href`, so
there is no need to pass it in explicitly.

* Remove junk parameter from `getEnvironmentType` invocation

`getEnvironmentType` doesn't need to be passed any parameter, as the
default value is `window.location.href` which is generally what is
wanted. In this case, the variable `location.href` was always
`undefined` anyway. This particular `location` variable is from React
Router, and does not have an `href` property.

* Fix comment for `getEnvironmentType`

One of the possible return values was referred to by the wrong name.
2020-01-24 15:12:58 -04:00
Mark Stacey
b90b30f706
Remove unnecessary withRouter and compose calls (#7890)
`withRouter` has been removed from any components that were not using
any of the three props injected by `withRouter`: `history`, `location`,
and `match`.

`compose` is a no-op when called upon a single component, so it has
been removed in all such cases.
2020-01-24 15:12:49 -04:00
Erik Marks
b095dc0347
Change "Log In/Out" terminology to "Unlock/Lock" (#7853)
* log out/in -> lock/unlock
2020-01-21 14:09:53 -08:00
Mark Stacey
00da0d28a0
Use data attributes to reference settings in e2e tests (#7820)
These rows on the Advanced Settings page were being looked up in the
e2e tests by the order they appeared in. Instead they're now referenced
by data id, so that we can add new settings and re-arrange them without
breaking the e2e tests.
2020-01-14 17:27:36 -04:00
Whymarrh Whitby
8b0c95cbb1
Add required props for AdvancedTab component tests (#7819) 2020-01-14 17:45:54 -03:30
Whymarrh Whitby
92971d3c87
Migrate codebase to use ESM (#7730)
* Update eslint-plugin-import version

* Convert JS files to use ESM

* Update ESLint rules to check imports

* Fix test:unit:global command env

* Cleanup mock-dev script
2020-01-09 00:04:58 -03:30
Sirius Tsou
9ba3774b5e Fix Kovan and Rinkeby chain IDs (#7762) 2020-01-08 11:26:56 -03:30
Whymarrh Whitby
4b471a4d8a
Adjust colour of Reset Account btn to reflect danger (#7696) 2019-12-12 17:03:05 -03:30
pldespaigne
0ef7f603d6 Ipfs cid v1 base32 (#7362)
add ipfs gateway to advanced settings
use ipfs gateway from settings
use ipfs.dweb.link as default CID gateway
disallow gateway.ipfs.io as gateway
2019-12-12 11:28:07 -08:00
Whymarrh Whitby
b5040266a0
Add description to Reset Account in settings (#7686)
* Add description to Reset Account in settings
* Update description copy
2019-12-12 12:10:30 -03:30
Whymarrh Whitby
56d9c06402
Clean up list of available currencies (#7667) 2019-12-09 13:09:46 -03:30
Mark Stacey
49a525b9f8
Add react/no-unused-prop-types ESLint rule (#7655)
* Add `react/no-unused-prop-types` rule

All detected unused prop types have been removed. I have attempted to
ensure these props are no longer passed in either.

* Update handling of props to avoid false positive lint errors

These cases were detected by `react/no-unused-prop-types` as being
unused props, even though they were used. These minor adjustments
prevent them from being flagged as errors.

* Update unit tests

Many of these tests were just checking that specific props were passed
from containers or to a child component. These were deleted, as I can't
imagine how they'd be useful.

* Disable `react/no-unused-prop-types` in `componentWillReceiveProps

The rule `react/no-unused-prop-types` doesn't seem to be detecting
props used within `UNSAFE_componentWillReceiveProps`. The two cases
have been disabled temporarily until we can replace these unsafe
lifecycle functions.
2019-12-07 23:10:47 -04:00
ricky
1c4f2aab8f React 16 upgrade (#7476)
* Use arrow property initializer functions

* Use pure components where applicable

* Add UNSAFE_ prefix for deprecated lifecycle hooks

* Add allow UNSAFE_

* Removed unused "Component"

* Replace boron with 'fade-modal'

* Upgrade react/no-deprecated to an error

* Paste react-tooltip-component source directly

* Use arrow functions to bind `this`

* Add UNSAFE_ prefix

* Update react-redux, react-router-dom

* Remove things from inlined 'fade-modal'

* Adjust mountWithRouter to get unit tests passing again

* Remove domkit

* Add Wrapper to render-helpers

* Upgrade @storybook/addon-knobs
2019-12-06 11:40:06 -04:00
Whymarrh Whitby
274a9ecf53 yarn lint --fix 2019-12-03 17:20:55 -03:30
Dan Finlay
f519fa1ed3
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 09:35:56 -08:00
Whymarrh Whitby
2e69f3233e
eslint: Enable more react/jsx-* rules (#7592) 2019-12-03 13:05:44 -03:30
Whymarrh Whitby
2c33ad3eb4
Enable react/no-unused-state rule for ESLint (#7609)
* eslint: Enable react/no-unused-state rule
* Fix unused state issues
* Remove now unused validFileImport localized message
2019-12-03 12:00:03 -03:30
Whymarrh Whitby
0d6b5b627d
Delete unused Copyable component (#7526)
* Delete unused Copyable component

* Delete unused copy localized message
2019-11-23 01:47:08 -03:30
Whymarrh Whitby
3203c75ee4
Delete commented-out CSS code (#7528) 2019-11-23 01:46:54 -03:30
Whymarrh Whitby
aa41057628
Update ESLint rules for curly braces style (#7477)
* eslint: Enable curly and brace-style

* yarn lint --fix
2019-11-19 20:33:20 -03:30
ricky
346c1f2622
Add additional rpcUrl verification (#7436)
* Add additional url verification

* Add commas

* Address PR feedback

* Use URL over URI

* Update key in other languages

* Add stateKey check

* Split validateUrl into two separate methods

* Remove unused variable

* Add isValidWhenAppended method
2019-11-19 00:11:50 -05:00
Whymarrh Whitby
b0890b6b32
Enforce a single boolean attr notation in JSX (#7465)
This changeset enables the ESLint rule enforcing a single notation for boolean
attributes in JSX—explictly setting the value to `true` is no longer allowed
(as it was never needed).[1]

From the docs for JSX:[2]

> If you pass no value for a prop, it defaults to `true`.

  [1]:https://github.com/yannickcr/eslint-plugin-react/blob/80935658/docs/rules/jsx-boolean-value.md
  [2]:https://reactjs.org/docs/jsx-in-depth.html#props-default-to-true

I have chosen to use this default as it the most consistent with HTML (a la
`checked` and `disabled`).
2019-11-18 19:53:41 -03:30
Whymarrh Whitby
f1384e7522
Disable unnecessary curly braces in JSX (#7454) 2019-11-18 11:38:47 -03:30
Thomas
9d793015d3 Add static defaultProps 2019-10-29 17:55:10 -07:00
Thomas
d90b3feab8 Add back placeholder addAlias for nickname 2019-10-29 16:42:56 -07:00
Thomas
cbd1d47559 Allow removing of contact details to change details. 2019-10-29 16:21:18 -07:00
Thomas
df8b825a67 Adjust copy-to-clipboard svg width and height on edit contact screen 2019-10-29 16:14:18 -07:00
Thomas
9285a10be6 Adds the chainId to remove accounts from state 2019-10-29 10:53:51 -07:00
Thomas Huang
9d9f3685bb Prevent Logout Timer that's longer than a week. (#7253) 2019-10-17 12:25:37 -03:00