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

3608 Commits

Author SHA1 Message Date
ricky
8ba35f673e
Add tx list-item component (#8195)
* Add tx list-item component

New list item compoent for transaction history

* Simplify component logic and remove type checks

* Address remaining feedback

* Remove extra line

* Place className prop on its own line

* Rename to primaryCurrency and secondaryCurrency

* Make the title `isRequired`

* Fix no-undef

* Remove more + buttons to be implemented in seperate PR

* Add minimal store and I18nProvider to storybook

* Use Component to support translations

* Add `metamask` to store

* Rename decorator
2020-03-17 15:15:53 -04:00
Mark Stacey
e1d0f3659e
Fix highlighting of selected asset (#8205)
The current selected asset in the asset list should be highlighted, but
this highlighting was broken for `ETH`. `ETH` was not highlighted when
it was selected, but it would be highlighted when anything else was.

This was broken accidentally in #7546
2020-03-17 14:45:46 -03:00
Mark Stacey
91f6dfc6e0
Fix method registry initialization (#8200)
The method registry was being initialized with the global variable
`ethereumProvider` before that variable was set. As a result, the
method registry was falling back to an internally constructed provider
that used the wrong provider URL (an obsolete Infura API). This was
resulting in an error with the message "Project ID not found".

The method registry is now initialized lazily, when it's first needed.
This should be well after the initialization of `ethereumProvider`,
which occurs during the UI initialization.
2020-03-17 11:14:27 -03:00
ricky
e3b68579ca
Clear sync timeout on unmount (#8199) 2020-03-16 19:33:43 -04:00
Brad Decker
7d374ab8d8
feat - add down caret on asset list (#8198) 2020-03-16 19:50:07 -03:00
Brad Decker
23bfa59bfd
fix #6958: fix destructuring of lastSelectedProvider (#8197) 2020-03-16 15:48:12 -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
74b519959b
Fix Tab prop type warning (#8185)
The props `isActive` and `tabIndex of the Tab component are required
and are always passed in, but the prop type warning is triggered
because the tabs are rendered without these props first, then cloned by
the `Tabs` component, where these props are added.

To silence the warning, the props have been made optional.
2020-03-13 10:49:17 -03:00
Mark Stacey
61fdb56864
Use specified gas limit when speeding up a transaction (#8178)
The sidebar used to speed up a transaction while it's pending or after
it has failed currently allows editing the gas limit, but that new
limit is ignored. This is especially problematic for transactions that
failed due to a low gas limit, as the problem becomes impossible to fix
by retrying.

The gas limit specified by the user is now used in the speed up
transaction.

Fixes #8156
Fixes #7977
2020-03-12 11:33:11 -03:00
Mark Stacey
2b3acfc92b
Skip ENS reverse resolution when address is blank (#8184)
The address is blank momentarily when navigating to the confirmation
screen when sending a token. The address is updated in a subsequent
render.

The ENS reverse resolution is now only attempted if the address is
given. It has also been updated to attempt resolution when the address
is finally set, which fixes the reverse resolution for token sends.

I had hoped to get rid of this interim render-without-address, but that
turned out to be a bit more challenging. The problem is that the UI
submits transactions through the provider just as a dapp would, and the
provider doesn't say when the transaction is submitted. The promise
returned doesn't resolve until after confirmation. We would have to
start calling the background methods directly and bypass the provider
to get the feedback we need, and that sounded potentially dangerous.
Definitely a challenge for another day.
2020-03-12 10:50:37 -03:00
Thomas Huang
e791882959
Handle and set gas estimation when max mode is clicked (#8176)
* Handle and set gas estimation when max mode is clicked
Add componentDidMount to SendAmountRow to check for maxMode boolean to update amount and gas.
2020-03-11 13:13:48 -07:00
Mark Stacey
f0f5554846
Fix selectors that use metamask.send.from state (#8182)
The `metamask.send.from` field was assumed by various selectors to be
an object, but instead it was recently set to a string. The selectors
have been updated to assume it's a string, and to fetch the full
account object explicitly.

The selector `getSendFromObject` was repurposed for this, as that's
basically what it already did. The optional address parameter was
removed though, as that was only used to fetch the `from` address in
cases where the `send` state was set without there being a `from`
address set. That case is no longer possible, as the `from` address is
always set upon the initialization of the `send` state.

The `getSendFromObject` selector no longer fetches the 'name' of that
address from the address book state either. This property was not used
in either of the cases this selector was used.
2020-03-11 15:40:35 -03:00
ricky
3cd35fe0ae
Add tx history icons (#8180)
* Add tx history icons

* Make size `isRequired`

* Use classnames

* Include keyframes
2020-03-11 14:05:47 -04:00
Mark Stacey
ad5174a588
Fix retry transaction (#8177)
The `createRetryTransaction` was accidentally removed from the
`gas-modal-page-container` component during a refactor in #7730.
Attempting to retry a transaction since that change has resulted in a
UI crash.
2020-03-11 12:07:48 -03:00
Dan J Miller
5c4831bdee
Notifications Icon Circles (#7830)
* Adds notification icon circles and associated storybook stories

* Fix image paths in circle-icon.stories and message-circle-icon.component

* Code improvements for icon circles PR: remove additional z-index, make iconSource required

* Use component story format in circle-icon.stories and message-circle-icon.stories

* Remove success and info circle icons, as not presently needed

* Rename message-circle-icon to alert-circle-icon

* Small code fix ups for alert-circle-icons
2020-03-11 12:30:39 -02:30
Dan J Miller
92e6338b78
Translation helper: substitute react components and component wrapping substrings (#8129)
* Update i18n-helper to allow substitutions of react components and wrapping of translation substrings

* Simplify code in i18n-helper.js related to substitutions, including react substitutions.

* Remove wrapper support from i18n in favour of using translations in substitutions.

* Fix i18n-helper substitution logic: ensure correct index of substitution is applied

* Throw error if there are not enough substitutions for a translation phrase

* Adds unit tests for now i18n-helper substitution functionality

* Fix grammar, react element line spacing and test layout+readability in i18n-helper.test.js
2020-03-11 12:30:05 -02:30
Erik Marks
2df8b85c5f
LoginPerSite: Support multiple accounts without automatic switching (#8079)
* transaction editing: use txParams 'from' account

* signature-request: use txParams 'from' account

* signature-request-original: use txParams 'from' account

* encryption/decryption: use txParams 'from' account

* update tests

* set 'send' state 'from' address in confirm containers
2020-03-06 13:34:56 -08: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
f1750d2807
Remove unnecessary variables for state and props (#8144)
The use of these variables confuses the ESLint plugin I use for VSCode.
It's also not useful.
2020-03-01 06:14:07 -04:00
Mark Stacey
ae1ed7079f
Fix token cell props (#8142)
The `hideSidebar` proptype of `TokenCell` was set as an optional bool,
when it should have been a required function.
2020-03-01 06:13:59 -04:00
Mark Stacey
887bc078d7
Fix bug preventing dropdown close upon outside click (#8145)
The base component we use for dropdowns handles ensuring the dropdown
is closed when the user clicks outside the dropdown. This functionality
was accidentally broken in #7781 when converting it to an ES6 class.
2020-03-01 06:13:49 -04:00
Mark Stacey
2b1a22b8b1
Consolidate Home UI (#8141)
The "Transaction View" component has been merged with the Home
component. The division between these two components seemed wrong
because the "Transaction View" contained the menu bar (distinctly a
"home" thing, not a "transaction" thing), and we will be adding more
non-transaction-related components shortly.

This also let us use a single `Media` component instead of two.
2020-02-28 17:46:01 -04:00
Mark Stacey
fa3497e39b
Move home notifications upwards in DOM (#8138)
The notifications displayed on the home screen were being passed
through the `TransactionView` and `TransactionList` components before
being rendered. This was unnecessary because the notifications are
absolutely positioned.

They are now rendered directly in the home component where they're
defined. A helper function has been written to improve readability.
2020-02-28 16:27:58 -04:00
Mark Stacey
f4c279e6ff
Extract style for Home component into separate module (#8139)
The styles used for the Home component were in the huge
"newui-sections" SCSS file. Instead they've been moved into an SCSS
module alongside the component, to follow our conventions.

The `main-container` class was left as-is because it is shared between
here and the settings page.
2020-02-28 16:27:22 -04:00
Mark Stacey
b534ecb2e1
Add stories for Tabs component (#8134)
This effectively covers the `Tab` component as well, which doesn't
really make sense to showcase on its own.

One minor change was made to the actual `Tabs` component; `children`
was marked as a required prop. It doesn't render anything sensible if
they are omitted, and it always has at least one child in our codebase.
2020-02-28 09:49:31 -04:00
Mark Stacey
7e4916e59e
Simplify tab component (#8132)
The tab component now sets the `tab` and `tab--active` classes
internally regardless what class is passed in. The convention in React
is to allow adding _additional_ classes via the `className` prop, not
to allow removing internal classes entirely.

the `activeClassName` prop was removed entirely. A few other props that
are always passed in have been marked as required.
2020-02-27 18:00:42 -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
Dan J Miller
4996a00cde
Change permissions connect screen to use browser routing (#8072) 2020-02-27 11:20:05 -04:00
Mark Stacey
46157cb476
Remove redundant PropTypes (#8126)
Specifying a PropType of either type `node` or type
`arrayOf(PropTypes.node)` is redundant, because an array of nodes is
itself a node.
2020-02-27 10:31:59 -04:00
ryanml
64aef5033d
Adding setting for disabling Eth Phishing Detection (#8125) 2020-02-27 02:29:41 -04:00
Mark Stacey
53d25d01a6
Add stories for Identicon component (#8113)
One main configurable story has been added, plus a few distinct other
examples. All props are covered except `className`, which seems safe to
ignore.

Default props have been added to `Identicon` to make more explicit what
defaults were expected; there is no functional change.
2020-02-26 22:08:58 -04:00
Erik Marks
5d1f3c1436
Delete shapeshift functionality; retain state and display (#8118)
* delete shapeshift functionality; retain state and display
2020-02-26 09:34:46 -08:00
Mark Stacey
7a9f53c99d
Use Component Story Format for stories (#8108)
The recommended way of writing stories changed in Storybook v5.2 to
the Component Story Format (CSF). Instead of using `storiesOf` and
running everything upon module import, the new story format is a
declarative description of each component that uses ES6 import
semantics.
2020-02-26 10:13:56 -04:00
Mark Stacey
cb995d66da
Re-render jazzicon component when diameter changes (#8114)
Previously when the `diameter` prop of the `jazzicon` component was
changed, the new diameter would be ignored. The jazzicon is now
redrawn upon each change, as you would expect.

I don't think it's possible for this bug to manifest itself in the
extension. This was discovered through tinkering with the Storybook
for this component.
2020-02-26 09:42:33 -04:00
Mark Stacey
0a0040842c
Fix display of identicon on Connect page (#8107)
The identicon was showing as a white circle on the connect page. This
was a CSS error introduced when `jazzicon` was updated in #7898.

The white circle shown was the white border around the identicon. This
circle is an adjacent `div` in the DOM, and was rendered _underneath_
the identicon itself because it was placed first in the DOM.
Unfortunately the new version of `jazzicon` is no longer explicitly
positioned (it used to have `position: relative` set internally), so
now it's lower in the stack order regardless of DOM position.

Rather than placing the border adjacent and relying upon both elements
being positioned, the border has been changed into a wrapping `div`
instead. Now the stack order is more explicit.
2020-02-26 09:34:39 -04:00
Mark Stacey
35941f34dd
Move default white background from body to root element (#8110)
In our base stylesheets we set the `body` background color to white.
This unfortunately also affected the preview area of Storybook. The
Storybook preview only renders isolated components, but it does
include all styles.

To avoid this problem, the white background color has been moved to
the `#app-content` div instead. All of our UI is inside this div.
2020-02-26 09:33:58 -04:00
Erik Marks
83da3db37b
Remove selected address history (#8104)
* remove selected address history, account switching; fix perm selectors, bugs

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2020-02-25 14:39:38 -08:00
Whymarrh Whitby
5eb95625ca
Remove react-tooltip-component (#8099) 2020-02-25 09:11:56 -03:30
Whymarrh Whitby
169ab8adc9
Remove recompose (#8097) 2020-02-24 19:28:26 -03:30
ricky
54f0830324
Use destructuring assignment (#8093)
* Use destructuring assignment

* remove `state` const

* Use defaultProps
2020-02-24 14:38:41 -05:00
Whymarrh Whitby
81d8237654
Use eslint-plugin-react@7.18.3 (#8085) 2020-02-24 15:24:35 -03:30
Mark Stacey
ef98e876a7
Remove unused container prop (#8076)
The `activeTab` prop being passed in from the container was never used.
2020-02-20 11:52:10 -04:00
Konstantin
6f47fece56
Implementation encrypt/decrypt feature (#7831)
Implement `eth_decrypt` and `eth_getEncryptionPublicKey`. This allows decryption backed by the user's private key. The message decryption uses a confirmation flow similar to the messaging signing flow, where the message to be decrypted is also able to be decrypted inline for the user to read directly before confirming.
2020-02-19 14:24:16 -04:00
Whymarrh Whitby
8f26f5a021
Remove redux-test-utils dependency (#8070)
* Remove usages of redux-test-utils
* Remove redux-test-utils dependency
2020-02-18 14:54:03 -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
a71f56e5da
Remove unused sinon sandboxes (#8063)
These sandboxes were created, then not utilized at all.
2020-02-17 21:31:09 -04: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
Jenny Pollack
befd580ab2
add parens to arrow function parameters (#8060) 2020-02-17 19:12:48 -04:00
Jenny Pollack
c1453c7528
Merge pull request #8056 from whymarrh/arrow-parens
Enable arrow-parens ESLint rule
2020-02-17 15:26:43 -07:00
Whymarrh Whitby
a78cf0ef3a Enable arrow-parens ESLint rule 2020-02-15 17:04:21 -03:30
Dan Finlay
eb57763056
Add warning to watchAsset API when editing a known token (#8049)
* Add warning when editing a known token with watchAsset API

* Add warning when watchAsset attempts to reuse token symbol

* Linted
2020-02-14 12:32:56 -08:00
Vodopyanov Egor
b63b848ed4
add title to transaction action component (#8050) 2020-02-14 12:31:44 -04:00
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
7f3cf07f94
Update sinon and proxyquire (#8027)
* Use sinon@8.1.1
* Use proxyquire@2.1.3
* Move sinon mocking out of global scope into hooks
2020-02-11 17:03:32 -03:30
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
ryanml
3bbbe13311
Use contact name instead of address during send flow (#7971) 2020-02-11 12:10:15 -03:30
ricky
8c81f9d530
Ensure we pass history to UnlockPage component (#8017)
* Add .isRequired to history propType definition

* Ensure we pass history down to the component
2020-02-10 12:42:59 -05:00
William Morriss
1eb828f7f0
Add support for 24 word seed phrases (#7987) 2020-02-06 18:55:45 -03:30
ricky
fbfaa6eb10
Use readOnly (#7995) 2020-02-06 14:34:23 -05:00
Whymarrh Whitby
dea8f0f24d
Use combineReducers for rootReducer (#7964) 2020-02-06 13:08:14 -03:30
Whymarrh Whitby
25bcdfcac8
Fix SendAmountRow tests (#7968)
* Rewrite SendAmountRow tests to avoid flakiness
* Use sinon@5.0.1
* Dedupe supports-color versions
2020-02-05 09:45:46 -03:30
Thomas Huang
6969e3984b
Fixes #5706 - Adds Dai/Sai to currency display (#7986)
With the change from infura to cryptocompare https://github.com/MetaMask/gaba/pull/30/files#diff-50c3c47cc5fa12e5213a6cc900476f41L41-R48 we have numerous conversion rates to go through and add if we like to.
2020-02-04 14:49:53 -08:00
Whymarrh Whitby
b80afc6493
Use ethereum-ens-network-map for network support (#7960) 2020-01-31 09:56:50 -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
Whymarrh Whitby
d75e587533
Replace fast-deep-equal with isEqual from lodash (#7935) 2020-01-29 16:31:53 -03:30
ryanml
07ce849c48
Sorting seed phrase confirmation buttons alphabetically (#7933) 2020-01-29 16:12:46 -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
398a45bfdd
Replace clone dependency with cloneDeep from lodash (#7926)
This was done to reduce the number of direct dependencies we have. It
should be functionally equivalent. The bundle size should not change,
as we use `clone` as a transitive dependency in a number of places.
2020-01-29 13:14:33 -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
Mark Stacey
7921196536
Update data on Approve screen after updating custom spend limit (#7918)
After updating the custom spend limit on the approve screen, the data
for the transaction was not being updated. Instead it showed the
original transaction data. The transaction data was being updated
correctly in the final transaction though.

The approve screen has been updated to ensure changes to the custom
spend limit are reflected correctly in the data shown.
2020-01-28 09:42:07 -04:00
Brandon Lucas
07f4294088 disable import button on Import Account screen for empty string/file (#7912)
* disable import button on Import Account screen for empty string/file
* use refs to access DOM for import-account
2020-01-28 09:40:03 -04: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
ryanml
60f6fd0008 Fixing broken JSON import help link (#7910) 2020-01-27 08:54:21 -04:00
Mark Stacey
560be4b4e3
Add top-level error page (#7889)
Any error caught during a React component render or lifecycle method
will now be caught by the top-level error boundary, which shows the
user this new error page. The error page will display a simple error
message, and will show the details of the error in a collapsible
section.

The caught error is also reported to Sentry.

In development the error will be re-thrown to make it easier to see on
the console, but it is not re-thrown in production.
2020-01-24 17:11:02 -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
e79d18de2a
Replace DetectRTC package with standard web APIs (#7887)
The only web API that our usage of DetectRTC relied upon was
'enumerateDevices', which is supported and stable among all of our
supported browsers.

Note that the error handling here is a little... non-standard, and the
logic around how Firefox and Brave are handled should be justified, but
I've left the logic as-is for now to keep this PR small.
2020-01-23 14:04:16 -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
d27f2ee7d6
Fix intermittent e2e test failure (#7873)
The 'can retype the seed phrase' test would fail sometimes when one of
the words in the seed phrase was a subset of another word (e.g. 'issue'
and 'tissue'). This is because the selector used to find the word
looked for the first element that contained the text, rather than an
exact match.

To simplify the selector and make it more reliable, test ids were added
to each seed phrase word. The selector now uses CSS instead of XPath,
and it only finds exact matches.

A test id was also added to the div containing the shuffled seed words
to select from, so that the chosen seed words wouldn't be selected
in place of the real target when the same word appears twice.
2020-01-21 11:31:56 -04:00
Mark Stacey
6e49d0b5b5
Remove unnecessary shouldComponentUpdate (#7875)
The `confirm-seed-phrase` component extends PureComponent, so it
doesn't need a `shouldComponentUpdate` function. The state is
effectively immutable, as all state is either a primitive type or is
updated with new instances rather than mutation.

Removing this function will silence a warning message printed to the
console during e2e tests (React doesn't want you to set this function
on `PureComponent`s).

Removing this function also exposed an unused piece of state, which has
also been removed.
2020-01-21 11:19:35 -04: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
20a7b8fa36
Force background state update after removing an account (#7840)
The e2e tests were failing intermittently after removing an account
because the account was shown as not deleted after the removal. I
suspect this was because the account _had_ been removed, but that
change to the background state hadn't yet propagated to the UI.

The background state is now synced before the loading overlay for
removing the account is removed, ensuring that the removed account
cannot be seen in the UI after removal.
2020-01-16 13:43:40 -04:00
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
Whymarrh Whitby
948a2ce831
Fix prop types for SendGasRow component tests (#7833) 2020-01-15 17:44:47 -03:30
Whymarrh Whitby
c53a40c45f
Add required props & fix propTypes for SendFooter tests (#7825) 2020-01-15 13:28:23 -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
Whymarrh Whitby
ab7500a940
Add required props for Send component tests (#7821) 2020-01-14 18:23:22 -03:30
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
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
2c3b1a0fe0
Convert ConfirmTxScreen to an ES6 class (#7790)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 13:32:54 -03:30
Whymarrh Whitby
61d1809750
Purge xtend from the UI (#7795) 2020-01-13 12:59:21 -03:30
Whymarrh Whitby
b9757f5563
Convert account import components to ES6 classes (#7791)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-13 11:42:53 -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
Whymarrh Whitby
82ef9674f2
Move util test file alongside subject (#7807) 2020-01-13 10:41:41 -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
Mark Stacey
0d61f78379
Remove unused PersistentForm (#7770)
This component used to persist form contents to LocalStorage. This was
especially useful for the popup UI, as each time the mouse left the
popup, the UI was completely torn down and state was lost.

This component was only being referenced by one form, and it wasn't
even being used there (e.g. no fields were labelled appropriately to
be persisted).

This was a useful component, and it seems this feature was lost
somewhere in the past couple of years. It was tempting to re-instate it
rather than delete it, but I decided not to because I'd likely approach
the problem differently if we wanted to reinstate it again today (maybe
by using a React Hook, or storing the state in Redux and persisting a
subset of the Redux store instead).
2020-01-10 11:55:27 -04:00
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
Mark Stacey
f20e028cde
Remove unused props, prevent redundant gas update (#7769)
These unused props weren't being caught by ESLint because this
component extended another, which I guess made it difficult for the
React plugin to determine what was unused.

The `componentWillUpdate` logic was moved into `componentDidUpdate` so
that it would be picked up by ESLint. Also it seemed like a sensible
place for it to go. Having three redundant gas updates as part of
the same lifecycle function seemed too far, so I ensured it's
only called once.
2020-01-10 10:39: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
Sirius Tsou
9ba3774b5e Fix Kovan and Rinkeby chain IDs (#7762) 2020-01-08 11:26:56 -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
1820836833
Clean up MetaMetricsProvider constructor (#7719) 2019-12-19 14:58:23 -03:30
Whymarrh Whitby
f441f83b16
Remove unused feature-toggle-utils file (#7703) 2019-12-13 13:48:05 -03:30
Whymarrh Whitby
2a8e586142
Remove unused methods from one of the many utils files (#7702) 2019-12-13 11:21:07 -03:30
Mark Stacey
2e188ce4ef
Remove unused fromDropdownOpen state in send reducer (#7700)
The unused state has been removed along with associated actions and
action creators.
2019-12-12 19:26:18 -04:00
Whymarrh Whitby
db0d59f800
Remove unused UI actions (#7675) 2019-12-12 19:48:48 -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
Mark Stacey
3ce19ee11d
Remove unused gasExpress fetch mocks (#7681)
These fetch mocks have been unnecessary since #7059
2019-12-10 09:52:34 -04:00
Whymarrh Whitby
8afbcd8e86
Add INR currency option (#7673) 2019-12-09 20:58:33 -03:30
Whymarrh Whitby
29da5cc7e8
Remove some unused MetaMaskController methods (#7666) 2019-12-09 13:11:44 -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