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

1591 Commits

Author SHA1 Message Date
Whymarrh Whitby
85453a2588
Rework pending tx logic (#8398) 2020-05-01 15:19:29 -02:30
Mark Stacey
5b5b67a985
Fix default gas race condition (#8490)
A race condition exists where after adding an unapproved transaction,
it could be mutated and then replaced when the default gas parameters
are set. This happens because the transaction is added to state and
broadcast before the default gas parameters are set, because
calculating the default gas parameters to use takes some time.
Once they've been calculated, the false assumption was made that the
transaction hadn't changed.

The method responsible for setting the default gas now retrieves an
up-to-date copy of `txMeta`, and conditionally sets the defaults only
if they haven't yet been set.

This race condition was introduced in #2962, though that PR also added
a loading screen that avoided this issue by preventing the user from
interacting with the transaction until after the gas had been
estimated. Unfortunately this loading screen was not carried forward to
the new UI.
2020-05-01 12:25:45 -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
Mark Stacey
92592fc905
Ensure tx has value before it's added (#8486)
Previously a transaction would get assigned a default value during the
`addTxGasDefaults` function, after the transaction was added and sent
to the UI.

Instead the transaction is assigned a default value before it gets
added. This flow is simpler to follow, and it avoids the race condition
where the transaction is assigned a value from the UI before this
default is set. In that situation, the UI-assigned value would be
overridden, which is obviously not desired.
2020-04-30 21:50:44 -03:00
Mark Stacey
118bddd71a
Ensure receive ETH test selects correct transaction (#8482)
The test for receiving ETH from a contract had been clicking on the
first transaction list item, assuming it was pending. This is not
necessarily true; if the pending transaction hadn't yet been rendered,
this could select the first confirmed transaction instead.

The test has been updated to look for the first _pending_ transaction,
rather than just the first transaction.

Note that this likely does not fix the intermittent failure we've been
experiencing. The failure has been observed with this fix in place.
2020-04-30 14:37:01 -03:00
Mark Stacey
388cdccb28
Capture UI state upon e2e test failure (#8481)
The UI state is now captured and stored as a test artifact in the event
of an e2e test failure.
2020-04-30 13:30:24 -03:00
Mark Stacey
b9860034f2
Fix intermittent reject transaction test failure (#8478)
This test would occasionally fail due to a fluke of timing, where a
pending transaction would take slightly longer than expected to
be rendered in the "confirmed transactions" list. This `wait` block
ensures the test will try again until it has confirmed.
2020-04-30 11:39:42 -03:00
Mark Stacey
bae8ef8b70
Fix broken test artifact directory name (#8480)
The test artifact directory for failed test "verbose reports" was
mistakenly being set to `[browser]/undefined`. This was broken during
the refactor in #7798, when the `driver` parameter was mistakenly left
in after the `verboseReportOnFailure` function was converted to a
method being called on `driver`.
2020-04-30 11:39:25 -03:00
Erik Marks
ec20d46362
Clear input elements in e2e tests instead of using sendKeys (#8468) 2020-04-29 20:48:36 -07: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
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
Erik Marks
c011c0406b
Add new inpage provider package (#8442)
* add @metamask/inpage-provider

* fix failing e2e tests

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-04-28 17:14:51 -07: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
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
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
78fc024636
Use default mock store in action tests (#8437)
A simple default store of `{ metamask: {} }` is now used for the
actions tests.

While I would prefer that any expectations about the store be included
in each test, the mere existence of this `metamask` object seems like
a fairly reasonable default, as it's (hopefully) impossible for it to
be unset at runtime.

The `2-state.json` test state file was deleted as well, as it was no
longer used.
2020-04-28 09:49:43 -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
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
Whymarrh Whitby
eb06394dd9
Delete Dai/Sai migration notification (#8418) 2020-04-27 16:23:43 -02:30
Whymarrh Whitby
7439cd1662
Mark PendingTransactionTracker#resubmitPendingTxs as async (#8399) 2020-04-27 13:24:39 -02:30
Erik Marks
b2d6076da3
Remove obs-store babel register handling (#8413) 2020-04-27 07:54:42 -07:00
kumavis
dcf08164d5
test/unit/permissions - fix promise await timing (#8410) 2020-04-24 15:05:30 -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
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
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
Whymarrh Whitby
91a75b2417
Add new PendingTransactionTracker tests (#8384)
Co-authored-by: Jenny Pollack <jennypollack3@gmail.com>
2020-04-23 13:19:04 -02:30
kumavis
887b27fd04
test/e2e - fix test for contract creation content (#8388) 2020-04-23 21:08:03 +08:00
Mark Stacey
1eaffee00d
Await completion of async actions under test (#8386)
Some of the unit tests for `actions.js` were calling async actions
without `await`-ing them. All async actions are now called with `await`
to ensure they've completed.
2020-04-23 09:45:54 -03:00
Whymarrh Whitby
deacde615f
Rename _checkIfTxWasDropped (#8378) 2020-04-22 17:03:59 -02:30
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
Whymarrh Whitby
f2f70342e2
Skip adding history entry for empty txMeta diffs (#8379) 2020-04-22 11:09:16 +08:00
Whymarrh Whitby
9d535b949f
Rename recipientBlacklistChecker function (#8365) 2020-04-20 16:29:41 -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
Whymarrh Whitby
18eaae2721
Update tx status tests to assert cb called (#8371) 2020-04-20 13:26:50 -02:30
Whymarrh Whitby
164923acd1
Export individual fns from tx-state-history-helpers (#8370) 2020-04-20 13:00:51 -02:30
Whymarrh Whitby
e05db747f5
Tidy up transaction-related unit tests (#8362)
Co-Authored-By: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-04-20 12:31:00 -02:30
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
Mark Stacey
c26d272649
Synchronously validate accounts (#8343)
Now that identities are available synchronously in the permissions
controller, accounts can be validated synchronously as well. Any
account the user wants to give permissions to should already be tracked
as an identity in the preferences controller.
2020-04-16 15:58:36 -03:00
Mark Stacey
63633635ab
Fix order of accounts in eth_accounts response (#8342)
* Fix order of accounts in `eth_accounts` response

The accounts returned by `eth_accounts` were in a fixed order - the
order in which the keyring returned them - rather than ordered with the
selected account first. The accounts returned by the `accountsChanged`
event were ordered with the selected account first, but the same order
wasn't used for `eth_accounts`.

We needed to store additional state in order to determine the correct
account order correctly on all dapps. We had only been storing the
current selected account, but since we also need to determine the
primary account per dapp (i.e. the last "selected" account among the
accounts exposed to that dapp), that wasn't enough.

A `lastSelected` property has been added to each identity in the
preferences controller to keep track of the last selected time. This
property is set to the current time (in milliseconds) whenever a new
selection is made. The accounts returned with `accountsChanged` and by
`eth_accounts` are both ordered by this property.

The `updatePermittedAccounts` function was merged with the internal
methods for responding to account selection, to keep things simpler. It
wasn't called externally anyway, so it wasn't needed in the public API.

* Remove caveat update upon change in selected account

The order of accounts in the caveat isn't meaningful, so the caveat
doesn't need to be updated when the accounts get re-ordered.

* Emit event regardless of account order

Now that we're no longer relying upon the caveat for the account order,
we also have no way of knowing if a particular account selection
resulted in a change in order or not. The notification is now emitted
whenever an exposed account is selected - even if the order stayed the
same.

The inpage provider currently caches the account order, so it can be
relied upon to ignore these redundant events. We were already emiting
redundant `accountsChanged` events in some cases anyway.
2020-04-16 15:20:01 -03: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
3735f0bf8c
Replace fetch-mock with stub (#8339)
The `fetch-mock` package has been removed, and replaced with a simple
stub in the one place it was used.
2020-04-15 13:01:02 -03:00
Mark Stacey
656dc4cf18
Cleanup detect-tokens controller and tests (#8329)
The tests for the detect-tokens controller were nearly all broken. They
have been fixed, and a few improvements were made to controller itself
to help with this.

* The core `detectNewTokens` method has been updated to be async, so
that the caller can know when the operation had completed.
* The part of the function that used `Web3` to check the token balances
has been split into a separate function, so that that part could be
stubbed out in tests. Eventually we should test this using `ganache`
instead, but this was an easier first step.
* The internal `tokenAddresses` array is now initialized on
construction, rather than upon the first Preferences controller update.
The `detectNewTokens` function would have previously failed if it ran
prior to this initialization, so it was failing if called before any
preferences state changes.

Additionally, the `detectTokenBalance` function was removed, as it was
no longer used.

The tests have been updated to ensure they're actually testing the
behavior they purport to be testing. I've simulated a test failure with
each one to check that it'd fail when it should. The preferences
controller instance was updated to set addresses correctly as well.
2020-04-13 17:14:42 -03:00
Whymarrh Whitby
d03f6b0167
Update PreferencesController tests (#8328) 2020-04-13 17:03:35 -02:30
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
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
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
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
Whymarrh Whitby
4229892fca
Refactor Menubar and AccountDetailsDropdown styles (#8278) 2020-04-02 00:08:45 -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
Whymarrh Whitby
cb7f81bb42
Update Connected Sites modal design (#8262) 2020-03-31 19:40:02 -02:30
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
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
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
Erik Marks
2301d9980e
Wait for extension unlock before processing eth_requestAccounts (#8149)
* eth_requestAccounts: wait on unlock

return error on duplicate eth_requestAccounts
add getUnlockPromise mock to permissions unit tests

* only await unlock if already permitted

* add notification badge for wait on unlock

* fixup

* more fixup

* cleanup

* update keyring controller, us its unlock event

* move keyring update unlock logic to unlock event handler

* fix unit tests

* delete onUnlock handler

* fix eth-keyring-controller resolution

* update eth-keyring-controller
2020-03-23 09:25:55 -07:00
Erik Marks
0af02d5194
Update address sync logic (#8224)
* update address sync logic

* error on sync with no addresses
2020-03-20 12:37:27 -07: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
Erik Marks
b1d090ac4d
Add permissions controller unit tests (#7969)
* add permissions controller, log, middleware, and restricted method unit tests

* fix permissions-related bugs

* convert permissions log to controller-like class

* add permissions unit test coverage requirements

* update rpc-cap

Co-Authored-By: Whymarrh Whitby <whymarrh.whitby@gmail.com>
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
2020-03-16 10:13:22 -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
kumavis
7686edadb0
Build system refactor (#8140)
* build - start static asset task cleanup

* build - simplify manifest tasks

* build - refactor + rename some tasks

* build - various cleanups

* manifest - fix ref from controller

* build - drop gulp for simple async tasks

* build - breakout gulpfile into multiple files

* build - rename some tasks

* build - use task fn refs instead of string names

* build - bundle all scripts first, except for contentscript

* build - improve task timeline

* deps - update lock

* build - improve task time printout

* build/scripts - remove intermediate named task

* build - use 'yarn build' for task entry points

* build - properly run tasks via runTask for timeline display

* development/announcer - fix manifest path + clean

* build - lint fix

* build - make all defined tasks possible entry points

* build/task - properly report errors during task

* ci - fix sesify/lavamoat-viz build command

* build/scripts - run each bundle in separate processes

* lint fix

* build - forward childProcess logs to console

* build/task - fix parallel/series stream end event

* build/scripts refactor contentscript+inpage into a single task

* build/static - use the fs for 150x speedup zomg

* lint fix

* build/static - fix css copy

* Update development/build/scripts.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/scripts.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/index.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* deps - remove redundant mkdirp

* deps - remove unused pumpify

* deps - remove redundant merge-deep

* deps - prefer is-stream of isstream

* deps - remove clone for lodash.cloneDeep

* clean - remove commented code

* build/static - use fs.copy + fast-glob instead of linux cp for better platform support

* build/manifest - standardize task naming

* build/display - clean - remove unused code

* bugfix - fix fs.promises import

* build - create "clean" as named task for use as entrypoint

* build/static - fix for copying dirs

* Update development/build/task.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/display.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/display.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/display.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* build - use task refs, tasks only return promises not streams, etc

* lint fi bad merge + lint

* build - one last cleanup + refactor

* build - add comments introducing file

* build/manifest - fix bug + subtasks dont beed to be named

* Update package.json

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* build/task - remove unused fn

* Update package.json

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/styles.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

* Update development/build/styles.js

Co-Authored-By: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-03-09 08:55:02 +08:00
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
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
ryanml
64aef5033d
Adding setting for disabling Eth Phishing Detection (#8125) 2020-02-27 02:29:41 -04:00
Erik Marks
f5f6f7b2d5
Require migration tests from 33 on (#8121) 2020-02-26 20:49:59 -08:00
Erik Marks
5d1f3c1436
Delete shapeshift functionality; retain state and display (#8118)
* delete shapeshift functionality; retain state and display
2020-02-26 09:34:46 -08:00
Dan J Miller
1d2c57a2f3
Assign tabId to middleware request, if provided (#7695)
The `tabId` of the message sender is now added to the middleware
request object. This step is omitted if the `tabId` is not provided.
This is done early in the middleware stack, so the `tabId` should be
available for any subsequent middleware to use.

The Onboarding Middleware has also been modified to get the `tabId`
from the request object, rather than expecting it as a parameter upon
creation.

This refactor will enable further uses of the `tabId`.
2020-02-20 18:39:00 -04:00
Konstantin
6f47fece56
Implementation encrypt/decrypt feature (#7831)
Implement `eth_decrypt` and `eth_getEncryptionPublicKey`. This allows decryption backed by the user's private key. The message decryption uses a confirmation flow similar to the messaging signing flow, where the message to be decrypted is also able to be decrypted inline for the user to read directly before confirming.
2020-02-19 14:24:16 -04:00
Whymarrh Whitby
8f26f5a021
Remove redux-test-utils dependency (#8070)
* Remove usages of redux-test-utils
* Remove redux-test-utils dependency
2020-02-18 14:54:03 -03:30
Mark Stacey
a71f56e5da
Remove unused sinon sandboxes (#8063)
These sandboxes were created, then not utilized at all.
2020-02-17 21:31:09 -04:00
Jenny Pollack
c1453c7528
Merge pull request #8056 from whymarrh/arrow-parens
Enable arrow-parens ESLint rule
2020-02-17 15:26:43 -07:00
Whymarrh Whitby
a78cf0ef3a Enable arrow-parens ESLint rule 2020-02-15 17:04:21 -03:30
Mark Stacey
62c5ea4f80
Update Wyre ETH purchase url (#8051)
* Revert "Revert "Update Wyre ETH purchase url" (#7631)"

This reverts commit bc67d1eeca.

* Restrict widget to just debit card payments

Apple Pay apparently only works on Safari.
2020-02-14 14:07:24 -08:00
Dan Finlay
9c8fd38db4
Merge pull request #8048 from MetaMask/null-check
Fix faulty null checks
2020-02-12 12:03:28 -08:00
Whymarrh Whitby
85430746ad
Update mocha version (#8028)
* Use mocha@7.0.1
* Remove bad async test
2020-02-12 14:47:36 -03:30
Erik Marks
0103bf8b29
fix faulty null checks 2020-02-12 08:17:13 -08:00
Whymarrh Whitby
4f3fc95d50
Update ESLint rules for test suite (#8023)
* Use @metamask/eslint-config@1.1.0
* Use eslint-plugin-mocha@6.2.2
* Mark root ESLint config as root
* Update Mocha ESLint rules with shared ESLint config
2020-02-11 13:21:13 -03:30
Whymarrh Whitby
1d654d6c4e
Remove version bump scripts (#8006) 2020-02-06 18:56:31 -03:30
Whymarrh Whitby
dea8f0f24d
Use combineReducers for rootReducer (#7964) 2020-02-06 13:08:14 -03:30
Whymarrh Whitby
08c7322203
Remove last remaining usages of npm run (#7994)
* Remove last remaining usages of `npm run`
* Use nyc@15.0.0
2020-02-06 12:22:40 -03:30
Thomas Huang
5d1c9313db
Various component tests and some conditional statements (#7765)
* Various component tests and some conditional statements

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

* Update helpers

* Remove component debugging

* Add default params for render helpers

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

Change logout to lock in account-menu test
2020-01-30 11:34:45 -08:00
Whymarrh Whitby
608a1fc298
Remove cross-env (#7950) 2020-01-30 14:11:26 -03:30
Whymarrh Whitby
2f3f605521
Inline isomorphic-fetch test helper (#7945) 2020-01-29 21:31:32 -03:30
ryanml
07ce849c48
Sorting seed phrase confirmation buttons alphabetically (#7933) 2020-01-29 16:12:46 -03:30
Whymarrh Whitby
4136209f3d
Remove redux-logger from mock-store (#7930) 2020-01-29 13:45:16 -03:30
Mark Stacey
398a45bfdd
Replace clone dependency with cloneDeep from lodash (#7926)
This was done to reduce the number of direct dependencies we have. It
should be functionally equivalent. The bundle size should not change,
as we use `clone` as a transitive dependency in a number of places.
2020-01-29 13:14:33 -04:00
Mark Stacey
1d73d90a1a
Replace bluebird with Node.js API for unhandled rejections (#7904)
Unhandled rejections are now caught using built-in Node.js APIs instead
of with `bluebird`. `bluebird` was added as a production dependency but
was only used for this purpose. The code responsible for catching
unhandled rejection in the browser was removed, as this test helper is
never run in the browser.

Additionally, unhandled rejections are tracked over the course of all
tests, and result in a non-zero exit code if they remain at the end.
This was done because it is possible for errors to trigger the
`uncaughtRejection` event but then still be handled later on. This is
uncommon, and doesn't seem to happen in our test suite. But if it does
in the future, it'll be logged but won't result in a non-zero exit
code.
2020-01-27 11:15:37 -04:00
Mark Stacey
550fba2466
Add benchmark to CI (#7871)
* Add benchmark to CI

The page load benchmark for Chrome is now run during CI, and the
results are collected and summarized in the `metamaskbot` comment.

Closes #6881

* Double default number of samples

The number of default samples was changed from 10 to 20. The results
from 10 samples would show statistically significant changes in page
load times between builds, so weren't a sufficiently useful metric.
2020-01-23 16:55:17 -04:00
Erik Marks
b095dc0347
Change "Log In/Out" terminology to "Unlock/Lock" (#7853)
* log out/in -> lock/unlock
2020-01-21 14:09:53 -08:00
Mark Stacey
e02b229df6
Add margin of error metric (#7877)
A margin of error metric has been added, which is calculated from a 95%
confidence interval. This confidence interval is calculated using
Student's t-distribution, which is generally preferred for smaller
sample sizes (< ~30) of populations following a normal distribution.
2020-01-21 17:12:40 -04:00
Mark Stacey
5734f7210c
Add benchmark script (#7869)
The script `benchmark.js` will collect page load metrics from the
extension, and print them to a file or the console. A method for
collecting metrics was added to the web driver to help with this.

This script will calculate the min, max, average, and standard
deviation for four metrics: 'firstPaint', 'domContentLoaded', 'load',
and 'domInteractive'. The variation between samples is sometimes high,
with the results varying between samples if only 3 were taken. However,
all tests I've done locally with 5 samples have produced results within
one standard deviation of each other. The default number of samples has
been set to 10, which should be more than enough to produce consistent
results.

The benchmark can be run with the npm script `benchmark:chrome` or
`benchmark:firefox`, e.g. `yarn benchmark:chrome`.
2020-01-21 12:02:45 -04:00
Mark Stacey
d27f2ee7d6
Fix intermittent e2e test failure (#7873)
The 'can retype the seed phrase' test would fail sometimes when one of
the words in the seed phrase was a subset of another word (e.g. 'issue'
and 'tissue'). This is because the selector used to find the word
looked for the first element that contained the text, rather than an
exact match.

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

A test id was also added to the div containing the shuffled seed words
to select from, so that the chosen seed words wouldn't be selected
in place of the real target when the same word appears twice.
2020-01-21 11:31:56 -04:00
Mark Stacey
206920e9bd
Add 1 second pause at the beginning of each e2e test run (#7872)
There have been intermittent test failures at the beginning of various
e2e test runs. Most tests start with waiting for the 'Welcome' button
to be visible and enabled, which means waiting for the loading screen
to go away.

It looks like the reason the test intermittently fails is that
sometimes the loading screen doesn't appear until a few moments _after_
the page loads (or that it vanishes and comes back).

It was rather difficult to track down each possible cause for the
loading screens, so in the meantime a pause has been added at the start
of each run. This should hopefully suffice to ensure the momentary gap
in loading has been passed by the time the first test starts up.
2020-01-20 18:40:01 -04:00
Mark Stacey
cc928aaed9
Add withFixtures helper and simple-send test (#7862)
The `withFixtures` helper will instantiate ganache, a web driver, and
a fixture server initialized with the given set of fixtures. It is
meant to facilitating writing small, isolated e2e tests.

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

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

Closes #6548
2020-01-20 14:50:25 -04:00
Mark Stacey
ca38635d22
Add page navigation to e2e web driver (#7867)
The driver now has a page navigation function that can navigate to any
of the three primary pages used in the extension. Additional pages and
support of paths can be added later as needed.
2020-01-20 13:03:07 -04:00
Mark Stacey
7b35ea6400
Allow exporting state during e2e tests (#7860)
As of #7663, an in-memory store was used in place of local storage
during e2e tests, to facilitate the use of state fixtures. However,
this made it difficult to export state during a test run. The
instructions for exporting state to create fixtures assumed that local
storage was being used.

A new global function has been added to the background context to allow
exporting state. This method is available during testing and
development, and it works with either local storage or the in-memory
store. The fixture instructions have been updated to reference this new
function.
2020-01-17 18:59:25 -04:00
Mark Stacey
3a2c81d8bc
Switch signature-request e2e tests to using ganache (#7859)
The signature request e2e tests were previously using ropsten. This
expectation was even hard-coded into the test contract dapp.

Instead the contract-dapp has been updated to use the current `chainId`
when calling `signTypedData` (falling back to the `networkId` if
`chainId` is not set). The fixture used by `signature-request` has been
updated to use ganache.
2020-01-17 18:16:21 -04:00
Whymarrh Whitby
1728d9a5aa
Inline networkStore to avoid having too many event listeners (#7854) 2020-01-17 18:28:27 -03:30
Whymarrh Whitby
b4ca671b6b
Fix propTypes and test props for Dropdown components (#7851) 2020-01-16 18:18:09 -03:30
Mark Stacey
08dcd87d58
Refactor building of e2e web driver (#7841)
The switch case has been moved to a separate function so that the
initialization steps following the web driver instantiation could more
easily be deduplicated.
2020-01-16 14:35:50 -04:00
Mark Stacey
20a7b8fa36
Force background state update after removing an account (#7840)
The e2e tests were failing intermittently after removing an account
because the account was shown as not deleted after the removal. I
suspect this was because the account _had_ been removed, but that
change to the background state hadn't yet propagated to the UI.

The background state is now synced before the loading overlay for
removing the account is removed, ensuring that the removed account
cannot be seen in the UI after removal.
2020-01-16 13:43:40 -04:00
Mark Stacey
8225bbe126
Remove unused current view related things (#7843)
* Remove unused functions from `mapDispatchToProps`

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

* Remove unused container component

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

* Remove both unused `getCurrentViewContext` selectors

* Remove unused SHOW_CONFIG_PAGE action

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

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

* Remove unused `wallet-view` container props

* Delete unused SHOW_SEND_PAGE and SHOW_ADD_TOKEN_PAGE actions

* Remove unused `account-menu.container` props

* Remove unused SHOW_INFO_PAGE action

* Remove unused SET_NEW_ACCOUNT_FORM action
2020-01-16 13:02:44 -04:00
Whymarrh Whitby
4257858fb5 Remove extraneous console output from TransactionStateManager tests (#7838) 2020-01-16 08:32:02 -08:00
Whymarrh Whitby
76a31c3175 Clean up Migrator test cases (#7835) 2020-01-15 13:54:28 -08:00
Mark Stacey
be08cfec0c
Wait until element is clickable before clicking in e2e tests (#7823)
* Wait until element is clickable before clicking in e2e tests

A new `findClickableElement` has been added to the webdriver to allow
finding an element and blocking until it's both visible and enabled.
This is now used by the pre-existing `clickElement` method as well.

All cases where something is clicked in the e2e tests have been
updated to use one of these methods, to ensure we don't run into
intermittent failures when loading screens take longer than usual.
2020-01-15 15:34:15 -04:00
Whymarrh Whitby
d0536ba984
Return promises from accountImporter tests (#7826) 2020-01-15 13:27:51 -03:30
Whymarrh Whitby
2525e5edaa
Fix usages of sinon deprecated APIs in MetaMaskController tests (#7827) 2020-01-15 13:24:15 -03:30
Whymarrh Whitby
73197b43e1
Don't log Ganache Testrpc started event (#7822) 2020-01-14 23:47:56 -03:30
Mark Stacey
00da0d28a0
Use data attributes to reference settings in e2e tests (#7820)
These rows on the Advanced Settings page were being looked up in the
e2e tests by the order they appeared in. Instead they're now referenced
by data id, so that we can add new settings and re-arrange them without
breaking the e2e tests.
2020-01-14 17:27:36 -04:00
Mark Stacey
f7aea9597b
await all clicks during e2e tests (#7815)
The `.click()` function returns a Promise, as it needs to communicate
with the browser and ensure the click was successfully sent.
2020-01-14 15:21:02 -04:00
Mark Stacey
19f10e197e
Simplify e2e test transaction navigation (#7816)
The transaction navigation in the e2e tests has been made simpler with
the addition of data attributes to help with finding the navigation
buttons. Each button is now labelled according to its purpose.
2020-01-14 14:53:02 -04:00
Mark Stacey
dd4e684f7d
Consolidate webdriver initialization (#7814)
The webdriver is now instantiated directly by the webdriver module,
rather than via a helper method.
2020-01-14 13:34:38 -04:00
Whymarrh Whitby
25fe4adaa7 Remove usages of xtend from the background scripts (#7796) 2020-01-13 08:59:36 -10:00
Mark Stacey
ac01c5c89a
Consistent jsdoc syntax (#7755)
* Specify type before parameter name

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

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

* Use JSDoc optional syntax rather than Closure syntax

* Use @returns rather than @return

* Use consistent built-in type capitalization

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

* Separate param/return description with a dash
2020-01-13 14:36:36 -04:00
Mark Stacey
27cfb6aa51
Move webdriver interactions into driver module (#7798)
The Selenium webdriver is difficult to use, and easy to misuse. To help
use the driver and make it easier to maintain our e2e tests, all driver
interactions are now performed via a `driver` module. This is basically
a wrapper class around the `selenium-webdriver` that exposes only the
methods we want to use directly, along with all of our helper methods.
2020-01-13 11:07:32 -04:00
Whymarrh Whitby
82ef9674f2
Move util test file alongside subject (#7807) 2020-01-13 10:41:41 -03:30
Mark Stacey
ff966d515d
Re-arrange transaction navigation test actions (#7806)
These tests were updated in #7473 to navigate in a different order,
because the transaction order changed. Unfortunately this meant that
a second contract deployment was being confirmed, where it was
previously being rejected.

This updates the test to ensure the same transaction is rejected and
confirmed as prior to the change in #7473
2020-01-10 15:32:57 -04:00
Mark Stacey
dac83f6188
Make account details modal close button easier to click (#7797)
The account details close button is difficult to click from the e2e
tests because it has a size of zero. The actual icon is added via CSS
as an `::after` pseudo-element.

The CSS has been adjusted to give the icon a size, and it the markup
is now a `button` rather than a `div`.
2020-01-10 10:43:53 -04:00
Erik Marks
728026d1f7
Fix batch transaction UX (#7473)
* order transactions from oldest to newest in UI

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

* update e2e and integration tests
2020-01-10 06:34:02 -08:00
Whymarrh Whitby
4f5f671cb1
Purge assertRejects shim (#7794) 2020-01-10 10:57:45 -03:30
Dan J Miller
d349bd61d2
Fix gas estimate for tokens (#7753)
* Make gas estimate update on debounced token amount change, not just on blur after change

* Updated tests

* Ensure `updateGas` is bound early

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-01-10 10:53:54 -03:30
Whymarrh Whitby
92971d3c87
Migrate codebase to use ESM (#7730)
* Update eslint-plugin-import version

* Convert JS files to use ESM

* Update ESLint rules to check imports

* Fix test:unit:global command env

* Cleanup mock-dev script
2020-01-09 00:04:58 -03:30
Mark Stacey
5e461df617
Remove obsolete e2e test ignored error messages (#7768)
These error messages are no longer present during e2e tests, so they
don't need to be ignored.
2020-01-08 13:10:38 -04:00
Mark Stacey
09859d48b0
Prevent install popup during e2e tests (#7760)
Typically the fullscreen UI will open upon installation, though this
behaviour was suppressed in development. This was dealt with in the e2e
tests by waiting for it to open, then closing it.

Instead this behaviour is now suppressed for test builds as well.
2020-01-08 11:47:45 -04:00
Mark Stacey
0f4c0286a4
Improve e2e helper functions (#7750)
* Improve `openNewPage` helper function

The two delays were removed, and the window handle for the new page is
now returned. This was made possible with the new `newWindow` function
added in `v4.0.0-alpha.3` of `selenium-webdriver`.

* Replace recursion with loops

This should result in far more pleasant stack traces for any
exceptions in these functions. It might also be faster. These functions
seem easier to understand as loops as well.

* Remove unused string parameter

The `closeAllWindowHandlesExcept` function has been simplified by
removing a branch that handles the case where the `exceptions`
parameter given is a string. That parameter is never a string.
2020-01-07 10:46:03 -04:00
Mark Stacey
8f40cd8438
Update selenium-webdriver (#7749)
Update `selenium-webdriver` to v4.0.0-alpha.5. Despite the fact that
this version has "alpha" in the name, the maintainer of
`selenium-webdriver` has described this release as stable [1].

A few APIs were removed or changed in v4, which required changes to our
Firefox webdriver.

The port used for webdriver communication can now be specified
manually. This was required to ensure the threebox tests kept working,
because they used two different driver instances. This new version of
`selenium-webdriver` now uses the same port for each instance of the
webdriver (unlike the old version, which generated a new port for each
one), so it was necessary to manually specify the port to prevent the
same port from being used for both instances.

`chromedriver` required an update, as the version we were using was not
compatible with the new W3C WebDriver protocol. I've updated
`geckodriver` as well, just to bring it in line with the version of
Firefox we are using.

[1]: https://github.com/SeleniumHQ/selenium/issues/5617#issuecomment-373446249
2020-01-07 10:01:06 -04:00
Mark Stacey
69d418a5a3
Login per site onboarding (#7602)
* Remove unused onboarding stream

* Pass `sender` through to `setupProviderEngine`

The Port `sender` has been passed down a few more layers. This allows
us to get more information from the sender deeper in the stack, but
also simplifies things a bit as well. For example, now the "fake"
URL object with the `metamask` hostname is no longer needed.

* Create onboarding middleware

This middleware intercepts `wallet_registerOnboarding` RPC messages. It
will register the sender as an oboarding initiator if possible, and
otherwise ignores the message.
2019-12-20 12:02:31 -03:30
Frankie
237d0b4d41 Add tests around migration files (#7016) 2019-12-12 20:44:29 -03:30
Whymarrh Whitby
db0d59f800
Remove unused UI actions (#7675) 2019-12-12 19:48:48 -03:30
Whymarrh Whitby
f49bc58c09
Remove unused methods from the app/scripts/ (#7692) 2019-12-12 15:07:18 -03:30
Mark Stacey
12fb5ad985 Refactor webdriver setup (#7690)
The setup for each browser web driver instance has been extracted from
`helpers.js` and moved to the `webdriver` directory.
2019-12-11 11:14:58 -08:00
Mark Stacey
eadeaa7883 End-to-end test state fixtures (#7663)
* Add network store for testing

An alternative persistent state store has been created for use with e2e
tests. Instead of reading state from disk, it tries to load state from
a local fixture server running on port `12345` and serving state from
the path `/state.json`, and returns a blank state otherwise.

* Add e2e test fixture server

A fixture server has been added for serving background state, which the
background will read upon startup as part of restoring persisted state.

The `signature-request` e2e test has been updated to use a fixture to
bypass the registration step. The fixture used (`imported-account`) was
generated by pausing midway through that test run
2019-12-11 09:26:20 -08:00
Whymarrh Whitby
34b674c3d7
Remove unneeded Edge-specific encryption code (#7683) 2019-12-10 16:34:50 -03:30
Mark Stacey
958ac69ba1
Consolidate E2E test helper functions into helper.js (#7684)
E2E test helper functions were split between `helper.js` and `func.js`.
They've now all been moved to `helper.js`.
2019-12-10 15:23:25 -04:00
Mark Stacey
885d30f90a
Remove unused test methods (#7679)
These helper methods were no longer used in any e2e tests.
2019-12-10 09:52:48 -04:00
Mark Stacey
3ce19ee11d
Remove unused gasExpress fetch mocks (#7681)
These fetch mocks have been unnecessary since #7059
2019-12-10 09:52:34 -04:00
Mark Stacey
812c546acd
Contract test dapp improvements (#7587)
* Add Get Accounts button

This button calls `eth_accounts`. This button is always enabled, even
when not connected.

* Disable account buttons by default

The buttons that require you to have first connected have been disabled
by default. Previously they would be enabled until the JavaScript
finished initializing the page, at which point they'd be disabled. This
resulted in a distracting flash as the page loaded and the buttons
changed.

The `signTypedData` button was added to the accounts button set as
well, rather than being left enabled regardless of connected status.

* Allow connect button to become re-enabled

The Connect button was broken previously in that after being disabled,
it would stay disabled even if the dapp lost access to MetaMask. The
button will now be enabled whenever not connected.

* Stringify signTypedData results

* Defer metamask onboarding bundle to speed up page load
2019-12-09 14:31:47 -04:00
Whymarrh Whitby
56d9c06402
Clean up list of available currencies (#7667) 2019-12-09 13:09:46 -03:30
Mark Stacey
476e422714
Use Ganache programmatically in e2e tests (#7664)
The `ganache.js` helper module uses `ganache-core` to start `ganache`
instead of `ganache-cli`, and allows all of the same customization.
Using `ganache` programmatically from our e2e tests is much faster, as
we don't have to wait that arbitrary 5 seconds before each test as we
wait for `ganache-cli` to start up.
2019-12-09 10:40:43 -04:00
ricky
1c4f2aab8f React 16 upgrade (#7476)
* Use arrow property initializer functions

* Use pure components where applicable

* Add UNSAFE_ prefix for deprecated lifecycle hooks

* Add allow UNSAFE_

* Removed unused "Component"

* Replace boron with 'fade-modal'

* Upgrade react/no-deprecated to an error

* Paste react-tooltip-component source directly

* Use arrow functions to bind `this`

* Add UNSAFE_ prefix

* Update react-redux, react-router-dom

* Remove things from inlined 'fade-modal'

* Adjust mountWithRouter to get unit tests passing again

* Remove domkit

* Add Wrapper to render-helpers

* Upgrade @storybook/addon-knobs
2019-12-06 11:40:06 -04:00
Frankie
71a89df8ee
transactions/pending - buffer 3 blocks before dropping a tx (#7483)
* transactions/pending - buffer 3 blocks before dropping a tx

* transactions/pending - only increment for dropped txs
2019-12-05 09:34:10 -10:00
Dan Finlay
30304913eb
Merge pull request #7591 from whymarrh/eslint-object-curly-spacing
Enable object-curly-spacing rule for ESLint
2019-12-04 10:25:32 -08:00