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

3360 Commits

Author SHA1 Message Date
Jyoti Puri
11c61a3ead
EIP-1559 V2 UI/UX improvements (#13419) 2022-01-31 11:21:43 +05:30
Shane
3772dfee11
Added subjectType to setupProviderConnection and setupUntrustedCommunication (#13437)
These changes were split off from the snaps branch [here](https://github.com/MetaMask/metamask-extension/pull/11837#discussion_r792942834).

The `subjectType` is necessary to handle connecting to snaps using these methods.
2022-01-28 13:42:32 -08:00
yanjade
3eb99babf2
batch fix misspelling (#13449) 2022-01-28 09:09:07 -06:00
David Walsh
851fce9a3b
Enable buying MATIC on Polygon, BNB on BSC, AVAX on Avalanche, FTM on Fantom, CELO on Celo, and respective stablecoins on Transak (#13398) 2022-01-28 07:46:26 -06:00
Alex Donesky
be65eb7339
More nft ux fixes (#13388)
* a batch of nft ux fixes
2022-01-27 11:26:33 -06:00
VSaric
5579061cfa
Proper calculation of the gas limit (#12784) 2022-01-21 09:58:59 -06:00
Alex Donesky
db0230f23a
NFT UX cleanup grab-bag (#13352)
* NFT UX cleanup
2022-01-20 11:49:49 -06:00
PeterYinusa
e2a8886a05
Upgrade ganache - continued (#13354)
* remove ganache-core

* use ganache v7

* convert to hex

* lint
2022-01-20 16:56:52 +00:00
Brad Decker
c58cc631c7
implement event fragments for tx controller (#13331) 2022-01-20 10:26:39 -06:00
Alex Donesky
f7849a0b7c
Add error that redirects users to Import NFT page when they attempt to add an NFT on the Import Token page (#13271)
* Add error that redirects users to Import NFT page when they attempt to add an NFT on the Import Token page
2022-01-19 08:38:33 -06:00
Erik Marks
a5873eb7ff
Fix manually connecting sites (#13320) 2022-01-14 14:31:32 -08:00
Brad Decker
dffad6e35d
use object.values to get array for iteration (#13300) 2022-01-13 12:10:47 -06:00
Brad Decker
b820ef131b
Implement event fragments (#12251) 2022-01-12 13:31:54 -06:00
Jyoti Puri
88faef7e19
Adding user setting option for EIP-1559 V2 (#13242) 2022-01-12 00:47:56 +05:30
Niranjana Binoy
cd0892a3af
EIP-1559 V2: Use default gas preferences of user for all transactions (#13238) 2022-01-10 14:34:54 -05:00
Alex Donesky
4826c8c95e
Feat/collectibles send flow (#13048)
* Add collectibles send flow
2022-01-10 10:23:53 -06:00
Mark Stacey
3732c5f71e
Add JSDoc ESLint rules (#12112)
ESLint rules have been added to enforce our JSDoc conventions. These
rules were introduced by updating `@metamask/eslint-config` to v9.

Some of the rules have been disabled because the effort to fix all lint
errors was too high. It might be easiest to enable these rules one
directory at a time, or one rule at a time.

Most of the changes in this PR were a result of running
`yarn lint:fix`. There were a handful of manual changes that seemed
obvious and simple to make. Anything beyond that and the rule was left
disabled.
2022-01-07 12:27:33 -03:30
Elliot Winkler
af971cd5b6
Remove dupe Prettier config from ESLint config (#13234)
The ESLint config for the extension explicitly includes support for
Prettier. However, this is already being provided by our global ESLint
config (`@metamask/eslint-config`). Therefore there is no need to
include it here. In fact, this is causing weird issues where the `curly`
option is getting overridden somehow. After this change, these syntaxes
are invalid:

``` javascript
if (foo) return;
```

``` javascript
if (foo) return 'bar';
```
2022-01-06 15:56:51 -07:00
Mark Stacey
22f931e6b2
Prevent automatic rejection of confirmations (#13194)
* Prevent automatic rejection of confirmations

Confirmations are now only automatically rejected if a user explicitly
closes the notification window. If we close the window programmatically
because there are no notifications left to show, nothing gets rejected.

This partially avoids a race condition where a confirmation gets
rejected automatically without the user having seen the confirmation
first. This could happen if the confirmation was processed just as the
notification window was being closed.

It's still possible for a confirmation that the user has never seen to
get rejected as a result of the user closing the window. But at least
now it's no longer possible for a confirmation to get rejected in this
manner after the user resolves the last confirmation in the queue.

* Fix bug that prevented automatic closure detection

All windows were being detected as explicit window closures,
essentially just as they were previously, because this variable was
cleared too soon.

* Re-open popup when necessary

After the window is automatically closed, a confirmation may have been
queued up while the window was closing. If so, the popup is now re-
opened.
2022-01-05 13:39:19 -03:30
Erik Marks
75e8b4f8b9
Add missing permissions middleware hook (#13205)
Adds a missing middleware hook for `wallet_requestPermissions` that we failed to add in #12243. Also adds a runtime check that throws an error if any expected hooks are not provided to `createMethodMiddleware`.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2022-01-04 12:57:18 -08:00
Ikko Ashimine
066b78c722
Fix typo in ComposableObservableStore.js (#13151) 2022-01-04 12:59:08 -06:00
Alex Donesky
c266d4e6af
Feat/check update collectible ownership (#13110)
* Use method to check and update collectible ownership
2022-01-03 14:39:41 -06:00
Mark Stacey
8866c39623
Update the Firefox prerelease version format (#13158)
The Firefox extension version format does not support the version
format we use (SemVer), so we have to specially format the extension
version to be compatible. The format we chose was
`[major].[minor].[patch].[buildType][buildVersion]`. But when we tried
to submit a build with a version in that format, it was rejected as
invalid for unknown reasons.

The Firefox extension format has been updated to
`[major].[minor].[patch][buildType][buildVersion]`. This seems to pass
validation.
2022-01-03 12:48:10 -03:30
Mark Stacey
ae97e91443
Fix how version_name manifest field is used (#13155)
The `version_name` manifest field was being used on Chrome to store the
build type. However, Chrome intended this field to be a full
representation of the version, for display purposes. This was evident
when uploading this version to the Chrome Web Store, because it used
`flask` as the entire version.

Instead the `version_name` field now includes the full SemVer version
string. The version parsing code within the build script and in the
wallet itself have been updated accordingly.
2022-01-03 10:30:13 -03:30
Mark Stacey
fe77367837
Update the Sentry setup log with the build type (#13157)
The `environment` field we use for Sentry includes the build type for
all build types except `main`, but the log message indicating that
Sentry did not include this. This log message is useful for ensuring
that Sentry is setup correctly, so it should display the same
environment that Sentry is using. It has been updated to do just that.
2022-01-03 10:29:44 -03:30
Hassan Malik
f946c030b5
Choose accounts refactor (#13039)
* added wrapper around account list to prevent storybook from collapsing the list

* updated translation files

* added snap-connect page

* refactored account list out of the choose account component

* fixed width

* removed unnecessary scss from choose-account component, fixed props in choose account story

* removed snaps-connect page, added comments to ChooseAccount

* updated choose account subtitle text, updated styling for title & subtitle, removed redundant account list story

* updated component name, updated paths

* fixed linter errors

* added comments

* removed unused message

* removed selectAccounts key from all locales

* updated class name for account list header, updated allAreSelected function to use length checks

* Revert "removed unused message"

This reverts commit 32771bc83c08f120825ef75f0741f3034e7dbecb.

* Revert "removed selectAccounts key from all locales"

This reverts commit ccfa4a860f9a75693d893d7c404384e719de297e.

* updated locale messages to use selectAccounts key

* removed stray import

* updated scss

* updated translation key

* removed chooseAccounts key from en locale

* removed optional chaining

* changes

* updated subjectMetadata

* updated subject types

* update useOriginMetadata function to include unknown subject type

* updated permission connect header props, removed host and added subjectType to targetSubjectMetadata

* added subjectType to targetSubjectMetadata

* removed console.log

* changed prop name to iconUrl
2021-12-14 18:54:46 -05:00
Alex Donesky
1b6e58c417
Feat/collectibles the return (#12970)
* Wire collectibles frontend UI with controller data
2021-12-13 17:41:10 -06:00
Erik Marks
c03b6dd19b
Subject metadata cleanup (#13090)
This PR fixes some subject metadata-related issues that were missed in #13026.
2021-12-13 12:10:20 -08:00
Thomas Huang
c9cb2ae1a1
Jestify app/scripts/controller/network/**/*.test.js (#12985) 2021-12-10 11:25:58 -06:00
Mark Stacey
ba54a3d83b
Update ESLint config to v8 (#12886)
The ESLint config has been updated to v8. The breaking changes are:

* The Prettier rule `quoteProps` has been changed from `consistent` to
`as-needed`, meaning that if one key requires quoting, only that key is
quoted rather than all keys.
* The ESLint rule `no-shadow` has been made more strict. It now
prevents globals from being shadowed as well.

Most of these changes were applied with `yarn lint:fix`. Only the
shadowing changes required manual fixing (shadowing variable names were
either replaced with destructuring or renamed).

The dependency `globalThis` was added to the list of dynamic
dependencies in the build system, where it should have been already.
This was causing `depcheck` to fail because the new lint rules required
removing the one place where `globalThis` had been erroneously imported
previously.

A rule requiring a newline between multiline blocks and expressions has
been disabled temporarily to make this PR smaller and to avoid
introducing conflicts with other PRs.
2021-12-09 15:36:24 -03:30
Mark Stacey
670bed4c61
Add @metamask/rpc-methods package (#13027)
The `selectHooks` function has been replaced with the equivalent
function from the `@metamask/rpc-methods` package, which is
functionally equivalent.

The function was included in that package so that it could be used
elsewhere in the `snaps-skunkworks` repo. Eventually the goal is to
migrate much of our RPC logic into this package so that it can be
shared across products, and by our libraries as needed.
2021-12-09 11:22:53 -03:30
Dan J Miller
e45560859c
Support EIP-1559 on Trezor Model One (#13023)
* Support EIP-1559 on Trezor Model One

* Update unit tests

* Fix unit test

* Run yarn lavamoat:auto
2021-12-08 23:16:54 -03:30
Erik Marks
fc1ffae406
Add subject types (#13026)
This PR introduces the concept of subject _types_ to be associated with each subject in the `SubjectMetadataController`, and used for control flow in our RPC stack (`setupProviderEngine` and so forth).

We already differentiate between "types" of subjects in various places on an ad hoc basis via boolean flags (e.g. `isInternal` in our RPC stack) or the presence/absence of certain values in the subject's metadata (specifically `metadata.extensionId`). The status quo is manageable if not ideal, but will start to become untenable with the introduction of Snaps in the near future.

Therefore, this PR establishes a `SUBJECT_TYPES` enum and adds the `subjectType` property to the metadata of each subject. A new migration is added to accomplish this. Finally, we specify and `INTERNAL` subject type to distinguish internal from external requests.
2021-12-08 15:37:29 -08:00
Mark Stacey
5076e5057f
Remove nodeify (#13003)
The `nodeify` utility is no longer needed for the background API.
Instead each method is assumed to be either synchronous or Promise-
returning.

The error handling was updated to at least log the error in the case
where a method fall fails after the connection is broken.
2021-12-08 18:06:53 -03:30
Dan J Miller
c9768df149
Dispose the trezor connect iframe upon lock (#13018)
* Dispose the trezor connect iframe upon lock

* Use KEYRING_TYPES.TREZOR

* Update eth-trezor-keyring version
2021-12-08 13:55:27 -03:30
Mark Stacey
c17fa40114
Consolidate permission exports (#13012)
The permission-related modules are now all exported together in the
index of the `app/scripts/controllers/permissions` directory.
2021-12-08 07:07:35 -03:30
igorms-cons
981db6e0ea
Fix confirmed transaction time (#12633) 2021-12-07 12:16:40 -06:00
Erik Marks
31cf7c10a4
Permission System 2.0 (#12243)
# Permission System 2.0

## Background

This PR migrates the extension permission system to [the new `PermissionController`](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/controllers/src/permissions).
The original permission system, based on [`rpc-cap`](https://github.com/MetaMask/rpc-cap), introduced [`ZCAP-LD`](https://w3c-ccg.github.io/zcap-ld/)-like permissions to our JSON-RPC stack.
We used it to [implement](https://github.com/MetaMask/metamask-extension/pull/7004) what we called "LoginPerSite" in [version 7.7.0](https://github.com/MetaMask/metamask-extension/releases/tag/v7.7.0) of the extension, which enabled the user to choose which accounts, if any, should be exposed to each dapp.
While that was a worthwhile feature in and of itself, we wanted a permission _system_ in order to enable everything we are going to with Snaps.
Unfortunately, the original permission system was difficult to use, and necessitated the creation of the original `PermissionsController` (note the "s"), which was more or less a wrapper for `rpc-cap`.

With this PR, we shake off the yoke of the original permission system, in favor of the modular, self-contained, ergonomic, and more mature permission system 2.0.

Note that [the `PermissionController` readme](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/controllers/src/permissions/README.md) explains how the new permission system works.

The `PermissionController` and `SubjectMetadataController` are currently shipped via `@metamask/snap-controllers`. This is a temporary state of affairs, and we'll move them to `@metamask/controllers` once they've landed in prod.

## Changes in Detail

First, the changes in this PR are not as big as they seem. Roughly half of the additions in this PR are fixtures in the test for the new migration (number 68), and a significant portion of the remaining ~2500 lines are due to find-and-replace changes in other test fixtures and UI files.

- The extension `PermissionsController` has been deleted, and completely replaced with the new `PermissionController` from [`@metamask/snap-controllers`](https://www.npmjs.com/package/@metamask/snap-controllers).
- The original `PermissionsController` "domain metadata" functionality is now managed by the new `SubjectMetadataController`, also from [`@metamask/snap-controllers`](https://www.npmjs.com/package/@metamask/snap-controllers).
- The permission activity and history log controller has been renamed `PermissionLogController` and has its own top-level state key, but is otherwise functionally equivalent to the existing implementation.
- Migration number 68 has been added to account for the new state changes.
- The tests in `app/scripts/controllers/permissions` have been migrated from `mocha` to `jest`.

Reviewers should focus their attention on the following files:

- `app/scripts/`
  - `metamask-controller.js`
    - This is where most of the integration work for the new `PermissionController` occurs.
      Some functions that were internal to the original controller were moved here.
  - `controllers/permissions/`
    - `selectors.js`
      - These selectors are for `ControllerMessenger` selector subscriptions. The actual subscriptions occur in `metamask-controller.js`. See the `ControllerMessenger` implementation for details.
    - `specifications.js`
      - The caveat and permission specifications are required by the new `PermissionController`, and are used to specify the `eth_accounts` permission and its JSON-RPC method implementation.
        See the `PermissionController` readme for details.
  - `migrations/068.js`
    - The new state should be cross-referenced with the controllers that manage it.
      The accompanying tests should also be thoroughly reviewed.

Some files may appear new but have just moved and/or been renamed:

- `app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js`
  - This was previously implemented in `controllers/permissions/permissionsMethodMiddleware.js`.
- `test/mocks/permissions.js`
  - A truncated version of `test/mocks/permission-controller.js`.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-12-06 19:16:49 -08:00
Thomas Huang
d78cfebd43
Jestify app/scripts/lib/**/*.test.js (#12890)
* Jestify app/scripts/lib/*.test.js

* Mocha config on mocha test script

* Add app/scripts/lib to include subdirs
2021-12-06 10:40:39 -06:00
Mark Stacey
7226357422
Fix isMainnet propType error (#12951)
A propType error was showing up during e2e tests with a `testDev`
build. It was caused by `process.env.IN_TEST` being treated as a
boolean, when in fact it is either the string `'true'` or a boolean.

`IN_TEST` has been updated to always be a boolean. `loose-envify` has
no trouble injecting boolean values, so there's no reason to treat this
as a string.
2021-12-02 14:46:46 -03:30
Alex Donesky
9e2935dd55
Revert "Feat/collectibles display (#12873)" (#12934)
This reverts commit 81ea24f08a.
2021-12-01 17:46:26 -06:00
Alex Donesky
81ea24f08a
Feat/collectibles display (#12873)
* Wiring up Collectibles lists/items

* wip

* more wip

* more more wip

* yet more wip

* wippp

* more wipppp

* closer

* wroking

* more wip

* cleanup

* cleanup

* add-collectible form validation

* update default ipfs-gateway

* update refresh button

* fix proptypes issue + add more padding to asset background

* css tweaking

* more cleanup

* more cleanup

* more cleanup

* add migration

* address feedback

* fix migration + cleanup

* bumping controllers version + adapting new collectiblesController shape

* fix yarn dedupe
2021-12-01 10:10:17 -06:00
Alex Donesky
3434b9f80a
add openSeaEnabled preference (#12909)
* add openSeaEnabled preference

* cleanup

* add description copy
2021-11-30 22:12:27 -06:00
Matthew Epps
8e6a0ff879
Send all swaps requests to api2, remove useNewSwapsApi boolean (#12792)
* Send all swaps requests to api2, remove useNewSwapsApi boolean

* Switch token bucket priority

* Fix tests

* Trigger Build

* Trigger Build
2021-11-30 19:56:28 +01:00
Dan J Miller
2856ea7606
Add support for eip-1559 on Trezor (#12627)
* Add support for eip-1559 on Trezor

* temp

* Lint fix

* Store trezor model type in background state instead attempting to get it in the frontend

* code simplification

* Temp update to eth-trezor-keyring version

* Tempory update to eth-trezor-keyring version

* Temp update to eth-trezor-keyring version

* Fix display of hdpath selector in connect hardware flow for trezor

* Updating the package version but we still need to run yarn setup and update the lockfile, once the package is updated

* Update yarn.lock

* Fix unit tests
2021-11-30 10:58:28 -03:30
Niranjana Binoy
4b975adc85
EIP-1559 V2 : Advanced gas fee modal - Max base fee and Priority fee inputs (#12619) 2021-11-29 23:10:48 +05:30
Alex Donesky
5aa191fd2e
Feat/add collectible manually (#12834)
* hook up add collectible manually flow

* address feedback
2021-11-26 14:03:35 -06:00
Alex Donesky
0bed51b936
add and hook up setting to toggle on/off collectible autodetection (#12839) 2021-11-26 12:54:57 -06:00
Aaron Chen
a931316a53
Introduce QR based signer into MetaMask (#12065)
* support qr based signer

* add CSP for fire fox

* get QR Hardware wallet name from device

* fix qrHardware state missing in runtime

* support qr based signer sign transaction

* refine Request Signature modal ui

* remove feature toggle

* refine ui

* fix notification is closing even there is a pending qr hardware transaction

* add chinese translation, refine ui, fix qr process was breaking in some case

* support import accounts by pubkeys

* refine qr-based wallet ui and fix bugs

* update @keystonehq/metamask-airgapped-keyring to fix that the signing hd path was inconsistent in some edge case

* fix: avoid unnecessay navigation, fix ci

* refactor qr-hardware-popover with @zxing/browser

* update lavamoat policy, remove firefox CSP

* refine qr reader ui, ignore unnecessary warning display

* code refactor, use async functions insteads promise

Co-authored-by: Soralit <soralitria@gmail.com>
2021-11-23 13:58:39 -03:30
Daniel
bf06025615
Fix "BigNumber Error: times() number type has more than 15 significant digits:" (#12802) 2021-11-23 17:33:32 +01:00
Dan J Miller
2647be9662
Ensure one and only one localhost option appears in network list (#12786)
* Ensure one and only one localhost option appears in network list

* Fix unit tests
2021-11-22 12:54:42 -03:30
Alex Donesky
6838a3d074
fix issue where contractExchangeRates are not available in swaps controller, make token address matching case insensitive (#12770) 2021-11-22 08:34:31 -03:30
Dan J Miller
c9baf39c4d
Ensure that metametrics error related to anonymousId is not sent to sentry (#12763) 2021-11-19 14:07:50 -03:30
Alex Donesky
b119b7744d
Add CollectiblesController & CollectibleDetectionController (#12443)
* Add CollectiblesController

* bump controllers version

* add CollectibleDetectionController

* adapt to ERC1155 support changes in CollectiblesController

* update @metamask/controllers to v20.0.0

* update lavamoat policy files

* put collectibleDetectionController instantiation behind feature flag
2021-11-19 10:16:41 -06:00
Olaf Tomalka
3f3479bf6e
Fix: eth_sign does not validate input (#12679)
* Fix #5039

* Converted function into async

* Added more explicit explanation of why the number of bits for EcSign

* eth_sign and eth_personalSign now report errors correctly back to the user

* Added leeway to unsigned message byte check

* Fix lint
2021-11-19 17:05:24 +01:00
Mark Stacey
cce2dda8e4
Remove unused background API methods (#12731)
These background API methods were not used anywhere in the UI. One of
them was called in `actions.js` by a function that itself was never
called, so it have been removed. Additionally, one unused `actions.js`
function was found and removed as well.

`setAdvancedGasFee` is the only unused background method that remains.
It was recently added and will be used in the near future.
2021-11-17 15:03:36 -03:30
Daniel
ecceb4d6da
Use v2 API for fiat onboarding URL creation, fix wrapping / unwrapping (#12729)
* Use a Swaps v2 API to get a fiat onboarding URL

* Fix an issue with wrapping / unwrapping if an address contained uppercase chars

* Rename a constant

* Use a constant in a test
2021-11-17 18:04:50 +01:00
Dan J Miller
ab8db945cd
Ensure the test network dismissal message in the network dropdown is permanently dismissed (#12723) 2021-11-16 18:52:01 -03:30
Ikko Ashimine
568289f29e
Fix typo in network.js (#12636)
intialize -> initialize
2021-11-16 10:40:49 -03:30
Erik Marks
05fae3fa1e
Add RPC method handler hook selection (#12664)
Adds a property, `hookNames`, to each RPC method handler export in `app/scripts/lib/rpc-method-middleware` and a function, `selectHooks`, to select from them.

`createMethodMiddleware` receives a giant `opts` object that includes a bunch of different methods from `MetaMaskController` and its subcontrollers. Each method implementation only requires a subset of these methods to do its work. Because they need some kind of name, we call these methods "hooks". With this change, whenever an RPC method is called, `selectHooks` will be called to ensure that each method only receives the hooks that it needs in order to do its job.

This implementation is based on [work in `snaps-skunkworks`](https://github.com/MetaMask/snaps-skunkworks/blob/a3e1248/packages/rpc-methods/src/utils.ts#L17-L34) that will be merged in the near future.
2021-11-15 15:11:51 -08:00
Dan J Miller
2ced3a8bfa
Add migration to set showTestNetworks to true if there is evidence of testnet use (#12675)
* Add migration to set showTestNetworks to true if there is evidence the user has used a test network

* Add migration to index file

* Remove console.log

* Clean up conditional structure in migration 67
2021-11-15 15:50:33 -03:30
Olaf Tomalka
a323a5fe59
Reject popup confirmations on close (#12643)
* Background clears confirmations on popup close

* [WIP] Remove clearing confirmations through UI

* Confirmations are now rejected instead of cleared

* Erased commented out code

* Fix linter errors

* Changes after code review

* Moved metrics events from onWindowUnload to background

* PR review fixes

* Added abillity to add reason to rejection of messages

* Fix prettier

* Added type metrics event to signature cancel

* Fix test

* The uncofirmed transactions are now cleared even if Metamask is locked
2021-11-15 17:13:51 +01:00
白宦成
4ef7162656
fix typo (#12672) 2021-11-12 11:10:50 -03:30
Erik Marks
b3963daaab
eth-json-rpc-middleware@8.0.0 (#10738)
We're bumping from `^6` to `^8`. All imports are now named, and they have been updated. This is a breaking change, in that support for `eth_signTransaction` is added in `^8.0.0`. We do not support this method in our UI, so our middleware stack has been instrumented to reject.

In addition, there are some non-breaking behavioral changes in this version that reviewers should be aware of, see the [7.0.0 release](https://github.com/MetaMask/eth-json-rpc-middleware/releases).
2021-11-11 12:26:49 -08:00
Niranjana Binoy
7cf4a16a63
EIP-1559 V2 : Adding advancedGasFee property to Preference Controller (#12577) 2021-11-11 14:18:50 -05:00
kumavis
3c749190d8
metametrics - ensure segment submission failures do not bubble up (#12573)
* metametrics - ensure segment submission failures do not bubble up

* metametrics - differentiate between trackEvent and submitEvent

* metametrics - validate event in trackEvent

* metametrics - re-throw error on clean stack

* lint fix

* controllers/metametrics - take a captureException option

* controllers/metametrics - capture and report any errors in trackPage

* Update app/scripts/controllers/metametrics.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-11-10 17:27:04 -10:00
David Walsh
3f9ec40107
Use gas estimate type constants (#12460) 2021-11-10 13:50:43 -06:00
Alex Miller
722c4e5b63
Support for GridPlus Lattice1 hardware wallet (#12053)
* GridPlus: Adds support for GridPlus Lattice1 hardware wallet

* Fixes issue with switching hardware HD path
The main `Select HD Path` piece of the account selection component was not
properly hooked up to the state manager (`onPathChange`) and the extra
`Popover` component was being used instead.
I'm not sure what the origin of this is, but I don't see why the Popover
is needed at all. I have remove it and hooked `onPathChange` directly into
the HD path selector dropdown.
This was an issue that nearly every Lattice user who had come from Ledger
has contacted us about.

* GridPlus: Addresses QA issues
* Adds Lattice tutorial + image
* Cleans up connectivity issues (see: https://github.com/GridPlus/eth-lattice-keyring/pull/16)

* GridPlus: Adds Firefox support
To connect to the Lattice you need to open a new tab/window and get
login data from it. We were not able to do this for Firefox because
we relied on the `window` API. This is now fixed.
See corresponding changes:
* `eth-lattice-keyring`: https://github.com/GridPlus/eth-lattice-keyring/pull/17
* Lattice connector: https://github.com/GridPlus/wallet-web/pull/152

* GridPlus: Adds missing error path for Firefox
See: 242a93f559
2021-11-08 11:18:41 -03:30
David Walsh
17b64e94fc
Use gas recommendation constants throughout app (#12461) 2021-11-05 19:59:23 -05:00
David Walsh
2822379bdc
Improve browser detection code (#12456)
* Improve browser detection code

* Add unit tests for platform detection

* Add test

* Use key check instead of object presence
2021-11-05 17:28:44 -07:00
David Walsh
042bd84c87
Minor code cleanup of _viewOnEtherscan (#12609) 2021-11-05 16:18:07 -05:00
Dan J Miller
e6ae6e09b8
Ensure proper transport type is set before attempting to connect ledger wallet (#12594)
* Ensure proper transport type is set before attempting to connect ledger wallet

* Fix unit tests
2021-11-05 13:43:29 -02:30
Dan J Miller
843bb6e047
Check if ledger was successfully able to establish transport on confirm screen mount (#12535)
* Check if ledger was successfully able to establish transport on mount of confirm screens

* Update ledger message/action if transport creation was blocked by existing connection

* TEMP: point eth-ledger-bridge-keyring to commite, REMOVE BEFORE MERGE

* Update eth-ledger-bridge-keyring to v0.10.0
2021-11-04 15:49:53 -02:30
Dan J Miller
401c8ee7b2
Ensure ledger transport preference is set on import (#12557) 2021-11-03 13:53:13 -02:30
Erik Marks
5560b7c3e5
Update build system lockdown parameter (#12556)
* Update build system lockdown parameter

* Add @reduxjs/toolkit patch

* Fix Mozilla lint syntax error

* Standardize a thing

* Remove redundant check for globalThis
2021-11-01 22:13:22 -10:00
Olusegun Akintayo
b6673731e2
Implement Network Switcher designs (#12260)
* Show test networks toggle button in settings/advanced tab.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Apply toggle testnet settings and show/hide testnets when on/off
Add localhost to testnet.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Show add network button

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Open full screen when add network is called.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Show custonm rpc before testnet rpcs
lint fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Test cases for network dropdown.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Test cases for toggle test networks in advanced tab component.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix Locales.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* E2E Tests: Custom RPC is now called Add Network

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fix

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* E2E: When Add Network button is clicked, wait for the full screen window to
be visible

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* findVisibleElement should use a class. i.e start with a dot

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Hide Dropdown when Add Netwok is clicked.
Only show full screen if it's not already showing.
E2E tests passing.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix tests for jest

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Testnets are not being shown by default anymore, tests should use
Mainnet instead.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Import Button from ui
Change selector name to getShowTestnetworks
Fix button to show full width

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix e2e tests

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Remove localhost from INFURA provider types.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix errors in Advanced Tab Component tests

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix unit tests for advanced tab component.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Remove deleted elements from e2e tests

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Make sure all tests passed.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-10-28 23:31:05 +04:00
Daniel
e85248aaf5
Fix parallel calls for quotes in swaps (#12484) 2021-10-28 08:53:26 +02:00
David Walsh
b5e601bc87
Use TRANSACTION_ENVELOPE_TYPES for legacy transaction type testing (#12455) 2021-10-27 18:55:02 -05:00
Mark Stacey
345ed9f6f2
Add build type to Sentry environment (#12441)
The build type (i.e. the distribution) is now included in the Sentry
environment during setup, for all builds except the "main" build. This
will allow us to track Flask and beta errors separately from other
errors.

A constant was created for the build types. The equivalent constant in
our build scripts was updated to match it more closely, for
consistency. We can't use the same constant in both places because our
shared constants are in modules that use ES6 exports, and our build
script does not yet support ES6 exports.

The singular `BuildType` was used rather than `BuildTypes` to match our
naming conventions elsewhere for enums. We name them like classes or
types, rather than like a collection.

Relates to #11896
2021-10-25 14:27:30 -02:30
David Walsh
b7b21ed20b
Use rejected constant within transaction state manager (#12458) 2021-10-25 08:01:30 -05:00
ryanml
a4ddeed799
Adding estimate fields to updateTransaction, createCancelTransaction and createSpeedUpTransaction (#12398) 2021-10-22 13:42:20 -07:00
Dan J Miller
9d70c60c22
Connect Ledger via WebHID (#12411)
* Connect ledger via webhid if that option is available

* Explicitly setting preference for webhid

* Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences

* Use single setLEdgerTransport preference methods and property

* Temp

* Lint fix

* Unit test fix

* Remove async keyword from setLedgerTransportPreference function definition in preferences controller

* Fix ledgelive setting toggle logic

* Migrate useLedgerLive preference property to ledgerTransportType

* Use shared constants for ledger transport type enums

* Use constant for ledger usb vendor id

* Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection

* Update eth-ledger-bridge-keyring to v0.9.0

* Only show ledger live transaction helper messages if using ledger live

* Only show ledger live part of tutorial if ledger live setting is on

* Fix ledger related prop type errors

* Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid

* Cleanup

* Wrap ledger webhid device request in try/catch

* Clean up

* Lint fix

* Ensure user can easily connect their ledger wallet when they need to.

* Fix locales

* Fix/improve locales changes

* Remove unused isFirefox property from confirm-transaction-base.container.js

* Disable transaction and message signing confirmation if ledger webhid requires connection

* Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales

* Drop .component from ledger-instruction-field file name

* Move renderLedgerLiveStep to module scope

* Remove ledgerLive from function and message names in ledger-instruction-field

* Wrap ledger connection logic in ledger-instruction-field in try catch

* Clean up signature-request.component.js

* Check whether the signing address, and not the selected address, is a ledger account in singature-request.container

* Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures

* Improve webhid selection handling in select-ledger-transport-type onChange handler

* Move metamask redux focused ledger selectors to metamask duck

* Lint fix

* Use async await in checkWebHidStatusRef.current

* Remove unnecessary use of ref in ledger-instruction-field.js

* Lint fix

* Remove unnecessary try/catch in ledger-instruction-field.js

* Check if from address, not selected address, is from a ledger account in confirm-approve

* Move findKeyringForAddress to metamask duck

* Fix typo in function name

* Ensure isEqualCaseInsensitive handles possible differences in address casing

* Fix Learn More link size in advanced settings tab

* Update app/scripts/migrations/066.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Add jsdoc comments for new selectors

* Use jest.spyOn for mocking navigator in ledger webhid migration tests

* Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType

* Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType

* Fix font size of link in ledger connection description in advanced settings

* Fix return type in setLedgerTransportPreference comment

* Clean up connectHardware code for webhid connection in actions.js

* Update app/scripts/migrations/066.test.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update ui/ducks/metamask/metamask.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Add migration test for when useLedgerLive is true in a browser that supports webhid

* Lint fix

* Fix inline-link size

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 16:47:03 -02:30
Akintayo A. Olusegun
03e3edb00c
Refactor checking if address is contract into a new module. (#12354)
* Refactor checking if address is contract into a new module.
Tests for new module.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* addressIsContract is an async function, use await when calling it.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Mock ethQuery
change variable names
refactor in transaction.utils.
fix possible boolean destructiring.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Refactor isContractAddress boolean checks.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-10-20 16:12:07 +01:00
Matthew Epps
7b34c7263d
Fix weth->eth direct wrapping allowance issue (#12405)
* chore: fix weth->eth direct wrapping allowance issue

* chore: clean up url issue
2021-10-20 13:07:34 +02:00
Alex Donesky
22378e4f72
fix issue where regional locales are not matched against our locales list (#12403)
* fix issue where regional locales are not matched against our locales list
2021-10-19 14:32:13 -05:00
ryanml
2712048c0e
Removing unused TokenRatesController (#12376) 2021-10-18 09:29:07 -07:00
Alex Donesky
71f91568db
Migrate completedOnboarding and firstTimeFlowType state into onboardingController (#12356)
* migrate completedOnboarding state into onboardingController

* migrate firstTimeFlowType state from preferencesController to onboardingController
2021-10-15 13:52:52 -05:00
Akintayo A. Olusegun
319ab42bc1
Fix for #11503: when you send a transaction with value as 0x, you get a Bignumber error (#11996)
* Fix for #11503: when you send a transaction with value  as 0x, you get a
Bignumber error. Fix this by setting value to 0x0 is it's 0x.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* 1. Fix this in app/scripts/controllers/transactions/lib/utils.js
2. Make sure other non-hex non-valid strings for value return 0x0

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Linting Fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Instead of returning 0x0 for invalid hex values, throw a descriptive
error

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Unit tests.
Lint fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* assert.throws takes a function

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint Fixes.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Use standardized error message.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* remove fixHexValue
move code validating hex value to validateTxParams

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Change message displayed if hex string is invalid.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fixed missing second quote mark on message.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-10-15 13:04:14 +01:00
Mark Stacey
864800b035
Normalize extension verison to SemVer (#12254)
The extension version used throughout the wallet is now normalized to a
SemVer-compliant version that matches the version used in
`package.json`. We use this version for display on the "About" page,
and we attach it to all error reports and metric events, so it's
important that we format it consistently so that we can correlate
events on the same version across different browsers.

This normalization step is necessary because Firefox and Chrome both
have different requirements for the extension version, and neither is
SemVer-compliant.
2021-10-14 18:50:14 -02:30
Erik Marks
20b921f520
Fix inpage provider behavior on unlock (#12339)
This fixes a bug where we were failing to notify the inpage provider of the user's currently selected account when the extension becomes unlocked.
2021-10-14 10:50:07 -07:00
David Walsh
72a3db7c0c
Use hardware constants everywhere (#12329) 2021-10-13 09:25:27 -05:00
Jyoti Puri
fc41321470
Support for type 0 transaction (#12252)
Support for type 0 transaction
2021-10-06 23:59:57 +05:30
kumavis
f9ea9e4b43
lockdown - breakout making globalThis properties non-writable (#12258)
* lockdown - breakout making globalThis properties non-writable into lockdown-more.js

* Update app/scripts/lockdown-more.js

Co-authored-by: David Walsh <davidwalsh83@gmail.com>

* Update app/scripts/lockdown-more.js

Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2021-10-01 08:53:12 -10:00
Niranjana Binoy
e238cbc568
Turning OFF token detection for test nets (#12232) 2021-09-29 14:53:56 -04:00
Daniel
acce73c943
Fix form prefilling in Swaps on the Build Quote page (#12244)
* Fix form prefilling in Swaps on the Build Quote page

* Fix UTs

* Clean up tokens when resetting swaps state, in case a user is changing a network
2021-09-29 18:13:34 +02:00
Matthew Epps
53f2c84209
Add client id to GasFeeController (#12221)
* chore: Add client id to GasFeeController

* chore: change EXTENSION_CLIENT_ID to SWAPS_CLIENT_ID in constants file
2021-09-29 10:41:19 -02:30
Thomas Huang
02a4da9ad2
Fix 12145 - Ledger errors being set as Error: [object, object] (#12176)
* Fixes #12145

When transactions fail, preserve error message when presented with an error object. Fallback to stringified error for other cases.

* Perserve error stack when err.stack is present, else set stack to message.

* Use optional chaining
2021-09-22 10:41:23 -07:00
Thomas Huang
1cc45774dc
Jestify continue (#12173) 2021-09-22 08:15:40 -07:00
Jyoti Puri
c9ce848f47
Fix case of password env variable (#12120) 2021-09-21 23:27:24 +05:30
Thomas Huang
e78e82205a
Jestify migrations/ (#12106)
* Jestify migrations/

* Lint exclude migrations from mocha config, and add inclusion to jest config

* Add migration tests to jest config

* Exclude/ignore migration tests

* Set process.env.IN_TEST to true when running tests locally
2021-09-21 09:28:13 -07:00
Muin Momin
ae84b0cb6d
Fixes #12073: Extra account with zero balance always added when importing wallet with seed and when first account's balance is non-zero (#12074)
* add command to debug unit tests

* remove extra zero balance account potentially created from seeking ahead

* Add PR 12074 to CHANGELOG

* Revert "Add PR 12074 to CHANGELOG"

This reverts commit 9f6f7eec1cac163c0ce1c711b1c205322aa5b2af.

* Remove test debug command
2021-09-16 16:20:57 -05:00
Niranjana Binoy
66c3414433
Changing Use Token detection to OFF by default (#12129) 2021-09-16 13:07:23 -04:00
Alex Donesky
2a9fbffb6c
Replace hardcoded sent ether label on confirm screen (#11802)
* Replace hardcoded sent ether label on confirm screen

* replace transaction type SENT_ETHER with network agnostic SENDING_NATIVE_ASSET

* remove sentEther translation base

* make backwards compatible with lingering transaction of legacy sentEther type

* update localalization files

* fixup legacy sentEther transaction type

* changing new transaction type away from localization string

* revert migration tests

* update fixtures and test data

* update name of new transaction type

* add migration

* remove legacy SENT_ETHER from transaction types enum object
2021-09-15 16:54:51 -05:00
Alex Donesky
9d968bae1e
Hook up shared TokenRatesController (#12066) 2021-09-15 14:02:28 -05:00
Daniel
28fc2d471f
Quotes prefetching in Swaps (#11915) 2021-09-15 15:13:18 +02:00
Niranjana Binoy
0c2af43d3a
changing token address to lowercase for dynamic token list (#12071) 2021-09-10 23:55:23 -04:00
Niranjana Binoy
769beb2a26
Adding Refresh list and import tokens link to the main page (#11755) 2021-09-10 14:03:42 -04:00
Alex Donesky
490d3b8d40
Integrate TokensController (#11552)
* Integrate controllers/tokensController

* address rebase issues

* small cleanup

* addressing feedback

* more feedback
2021-09-10 12:37:19 -05:00
Niranjana Binoy
eb987a47b5
Integrating the TokenListController to Extension (#11398) 2021-09-09 16:56:27 -04:00
Daniel
93cdd3c159
Use Swaps dev APIs based on an env variable (#11924) 2021-09-08 19:26:37 +02:00
Shane
362b54b2dd
Added getPersistentState support for V2 controllers persist metadata (#12007) 2021-09-05 19:33:37 -07:00
ryanml
fe59cbfe66
Autofilling new issue link with url and domain (Phishing detect page) (#12000) 2021-09-03 11:22:28 -07:00
Alex Donesky
e8ab578ed0
bump @metamask/controllers to v15.0.2 and remove AbortController workaround in e2e tests (#11988)
* bump @metamask/controllers to v15.0.1 and remove AbortController workaround in e2e tests

* remove old abortcontroller polyfill

* bump @metamask/controllers to v15.0.2
2021-09-03 09:34:21 -05:00
Alex Donesky
da305656bd
cap resubmit transaction retries to within 50 blocks of first submission (#12003) 2021-09-02 16:06:31 -05:00
Dan Finlay
2df159841a
Add eth_feeHistory to safe method list (#11999)
So that we can expose this method to dapps.
2021-09-02 10:26:32 -07:00
Dan J Miller
a4c0133bc5
1559 ledger (#11951)
* EIP-1559 - Provide support for Ledger

* Update ui/selectors/selectors.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Add shared constants for hw types

* bump eth-ledger-bridge-keyring to v0.7.0

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Alex <adonesky@gmail.com>
2021-09-01 11:25:06 -05:00
Erik Marks
8a8ce3a0c0
@metamask/controllers@15.0.0 (#11975)
Adds the latest version of `@metamask/controllers`, and updates our usage of the `ApprovalController`, which has been migrated to `BaseControllerV2`. Of [the new `controllers` release](https://github.com/MetaMask/controllers/releases/tag/v15.0.0), only the `ApprovalController` migration should be breaking.

This is the first time we use events on the `ControllerMessenger` to update the badge, so I turned the messenger into a property on the main `MetaMaskController` in order to subscribe to events on it in `background.js`. I confirmed that the badge does indeed update during local QA.

As it turns out, [MetaMask/controllers#571](https://github.com/MetaMask/controllers/pull/571) was breaking for a single unit test case, which is now handled during setup and teardown for the related test suite (`metamask-controller.test.js`).
2021-08-31 12:27:13 -07:00
Erik Marks
1175b4bfa7
Make all named intrinsics non-modifiable (#11953)
This PR makes ~all named intrinsics in all of our JavaScript processes non-modifiable. A named intrinsic is any property specified by the ECMAScript specification that exists on `globalThis` when the JavaScript process starts. We say that a property is non-modifiable if it is non-configurable and non-writable. We make exceptions for properties that meet any of the following criteria:

1. Properties that are non-configurable by the time `lockdown-run.js` is executed are not modified, because they can't be.
2. Properties that have accessor properties (`get` or `set`) are made non-configurable, but their writability cannot be modified, and is therefore left unchanged. It's unclear how many of the named intrinsics this applies to, if any, but it's good defensive programming, regardless.
2021-08-30 14:30:48 -07:00
Alex Donesky
33849bfec6
Fix issue with chainId comparison in sign typed message param validation (#11900) 2021-08-24 11:23:29 -05:00
ryanml
d96973e55b
Improving handling for non-existent props in state migrations (#11829) 2021-08-17 19:18:53 -07:00
ryanml
5cbece90c0
Removing unnecessary console log from the preferences controller (#11828) 2021-08-17 01:56:18 -07:00
ryanml
e7dc42be0b
Do not attempt to track tx metrics events if txMeta is not available (#11823) 2021-08-16 17:28:56 -07:00
Dan J Miller
e6543a83ef
Ensure transaction activity log supports EIP-1559 (#11794)
* Ensure transaction activity log supports EIP-1559

* unit test fix

* Add estimated base fee to swaps txMeta

* fix lint and tests

* Improve activity log copy
2021-08-06 19:48:53 -02:30
Dan J Miller
bfde5a1d77
Fixes updates on the confirm screen. (#11788)
* Fixes updates on the confirm screen.

* Better handling of internal send transactions

* maxFee -> maxFeePerGas property name fix

* Remove redundant setEstimateToUse call in onManualChange

* Fix unit tests

* rebase error fix

* Fixes to speedup loading and transaction breakdown priority fee

* Fix lint and unit tests

* Ensure gas price based transaction that have been customized (e.g. speed up and retry) are properly initialized in useGasFeeInputs

* Clean up

* Link fix
2021-08-06 14:31:30 -05:00
Alex Donesky
d359429f04
Stop GasFeeController polling when pop closes (#11746)
* Stop GasFeeController polling when pop closes

* Stop estimate gas polling on window unload

* lint + comments

* Improve client closed logic

* lint

* Add back _beforeUnload on unmount in gas-modal-page-container

* Add full check and call onClientClosed method for notifcation environment

* Add gas pollingToken tracking to appStateController and use to disconnect polling for each environment type

* remove unused method

* move controller manipulation logic from background.js to metamask-controller, disaggregate methods

* add beforeunload handling to reset gas polling tokens from root of send page

* cleanup, lint and address feedback

* clear appState gasPollingTokens when all instances of all env types are closed, fix pollingTokenType arg from onEnvironmentTypeClosed call in metamask-controller

* mock new methods to fix tests

* final bit of cleanup + comments

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2021-08-04 16:53:13 -05:00
David Walsh
c8b3dfe4e9
EIP-1559 - Fall back to gasLimit and gasPrice for hardware wallets (#11716) 2021-08-02 17:52:18 -05:00
ryanml
1360b2bf6b
Rejecting EIP-1559 transactions on unsupported networks (#11722) 2021-08-02 08:38:01 -07:00
Alex Donesky
8a42258e10
Remove the SHOW_EIP_1559_UI environment variable, replace with network detection where appropriate (#11694)
Fixing up tests and add back old custom gas modal for non-eip1559 compliant networks

Remove unnecessary props from send-gas-row.component

fix breaking test

Fix primary and secondary title overrides

fix rebase issue

Fix rebase conflict

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
2021-07-30 22:59:21 -02:30
Brad Decker
e0953d9f68
Update send and confirm state management, and tx controller gas defaults, for EIP1559 (#11549)
wip

Documentation improvements for send slice support of EIP1559

Remove console.log in send duck

Property lookup safety improvement in selectors/confirm-transaction

Add code accidentally removed in rebase

Update addTxGasDefaults and _getDefaultGasFees to work with new estimate types, and ensure we correctly handle gas price estimates when on EIP1559 networks (#11615)

* Fix typo

Remove console.log in send duck

* Update addTxGasDefaults and _getDefaultGasFees to work correctly with all new gas fee estimate types

* Don't show gas timing support when not on eip1559 compatible network

* Hide gas timing component on transaction screen when on a non-1559 network

* Improve comments, tests and edge case handling

* Ensure eip1559 fees are applied and updated correctly when eip1559 estimate api fails

* Lint fix

Co-authored-by: Brad Decker <git@braddecker.dev>

Remove console.log

Handle possible gasEstimateType undefined

Remove unnecessary nonce field position change in confirm-page-container-content__details
2021-07-30 22:15:18 -02:30
Dan J Miller
b2cb38ab2d
Ensure createPendingTxMiddleware returns gasPrice for EIP-1559 transactions (#11685) 2021-07-30 18:10:19 -02:30
kumavis
66eb4fb5a0
Update background.js (#11663) 2021-07-30 08:02:48 -05:00
David Walsh
e283c03c4e
EIP-1559 - Improve gas timing logic to show more accurate verbiage (#11668) 2021-07-30 08:00:02 -05:00
Daniel
714170c7b8
EIP-1559 and Rinkeby Testnet support in Swaps (#11635) 2021-07-30 13:35:30 +02:00
Dan J Miller
aaa15cbe03
Add support for EIP1559 transactions to transaction breakdown (#11622)
* Add support for EIP1559 transactions to transaction breakdown

* Use userPreferencedCurrencyDisplay for effective gas price in transaction breakdown

* Hide eip1559 gas properties in transaction breakdown on non-1559 networks

* Add comment explaining gasPrice and effectiveGasPrice usage in transaction breakdown container.
2021-07-28 15:00:34 -02:30
Dan J Miller
7c86727c16
Make EIP1559 compatibility in tx controller also require account type support (#11616) 2021-07-27 20:43:48 -02:30
Daniel
594025a198
Add support for Polygon (#11545)
* Fix a check for EIP presense
* Add support for Polygon
* Update default Polygon URL
* Trigger Build
* Use a more user-friendly error message for disabled Swaps API calls
2021-07-20 19:17:15 +02:00
ryanml
ceaf16417d
Updating formatTxMetaForRpcResult to match latest spec (#11536) 2021-07-16 11:53:01 -07:00
Brad Decker
dc25a24de3
rely upon gas fee controller for gas price estimates (#11511) 2021-07-16 11:06:32 -05:00
Peter-Jan Brone
3fada25dfc
Add Skylink support to ENS resolver (#11401)
* Add Skynet support to ENS to IPFS resolver

* Remove newline

* Fix lint

* Fix lint

* Remove mistakenly committed zip file

* Update
2021-07-16 10:22:04 -05:00
Niranjana Binoy
d33b841fb8
Adding TokenListController to Metamask-Controller (#11515) 2021-07-15 19:08:16 -04:00
Dan J Miller
ee925d0186
Retrieve state after async action before updating state in _setSwapsQuoteRefreshTime (#11538) 2021-07-15 20:13:53 +02:00
kumavis
9f4820ee98
Build - refactor for bundle factoring and swappable runtime (#11080)
* wip

* build - breakout sentry-install bundle

* deps - move new build sys deps to published versions

* chore: lint fix

* clean - remove unused file

* clean - remove unsused package script

* lavamoat - update build system policy

* build - render html to all platforms

* development - improve sourcemap debugger output

* deps - update lavapack

* lint - fix

* deps - update lavapack for bugfix

* deps - update lavapack for bugfix

* deps - bump lavapack for line ending normalization

* sourcemap explorer - disable boundary validation

* ci - reset normal ci flow

* build - re-enable minification on prod

* build - remove noisy log about html dest

* build - update terser and remove gulp wrapper for sourcemap fix

* Revert "sourcemap explorer - disable boundary validation"

This reverts commit 94112209ed880a6ebf4ee2ded411e59db6908162.

* build - reenable react-devtools in dev mode

* wip

* build - breakout sentry-install bundle

* deps - move new build sys deps to published versions

* chore: lint fix

* clean - remove unused file

* clean - remove unsused package script

* lavamoat - update build system policy

* build - render html to all platforms

* development - improve sourcemap debugger output

* deps - update lavapack

* lint - fix

* deps - update lavapack for bugfix

* deps - update lavapack for bugfix

* deps - bump lavapack for line ending normalization

* sourcemap explorer - disable boundary validation

* ci - reset normal ci flow

* build - re-enable minification on prod

* build - remove noisy log about html dest

* build - update terser and remove gulp wrapper for sourcemap fix

* Revert "sourcemap explorer - disable boundary validation"

This reverts commit 94112209ed880a6ebf4ee2ded411e59db6908162.

* build - reenable react-devtools in dev mode

* Updating lockfile

* lint fix

* build/dev - patch watchifys incompatible binary stats output

* ui - add comment about conditional import

* build - improve comment

* Update development/stream-flat-map.js

Co-authored-by: Brad Decker <git@braddecker.dev>

* Outputting all bundle file links (metamaskbot)

Co-authored-by: ryanml <ryanlanese@gmail.com>
Co-authored-by: Brad Decker <git@braddecker.dev>
2021-07-15 10:59:34 -07:00
muji
aef1cd2450
Use ESM imports in migrations index. (#11443)
So that spack does not complain about mixing CommonJs and ESM.
2021-07-13 17:11:53 -05:00
Brad Decker
2edd44e1c5
moving some properties to identifiable payload (#11506) 2021-07-12 15:30:35 -07:00
ryanml
07601f4a90
Setting tx param type before signing transactions (#11497)
Fixes MetaMask/metamask-extension#11491
2021-07-12 13:26:53 -07:00
ryanml
e88c069398
Converting gas params for tx metrics to decimal GWEI (#11482) 2021-07-12 10:54:39 -07:00
ryanml
bf4cdb0b5c
Using current time in place of block timestamp for completion time metric (#11483) 2021-07-12 10:14:54 -07:00
Alex Donesky
1117e7b1fe
use ERC721 interface id instead of ERC721 metadata interface ID for identifying ERC721 tokens (#11495) 2021-07-12 11:55:48 -05:00
Daniel
d438439661
Swaps: Add conditional routing to new APIs based on a feature flag (#11470) 2021-07-09 10:24:00 -05:00
Brad Decker
68dfc98f40
wire up gasFeeController (#11421) 2021-07-08 15:23:00 -05:00
Brad Decker
64adfe7b11
update speedup and cancel to make room for EIP-1559 (#11407)
* prepare for EIP1559 gas fields in speedup/cancel

* Update ui/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js
2021-07-08 13:48:23 -05:00
周宇盛 Yusheng Zhou
cbe1d09396
✏️ fix typo of middleware imported from eth-json-rpc-middleware (#11455) 2021-07-06 10:53:35 -07:00
Brad Decker
da9fb4636b
move conversion utils to shared folder (#11451) 2021-07-06 12:48:49 -05:00
Dan J Miller
7163c56f3e
Add some metrics events to the 3box controller (#11447) 2021-07-02 17:00:40 -02:30
Dan J Miller
932444c355
Ensure transaction controller correctly estimates gas for special custom networks (#11441) 2021-07-02 13:01:27 -02:30
Brad Decker
27c140355e
Switch hardfork in getCommonConfiguration when EIP-1559 support is detected (#11385) 2021-06-30 09:39:00 -05:00
Brad Decker
8f371e4f87
add eip-1559 fields to event schema (#11408)
* add eip-1559 fields to event schema

* add gas_limit to all
2021-06-29 14:54:42 -07:00
Brad Decker
4ba565e719
track dapp suggested gas fees (#11410) 2021-06-29 15:08:16 -05:00
Brad Decker
55502f212d
update txParams normalization and validation. (#11406) 2021-06-29 14:25:56 -05:00
ryanml
3aae36754f
Updating address error (#11389) 2021-06-28 15:38:20 -07:00
Brad Decker
bc4a9b16d0
add account eip1559 detection support (#11380)
* add account eip1559 detection support

* add constants for keyring types
2021-06-28 12:29:08 -05:00
Brad Decker
b6f514e293
remove EIP-1559 fields from txParams before calling estimateGas (#11368) 2021-06-28 10:33:19 -05:00
Brad Decker
dd1330c707
Remove gasPrice defaults for eip-1559 txs (#11391) 2021-06-28 10:22:59 -05:00
Brad Decker
23a859826f
add method to detect EIP 1559 support (#11369) 2021-06-25 11:24:00 -05:00
Daniel
a1d7271ed7
Call Wyre’s API via our backend to generate Wyre’s Checkout URL (#11387)
* Call Wyre’s API via our backend to generate Wyre’s Checkout URL

* Add back paymentMethod=debit-card, use a fallback URL if no url is returned from BE

* Fix a lint issue

* Refactor how to return Wyre’s Checkout URL

* Add 2 constants into a test file, refactoring
2021-06-25 09:52:29 -05:00
Brad Decker
cb652c0fae
remove unused sufficient balance method (#11381)
this method relied on gasPrice being present and is safe to remove
2021-06-25 09:52:18 -05:00
Daniel
ba3f51d6ed
Add support for fiat on-ramp via Transak (#11376) 2021-06-25 08:10:24 -05:00
ryanml
a69ed05141
Removing obsolete client-side transaction metrics events (#11329)
* Removing metametrics send count tracking

* Removing client side Transaction Completed and Canceled events
2021-06-24 15:37:44 -07:00
Brad Decker
393e79ce3e
add maxPriorityFeePerGas and maxFeePerGas to incoming controller (#11367) 2021-06-24 14:52:14 -05:00
ryanml
d5ab1e1591
Adding metric events for Approved, Rejected, and Submitted to the TxController (#11358) 2021-06-24 12:00:54 -07:00
Alex Donesky
23f0270af2
add back strict equality checks in typed-message-manager, ensure that chainId comparison bases are both ints (#11340) 2021-06-23 16:32:23 -05:00
Alex Donesky
e10ddbe3a3
add erc-721 token detection and flag to disable sending (#11210)
* add erc-721 token detection and flag to disable sending

* addressing feedback

* remove redundant provider instantiation

* fix issue caused by unprotected destructuring

* add tests and documentation

* move add isERC721 flag to useTokenTracker hook

* Update  and  unit tests

* use memoizedTokens in useTokenTracker

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2021-06-22 12:39:44 -05:00
ryanml
303ba1eac8
Add 'Transaction Added' metric event to TransactionController (#11341) 2021-06-21 12:02:43 -07:00
Brad Decker
cf34e64f15
Support EIP-2718 transaction types, EIP-2930 and EIP-1559 support (#11288) 2021-06-16 15:40:17 -05:00
Alex Donesky
be98e05c58
patch breaking change in signTypeData param validation (#11309) 2021-06-15 13:17:38 -05:00
ryanml
2bfc3a093f
Using values from shared/constants/time to represent timing values (#11241) 2021-06-10 12:27:03 -07:00
Mark Stacey
e5a050b36f
Remove unused parameters from setProviderType (#11270)
Only the first parameter, `type`, was ever passed in. The others are
superfluous. The defaults have been set directly instead.

It's a bit silly to set the `rpcUrl` and `nickname` to an empty string,
but to make this more sensible would take much more effort. This at
least is simpler and guaranteed to be equivalent.
2021-06-10 13:54:18 -02:30
Dan J Miller
432d6508ba
Stringify gas estimate in backend, before it is serialized and sent to ui (#11266)
* Stringify gas estimate in backend, before it is serialized and sent to ui

* Fix send.utils.test.js
2021-06-09 22:18:05 -02:30
ryanml
a75092762f
Fix built-in networks switch-ethereum-chain, Including RPC url in switchEthereumChain requestData (#11268)
* Moving RPC Urls to network constants

* Including RPC url in switchEthereumChain requestData

* Setting project id to var

* Fix built-in networks switch-ethereum-chain

`switch-ethereum-chain` did not work correctly with built-in networks.
It was treating them as custom networks, rather than as built-in
networks. This affected how they were displayed in the network
dropdown, and resulted in slight differences to the network stack used
as well.

The problem was that `updateRpcTarget` was used, which was meant for
custom networks only. Now that `setProviderType` is used in the case of
a built-in network, the behaviour should match the network switcher
exactly.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-06-09 15:18:38 -07:00
Brad Decker
df9bc52e9f
Add gas constants (#11248) 2021-06-08 10:25:48 -05:00
ryanml
9932c40651
Adding periodic reminder modal for backing up recovery phrase (#11021)
* Adding recurring recovery phrase reminder modal

* Refactoring per PR feedback
2021-06-04 23:33:58 -07:00
ryanml
3242710f3d
Supporting existing default networks in switchEthereumChain (#11184) 2021-05-26 09:17:18 -07:00
Dan J Miller
1323a77531
Add stringified payload to metametrics controller trackEvent error message (#11166)
* Add stringified payload to metametrics controller trackEvent error message

* Don't include full payload when throwing error on missing event or category in trackEvent
2021-05-24 16:57:07 -02:30
Dan J Miller
3cbef734f2
Add event property to event sent on tx:status-update in metamask-controller (#11165) 2021-05-24 16:32:26 -02:30
Mark Stacey
5009ceae53
Migrate to new CurrencyRateController (#11005)
The CurrencyRateController has been migrated to the BaseControllerV2
API, which includes various API changes. These changes include:
* The constructor now expects to be passed a
`RestrictedControllerMessenger`.
* State changes are subscribed to via the `ControllerMessenger` now,
rather than via a `subscribe` function.
* The state and configration are passed in as one "options" object,
rather than as two separate parameters
* The polling needs to be started explicitly by calling `start`. It
can be stopped and started on-demand now as well.
* Changing the current currency or native currency will now throw an
error if we fail to update the conversion rate.

The `ComposableObservableStore` has been updated to accomodate these
new types of controllers. The constructor has been updated to use an
options bag pattern as well, to make the addition of the new required
`controllerMessenger` parameter a bit less unweildly.
2021-05-20 00:27:51 -02:30
Alex Donesky
f19207ca87
use etherscan-link customBlockExplorer methods with customNetwork usage tracking (#11017)
* use etherscan-link customBlockExplorer methods with customNetwork usage tracking

* consolidate blockexplorer events, add domain to metametrics event

* lint fix
2021-05-19 09:51:47 -05:00
ryanml
86b61a2fc2
Removing support survey notification from What's New (#11118)
* Removing support notification from what's new

* Adding migration for support notification removal

* Expanding test cases, using async/await for storage comparison
2021-05-18 10:55:55 -07:00
Mark Stacey
37dc19a352
Migrate Sentry settings to environment variables (#11085)
Sentry is now configured with environment variables, rather than with
hard-coded values. This makes it easier to test Sentry functionality
using a different Sentry account, as we did recently during QA of
v9.5.1.

The only change for the normal build process is the introduction of the
`SENTRY_DSN_DEV` variable, which can be set via `.metamaskrc` or via an
environment variable. This determines where error reports are sent. It
still defaults to our team Sentry account's `metamask-testing` project.

The `sentry:publish` script now requires SENTRY_ORG and SENTRY_PROJECT
to be set in order to publish release artifacts. The CircleCI
configuration has been updated with these values, so it should act the
same as it did before. Previously we had used a CLI flag to specify the
organization and project, but Sentry already natively supports these
environment variables [1].

[1]: https://docs.sentry.io/product/cli/configuration/#configuration-values
2021-05-18 13:56:22 -02:30
Shane
abba7f4159
fix metaRPCClientFactory id handling (#11116)
* fix metaRPCClientFactory id handling
2021-05-17 14:46:00 -07:00
Brad Decker
d9a2165f69
use safer toChecksum utility (#11117) 2021-05-17 16:19:39 -05:00
Brad Decker
9386e3cb03
create safer isValidAddress method (#11089) 2021-05-17 14:00:59 -05:00
Brad Decker
8f44383837
Migration to remove erroneous tx state (#11107) 2021-05-17 12:44:47 -05:00
Brad Decker
45cd98715a
fix splitting of transaction nonce groups in state (#11103)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-05-17 12:34:44 -05:00
Erik Marks
43c33b676f
@metamask/providers@8.1.1 (#11078)
* @metamask/providers@8.1.1

* Minimize import footprint
2021-05-12 19:51:14 -07:00
Shane
cacefc72fc
return early from metaRPCHandler if stream has ended (#11065)
* return early from metaRPCHandler if stream has ended

* add write after end guard to handleUpdate
2021-05-12 15:12:46 -07:00
Mark Stacey
89ef78674d
Replace uses of hasOwnProperty.call with simpler alternatives (#11009)
Three uses of `hasOwnProperty.call` have been replaced with simpler
alternatives. I did this because I found this convention confusing.

The `ComposableObservableStore` changes required adding a check for
whether the `config` is defined, because the old syntax would allow
iterating over `undefined` as if it was an empty object. Functionally
it should be identical. A new test was added to highlight this
functionality.
2021-05-11 14:09:17 -02:30
Erik Marks
35531d8360
Fix error behavior of addEthereumChain (#11031) 2021-05-11 09:34:52 -07:00
Erik Marks
2289e47e87
Update switchEthereumChain unrecognized chain error (#11030) 2021-05-10 15:29:07 -07:00
Brad Decker
c188e3fda0
rough in switchEthereumChain (#10905) 2021-05-10 14:14:21 -05:00
Mark Stacey
f47cfbbb3e
Use strict assertion mode everywhere (#11012)
The `assert` module has two modes: "Legacy" and "strict". When using
strict mode, the "strict" version of each assertion method is implied.
Whereas in legacy mode, by default it will use the deprecated, "loose"
version of each assertion.

We now use strict mode everywhere. A few tests required updates where
they were asserting the wrong thing, and it was passing beforehand due
to the loose matching.
2021-05-07 17:08:24 -02:30
Mark Stacey
14dc6b58cc
Remove SET_CURRENT_FIAT action (#11003)
The `SET_CURRENT_FIAT` action has been removed. It has been replaced
by a call to `forceUpdateMetamaskState`. The only purpose of this
action was to eagerly update the current fiat currency settings before
the next state update. Forcing a state update instead is simpler and
safer.

The `setCurrentCurrency` function in the background has been updated to
no longer return the state, now that it's no longer needed.
2021-05-07 11:32:22 -02:30
Erik Marks
29fa00a97b
@metamask/post-message-stream@4.0.0 (#10989) 2021-05-05 16:07:48 -07:00
Alex Donesky
96fe563579
add setting to dismiss seed phrase backup reminder (#10967) 2021-05-05 08:58:29 -05:00
David Walsh
04ab1e72cc
Fix #10173 - Prevent lag in external monitors when using Mac + Chrome (#10952) 2021-04-30 10:28:07 -05:00
Brad Decker
5928bc0256
fix transaction sync logic (#10954) 2021-04-29 12:51:39 -05:00
Brad Decker
09d81ac5f2
remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
Dan J Miller
b73f543b23
Whats new popup (#10583)
* Add 'What's New' notification popup

* Move selectors from shared/notifications into ui/ directory

* Use keys for localized message in whats new notifications objects, to ensure notifications will be translated.

* Remove unused swaps intro popup locale messages

* Fix keys of whats new notification locales

* Remove notifications messages and descriptions from comment in shared/notifications

* Move notifcationActionFunctions to shared/notifications and make it stateless

* Get notification data from constants instead of state in whats-new-popup

* Code cleanup

* Fix build quote reference to swapsEthToken, broken during rebase

* Rename notificationFilters to notificationToExclude to clarify its purpose

* Documentation for getSortedNotificationsToShow

* Move notification action functions from shared/ to whats-new-popup.js

* Stop setting swapsWelcomeMessageHasBeenShown to state in app-state controller

* Update e2e tests for whats new popup changes

* Updating migration files

* Addressing feedback part 1

* Addressing feedback part 2

* Remove unnecessary div in whats-new-popup

* Change getNotificationsToExclude to getNotificationsToInclude for use in the getSortedNotificationsToShow selector

* Delete intro-popup directory and test files

* Lint fix

* Add notifiction state to address-entry fixture

* Use two separate functions for rendering first and subsequent notifications in the whats-new-popup

* Ensure that string literals are passed to t for whats new popup text

* Update import-ui fixtures to include notificaiton controller state

* Remove unnecessary, accidental change confirm-approve

* Remove swaps notification in favour of mobile swaps as first notifcation and TBD 3rd notification

* Update whats-new-popup to use intersection observer api to detect if notification has been seen

* Add notifications to send-edit and threebox e2e test fixtures

* Update ui/app/selectors/selectors.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update ui/app/selectors/selectors.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Clean up locale code for whats-new-popup notifications

* Disconnect observers in whats-new-popup when their callback is first called

* Add test case for migration 58 for when the AppStateController does not exist

* Rename popover components containerRef to popoverWrapRef

* Fix messages.json

* Update notification messages and images

* Rename popoverWrapRef -> popoverRef in whats-new-popup and popover.component

* Only create one observer, and only after images have loaded, in whats-new-popup

* Set width and height on whats-new-popup image, instead of setting state on img load

* Update ui/app/components/app/whats-new-popup/whats-new-popup.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Code clean up in whats new popup re: notification rendering and action functions

* Code cleanup in render notification functions of whats-new-popup

* Update ui/app/components/app/whats-new-popup/whats-new-popup.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* lint fix

* Update and localize  notification dates

* Clean up date code in shred/notifications/index.js

Co-authored-by: ryanml <ryanlanese@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-04-28 14:21:41 -02:30
Brad Decker
cbce07e983
upgrade eth-keyring-controller (#10933) 2021-04-27 12:03:58 -05:00
David Walsh
15b596ad15
Implement Ledger Live bridge (#10293) 2021-04-26 13:05:48 -05:00
Brad Decker
f1825e850d
use one segment instance (#10915) 2021-04-26 11:05:43 -05:00
Brad Decker
d1f8171877
upgrade ethereumjs util (#10886) 2021-04-16 10:05:13 -05:00
ryanml
2f8908804a
Handling infura blockage (#10883)
* Handling infura blockage

* Adding blockage home notification

* Updating copy, adding temporary notification dismissal

* Addressing review feedback

* Using eth_blockNumber method to check Infura availability

* Handling network changes in availability check
2021-04-15 10:41:40 -07:00
David Walsh
fc30fd44d7
Fix 10036 - Prevent odd localStorage migration error in Firefox (#10884) 2021-04-14 09:24:17 -05:00
Daniel
e7d7d24d83
Reduce calls of the /featureFlag API (#10859)
* Remove periodic calls to the /featureFlag API

* Always show the Swap button on the main page

* Check if the Swaps feature is enabled, show loading animation while waiting

* Reuse an existing useEffect call

* Use ‘isFeatureFlagLoaded’ in React’s state, resolve lint issues

* Add a watch mode for Jest testing

* Add unit tests for Swaps: fetchSwapsLiveness, add /ducks/swaps into Jest testing

* Remove Swaps Jest tests from Mocha’s ESLint rules

* Ignore Swaps Jest tests while running Mocha, update paths

* Increase test coverage to the current max

* Fix ESLint issues for Swaps

* Enable the Swaps feature by default and after state reset, remove loading screen before seeing Swaps

* Update Jest config, fix tests

* Update Jest coverage threshold to the current maximum

* Update ESLint rule in jest.config.js

* Disable the “Review Swap” button if the feature flag hasn’t loaded yet

* Update jest threshold
2021-04-14 04:46:27 -02:30
Erik Marks
e18deda0da
@metamask/eslint-config*@6.0.0 (#10858)
* @metamask/eslint-config*@6.0.0

* Minor eslintrc reorg
2021-04-08 14:34:55 -07:00
Erik Marks
e142bf0c5e
Fix _getPermittedAccounts type safety (#10819) 2021-04-05 11:32:46 -07:00
kumavis
952adbce44
Build - refactor background process to use html (#10769)
* build - declare background as html

* build - fill in empty file when a missing file is expected

* lint - fix

* Update development/build/manifest.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update development/build/manifest.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-03-31 11:12:28 +08:00
Dan J Miller
2dadf4374a
Use network specific swaps contract address when checking swap contract token approval (#10774) 2021-03-30 16:25:14 -02:30
Brad Decker
4080ed63a4
Refactor Tx State Manager (#10672)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-03-30 09:54:05 -05:00
David Walsh
29cc31afe8
Fix 10517 - Prevent tokens without addresses from being added to token list (#10593) 2021-03-29 16:05:36 -05:00
Erik Marks
6d1add7afe
eth-block-tracker@5.0.1 (#10737) 2021-03-26 10:03:44 -07:00
Grant Bakker
94fc420584
Allow 11 characters in symbol for RPC (#10670)
* Add error in RPC for zero length symbols

* Increase RPC symbol length allowed to 11

* Add RPC tests for new symbol length checks
2021-03-26 10:40:17 -02:30
Etienne Dusseault
8fc2c3272a
security - update SES lockdown (#10663)
* update ses

* build - reference ses directly

* deps - unify regenerator-runtime versions on 0.13.7

* patches - apply regenerator-runtime ses compat patch\nhttps://github.com/facebook/regenerator/pull/411

* patches - patch regenerator-runtime for latest ses fix

* reduc patch, new lockdown severe override taming

* updated redux patch

* update redux patch for production

* ignore lockdown in lint

* deps - bump patch-package just in case

* trailing comma

* remove ses as dep

* fix path for frozen promise

* remove js extension in lockdown require

* Revert "ignore lockdown in lint"

This reverts commit 8cefdc94dd25d7781bb09eed8af36441397676da.

* Revert "build - reference ses directly"

This reverts commit 30371a377dcdd781c1bf9abe55e9c8ae34da26b5.

* deps - update ses

* Revert "fix path for frozen promise"

This reverts commit 966e4c60921a25befe8ca8dea58313cc25852f72.

Co-authored-by: kumavis <aaron@kumavis.me>
2021-03-26 12:27:25 +08:00
Dan J Miller
9573aa7515
Update @metamask/controllers to v6.2.1 (#10701) 2021-03-25 17:37:52 -02:30
kumavis
bfdc1e68f5
Delete setupFetchDebugging.js (#10636)
* Delete setupFetchDebugging.js

* remove fetch-debugging (now handled corrently by sentry)
2021-03-23 18:05:49 +08:00
Brad Decker
1b4504e233
make migration more safe (#10689) 2021-03-22 10:21:52 -05:00
Brad Decker
a81629e104
refactor incoming tx controller (#10639) 2021-03-19 16:54:30 -05:00
ryanml
530e8c132f
Fixing incorrectly typed token decimal attribute (#10666) 2021-03-19 10:17:39 -07:00
Shane
b50fe3184a
fix: replace dnode background with JSON-RPC (#10627)
fixes #10090
2021-03-18 11:23:46 -07:00
Dan J Miller
480512d14f
Swaps support for local testnet (#10658)
* Swaps support for local testnet

* Create util method for comparison of token addresses/symbols to default swaps token

* Get chainId from txMeta in _trackSwapsMetrics of transaction controller

* Add comment to document purpose of getTransactionGroupRecipientAddressFilter

* Use isSwapsDefaultTokenSymbol in place of repeated defaultTokenSymbol comparisons in build-quote.js
2021-03-18 07:50:06 -02:30
Brad Decker
5a233e4634
colocate tests in flat structure (#10655) 2021-03-16 16:00:08 -05:00
Dan J Miller
153bbc6053
Move swaps constants to the shared constants directory (#10614) 2021-03-15 10:51:35 -02:30
Brad Decker
3d4dfc74a8
prefer chainId over networkId in most cases (#10594) 2021-03-12 16:23:26 -06:00
Shane
b21cc5660f
fix: speedup cancellation (#10579)
fixes #7305
2021-03-12 11:26:07 -08:00
Niranjana Binoy
84b1379b40
Setting balance to 0x0 when the original value is undefined (#10634) 2021-03-12 10:20:33 -05:00
Brad Decker
2ed5bafa11
remove transactionCategory in favor of more types (#10615)
* remove transactionCategory in favor of more types

* remove reference to STANDARD in stubs
2021-03-10 14:16:44 -06:00
Erik Marks
a29fc51838
Ensure permission log will only store JSON-able data (#10524) 2021-03-10 11:50:06 -08:00
Brad Decker
38fe75b7d9
prefer chainId when building block explorer urls (#10587) 2021-03-09 15:37:19 -06:00
David Walsh
92680cf56f
Add support for multiple Ledger & Trezor hardware accounts (#10505) 2021-03-09 14:39:16 -06:00
David Walsh
aeffe176b3
Hide zero balance tokens with preference (#10486) 2021-03-09 13:35:55 -06:00
Dan J Miller
c86ceacfd9
Standard reference to ETH_SWAPS_TOKEN_ADDRESS via ETH_SWAPS_TOKEN_OBJECT.address (#10613) 2021-03-09 12:29:35 -03:30
Mark Stacey
79a7199a2f
Fix mobile sync of ERC20 tokens (#10591)
In #10510 we changed how tokens are stored, keying them by `chainId`
rather than network type. However we didn't update our mobile sync
function to account for this, which ended up breaking the filtering
logic used to prepare the data that is synced.

Specifically, custom tokens added by users are filtered out to just
those that are confirmed to be ERC20 tokens in our built-in list of
tokens. This filters out unrecognized tokens and NFTs.

The filtering logic has been restored to the pre-#10510 behaviour.
2021-03-04 18:43:15 -03:30
Brad Decker
e42658b590
cache balances by chain id (#10545) 2021-03-02 16:53:07 -06:00
Brad Decker
616b71271a
add chainId to all new transaction metadata (#10528) 2021-03-01 09:15:42 -06:00
Brad Decker
caa32d87fb
key tokens by chainId (#10510) 2021-02-26 09:40:25 -06:00
Brad Decker
1a2dc850a3
addEthereumChain bug fixes (#10520) 2021-02-25 16:25:51 -06:00
Brad Decker
15d78b8158
use chain id for enabling ENS IPFS resolution (#10507) 2021-02-25 05:40:57 -06:00
Niranjana Binoy
465dcb5e91
Wrong Currency Symbol when using Custom Network (#10490) 2021-02-24 15:39:56 -05:00
Mark Stacey
684c5855cd
Remove unused TransactionController option (#10508)
The function `getNetwork` was being passed into the
TransactionController constructor, but no such option was used in the
controller itself.
2021-02-24 01:01:09 -03:30
Brad Decker
aaec480e32
fix misuse of getCurrentNetwork (#10504) 2021-02-23 12:33:33 -06:00
Brad Decker
823466b62a
Re-add handler for addEthereumChain (#10489) 2021-02-23 10:32:46 -06:00
Brad Decker
1d23b59af3
add Custom Network Added event (#10484) 2021-02-23 09:58:35 -06:00
Shane
e3084b87cc
fix: manually connect accountsChanged (#10477)
fixes #9933
2021-02-19 09:48:49 -08:00
Austin Akers
2122b8cf16
Hide links to etherscan when no block explorer is specified for a custom network (#10455)
Conditionally render view on Etherscan text if it's a custom network

Fixes: #5631
2021-02-17 09:45:30 -03:30
Brad Decker
4c5edea294
fix contract exchange rate race condition (#10414) 2021-02-12 11:41:53 -06:00
Erik Marks
e48053a6d5
Add custom network RPC method (#9724)
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
Co-authored-by: Brad Decker <git@braddecker.dev>
2021-02-12 09:25:58 -06:00
jpatel888
38078d7a8d
Fix BatchRequest.execute() multiple window issue (#10423) 2021-02-11 18:37:56 -03:30
Brad Decker
bd1683402a
use native currency in asset row (#10413)
* use native currency in asset row

* set native currency on startup
2021-02-11 12:20:08 -06:00
Brad Decker
19fa2f5962
cancel unapproved confirmations on network change (#10357) 2021-02-08 17:22:30 -06:00
Erik Marks
76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00
Thomas Huang
6a89261f28
Reject Trezor eth_getEncryptionPublicKey requests (#10330)
Further implements request rejection on eth_getEncryptionPublicKey for Trezor as they do not implement this method either.
2021-02-02 07:25:30 -08:00
Etienne Dusseault
6b34fb4184
Use @lavamoat/allow-scripts (#10009)
* use @lavamoat/allow-scripts for package postinstall allow list
* dnode: set "weak" to false

Co-authored-by: kumavis <kumavis@users.noreply.github.com>
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2021-02-01 20:08:42 -08:00
Thomas Huang
23bab62008
Reject eth_getEncryptionPublicKey for ledger hw wallets (#10326)
Fixes #10111

Determine if the msgParams/address for the newRequestEncryptionPublicKey is a ledger keyring via getKeyringForAccount and return a promise rejection.
2021-02-01 12:39:09 -08:00
Erik Marks
7ebab83e40
Fix logWeb3ShimUsage metrics (#10286) 2021-01-25 14:20:44 -08:00
Thomas Huang
1dad4abfdc
Fix site metadata JSON-RPC handler (#10243)
* Fix getting the site metadata from the request origin params.

Regressed from inpage-provider ts migration the request. The property domainMetadata is now set as a params key for the request.

https://github.com/MetaMask/inpage-provider/blob/v7.0.0/src/siteMetadata.js#L19-L25
vs
https://github.com/MetaMask/inpage-provider/blob/main/src/siteMetadata.ts#L19-L27

* Change hardcoded mocked response of the request to the prod response.
2021-01-22 10:27:07 -08:00
Erik Marks
30ff153103
eth-rpc-errors@4.0.2 (#10226) 2021-01-20 22:06:41 -08:00
Erik Marks
4fef2b7443
Add MAX_SAFE_CHAIN_ID and refactor chain ID validation (#10224)
* Add MAX_SAFE_CHAIN_ID constant
* Add isSafeChainId to shared utils module
* Move isPrefixedFormattedHexString to shared utils module
* Validate custom RPC chain IDs in network controller
* Update some network controller error messages.
* Add isSafeChainId validation to UI
2021-01-20 15:37:18 -08:00
Erik Marks
7077ee68dc
Add NETWORK_TYPE_RPC constant (#10203)
* Refactor network display props
* Add NETWORK_TYPE_RPC constant
* Consolidate network constants
2021-01-20 08:49:05 -08:00
Erik Marks
90289ec22a
Further improve organization of constants (#10200) 2021-01-20 08:13:14 -08:00
Erik Marks
7159dd6867
Fetch with a timeout everywhere (#10101)
* Use fetchWithTimeout everywhere
* Memoize getFetchWithTimeout
* Require specified timeout
2021-01-19 08:41:57 -08:00
Erik Marks
0dfdd44ae7
Restore support for @metamask/inpage provider@"< 8.0.0" (#10179)
This restores support for versions of the inpage provider prior to v8.
This is intended to support dapps and extensions that directly
instantiated their own provider rather than using the injected
provider.

* Forward traffic between old and new provider streams

* Ignore publicConfig stream for non-legacy muxes

* Transform accountsChanged notification for legacy streams

* Convert publicConfigStore to singleton

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-01-12 17:43:45 -08:00
Dan J Miller
2431a5821c
Migration 51: ensure chainId is set in state for default/infura providers (#10170)
* Migration 51: ensure chainId is set in network controller provider state for all infura/default networks

* Clean up

* Migrate incorrect as well as falsy chainIds

Co-authored-by: Erik Marks <rekmarks@protonmail.com>
2021-01-11 11:09:15 -03:30
Mark Stacey
69e883c728
Detect tokens on custom Mainnet RPC endpoints (#10157)
Our automatic token detection was hard-coded to only work on our built-
in Infura Mainnet endpoint. It now works with custom Mainnet RPC
endpoints as well.

Relates to #6992
2021-01-08 10:55:46 -03:30
Brad Decker
b5fc1f9314
improve handling of last selected provider (#10093) 2021-01-06 17:31:11 -06:00
David Walsh
c42087d044
Use destructured signal (#10115) 2020-12-23 10:15:07 -06:00
Brad Decker
64adcae08d
throw a new wrapped error instead of default one from segment (#10118) 2020-12-23 00:24:49 -03:30
Mark Stacey
889ca62723
Use late-bound noop function when disabling console (#10110)
The `disable-console` script introduced in #10040 used an arrow-
function no-op function to replace `console.log` and `console.info`.
This replacement function was early-bound to the `this` context of the
`disable-console` script, because that's how arrow functions work.

This violates an assumption baked into Sentry, which also replaces the
`console` functions. It wraps them in a function it uses to track
console logs as breadcrumbs. This wrapper function blows up for some
reason if the "original" `console` function is early-bound to a `this`
value of `undefined`.

This resulted in various UI freezes. One example is during onboarding,
when using Firefox with Enhanced Tracking Protection set in "strict"
mode. After submitting a password in the 'Create wallet' flow, the
Sentry `console` wrapper would throw and leave the user stuck on the
loading screen.

By replacing the no-op arrow function with a no-op function
declaration, the problem has been resolved.

Relates to #10097
2020-12-19 16:58:49 -03:30
Mark Stacey
d2b6376c3d
Skip reporting of successive persistence failures (#10099)
Failure to persist state will now only report to Sentry if the last
attempt to save state succeeded. This ensures that if anyone is stuck
in a state where state can't be saved (e.g. low disk space), we aren't
flooded with repeated errors on Sentry.
2020-12-17 15:39:01 -03:30
Mark Stacey
bba2b9646d
Update @metamask/controllers to v5.1.0 (#10096)
This update comes with a breaking change to the Approval controller. It
now requires a `defaultApprovalType` parameter.

I don't think we have any use for a default approval type, but I've
added a "NO_TYPE" one for now because it's a strict requirement. We
should consider making this parameter optional in the future, for cases
like this where it's not needed.

This update will hopefully address some caching issues we've been
seeing with our phishing configuration. See here for more details:
https://github.com/MetaMask/controllers/pull/297
2020-12-17 12:06:29 -03:30
Erik Marks
e05be40d92
@metamask/obs-store@5.0.0 (#10092) 2020-12-16 13:14:49 -08:00
David Walsh
88525ec392
Fetch swap quote refresh time from API (#10069) 2020-12-15 16:54:22 -03:30
Erik Marks
eeee8852cd
Add eth_getProof to safe methods (#10070)
`eth_getProof` is an unpermissioned, read-only RPC method for getting account-related Merkle proofs, specified here: https://eips.ethereum.org/EIPS/eip-1186

It's been supported by major Ethereum clients, and Infura, for some time. By adding it to the safe methods list, we enable this method for our users.
2020-12-14 15:21:15 -08:00
Etienne Dusseault
69df19f195
Disable console in contentscript (#10040)
* Maintain console logging in dev mode

Co-authored-by: kumavis <aaron@kumavis.me>
Co-authored-by: Erik Marks <rekmarks@protonmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-12-14 11:17:13 -08:00
David Walsh
9a1548368f
Use Boolean for filters (#10066) 2020-12-14 11:03:59 -06:00
Erik Marks
8f40d03299
Add approval controller (#9401)
This PR introduces the new approval controller to the extension codebase. We use it for the permissions controller's pending approval functionality.

The approval controller sets us up for a new pattern of requesting and managing user confirmations in RPC methods. Along with the generic RPC method middleware, the approval controller will allow us to eliminate our message managers, and decouple various method handlers from our provider stack, making the implementations more portable between the extension and mobile.
2020-12-14 08:04:26 -08:00
Erik Marks
54e9c53b27
Add web3 shim usage notification (#10039)
* Add web3 shim usage alert background state and logic
* Cleanup alert background state, constants
* Implement web3 shim usage notification and settings
* nodeify alert controller background hooks
* Remove svg icon, again
* Tweak alert controller initialization
* Add support article URL
* Un-thunk alert UI "actions"
* Delete connect.svg file (unused)
2020-12-10 15:40:29 -08:00
Mark Stacey
86fba2dac1
Fix contentscript injection failure on Firefox 56 (#10034)
On Firefox 56 and Waterfox Classic, our `runLockdown.js` script throws
an error. This is fine on the HTML pages, as the next script tags still
get run without issue (though they don't benefit from the SES lockdown
sadly). But in the `contentscript`, an exception thrown here appears to
halt the execution of subsequent scripts.

To prevent the `contentscript` from crashing completely, lockdown
errors are now caught and logged. They are also logged to Sentry on the
pages where Sentry is setup.
2020-12-10 14:03:04 -03:30
Patryk Łucka
e4a77e1dc3
Add hidden tokens to store (#9320)
From a behavioral standpoint this PR fixes the issue with tracking, and persisting, tokens that the user hides. Whether we can/should optimize this to prevent duplicates of the accountHiddenTokens and hiddenToken is a point of contention, but it acts similiarly to how we track tokens and accountTokens. 

Also to note, for tokens under a custom network there is no way to distinguish two different custom network sets of hidden tokens, they are all under the `rpc` property, same as accountTokens.
2020-12-08 12:38:00 -08:00
Erik Marks
3bf94164ac
@metamask/inpage-provider@^8.0.0 (#8640)
* @metamask/inpage-provider@^8.0.0
* Replace public config store with JSON-RPC notifications
* Encapsulate notification permissioning in permissions controller
* Update prefix of certain internal RPC methods and notifications
* Add accounts to getProviderState
* Send accounts with isUnlocked notification (#10007)
* Rename provider streams, notify provider of stream failures (#10006)
2020-12-08 11:48:47 -08:00
Mark Stacey
55e5f5513c
Log persistence errors with Sentry (#10018)
Failures to persist state are now logged in Sentry. Previously they
were only logged to the background console.
2020-12-08 16:17:51 -03:30
Mark Stacey
f75c3c6f68
Fix unbound metrics track function (#10016)
The new metrics controller has a `trackEvent` function that was being
called unbound, so `this` references were undefined. It is now bound
early in both places where it is passed in as a parameter.
2020-12-08 12:40:55 -03:30
Mark Stacey
2bcb219501
Deobfuscate error message (#10012)
The SES lockdown added in #9729 had the effect of obfuscating our error
messages. Any messages printed to the console would have the error
message replaced with the string "Error #" followed by a number. The
stack was also updated to point at `lockdown.cjs`, though the original
stack was preserved beneath the top stack frame.

Marking the `console` API as untamed seems to have fixed both issues.
The original error message is now printed to the console, along with
the original stack.
2020-12-08 07:24:31 +08:00
Erik Marks
6795298c65
Remove web3 injection (#9156)
* Remove web3 injection
* Implement logWeb3ShimUsage
2020-12-07 12:09:02 -08:00
Thomas Huang
26272d3557
Initialize network controller provider chainId to the appropriate default networks (#9999) 2020-12-07 11:40:42 -08:00
Erik Marks
4839e31e05
Fix Infura network chain IDs (#8629) 2020-12-07 11:39:39 -08:00
Erik Marks
baea1b57fb
Update transaction params validation (#9992)
* Update transaction params validation

* fixup! Update transaction params validation

* Update to/data error message

* fixup! Update to/data error message
2020-12-03 18:15:59 -08:00
Dan J Miller
1661953e23
Migration to remove legacy local storage keys from localStorage (#9986)
* Migration to remove legacy local storage keys from localStorage

* Update app/scripts/migrations/050.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update app/scripts/migrations/050.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Fix unit tests for migration 50

* Fixing stubbing and localstorage reference in migration 50

* Update test/helper.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-12-03 20:25:23 -03:30
Mark Stacey
703a063ad1
Fix metrics error when options are not used (#9985)
Attempts to send metrics would fail when no `options` were used. This
was because when the options parameter was not set, it was often sent
over our RPC connection as `undefined`, which gets serialized to `null`
when the message is converted to JSON. This `null` parameter didn't
trigger the default parameter set in the metametrics controller, as
default parameters are only used for `undefined`.

Instead the `options` parameter is now treated as fully optional, with
no default value set. The optional chaining operator is used to ensure
it won't blow up if it's not set. A fallback of `{}` was used for the
one destructure case as well.
2020-12-03 15:35:11 -03:30
Mark Stacey
52d25f0df8
Fix inflated gas estimates (#9984)
If a `gasPrice` was specified in a transaction sent via a dapp, we
would include it in our `eth_estimateGas` call, causing it to fail if
the user had insufficient balance (for either the transaction amount or
the gas fee). This resulted in the fallback gas estimate being used;
the block gas limit. The block gas limit is quite a bit larger than
most transactions need, so this resulted in wildly inflated gas costs
being shown on our confirmation screen.

The `gasPrice` has been removed from the `txParams` object we pass to
`eth_estimateGas`, so now it won't perform any balance checks anymore.
This ensures that we'll get a valid gas estimate, as long as geth is
able to simulate the contract execution properly.

Fixes #9967
2020-12-03 13:55:42 -03:30
Dan J Miller
97d268c8ee
Remove use of ethgasstation; use metaswap /gasPrices api for gas price estimates (#9867)
* Remove use of ethgassthat; use metaswap /gasPrices api for gas price estimates

* Remove references to ethgasstation

* Pass base to BigNumber constructor in fetchExternalBasicGasEstimates

* Update ui/app/hooks/useTokenTracker.js

Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>

* Delete gas price chart

* Remove price chart css import

* Delete additional fee chart code

* Lint fix

* Delete more code no longer used after ethgasstation removal

Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-12-02 19:55:19 -03:30
Brad Decker
0653a489b0
add new MetaMetricsController (#9857) 2020-12-02 15:41:30 -06:00
Erik Marks
5fb2e544d4
Add __isMetaMaskShim__ property to injected web3 (#9972) 2020-12-02 12:35:45 -08:00
Erik Marks
1da9ad77a4
json-rpc-engine@6.1.0 (#9922) 2020-12-02 11:41:24 -08:00
Erik Marks
c3eb272af9
Use method middleware for watchAsset (#9943)
* Use method middleware for watchAsset
* Update validation error messages
* Make addSuggestedERC20Asset private
* Remove redundant check in _handleWatchAssetERC20
2020-12-02 08:49:49 -08:00
Erik Marks
9d4b8a4903
@metamask/contract-metadata (#9968) 2020-12-01 14:55:01 -08:00
Erik Marks
cb44cff168
Fix watchAsset symbol validation (#9960) 2020-11-30 12:59:01 -08:00
Etienne Dusseault
9f6fa64d67
Add SES lockdown to extension webapp (#9729)
* Freezeglobals: remove Promise freezing, add lockdown

* background & UI: temp disable sentry

* add loose-envify, dedupe symbol-observable

* use loose envify

* add symbol-observable patch

* run freezeGlobals after sentry init

* use require instead of import

* add lockdown to contentscript

* add error code in message

* try increasing node env heap size to 2048

* change back circe CI option

* make freezeGlobals an exported function

* make freezeGlobals an exported function

* use freezeIntrinsics

* pass down env to child process

* fix unknown module

* fix tests

* change back to 2048

* fix import error

* attempt to fix memory error

* fix lint

* fix lint

* fix mem gain

* use lockdown in phishing detect

* fix lint

* move sentry init into freezeIntrinsics to run lockdown before other imports

* lint fix

* custom lockdown modules per context

* lint fix

* fix global test

* remove run in child process

* remove lavamoat-core, use ses, require lockdown directly

* revert childprocess

* patch package postinstall

* revert back child process

* add postinstall to ci

* revert node max space size to 1024

* put back loose-envify

* Disable sentry to see if e2e tetss pass

* use runLockdown, add as script in manifest

* remove global and require from runlockdown

* add more memory to tests

* upgrade resource class for prep-build & prep-build-test

* fix lint

* lint fix

* upgrade remote-redux-devtools

* skillfully re-add sentry

* lintfix

* fix lint

* put back beep

* remove envify, add loose-envify and patch-package in dev deps

* Replace patch with Yarn resolution (#9923)

Instead of patching `symbol-observable`, this ensures that all
versions of `symbol-observable` are resolved to the given range, even
if it contradicts the requested range.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-11-24 11:26:43 +08:00
Mark Stacey
31a3541105
Remove invalid matomo metric event option (#9897)
The `matomo` option passed to the send metrics function is invalid. The
intent was to set the `matomoEvent` option, but instead of rectifying
that, we've decide to keep sending this event to the production Segment
project for now. The invalid option has been removed.
2020-11-17 15:59:05 -03:30
Erik Marks
2687163dbb
Fix minor issues with web3 metrics (#9895)
* Fix minor issues with web3 metrics

* Log error, use try/catch
2020-11-17 11:07:59 -08:00
Brad Decker
daf783a0d8
Track a new schema event when adding a token (#9810)
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-11-17 11:39:21 -06:00
Nate Chastain
179dbcb41c
Remove CoinSwitch from Deposit screen(#9869)
Remove all CoinSwitch references and functionality, and bump Wyre to top spot on Deposit screen unless user on test network
2020-11-16 13:57:53 -03:30
Erik Marks
5a80f04dca
Consolidate notification UI openers (#9885)
* Consolidate notification UI openers

* Update tests
2020-11-16 08:32:53 -08:00
Dan J Miller
bcd5f2a7c1
Fix gas_fees properties collected for swaps analytics events (#9727) 2020-11-10 14:09:45 -03:30
Mark Stacey
14d85b1332
Make JSDoc formatting more consistent (#9796)
A few inconsistencies in JSDoc formatting have been fixed throughout
the project. Many issues remain; these were just the few things that
were easy to fix with a regular expression.

The changes include:

* Using lower-case for primitive types, but capitalizing non-primitive
 types
* Separating the parameter identifier and the description with a dash
* Omitting a dash between the return type and the return description
* Ensuring the parameter type is first and the identifier is second (in
 a few places it was backwards)
* Using square brackets to denote when a parameter is optional, rather
 than putting "(optional)" in the parameter description
* Including a type and identifier with every parameter
* Fixing inconsistent spacing, except where it's used for alignment
* Remove incorrectly formatted `@deprecated` tags that reference non-
 existent properties
* Remove lone comment block without accompanying function

Additionally, one parameter was renamed for clarity.
2020-11-10 14:00:41 -03:30
Mark Stacey
a6cc2d3d7c
Track whether seed phrase has been backed up (#9830)
The `seedPhraseBackedUp` now tracks whether or not the seed phrase has
been backed up. Previously this defaulted to `true`, which left no way
to distinguish whether it had been backed up or not during onboarding.

The default is now `null`, and the UI logic has been updated to account
for this, so that "existing users" (i.e. users that have a backup that
is years old) aren't mistakenly considered to have not backed up their
seed phrase. This value is already set explicitly to `true` or `false`
during onboarding, in both the create and import flow.

This change was made primarily to make it easier to fix the onboarding
library integration, which will be done in a subsequent PR.
2020-11-10 12:34:20 -03:30
Dan Finlay
8443c3bdde
Warn instead of throw on duplicate web3 and do not inject (#9832) 2020-11-09 10:40:40 -08:00
Erik Marks
e005a03e75
eth-sig-util@3.0.0 (#9831)
* eth-sig-util@3.0.0

* Only import used sig-util exports in the typed message manager
2020-11-09 09:30:33 -08:00
Dan J Miller
c044b6f2b4
Alternative savings fix (#9675)
* Alternative savings fix

* Further required changes to savings fix

* Further fix to savings calculations that properly accounts for metamask fees

* metaMaskFeeInEth property on quotes to decimal string

* Fix swaps controller unit tests

* Improve documentation in swaps controller

* Prevent getMedianEthValueQuote from mutation passed quotes array with .sort() call

* Another fix and refactor to savings calculations in _findTopQuoteAndCalculateSavings

Cleaner structuring of conditionals for setting tokenValueOfQuoteForSorting, ethValueOfQuote and metaMaskFeeInEth in swaps controller

Stop subtracting medianMetaMaskFee from savings, but include it in savings data

Another fix and refactor to savings calculations in _findTopQuoteAndCalculateSavings

* Add and update unit tests for _findTopQuoteAndCalculateSavings

* Improve calculation of overallValueOfQuoteForSorting for case where ETH is the source token

* Clean up getMedianEthValueQuote code, test and comments

* Clean up _findTopQuoteAndCalculateSavings, create test input and expected results helper functions

* Update getMedianEthValueQuote to account for multiple quotes with overall values equal to the median

* Add jsdoc comment for meansOfQuotesFeesAndValue

* Fix jsdoc comment for getMedianEthValueQuote
2020-11-09 13:39:38 -03:30
Erik Marks
0555cb856e Only import used sig-util exports 2020-11-09 08:59:44 -08:00
Erik Marks
6aa6052318 eth-sig-util@3.0.0 2020-11-09 08:57:18 -08:00
Brad Decker
a49a4a066c
expand transaction constants coverage (#9790)
* expand transaction constants coverage

* touchups

* dont import inside of e2e

* Update app/scripts/controllers/transactions/tx-state-manager.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update test/unit/app/controllers/transactions/tx-controller-test.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-11-07 01:38:12 -06:00
Patryk Łucka
ee205b893f
Create custom addHexPrefix function (#9306)
* create custom addHexPrefix function

* switch to custom addHexPrefix

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Erik Marks <rekmarks@protonmail.com>
2020-11-06 13:18:00 -08:00
Patryk Łucka
d1430e733e
Do not check popupIsOpen on Vivaldi (#9271) 2020-11-06 10:38:48 -08:00
Erik Marks
6426816411
Log web3 usage for functions and nested properties only (#9797)
* Log web3 usage for functions and nested properties only

* Change web3 metrics source to legacy

* Update web3 metrics properties and event name

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-11-05 14:55:28 -08:00
Brad Decker
026a06b39d
add shared transaction constants (#9459)
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-11-03 16:57:51 -06:00
Brad Decker
2ebf8756a4
[RFC] add prettier to eslint (#8595) 2020-11-02 17:41:28 -06:00
Mark Stacey
55bff07bbf
Use chainId for incoming transactions controller (#9583)
The incoming transactions controller now uses the `chainId` for the
current network instead of the `networkId`. This ensures that custom
RPC endpoints for the built-in supported networks do correctly receive
incoming transactions.

As part of this change, the incoming transactions controller will also
cease keeping track of the "last block fetched" for networks that are
not supported. This piece of state never really represented the last
block fetched, as _no_ blocks were fetched for any such networks. It
been removed.
2020-10-30 22:28:12 -02:30
Mark Stacey
4bacb9144f
Add description for the incoming transactions controller (#9759)
This comment block describes the responsibilities of this controller.
This was motivated by a suggestion made during review of #9755 [1]

[1]: https://github.com/MetaMask/metamask-extension/pull/9755#discussion_r514400479
2020-10-30 11:33:35 -02:30
Brad Decker
ff7ce81c73
fix for METAMASK-GKF5 (#9760) 2020-10-29 17:18:52 -05:00
Mark Stacey
4086f7b4d6
Fix error when fetchParams is null (#9757)
If the swaps state is cleared in between the initial quote fetch and
the subsequent poll fetch, a `TypeError` will be thrown due to
`fetchParams` being set to `null`.

This is of no functional consequence, as `fetchParams` _should_ be
`null` in this case, and and no further action should be taken.

The optional chaining operator is now used to ensure the call no longer
throws.
2020-10-29 15:52:04 -02:30
Mark Stacey
1294955d81
Fix swaps when initial network not Mainnet (#9745)
This is a continuation of #9726, which did not fix the problem
described.

If the initial network when the extension is started is something other
than Mainnet, the swaps controller will never successfully retrieve
swap quotes. This is because `ethers` will continue to communicate
with whichever network the provider was initially on.

We tried fixing this by hard-coding the `chainId` to Mainnet's
`chainId` when constructing the Ethers provider, but this did not work.
I suspect this failed because the `provider` we pass to `ethers` is not
compliant with EIP 1193, as `ethers` doubtless expects it to be.

Instead the entire `ethers` provider is now reconstructed each time the
network changes. This mirrors the approach we take in some other
controllers.
2020-10-28 16:17:32 -02:30
Mark Stacey
3bbc1d1fa4
Fix fetching of swap quotes when initial network was testnet (#9726)
If the initial network when the extension is started is something other
than Mainnet, the swaps controller will never successfully retrieve
swap quotes. This is because the `ethers` provider used by the swaps
controller doesn't allow network changes by default - it assumes that
the network remains the same as when the provider was initialized.

This was fixed by hard-coding Mainnet as the initial chain ID for this
`ethers` provider used by the swaps controller.

Some adjustments needed to be made to the `provider` stub to allow
setting `1` as the network ID and chain ID in unit tests.
2020-10-27 13:22:21 -02:30
Brad Decker
7d50357684
remove matomo and route to segment (#9646) 2020-10-26 14:05:57 -05:00
David Walsh
5c1c9c8f16 Fix 9632 - Prevent old fetches from polluting the swap state 2020-10-23 10:59:02 -05:00
Dan J Miller
5cc40bff41
Gas metrics tweaks for swaps failed and completed events (#9676)
* Change base of estimated_gas sent to analytics

* Add suggested_gas_price and used_gas_price to analytics
2020-10-22 17:34:34 -02:30
Whymarrh Whitby
6df17dc90e
Fix accessor-pairs issues (#9680)
Refs #9663

See [`accessor-pairs`][1] for more information.

This change enables `accessor-pairs` and fixes the issues raised by the rule.

  [1]:https://eslint.org/docs/rules/accessor-pairs
2020-10-22 14:36:44 -02:30
Whymarrh Whitby
362e717eef
Fix node/no-deprecated-api issues (#9670)
Refs #9663

See [`node/no-deprecated-api`][1] for more information.

This change enables `node/no-deprecated-api` and fixes the issues raised by the rule.

  [1]:https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-deprecated-api.md

The change to the way that `punycode` is imported is to address the fact that
third-party module is hidden by the built-in. This is a silly hack but it works.
2020-10-22 11:33:45 -02:30
Mark Stacey
07cffe92c6
Fix ENS resolution of .eth URLs with query strings (#9674)
Our ENS resolver for the browser address bar was incorrectly resolving
addresses that included query strings. We were concatenating the `path`
property with the `search` property, despite the fact that the `path`
property already contains `search`. As a result, `search` was
duplicated in the resolved addresses.

For example, if an IPFS content ID was found for this address, the
resolved address for `metamask.eth/?foo=bar` would have the path
`/?foo=bar?foo=bar`

The original intent was likely to use `pathname` in place of `path`.
The resolver has been updated to use `pathname`, and the query string
now appears only once in the resolved address.
2020-10-22 10:45:26 -02:30
Brad Decker
e5688c024e
consolidate segment setup (#9617)
Consolidates the background and UI segment implementations into a shared solution.

This results in the introduction of our first shared module.

Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
2020-10-21 16:10:55 -05:00
Mark Stacey
7d0a7ab301
Update @metamask/eslint-config to v4.1.0 (#9663)
`@metamask/eslint-config` has been updated to v4.1.0. This update
requires that we update `eslint` to v7 as well, which in turn requires
updating most `eslint`-related packages.

Most notably, `babel-eslint` was replaced with `@babel/eslint-parser`,
and `babel-eslint-plugin` was replaced by `@babel/eslint-plugin`. This
required renaming all the `babel/*` rules to `@babel/*`.

Most new or updated rules that resulted in lint errors have been
temporarily disabled. They will be fixed and re-enabled in subsequent
PRs.
2020-10-21 14:01:03 -02:30
Whymarrh Whitby
3c492a2ff7
Remove incorrect Migrator comment (#9659)
This change removes an incorrect comment about migrations
2020-10-20 11:34:55 -02:30
Erik Marks
7de7e7d8c2
Add swaps savings calculation (#9611)
* Calculate savings per swap relative to median values

* Update test mock quotes, add getMedian tests

* Identify assets by sourceToken and destinationToken
2020-10-19 14:52:47 -07:00
Mark Stacey
003f1306d3
Split the account tracker doc comments (#9574)
The account tracker had one doc comment above the constructor that
partially served to document the constructor, but mostly contained a
type definition for the class itself. It has been split into two
blocks; one for the class, one for the constructor. The constructor doc
comment has also been expanded to document all constructor options.
2020-10-15 13:09:13 -02:30
Mark Stacey
a53121a763
Use chainId in account tracker (#9573)
The `chainId` is now used by the account tracker to identify the
current network, instead of the `networkId`. This should have no
functional impact, aside from that different chains with the same
`networkId` will now be correctly distinguished from each other.
2020-10-15 11:18:30 -02:30
Mark Stacey
360d8ded1f
Fix exception upon failure to get next nonce (#9598)
An attempt to safely release the `nonceLock` upon failure has instead
made failure worse by masking it with a new error. If the call to get
the `nonceLock` throws an exception, then the `finally` block here
would attempt to call `releaseLock` on the `nonceLock` variable, which
is guaranteed to be `undefined` if the previous call failed. The
attempt to call a method on `undefined` throws another error, masking
the original error.

It is safer to obtain the `nonceLock` and release it without using any
`try` or `finally` block. The `nonceLock` is synchronously released
immediately after it is obtained, and any errors bubble up correctly
without being masked. There is no case where the lock is left
unreleased.
2020-10-14 13:34:08 -02:30
Mark Stacey
320e8c0af9
Fix TypeError when signTypedData throws (#9596)
If the `signTypedData` background function threw an exception, it would
return `undefined` to the UI, which would throw another exception in
the UI. It now re-throws the error if an error is thrown, which
allows the UI to handle the error.

I'm not sure why this might fail, and I'm not sure we're handling this
failure well, but this is an improvement at least.
2020-10-13 21:20:50 -07:00
Dan J Miller
00c8609f95
Add data point to 'Swaps Completed' segment event: estimated vs used gas (#9571)
* Add data point to 'Swaps Completed' segment event: estimated vs used gas

* Linted

* Correct property name for estimated gas on swapMetaData in _trackSwapsMetrics()

* Set estimated_gas property on swapMetaData to a hex string

* Correct base when dividing by estimated_gas

Co-authored-by: Dan Finlay <dan@danfinlay.com>
2020-10-13 16:11:26 -02:30
Erik Marks
6e8c9aede8
Migrate 'localhost' tokens (#9570)
* Delete localhost state from incoming tx controller

* Migrate localhost tokens

Co-authored-by: Dan Finlay <542863+danfinlay@users.noreply.github.com>
2020-10-13 07:07:00 -07:00
Mark Stacey
ded43cbcdf
Remove unused code (#9564)
A number of unused parameters and `propTypes` have been merged, along
with an unused function.
2020-10-13 11:18:22 -02:30
Erik Marks
4ce04b5cb9
Delete localhost state from incoming tx controller (#9569) 2020-10-13 06:18:24 -07:00