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

279 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Whymarrh Whitby
274a9ecf53 yarn lint --fix 2019-12-03 17:20:55 -03:30
Dan Finlay
f519fa1ed3
Connect distinct accounts per site (#7004)
* add PermissionsController

remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata

add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales

Add external extension id to metadata (#7396)

update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages

* Login Per Site UI (#7368)

* LoginPerSite original UI changes to keep

* First commit

* Get necessary connected tab info for redirect and icon display for permissioned sites

* Fix up designs and add missing features

* Some lint fixes

* More lint fixes

* Ensures the tx controller + tx-state-manager orders transactions in the order they are received

* Code cleanup for LoginPerSite-ui

* Update e2e tests to use new connection flow

* Fix display of connect screen and app header after login when connect request present

* Update metamask-responsive-ui.spec for new item in accounts dropdown

* Fix approve container by replacing approvedOrigins with domainMetaData

* Adds test/e2e/permissions.spec.js

* Correctly handle cancellation of a permissions request

* Redirect to home after disconnecting all sites / cancelling all permissions

* Fix display of site icons in menu

* Fix height of permissions page container

* Remove unused locale messages

* Set default values for openExternalTabs and tabIdOrigins in account-menu.container

* More code cleanup for LoginPerSite-ui

* Use extensions api to close tab in permissions-connect

* Remove unnecessary change in domIsReady() in contentscript

* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.

* Adds getOriginOfCurrentTab selector

* Adds IconWithFallback component and substitutes for appropriate cases

* Add and utilize font mixins

* Remove unused  method in disconnect-all.container.js

* Simplify buttonSizeLarge code in page-container-footer.component.js

* Add and utilize getAccountsWithLabels selector

* Remove console.log in ui/app/store/actions.js

* Change last connected time format to yyyy-M-d

* Fix css associated with IconWithFallback change

* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes

* Code cleanup for LoginPerSite-ui

* Use reusable function for modifying openNonMetamaskTabsIDs in background.js

* Enables automatic switching to connected account when connected domain is open

* Prevent exploit of tabIdOriginMap in background.js

* Remove unneeded code from contentscript.js

* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs

* Design and styling fixes for LoginPerSite-ui

* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts

* Front end changes to support display of lastConnected time in connected and permissions screens

* Fix lint errors

* Refactor structure of permissionsHistory

* Fix default values and object modifications for domain and permissionsHistory related data

* Fix connecting to new accounts from modal

* Replace retweet.svg with connect-white.svg

* Fix signature-request.spec

* Update metamask-inpage-provider version

* Fix permissions e2e tests

* Remove unneeded delay from test/e2e/signature-request.spec.js

* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec

* Use requestAccountTabIds strategy for determining tab id that opened a given window

* Improve default values for permissions requests

* Add some message descriptions to app/_locales/en/messages.json

* Code clean up in permission controller

* Stopped deep cloning object in mapObjectValues

* Bump metamask-inpage-provider version

* Add missing description in app/_locales/en/messages.json

* Return promises from queryTabs and switchToTab of extension.js

* Remove unused getAllPermissions function

* Use default props in icon-with-fallback.component.js

* Stop passing  to permissions controller

* Delete no longer used clear-approved-origins modal code

* Remove duplicate imports in ui/app/components/app/index.scss

* Use URL instead of regex in getOriginFromUrl()

* Add runtime error checking to platform, promise based extension.tab methods

* Support permission requests from external extensions

* Improve font size and colour of the domain origin on the permission confirmation screen

* Add support for toggling permissions

* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions

* Remove unused code from LoginPerSite-ui branch

* Ensure modal closes on Enter press for new-account-modal.component.js

* Lint fix

* fixup! Login Per Site UI (#7368)

* Some code cleanup for LoginPerSite

* Adds UX for connecting to dapps via the connected sites screen (#7593)

* Adds UX for connecting to dapps via the connected sites screen

* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask

* Delete unused permissions controller methods

* Fixes two small bugs in the LoginPerSite ui (#7595)

* Restore `providerRequest` message translations (#7600)

This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.

* Login per site no sitemetadata fix (#7610)

* Support connected sites for which we have no site metadata.

* Change property containing subtitle info often populated by origin to a more accurate of purpose name

* Lint fix

* Improve disconnection modal messages (#7612)

* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages

* Update disconnectAccountModalDescription app/_locales/en/messages.json

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

* Improve disconnectAccount modal message clarity

* Adds cancel button to the account selection screen of the permissions request flow (#7613)

* Fix eth_accounts permission language & selectability (#7614)

* fix eth_accounts language & selectability

* fix MetaMask capitalization in all messages

* Close sidebar when opening connected sites (#7611)

The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.

It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.

I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.

* Reject permissions request upon tab close (#7618)

Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617

* Handle tab update failure (#7619)

`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.

* Login per site tab popup fixes (#7617)

* Handle redirect in response to state update in permissions-connect

* Ensure origin is available to permissions-connect subcomponents during redirect

* Hide app bar whenever on redirect route

* Improvements to handling of redirects in permissions-connect

* Ensure permission request id change handling only happens when page is not null

* Lint fix

* Decouple confirm transaction screen from the selected address (#7622)

* Avoid race condtion that could prevent contextual account switching (#7623)

There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.

The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.

* Only redirect back to dapp if current tab is active (#7621)

The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.

* Fix JSX style lint errors

* Remove unused state
2019-12-03 09:35:56 -08:00
Whymarrh Whitby
e61745a821
Enable no-var rule for ESLint (#7590)
* eslint: Enable no-var rule
* yarn lint --fix
2019-12-03 11:22:01 -03:30
Whymarrh Whitby
926c8848f1
Enable default-case rule for ESLint (#7572)
* eslint: Enable default-case rule

* Fix missing default cases

* Fix tests failing due to incorrect assumptions
2019-11-27 12:38:35 -03:30
Mark Stacey
f763979bed
Add support for one-click onboarding (#7017)
* Add support for one-click onboarding

MetaMask now allows sites to register as onboarding the user, so that
the user is redirected back to the initiating site after onboarding.
This is accomplished through the use of the `metamask-onboarding`
library and the MetaMask forwarder.

At the end of onboarding, a 'snackbar'-stype component will explain to the
user they are about to be moved back to the originating dapp, and it will
show the origin of that dapp. This is intended to help prevent phishing
attempts, as it highlights that a redirect is taking place to an untrusted
third party.

If the onboarding initiator tab is closed when onboarding is finished,
the user is redirected to the onboarding originator as a fallback.

Closes #6161

* Add onboarding button to contract test dapp

The `contract-test` dapp (run with `yarn dapp`, used in e2e tests) now
uses a `Connect` button instead of connecting automatically. This
button also serves as an onboarding button when a MetaMask installation
is not detected.

* Add new static server for test dapp

The `static-server` library we were using for the `contract-test` dapp
didn't allow referencing files outside the server root. This should
have been possible to work around using symlinks, but there was a bug
that resulted in symlinks crashing the server.

Instead it has been replaced with a simple static file server that
will serve paths starting with `node_modules` from the project root.
This will be useful in testing the onboarding library without vendoring
it.

* Add `@metamask/onboarding` and `@metamask/forwarder`

Both libraries used to test onboarding are now included as dev
dependencies, to help with testing. A few convenience scripts
were added to help with this (`yarn forwarder` and `yarn dapp-forwarder`)
2019-11-22 13:03:51 -04:00
Mark Stacey
5c356a4cac
Show transaction fee units on approve screen (#7468)
The units for the amounts shown on the approve screen in the
transaction fee section were missing. It appears that they were present
in an early version of the approve screen (#7271) but they got lost
somewhere along the way.
2019-11-19 09:41:28 -04:00
Dan Miller
f8aaec6d32 Adds and end to end test for typed signature requests 2019-11-14 10:37:58 -03:30
Dan J Miller
2673eef3c4
Redesign approve screen (#7271)
* Redesign approve screen

* Add translations to approve screen components

* Show account in header of approve screen

* Use state prop bool for unlimited vs custom check in edit-approval-permission

* Set option to custom on input change in edit-approval-permission

* Allow setting of approval amount to unlimited in edit-approval-permission

* Fix height of confirm-approval popup

* Ensure decimals prop passted to confirm-approve.component is correct type

* Ensure first param passed to calcTokenValue in confirm-approve.util is the correct type

* Fix e2e test of permission editing

* Remove unused code from edit-approval-permission.container
2019-11-05 11:43:48 -03:30
Mark Stacey
fe28e0d134
Cleanup beforeunload handler after transaction is resolved (#7333)
* Cleanup beforeunload handler after transaction is resolved

The notification window was updated to reject transactions upon close
in #6340. A handler that rejects the transaction was added to
`window.onbeforeunload`, and it was cleared in `actions.js` if it was
confirmed or rejected.

However, the `onbeforeunload` handler remained uncleared if the
transaction was resolved in another window. This results in the
transaction being rejected when the notification window closes, even
long after the transaction is submitted and confirmed. This has been
the cause of many problems with the Firefox e2e tests.

Instead the `onbeforeunload` handler is cleared in the
`componentWillUnmount` lifecycle function, alongside where it's set in
the first place. This ensures that it's correctly unset regardless
of how the transaction was resolved, and it better matches user
expectations.

* Fix indentation and remove redundant export

The `run-all.sh` Bash script now uses consistent indentation, and is
consistent about only re-exporting the Ganache arguments when they
change.

* Ensure transactions are completed before checking balance

Various intermittent e2e test failures appear to be caused by React
re-rendering the transaction list during the test, as the transaction
goes from pending to confirmed. To avoid this race condition, the
transaction is now explicitly looked for in the confirmed transaction
list in each of the tests using this pattern.

* Enable all e2e tests on Firefox

The remaining tests that were disabled on Firefox now work correctly.
Only a few timing adjustments were needed.

* Update Firefox used in CI

Firefox v70 is now used on CI instead of v68. This necessitated
rewriting the function where the extension ID was obtained because the
Firefox extensions page was redesigned.
2019-10-31 13:27:22 -03: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
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
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
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
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