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

2180 Commits

Author SHA1 Message Date
Whymarrh Whitby
d75e587533
Replace fast-deep-equal with isEqual from lodash (#7935) 2020-01-29 16:31:53 -03:30
Mark Stacey
59a1746afc
Validate custom spend limit (#7920)
The custom spend limit was previously not validated. It did have a
minimum of zero set, but this didn't have any affect (that minimum is
used for form constraint validation, and this field wasn't in a form).
The field was never checked to ensure the contents didn't exceed the
maximum.

The field is now checked for values that exceed the maximum, and
invalid values in general (including negative values).

The parameters to the `showEditApprovalPermissionModal` were also
alphabetized to make them easier to read. In the course of doing this,
I noticed that the origin was missing from one of the calls. This was
responsible for the modal saying "Spend limit requested by undefined"
when clicking "Edit" under the transaction details. This has been
fixed.
2020-01-29 14:16:38 -04:00
Mark Stacey
00a73ee25e
Replace debounce package with debounce function from lodash (#7931)
These two functions differ slightly in options, but none of those
options are being used by us, so in these cases they're functionally
equivalent. They're even both descendants of the original `debounce`
function from `underscore`.

This was done to reduce the number of direct dependencies we have. It
should not affect bundle size, as we still depend upon the `debounce`
package transitively.
2020-01-29 13:36:03 -04:00
Mark Stacey
cc78378b8e
Allow editing max spend limit (#7919)
In the case where the initial spend limit for the `approve` function
was set to the maximum amount, editing this value would result in the
new limit being silently ignored. The transaction would be submitted
with the original max spend limit.

This occurred because function to generate the new custom data would
look for the expected spend limit in the existing data, then bail if
it was not found (and in these cases, it was never found).

The reason the value was not found is that it was erroneously being
converted to a `Number`. A JavaScript `Number` is not precise enough to
represent larger spend limits, so it would give the wrong hex value
(after rounding had taken place in the conversion to a floating-point
number).

The data string is now updated without relying upon the original token
value; the new value is inserted after the `spender` argument instead,
as the remainder of the `data` string is guaranteed to be the original
limit. Additionally, the conversion to a `Number` is now omitted so
that the custom spend limit is encoded correctly.

Fixes #7915
2020-01-28 22:49:32 -04:00
Mark Stacey
99ceca3d25
Update jazzicon component (#7898)
* Use ref instead of findDOMNode in jazzicon component

The jazzicon component was using `findDOMNode` to get the DOM node for
the main div returned by the component, which is generally not
recommended. Instead a ref is now used.

* Update Jazzicon to v2

This version drops the dependency upon `raphael`, and no longer uses
the function `createSVGMatrix` which was causing unit tests to fail
(because it's not supported by jsdom).
2020-01-28 16:08:55 -08:00
Erik Marks
b75f812953
Improve LoginPerSite UX/devX and permissions logging (#7649)
Update accounts permission history on accountsChanged
Create PermissionsLogController
Fix permissions activity log pruning
Add selectors, background hooks for better UX
Make selected account the first account returned
Use enums for store keys in log controller
Add last selected address history to PreferencesController
2020-01-27 14:42:03 -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
Mark Stacey
70a689410a
Use ref in Mascot component rather than reaching into DOM directly (#7893)
Accessing the dom via `document` is strongly discouraged in React.
Instead the DOM element is now referenced by ref instead.
2020-01-24 14:15:34 -04:00
Mark Stacey
7471e2df02
Remove unnecessary WebRTC shim (#7886)
The WebRTC spec is fairly stable these days, particularly among the
browsers we support. We don't need this shim for anything. I'm guessing
it may have been added primarily with IE in mind.
2020-01-23 14:04:05 -04:00
ryanml
d8c685ba2e Add mechanism to randomize seed phrase filename (#7863)
The filename is seeded by a simple use of Math.random() pulling from an alphanumeric character bank, as opposed to a more cryptographically random solution. This provides a simple layer of difficulty for bad actors to seek out the recovery phrase file.
2020-01-21 21:22:55 -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
cc928aaed9
Add withFixtures helper and simple-send test (#7862)
The `withFixtures` helper will instantiate ganache, a web driver, and
a fixture server initialized with the given set of fixtures. It is
meant to facilitating writing small, isolated e2e tests.

The first example test has been added: simple-send. It ensures that the
user can send 1 ETH to another account.

These new e2e tests will run during the normal e2e test run.

Closes #6548
2020-01-20 14:50:25 -04:00
Whymarrh Whitby
000fcfdfcc
Fix propTypes for TransactionBreakdown component (#7848) 2020-01-16 18:19:38 -03:30
Whymarrh Whitby
7c7f121fe3
Fix props for BasicTabContent component tests (#7850) 2020-01-16 18:19:01 -03:30
Whymarrh Whitby
b4ca671b6b
Fix propTypes and test props for Dropdown components (#7851) 2020-01-16 18:18:09 -03:30
Whymarrh Whitby
78044a5cdc
Fix propTypes and test props for SignatureRequest component (#7849) 2020-01-16 15:53:14 -03:30
Whymarrh Whitby
70e083820b
Refactor Network dropdown component (#7817) 2020-01-16 15:02:03 -03:30
Mark Stacey
8225bbe126
Remove unused current view related things (#7843)
* Remove unused functions from `mapDispatchToProps`

The actions import was also updated to import only the two actions
used, rather than all actions.

* Remove unused container component

Well, technically it was the props injected by this container that were
unused. The container served no purpose, so the component it surrounded
is now used directly instead.

* Remove both unused `getCurrentViewContext` selectors

* Remove unused SHOW_CONFIG_PAGE action

* Remove checks for `currentView` with name `config`

Now that the SHOW_CONFIG_PAGE action has been removed, it's no longer
possible for `currentView.name` to be set to that value.

* Remove unused `wallet-view` container props

* Delete unused SHOW_SEND_PAGE and SHOW_ADD_TOKEN_PAGE actions

* Remove unused `account-menu.container` props

* Remove unused SHOW_INFO_PAGE action

* Remove unused SET_NEW_ACCOUNT_FORM action
2020-01-16 13:02:44 -04:00
Whymarrh Whitby
48c9b0174f
Add required props for TransactionListItemDetails tests (#7834) 2020-01-16 00:04:32 -03:30
Whymarrh Whitby
dcf8eb2187
Fix prop types for GasPriceChart tests (#7836) 2020-01-16 00:03:50 -03:30
Whymarrh Whitby
e642314ae4
Fix prop types for NetworkDropdown tests (#7837) 2020-01-16 00:03:37 -03:30
Mark Stacey
74557bd68a
Delete onBlur handlers from currency and token input components (#7824)
As of #7753, the `onBlur` prop is no longer used for the `token-input`
and `currency-input` components, and the associated wrapper components
and the shared underlying component. It as been removed from all of
them.
2020-01-15 11:18:59 -04:00
Mark Stacey
19f10e197e
Simplify e2e test transaction navigation (#7816)
The transaction navigation in the e2e tests has been made simpler with
the addition of data attributes to help with finding the navigation
buttons. Each button is now labelled according to its purpose.
2020-01-14 14:53:02 -04:00
Mark Stacey
ac01c5c89a
Consistent jsdoc syntax (#7755)
* Specify type before parameter name

Various JSDoc `@param` entries were specified as `name {type}` rather
than `{type} name`.

A couple of `@return` entries have been given types as well.

* Use JSDoc optional syntax rather than Closure syntax

* Use @returns rather than @return

* Use consistent built-in type capitalization

Primitive types are lower-case, and Object is upper-case.

* Separate param/return description with a dash
2020-01-13 14:36:36 -04:00
Whymarrh Whitby
61d1809750
Purge xtend from the UI (#7795) 2020-01-13 12:59:21 -03:30
Whymarrh Whitby
f850a17f63
Convert FiatValue component to ES6 class (#7786)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 11:42:26 -03:30
Whymarrh Whitby
789dd19677
Convert Network component to an ES6 class (#7784)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 11:42:11 -03:30
Whymarrh Whitby
3b3325d191
Convert ReadOnlyInput to functional component (#7788)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 11:41:51 -03:30
Whymarrh Whitby
e20163bfda
Convert TokenList component to an ES6 class (#7785)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 11:39:38 -03:30
Thomas Huang
428fdee7e3
Remove padding of info circle of advanced gas (#7810) 2020-01-13 07:08:39 -08:00
Whymarrh Whitby
d802e09a8b
Convert Mascot component to an ES6 class (#7787) 2020-01-13 10:42:58 -03:30
Thomas Huang
f6de94a6e5
Remove redundant gas selector file (#7805)
One of these two selectors are in use, which is is another file
92971d3c87/ui/app/selectors/custom-gas.js (L44)
2020-01-10 11:11:49 -08:00
Whymarrh Whitby
89e7dc2312
Convert Modal component to ES6 class (#7783) 2020-01-10 15:35:46 -03:30
Whymarrh Whitby
52a38de567
Remove unused components (#7802) 2020-01-10 15:27:48 -03:30
Whymarrh Whitby
fa1482ef76
Convert HideTokenConfirmationModal to an ES6 class (#7782) 2020-01-10 11:51:47 -03:30
Whymarrh Whitby
dadb112df9
Convert MenuDroppoComponent component to an ES6 class (#7781)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-10 11:43:21 -03:30
Mark Stacey
dac83f6188
Make account details modal close button easier to click (#7797)
The account details close button is difficult to click from the e2e
tests because it has a size of zero. The actual icon is added via CSS
as an `::after` pseudo-element.

The CSS has been adjusted to give the icon a size, and it the markup
is now a `button` rather than a `div`.
2020-01-10 10:43:53 -04:00
Mark Stacey
61ab053bb1
Remove unused className prop (#7800)
This prop is not checked by the component it's passed into, and that
class doesn't correspond to any style rules.
2020-01-10 10:43:44 -04:00
Erik Marks
728026d1f7
Fix batch transaction UX (#7473)
* order transactions from oldest to newest in UI

* update json-rpc-engine, eth-json-rpc-middleware

* update e2e and integration tests
2020-01-10 06:34:02 -08:00
Dan J Miller
d349bd61d2
Fix gas estimate for tokens (#7753)
* Make gas estimate update on debounced token amount change, not just on blur after change

* Updated tests

* Ensure `updateGas` is bound early

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-10 10:53:54 -03:30
Whymarrh Whitby
3b1cd1286f
Convert TokenMenuDropdown to an ES6 class (#7779) 2020-01-10 10:34:03 -03:30
Whymarrh Whitby
be3ba68e4c
Convert NetworkDropdown to ES6 class (#7778) 2020-01-10 10:33:47 -03:30
Whymarrh Whitby
7f47a42f55
Convert AccountDetailsDropdown to ES6 class (#7777) 2020-01-10 10:33:32 -03:30
Whymarrh Whitby
6947ff49e0
Convert AccountPanel component to ES6 class (#7775) 2020-01-10 10:32:24 -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
Mark Stacey
7bddbf611a
Replace inlined blockies identicon with npm package (#7757)
The "blockies" style identicon is handled by a module that was copied
from MyEtherWallet and inlined. This has been removed, and replaced
with the upstream package it was originally derived from.
2020-01-07 23:55:32 -04:00
ricky
984e5a1e26
Properly handle <enter> keystroke (#7747)
* Properly handle <enter> keystroke, closes #7737

* no-unused-vars
2020-01-07 17:20:29 -05:00
Whymarrh Whitby
c66449f823
Disable semicolons for class props (#7754) 2020-01-07 16:40:44 -03:30
Whymarrh Whitby
8701ac38a1
Remove useless component constructors (#7718) 2019-12-19 18:30:22 -03:30
Whymarrh Whitby
4b471a4d8a
Adjust colour of Reset Account btn to reflect danger (#7696) 2019-12-12 17:03:05 -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
Mark Stacey
e87e79870a
Add missing PropTypes (#7658)
The props for `send` were also sorted, to make them easier to compare.
I only bothered because they were _almost_ sorted already.
2019-12-06 11:32:03 -04:00
Mark Stacey
eeb329adf7
Fix the permissions connect screen MetaMask logo (#7641)
The MetaMask logo was throwing an exception because the `history` prop
from React Router wasn't being passed in. However, even if it was
passed in, clicking on the logo wouldn't have done anything because the
home route redirects back to the permission connect page.

Instead the logo now isn't given an `onClick` handler. The
`MetaFoxLogo` component has been updated to only set `cursor: pointer`
if given an `onClick` handler.
2019-12-04 19:57:30 -04:00
Dan Finlay
30304913eb
Merge pull request #7591 from whymarrh/eslint-object-curly-spacing
Enable object-curly-spacing rule for ESLint
2019-12-04 10:25:32 -08:00
Dan Finlay
6aa0bec751
Merge pull request #7573 from whymarrh/eslint-no-confusing-arrow
Enable no-confusing-arrow rule for ESLint
2019-12-04 10:23:57 -08:00
Thomas Huang
0b8f74ede5
Remove random comma (#7639) 2019-12-03 21:35:44 -08:00
Whymarrh Whitby
03f53df3f3
Updates to account search functionality (#7637) 2019-12-03 23:25:00 -03:30
Paweł Lula
638e242ce6 Search accounts by name (#7261)
Co-Authored-By: Paweł Lula <pavloblack@hotmail.com>
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2019-12-03 22:51:55 -03:30
Whymarrh Whitby
4ec92ceed3
Fix SimpleDropdown event bubbling (#7627) 2019-12-03 17:44:19 -03:30
Whymarrh Whitby
b8e3957542
Remove unneeded store connections (#7625) 2019-12-03 17:34:16 -03:30
Whymarrh Whitby
274a9ecf53 yarn lint --fix 2019-12-03 17:20:55 -03:30
Whymarrh Whitby
7e22244c03
Replace wild random number key with index (#7629) 2019-12-03 16:53:25 -03:30
Mark Stacey
d9bdba5948
Use ES6 exports for selectors (#7626)
This lets us get rid of the big `selectors` object that was unpleasant
to maintain.
2019-12-03 16:04:28 -04:00
Mark Stacey
b4fd7aea32
Fix a typo made comparing previous prop (#7628)
The prop `prevIsAccountMenuOpen` was referenced in `prevProps`, despite
it not existing. It seems clear from the context that the intention
was to check the `isAccountMenuOpen` prop from `prevProps`, and name
the local variable `prevIsAccountMenuOpen`.
2019-12-03 15:16:59 -04:00
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
16e6103a68 yarn lint --fix 2019-12-03 13:23:13 -03:30
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
e61745a821
Enable no-var rule for ESLint (#7590)
* eslint: Enable no-var rule
* yarn lint --fix
2019-12-03 11:22:01 -03:30
Whymarrh Whitby
f61b068bd2
Drop eslint-disable and TODO comments from Modal component (#7589) 2019-11-28 13:38:31 -03:30
Whymarrh Whitby
cfd041b364
Convert modals to use JSX (#7566) 2019-11-27 18:49:48 -03:30
Whymarrh Whitby
867dcc48ee
Clean up Item JSX (#7584) 2019-11-27 15:49:38 -03:30
Whymarrh Whitby
359be03db8
Split DepositEtherModal into container and component files (#7565) 2019-11-27 12:44:02 -03:30
Whymarrh Whitby
926c8848f1
Enable default-case rule for ESLint (#7572)
* eslint: Enable default-case rule

* Fix missing default cases

* Fix tests failing due to incorrect assumptions
2019-11-27 12:38:35 -03:30
Whymarrh Whitby
9a1c7e3864
Convert Network component to use JSX (#7564) 2019-11-27 11:37:06 -03:30
Whymarrh Whitby
baa5313d21
Convert NetworkDropdown component to use JSX (#7562) 2019-11-27 11:36:46 -03:30
Whymarrh Whitby
f0e5ab6c12
Split ExportPrivateKeyModal into container and component files (#7561) 2019-11-27 11:36:31 -03:30
Whymarrh Whitby
00060d787a
Split TokenCell into container and component files (#7560) 2019-11-27 11:36:12 -03:30
ricky
4a59fb432f
Fix backButtonAction proptype (#7578)
* Fix backButtonAction proptype

* Fix missing trailing comma

* Remove no-op
2019-11-26 17:44:33 -05:00
ricky
e39485cb1c
Fix loading prop type (#7563) 2019-11-25 13:15:12 -05:00
Whymarrh Whitby
e2d6798673
Split EthBalance into container and component files (#7557)
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2019-11-25 11:58:21 -03:30
Whymarrh Whitby
caefda5f47
Use localized messages for NotificationModal buttons (#7558) 2019-11-25 10:02:51 -03:30
Whymarrh Whitby
5f89988671
Delete unused BnAsDecimalInput (#7556) 2019-11-25 10:02:28 -03:30
Whymarrh Whitby
f5c496ffcd
Convert Menu, Item, Divider, and CloseArea components to use JSX (#7547) 2019-11-25 10:01:44 -03:30
Whymarrh Whitby
2b4c99e031
Split WalletView into component and container files (#7546) 2019-11-25 10:00:46 -03:30
Whymarrh Whitby
1ffaa330ad
Split AccountModalContainer into container and component files (#7549)
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2019-11-24 19:11:08 -03:30
Whymarrh Whitby
22a2d21796
Convert Alert component to use JSX (#7542) 2019-11-24 19:10:16 -03:30
Whymarrh Whitby
666277b4fa
Convert TokenMenuDropdown component to use JSX (#7552) 2019-11-24 19:09:10 -03:30
Whymarrh Whitby
d948a3b195
Convert NotificationModal component to use JSX (#7550) 2019-11-24 18:32:53 -03:30
Whymarrh Whitby
6e73d2be69
Convert HideTokenConfirmationModal component to use JSX (#7551) 2019-11-24 18:31:56 -03:30
Whymarrh Whitby
8311617b95
Convert LoadingScreen component to use JSX (#7545) 2019-11-24 17:51:50 -03:30
Whymarrh Whitby
04442318d3
Convert EditableLabel component to use JSX (#7543) 2019-11-24 17:51:21 -03:30
Whymarrh Whitby
1cac6f2768
Convert SimpleDropdown component to use JSX (#7540) 2019-11-24 17:48:58 -03:30
Whymarrh Whitby
a849218f81
Adjust QrCodeView propTypes for its Qr.messages prop (#7529) 2019-11-24 13:45:35 -03:30
Whymarrh Whitby
3377228b74
Split ShiftListItem into container and component files with JSX (#7539) 2019-11-24 01:41:30 -03:30
Whymarrh Whitby
c3e834d17b
Convert CustomizeGasModal component to use JSX (#7537) 2019-11-24 01:32:14 -03:30
Whymarrh Whitby
439fce8901
Convert Mascot component to use JSX (#7535) 2019-11-24 01:29:18 -03:30
Whymarrh Whitby
f15237b1a5
Convert ExportTextContainer component to use JSX (#7538) 2019-11-24 01:24:22 -03:30
Whymarrh Whitby
340559b805
Convert TokenList component to use JSX (#7541) 2019-11-24 01:19:51 -03:30
Whymarrh Whitby
99e94dadbd
Convert Tooltip component to JSX (#7516) 2019-11-23 12:51:59 -03:30
Whymarrh Whitby
9f7438e756
Convert FiatValue component to JSX (#7515) 2019-11-23 12:51:37 -03:30
Whymarrh Whitby
f5824ffad7
Convert CopyButton component to JSX (#7513)
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2019-11-23 12:51:21 -03:30
Whymarrh Whitby
c555ea659c
Convert NetworkDropdownIcon component to JSX (#7511)
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2019-11-23 12:50:47 -03:30
Whymarrh Whitby
4fe147f82f
Convert MenuDroppoComponent component to JSX (#7531) 2019-11-23 12:49:36 -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
a3d0b71320
Convert ReadOnlyInput component to use JSX (#7512) 2019-11-23 00:44:44 -03:30
Whymarrh Whitby
c775a842d1
Convert QrCodeView to use JSX (#7504) 2019-11-23 00:10:35 -03:30
Whymarrh Whitby
7d097dedaf
Convert Dropdown and DropdownMenuItem components to JSX (#7510) 2019-11-22 23:53:16 -03:30
Whymarrh Whitby
7a0e40829a
Convert AccountDetailsDropdown component to use JSX (#7509) 2019-11-22 23:52:41 -03:30
Whymarrh Whitby
1d9787c0d8
Convert GasModalCard component to use JSX (#7507) 2019-11-22 23:28:33 -03:30
Whymarrh Whitby
df88e7656d
Delete unused GasSlider component (#7508) 2019-11-22 23:26:02 -03:30
Whymarrh Whitby
3d598473a0
Convert AccountPanel component to use JSX (#7505) 2019-11-22 22:48:46 -03:30
Whymarrh Whitby
6820a245b5
Convert InputNumber component to use JSX (#7503) 2019-11-22 20:13:58 -03:30
Whymarrh Whitby
5235d8db96
Remove unused onClick prop from Dropdown component (#7500) 2019-11-22 17:23:27 -03:30
Mark Stacey
f763979bed
Add support for one-click onboarding (#7017)
* Add support for one-click onboarding

MetaMask now allows sites to register as onboarding the user, so that
the user is redirected back to the initiating site after onboarding.
This is accomplished through the use of the `metamask-onboarding`
library and the MetaMask forwarder.

At the end of onboarding, a 'snackbar'-stype component will explain to the
user they are about to be moved back to the originating dapp, and it will
show the origin of that dapp. This is intended to help prevent phishing
attempts, as it highlights that a redirect is taking place to an untrusted
third party.

If the onboarding initiator tab is closed when onboarding is finished,
the user is redirected to the onboarding originator as a fallback.

Closes #6161

* Add onboarding button to contract test dapp

The `contract-test` dapp (run with `yarn dapp`, used in e2e tests) now
uses a `Connect` button instead of connecting automatically. This
button also serves as an onboarding button when a MetaMask installation
is not detected.

* Add new static server for test dapp

The `static-server` library we were using for the `contract-test` dapp
didn't allow referencing files outside the server root. This should
have been possible to work around using symlinks, but there was a bug
that resulted in symlinks crashing the server.

Instead it has been replaced with a simple static file server that
will serve paths starting with `node_modules` from the project root.
This will be useful in testing the onboarding library without vendoring
it.

* Add `@metamask/onboarding` and `@metamask/forwarder`

Both libraries used to test onboarding are now included as dev
dependencies, to help with testing. A few convenience scripts
were added to help with this (`yarn forwarder` and `yarn dapp-forwarder`)
2019-11-22 13:03:51 -04:00
ricky
bf57dd5ad9
Add overflow hidden (#7488) 2019-11-21 16:59:50 -05:00
Mark Stacey
71a0bc8b3f
Refactor signature-request-original (#7415)
The component has been updated to split the container from the base
component, and all hyperscript has been replaced with JSX. ES6 imports
are used throughout as well.
2019-11-20 18:03:49 -04:00
Mark Stacey
056e8cdf7e
Merge pull request #7479 from MetaMask/master
Master sync
2019-11-19 21:10:55 -04:00
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
Whymarrh Whitby
ab0600ef0b Add Remind Me Later to SAI migration notification 2019-11-19 16:40:00 -03:30
Whymarrh Whitby
5f9e8867b4 Allow any renderable type in HomeNotification texts 2019-11-19 16:22:34 -03:30
Thomas Huang
4ac247462b
Merge pull request #7469 from MetaMask/master
Master sync
2019-11-18 17:50:03 -08: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
Thomas
7f5d829880 Set default height and alignment of notification icon 2019-11-18 14:45:10 -08:00
Whymarrh Whitby
86b165ea83
Add migration notification for users with Sai (#7450)
Maker has upgraded its Dai token to "Multi-Collateral Dai" (MCD) and requires
all users interacting with Dai migrate their tokens to the new version. Dai
now exclusively refers to Multi-Collateral Dai and what was previouly called
Dai is now Sai (Single Collateral Dai).

In this description, Sai refers to what was (prior to the 2019-11-18) known as Dai.
Dai is the _new_ token.

This changeset:

1. Only affects users who had non-zero Sai at the old contract address
2. Displays a persistent notification for users with Sai
3. Updates the token symbol for users already tracking the Sai token
4. Bumps our direct and indirect eth-contract-metadata dependencies

The notification copy:

> A message from Maker: The new Multi-Collateral Dai token has been released. Your old tokens are now called Sai. Please upgrade your Sai tokens to the new Dai.

The copy is from the Maker team.
2019-11-18 18:16:28 -03:30
Thomas Huang
b3395502f2
Merge pull request #7463 from MetaMask/expand-home-notification-height
Expand home notification height
2019-11-18 12:32:38 -08:00
Mark Stacey
3003104a5d Expand home notification height
The home notification static height of 116px is too cramped for longer
messages, such as the one used for the Sai migration. The old height is
now used for the minimum height instead, with a margin to ensure the
text doesn't get too close to the buttons.
2019-11-18 16:04:43 -04:00
Mark Stacey
273ec7beef Import styles for showing multiple notifications
The styles for the multi-notification component on the home screen were
accidentally removed while resolving a merge conflict in #6891.

Fixes #7460
2019-11-18 15:56:47 -04:00
Whymarrh Whitby
51bfe56510
Disallow spaces around the equal sign in JSX (#7459) 2019-11-18 14:19:03 -03:30
Whymarrh Whitby
f1384e7522
Disable unnecessary curly braces in JSX (#7454) 2019-11-18 11:38:47 -03:30
Whymarrh Whitby
659b4360bc
Add ESLint rule forbidding extraneous defaultProps (#7453) 2019-11-18 11:38:10 -03:30
Sunghee Lee
a6e387fddc Add button disabled when password is empty (#7451) 2019-11-17 14:04:17 -03:30
Whymarrh Whitby
7a6f2693fe
Add defaultProps to MultipleNotifications (#7449) 2019-11-16 19:43:46 -03:30
Mark Stacey
23ab6e2d54
Add metricsEvent to contextTypes (#7439)
The metricsEvent context type was missing, resulting in an error when
it was called.
2019-11-15 14:04:36 -04:00
Mark Stacey
f5cec3e6b7
Ensure SignatureRequestOriginal 'beforeunload' handler is bound (#7414)
The 'beforeunload' handler was being bound to the module scope instead
of the instance scope, because the class was defined using prototypes
rather than the ES6 class syntax. The arrow functions were removed, and
the handler is now bound explicitly in the constructor.
2019-11-14 14:28:40 -04:00
Mark Stacey
5a8e8c61ea
Reject connection request on window close (#7401)
This was first implemented in #7335, but the final version didn't work
because the `_beforeUnload` handler was not bound early, so `this` was
not defined when it was triggered.
2019-11-13 11:03:11 -04:00
Dan J Miller
6acd5cec37
Get prop for signed typed data from domain instead of message (#7402) 2019-11-13 09:11:21 -05:00
Thomas Huang
069a24c1b9 Revert "Adds Wyre Widget (#6434)" (#7385)
This reverts commit 6a4df0dc3f.
2019-11-11 16:18:57 -05:00
ricky
78224601b9 Fix grid-template-columns (#7366)
* Fix grid-template-columns

* Add fullscreen check
2019-11-10 21:17:00 -05:00
Mark Stacey
42279c474b
Set default advanced tab gas limit (#7379)
* Set default advanced tab gas limit

The advanced tab of the transaction confirmation screen would enter
into an infinite loop and crash if the given gas price was falsy and
some interaction was made with the gas limit field.

To prevent this infinite loop, a default value of 0 has been set. The
user will still need to update the gas limit in order to confirm the
transaction, as zero is too low a gas limit (the lowest is 21000).
21000 cannot be the default gas limit at this layer, because the limit
used is from a layer above this, which wouldn't have that same 21000
set.

* Set default gas limit to minimum allowed

A transaction initiated from a dapp might not set a gas limit, which
would result in a default of zero being used in the advanced tab. The
default gas limit in that case has been changed to 21,000, the minimum
allowed gas limit, so that users aren't forced to manually update it.
2019-11-10 21:15:38 -05:00
Mark Stacey
a8175eb799
Fix advanced tab gas chart (#7380)
The gas chart on the advanced tab was not converting the gas price
selected into hex before setting it in state, resulting in the UI
throwing errors and the price being set incorrectly. It now converts
in the same manner as the input fields.
2019-11-10 21:14:53 -05:00
matteopey
efe240195b Hide accounts dropdown scrollbars on Firefox (#7374) 2019-11-10 02:43:36 -05:00
Mark Stacey
ec1f3fa19a
Fix threebox last updated proptype (#7375)
* Use child components for multiple notifications component

The multiple notifications component has been updated to take its child
components as children rather than as a props array, so that the child
components are never executed in the case where they aren't needed.

* Fix threebox last updated proptype
2019-11-10 01:30:07 -05:00
ricky
02aebc2e03
Add onbeforeunload and have it call onCancel (#7335)
* Add onbeforeunload and have it call onCancel

* Address PR feedback

* Get integration tests passing again

* Add underscores

* Add ENVIRONMENT_TYPE_NOTIFICATION check

* Add _beforeUnload + metricsEvent
2019-11-06 12:04:44 -05:00
hjlee9182
9ed01dff7a fix account menu width (#7354) 2019-11-05 11:31:28 -04:00
Dan J Miller
2673eef3c4
Redesign approve screen (#7271)
* Redesign approve screen

* Add translations to approve screen components

* Show account in header of approve screen

* Use state prop bool for unlimited vs custom check in edit-approval-permission

* Set option to custom on input change in edit-approval-permission

* Allow setting of approval amount to unlimited in edit-approval-permission

* Fix height of confirm-approval popup

* Ensure decimals prop passted to confirm-approve.component is correct type

* Ensure first param passed to calcTokenValue in confirm-approve.util is the correct type

* Fix e2e test of permission editing

* Remove unused code from edit-approval-permission.container
2019-11-05 11:43:48 -03:30
Mark Stacey
dbd14d796c
Clear beforeunload handler after button is pressed (#7346)
On the signature request and transaction confirmation notification
pages, the closure of the notification UI implies that the request has
been rejected. However, this rejection is being submitted even when the
window is closed as a result of the user explicitly confirming or
rejecting. In practice, I suspect this has no effect because the
transaction, after being explicitly confirmed or rejected, has already
been moved out of a pending state. But just in case there is some
present or future edge case that might be affected, the `beforeunload`
handler is now removed once the user has explicitly made a choice.

This mistake was introduced recently in #7333
2019-11-04 14:03:57 -04:00