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

789 Commits

Author SHA1 Message Date
Frankie
514be408f8
I#6704 eth_getTransactionByHash will now check metamask's local history for pending transactions (#7327)
* tests - create tests for pending middlewares

* transactions - add r,s,v values to the txMeta to match the JSON rpc response

* network - add new middleware for eth_getTransactionByHash that the checks pending tx's for a response value

* transactions/pending - use getTransactionReceipt for checking if tx is in a block

* meta - file rename
2019-10-30 12:15:54 -10:00
Frankie
51e5220d5e
I#3669 ignore known transactions on first broadcast and continue with normal flow (#7328)
* transactions - ignore known tx errors

* tests - test ignoreing Transaction Failed: known transaction message
2019-10-30 11:40:33 -10:00
Mark Stacey
8dfb0e8154
Add hostname and extensionId to site metadata (#7218)
If the extension ID is set, an alternate title and subtitle are used
for the Connect Request screen. The title is always `External
Extension`, and the subtitle is `Extension ID: [id]` instead of the
origin (which would just be `[extension-scheme]://[id]` anyway).

The hostname for the site is used as a fallback in case it has no
title.

The artificial hostname set for internal connections has been renamed
from 'MetaMask' to 'metamask' because URL objects automatically
normalize hostnames to be all lower-case, and it was more convenient to
use a URL object so that the parameter would be the same type as used
for an untrusted connection.
2019-10-29 13:14:41 -03: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
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
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
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
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
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
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
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
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
Whymarrh Whitby
d1e47a30bc
Add test cases for migration 34 (#6938) 2019-08-01 14:03:20 -02:30
Whymarrh Whitby
4d88e1cf86 Enable indent linting via ESLint (#6936)
* Enable indent linting via ESLint

* yarn run lint:fix
2019-07-31 10:17:11 -10:00
Dan J Miller
e9c7df28ed
Address book send plus contact list (#6914)
* Style Send Header

* Move Send to-row to send view and restyle

* Add "Recents" group to select recipient view

* Rename SendToRow to AddRecipient

* Basic UI and Layout

* New ENSInput component

* wip - fuzzy search for input

* small refactor

* Add Dialog

* contact list initial

* initial error on invalid address

* clean up edit

* Click to open modal

* Create AddToAddressBookModal component

* Modal styling and layout

* modal i18n

* Add to Addressbook

* ens wip

* ens wip

* ENS Resolution

* Reset input

* Send to explicit address

* Happy Path Complete

* Add back error checking

* Reset send-to when emptying input

* Add back warning object

* Fix linter

* Fix unit test #1 - fix import paths

* Remove dead tests

* One more to go

* Fix all unit tests

* add unit test for reducers and actions

* test rendering AddRecipient

* Add tests for dialog boxes in AddRecipient

* Add test for validating

* Fix linter

* Fix e2e tests

* Token send e2e fix

* Style View Contact

* Style edit-contact

* Fix e2e

* Fix from-import-beta-ui e2e spec

* Make section header say "add recipient” by default

* Auto-focus add recipient input

* Update placeholder text

* Update input title font size

* Auto advance to next step if user paste a valid address

* Ellipsify address when recipient is selected

* Fix app header background color on desktop

* Give each form row a margin of 16px

* Use .container/.component naming pattern for ens-input

* Auto-focus on input when add to addressbook modal is opened; Save on Enter

* Fix and add unit test

* Fix selectors name in e2e tests

* Correct e2e test token amount for address-book-send changes

* Adds e2e test for editing a transaction

* Delete test/integration/lib/send-new-ui.js

* Add tests for amount max button and high value error on send screen to test/e2e/metamask-ui.spec.js

* lint and revert to address as object keys

* add chainId based on current network to address book entry

* fix test

* only display contacts for the current network

* Improve ENS message when not found on current network

* Add error to indicate when network does not support ENS

* bump gaba

* address book, resolve comments

* Move contact-list to its own component

* De-duplicate getaddressbook selector and refactor name selection logic in contact-list-tab/

* Use contact-list component in contact-list-tab.component (i.e. in settings)

* Improve/fix settings headers for popup and browser views

* Lint fixes related to address book updates

* Add 'My accounts' page to settings address book

* Update add new contact button in settings to match floating circular design

* Improve styles of view contact page

* Improve styles and labels of the add-contact.component

* Further lint fixes related to address book updates

* Update unit tests as per address book updates

* Ensure that contact list groups are sorted alphabetically

* Refactor settings component to use a container for connection to redux; allow display of addressbook name in settings header

* Decouple ens-input.component from send context

* Add ens resolution to add contact screen in settings

* Switching networks when an ens address is shown on send form removes the ens address.

* Resolve send screen search for ensAddress to matching address book entry if it exists

* Show resolved ens icon and address if exists (settings: add-contact.component)

* Make the displayed and copied address in view-contact.component the checksummed address

* Default alias state prop in AddToAddressBookModal to empty string

* Use keyCode to detect enter key in AddToAddressBookModal

* Ensure add-contact component properly updates after QR code detection

* Fix display of all recents after clicking 'Load More' in contact list

* Fix send screen contact searching after network switching

* Code cleanup related to address book changes

* Update unit tests for address book changes

* Update ENS name not found on network message

* Add ens registration error message

* Cancel on edit mode takes user back to view screen

* Adds support for memo to settings contact list view and edit screens

* Modify designs of edit and view contact in popup environment

* Update settings content list UX to show split columns in fullscreen and proper internal navigation

* Correct background address book API usages in UI
2019-07-31 17:26:44 -02:30
Mark Stacey
1112277cd6
Remove seedWords completely from metamask state (#6920)
`seedWords` used to be stored on the metamask state temporarily at
certain points. This hasn't been the case since #5994, but references
to this state remained. All of the logic remained for correctly updating
these `seedWords`, handling them during navigation, and scrubbing them
from the state.

However the state was never updated in practice. The `seedWords` are
still returned by `verifySeedPhrase`, and they're still stored in
component state in a few places. But they aren't ever set in the Redux
metadata state or the Preferences controller.

All references to this state have been removed, along with any logic
for interacting with this state. A few unused actions were removed as
well.
2019-07-26 10:35:21 -03:00
Mark Stacey
95f198550e
Declare variables before use (#6806)
While working on #6805, I noticed that many variables were being used
before they were declared. Technically this worked fine in practice
because we were using the `transform-es2015-block-scoping` Babel plugin,
which transforms `let` and `const` to `var`, which is hoisted. However,
after removing that Babel transformation, many things broke.

All instances of variables or classes being used before declared have
been fixed.

The `no-use-before-define` eslint rule has been added to catch these
cases going forward. The rule is disabled for function declarations for
the moment, because those are always hoisted. We could disable that too
if we want to, but it's purely stylistic and would require a lot more
changes.
2019-07-05 14:01:34 -03:00
Akshit Kr Nagpal
d16d6f483c Validate txParams in TransactionStateManager.addTx (#6713)
* Normalize and Validate txParams in TransactionStateManager.addTx too

* Added Tests

* Updated normalizeAndValidateParams to return the new txParams
2019-06-29 00:51:51 +02:00
Paul Bouchon
47024fd9a5
feature: integrate gaba/CurrencyRateController (#6570) 2019-05-31 18:14:22 -04:00
Frankie
2b5c7b82a9
transactions/deps - use broken out nonce-tracker module (#6555) 2019-05-21 17:17:09 +02:00
Frankie
a34103987a
drop transactions who's nonce is lower then the known network nonce but were not included in a block (#6388)
* transactions/pending - check nonce against the network and mark as dropped if not included in a block

* transactions/pending - unifiy "dropped" txs

* transactions/pending - test - fix for new expected behavior

* fix comment

* transactions/pending - clean up dropped event

* fix spelling

Co-Authored-By: frankiebee <frankie.diamond@gmail.com>

* nit fix

* test/tx-pending - clarify test description
2019-05-16 07:36:53 +02:00
Paul Bouchon
e57ffbed59
feature: integrate gaba/ShapeShiftController (#6569) 2019-05-14 14:38:55 -04:00
Dan J Miller
b81c4e5c98 Set a default value for code in _determineTransactionCategory (#6604)
* Set a default value for code in _determineTransactionCategory

* Adds e2e tests that fail when token txs without gas param are not properly handled.

* Adds unit tests for _determineTransactionCategory

* Base error throwing and simple gas setting in estimateTxGas on transactionCategory
2019-05-14 14:14:07 -04:00
Thomas Huang
08e8fb21dc
Merge pull request #6568 from MetaMask/feature/gaba-phishing-controller
feature: integrate gaba/PhishingController
2019-05-10 13:43:20 -07:00
Dan J Miller
13be683701
New settings custom rpc form (#6490)
* Add networks tab to settings, with header.

* Adds network list to settings network tab.

* Adds form to settings networks tab and connects it to network list.

* Network tab: form adding and editing working

* Settings network form properly handles input errors

* Add translations for settings network form

* Clean up styles of settings network tab.

* Add popup-view styles and behaviour to settings network tab.

* Fix save button on settings network form

* Adds 'Add Network' button and addMode to settings networks tab

* Lint fix for settings networks tab addition

* Fix navigation in settings networks tab.

* Editing an rpcurl in networks tab does not create new network, just changes rpc of old

* Fix layout of settings tabs other than network

* Networks dropdown 'Custom Rpc' item links to networks tab in settings.

* Update settings sidebar networks subheader.

* Make networks tab buttons width consistent with input widths in extension view.

* Fix settings screen subheader height in popup view

* Fix height of add networks button in popup view

* Add optional label to chainId and symbol form labels in networks setting tab

* Style fixes for networks tab headers

* Add ability to customize block explorer used by custom rpc

* Stylistic improvements+fixes to custom rpc form.

* Hide cancel button.

* Highlight and show network form of provider by default.

* Standardize network subheader name to 'Networks'

* Update e2e tests for new settings network form

* Update unit tests for new rpcPrefs prop

* Extract blockexplorer url construction into method.

* Fix broken styles on non-network tabs in popup mode

* Fix block explorer url links for cases when provider in state has not been updated.

* Fix vertical spacing of network form

* Don't allow click of save button on network form if nothing has changed

* Ensure add network button is shown in popup view

* Lint fix for networks tab

* Fix block explorer url preference setting.

* Fix e2e tests for custom blockexplorer in account details modal changes.

* Update integration test states to include frequentRpcList property

* Fix some capitalizations in en/messages.json

* Remove some console.logs added during custom rpc form work

* Fix external account link text and url for modal and dropdown.

* Documentation, url validation, proptype required additions and lint fixes on network tab and form.
2019-05-09 14:57:14 -02:30
bitpshr
77d3bc252d feature: integrate gaba/PhishingController 2019-05-08 17:56:52 -04:00
Whymarrh Whitby
094e4cf555 Check for unused function arguments (#6583)
* eslint: Check for unused function arguments

* eslint: Ignore unused '_' in argument list

Also allow any number of '_' e.g., '__' or '___' which is to be used sparingly

* Remove and rename unused arguments
2019-05-08 15:51:33 -04:00
Whymarrh Whitby
1de7dc9b41 Remove nock#restore call from actions.spec.js
This call was unmocking all of our HTTP requests, allowing further test cases
to hit the network. Calling nock#restore should not be required.
2019-05-07 13:48:50 -02:30
Paul Bouchon
0db0a187c8 feature: add Goerli support (#6459) 2019-04-17 15:04:49 -02:30
Thomas Huang
a46ec83c9b Remove NoticeController (#6382) 2019-04-01 22:33:54 -02:30
kumavis
ed381f5b2a test - unit - ui - actions - setCompletedOnboarding - fix stub to call callback 2019-03-29 13:10:42 +08:00
kumavis
02585c0bd0 lint fix 2019-03-29 12:51:54 +08:00
kumavis
846038a69c notice-controller - make markAllNoticesRead sync 2019-03-29 12:39:29 +08:00
kumavis
e04f0c877b lib - nodeify - correctly wrap synchronous functions 2019-03-29 12:37:40 +08:00
kumavis
a64855ef49 notices - markAllNoticesRead - use async/await 2019-03-29 12:03:31 +08:00