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

1318 Commits

Author SHA1 Message Date
Erik Marks
478d6563f2
Freeze Promise global on boot (#7309)
* freeze background and UI Promise globals on boot

* add new tests

* remove tape
2019-10-24 06:54:32 -07:00
Thomas
5f53e4b67e Remove async 2019-10-23 12:43:22 -07:00
Thomas
94a4b4d7db Stub signTypedMessage 2019-10-23 12:09:27 -07:00
Mark Stacey
adb50d1357
Fix flaky e2e tests (#7307)
* Add a delay after connecting

This addresses an intermittent test failure where the MetaMask
Notification window cannot be found. It appears to be caused by the
Send button being clicked too soon after connecting to a dapp, before
the background has had a chance to process the approval. The premature
send is ignored and the window never appears.

This delay (2 seconds) should be sufficient time for the connection to
be processed. A later 5-second delay was also reduced to 2 seconds.

* Select onboarding buttons by button text

The onboarding buttons were being selected using the classname, which
was common to all onboarding buttons. This resulting in buttons being
selected just before a page transition, leading to an error about
the element reference being stale when a click was attempted.

The CSS class selectors have been replaced by text selectors, which
are more specific and shouldn't be at risk of resolving early. They're
also easier to read.

* Remove retypeSeedPhrase function

This function was used to re-type the seed phrase in the event that a
failure occurred when confirming the seed phrase. I'm not sure what
failure this was meant to address exactly, but this contingency hasn't
been needed for some time. We can tell that it hasn't been used because
it wasn't updated for the incremental account security changes, so it
couldn't have worked since then (it would have clicked the wrong
button).
2019-10-23 14:00:16 -03:00
Mark Stacey
ba25d52670
Use AdvancedGasInputs in AdvancedTabContent (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`

The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.

The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.

Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.

The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.

Closes #6872

* Cleanup send components

Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 09:23:15 -03:00
Thomas
4d6ce8ceeb Use async/await 2019-10-22 17:23:18 -07:00
tmashuang
2a81083f14 MM controller additions, balance controller, typedMessageManager, and addtional actions tests 2019-10-21 12:47:36 -07:00
Whymarrh Whitby
06536b1d0f
Fix phishing detect script (#7287) 2019-10-18 13:35:32 -02:30
Dan J Miller
1a0b0ce7c7 Fix e2e tests and gas default (#7267)
* Add extra delay after second send3eth.click() in the 'adds multiple transactions' test

* Remove use of ARBITRARY_HIGH_BLOCK_GAS_LIMIT as fallback
2019-10-08 14:14:20 -03:00
Dan J Miller
38df64783d Ensure correct tx category when sending to contracts without tx data (#7252)
* Ensure correct transaction category when sending to contracts but there is no txParams data

* Update gas when pasting address in send

* Gracefully fall back is send.util/estimateGas when blockGasLimit from background is falsy

* Remove network request frontend fallback for blockGasLimit

* Add some needed slow downs to e2e tests
2019-10-08 04:29:37 +09:00
Mark Stacey
9541d1e281
Don't wait for 3Box initialization during login (#7242)
The 3Box initialization is triggered by login, but it no longer blocks
the login from finishing. The 3Box initialization is designed to run in
the background, so there's no reason to block on it.
2019-10-02 16:12:20 -03:00
ricky
5f254f7325 Add advanced setting to enable editing nonce on confirmation screens (#7089)
* Add UseNonce toggle

* Get the toggle actually working and dispatching

* Display nonce field on confirmation page

* Remove console.log

* Add placeholder

* Set customNonceValue

* Add nonce key/value to txParams

* remove customNonceValue from component state

* Use translation file and existing CSS class

* Use existing TextField component

* Remove console.log

* Fix lint nits

* Okay this sorta works?

* Move nonce toggle to advanced tab

* Set min to 0

* Wrap value in Number()

* Add customNonceMap

* Update custom nonce translation

* Update styles

* Reset CustomNonce

* Fix lint

* Get tests passing

* Add customNonceValue to defaults

* Fix test

* Fix comments

* Update tests

* Use camel case

* Ensure custom nonce can only be whole number

* Correct font size for custom nonce input

* UX improvements for custom nonce feature

* Fix advanced-tab-component tests for custom nonce changes

* Update title of nonce toggle in settings

* Remove unused locale message

* Cast custom nonce to string in confirm-transaction-base.component

* Handle string conversion and invalid values for custom nonces in handler

* Don't call getNonceLock in tx controller if there is a custom nonce

* Set nonce details for cases where nonce is customized

* Fix incorrectly use value for deciding whether to getnoncelock in approveTransaction

* Default nonceLock to empty object in approveTransaction

* Reapply use on nonceLock in cases where customNonceValue in approveTransaction.

* Show warning message if custom nonce is higher than MetaMask's next nonce

* Fix e2e test failure caused by custom nonce and 3box toggle conflict

* Update nonce warning message to include the suggested nonce

* Handle nextNonce comparison and update logic in lifecycle

* Default nonce field to suggested nonce

* Clear custom nonce on reject or confirm

* Fix bug where nonces are not shown in tx list on self sent transactions

* Ensure custom nonce is reset after tx is created in background

* Convert customNonceValue to number in approve tranasction controller

* Lint fix

* Call getNextNonce after updating custom nonce
2019-09-27 00:30:36 -04:00
Dan J Miller
970e90ea70
Add migration on 3box imports and remove feature flag (#7209)
* Delete unused code

* Run threebox imports through migrations

* Remove 3box feature flag

* Remove unnecessary use of 'type' in threebox._updatePlugin

* Fix threebox controller getLastUpdated

* Turn off threebox by default

* Rename restoredFromThreeBox to showRestorePrompt

* Remove accientally added method from threebox controller

* Restore from threebox on import from unlock screen

* Throw on non 404 errors from Box.getconfig in new3Box
2019-09-26 03:24:52 -04:00
Dan J Miller
1bd22b58c0
Add a/b test for full screen transaction confirmations (#7162)
* Adds ab test controller with a fullScreenVsPopup test

* Add migration for fullScreenVsPopup state

* Move abtest state under an 'abtests' object.

* MetaMask shows fullScreen group of a/b test unapproved txs in a full browser tab

* Ensure cancel metrics event in confirm-transaction-base.component.js is sent in all cases

* Switch to existing tab for unapproved tx if it exists when opening in full screen

* Send metrics event for entering a/b test from confirm screen

* Fix lint, unit and integration tests related to a/b test code

* Remove unnecessary tabs.query call in triggerUiInNewTab
2019-09-24 17:08:38 -04:00
Jenny Pollack
e86cebde3b address book entries by chainId (#7205) 2019-09-21 14:36:05 -03:00
Jenny Pollack
03f216e27c add goerli to incoming tx 2019-09-18 10:04:39 -07:00
Dan J Miller
5641f1be29
Fix recipient field of approve screen (#7171) 2019-09-16 17:05:21 -02:30
Dan J Miller
7985f4f4f8
3box integration 2.0 (#6972)
* Adds threebox controller

* Adds threebox approval modal

* Fix unit tests and lint after addition of threebox

* Correct threebox behaviour after rejecting request for backup; fixes e2e tests.

* Update threebox controller for automatic syncing

* Ensure frontend locale updates when preferences are changed via direct update within controller

* Add toggle in settings for 3box syncing

* Update threebox controller for latest 3box version

* Delete unnecessary frontend changes for threebox integration

* Backing up address book contacts with threebox

* Update unit tests for 3box-integration additions

* Only enable threebox by default for new wallets

* Mock globals for correct unit tests

* 3box '1.10.2' -> '^1.10.2'

* Correct capilalization on 3Box

* Use log.debug instead of console.log in threebox controller

* Update yarn.lock

* Remove edge build

* Split 3box module into background deps js file

* extra bundle opts for bg-libs

* sync yarn.lock

* new3Box logic

* Show confirm threebox restore after import

* Remove bg-libs.js from manifest file for dev builds

* Switch 3Box controller to using the spaces api (instead of the profile api)

* Finalize switching to spaces api and only restoring from 3box after import

* Update metamask-controller-test.js for threebox controller changes

* Make threebox modal style consistent with others and update success button wording

* Use mock 3box when in test

* Correct 3box modal header

* Remove unnecessary property of threebox controller provider

* Remove unnecessary method calls after restoration from 3box in the threebox-restore-confirm modal.

* Replace setThreeBoxSyncingPermission calls in routes/index.js with turnThreeBoxSyncingOn

* Replace erroneous use of  with

* Replace erroneous use of threeboxSyncing with threeBoxSyncingAllowed in advancted-tab directory

* Lint fixes for 3box changes

* Log errors encountered when updating 3Box

* Remove unnecessary parameter from state update

* Add timeout to initial 3Box sync

The initial 3Box sync will now timeout after 1 minute. If the timeout
is triggered, 3Box is disabled and cannot be re-enabled unless the
initial sync does finally finish. If it never finishes, 3Box cannot
be enabled unless the extension is reinstalled.

The Advanced Settings page was updated to show this option as disabled
in that circumstance, with a new discription explaining why it's
disabled. The UI here could certainly be improved.

Additionally, "on" and "off" labels were added to the toggle to match
the other toggles on the Advanced Settings page.

* Use non-minified 3Box module

We had previously used the minified 3Box module to avoid a build error
encountered when `envify` was processing the `libp2p` module (which is
used by 3Box). The build would fail because `esprima` (used by `envify`)
is incompatible with the object spread/rest operator (which is used in
`libp2p`).

That issue has been solved by adding a global Babelify transformation
specifically for transpiling out the object rest/spread operator from
dependencies. It has been targetted to only affect `libp2p` to avoid
extending the build time too much. This workaround can be used until
a new version of `esprima` is released that includes this bug fix.

* Use app key addresses for threebox

* Replace use of modal for confirming 3box restoration with a home notification

* Adds e2e tests for restoring from threebox

* Update eth-keyring-controller to 5.1.0

* Correct parameters passed to getAppKeyAddress in threebox.js

* Add prefix to origin passed to getAppKeyAddress in threebox.js

* Remove unused locale message.

* Prevent CORS errors in firefox e2e tests

* Ensure extraneous scripts are excluded from the local test dev build

* Move threeBoxLastUpdate state from home.component to redux

* Threebox PR code cleanup

* Always use first address when initializing threebox

* Replace setRestoredFromThreeBox api with setRestoredFromThreeBoxToFalse and setRestoredFromThreeBoxToTrue

* Update development/metamaskbot-build-announce.js to include ui-libs and bg-libs in hard coded bundle list

* Update test/e2e/threebox.spec.js to use new helpers added with pull #7144

* Make setFeatureFlag available on the ui window during testing

* Hide threebox feature behind a feature flag that can only be activated via dev console

* Remove unnecessary migration of threebox feature flag

* Prevent this.init() call in threebox constructor if feature flag is not turned on

* Prevent threebox notification from showing if feature flag is falsy

* http://localhost/8889 -> http://localhost/* in gulp manifest:testing tasks
2019-09-16 14:41:01 -02:30
Erik Marks
38f6550951 fix rinkeby spelling (#7148) 2019-09-10 12:51:34 -10:00
kumavis
ef3f7b77f2 test:integration - fix renamed test data file 2019-09-11 00:13:21 +08:00
kumavis
8eb3e4705a lint fix 2019-09-11 00:11:49 +08:00
kumavis
b2e1f14039 test:e2e - fix bail condition 2019-09-10 23:45:43 +08:00
kumavis
ded3b7df62 test:e2e - fix responsie argument 2019-09-10 23:43:59 +08:00
kumavis
d2376ac268 test:e2e - refactor missed spec file 2019-09-10 23:43:41 +08:00
kumavis
17e7b1a8cb test:e2e - only overwrite window.fetch once per session 2019-09-10 23:10:24 +08:00
kumavis
43007555bd test:e2e - rework fetch-mocks 2019-09-10 23:04:03 +08:00
kumavis
581763d510 test:e2e - add extra delay before closing popups 2019-09-10 21:05:03 +08:00
kumavis
95b1cfd282 test:e2e - factor out prepareExtensionForTesting 2019-09-10 21:05:03 +08:00
kumavis
3afd69b3ec test - e2e - dedupe fetchMocking + compose script as fn 2019-09-10 21:05:03 +08:00
Dan J Miller
7af902e500
Make chainId available in the metamask-inpage-provider (#7110)
* Make chainId available in the metamask-inpage-provider

* Update metamask-inpage-provider to 2.1.0

* Add e2e tests for ethereum.on events

* Move chainId constants to lib/enums.js

* Don't use new chainId enums in createInfuraClient

* Fix app/scripts/lib/select-chain-id.js
2019-09-09 22:01:34 -02:30
Mark Stacey
5363d6aa2a
Prevent multiple warnings for the same locale message (#7091)
* Prevent multiple warnings for the same locale message

Our i18n helper issues warnings whenever a requested message is
missing. These warnings are helpful in assisting translation efforts,
but they can be distracting otherwise. They're especially problematic
for locales that are missing many messages. My browser ended up
crashing on more than one occasion due to the sheer volume of warnings.

The warning has been updated to only be issued once per missing key.
This required updating the method to pass in the current locale. The
current locale was added to the warning itself as well, which could be
helpful for cases where a message is missing in both the current locale
and the fallback ('en').

* Change locale and localeMessages as single action

Updating the current locale and the locale messages resulted in two
renders, and during the first the state was inconsistent (it would say
the locale had changed to the new one, but still be using the old set
of locale messages). Instead the locale is now updated with one atomic
action.

This was required after adding the locale to the missing locale message
warning, as otherwise it would say the message was missing from the
wrong locale.
2019-09-06 10:47:07 -03:00
Mark Stacey
1e7b37d1cc
Combine fetch-with-timeout implementations (#7084)
There were two competing utility functions for calling fetch with a
timeout. They have been combined into one.
2019-09-04 17:00:11 -03:00
Mark Stacey
daa20b4b63
Return after rejecting promise in action (#7079)
* Add missing test descriptions

* Fix async tests that expect a rejection

These tests expected the function under test to return a rejected
promise, and had assertions to be run in the `catch` clause. However,
the tests would still pass if the function didn't reject, with
the assertions never being run.

The tests have been updated to fail if the function doesn't throw.

* Handle ignored promise rejection

In the case where `forceUpdateMetamaskState` rejects, the function
`setSeedPhraseBackedUp` would never resolve. It has been updated to
pass along the rejection instead.

* Return after rejecting promise in action

A few actions would continue after encountering an error, resulting in
errors being compounded. Instead all actions will now return after
encountering an error (which it looks like was the intention in these
cases anyway).
2019-08-31 13:34:27 -03:00
Frankie
f6d25357db
transactions:tx-state-manager - optionally take a function as a search param (#7078) 2019-08-29 14:57:28 +02:00
Whymarrh Whitby
ecbde20949
Remove ComputedbalancesController (#7057) 2019-08-22 10:26:43 -02:30
Whymarrh Whitby
ef3859ff77
Add toggle for incoming transactions (#7049) 2019-08-21 16:12:14 -02:30
Whymarrh Whitby
e47448362d
Bug fixes for incoming transactions (#7043)
* Fix styling of `.transaction-list`
* Filter `incomingTxListSelector` by network as well
* Start and stop block tracker polling in incoming tx controller
* Add fetch with abort in bg for `IncomingTxController`
2019-08-20 16:22:00 -02:30
Dan J Miller
821529622e Fetch & display received transactions (#6996) 2019-08-16 16:24:10 -02:30
Whymarrh Whitby
247659ca65
Connections settings tab (#7013)
* Nix notification for Share Address

* Add Connections settings tab in place of privacy mode toggle

* Split ProviderApprovalController into two stores

* Remove privacyMode feature flag altogether

* Add migration to remove privacyMode feature flag
2019-08-15 18:37:18 -02:30
Whymarrh Whitby
e321feb92d
Fix Firefox e2e test command on CI (#7000)
* Skip a few Firefox tests to get them passing again
* ci: Fix Firefox e2e test command

This is my bad, introduced in 7fc84f3cc0
2019-08-13 10:27:18 -02:30
Whymarrh Whitby
ceace71bf5
Remove unused lostAccounts state (#6979) 2019-08-08 17:03:10 -02:30
Mark Stacey
12e055a37c
Close window after opening fullscreen (#6966)
* Add background environment type

The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.

Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.

[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL

* Add note regarding a missing manifest permission

The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.

* Close window after opening full screen

The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.

We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.

Closes #6513, #6685
2019-08-08 11:50:32 -03:00
Mark Stacey
14e31cb9be
Allow overriding GANACHE_ARGS for e2e tests (#6970)
This allows the environment variable `GANACHE_ARGS` to override the
default set of optional flags used. By default, the flag `--quiet` is
set. Setting `GANACHE_ARGS` will override the default.

For example, you can now run the e2e tests without the `--quiet` flag
by running this:

```bash
GANACHE_ARGS='' yarn test:e2e:chrome
```

This change also prevents the arguments from being needlessly repeated.
Previously this script accidentally build up `GANACHE_ARGS`, adding to
the set of flags used with each change in arguments.

This PR is based upon #6870
2019-08-07 08:52:05 -03:00
Dan J Miller
010e3927da
Show seed phrase challenge in browser (#6961)
* Open backup challenge screen, prompted from notification, in browser window

* Remove no longer used showingSeedPhraseBackupAfterOnboarding related code

* Make incremental-security.spec.js click through the seed phrase success screen
2019-08-06 00:54:19 -02:30
Dan J Miller
165f44d3a4
Address book name save fix (#6945)
* Fix address book name saving and ens input errors on good inputs on unsupported networks

* Add initial e2e test for address book send flow.

* No longer need to click recipient row in e2e tests

* Click write button in address book e2e test on seed confirm screen

* Use correct seed phrase and private key in address-book.spec tests
2019-08-02 20:30:50 -02:30
Dan J Miller
9d5be5d29f
New notification fixes (#6955)
* Replace use of backup-notification with use of home notification

* Pin notifications relative to window

* Remove unneeded isRequired condition on some home.component properties

* Refactor rendering of home notifications

* UX for multiple notifications

* Adds dismissal to provider request notification.

* Fix test failures

The e2e tests have been updated to reference `home-notification`
classnames instead of the removed `background-notification`. The
active tab proptypes and default values were updated as well.
2019-08-02 18:01:26 -02:30
Mark Stacey
6a0dbcdb31
Upgrade to Babel 7 (#6942)
Babel 7 moved to a new configuration format, and they've scoped all of
their packages under `@babel/`. This brings MetaMask in-line with
dependencies we use that _already_ use Babel 7, and it eliminates a
few unfortunate edge cases that can prevent dependencies from being
correctly transpiled.
2019-08-02 13:17:20 -02:30
Mark Stacey
a6d4725e5c
Fix incremental security e2e test (#6948) 2019-08-02 11:52:18 -02:30
Mark Stacey
bb87a0b92c
Add migration to remove seedWords state (#6937)
The `seedWords` state was removed from the PreferencesController
recently in #6920. That state hadn't been used in some time, and there
was a long period during which `seedWords` was periodically scrubbed
from the state, so it's highly unlikely that it still exists in state
for most users. It's hard to guarantee that it _doesn't_ though,
especially if a user hasn't opened MetaMask in a few months.
2019-08-02 10:28:25 -02:30
Christopher Cooper
b7eae4ba80 split AccountDetails into a separate component (#6943) 2019-08-02 10:06:31 -02:30