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

1498 Commits

Author SHA1 Message Date
Erik Marks
e8fa0b7b5d
Consolidate and dedupe send selectors (#8506)
* consolidate & dedupe send selectors
2020-05-04 12:06:28 -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
Erik Marks
786e82791e
Reorganize selectors directory (#8497) 2020-05-02 12:41:17 -07:00
Erik Marks
7100a36ed3 fix e2e tests 2020-05-01 16:51:36 -07:00
Erik Marks
748d5e680c
Add @metamask/test-dapp (#8464)
* add @metamask/test-dapp; delete contract-test files

* dedupe @metamask/onboarding, remove from direct deps
2020-05-01 11:23:03 -07:00
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