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

3415 Commits

Author SHA1 Message Date
Maarten Zuidhoorn
2900fe2c1a
Move subject type enum to @metamask/subject-metadata-controller (#16431)
* Move subject type enum to @metamask/controllers

* Fix imports
2023-01-24 16:03:01 +01:00
amerkadicE
dd09245ff6
Fix/use etherjs specific imports (#15461)
* replace ethers with submodules

Co-authored-by: Alex <adonesky@gmail.com>
2023-01-24 08:10:36 -06:00
Frederik Bolding
51518c42bb
[FLASK] snaps-monorepo@0.28.0 (#17277)
* snaps-monorepo@0.28.0

* Update LavaMoat policies

* Remove old blocklist implementation, add feature flags

* Lint

* Update iframe execution environment

* Change getPrimaryKeyringMnemonic return type

* Update tests

* Update key-tree
2023-01-23 20:41:04 +01:00
Brad Decker
ead1446c98
Refactor usages of conversion util in the app folder and shared folder in favor of Numeric (#17331) 2023-01-23 11:41:01 -06:00
Vladimir Saric
f988dc1c5e
Enable the Token Allowance flow by default for all users (#16740) 2023-01-23 21:49:55 +05:30
Brad Decker
af83e120dc
Convert app//scripts/lib/util.js to typescript (#17330) 2023-01-23 10:18:22 -06:00
Mark Stacey
cb12cb8f5a
Restore support for Chromium v78 (#17251)
Support has been restored for Chromium v78. Previously the extension
would crash upon startup.

The main incompatibility was the use of ES2020 operators (the optional
chain and nullish coalesce operators) in the libraries
 `@ethereumjs/util` and `superstruct`. This was resolved by transpiling
those libraries.

After fixing that, the extension no longer crashed but the UI refused
to connect. This was because the UI process was not being identified as
an internal process, because the code responsible for checking that was
relying on the `origin` property of `MessageSender` [1] which wasn't
added until Chromium v80. The check has been updated to use the `url`
property instead, which existed in older versions of Chrome.

Lastly, the content security policy was updated to include the default
content security policy alongside the intended modification. Newer
versions of Chrome will merge the configired CSP with the default, but
older versions required it to be explicitly specified. This should not
result in any functional change.

[1]: https://developer.chrome.com/docs/extensions/reference/runtime/#type-MessageSender
2023-01-23 12:36:48 -03:30
Filip Sekulic
27d34166fe
Security provider check (OpenSea) (#16584) 2023-01-23 20:02:01 +05:30
Mark Stacey
d6cf809bcc
Setup network controller mocks per-test (#17250)
The network controller unit test network mocks are now setup for each
test. This makes modifying network behavior on a per-test basis easier,
and makes it more clear which test relies upon which mocks.
2023-01-23 10:52:42 -03:30
Alex Donesky
c508087cf1
Integrate KeyringController v10 (#17056)
* integrate `@metamask/eth-keyring-controller` v10
2023-01-20 17:03:11 -06:00
ryanml
b87f89b7b4
Convert app/scripts/constants -> Typescript (#17327) 2023-01-20 13:33:01 -07:00
David Walsh
cb6ee2b3fe
Use async/await instead of Promise.resolve (#16221) 2023-01-20 14:20:18 -06:00
Brad Decker
92f6ea6f6b
Relocate conversion utils to shared/modules/conversion.utils.js (#17319) 2023-01-20 11:04:37 -06:00
ryanml
a19a5d60d3
Convert shared/constants/hardware-wallets.js -> Typescript (#17310) 2023-01-20 09:14:40 -06:00
Brad Decker
e830176fc8
fix issue with network state shape expected in NftDetectionController (#17283) 2023-01-19 08:17:47 -06:00
Olusegun Akintayo
d7e829ed5a
Persist phishing state controller state. (#16643)
* Persist phishing state controller state.

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

update phishing controller to latest version

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

Rebase, Yarn3, Lavamoat

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

run allow-scrips.

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

lavamoat:auto and linter

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

* lint fixes

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

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2023-01-18 16:44:19 +01:00
Brad Decker
5f6d2ba6b0
Convert Transaction constants to typescript (#17149) 2023-01-18 08:47:29 -06:00
Mark Stacey
7d77554f3b
Refactor: Construct the network controller within each test (#17199)
The network controller is now constructed within each network
controller unit test, rather than in the `beforeEach`. This allows us
to customize the constructor options in each test, which some planned
future tests will require.

The controller is constructed with a helper function that also handles
calling `destroy` after each test, even if the test failed. This helps
to prevent tests from affecting each other.

Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
2023-01-17 19:58:16 -03:30
Mark Stacey
3c52e80713
Remove unnecessary test (#17181)
This test was testing a function that was only present in the test
module.

The function under test was mistakenly moved here when it was
discovered that it wasn't being used elsewhere, under the assumption
that it was used in these tests. I hadn't realized it was being tested
directly.
2023-01-17 19:57:41 -03:30
Mark Stacey
61d8fbb1d4
Refactor: Use network mocks for network unit tests (#17126)
The network controller unit tests now use network mocks rather than
mocking controller methods.

This makes the tests less brittle, as they will no longer break when
internal changes to the `_getLatestBlock` method are made.
2023-01-17 14:39:02 -03:30
Niranjana Binoy
a0bb4a6c5a
Toggle option to enable/disable balance and Token rate checking for using third-party API (#16772) 2023-01-17 10:23:04 -05:00
Michal
49c8b279be
harden export account (#17241)
harden export account
2023-01-17 15:01:12 +00:00
Dan J Miller
7f35488247
Ensure that account tracker does not set balances incorrectly when us… (#17021)
* Ensure that account tracker does not set balances incorrectly when useMultiAccountBalanceChecker is false

* Lint fix

* Fix account setting in _updateAccount in useMultiAccountBalanceChecker === true case

* Fix _updateAccount

* Add unit tests
2023-01-16 14:10:48 -03:30
Mark Stacey
15ee9e1556
Await initializeProvider in network controller tests (#17180)
The network controller unit tests have been updated to wait until the
network controller is fully initialized before proceeding. This ensures
that the initialization doesn't have any side-effects that affect later
tests.
2023-01-13 12:53:39 -03:30
Frederik Bolding
7b852c3ff2
Fix EIP-712 input validation order (#17156) 2023-01-13 16:57:08 +01:00
Alex Donesky
709b64c128
Remove dead addressbook migration code (#17127)
* remove dead address book migration code

* cleanup

* addToFrequentRpcList -> upsertToFrequentRpcList

* remove migrateAddressBookState function
2023-01-12 13:05:48 -06:00
Alex Donesky
e0ff039078
bump @metamask/smart-transactions-controller version (#17120)
* bump smart-transactions-controller version

* update policy files

* fix

* rebase cleanup
2023-01-12 12:57:01 -06:00
Mark Stacey
6482848610
Fix NetworkController destroy before initialization (#17136)
The NetworkController `destroy` method has been updated to ensure that
it no longer throws if called before initialization.

This method was added recently in #17032, but we forgot to handle the
case where the controller was not initialized.
2023-01-11 15:26:33 -03:30
Mark Stacey
e8e0cf5786
Remove unecessary code from the network controller tests (#17137)
The `initializeProvider` parameters were removed recently in #16863,
but they were still being set in tests. They have now been removed.

An unused property was also being set in the tests, which has now also
been removed.
2023-01-11 15:26:18 -03:30
David Walsh
dc3a09de16
Dark Mode: Set to default based on user preferred scheme (#15870) 2023-01-06 14:07:47 -06:00
Mark Stacey
87ce653c86
Move MetaMask middleware out of network controller (#16863)
The "MetaMask middleware" is the set of middleware for handling methods that
we don't send to the network. This includes signing, encryption, `getAccounts`,
and methods that rely on pending transaction state.

Previously this middleware was setup as part of the network client, despite
having nothing to do with the network. They have been moved into the main RPC
pipeline established in `metamask-controller.js` instead.

This is a pure refactor, and should have no functional changes. The middleware
are still run in exactly the same order with the same arguments.
2023-01-06 13:44:50 -03:30
Zachary Belford
cd2249f193
Add tests for custom JSON-RPC network client (#16337)
Previously we had written tests for `createInfuraClient`, which creates a middleware stack designed to connect to an Infura provider. These tests exercise various RPC methods that relate to the behavior that the middleware provides (mainly around caching). 

Now we need to write the same tests but for `createJsonRpcClient`, which creates a middleware stack designed to connect to a non-Infura RPC endpoint. To do this, we had to:

- Consolidate the tests for both types of RPC client into a single test file.
- Add conditions around tests or assertions in tests to account for differences in behavior between the two sets of middleware stacks.
- Relocate code in `createJsonRpcClient` which slows down `eth_estimateGas` calls just for tests so that this behavior can be disabled in the network client tests.

Eventually, as we unify the network controllers in this repo and in the core repo, we will move these tests into the core repo.

Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
2023-01-06 10:10:17 -07:00
Michal
b1254843ac
determine tx type using normalized txparams (#17055)
Co-authored-by: ryanml <ryanlanese@gmail.com>
2023-01-05 17:37:50 -07:00
Brad Decker
f586f142be
add an extra identifier on anonymized duplicate events (#17080) 2023-01-05 08:49:55 -06:00
Mark Stacey
8d28fbccc5
Stop block tracker after each network controller unit test (#17032)
The network controller unit tests have been updated to stop the block
tracker after each test. This was accomplished with a new `destroy`
method.
2023-01-04 17:46:22 -03:30
Adnan Sahovic
54cbc66120
Improve transaction complete popup (#16300)
* modified transaction complete popup

deleted upperCase function

deleted replaceAll

fixed lint

* resolved conflicts

* modified view const

Co-authored-by: Vladimir Saric <92527393+VSaric@users.noreply.github.com>
2023-01-04 09:40:42 -06:00
weizman
3cf5ef642f
Revert "Integrate new LavaMoat scuttling protection feature (#16994)" (#17043) 2022-12-22 17:26:53 +02:00
Daniel
2832f8a97e
Update quote selection for Optimism (#16998) 2022-12-21 20:59:34 +01:00
Guillaume Roux
3cfef11f71
[FLASK] Resolve snap_dialog approval on close (#16801) 2022-12-21 20:15:52 +01:00
weizman
5d320ceec6
Integrate new LavaMoat scuttling protection feature (#16994)
Co-authored-by: kumavis <kumavis@users.noreply.github.com>
Co-authored-by: kumavis <aaron@kumavis.me>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-12-21 12:54:30 -06:00
Zachary Belford
6f6984fa58
Moved subscribe and filter into network controller (#16693)
Our middleware for handling subscription and filter-related methods (`eth-json-rpc-filters`) currently lives in our RPC pipeline ahead of the network stack. This commit moves this middleware to the network client middleware instead. There are two reasons for this change. First, this middleware wraps RPC methods that are supported by the network. Second, it is necessary for this middleware to live with the network client so that it will aid us in unifying the NetworkController in this repo and the NetworkController in the `controllers` repo.

Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
2022-12-20 10:28:09 -07:00
Jyoti Puri
c61d44a3be
Making add un-approved transaction idempotent (#16995) 2022-12-20 18:01:37 +05:30
Guillaume Roux
85f260c22d
[FLASK] Use custom UI for dialogs (#16973)
* update dialog templates to use custom UI

* add TODO comments

* Fix showDialog hook and destructuring

* Regen LavaMoat policies

* Re-add legacy snap confirmation for now

* Fix circular dependency issue

* Revert change to token-util

* Fix lint

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-12-20 11:44:22 +01:00
Frederik Bolding
abe0204171
[FLASK] snaps-monorepo@0.27.1 (#16981)
* snaps-monorepo@0.27.0

* Regen LavaMoat policies

* Remove unused constructor arg

* snaps-monorepo@0.27.1
2022-12-20 11:44:05 +01:00
Olusegun Akintayo
13de51e748
Security and Privacy Settings Re-org (#16756) 2022-12-19 18:46:36 +01:00
Mark Stacey
3e98758719
Rename the network controller module (#16974)
The network controller module has been renamed from `network.js` to
`network-controller.js`. All of our newer controllers have "controller"
in the module names, so this aligns better with that convention. It
also brings the test module name into alignment (it's already called
"network-controller.test.js").
2022-12-16 16:37:06 -03:30
Mark Stacey
dbe77289d3
Make initializeProvider and lookupNetwork async (#16881)
* Make `initializeProvider` and `lookupNetwork` async

These two methods were "synchronous" previously, but initiated an
asynchronous operation. They have both been made `async` to bring them
more in-line with the mobile controller API, and to make them easier
to test.

This should include zero functional changes. These methods are still
being invoked without an `await`, to preserve the same behaviour they
had previously.

This relates to https://github.com/MetaMask/controllers/issues/971

* Move 'net_version' query to private function

* Fix error made when resolving conflicts

* Refactor to improve readability
2022-12-16 13:03:22 -03:30
Dan J Miller
ba3914e9fe
Sanitize privacy sensitive data before sending to sentry. (#16780)
* Sanitize privacy sensitive data before sending to sentry.

Temp

Near complete

Complete

* Temp

* Fix url error message rewrite

* Add unit tests and cleanup code

* Improvements

* Update app/scripts/lib/setupSentry.js

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

* Update app/scripts/lib/setupSentry.js

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

* Update app/scripts/lib/setupSentry.js

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

* Fix syntax of doc comments

* Catch errors caused by invalid urls in sanitizeUrlsFromErrorMessages

* Ensure our allowlist matches multiple subdomains

* Ensure sanitizeUrlsFromErrorMessages correctly matches hostnames

* Update app/scripts/lib/setupSentry.js

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

* Improve test descriptions

* fix

Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2022-12-16 11:56:23 -03:30
Frederik Bolding
0511d6f0b1
[FLASK] Bump snaps iframe-execution-environment (#16932) 2022-12-14 11:48:50 +01:00
Alex Donesky
5d285f7be5
fix cached detected token results (#16866) 2022-12-14 12:26:08 +05:30