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

4335 Commits

Author SHA1 Message Date
Dan Miller
9787ca633b Improve scss naming 2020-08-18 15:27:47 -02:30
Whymarrh Whitby
4357cda7b8
Fix no-shadow issues (#9246)
See [`no-shadow`](https://eslint.org/docs/rules/no-shadow) for more information.

This change enables `no-shadow` and fixes the issues raised by the rule.
2020-08-18 14:06:45 -02:30
Brad Decker
d5a539e0e5
remove old tooltip component and styles (#9250)
The old tooltip component was only used in two places. Removing those usages
was simple and straight forward. So, instead of colocating the old tooltip
styles with the deprecated tooltip component, I removed all old styles and
made tooltip-v2 now simply 'tooltip' and removed the deprecated component.
2020-08-18 11:13:55 -05:00
Patryk Łucka
f7e4e209ef
move footer buttons to scrollable area (#9228)
Co-authored-by: Patryk Łucka <patryk.lucka@consensys.net>
2020-08-18 09:10:56 -05:00
Brad Decker
d5948f1cbe
colocate confirm-encryption-public-key page styles (#9251)
Follows the previously set pattern of colocating styles along side the
consuming components. This one was really straight forward and just a
reorganization of files and imports. No code changes occurred.
2020-08-18 09:10:15 -05:00
Brad Decker
2e565d02b2
Removes the dropdown menu and colocates old styles with account-menu (#9185)
The only place that these .menu styles were being used was the account-menu by way of components/app/dropdowns/menu. Because account-menu is the only place that used these styles I moved them to exist with the account-menu
2020-08-18 09:09:56 -05:00
Brad Decker
7bc2de006f
Colocate create-account styles with the create-account page (#9181)
Follows previous patterns of moving styles to exist alongside the components that use them. I would like these styles to be updated to use BEM syntax as well but I am holding off for a future PR to improve these styles.
2020-08-18 09:06:46 -05:00
Dan Miller
807acaa536 Add exchange-rate-display component 2020-08-18 11:23:54 -02:30
Whymarrh Whitby
e803807dd9
Fix no-param-reassign issues (#9235)
See [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign) for more information.

This change enables `no-param-reassign` and fixes the issues raised by the rule.
2020-08-15 09:28:11 -02:30
Thomas Huang
87e5281a82
Clear Account Details in AppState (#9238)
* Clear Account Details in AppState

We store sensitive information in the AppState under accountDetail for when the modal is active and present. This adds a new action/reducer and componentWillUnmount to clean up the persisted data left after leaving the modal.

* Remove reduntant clearAccountDetails call when clicking done button
2020-08-14 16:08:26 -07:00
Patryk Łucka
aad840777d
Permit all-caps addresses (#9227)
* permit all-caps addresses

* handle empty address
2020-08-14 19:18:46 -03:00
Whymarrh Whitby
04bfe3772c
Delete page-container.component.test.js (#9229) 2020-08-14 12:52:38 -02:30
Whymarrh Whitby
2aa4b6bbee
Tidy up getAccountLink (#9223) 2020-08-14 12:31:59 -02:30
Whymarrh Whitby
937616565d
Tidy ConnectHardwareForm#checkIfUnlocked (#9224)
This change tidies up the implementation of `ConnectHardwareForm#checkIfUnlocked`—passing
an `async` function to `forEach` doesn't ensure that the one is run before the other.
2020-08-14 11:57:42 -02:30
Whymarrh Whitby
5d42a9b773
Fix require-unicode-regexp issues (#9212)
* Fix require-unicode-regexp issues

See [`require-unicode-regexp`](https://eslint.org/docs/rules/require-unicode-regexp) for more information.

This change enables `require-unicode-regexp` and fixes the issues raised by the rule.

* Remove case-insensitive flag from regexps
2020-08-14 09:18:42 -02:30
Whymarrh Whitby
884775cf71
Fix no-negated-condition issues (#9222)
See [`no-negated-condition`](https://eslint.org/docs/rules/no-negated-condition) for more information.

This change enables `no-negated-condition` and fixes the issues raised by the rule.
2020-08-14 09:17:43 -02:30
Whymarrh Whitby
c11888f287
Fix no-empty-function issues (#9216)
See [`no-empty-function`](https://eslint.org/docs/rules/no-empty-function) for more information.

This change enables `no-empty-function` and fixes the issues raised by the rule.
2020-08-14 09:17:02 -02:30
Whymarrh Whitby
9b78d3ab07
Fix import/extensions issues (#9217)
See [`import/extensions`](https://eslint.org/docs/rules/import/extensions) for more information.

This change enables `import/extensions` and fixes the issues raised by the rule.
2020-08-14 09:16:45 -02:30
Whymarrh Whitby
b91cf74d14
Fix no-nested-ternary issues (#9214)
See [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary) for more information.

This change enables `no-nested-ternary` and fixes the issues raised by the rule.
2020-08-13 17:30:09 -02:30
Whymarrh Whitby
42e7d205b2
Fix no-dupe-else-if issues (#9208)
See [`no-dupe-else-if`](https://eslint.org/docs/rules/no-dupe-else-if) for more information.

This change enables `no-dupe-else-if` and fixes the issues raised by the rule.
2020-08-12 21:22:02 -02:30
Whymarrh Whitby
cd370be728
Fix no-invalid-this issues (#9207)
See [`no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) for more information.

This change enables `no-invalid-this` and fixes the issues raised by the rule.
2020-08-12 21:19:33 -02:30
Whymarrh Whitby
c0f05ccae6
Fix implicit-arrow-linebreak issues (#9201)
See [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak) for more information.

This change enables `implicit-arrow-linebreak` and fixes the issues raised by the rule.
2020-08-12 21:19:10 -02:30
Whymarrh Whitby
310b15ba4a
Fix no-plusplus issues (#9206)
See [`no-plusplus`](https://eslint.org/docs/rules/no-plusplus) for more information.

This change enables `no-plusplus` and fixes the issues raised by the rule.
2020-08-12 20:36:44 -02:30
Whymarrh Whitby
548b0bbbd5
Fix no-eq-null issues (#9205)
See [`no-eq-null`](https://eslint.org/docs/rules/no-eq-null) for more information.

This change enables `no-eq-null` and fixes the issues raised by the rule.
2020-08-12 20:32:44 -02:30
Whymarrh Whitby
88f54e29fb
Fix no-empty issues (#9202)
See [`no-empty`](https://eslint.org/docs/rules/no-empty) for more information.

This change enables `no-empty` and fixes the issues raised by the rule.
2020-08-12 18:20:29 -02:30
Whymarrh Whitby
ef88d79fac
Fix no-useless-concat issues (#9200)
See [`no-useless-concat`](https://eslint.org/docs/rules/no-useless-concat) for more information.

This change enables `no-useless-concat` and fixes the issues raised by the rule.
2020-08-12 17:07:44 -02:30
Whymarrh Whitby
a8863a3446
Fix consistent-return issues (#9192)
See [`consistent-return`](https://eslint.org/docs/rules/consistent-return) for more information.

This change enables `consistent-return` and fixes the issues raised by the rule.
2020-08-12 16:36:57 -02:30
Whymarrh Whitby
885125ad03
Fix no-case-declarations issues (#9191)
See [`no-case-declarations`](https://eslint.org/docs/rules/no-case-declarations) for more information.

This change enables `no-case-declarations` and fixes the issues raised by the rule.
2020-08-12 14:11:27 -02:30
Brad Decker
b2813f0b54
colocate the base modal styles with the modal component (#9151)
finalizes the colocation of styles with the consuming components.
2020-08-12 12:49:45 -03:00
Erik Marks
163f45beed
Fix account modal back button styling (#9184) 2020-08-11 09:49:07 -07:00
Brad Decker
42be0645da
colocate original request-signature component styles (#9182)
Moves the styles out of the itcss folder and colocates them with the component, as per the pattern set elsewhere.
2020-08-11 11:29:19 -05:00
Erik Marks
ef68a7963c fix account modal back styling 2020-08-11 09:17:50 -07:00
Brad Decker
01f69d7e7a
colocate account modal styles with their components (#9150)
This one gets a bit more complicated because the styles were interwoven and needed to be untangled to be moved. Essentially, though, the goal is to put the styles where they make the most sense and colocate them with their components.
2020-08-11 11:07:47 -05:00
Brad Decker
6ba9e65712
colocate tab-bar styles with the tab-bar component (#9176)
Moves styles out of the itcss components folder and places them alongside the component.
2020-08-11 08:58:10 -05:00
Dan J Miller
b8edc32f48
Fee card component (#9169)
* Fee card component

* Clean up

* Style lint fixes
2020-08-11 10:59:24 -02:30
Mark Stacey
c557e25ba6
Add version dimension to background metrics (#9167)
The background metrics were missing the `version` custom dimension. It
has now been added to all background metric events.
2020-08-10 12:10:30 -03:00
Brad Decker
2e33b57d17
colocate hide-token-confirmation modal styles (#9149) 2020-08-07 14:31:02 -05:00
Erik Marks
e5cb63eea2
Add web3 usage metrics, prepare for web3 removal (#9144)
* add web3 usage metrics

* move web3 metrics method to new middleware

* rename some methods, files, and exports
2020-08-07 12:28:23 -07:00
Brad Decker
d59fc79e0f
colocate deposit-ether-modal styles (#9148)
Moves the still alive deposit-ether-modal styles to be colocated with it's component, as per the examples already in place in the components/modal folder
2020-08-07 13:57:33 -05:00
Mark Stacey
1419c14fb6
Use pathname instead of URL for currentPath metrics parameter (#9158)
The `currentPath` parameter passed to our metrics utility had been
passed the full URL rather than just the path, contrary to what the
name would imply. We only used the path portion, so passing the full
URL did lead to complications.

Now just the `pathname` is passed in, rather than the full URL. This
simplifies the metrics logic, and it incidentally fixes two bugs.

The main bug fixed is regarding Firefox metrics. Previously we had
assumed the `currentPath` would start with `chrome-extension://`, which
of course was not true on Firefox. This lead to us incorrectly parsing
the `currentPath`, so path tracking was broken for Firefox events.
This broken parsing is now bypassed entirely, so metrics should now
work the same on Firefox as on Chrome.

The second bug was that we were incorrectly setting the tracking URL
for background events during tests. As a result, we were incorrectly
detecting ourselves as an internal site that had referred the user to
us. But this was not of major concern, since it only affected test
metrics (which get sent to the development Matomo project).

Lastly, this change let us discard the `pathname` parameter used in
the `overrides` parameter of the `metricsEvent` function. Now that
`currentPath` is equivalent to `pathname`, the `pathname` parameter is
redundant.
2020-08-07 15:32:46 -03:00
Mark Stacey
8713927e5e
Remove url parameter from metricsEvent (#9157)
* Remove `url` parameter from `metricsEvent`

The `url` parameter was used to override the `currentPath`, but it
never worked correctly. It was supposed to be used for setting the
`url` query parameter that was sent to Matomo, but `currentPath` was
always used even if it `url` was set and `currentPath` was empty.

Instead, `currentPath` is now always used. There was never a need to
provide an "override" for `currentPath` when it can be set directly.
The metrics provider does set `currentPath` automatically by default,
but this can be overwritten already by passing a second parameter to
`metricsEvent`.

There were two places this `url` parameter was being used: background
events, and path changes. Background events were submitted with no
`currentPath`, so because of the bug with the `url` parameter, the
metrics utility would crash upon each event. So those were never
actually sent. This commit will fix that crash.

The `currentPath` parameter was supplied as an empty string for the
path change events, so those never crashed. They just had the `url`
query string parameter set incorrectly (to an empty string). It should
now be correctly populated, which should mean we'll be capturing all
path changes now. Previously we were only capturing path changes to
pages that happened to include an event, because of this blank `url`
problem.

* Use `url` query parameter as fallback for generating `pv_id`

The `pv_id` parameter currently isn't generated correctly on Firefox,
as the generation assumes that the current URL starts with
`chrome-extension://`. The `url` query parameter is still unique for
each path, so it's probably good enough for generating an id for each
page.

This is just a temporary fix; it will be removed in a future PR, where
Firefox will be properly supported.
2020-08-07 14:57:27 -03:00
Erik Marks
f18473a03d
Fix .network-name vertical alignment (#9152) 2020-08-07 09:05:31 -07:00
Brad Decker
f3ba18d79f
remove unused section scss (#9146) 2020-08-07 10:58:48 -05:00
Brad Decker
85e658993b
colocate notification-modal styles (#9147)
Follows former examples of colocating styles with the modals that use them.
2020-08-07 10:25:00 -05:00
Erik Marks
365a096e5b remove .network-name height 2020-08-06 15:45:02 -07:00
Dan J Miller
a914eae51e
Adds decETHToDecWEI util method (#9141) 2020-08-06 09:22:12 -07:00
Brad Decker
ecaa6c55dd
trim unused account-list-item code and co-locate styles (#9116) 2020-08-06 08:04:55 -05:00
Brad Decker
db1b72a95c
colocate editable label styles and code (#9120) 2020-08-05 08:44:17 -05:00
Brad Decker
b92475ac7c
Colocate alert styles (#9117) 2020-08-05 08:43:21 -05:00
Brad Decker
723e478689
move currency-display styles to where they are used (#9119) 2020-08-05 08:43:07 -05:00
Brad Decker
943d637cd2
remove unused tx-list styles (#9121) 2020-07-31 09:17:43 -05:00
Brad Decker
1c46715b46
delete unused confirm styles (#9118) 2020-07-31 09:17:29 -05:00
Brad Decker
1207d43945
update email us to contact us (#9104) 2020-07-29 16:05:19 -05:00
Brad Decker
46ba1ef100
Update font family globally (#9073) 2020-07-29 15:04:02 -05:00
Mark Stacey
b7715f6e70
Only log error on first occurrence of missing substitution (#9096)
A missing substitution for a localized message will now only log an
error upon the first occurrence. Further errors are generally not
useful.
2020-07-29 13:09:52 -03:00
Brad Decker
1582855e28
Use mixins for typography instead of placeholder selectors (#9072)
Using extend would not work inside of some css, namely
inside of media queries. This made it a clear choice to
use mixins for these styles.
2020-07-29 10:35:53 -05:00
Brad Decker
4cc3fff96a
Update css folder structure (#9071) 2020-07-28 15:16:30 -05:00
Mark Stacey
8a7c8e8aeb
Use environment variable for MetaMetrics project ID (#9094)
The MetaMetrics project ID can now be set via environment variable. It
has not been set yet in practice, so for now the old project IDs will
still be used. This is in preparation for migrating to a new project.
2020-07-28 16:59:27 -03:00
Mark Stacey
1e0ef76524
Use development metametrics project during tests (#9093)
e2e tests will now reference the development MetaMetrics project
instead of the production one. The metrics endpoint should be stubbed
out during e2e tests anyway, but this seemed like a better default
regardless.
2020-07-28 16:09:20 -03:00
Brad Decker
13aafa4702
Add euclid fontface (#9018) 2020-07-27 17:15:44 -05:00
ryanml
d9f07a796d
Complete onboarding upon importing/verifying seed (#8873)
Fixes #8679
2020-07-27 18:03:26 -03:00
Brad Decker
57715a8da1
support longer text in network dropdown (#9085) 2020-07-27 15:01:21 -05:00
ryanml
b4663eb78b
Fixes MetaMask/metamask-extension#8626 - verifies password on requesting seed phrase (#9063) 2020-07-24 19:47:40 -03:00
Brad Decker
df8eb494fe
Updates Typography Variables and styles. (#9017)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-07-24 11:26:45 -05:00
Bakhtiiar Muzakparov
1747f91bf1
Add tooltip to contacts (#8974)
Fixes #8790
2020-07-24 11:17:03 -03:00
Thomas Huang
17e9d85401
Resolve on 0x (#9048) 2020-07-22 11:05:23 -07:00
Mark Stacey
a0589d3290
Remove unused with-method-data HOC (#9050)
This higher-order-component has been unused since #6551
2020-07-22 12:41:16 -03:00
Whymarrh Whitby
bf6578c6b8
Enable guard-for-in rule (#9000) 2020-07-21 18:40:45 -02:30
Brad Decker
35a6ad98b3
Add accent-color usage from design system. (#9009) 2020-07-21 11:17:02 -05:00
Brad Decker
e463a47588
do not show amounts for approvals (#9032) 2020-07-21 10:45:14 -05:00
Whymarrh Whitby
2389777244
Fix invalid CSS rules (#9039) 2020-07-20 15:26:44 -02:30
Whymarrh Whitby
2ae4720443
Fix words (#9038) 2020-07-20 14:32:49 -02:30
Mark Stacey
7cd609b86b
Fix crash upon removing contact (#9031)
The UI would crash upon deleting a contact from the contact list. This
happened for two reasons: the deletion could result in a re-render
before the `history.push` finished navigating back to the contact list
(it was a race condition), and the contact entry left behind an invalid
`identities` entry when it was removed.

The first problem was fixed by making the container components for view
and edit contact more tolerant of being passed an `address` that
doesn't correspond to a contact. If they are given an address without a
contact, `null` is passed to the component via the `address` prop. The
component will redirect back to the list when this happens instead
rendering. This is more awkward than I'd like, but it was the most
sensible way of handling this I could think of without making much more
drastic changes to how we're handling routing here.

The second problem was caused by the `setAccountLabel` call, which was
used to ensure the contact entry for any wallet accounts was kept
in-sync with the account label. This was being called even for non-
wallet accounts though, which is where this problem arose. This step is
now skipped for non-wallet accounts.

Fixes #9019
2020-07-20 11:55:47 -03:00
Mark Stacey
ea8fa580be
Hide "delete" button when editing contact of wallet account (#9030)
Wallet accounts can't be deleted from the contact list. This button
never worked, nor should it.
2020-07-17 20:30:25 -03:00
Whymarrh Whitby
983e32274c Fix array-callback-return issues
See [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return) for more information.

This change enables `array-callback-return` and fixes the issues raised by the
rule.
2020-07-17 16:03:33 -02:30
Brad Decker
549eb320e8
Narrow usages of 037DD6 to 'primary-blue' (#9008) 2020-07-17 13:11:04 -05:00
Brad Decker
9bf748eb44
Define Design System Colors (#9007)
Adds design system colors to the css/variables/colors file and deprecates
old colors in the deprecated itcss/variables folder
2020-07-17 11:13:45 -05:00
Mark Stacey
e8b33fb7c8
Restore state snapshot for Sentry errors (#9028)
The state snapshot that was attached to Sentry errors was removed
recently in #8794 because it had become too large. The snapshot has
now been restored and reduced in size.

A utility function has been written to reduce the state object to just
the requested properties. This seemed safer than filtering out state
that is known to be large or to contain identifiable information.
This is not a great solution, as now knowledge about the state shape
resides in this large constant, but it will suffice for now. I am
hopeful that we can decorate our controllers with this metadata in the
future instead, as part of the upcoming background controller refactor.

A separate `getSentryState` global function has been added to get the
reduced state, so that the old `getCleanAppState` function that we used
to use could remain unchanged. It's still useful to get that full state
copy while debugging, and in e2e tests.
2020-07-17 12:09:38 -03:00
Mark Stacey
fd2e02274a
Catch gas estimate errors (#9025)
There were two cases where bad gas estimate data was resulting in
crashes. These two places have been wrapped in a `try ... catch` to
handle the absence of gas estimate data.

The errors are still reported to Sentry so that we can track down the
root cause of this corrupted gas estimate data at some point in the
future. We plan on adding additional context to Sentry soon that should
help with this.

Fixes #8992
2020-07-16 20:29:22 -03:00
Brad Decker
c8e50c6b15
Deprecate itcss (#9005) 2020-07-16 15:14:07 -05:00
Mark Stacey
dbafa49448
Skip render when home page is closing or redirecting (#9012)
The Home page component is responsible for closing the notification
window and triggering redirects in various situations. When this
happens, the home page is briefly rendered before the redirect/close
happens. This is a waste of cycles, and is distracting for users.

We now render nothing if the page is in the process of redirecting or
reloading. None of the redirects handled in this component are for sub-
pages, so we don't need the Home page to render in any of these cases.

We were already doing this for redirects to transaction confirmations,
but now we're taking the same approach for all redirects, and for the
cases where the window is closed.
2020-07-16 15:23:07 -03:00
Mark Stacey
b97cd1dc04
Display pending notifications after connect flow (#9011)
The notification window is now kept open after the connect flow if
there are still pending confirmations. Previously, the notification
window would be closed after the connect flow no matter what, and any
pending confirmations would never be shown to the user.

This was accomplished by redirecting to the home screen after the
connect flow. The logic for deciding whether or not to close the window
is already handled by the home page. This does have the unfortunate
side-effect of briefly rendering the home page before the window
closes, but this is a minor problem that exists already in a number of
other scenarios, and it will be fixed in a subsequent PR.

Fixes #8973
2020-07-16 09:13:29 -03:00
Mark Stacey
7333d821b8
Hide loading indication after personal_sign (#9006)
The loading indication had remained after successfully signing with
`personal_sign`. This mistake was introduced accidentally in #8434.

This is noticeable if you confirm the signature in the popup UI or
fullscreen UI, as they remain open after signing. The notification UI
closes after signing without waiting for this loading indicator to be
removed.
2020-07-15 22:12:56 -03:00
Mark Stacey
acaa648779
Fix ListItem styles (#9002)
The styles for the `ListItem` component were recently broken in #8989
because of a change made by `stylelint`. It incorrectly removed the
`fr` unit because of the `length-zero-no-unit` rule. This was a bug
that has since been fixed in `stylelint`; it should have left the `fr`
unit in this case.
2020-07-15 17:13:33 -03:00
Mark Stacey
f46dda0195
Uncomment and fix all auto-fixable stylelint rules (#8989)
All stylelint rules that can be automatically fixed have been uncommented. The rules are:

* `at-rule-empty-line-before`
* `block-closing-brace-empty-line-before`
* `block-closing-brace-newline-before`
* `block-opening-brace-space-before`
* `color-hex-case`
* `color-hex-length`
* `comment-empty-line-before`
* `declaration-block-semicolon-newline-after`
* `declaration-block-semicolon-space-after`
* `declaration-block-trailing-semicolon`
* `declaration-colon-space-after`
* `declaration-empty-line-before`
* `function-comma-space-after`
* `function-comma-space-before`
* `indentation`
* `length-zero-no-unit`
* `no-eol-whitespace`
* `no-missing-end-of-source-newline`
* `number-leading-zero`
* `number-no-trailing-zeros`
* `rule-empty-line-before`
* `selector-list-comma-newline-after`
* `selector-pseudo-element-colon-notation`
2020-07-15 10:13:40 -03:00
Mark Stacey
a789c23faa
Replace inlined vendored CSS with import (#8986)
The vendored CSS required by `react-tippy` is now imported instead of
inlined. This should result in no functional changes, and it makes it
easier to lint our styles.

This was originally inlined in #3120 when `react-tippy` was first added
to the project. It has not been updated since then, so I don't think
there's any risk this has gotten out-of-sync.
2020-07-14 18:43:32 -03:00
Whymarrh Whitby
4f0a205369
Use eslint@6.8.0 (#8978)
* Use eslint@6.8.0
* yarn lint:fix
2020-07-14 12:50:41 -02:30
Mark Stacey
670ae111f0
Remove unnecessary optional chaining operator (#8892)
`state.activeTab` is always guaranteed to be set to an object before
the UI is initialized. This happens in `app/ui.js`.
2020-07-10 12:46:54 -03:00
Brad Decker
9c54b2d8d5
remove superfulous fonts (#8954) 2020-07-10 10:42:59 -05:00
Mark Stacey
d53c4f824e
Add personal_sign e2e test (#8958)
This tests the `personal_sign` method using the test dapp. This test
reflects part of the `confirm-sig-requests` integration test, which
tests the confirmation of a `personal_sign` signature request.

A `data-testid` prop was added to the 'Sign' button on the signature
request confirmation page, to make it easier to select the 'Sign'
button reliably.
2020-07-10 11:35:52 -03:00
Brad Decker
3cbcc913e9
update material-ui/core (#8950) 2020-07-09 16:05:44 -05:00
Mark Stacey
b485a9afb3
Add data-testid to the EthOverview balances (#8951)
Both the primary and secondary balance components on `EthOverview` now
have `data-testid` props, so that they can be more easily referenced in
e2e tests.

This required the addition of a `data-testid` prop to the component
`UserPreferencedCurrencyDisplay`, which is passed through to the
underlying `CurrencyDisplay` component.
2020-07-09 17:33:37 -03:00
Erik Marks
652db3fd36
Use string network and chain IDs (#8628)
* convert network id enums to string

* stringify appropriate chain/network ids in tests

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-07-08 14:05:09 -07:00
Brad Decker
cd4903f65e
remove ramda (#8932) 2020-07-08 15:17:53 -05:00
Dan J Miller
ac525572eb
Move checkExistingAddresses to helpers/utils/util and stop its use of ramda (#8868) 2020-07-07 19:18:18 -03:00
Thomas Huang
15d713f0ee
Standardize transaction activity conversion's currency to 'ETH' (#8934) 2020-07-07 15:15:42 -07:00
Erik Marks
8bc02d4b5e
rpc-cap@3.0.0 (#8924)
* rpc-cap@3.0.0

* adapt use of rpc-cap for new major version
2020-07-05 12:49:22 -07:00
Erik Marks
e20e42bb17
Rename confusing permissions-connect variable (#8925) 2020-07-05 12:38:02 -07:00
Mark Stacey
b0014a9b35
Handle suggested token resolved elsewhere (#8910)
When a suggested token was resolved in a different window, the popup
or notification UI could get stuck with an empty suggested token list,
where either action would throw an error.

This case is now handled by either redirecting or closing the window,
in the popup and notification cases respectively. This check is
performed on both component mount and update.
2020-07-03 13:16:31 -03:00
Mark Stacey
a4e7cff36e
Prevent confirming blank suggested token (#8909)
The "confirm suggested token" page allowed the confirm button to be
pressed even when there were no tokens to confirm. This can happen
sometimes when the page is in the process of redirecting.
2020-07-03 13:03:47 -03:00
Mark Stacey
4a989c339a
Fix activity log inline buttons (#8908)
The inline speedup and speedup cancellation buttons in the activity log
were broken. An exception would be thrown upon either button being
clicked, and nothing would happen from the user's perspective.

Both handlers were being passed a transaction id, which was a holdover
from before the transaction list redesign. The handlers passed for
these two actions now have the transaction id embedded, so it doesn't
need to be passed in anymore. They expect the click event to be passed
through instead.

The handlers passed also didn't handle closing the transaction details
modal when clicked. After fixing the first problem, they still didn't
work because the speedup/cancel dialog was shown behind the transaction
details modal.

Both issues are now fixed. Both buttons now close the transaction
details modal, and trigger the appropriate action.
2020-07-03 13:03:13 -03:00
Mark Stacey
564f76584b
Tolerate missing or falsey substitutions (#8907)
Previously the `getMessage` function would throw if a substitution was
falsey. Now it will accept any substitution, including `undefined`.

A substitution of `null` or `undefined` will still be reported to
Sentry and printed to the console as an error, but it will not
interrupt execution. Any `null` or `undefined` substitutions will be
rendered as empty strings.

Ideally we'd never pass in `null` or `undefined` as a substitution, but
in practice this sometimes just occurs breifly between renders, which
isn't a severe enough problem to justify crashing the UI.

The detection of React component substitutions has been updated as
well, to ensure that `null` values aren't counted as React
substitutions.
2020-07-03 13:02:35 -03:00
Mark Stacey
3832d694a4
Replace percentage opacity value (#8898)
The CSS `opacity` rule accepts percentages on newer browsers, but some
older browser versions we support (e.g. Firefox v60) doesn't support
them. A number is now used instead, which is supported by all browsers
we support.
2020-07-02 21:51:41 -03:00
Mark Stacey
f5d4ab1cc1
Include relative time polyfill locale data (#8896)
We were including the polyfill for the `Intl.RelativeTimeFormat` API,
but we weren't including any locale data. This polyfill doesn't work
without the locale data for whichever locale you're formatting.

The data for all locales we support is now included. The locale data
is loaded from disk as-needed (during app startup, and upon each change
in locale).
2020-07-02 21:34:48 -03:00
Mark Stacey
4855d1b423
Allow localized messages to not use substitutions (#8895)
The `getMessage` function in `i18n-helper` was assuming that any
substitutions passed into the transaction function were used by the
corresponding localized message. However, some messages are
intentionally ignoring substitutions passed in. This was done to
simplify the UI logic, so the same substitutions could be passed in for
many different messages, even if some don't use them.

For example, `transactionCancelSuccess` is passed two substitutions but
only uses the second one. `transactionErrored` is passed in two, but
uses neither.

`getMessage` has been updated to no longer make that assumption. It
will now only throw an error if the localized message expects a
substitution that was not given. A given substitution that is unused
results in no error.
2020-07-02 19:18:22 -03:00
Mark Stacey
d9a27fcf52
Prevent showing connected accounts without origin (#8891)
There was a case where the `activeTab.origin` was not set, yet the user
could still navigate to the "Connected accounts" modal, which assumes
that `activeTab.origin` is set. This would happen in Firefox when the
user opened the popup on a page internal to Firefox (e.g.
`about:blank`). The connected status indicator would still be shown,
but the UI would crash when it was clicked.

The connected status indicator is now hidden whenever
`activeTab.origin` is falsy. The 'Unconnected account' alert has also
been made impossible to trigger in that circumstance.
2020-07-02 18:26:30 -03:00
Brad Decker
68bcf38a65
fix language code format mismatch (#8889) 2020-07-02 15:13:23 -05:00
Mark Stacey
e4410724e9
Show origin in connect flow rather than site name (#8885)
The designs for the connect flow show the site `origin` below the site
icon rather than the site name. This was done for security reasons,
and because the site name is often set to an unwieldy long string.

This was accidentally undone in #8815 in the process of fixing a
separate bug. The origin has now been restored. More specific PropTypes
have been set on each use of the `domainMetadata` prop as well.
2020-07-02 14:08:43 -03:00
Dan J Miller
14fa80c105
Set min-height: 0 on page-container__bottom to fix overflow behaviour of add token list (#8874) 2020-07-01 05:52:36 -02:30
Whymarrh Whitby
80132f5580
Add envar for ETH Gas Station API key (#8870) 2020-06-29 14:56:21 -02:30
Esteban Miño
73257b1cd1
feature/sync imported accounts with mobile (#8631)
* sync imported accounts

* Update app/scripts/metamask-controller.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* exportAccounts action

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-25 22:04:17 -03:00
Mark Stacey
2dbb151e0b
Fix account order on unconnected account alert (#8863)
The account list on the unconnected account alert was in the wrong
order; they were in the order provided by the permissions controller
rather than by last active.

The accounts are now sorted correctly; first by last active, second by
the keyring controller order.

The `getPermittedIdentitiesForCurrentTab` selector was removed because
it is no longer used.
2020-06-25 21:05:42 -03:00
Brad Decker
83fbf6608b
Restore list item title attributes (#8858) 2020-06-24 19:41:30 -03:00
Mark Stacey
5121fded67
Fix mobile sync redirect (#8860)
The mobile sync redirect was failing due to a typo in a prop. It would
fail to redirect correctly in the event of a timeout, or after pressing
'Cancel'.
2020-06-24 19:34:39 -03:00
Thomas Huang
85c81a5cfe
Align copy tooltip text and icon (#8861)
Add style prop to ReactTippy to override the inline display to flex display and align items to center
2020-06-24 15:34:18 -07:00
Mark Stacey
1d2644423e
Replace removed 'copy-to-clipboard' icon (#8853)
The 'copy-to-clipboard' icon was removed in #8190, and replaced with a
new 'Copy' icon component. It was still being used in two places
though, on the confirmation page for decryption and on the reveal seed
phrase screen..

The new Copy icon is now used in these two places instead. It has been
given a size of '17' to match the old icon size.
2020-06-24 12:10:29 -03:00
Mark Stacey
310d35c044
Stop upper-casing exported private key (#8850)
We were showing exported private keys in all upper case. This is
atypical, and many other wallets (e.g. MyCrypto) expect private keys
for imported accounts to be lower-cased. Our own account import is
tolerant of either case.
2020-06-24 10:34:10 -03:00
Brad Decker
41c8e486af
replace icons with Checkbox component (#8830)
in both permission flows the checkboxes were using the fa-check icon, and in the case
of the connected accounts popover the color of the icon was wrong. It occurred to me
while simply fixing that color would have been easier, we will be adding permissions
at some point in the future that a user will be able to 'uncheck'. This PR replaces
the usages of those icons with the Checkbox component that is equipped to handle the
interactivity of checking/unchecking.
2020-06-23 09:26:33 -05:00
Thomas Huang
4354e9eb93
Call getMethodDataAsync when knownMethodData[fourBytePrefix] object is empty (#8836)
Fixes #8835

In cases where the registry failed to load, and the sig is set to `{}` on this line: e85b162651/ui/app/helpers/utils/transactions.util.js (L78) this proceeds to set the method prefix to `{}` in knownMethodData.

Additionally check if the method prefix object is empty to proceed call getMethodDataAsync again.

I could only reproduce by intentionally failing the method registry lookup and found this solution. I could not find an instance where the registry consistently failed to lookup even on slow/throttled/high latency networks.
2020-06-22 21:30:45 -07:00
Erik Marks
b090625dc1
Update connected status popover content (#8834)
* update connected status popover content

* update highlight styling
2020-06-21 14:00:06 -07:00
Mark Stacey
c8be5d0779
Fix first time onboarding popup position (#8829)
The connected status indicator had been moved left since this popup was
first written. The position of the highlighted portion of the
background has been updated reflect this.
2020-06-17 15:12:41 -03:00
Brad Decker
c07bf62a73
fix overflowing contract names and origins (#8823)
* fix overflowing contract names and origins

Moves heading and subtitle into divs with h3/h2 children so that the
div can be display flex and still have ellipses overflow. Only the
heading was display flex but I wanted the two to have similar structure.
this allows subheading to be display flex in the future.

Also uses stripHttpSchemes to remove that from origin in the subheading

* rtl ellipses on domain

* Update ui/app/components/app/transaction-list-item/index.scss

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-17 11:38:15 -05:00
Mark Stacey
dafc5046ff
Hide 'Expand view' button in fullscreen (#8826)
The 'Expand view' button in the 'Account Options' menu was still being
shown on the fullscreen UI. This button is not useful in fullscreen, as
all it does is open the fullscreen UI. It is now hidden on the
fullscreen UI.
2020-06-17 00:40:56 -03:00
Erik Marks
b0187d3247
Fix permissions domain metadata retrieval (#8821)
* delete targetDomainMetadata selector

* fix permissions connect target domain metadata handling
2020-06-16 13:48:35 -07:00
Erik Marks
28cf728067 delete targetDomainMetadata selector 2020-06-16 11:34:08 -07:00
Brad Decker
4f3e9d70fa
remove top/bottom margin on info icon (#8822) 2020-06-16 13:05:03 -05:00
Brad Decker
61d9fcde35
add send token button on fullscreen asset list (#8812) 2020-06-16 13:04:51 -05:00
Erik Marks
d79bf8db2e fix getTargetDomainMetadata selector 2020-06-16 10:15:53 -07:00
Brad Decker
53e88b06b6
select current address in permissions connect (#8811)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-16 11:16:57 -05:00
Erik Marks
0813cc5c88
Fix encrypt/decrypt beforeunload bugs (#8816) 2020-06-16 07:40:00 -07:00
Mark Stacey
ec10323495
Fix site icon fallback letter (#8815)
The letter chosen for the fallback site icon was being set
inconsistently throughout the extension. The connect flow was using the
first letter of the `origin` for the letter (which was always `H`,
because `HTTP`), but the connect sites list and the account menu were
using the `name` from the domain metadata.

The `name` is now used for the fallback icon everywhere. A selector
that supplied a default domain metadata object has also been augmented
to use the `hostname` rather than the `origin` as a fallback name, to
match the behavior of the inpage provider.
2020-06-16 09:57:21 -03:00
Brad Decker
a6ee23cf9a
add hover style to list-item (#8813) 2020-06-15 17:36:32 -05:00
Mark Stacey
ad5e16cfa7
Fix site icon size (#8814)
A new `SiteIcon` component has been created for showing icons
representing web3 sites. The icon has a border and background, and it
has a fallback in case no icon is given. This new component accepts a
`size` prop that controls the size of the icon.

The old `IconWithFallback` component had a hard-coded size in the
SCSS styles for the icon, which was being overridden in a few places.
It was difficult to customize, and overly complicated.

The old `IconWithFallback` component is still used, but it's now
simpler. It only handles rendering the underlying `img` for the icon,
or the fallback letter if no image is given.

A separate `IconBorder` component has been created for the border and
white background used. It's solely used by `SiteIcon` for now, but I
intend to use it elsewhere as well, where this same pattern of a white
background is embedded.
2020-06-15 19:24:23 -03:00
Erik Marks
4dfe4e7463
Consolidate connected account alerts (#8802)
* update connected accounts appearance

* consolidate account alerts

* UnconnectedAccountAlert: use ConnectedAccountsList

* move switch account action out of menu in all views

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-15 12:08:53 -07:00
Brad Decker
955625278b
update button styling on home/asset page (#8800) 2020-06-15 12:02:38 -05:00
Mark Stacey
6ca18c3573
Fix handling of permissions of removed accounts (#8803)
Imported accounts can be removed, but the permissions controller is not
informed when this happens. Permissions are now removed as part of the
account removal process.

Additionally, the `getPermittedIdentitiesForCurrentTab` selector now
filters out any non-existent accounts, in case a render occurs in the
middle of an account removal.

This was resulting in a render crash upon opening the popup on a site
that was connected to the removed account.
2020-06-15 10:27:27 -03:00
Mark Stacey
bb087e3749
Hide token transfers on ETH asset page (#8799)
Token transfers will now be hidden on the ETH asset page. Arguably
token transfers are still relevant to show on the ETH asset page
because the gas for token transfers is paid in ETH, but they weren't
being displayed in a way that highlighted this (only the token amount
was shown inline - not the gas price).

We will likely restore token transfers to the ETH asset page at a later
date, after designs have been updated to highlight their relevance to
this page.
2020-06-12 23:06:33 -03:00
Mark Stacey
31bb86c596
Fix account name editing (#8801)
Editing the name of an account was accidentally made impossible when
FontAwesome was updated in #8256, because the icon we used to use for
the edit button (`fa fa-pencil`) was no longer free. The icon has been
switched to `fas fa-pencil-alt`, which is free.
2020-06-12 23:06:19 -03:00
Mark Stacey
f17aa87a65
Fix connect flow account list height (#8798)
The list of accounts shown on the first page of the connect flow takes
up the entire height of the window, even if there aren't enough
accounts to fill the space. This looks strange because of the border
around the account list, especially in the case where there are three
accounts in the list.

The list now cedes space to the footer if it can't fill the space
itself. The extra space is taken by whitespace between the footer and
the list.
2020-06-12 18:22:45 -03:00
Mark Stacey
53769a7b3a
Update color of menu item icons (#8797)
Menu item icons are now grey instead of black, as requested in design
QA feedback.
2020-06-12 17:09:47 -03:00
Mark Stacey
cf08131b49
Show fiat balance on token page (#8791)
The token page overview now shows the balance in fiat.
2020-06-12 15:47:39 -03:00
Mark Stacey
a100c55e64
Hide token fiat amounts on testnets (#8792)
The token amount is no longer shown in fiat on testnets, unless the
user has enabled the "Show fiat on testnets" setting.
2020-06-12 15:47:23 -03:00
Brad Decker
2f50e9fd72
Restore timing function (#8774)
* restore and enhance the time est feature

background: we had a feature for showing a time estimate on pending txs
that was accidently removed during the redesign implementation. This PR
restores that feature and also enhances it:
1. Displays the time estimate on all views instead of just fullscreen
2. Uses Intl.RelativeTimeFormat to format the time
3. Adds a way to toggle the feature flag.
4. Uses a hook to calculate the time remaining instead of a component

* Update app/_locales/en/messages.json

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* do not display on test nets

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-12 13:46:01 -05:00
Erik Marks
5aabe2ac75
Warn users to only add custom networks that they trust (#8789)
* add warning when adding custom network

* give the settings subheader breathing space
2020-06-12 11:21:29 -07:00
Mark Stacey
3c98be4214
Show fiat amounts inline on token transfers (#8786)
Fiat amounts are now shown inline on token transfers in the transaction
list, where possible (i.e. where the conversion rates are known).

The logic for this hook is pretty tangled because it's used for so many
fundamentally different types of items (eth transactions, token
transactions, signature requests). In the future we should split these
into different components.

The documentation for the `useTokenFiatAmount` hook was updated to make
`tokenAmount` optional, but in practice it already worked as expected
without the amount being passed in.
2020-06-12 14:37:06 -03:00
Mark Stacey
016acd3e94
Refactor asset page component (#8788)
The asset page component has been split into three parts: the main
asset page wrapper, and a component for the content (either token or
native currency). This makes it easier to add functionality that is
specific to either token asset pages or native currency asset pages.
2020-06-12 14:04:40 -03:00
Erik Marks
1323233cfa
Make permission approval redirect flow consistent (#8755)
* make redirect flow consistent

* remove cancel redirect

* extract redirect component into own file
2020-06-12 09:38:20 -07:00
Brad Decker
73ba992125
use UI button for add token functionality (#8781) 2020-06-12 11:22:00 -05:00
Erik Marks
d1e645f671 fixup! fix redirect alignment and css class names 2020-06-12 09:09:42 -07:00
Erik Marks
0cec119fc8 fix redirect alignment and css class names 2020-06-12 09:09:24 -07:00
Erik Marks
d8e7fb4c42 address review feedback 2020-06-11 14:11:50 -07:00
Erik Marks
14a5e77edd fix classes 2020-06-11 13:56:29 -07:00
Mark Stacey
4ac4790cfa
Rename 'History' tab to 'Activity' (#8785)
'Activity' is a better name for this tab because it contains more than
just transactions. Signature requests are also included, and more non-
transaction activity may be included in the future.
2020-06-11 17:14:07 -03:00
Erik Marks
8bf1410f06 fix calling redirect immediately on cancel 2020-06-11 12:55:35 -07:00
Mark Stacey
058c63cf80
Use localized tab names on Home screen (#8784)
The tab names on the Home screen are now localized messages, rather
than being hard-coded as English.
2020-06-11 15:19:13 -03:00
ricky
71e7966b6a
Update Seed Phrase Functionality on Account Import (#8730)
Update seed phrase functionality to be able to conceal seed phrase (as a password field) so it remains hidden on screen.
2020-06-11 10:24:13 -04:00
Erik Marks
a5f4115969 fixup! only run beforeunload in notification UI 2020-06-10 22:14:17 -07:00
Erik Marks
222ccd9d44 only run beforeunload in notification UI 2020-06-10 22:13:55 -07:00
Erik Marks
c090bc7f40 remove home page flicker on notification close 2020-06-10 22:09:04 -07:00
Erik Marks
51956b2a14 handle multiple pending permissions requests 2020-06-10 21:50:49 -07:00
Erik Marks
854e06b3ae fixup! only close notification in redirectFlow 2020-06-10 17:49:26 -07:00
Erik Marks
12d2315f18 only close notification in redirectFlow 2020-06-10 17:35:16 -07:00
Erik Marks
3eb33ef492 remove cancel redirect 2020-06-10 17:27:47 -07:00
Erik Marks
e86fc77d16 fixup! delete buttonsDisabled boolean 2020-06-10 16:44:10 -07:00
Erik Marks
0de56203fc delete buttonsDisabled boolean 2020-06-10 16:44:10 -07:00
Erik Marks
567b5634ca cleanup; update metadata as needed 2020-06-10 16:44:10 -07:00
Erik Marks
a94dc15349 removed unused styles 2020-06-10 16:44:09 -07:00
Erik Marks
ea398abc5d make redirect flow consistent 2020-06-10 16:44:09 -07:00
Brad Decker
a4e5fc934d
restore status tooltip (#8745)
initially set out to add the failed tooltip back to the transaction list, but
in the process rediscovered the transaction-status component which illuminated
a fair number of statuses that were not properly handled by the refactor of the
list. These statuses were discussed with UX and engineering team members to come
up with a definitive list of statuses that should be reflected in the UI

Changes:
1. normalized the color of status labels to use Red-500 and Orange-500 where applicable
2. added a new color of icon for pending transactions -- grey
3. added support for dropped and rejected labels
4. failed, dropped, rejected and cancelled all have red icons now.
5. cancelled transactions will reflect a change in the user's balance
6. tooltip displayed for failed transactions
7. Icon logic isolated to a new component.
2020-06-10 15:38:34 -05:00
Mark Stacey
0b86283c10
Create useTokenFiatAmount hook (#8778)
This hook is responsible for converting a token balance to fiat. It has
been extracted from the `TokenCell` component, and will be used
elsewhere in a future PR.
2020-06-10 16:04:29 -03:00
Thomas Huang
e124a9b467
Remove default sendToken value in send.component.js (#8764)
Fixes #8763
2020-06-10 11:34:16 -07:00
Brad Decker
13d6803698
Adds the rule of hooks eslint rule (#8779) 2020-06-10 13:31:14 -05:00
Mark Stacey
e4a77ea631
Extract token to fiat conversion (#8777)
The conversion of token amounts to fiat amounts was extracted from the
`TokenCell` component, and moved to a utility function. This will be
used elsewhere in an upcoming PR.
2020-06-10 15:04:56 -03:00
Whymarrh Whitby
87c2c81da7
Remove some unused state keys (#8776)
* Remove unused networkEndpointType state key

* Remove unused coinOptions state key
2020-06-10 14:51:12 -02:30
Mark Stacey
cfadc7592e
Avoid mutating module export (#8775)
The `eth-contracts-metadata` export was mutated in `token-list.js` to
add the token address to the contract metadata, and this was taken
advantage of in the token search component.

Instead, the address is now added to a copy of the token metadata in
the one place it's used. The module export is no longer mutated, and
the unused `defaultTokens` variable in `token-list.js` has been
removed.
2020-06-10 13:27:35 -03:00
Erik Marks
a84eedb7da
Permissions: Do not display HTTP/HTTPS URL schemes for unique hosts (#8768)
* only show URL.host in connected-accounts component

* strip scheme from URL for unique hosts

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-09 13:56:24 -07:00
Mark Stacey
4706401f4f
Refactor confirm approve page (#8757)
The `confirm-approve` page has been converted from a set of container/
component components to a functional component. The `withTokenTracker`
higher-order component has been deleted, as it was replaced by the
`useTokenTracker` hook.
2020-06-09 17:10:07 -03:00
Erik Marks
53c55d8522
Order accounts on connect page (#8762) 2020-06-08 13:23:48 -07:00
Brad Decker
e82a8a5f52
Fix prop type mismatch (#8754) 2020-06-05 15:06:15 -07:00
Brad Decker
1eed8dc167
use grid template to position list item (#8753)
Using flex was getting out of hand, I noticed on develop that when
a pending transaction is coming in the speed up and cancel buttons
cause the icon to center according ot their height as well. A grid
is really what is needed. This seemingly greatly simplifies the CSS
AND html (removes unnecessary nesting of divs)
2020-06-05 16:33:51 -05:00
Mark Stacey
f5ec16c65a
Fix account menu entry for imported accounts (#8747)
The entry for imported accounts in the account menu looked wrong with
the new connected site icon - there was no padding between the site
icon and the 'imported' label. The entry was pretty crowded with these
three symbols as well (the third being the 'x' used to remove the
account).

The site icon has been made the right-most icon, so that it lines up
with the site icons shown for other accounts, and spacing has been
added between the site icon and the 'imported' label.

The 'x' used to remove accounts has been removed. Accounts can still be
removed from the 'Account Options' menu on the Home screen. This seemed
like the wrong place for this button to exist, as it's the only action
that can be taken from that menu aside from navigation.
2020-06-05 17:24:51 -03:00
Erik Marks
bb78512bd6
Fix permissions connect close and redirect behavior (#8751)
* fix permissions connect close/redirect behavior

* improve permissions connect fullscreen close behavior

* fix multi ui perm conf redirect; consolidate perm selectors
2020-06-05 13:24:38 -07:00
Mark Stacey
9a1f27fe04
Refactor TokenBalance component (#8752)
The `TokenBalance` component now uses the new `useTokenTracker` hook
instead of the `withTokenTracker` higher-order component. The component
was converted from a split container/component to a functional
component so that the hook could be used.

The prop `withSymbol` was removed from a few call sites, as it was no
longer used. An empty string was substituted for any falsy `string` or
`symbol` because that's what the `withTokenTracker` higher-order
component did.
2020-06-05 17:19:27 -03:00
Mark Stacey
799536c35f
Fix 'Remove account' in Account Options menu (#8748)
The 'Remove account' button in the Account Options menu was broken.
Clicking it would crash the UI. It now correctly opens the 'Remove
Account' modal.
2020-06-05 16:01:06 -03:00
Brad Decker
7fcf625549
asset outdated warning inline on full screen (#8734)
The asset list item and transaction list item do not make great use of
screen realestate when in fullscreen mode on larger displays/windows.
This PR adds in a new prop for list-item for displaying content in the
middle of the list-item when on these types of screens. To facilitate
this, some updates were made to styling to allow for the list item to
better control how items are laid out in various breakpoints.

This works makes it possible to display the outdated balance warning
inline in the middle section of the list item, and convert to a tooltip
when on small displays.
2020-06-05 13:36:40 -05:00
Mark Stacey
8e1f40aedb
Handle connected accounts with no last active time (#8746)
The "Connected accounts" modal was throwing an exception when
attempting to render an account that has no `lastActive` time. The
component and related selector has been updated to no longer expect
the `lastActive` time to be set.

Prior to #8653 there was a guarantee that all connected accounts had a
`lastActive` time set, as the time would be set on any account returned
from the `eth_requestAccounts` call. But after #8653 only the primary
account was returned, so only the primary account had a `lastActive`
time set.

Fixes #8733
2020-06-05 13:07:23 -03:00
Mark Stacey
e85b162651
Add MESSAGE_TYPE enum (#8743)
Each "message" requiring a user confirmation has a unique `type`
property. These `type` properties have all been added as enums, and the
enum is now used wherever the literal string was used previously.
2020-06-04 16:22:45 -03:00
Brad Decker
ab06595a5d
refactor token list (#8726)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-04 13:13:11 -05:00
Mark Stacey
b96eb55c76
Add box shadow to Home screen tabs (#8739)
This matches the box shadow on the asset page. Some CSS specificity
hijinks were required to override the base `Tabs` CSS rules, and a new
`tabsClassName` prop was added to the `Tabs` component.
2020-06-04 13:42:45 -03:00
Mark Stacey
cac3bf5c56
Increase padding of empty transaction list (#8738)
The top padding of the empty transaction list now mirrors the space
below the buttons in the overview.
2020-06-04 12:52:21 -03:00
Mark Stacey
1553f70a65
Make asset page breadcrumb clickable (#8737)
The entire asset page breadcrumb is now clickable. Clicking it will
bring the user back to the home page.
2020-06-04 12:51:44 -03:00
Whymarrh Whitby
731efcb36d
Move terms of use strings into localized messages (#8736) 2020-06-04 12:28:21 -02:30
Brad Decker
591d84d2bb
refactor asset-list-item to use list-item component (#8725)
* refactor asset items to use list-item

Refactors the asset-list-item and token-cell to rely on the list-item
component for UI. Little changes were needed to the list-item code
to make this work! The result should be lots of eliminated code

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-06-03 12:50:12 -05:00
Whymarrh Whitby
b9028397cb
Fix parsing of seed phrases on import and restore (#8721) 2020-06-03 14:37:07 -02:30
Brad Decker
c6b77c9734
fix grid repositioning on label change (#8713) 2020-06-03 09:47:12 -05:00
Mark Stacey
171704d980
Fix gas price intermittent test failure (#8728)
The "the transaction has the expected gas price" test was assuming the
fifth element with the `transaction-breakdown__value` class was the
element with the gas price. In practice that was sometimes not the
case, because some transaction detail fields would not be present, or
would appear after the first render.

The field is now looked up with a test id, ensuring it always finds the
correct field.
2020-06-03 10:54:55 -03:00
Mark Stacey
56b157f692
Fix hide token e2e test (#8724)
The e2e test for the "Hide token" functionality was incorrectly
clicking "Cancel" on the "Hide token" modal, thus not actually testing
that that token was hidden at all.

The "Confirm" button is now selected using a test id, to ensure the
wrong button isn't selected.
2020-06-02 18:47:55 -03:00
Mark Stacey
e1c3778446
Fix disabled prop type in AddToken component (#8723)
The `disabled` prop being passed to the `PageContainer` component in
the render function for the `AddToken` component was a string in some
cases. It should always be a boolean. It has been cast to a boolean in
the one case where it was a string.
2020-06-02 18:47:43 -03:00
Erik Marks
616a446832
Use URL origin instead of hostname for permission domains (#8717)
* use URL.origin instead of hostname for tabs and permissions
2020-06-01 16:24:27 -07:00
Erik Marks
8afb295e1d
Fix connect long URL styling (#8719)
* fix connect long URL styling
2020-06-01 15:28:05 -07:00
Brad Decker
c8de0b70fa
Add nonce to transaction details (#8716) 2020-06-01 17:19:49 -05:00
Thomas Huang
fb906e2150
Consistent rounded corners on tx details modal/popup (#8714) 2020-06-01 13:04:39 -07:00
Mark Stacey
df85ab6e10
Implement asset page (#8696)
A new page has been created for viewing assets. This replaces the old
`selectedToken` state, which previously would augment the home page
to show token-specific information.

The new asset page shows the standard token overview as seen previously
on the home page, plus a history filtered to show just transactions
relevant to that token.

The actions that were available in the old token list menu have been
moved to a "Token Options" menu that mirrors the "Account Options"
menu.

The `selectedTokenAddress` state has been removed, as it is no longer
being used for anything.

`getMetaMetricState` has been renamed to `getBackgroundMetaMetricState`
because its sole purpose is extracting data from the background state
to send metrics from the background. It's not really a selector, but
it was convenient for it to use the same selectors the UI uses to
extract background data, so I left it there for now.

A new Redux store has been added to track state related to browser history.
The most recent "overview" page (i.e. the home page or the asset page) is
currently being tracked, so that actions taken from the asset page can return
the user back to the asset page when the action has finished.
2020-06-01 14:54:32 -03:00
Brad Decker
ec2e5c848b
fix crash on signature request (#8709) 2020-06-01 12:27:51 -05:00
Erik Marks
9193522bd5
Fix accounts menu styling (#8707)
* fix accounts menu styling
2020-06-01 10:01:51 -07:00
Mark Stacey
df4b757479
Remove unused getToErrorObject parameters (#8705)
The third and fourth parameters were unused, so they have been removed.
The tests descriptions for both `getToErrorObject` and
`getToWarningObject` have been improved as well.
2020-05-29 15:31:57 -03:00
Brad Decker
c3b29e192a
hide connected-status on metamask ext (#8703)
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-05-29 13:14:25 -05:00
Mark Stacey
ddaa492751
Use send state for send flow token (#8695)
The chosen token in the `send` flow was set from one of two places:
`metamask.selectedTokenAddress` or `metamask.send.token`. The former is
used most of the time, but the latter is used for the 'Edit' button
shown in the upper-left of the confirmation UI.

The send flow will now exclusively use `metamask.send.token` for the
token state during the send flow. `metamask.selectedTokenAddress` is
now only used for the selected token state on the Home screen. This
simplifies the Redux state, as the send token is now in one place
instead of two, and `metamask.selectedTokenAddress` has only one
purpose.
2020-05-29 14:46:10 -03:00
Brad Decker
e481166052
do not display extension id in connection modal (#8699) 2020-05-29 12:12:14 -05:00
Whymarrh Whitby
ad85382824
Fix tab content disappearing during scrolling on macOS Firefox (#8702) 2020-05-29 14:41:34 -02:30
Brad Decker
68f8abbbca
close details when button is pressed (#8694) 2020-05-29 11:15:33 -05:00
Mark Stacey
88bed7181f
Refactor token selectors (#8671)
Unused token selectors have been removed, and the remaining token
selector has been moved to the `metamask` Redux store.
2020-05-28 21:43:44 -03:00
Erik Marks
606618ee28
Update eth_accounts permission description (#8693)
* update eth_accounts permission description

* make it easier to find permission name locale message

* handle longer permissions descriptions in UI
2020-05-28 15:53:11 -07:00
Mark Stacey
7ff3b4c928
Extract selected token from token input (#8692)
The `TokenInput` component now takes the token as a prop, instead of
using the `selectedTokenAddress` state. The `UserPreferencedTokenInput`
component that wrapped `TokenInput` has also been updated to take the
token as a prop.
2020-05-28 19:08:11 -03:00
Whymarrh Whitby
91a26bae89
Fix propType for Home defaultHomeActiveTabName (#8683) 2020-05-28 19:15:04 -02:30
Erik Marks
eb7ef4047f
Fix create account form styling (#8689)
* ensure space between create account buttons

* delete wrapper div class name
2020-05-28 13:23:50 -07:00
Mark Stacey
8ed4510d90
Remove unused getSelectedTokenAssetImage selector (#8691)
This selector has been unused as of #8637
2020-05-28 17:17:04 -03:00
Mark Stacey
795676d3ec
Remove getTxParams (#8676)
This function primarily ensured that there was a reasonable fallback
for `txParams` if the given transaction was missing it. This fallback
was only used in one place: the customize gas modal, during the send
flow specifically.

The helper function has been removed, and the default `txParams` is set
in the one place it was needed. In the future we should attempt to
simplify this modal so it doesn't need to know details about the
context in which it's being used.
2020-05-28 16:39:33 -03:00
Brad Decker
00834f5de6
do not show account mismatch alert on details (#8678) 2020-05-28 14:20:56 -05:00
Erik Marks
22699cb1d9
Fix connect hardware styling (#8680)
* Connect -> Hardware

* fix connect hardware styling

* rename some components and classes

* make hardware account scrolling sane
2020-05-28 11:47:48 -07:00
Erik Marks
b34ccbb904
Fix Firefox account menu styling (#8681)
* Fix Firefox account menu styling
2020-05-28 11:02:59 -07:00
Brad Decker
fbe16e8a5f
various fixes to transaction list (#8673) 2020-05-28 13:00:51 -05:00
Whymarrh Whitby
93c2184bd9
Add metrics events for Wyre and CoinSwitch (#8677) 2020-05-28 13:54:52 -02:30
Whymarrh Whitby
f8137b7a66
Fix height of connect screen (#8675) 2020-05-28 12:22:16 -02:30
Whymarrh Whitby
a75dcae9bb
Merge branch 'develop' into manual-connect 2020-05-28 07:20:26 -02:30
Mark Stacey
95a95ee4bc
Refactor transaction list token filtering (#8669)
The transaction list now filters by token in the `TransactionList`
component instead of in the transaction selector. This was done in
preparation for the asset page work.

Technically this approach is slightly less efficient than before, as
we're now filtering the transactions after they've been grouped
together rather than beforehand. The difference is minimal though, and
this method is more correct.

The old filtering was broken because it inappropriately filtered out
cancel transactions. Cancel transactions always have the `to` address
set to the same as the `from` address, and the token filter only
returned transactions where the `to` address was set to the token
address.

Now that we're only filtering by the `to` address of the initial
transaction, token transaction groups will be included in their
entirety, including any cancel transactions.
2020-05-28 00:11:15 -03:00
Mark Stacey
e89540fd94
Fix token decimal type (#8670)
The `decimals` property of tokens was being set as a string instead of
a Number for any tokens added via `getTokenParams`. It's now cast to a
Number instead.
2020-05-27 22:33:59 -03:00
Whymarrh Whitby
5b1608681c Manually connect via the full connect flow 2020-05-27 21:45:41 -02:30
Whymarrh Whitby
145edbe99d
Make address display wider in Account Details (#8665) 2020-05-27 20:11:44 -02:30
Whymarrh Whitby
3931427db8
Show hostname in the disconnect confirmation (#8663) 2020-05-27 19:39:14 -02:30
Whymarrh Whitby
34adccec7c
Fix JSDoc for Tabs#_findChildByName (#8664) 2020-05-27 19:10:26 -02:30
Mark Stacey
cc1170f577
Remove unused isWideViewport prop (#8662)
This prop is no longer required, now that the new fullscreen redesign
has been implemented. This was unused before the redesign as well,
seemingly by accident.
2020-05-27 18:36:55 -03:00
Whymarrh Whitby
4802ed1df5
Localize permission descriptions (#8661) 2020-05-27 18:15:10 -02:30
Mark Stacey
a0d64c7932
Implement new fullscreen design (#8657)
The fullscreen UI now shows roughly the same design as the popup UI.
A few additional changes depicted in the new fullscreen designs will
be implemented in subsequent PRs (e.g. the inline buttons on assets)

This was done now to make asset pages easier to implement. Implementing
asset pages solely for the popup UI would have been complicated by the
fact that we use viewport size to switch between the two layouts, so we
would have had to re-route upon resizing the window.
2020-05-27 17:28:33 -03:00
Brad Decker
398f2647c0
resolve remaining issues with transaction list (#8659) 2020-05-27 14:45:20 -05:00
Mark Stacey
a6f2156386
Update account options menu design (#8654)
The `AccountDetailsDropdown` component has been rewritten to use the
new `Menu` component, and to follow the latest designs.

This should be functionally equivalent. A couple of the icons have
changed, but that's about it.

Support for a subtitle was added to `MenuItem` to support the `origin`
subtitle used for the explorer link for custom RPC endpoints.

A few adjustments were required to `test/helper.js` to accommodate
the use of `Menu` from a JSDOM context (this is the first time it's
been used in a unit test). A `popover-content` element was added to the
fake DOM, and another global was added that `react-popper` used
internally.

An additional driver method (`clickPoint`) was added to the e2e driver
to allow clicking the background behind the menu to dismiss it. This
wasn't possible using the `clickElement` method, because that method
would refuse to click an obscured element. The only non-obscured
element to click was the menu backdrop, and that didn't work either
because the center was obscured by the menu (Selenium clicks the center
of whichever element is targeted).
2020-05-27 12:31:53 -03:00
Brad Decker
706dc02cb4
Implement new transaction list design (#8564)
Co-authored-by: Whymarrh Whitby <whymarrh.whitby@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-05-26 15:49:11 -05:00
Whymarrh Whitby
ab11e0b623
Rename preferencesSelector selector to getPreferences (#8647) 2020-05-26 03:41:58 -02:30
Whymarrh Whitby
835386bf35
Persist home tab state (#8612) 2020-05-25 16:31:28 -02:30
Mark Stacey
3cedf708e9
Remove duplicate 'Account options' tooltip (#8644)
The `title` HTML attribute already resulted in this having a tooltip.
We didn't need to add an extra one.
2020-05-22 14:42:09 -03:00
Mark Stacey
8379dd6a07
Refactor MenuBar component (#8643)
The `MenuBar` component has been converted to a functional component.
This was done to make upcoming changes related to the home screen
redesign easier to implement.
2020-05-22 14:11:42 -03:00
Brad Decker
684c58b94e
fix prop name for disconnect icon (#8641) 2020-05-21 16:12:38 -05:00
Brad Decker
389df9dd37
warn user when sending from different account (#8601) 2020-05-21 15:21:34 -05:00
Mark Stacey
dd41870f1d
Split TransactionViewBalance component (#8637)
The `TransactionViewBalance` component has been split into three
separate components. This was done primarily to make the asset page
easier to implement. Also the name `TransactionViewBalance` didn't
describe this component very well anymore.

Instead of the Ethereum and token-specific logic being in the same
component, the two cases were split into the `EthOverview` and
`TokenOverview` components respectively. They both use the
`WalletOverview` component, which has the structure shared by both
cases.
2020-05-21 14:33:48 -03:00
Mark Stacey
57531ad100
Fix AssetList metric events (#8639)
The metric events in the `AssetList` component were using the
`useMetricEvent` hook incorrectly.
2020-05-21 13:06:06 -03:00
Brad Decker
f9ea9b541a
add useI18nContext shortcut hook (#8635) 2020-05-21 10:26:49 -05:00
Brad Decker
ec99cc82b8
Design QA fixes for v8 (#8630) 2020-05-20 15:42:18 -05:00
Mark Stacey
f886686db2
Extract Menu component from ConnectedAccountsListOptions (#8632)
A `Menu` component has been extracted from the
`ConnectedAccountsListOptions` component. The menu and the menu items
are now the `Menu` and `MenuItem` components respectively.

A custom body was added to the Storybook preview to ensure that the
`popover-content` element was present in the DOM before the Menu was
constructed.
2020-05-20 14:52:23 -03:00
Mark Stacey
91953f062b
Remove unused network prop (#8633)
The `Identicon` component was being passed a `network` prop, despite
not accepting a `network` prop.

A duplicate set of `token-cell` tests have also been deleted, as they
used this prop. The tests were never run, because the file was misnamed
(it needs to be named `.test.js`).
2020-05-20 13:51:21 -03:00
Erik Marks
f748664638
Cleanup network enums (#8627)
* cleanup & consolidate network enums
2020-05-20 08:57:45 -07:00
Whymarrh Whitby
4ced792aec
Remove title from Connected Sites modal (#8623) 2020-05-19 14:47:55 -02:30
Whymarrh Whitby
97d65b645a
Delete the ABTestController and its state (#8620) 2020-05-19 13:27:06 -02:30
Whymarrh Whitby
1ba65d5128
Handle zero nextNonce in ConfirmTransactionBase placeholder (#8618) 2020-05-18 21:18:38 -02:30
Whymarrh Whitby
e4b8cddf02
Disallow all anonymous default export, aside from CSF and migrations (#8535)
CSF = Storybook’s Component Story Format (CSF)

See https://storybook.js.org/docs/formats/component-story-format/

Note that the migrations still use CommonJS require, so the default export as
an object is quite ergonomic (& I don't want to touch the migrations).
2020-05-18 21:18:11 -02:30
Whymarrh Whitby
3244449ab9
Use activeTab.origin where possible (#8617)
This changeset updates the `getOriginOfCurrentTab` selector and the container
for the ConnectedSites page to use `activeTab.origin` instead of parsing the
URL. The `activeTab` URL is parsed in `queryCurrentActiveTab` before the UI is
launched and any subsequent parsing of the URL is unnecessary.

See `queryCurrentActiveTab` in `ui.js:86` [1].

  [1]:e7bb0876f5/app/scripts/ui.js (L86-L118)
2020-05-18 20:04:51 -02:30
Whymarrh Whitby
9e8f922c10
Remove unused index for dropdowns (#8615) 2020-05-18 19:14:40 -02:30
Whymarrh Whitby
3485bfbc5c
Sticky position the tabs at the top (#8609) 2020-05-18 16:22:42 -02:30
Mark Stacey
ce11fad81c
Improve account options menu (#8607)
The account options menu is now much faster, and it correctly closes
when 'Switch account' is selected.

A static width had to be set on the menu so that it could be positioned
reliably. Without this width set, it was rendered as a different size
before positioning than after, which resulted in it being positioned
incorrectly. A `z-index` had to be added (equal to the `z-index` used
by the popover component) to ensure it wasn't rendered beneath the
popover.

The menu is automatically positioned relative to the account options
button, appearing below the button by default but above it instead if
there isn't room below. It is positioned to be inside the bounds of the
popover as well.

The account options button is now a `<button>` rather than a `<i>`.
This required a few additional style rules to overrule the default
button styles. Additionally the size was increased so that it matches
the designs more closely.

The callbacks for connecting, disconnecting, and switching accounts
have been updated to use state and props to determine the correct
address to use, rather than being bound to the correct address
parameter in the render function. This means we aren't creating a new
function upon each render anymore.

The `showAccountOptions` method still needs to be bound once per
account, but this was switched to use more readable syntax (`.bind`,
instead of the double arrow function).

`react-popper` and `@popperjs/core` were both added as dependencies.
These should be used for any UI requiring relative positioning (e.g.
tooltips, menus, etc.). Older versions of these libraries are already
in our codebase as transitive dependencies of the tooltip library we're
using.
2020-05-18 14:51:29 -03:00
Mark Stacey
0033a64e5d
Connected accounts secondary sort order (#8608)
The connected accounts are now ordered by keyring controller order
whenever the `lastSelected` time is equal. This ensures the order is
identical to what connected sites see. This is especially important
when no accounts have been selected, as it ensures the correct account
is marked as the "Primary" account.
2020-05-18 13:31:11 -03:00
Whymarrh Whitby
d488c16df5
Add Connected Accounts modal (#8313) 2020-05-15 15:53:52 -03:00
Whymarrh Whitby
320804bb71
Delete unused DisconnectAll modal (#8599) 2020-05-15 15:32:46 -02:30
Erik Marks
d0fcf665bb
Handle trailing / in block explorer URLs (#8592)
* Strip trailing slashes from variable in block explorer URL template strings
2020-05-14 08:13:53 -07:00
Mark Stacey
74007e054b
Update asset list styles (#8591)
The asset list has been updated to more closely match the new designs.
There are still a few major differences (e.g. the selection state, the
token menu) that can't be implemented until the asset screen has been
implemented.

The background color of the selected asset has been lightened, so that
it's less jarring until we remove it.
2020-05-14 09:49:50 -03:00
bguiz
96929d99c0 fix: handle trailing / in block explorer URLs
What

- modify `ui/app/helpers/utils/transactions.util.js` and
  `ui/lib/account-link.js` to strip trailing slashes
  if they are present.
- added relevant tests not just for the new scenario,
  but also the general scenarios for these functions,
  as there previously was no test coverage for these
  two functions.

Why

- Current behaviour, when user enters a block explorer URL
  when configuring a custom RPC, and that block explorer URL
  contains a trailing `/`.
  - e.g. `https://block.explorer/`
  - this results in a double-slash (`//`) in the transaction
    and account URLs generated by MetaMask.
  - e.g. `https://block.explorer/tx/0xabcd...`,
    `https://block.explorer/account/0xabcd...`
  - This needs to be handled using a router redirect
    on the server of the block explorer,
    and this changes would avoid that requirement.
2020-05-14 17:15:17 +08:00
Mark Stacey
095eeab881
Update Home tab styles to match new designs (#8590)
The tabs on the Home page have been updated to match the new home
screen designs.

A new `activeClassName` prop was added to the `Tab` component to allow
applying different styles to the active tab state.

I ran into specificity problems when overriding the default `Tab` styles
because the import order of our CSS is bizarre and wrong. For now I've
used a crude workaround, but we can fix this properly later by changing
the import order to place styles likely to be overridden first.
2020-05-14 00:16:47 -03:00
Mark Stacey
204d197996
Convert AssetList to functional component (#8588)
The `AssetList` component is now a function rather than a class, and it
makes use of the new `useMetricsEvent` and `useUserPreferencedCurrency`
hooks.
2020-05-14 00:16:30 -03:00
Brad Decker
73272124b3
broaden usage options for list-item (#8587) 2020-05-13 16:19:14 -05:00
Mark Stacey
0ca5d1dc8a
Refactor asset list items (#8586)
All asset list items now use the same component (`AssetListItem`).
Previously the tokens and the Ethereum balance were totally separate
components, despite being styled similarly.

Various unnecessary DOM elements and style rules were removed, but the
overall list looks identical to how it looked before.
2020-05-13 17:41:15 -03:00
Brad Decker
f64106ce21
set home container height to auto (#8577) 2020-05-13 11:12:34 -05:00
Mark Stacey
f9eb1440e4
Always return a Boolean from getShowFiatSelector (#8585)
`getShowFiatSelector` would return the `showFiatInTestnets` value
directly when on mainnet, which could be `undefined`. Now it is cast to
a Boolean instead.

This was done to fix a PropType warning in a component that will be
included in a future PR, where this selector was used for a required
prop.
2020-05-13 11:53:27 -03:00
Mark Stacey
de02eeefbe
Add default values for preferences (#8584)
Defaults have been added for all three preferences. The default values
added are both falsey, so this shouldn't result in any functional
change. This was done to help make this preferences more easily
discoverable.
2020-05-13 11:53:00 -03:00
Mark Stacey
7a4eece92d
Fix Matomo dimension IDs (#8579)
The IDs for the `numberOfTokens` and `numberOfAccounts` Action
Dimensions were swapped. These are the correct IDs. We'll have to
consider that these are swapped when viewing any pre-v8.0.0 metrics.
2020-05-13 10:12:07 -03:00
Mark Stacey
797ee2f4de
Remove redundant .scss file extension from SCSS imports (#8581)
The `.scss` file extension is not required when importing SCSS files.
It has been removed from all imports, for consistency. I chose to
remove it rather than add it everywhere because imports without the
extension seem to be more common.
2020-05-13 09:28:06 -03:00
Mark Stacey
a6d8d3d76e
Refactor identicon styles (#8580)
The CSS class for the fallback Ethereum logo used in the identicon
component was with the `AssetList` styles, and was confusingly named
`balance-icon`. It has been migrated to the identicon styles, and
renamed `identicon__eth-logo`.

A few redundant rules have been removed as well (they were always
overridden by inline styles).
2020-05-13 09:27:34 -03:00
Mark Stacey
fab049b1b0
Fix PropType of network prop of TokenMenuDropdown. (#8582)
The `network` prop of the `TokenMenuDropdown` component was mistakenly
set to "number" in #7779.
2020-05-13 09:26:57 -03:00
Erik Marks
24cbb6fc66
Delete retryTransaction action and background (#8576)
* delete retryTransaction action and background
2020-05-12 16:19:33 -07:00
Erik Marks
0470386326
Delete recent blocks controller (#8575)
* delete recent blocks controller

* delete percentile from direct dependencies
2020-05-12 12:40:33 -07:00
Brad Decker
0aa41e397e
factor out containers for currency components (#8543) 2020-05-12 14:07:35 -05:00
Erik Marks
54b423d407
Fix domain selector (#8574)
* fix domain selector

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-05-12 09:29:45 -07:00
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
6868688a03
Remove unused Balance component props (#8570)
This component was indended to show both ETH/fiat and token balance,
but today is not used for token balance. As a result, large pieces of
this component and many props were unused in practice. The condition
about `formattedBalance` returning a falsy or `None` or `...` result
was also removed, as that doesn't seem to be possible.

The `balanceValue` passed into the `Balance` component in the asset
list has also been removed, as it isn't used.
2020-05-11 19:20:32 -03:00
Erik Marks
6f0f106f7f
Only display accounts with identities in send and permissions flows (#8568)
* send ether info: only select identities
2020-05-11 11:23:28 -07:00
Mark Stacey
d8a4b7fc9b
Fix alert disabling type error (#8561)
When disabling an alert, the background `alertEnabledness` state of the
alert was being set to `undefined` instead of `false`. This didn't have
any user-facing effect, since `undefined` is falsey, but it did result
in a PropType error on the Alert settings page. This mistake was made
in #8550.

The `alertEnabledness` state is now correctly set to `false` instead of
`undefined`.
2020-05-08 21:49:41 -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
Brad Decker
c0489163b5
Use createContext for metametrics context (preserve legacy context) (#8540) 2020-05-08 11:41:43 -05:00
Mark Stacey
abf2294bf3
Update menu bar account hover background color (#8555)
The hover state background color of the "Account" in the popup home
screen menu bar has been updated to match the hover state background
color of the connected status indicator. Both hover state backgrounds
now match.
2020-05-07 23:36:48 -03:00
Mark Stacey
0688426b7c
Fix checkbox color when checked or indeterminate (#8552)
The checkbox color was sometimes incorrect after it was checked. I'm
not sure how to consistently reproduce this issue, but I was able to
make this happen most of the time if I clicked the checkbox while some
text was highlighted.

It seems that the `:checked` and `:indeterminate` pseudo-selectors were
not being applied right away for some reason. Either that or React
wasn't setting the `checked` state of the `input` element right away.

This problem has been worked around by using CSS classes instead of
pseudo-selectors. I am no longer able to reproduce the issue now.
2020-05-07 23:25:19 -03:00
Mark Stacey
5e5215f907
Add Checkbox id prop (#8553)
This prop allows associating the checkbox with a label.
2020-05-07 23:25:06 -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
Mark Stacey
7a6b2594f6
Remove scroll bar from home screen (#8547)
A change made in #8284 had the unintended side-effect of making this
scrollbar appear on the home screen. Previously it was scrollable
without any scroll bar being visible.
2020-05-07 11:34:58 -03:00
Whymarrh Whitby
27e69ec3aa
Export each action constant directly (#8536) 2020-05-06 16:26:09 -02:30
Whymarrh Whitby
fe9176662a
Use named exports in alerts ducks (#8539) 2020-05-06 16:10:24 -02:30
Thomas Huang
39dad370c8
Fixes #8492 (#8533)
Adds min value for input in the advanced-gas-inputs component to prevent users from entering negative values on keypress, change, etc.
2020-05-06 09:59:34 -07:00
Whymarrh Whitby
a2fc06dce9
Remove unused seed phrase action (#8537) 2020-05-06 13:06:20 -02:30
Mark Stacey
8a12257f8e
Add dropdown component (#8524)
This new dropdown component uses a native `select` element, thus
avoiding various issues encountered in attempting to reuse our existing
dropdown components for the new permission system alert modal.

The prefixed forms of `appearance` have been added temporarily so that
the component can be used in Storybook, as our Storybook config isn't
setup to do autoprefixing yet. Our real build system does handle
autoprefixing for this rule correctly already.
2020-05-06 11:48:38 -03:00
Erik Marks
351424df7d
Make permissions selectors less bad (#8529)
* make getPermittedAccountsForCurrentTab more efficient

* add missing docstrings
2020-05-05 21:04:05 -07:00
Mark Stacey
48d29e679b
Add Popover contentClassName prop (#8514)
This class is set on the Popover content. This was required for an
upcoming PR (the last permissions system alert).
2020-05-05 15:02:53 -03:00
Whymarrh Whitby
28af32a84c
Remove unused getUsePhishDetect selector (#8515) 2020-05-05 15:30:04 -02:30
Erik Marks
0a584a3a0e
Consolidate selector tests (#8510) 2020-05-05 07:05:16 -07:00
Jenny Pollack
e00982aa58
add version dimension to metrics event (#8419)
* add version dimension to metrics event

* mock global.platform.getVersion

Co-authored-by: Erik Marks <rekmarks@protonmail.com>
2020-05-05 15:40:36 +02:00
Dan J Miller
fda4c94670
Design improvements for the Connect flow (#8494)
* Design improvements for the Connect flow

* Make new-account-modal close a button

* Update e2e tests for auto select account on connect flow
2020-05-04 18:10:09 -02:30
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
5b06bf795b
Delete amountConversionRate and selectors (#8503) 2020-05-04 10:54:54 -07:00
Erik Marks
898feee69b
Delete forceGasMin state and related selectors (#8504) 2020-05-04 08:59:33 -07:00
Erik Marks
898f8458a2
Consolidate send, onboarding selectors (#8501)
* reorganize & dedupe send selectors
2020-05-04 08:22:34 -07:00
Brad Decker
eaa9f759f9
Fix connection modal style issues (#8433)
Resolves three different style issues due to overflow of content
and addresses an issue where UI was being squished due to available
screen real estate.

- On the choose account modal, when a user has enough accounts to need
to scroll within the account chooser, the last-connected data column
was squished. This is resolved by using a tooltip and icon for this data
rather than text printed in column.
- On the connection permission result screen where it shows the Dapp icon ->
Metamask icon, the bottom of the logos and dropshadows were being cut off
this was resolved by removing the height set on this element and allowing
it to fill the available space.
- On the confirmation screen the content appeared off center due to the scrollbar being overlayed instead of auto. This was resolved by removing some of the setting of manual overflow controls on the body element.
2020-05-04 12:04:41 -03:00
Erik Marks
786e82791e
Reorganize selectors directory (#8497) 2020-05-02 12:41:17 -07:00
Erik Marks
44c5a61d32 fixup! review fixup 2020-05-01 19:07:10 -07:00
Erik Marks
b397aa5725 review fixup 2020-05-01 18:52:23 -07:00
Erik Marks
15958683e5 enable disconnecting single or all accounts 2020-05-01 16:50:26 -07:00
Erik Marks
d45956b2b7 add connected sites popovers render methods 2020-05-01 16:50:26 -07:00
Erik Marks
c7d945e62d disconnectAccount -> disconnectSite; close popover 2020-05-01 16:50:26 -07:00
Erik Marks
ca135a4342
Minor permissions selector refactor (#8495)
* refactor selectors
2020-05-01 16:48:32 -07:00
Mark Stacey
902ed3d649
Update tokens after importing account (#8491)
Tokens are now updated when the account switches after a failed account
import. The usual account switching flow (via the account menu) already
updated tokens, but this step was omitted when the account switched
after a failed import.
2020-05-01 13:56:46 -03:00
Mark Stacey
165666b315
Remove unnecessary tx meta properties (#8489)
* Remove `estimatedGas` property from `txMeta`

The `estimatedGas` property was a cache of the gas value estimated for
a transaction when the default gas limit was set. This property wasn't
used anywhere. It may have been useful for debugging purposes, but the
same gas estimate is already stored on the `history` property so it
should be present in state logs regardless.

* Remove `gasLimitSpecified` txMeta property

The `gasLimitSpecified` property of `txMeta` wasn't used for anything.
It might have been useful for debugging purposes, but whether or not
the gas limit was specified can also be determined from looking at the
transaction history, so it's not a huge loss.

* Remove `gasPriceSpecified` txMeta property

The `gasPriceSpecified` property of `txMeta` wasn't used for anything.
It might have been useful for debugging purposes, but whether or not
the gas price was specified can also be determined from looking at the
transaction history, so it's not a huge loss.

* Remove `simpleSend` txMeta property

The `simpleSend` property of `txMeta` was used to ensure a buffer was
not added to the gas limit during gas estimation for simple send
transactions. It was made redundant by #8484, which accomplishes this
without the use of this property.
2020-05-01 08:44:05 -03:00
Brad Decker
ee5e84af61
Convert connected-status-indicator to button (#8428) 2020-04-29 16:25:15 -05:00
Mark Stacey
53feb20803
Alert user upon switching to unconnected account (#8312)
An alert is now shown when the user switches from an account that is
connected to the active tab to an account that is not connected. The
alert prompts the user to dismiss the alert or connect the account
they're switching to.

The "loading" state is handled by disabling the buttons, and the error
state is handled by displaying a generic error message and disabling
the connect button.

The new reducer for this alert has been created with `createSlice` from
the Redux Toolkit. This utility is recommended by the Redux team, and
represents a new style of writing reducers that I hope we will use more
in the future (or at least something similar). `createSlice` constructs
a reducer, actions, and action creators automatically. The reducer is
constructed using their `createReducer` helper, which uses Immer to
allow directly mutating the state in the reducer but exposing these
changes as immutable.
2020-04-29 14:10:51 -03: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
Mark Stacey
da373713da
Merge pull request #8443 from MetaMask/return-promise-from-set-rpc-target
Return Promise from `setRpcTarget`
2020-04-28 13:56:46 -03:00
Mark Stacey
627fc2f93c
Return Promise from editRpc thunk (#8441)
`editRpc` returned a thunk that didn't return a Promise, despite doing
async work. It now returns a Promise.

In the one place where this is used, it didn't seem important to update
the callsite to block on this finishing. Only one call followed it in
the event handler, and it didn't seem to depend on this.
2020-04-28 13:56:35 -03:00
Mark Stacey
47b785ad7e
Return Promise from updateAndSetCustomRpc thunk (#8440)
`updateAndSetCustomRpc` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

In the one place where this is used, it didn't seem important to update
the callsite to block on this finishing. Only one call followed it in
the event handler, and it didn't seem to depend on this.
2020-04-28 13:56:18 -03:00
Mark Stacey
06ba0db840
Remove fallback selected address (#8439)
The `getSelectedAddress` selector has a fallback of selecting the first
MetaMask account. This is not useful. The only time the
`selectedAddress` is not set is during onboarding, before any accounts
exist, so selecting the first account wouldn't be useful anyway.
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-04-28 12:36:25 -03:00
Mark Stacey
e7fbdd1be6 Return Promise from setRpcTarget
`setRpcTarget` returned a thunk that didn't return a Promise, despite
doing async work. It now returns a Promise.

The callers of this action creator didn't need to be updated, as they
were all in event handlers that didn't require knowing when the
operation had completed.
2020-04-28 12:16:59 -03:00
Mark Stacey
bd50dabad9 Return Promise from editRpc thunk
`editRpc` returned a thunk that didn't return a Promise, despite doing
async work. It now returns a Promise.

In the one place where this is used, it didn't seem important to update
the callsite to block on this finishing. Only one call followed it in
the event handler, and it didn't seem to depend on this.
2020-04-28 12:05:24 -03:00
Mark Stacey
46d72d17a9
Correctly detect changes to background state (#8435)
Changes to the background state were being detected in the `update`
event handler in `ui/index.js` that receives state updates from the
background. However this doesn't catch every update; some state
changes are received by the UI in-between these `update` events.

The background `getState` function is callable directly from the UI,
and many action creators call it via `forceUpdateMetamaskState` to
update the `metamask` state immediately without waiting for the next
`update` event. These state updates skip this change detection in
`ui/index.js`.

For example, if a 3Box state restoration resulted in a `currentLocale`
change, and then a `forceUpdateMetamaskState` call completed before the
next `update `event was received, then `updateCurrentLocale` wouldn't
be called, and the `locale` store would not be updated correctly with
the localized messages for the new locale.

We now check for background state changes in the `updateMetamaskState`
action creator. All `metamask` state updates go through this function,
so we aren't missing any changes anymore.
2020-04-28 10:40:28 -03:00
Mark Stacey
e132998930
Return a Promise from setProviderType thunk (#8436)
`setProviderType` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

None of the callers of this action creator needed to know when it
completed, so no changes to the call sites were made.
2020-04-28 09:50:04 -03:00
Mark Stacey
580a90d543
Use async/await in message manager action creators (#8434)
These action creators for the "message manager" controller
interactions have been updated to use `async/await`. There should be
almost no changes in behavior. The only things removed were a few debug
log statements, and a single `console.log`.
2020-04-28 09:49:10 -03:00
Mark Stacey
b58c0d7810
Skip state update upon failure (#8432)
Many of the "message manager" background methods return a full copy of
the background state in their response; presumably to save us from
making a full round-trip to update the UI `metamask` state after it
changes. However, the action creators responsible for calling these
methods were calling `updateMetamaskState` even when the background
method failed. In effect, they were setting the UI `metamask` state to
`undefined`.

They have been updated to only set the UI `metamask` state if the
background method succeeded.
2020-04-27 20:32:15 -03:00
Mark Stacey
3ab00b48df
Return Promise from setSelectedAddress thunk (#8426)
`setSelectedAddress` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

This action creator was only called in two places, and neither benefit
from using the Promise now returned. They were both event handlers. In
both cases there was an existing Promise chain, but the only thing
after this set was a `catch` block that displayed any error
encountered. I decided not to return the result of `setSelectedAddress`
to this chain, because all it would do is set the warning a second
time in the event of failure.
2020-04-27 18:56:17 -03:00
Mark Stacey
21d62e3adc
Use async/await for forceUpdateMetamaskState (#8429)
The `forceUpdateMetamaskState` function now uses `async/await` instead
of a Promise constructor. This was done to make an upcoming change
easier (making `updateMetamaskState` async).
2020-04-27 18:21:17 -03:00
Mark Stacey
f11a5b4808
Return a Promise from showAccountDetail thunk (#8427)
`showAccountDetail` returned a thunk that didn't return a Promise,
despite doing async work. Now it returns a Promise.

This action is only called in one place, and it looks like the actions
dispatched alongside it were meant to be run in parallel, so no changes
were made there.
2020-04-27 18:17:28 -03:00
Mark Stacey
65ad3ba9e6
Await forceUpdateMetamaskState (#8422)
`forceUpdateMetamaskState` was being called in various action creators
without `await`. Each action creator now waits for the state update to
complete before continuing.
2020-04-27 16:36:19 -03:00
Mark Stacey
ee3f6f124e
Return promise from setCurrentCurrency thunk (#8420)
`setCurrentCurrency` returned a thunk that didn't return a Promise,
despite doing async work. It now returns a Promise.

The callers in this case never needed to know when this action had
completed, but at least this makes our tests more reliable. They were
already `await`-ing this action, despite the lack of Promise.
2020-04-27 16:30:27 -03:00
Mark Stacey
b4c6c11267
Use async/await in action creators that force update state (#8421)
The action creators that use `forceUpdateMetamaskState` without
awaiting that task's completion have been updated to use `async/await`.
This was done in preparation for `await`-ing the completion of
`forceUpdateMetamaskState`, which will be done in a subsequent PR.
2020-04-27 16:03:25 -03:00
Whymarrh Whitby
eb06394dd9
Delete Dai/Sai migration notification (#8418) 2020-04-27 16:23:43 -02:30
Erik Marks
40cd976e8c
Fix connected sites modal styling; add shortenUrl function (#8409)
* fix content row styling

* fix border styling

* handle long domain names
2020-04-27 08:36:08 -07:00
Mark Stacey
b9c82d6ed9
Remove unused useEtherscanProvider action creator (#8412)
This action creator was never called, and it was broken (the background
method it called doesn't exist).
2020-04-27 11:12:15 -03:00
Erik Marks
266d6e67fe
Rename addressSlicer function to shortenAddress (#8408) 2020-04-24 09:52:09 -07:00
Mark Stacey
bace02ad02
Remove unused ShapeShift components (#8402)
The `shift-list-item` component for displaying ShapeShift transactions
has been removed, along with three other components that were used
solely by that component (`copyButton`, `eth-balance`, and
`fiat-value`).

This component hasn't been used in some time, as ShapeShift
transactions no longer exist to display. The controller that ShapeShift
transactions originated from was removed in #8118, and it became
impossible to create new ShapeShift transactions from within MetaMask
in #6746
2020-04-24 12:33:24 -03:00
Mark Stacey
a36e6d414b
Remove unused currentAccountTab state (#8404)
This state has been removed from the background. It was used for the
old UI, and has been unused for some time. A migration has been added
to delete this state as well.

The action creator responsible for updating this state has been removed
from the UI as well, along with the `callBackgroundThenUpdateNoSpinner`
convenience function, which was only used for this action.
2020-04-24 00:23:28 -03:00
Mark Stacey
cc41dee92c
Remove leftover references to Coinbase (#8403)
Coinbase was removed as a deposit option some time ago.
2020-04-23 20:32:15 -03:00
Mark Stacey
3620146e63
Remove unused transForward state and actions (#8401)
The `transForward` app state is no longer used, so it has been removed.
Associated actions have been removed as well.

This state dates back a few years, so I was unable to determine when it
was made obsolete.
2020-04-23 20:32:08 -03:00
Mark Stacey
24a8689090
Remove unused addNewKeyring action (#8400)
Keyrings are added either through the `getKeyringForDevice` background
method (as part of the hardware wallet connect flow), or via
`importAccountWithStrategy` (when importing an account). The
`addNewKeyring` action and corresponding background method has not been
used in a long time.
2020-04-23 20:31:59 -03:00
Mark Stacey
4d76f5b7ca
Promisify gas estimation (#8387)
The `estimateGasMethod` function passed to `estimateGas` is now an
async function. It is now invoked using `async/await` rather than a
Promise constructor.

This was done as part of a broader effort to use Promises rather than
callbacks when interacting with the background.
2020-04-23 15:01:38 -03:00
Mark Stacey
0d6dc380b4
Simplify use of promisified background connection (#8396)
The background connection used in `actions.js` was being promisified
in specific actions. Instead it's now promisified once. This was made
possible by changes in `pify` v5.0.0 that ensure the binding works
correctly when passing in an object to `pify` (e.g. the `this` value
is correctly set to the wrapped background connection).

This async background connection has been temporarily assigned to a
separate variable, until we can transition all of our actions to using
this. This was done to reduce the size of this PR. There are a lot of
actions.
2020-04-23 14:10:15 -03:00
Mark Stacey
5fe25e41b7
Remove unused network nonce state (#8395)
This state hasn't been used since #5886. The nonce we display in our UI
is now from the background, rather than queried directly from the
front-end.

This also means we save making this network call each time a pending
transaction is added, and each time the transaction list is mounted.
2020-04-23 13:23:22 -03:00
Jenny Pollack
940bd81f0f fix-typos-in-actions 2020-04-23 14:16:05 +02:00
Mark Stacey
d0e7f4beaf
Fix comment above callBackgroundThenUpdateNoSpinner function (#8382)
The comment above this function was originally written for a different
function: `callBackgroundThenUpdate`. It was mistakenly left above
`callBackgroundThenUpdateNoSpinner` in #1603 when this function was
added.

The original `callBackgroundThenUpdate` function this was written for
was removed recently in #7675, as it was no longer used.

The format of the comment has also been updated to match our
conventions, and JSDoc params have been added.
2020-04-22 16:15:46 -03:00
Mark Stacey
4598b1844e
Await completion of markPasswordForgotten (#8381)
`markPasswordForgotten` is an asynchronous function, but it was being
called synchronously. The page was redirected without waiting for the
operation to complete.

We now wait for the operation to complete before continuing. Failure is
still not being handled correctly, but that will be addressed in a
separate PR.
2020-04-22 16:15:22 -03:00
Dan J Miller
01985b2cff
Connected indicator info popup (#8293)
* Add popover for informing user about the connected status indicator

* Ensure user only sees connected status info popover once

* Default connectedStatusPopoverHasBeenShown to true and set it to false in a migration

* Add unit test for migration 42

* Initialize AppStateController if it does not exist in migration 42

* Update connect indicator popup locale text

* Code cleanup for connected-indicator-info-popup

* Code cleanup for connected-indicator-info-popup
2020-04-22 14:41:36 -02:30
Erik Marks
a2a51e78d1
Add PermissionsController.removePermittedAccount (#8354)
* add PermissionsController.removePermittedAccount and corresponding UI action

* remove eth_accounts permission on removing last account
2020-04-20 11:34:56 -07:00
Erik Marks
62777a81b4
Close notification UI if no unapproved confirmations (#8358)
* close notification UI if no pending confirmations

* change benchmark page to 'home'
2020-04-20 10:21:57 -07:00
Erik Marks
50451341a0
Route to home page after connecting in popup (#8357)
* after connecting in popup, route to home page
2020-04-17 12:48:13 -07:00
Mark Stacey
15616a33ca
Add 'addPermittedAccount' method to permissions controller (#8344)
This method adds the given account to the given origin's list of
exposed accounts. This method is not yet used, but it will be in
subsequent PRs (e.g. #8312)

This method has been added to the background API, and a wrapper action
creator has been written as well.
2020-04-16 19:23:36 -03:00
Erik Marks
1f49772ca3
Create new tabs instead of windows in most cases (#8347)
* openExtensionInBrowser: create tab, not window

* open tabs instead of windows in most cases
2020-04-16 14:34:40 -07:00
Mark Stacey
b2882aa778
Handle account selection on all domains that can view the selection (#8341)
Selecting a new account now results in all domains that can view this
change being notified. Previously only the dapp in the active tab was
being notified (though not correctly, as the `origin` was accidentally
set to the MetaMask chrome extension origin).

This handling of account selection has been moved into the background
to minimize the gap between account selection and the notification
being sent out. It's simpler for the UI to not be involved anyway.
2020-04-16 13:16:53 -03:00
Mark Stacey
5ee1291662
Prevent accidental use of globals (#8340)
Previously all browser globals were allowed to be used anywhere by
ESLint because we had set the `env` property to `browser` in the ESLint
config. This has made it easy to accidentally use browser globals
(e.g. #8338), so it has been removed. Instead we now have a short list
of allowed globals.

All browser globals are now accessed as properties on `window`.

Unfortunately this change resulted in a few different confusing unit
test errors, as some of our unit tests setup assumed that a particular
global would be used via `window` or `global`. In particular,
`window.fetch` didn't work correctly because it wasn't patched by the
AbortController polyfill (only `global.fetch` was being patched).
The `jsdom-global` package we were using complicated matters by setting
all of the JSDOM `window` properties directly on `global`, overwriting
the `AbortController` for example.

The `helpers.js` test setup module has been simplified somewhat by
removing `jsdom-global` and constructing the JSDOM instance manually.
The JSDOM window is set on `window`, and a few properties are set on
`global` as well as needed by various dependencies. `node-fetch` and
the AbortController polyfill/patch now work as expected as well,
though `fetch` is only available on `window` now.
2020-04-15 14:23:27 -03:00
Mark Stacey
be84a7c2cf
Use correct history object on Permissions Connect page (#8338)
The browser global `history` was being used here instead of the React
Router `history` object. This was accidentally broken when refactoring
in #8269
2020-04-15 11:41:53 -03:00
Mark Stacey
8e03a96470
Rename non-existent selectedAccount prop to fromAccount (#8337)
The prop passed into the SignatureRequestHeader was changed from
`selectedAccount` to `fromAccount` in #8079, but the header component
itself was never updated to use the new prop name.
2020-04-15 11:41:34 -03:00
Mark Stacey
ec40c1fdeb
Remove undeclared name variable from render (#8336)
The header component for the new Signature Request screen has an
undeclared variable called `name` in it. This was present in the
original implementation of this component in #6891. It's unclear what
this was supposed to be, and it doesn't seem to reference anything that
exists.
2020-04-15 11:41:11 -03:00
Whymarrh Whitby
1775d9b163
Update fetchWithCacheTests to use assert.rejects (#8334) 2020-04-14 13:03:33 -02:30
Mark Stacey
3955a4091d
Remove unused getActiveTab selector (#8319)
This selector was added as part of #7004, but wasn't used by the time
it was merged.
2020-04-09 21:17:43 -03:00
Mark Stacey
b628ff05d1
Rewrite checkbox component (#8305)
This new checkbox component uses a plain `input` component internally,
so the browser treats it like a native checkbox. It is styled by hiding
the native checkbox and replacing it with Font Awesome icons (the same
that we are using in Figma).

Support for a 'disabled' state and an indeterminate state has been
added as well. The `onClick` prop has been made optional, as it may not
be required if the parent component is intercepting the click instead.

The `regular` Font Awesome font style needed to be added so that we
could use the `far fa-square` icon for the unchecked checkbox.
2020-04-09 18:51:12 -03:00
Mark Stacey
b0b99fa748
Move action constants to separate module (#8308)
The "global" action constants (the ones previously in `actions.js`)
have been moved to a separate module. This was necessary to avoid a
circular dependency in an upcoming change that was causing problems.

In general the "ducks" pattern of organizing Redux stores does result
in circular dependency problems. This is because reuse of actions
between reducers is encouraged, so it's not uncommon for two reducers
to want to reference an action from the other. Going forward we can
avoid this problem by moving action constants that are shared between
reducers into this shared module.
2020-04-08 21:35:37 -03:00
Whymarrh Whitby
be23ed5b2d
Tidy getAccountsWithLabels selector (#8311) 2020-04-08 20:45:36 -02:30
Whymarrh Whitby
d131014b5e
Fix Connected Sites data selector (#8310)
This change replaces `getRenderablePermissionsDomains` with a new selector `getConnectedDomainsForSelectedAddress` that works better. The data returned from this selector is used to populated the _Connected Sites_ modal, which (as of #8262) didn't use most of the data returned from the old selector.

The old selector only looked at the first address that was exposed, making it not work for anything other than the first account connected to a particular origin.
2020-04-08 20:38:48 -02:30
Mark Stacey
2e67751efe
Delete unused UNLOCK_METAMASK action (#8307)
This action was never triggered in practice, as MetaMask is never
unlocked from the UI. The unlock always occurs as a result of a
background state update.
2020-04-08 10:22:04 -03:00
Mark Stacey
5b64a3d75e
Use ISO-8601 date format for last active time (#8306)
The last active time for each account in the Connected Sites list was
formatted as `yyyy-M-d` (i.e. without the zero-padding for the month
and the day). This didn't match the designs, isn't compliant with
ISO-8601, and generally isn't a common date format.

The month and day are now zero-padded.
2020-04-08 10:21:56 -03:00
Whymarrh Whitby
55228ef08c
Show correct description for empty Connected Sites modal (#8298) 2020-04-08 10:14:54 -02:30
Thomas Huang
a67ac8dd61
Change fa-refresh to fa-sync (#8301)
fa-sync has replaces fa-refresh in version 5 of font-awsome
https://fontawesome.com/icons/sync?style=solid
2020-04-07 14:51:22 -07:00
Whymarrh Whitby
6aa8e78006
Make ConnectedStatusIndicator clickable (#8297) 2020-04-07 18:53:18 -02:30
Whymarrh Whitby
049b98e965
Close Account Details dropdown after opening Connected Sites (#8299) 2020-04-07 18:21:35 -02:30
Dan J Miller
d1e078b8de
Connect flow via popup (#8269)
* Connect screen popup redesign

* Open permission request in notification instead of tab

* Remove no longer user locales

* Update permissions unit test mock to accout for change of opts passed to permissions controller

* Lint fix

* Inline broken line svg in permission-page-container-content.component.js for faster loading

* Add back button to second screen on connect flow

* Add xOfY locale and use for the page count in the connect flow

* Lint fix for svgs permission-page-container-content.component.js

* Fix rebase error

* Lint fix

* Clean up styles on the connect-screen-into-popup branch

* Use closeCurrentWindow to close window on cancel when in full screen connect flow

* Handle errors in rejectPermissionsRequest

* Full screen styles for connect flow

* Lint fixed in permissions-connect and actions.js

* Redirect screen now shows metamask icon instead of users identicon

* Fix subtitle spacing in permissions-connect-header'

* Use window.close instead of closeCurrentWindow() in cancelPermissionsRequest

* Use permissions-connect-header__subtitle in permissions-connect-header.component
2020-04-07 16:08:15 -02:30
Whymarrh Whitby
d8e0c9edd9
Use @metamask/etherscan-link@1.1.0 (#8294) 2020-04-06 13:38:44 -02:30
Mark Stacey
addbf4c62a
Add footer to Popover (#8291)
There were two existing cases where a footer was added to a popover by
putting it in the popover contents. This has been refactored to place
the footer in the popover instead, so that styles common to all
popover footers could be shared.

The popover now has a `section` element instead, giving the `header`
and `footer` elements a correct section context.
2020-04-02 14:43:50 -03:00
Mark Stacey
b09895b8b4
Replace static popover height with responsive max-height (#8290)
The height of the popover is now set to a maximum of 94% of the
viewport height, rather than a static height of 564px. This setting
ensures that the popover has a maximum height of exactly 564px in the
popup, which matches the designs. However it is now able to shrink or
grow to accommodate larger viewports or smaller popovers.
2020-04-02 13:37:46 -03:00
Whymarrh Whitby
f9e8a01dca
Remove z-index from IconWithFallBack (#8289) 2020-04-02 12:48:40 -02:30
Dan J Miller
af24309dc0
Connect screen multi accounts tooltip (#8181)
* Implement tooltip and styled sentence parts on header text of second screen of multi-account-select flow

* Clean up code related to the multi-accounts tooltip implementation
2020-04-02 12:47:10 -02:30
Whymarrh Whitby
09450fe765
Remove selectedAddress from SelectedAccount component (#8285) 2020-04-02 11:49:19 -02:30
Whymarrh Whitby
1b38b4867a
Delete Close icon component (#8286) 2020-04-02 11:49:07 -02:30
Dan J Miller
d8179ff030
Connect Screen Multi Select (#8078)
* Add UI for selecting multiple accounts on the first permissions connect screen

* Make accounts list scrollable on connect screen

* Change title wording on connect screen to 'select your accounts'

* Add select all tooltip to info circle on top of connect screen account list

* Add security info footer to the first screen of the connect flow

* Apply redesigns to page 2 of connect flow

* Display number of accounts on connect flow second screen if there are multiple to connect

* Update e2e tests for connect screen multi-select changes

* Remove unused chooseAnAcount message

* Fix styling/display of redirect elements on second page of connect flow

* Assorted small fixes in permissions connect

* Remove unnecessary tiny delays in spec files

* Remove incorrect use of bem modified in choose-account

* Remove unused locale

* Use Set for managing selected accounts in choose-acount and permissions-connect componets

* Compone!

* Move connect flow header into a reusable component, and implement new header designs

* Update locales and add missing locales

* Improve permission list item design (second screen of connect flow)

* Check box component improvements

* Fixes in variables.scss

* Simplfy code in selectAll of choose-account.component

* Hide checkboxes on first pages on connect flow when there is only one account

* Allow autofill of default new account modal text with right arrow

* Disable next button on first screen of connect flow when no accounts selected

* Improve choose-account/index.scss

* Remove metamask secure graphic

* Fix connect flow redirect screen

* Fix connectToMultiple locale

* Remove locales no longer used after connect flow multiple connect updates

* Fix size of dapp icon on redirect screen of connect flow

* Clean up choose-account code

* Stop using placeholder in new-account-modal

* Remove unused styles in permission-page-container/index.scss

* Pass origin instead of site name to PermissionsConnectHeader in connect flow

* Make iconName a required prop in permissions-connect-header

* Show checkbox in cases where there is one account in the choose-account list

* Do not render select all checkbox when only 1 list item, instead of just hiding it

* Small cleanup in choose-account/index.scss
2020-04-02 06:39:53 -02:30
Mark Stacey
4efa6caec7
Fix home container height (#8284)
* Fix home container height

The home container element's height was not set, so the lower half of
the home component was showing as the wrong color when the user had no
transactions or tokens.

This was broken in #8271, which was a fix for a different CSS problem.
Both problems should remain fixed now with height being set explicitly.

* Remove obsolete `flex` rule

This element is no longer within a flex container as of #8271, so this
rule doesn't do anything.
2020-04-02 00:06:27 -03:00
Whymarrh Whitby
4229892fca
Refactor Menubar and AccountDetailsDropdown styles (#8278) 2020-04-02 00:08:45 -02:30
Whymarrh Whitby
ccf5d5d36c
Undefine Tooltip default wrapperClassName (#8283) 2020-04-01 23:12:19 -02:30
Whymarrh Whitby
e32417d51f
Remove unused 2nd argument to checksumAddress (#8282) 2020-04-01 23:12:03 -02:30
Mark Stacey
12536aa47f
Remove unused isPopup state (#8280)
This property was being set upon each change to background state.
2020-04-01 20:01:47 -03:00
Mark Stacey
44effa0d91
Replace METAMASK_UI_TYPE global with helper function (#8279)
We don't need to store the current UI type as a global. We're already
using the `getEnvironmentType` helper function throughout the UI, so
we'd might as well use that instead of this global state.
2020-04-01 19:28:10 -03:00
Mark Stacey
043ed6cbdb
Restore History title on wide viewport (#8277)
The `History` title above the transaction history was changed in #8264
to only show when there are pending transactions, because it was
redundant to show an additional `History` title below a tab called
`History`. It was preserved when there were pending transactions
because the pending transactions are shown first in the list, followed
by the history, so the title served to divide the two lists.

This ended up breaking the fullscreen view though, which doesn't use
tabs yet. It has been updated to always show on fullscreen.
2020-04-01 18:11:50 -03:00
Whymarrh Whitby
6b6615be27
Enable react/jsx-first-prop-new-line for multiline, single prop JSX (#8276)
* Enable react/jsx-first-prop-new-line for multiline, single prop JSX
* yarn lint --fix
2020-04-01 18:08:19 -02:30
Whymarrh Whitby
8459e8dda1
Don't render the ConnectedStatusIndicator outside of the popup (#8275) 2020-04-01 17:11:42 -02:30
Dan J Miller
d1cd2bb618
Fix centering of account info in menu bar (#8274) 2020-04-01 17:11:26 -02:30
Whymarrh Whitby
7b9e209174
Split AccountDetailsDropdown into container and component files (#8273) 2020-04-01 16:45:35 -02:30
Dan J Miller
3f38451f3e
Connected status indicator (#8270)
Co-authored-by: Whymarrh Whitby <whymarrh.whitby@gmail.com>
2020-04-01 16:14:59 -02:30
Mark Stacey
cb0ab90c84
Move asset list to home tab on small screens (#8264)
Two tabs have been created on the home screen: 'Assets' and 'History'.
This tabbed view is shown only on small screens (e.g. in the popup).
The fullscreen view is unchanged.

The toggle-able left sidebar no longer exists, so some 'sidebar-left'
specific code and styles have been removed. The button in the menu bar
has been removed as well.

The 'History' title of the transaction history is now redundant when
where are no pending transactions, so it as been conditionally hidden.

A passthrough for `data-testid` has been added to the Tab component for
convenience in e2e tests.
2020-04-01 13:35:07 -03:00
Mark Stacey
dbc7446b9a
Fix popup view expanding when expanding transaction (#8271)
The popup view would expand beyond the width of the viewport when
expanding a transaction. This bug was introduced in #8139 when I
removed the `min-width: 0` property from the `home__container` class;
this property was giving the parent permission to shrink that div below
the size of its content.

Instead of restoring that property, the parent component is no longer
using `display: flex`. Flexbox was never useful here, as this is just a
wrapper div around a wrapper div, both with identical sizes. The
default display type of `block` produces the desired behaviour with
less rules.
2020-04-01 13:18:36 -03:00
Mark Stacey
3f2bf36f6a
Add additional prop validation to Tabs component (#8267)
The Tabs component expects the `children` prop to be either a single
Tab component or an array of Tab components, and the internal tab index
should always map onto one of these components. However, if an invalid
tab index was set, it was just returning the first tab contents.

Instead it will now validate that the tab being asked for does exist,
and throw an error otherwise.
2020-04-01 11:29:33 -03:00
Whymarrh Whitby
cb7f81bb42
Update Connected Sites modal design (#8262) 2020-03-31 19:40:02 -02:30
Mark Stacey
2d66e90d07
Refactor asset list into separate component (#8263)
The pieces that we'll be referring to as the "Asset List" in the near
future have been extracted from WalletView into a separate AssetList
component. This list includes ETH, the tokens, and the 'Add Token'
button.

The styles were moved alongside this new component as well.
2020-03-31 16:48:11 -03:00
Mark Stacey
a554353ef3
Update token cell to show inline stale balance warning (#8259)
The token cell how shows a warning inline for the case where the token
balance failed to update. It displays a warning icon next to the
balance, with a tooltip that contains the same contents as was shown on
the token list previously.
2020-03-31 10:50:32 -03:00
Mark Stacey
4f80ff5b01
Redesign 'Add Token' component (#8260)
The 'Add Token' component has been redesigned to be more in-line with
the new home screen design. The description instructing the user to
click the 'Add Token' button has been removed, and the section itself
has been made roughly the same size as one of the list item. The text
now appears on just one line, overflowing to two if necessary.
2020-03-31 10:31:32 -03:00
Mark Stacey
f9767ed191
Add 'interactive' tooltip prop (#8258)
The 'interactive' prop for React Tippy will keep the tooltip open when
the user moves the mouse over the tooltip. This enables interactive
tooltips, where the user is expected to click on something in the
tooltip (e.g. a message with a link).
2020-03-30 23:44:20 -03:00
Mark Stacey
f7504d153e
Move TokenCell styles alongside component (#8257)
The styles for the TokenCell component have been moved to be alongside
the component. They have also been renamed from `token-list-item` to
match the component name.
2020-03-30 23:44:10 -03:00
Whymarrh Whitby
d82f06c710
Convert Connected Sites page to modal (#8254)
This commit updates the existing _Connected Sites_ section to a modal using
the `Popover` component. This will serve as a base for the new modal design.
2020-03-30 21:08:02 -02:30
Mark Stacey
b30a352acb
Use @fortawesome/fontawesome-free npm package (#8256)
The official npm package for Font Awesome Free is now used instead of
the vendored styles. Previously we had been using v4.4.0, now we're
using v5.13.0.

We're now importing the Font Awesome SCSS modules instead of using the
minified CSS bundle. This integrates more cleanly into our build
system, and it lets us use their mixins directly in the future if we
need to.

The variable `fa-font-path` has been set to reference our font
directory, as instructed here:
https://fontawesome.com/how-to-use/on-the-web/using-with/sass#compile
2020-03-30 20:05:51 -03:00
Whymarrh Whitby
d1f761956a
Add optional portal to Popover component (#8253) 2020-03-30 18:25:17 -02:30
Mark Stacey
079db2fdb4
Remove use of webpack loaders in components (#8249)
Various SVGs were being imported directly in components using Webpack
loaders. This was done to get these components to work correctly in
storybook, which uses Webpack. However we don't use Webpack for our
actual build system, so these components would fail when you attempted
to use them.

Instead the storybook script has been updated to use the `--static-dir`
flag, which allows specifying a directory of files to serve statically.
The `app` directory is served statically, so all of the relative URLs
we use in practice to reference fonts and images should just work.

The storybook build command has been updated to use the same flag.
Unfortunately this also means that the uncompiled background code is
now included in the build as well, because it's alongside our static
files. This shouldn't have any impact upon the build though.

The use of this `static-dir` option as made much of the existing
storybook Webpack configuration unnecessary, so it has been reduced to
just the essential steps.
2020-03-30 15:38:02 -03:00
Mark Stacey
4b59d6099a
Fix token list when balance is zero (#8250)
The token list would be stuck on "Loading" when there was at least one
token, but the balance of all tokens was zero. This bug was only
present on `develop`, and has not affected any published version of the
extension.

This was introduced in #8223, which removed what at the time seemed to
be an unnecessary update step. It turns out that the step was required
as a workaround to this bug with the token tracker.

The bug was fixed in https://github.com/MetaMask/eth-token-tracker/pull/33
and published in v2.0.0 of `@metamask/eth-token-tracker`.
2020-03-30 15:37:51 -03:00
marktoda
a761b9e15d
Make seed phrase import case-insensitive (#8246)
The user-specified seed phrase during the first-time-flow import step
required the phrase to be entered in all lowercase. The case does not
add any extra entropy to the seed, so there's no reason to be case
sensitive. Flexibility here will improve the onboarding UX.

This commit makes the entered seed phrase case-insensitive.

Fixes #8171
2020-03-30 10:21:04 -02:30
matteopey
007631171c
Update Italian translation (#8247)
* Update translation
* Align text center in welcome page header
2020-03-30 10:01:07 -02:30
Whymarrh Whitby
69388d9963
Split Routes into container and component files (#8242) 2020-03-26 13:48:50 -02:30
Mark Stacey
966c38cd99
Refactor token list (#8233)
* Refactor token list into standard container/component modules

The token list has been moved into its own directory and split into
separate container and component modules. Additional updates have been
made to simplify the component logic as well.

* Update token-list to use new React Context API
2020-03-25 21:43:25 -03:00
Mark Stacey
ade737e2a8
Refactor token list click handler (#8234)
The token list click handler has been moved up from the token cell to
the wallet view component where the token list is used. This keeps the
responsibilities of the token list and token cell components a bit more
focused - they're now only responsible for display, not what the
effects of clicking should be.
2020-03-25 18:24:14 -03:00
Mark Stacey
19c58b2f32
Move token cell unit test into component directory (#8237)
This is the conventional location for UI unit tests.
2020-03-25 15:56:48 -03:00
Mark Stacey
4328db78d7
Remove unused token cell methods and props (#8238)
The `network` prop was being passed to the Identicon despite that not
being an Identicon prop, and the `userAddress` prop was being passed
down by the container but was unused. The methods removed were not
called anywhere.
2020-03-25 14:59:16 -03:00
Mark Stacey
1e93340c16
Fix unit tests using shared test doubles (#8235)
These tests broke when `sinon.restore()` was called in a separate test
because they setup stubs/spies using `sinon` in the module context.
These were constructed then restored before the tests even ran.

Instead the test doubles are now setup in the `beforeEach` hook, which
in addition to fixing this problem also ensures each unit test is
isolated from the others.
2020-03-25 14:45:23 -03:00
ricky
b7b827b01c
Add Idle Timeout for Sync with mobile (#8201)
* Add idle timeout for sync

* refactor a bit with `goBack` and `clearTimeouts`

* Address lint nit

* Rename handleIdleTimeout -> startIdleTimeout
2020-03-24 01:00:59 -04:00
Mark Stacey
1105da7800
Refactor tab styles to minimize tab component styles (#8209)
* Refactor tab styles to minimize tab component styles

The tab component styles were not applicable to all tab instances, so
they were being overridden in a few places. Instead the tab styles have
been reduced to a minimal set that should be applicable in most cases.

There are a few functional changes here as well, meant to undo
changes made accidentally in #8132. Before that PR the page container
was overriding the tab styles altogether, but after that PR they were
combined with the base tab styles instead.

* Remove background color

This was previously being overridden by the page container styles, and
it matches the inherited background color already in the one other case
(the confirm page for token interactions)
2020-03-23 21:18:45 -03:00
Mark Stacey
2b6aff535e
Migrate "i18n-provider" to new context API (#8213)
The "i18n-provider" module has been replaced by a new `i18n.js` module
in the `contexts` directory which provides the `t` function via the new
React Context API.

The legacy context API is still used throughout the codebase, so a
legacy context provider has also been added as a shim until we migrate
away from the old API. The migration does require changing every single
place where the `t` function is used, so it is a non-trivial amount of
work. This shim allows us to tackle it one piece at a time without
breaking anything.

This was placed in a new `contexts` directory because it didn't seem
to belong in any existing categories. It certainly isn't a higher-order
component.
2020-03-23 14:07:05 -03:00
Mark Stacey
624523168f
Remove fallback for missing localized messages (#8212)
The translation helper function we use everywhere (`t`) would fallback
to the message `[${key}]` for any key not found in the set of localized
messages. Instead it how returns `undefined` in that case.

`[${key}]` isn't something you'd typically want to show to users, so
this fallback wasn't overly useful in practice. At best it served to
hide errors.

The falsey return value in the case where the message is missing makes
it easier to implement a fallback for that case. Such a fallback is
used in the `confirm-transaction-base` component, to restore the
fallback behavior accidentally changed in #8211
2020-03-23 11:54:57 -03:00
Mark Stacey
c167fbf903
Remove unnecessary token list update (#8223)
When the token tracker is first constructed and the first balance
update is triggered, we manually serialize the tracker state and call
our update function. This is _in addition_ to the update event handler
though, so the balances get updated twice. Similarly, we also catch any
errors during this first update to handle them, but this is done via an
event as well, so is redundant.

These steps have been removed; updates and errors are now handled
solely through events. We were able to drop a check from
`updateBalances` as well to ensure the tracker is still running, as the
event cannot be emitted unless it's running.
2020-03-21 17:35:08 -03:00
Mark Stacey
1972adad76
Remove unused parameters (#8216)
These two parameters were never used in practice - a `null` was being
passed in explicitly.
2020-03-19 14:32:38 -03:00
ricky
84806bed9b
Add border none for moz-focus-inner (#8217) 2020-03-19 12:44:20 -04:00
ricky
ba18f600fb
Tx popover (#8210)
* Add minimal working popover

* Fix styling of popover component

* Use lorem ipsum

* Update classnames and remove unrelated styles

* Remove unused components

* Add SVG close icon

* Add Close icon to icon stories

* Use div

* Use `addon-actions`

* Use `<button>` for close

* Fix button wobble in Firefox

* Remove border
2020-03-19 12:07:12 -04:00
Mark Stacey
4cc75eb9af
Remove tOrKey and tOrDefault functions from i18n context (#8211)
These two functions were not especially useful. `tOrDefault` was used
only by `tOrKey`, and `tOrKey` was only used in one place. All it did
was return the given `key` directly if it was falsey, so it was easily
replaced by a condition.
2020-03-19 01:03:20 -03:00
Mark Stacey
23a4c62bd5
Display nothing during confirm page load (#8207)
Previously a few mostly-empty `div`s would be shown if a render
happened while the confirm page was loading. Now nothing is shown. This
shouldn't impact users at all, as this condition should only last a
fraction of a second.
2020-03-17 18:11:44 -03:00
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