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

10237 Commits

Author SHA1 Message Date
Erik Marks
7419fa84ae
update eth-contract-metadata (#8466) 2020-04-30 09:50: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
Brad Decker
0c7269f599
fixes firefox popup location (#8467)
Co-Authored-By: Whymarrh Whitby <whymarrh.whitby@gmail.com>
2020-04-29 17:04:03 -05:00
Brad Decker
ee5e84af61
Convert connected-status-indicator to button (#8428) 2020-04-29 16:25:15 -05:00
Whymarrh Whitby
0e54c5aecd
Don't updatePendingTxs outside of block updates (#8445)
* Don't updatePendingTxs outside of block updates

Refs #8377

Reverts 507397f6c (#5431)

* Check for new block data on unlock
2020-04-29 16:01:22 -02:30
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
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
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
1697bb30cd
Fix page benchmark result display (#8438)
The page tested by the benchmark was changed from `notification` to
`home` in #8358, but the announce script was still expecting the
`notification` page to be in the results. It does collect results for
all pages, but the `notification` page was hard-coded to be used for
the benchmark summary.

The announce script now correctly looks for the `home` page results for
the benchmark summary. Variable names have been updated to make it more
clear what's going on here as well.
2020-04-28 09:50:21 -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
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
Whymarrh Whitby
306f04be8d
Simplify logic in PTT helper fns (#8430) 2020-04-27 18:38:16 -02:30
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
Whymarrh Whitby
7439cd1662
Mark PendingTransactionTracker#resubmitPendingTxs as async (#8399) 2020-04-27 13:24:39 -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
Erik Marks
b2d6076da3
Remove obs-store babel register handling (#8413) 2020-04-27 07:54:42 -07:00
Whymarrh Whitby
b947fd54c7
Move default exports for all tx classes (#8416) 2020-04-27 12:15:00 -02:30
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
Whymarrh Whitby
8dd886a25b
Update tx:dropped return value in PendingTxTracker (#8397) 2020-04-26 00:03:25 -02:30
Whymarrh Whitby
d612f9988e
Move default export declaration to Migrator class (#8407) 2020-04-26 00:02:41 -02:30
kumavis
dcf08164d5
test/unit/permissions - fix promise await timing (#8410) 2020-04-24 15:05:30 -07: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
26dcb3af9b
Fix comment on migration #42 (#8405)
The comment was accidentally copied from the previous migration.
2020-04-23 23:08:50 -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
Whymarrh Whitby
e2bf779acd
Add @kumavis for CircleCI and dev directories (#8394) 2020-04-23 14:09:26 -02:30
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
ec08e5c029
Update README.md (#8393) 2020-04-23 13:30:14 -02:30
Whymarrh Whitby
91a75b2417
Add new PendingTransactionTracker tests (#8384)
Co-authored-by: Jenny Pollack <jennypollack3@gmail.com>
2020-04-23 13:19:04 -02:30