* NFTs: Use Unknown Collection instead of first NFT name
* Use localization in hook
* Get localization for previously owned
* Fix tests
---------
Co-authored-by: Dan Miller <danjm.com@gmail.com>
* fix(18194): Redirect to extension expanded view when click back to safety button
* Bump phishing warning version
---------
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
The `network` store of the network controller crams two types of data
into one place. It roughly tracks whether we have enough information to
make requests to the network and whether the network is capable of
receiving requests, but it also stores the ID of the network (as
obtained via `net_version`).
Generally we shouldn't be using the network ID for anything, as it has
been completely replaced by chain ID, which all custom RPC endpoints
have been required to support for over a year now. However, as the
network ID is used in various places within the extension codebase,
removing it entirely would be a non-trivial effort. So, minimally, this
commit splits `network` into two stores: `networkId` and
`networkStatus`. But it also expands the concept of network status.
Previously, the network was in one of two states: "loading" and
"not-loading". But now it can be in one of four states:
- `available`: The network is able to receive and respond to requests.
- `unavailable`: The network is not able to receive and respond to
requests for unknown reasons.
- `blocked`: The network is actively blocking requests based on the
user's geolocation. (This is specific to Infura.)
- `unknown`: We don't know whether the network can receive and respond
to requests, either because we haven't checked or we tried to check
and were unsuccessful.
This commit also changes how the network status is determined —
specifically, how many requests are used to determine that status, when
they occur, and whether they are awaited. Previously, the network
controller would make 2 to 3 requests during the course of running
`lookupNetwork`.
* First, if it was an Infura network, it would make a request for
`eth_blockNumber` to determine whether Infura was blocking requests or
not, then emit an appropriate event. This operation was not awaited.
* Then, regardless of the network, it would fetch the network ID via
`net_version`. This operation was awaited.
* Finally, regardless of the network, it would fetch the latest block
via `eth_getBlockByNumber`, then use the result to determine whether
the network supported EIP-1559. This operation was awaited.
Now:
* One fewer request is made, specifically `eth_blockNumber`, as we don't
need to make an extra request to determine whether Infura is blocking
requests; we can reuse `eth_getBlockByNumber`;
* All requests are awaited, which makes `lookupNetwork` run fully
in-band instead of partially out-of-band; and
* Both requests for `net_version` and `eth_getBlockByNumber` are
performed in parallel to make `lookupNetwork` run slightly faster.
Currently, the network controller notifies consumers about events by
emitting them directly from the controller. In order to migrate the
controller to the core repo, where controllers use the BaseControllerV2
interface, events should be emitted via a messenger object.
This commit updates the network controller to use a messenger, and then
updates all of the controllers that listen for network events to use the
messenger as well.
* added the rest of the sev1 warnings to getSnapInstallWarnings
* added and updated translations
* Updated getSnapInstallWarnings to include warnings for all weight-1 permissions
* Updated snap install warning and css according to designs
* fix snaps tests
* fixed alignment/spacing
* updated e2e tests to click through the newly displayed public key access warning
* lint fix
* fixed update snap test
* refactored getSnapInstallWarnings, moved logic to PERMISSION_DESCRIPTIONS
* fix logic to account for objects & arrays
* update function description
* add missing properties to ethereum provider description
* moved id and message to baseDescription to fix error
* add optional chaining to fix undefined error
* more optional chaining
* more optional chaining
* UX: Multichain: Account Menu List
* Move to using stylesheet
* Add hover state
* Implement George's suggestions
* Add connected site avatar
* Add hardware tag
* Create story for selected hardware item
* Progress on the AccountListItemMenu
* Add story for AccountListItemMenu
* Better position the account menu
* Fix AvatarFavicon missing name prop
* Update menu options label to be account specific
* Update text of 'View on Explorer'
* Add AccountListMenu component
* Move all items to multichain directory
* Fix paths
* Fix linting, use AvatarIcon
* Add title and close button to account menu
* Center the popover title
* Add search functionality
* Implementation WIP
* Add MULTICHAIN feature flag
* Add MULTICHAIN feature flag, add actions for menu items
* Properly dispatch events
* Fix search box padding
* Fix sizing of menu item text
* Fix isRequired
* Fix alignment of the popover
* Update label for hardware wallet items, add text for no search results
* Update keyring retreival to remove account and add label
* Fix storybook
* Fix double link click issue, prevent wrapping of values
* Use labelProps for tag variant
* Restructure item menu story
* Empower storybooks for all new components
* Allow only 3 decimals for currencies
* Avoid inline styles
* Prefix classes with multichain, fix account-list-menu storybook
* Close the accounts menu when account details is clicked
* Restore tag.js
* Create global file for multichain css
* Add index file for multichain js
* Update file paths
* Ensure the block domain is present in menu
* Add AccountListItem test
* Add AccountListItemMenu tests
* Show account connect to current dapp
* Improve tests
* Make avatar smaller
* Add tooltip for account menu
* Align icon better
* Update snapshot
* Rename files to DS standard
* Add index files for export
* Export all multichain components
* Update snapshot
* Remove embedded style in popover
* Add comments for props, cleanup storybook
* Improve test coverage
* Improve test code quality
* Remove border form avatar
* Switch to using the ButtonLink iconName prop
* Only show tooltip if character limit is reached
* Restore prior search settings
* Add test for tooltip
* feat: add the consensys zkEVM as a default network
* fix: change infuraNetworkStatus in navigate-txs file
* fix: remove account tracker for zkEVM + remove zkEVM from infura list
* fix: change consensys zkevm name to linea + change rpc url for linea network
* fix: rebase conflicts
* feat: add new colors for linea goerli network
* feat: add new function inside network dropdown to render non infura networks
* feat: add feature toggle for linea network
* fix: add new unit test
---------
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
* Update UI related to MetaMask Snaps Platform trademark
* Remove redundant UI text according to new designs
* Fix lint errors
* Fix e2e test expectation
* Fix lint in test
* Fix e2e test expectation
* Fix some UI parts
* Update CSS for noSnaps message
* Add next design iteration
* Add minor fix
* Update locale message
* Fix learn more text size
* Refactor usage of design system components
---------
Co-authored-by: Erik Marks <rekmarks@protonmail.com>
The `HardwareKeyringTypes` constant has been renamed to `KeyringTypes`
and moved to a separate constants module, to reflect that it contains
more than just hardware wallet keyring types. This corrects a mistake
made recently during a TypeScript conversion.
* Added fallback copy for when we're not able to retrieve a erc721 or erc1155 name in the setApprovalForAll screen and added unit tests
* Fixing lint
* Review requested changes
* Modify small copy changes in messages.json
* Fixing nft e2e tests
* Fixing nft e2e tests final
* Added snapshots for tests and removed data-testid
* Modify translation messages and e2e tests
When the network client tests in this repo were copied over to the core
repo, some alterations were made. This commit copies them back to this
repo so that the two test suites are easier to compare to each other.
Changes include:
* Extracting `testsFor*` functions (functions that bundle similar tests
together) into separate files
* Reordering the tests defined in
`testsForRpcMethodsThatCheckForBlockHashInResponse`
* Reordering the set of RPC methods listed in `shared-tests.js`
* Reordering the type definitions defined in `shared-tests.js` to be
closer to the functions that use them
* Updating the tests defined in `testsForRpcMethodSupportingBlockParam`
so that when they make requests they pass params, even if it's just an
empty array
* MMI adds the Jwt dropdown
* MMI prettier
* review fixes
* adds the component
* adds tests and story file
* lint & prettier fix
* prettier fix
* prettier and clean up
* prettier and clean up
* Add tooltips to show info about a permission
* Make Tooltip component in scope regardless of build type
* Add descriptions
* Add translation variables and fix tooltip
* Use new icons
* Add missing description after rebase
* Fix build issues
* Fix icons
* Fix translation
* Add missing description
* Fix Ethereum icon
* Update coverage
* Revert "Moved subscribe and filter into network controller (#16693)"
This reverts commit 6f6984fa58. That
commit was an RPC middleware refactor intended to move the subscribe
and filter middleware into the network controller, to simplify the
process of sharing this middleware between clients.
This refactor resulted in `eth_subscribe` notifications being sent on
the wrong connections, causing the UI to break in some cases (the UI
`provider` connection does not support notifications). This happened
because the `setupProviderEngine` function runs per-connection,
whereas the engine setup inside the network controller is global. The
global network client cannot support notifications because it has no
way to route them; they'll need to stay in the per-connection provider
engine.
Closes#17467
* Add e2e test
An e2e test has been added that confirms subscriptions are only
broadcast to the site that registered them. This test fails on
`develop`.
* adding base what's new for NFT autodetection
* lintfix
* Adding nfts svg image
* adding new notification to fixture builder for e2e
* lint:fix
* Adding new messaging, styling what's new
* styling descriptions, increasing fullscreen height
* applying firstNotification styling to NFT whats new announcement
* adding scrollDown button to whats new popup
* adding Opensea announcement, removing old announcement, moving scrollDown button up to popover component
* verify-locales:fix
* updating icon
* NFTs: Remove feature flag for release
* Update security tab jest test
* Fix broken test
* Update snapshot
* Update test
* Fix test
* Remove last usages of flag
* Update CI jobs
* Fix jest tests
* add banner-tip component
* set fixed width
* add banner tip props to logo
* fix logo type naming
* update test
* reduce png sizes
* upate type name and add image element test
* updates
* Update ui/components/component-library/banner-tip/banner-tip.js
Co-authored-by: George Marshall <george.marshall@consensys.net>
* update BannerTip
* fix text case banner tip
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
* Use tokenList to get token details, when available, in getTokenStandardAndDetails
Previously, every call to getTokenStandardAndDetails would fetch data via the provider.
This would result in at least 3 network requests whenever that method is called for an
ERC20 token, contributing to unneccesary loading and lagging in multiple places.
This commit takes advantage of stored data we already have available to avoid the unnecessary
loading.
* Lint fix
* Fix build-quote test
* bump coverage targets
* Pass provider to token-util, for use in ethers Contract module
* Check all possible sources of ERC20 token data before async call to assetsContractController
* Add and update tests
* Update app/scripts/metamask-controller.js
Co-authored-by: Alex Donesky <adonesky@gmail.com>
* Update app/scripts/metamask-controller.js
Co-authored-by: Alex Donesky <adonesky@gmail.com>
* Remove unnecessary this.ethQuery changes
* Use metamask-eth-abis instead of human-standard-token-abi in token-util.ts
* Add explanatory comments to getTokenStandardAndDetails
* lint fix
* Cleanup
* fix test
* Update app/scripts/metamask-controller.js
Co-authored-by: Alex Donesky <adonesky@gmail.com>
* update error message
---------
Co-authored-by: Alex Donesky <adonesky@gmail.com>
* Add Bridge button
* Add newline to the end of bridge svg
* Move Portfolio button
* Vertically center Portfolio button
* Use IconButton for Portfolio button
* Change portfolio button size
* Lowering coverage to get this in for release by a very small amount
* Add unit tests for Portfolio button
---------
Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
* MMI adds all mmi images, build type and manifest files
* build-for-all-custodians
* fix remove-fenced-code test
* no need for axios
* runs prettier
* linter
* MMI moving file out of codebase
* MMI adds locale appNameMmi
* MMI adds locale appNameMmi to verify-locale-strings
* feat: disable deposit popover and replace it with global redirect to onramp on pdapp
* feat: remove legacy code for hardcoded onramp providers
* fix: remove unused visuals and components related to legacy code of deposit popover
* fix: remove unused messages
* feat: use a custom hook for all onramps related methods and variables
* fix: modify the custom hook implementation to include test networks
* fix: remove deprecated file buy-url
* fix: remove references for deleted deposit logos
* fix: network-controller failing unit test
* fix: snapshot loading-swaps-quotes-stories-metadata.test.js.snap
* fix: storybook tests
* fix: remove unused constatns related to buyable onramp chains
* fix: remove unused variables and fix eslint
* adding unit test for useRamps custom hook
* feat: add comment on the proper usage of useRamps within confirm-page-container component
* fix: add unit tests for buy button in token-overview page
* fix: add unit test for open the buy crypto URL for a buyable chain ID in token page
* feat: add unit test coverage for eth-overview page
* fix: update locales
The migration template has been converted to TypeScript. We can start
writing migrations in TypeScript today; they have no dependencies on
JavaScript modules.
This release only includes one breaking change, which is the renaming
of the package to be under the `@metamask` scope. It includes
improvements to the types that will unblock migrating our network
clients to TypeScript.
The minimum browser versions have been updated to Chromium v80 and
Firefox v78.
Chromium v80 is >3 years old, and very few users use older versions
than that.
Firefox v78 is two extended support releases ago (v91 and v102 ar the
previous and current ESR releases).
The PhishingController has been updated to v2. This release should
dramatically reduce network traffic and double the update speed of the
phishing list.
This was accomplished by combining both of our phishing configurations
into one list (the "stalelist"), then creating a separate list of the
changes just the past few days (the "hotlist"). Now users will download
a smaller list more frequently (every 30 minutes rather than every
hour), whereas the full list is only updated every 4 days.
The combined configuration means that we no longer know which list was
responsible for each block. The phishing warning page has been updated
to dynamically look this information up, to ensure users are still
directed to the correct place to dispute a block. This update to the
phishing warning page also includes the recent redesign.
* feat: add desktop enable button component
This component will be added
to the experimental page. Users
will then be able to initialize
a desktop connection
* feat: add desktop pairing page
* feat: add desktop deep-linking shared lib
* test: add initial entries to render helper
Allow specifying initialEntries for
MemoryRouter. This change will allow
testing pages that use the useParam
hook.
* feat: add desktop error page
Error page for any desktop pairing
related issue
* feat: add desktop routes to route component
* feat: add enable desktop button to experimental tab
* feat: add desktop icon when paired in dev mode
* feat: disable ledger live control when desktop enabled
* feat: register desktop error actions on ui init
* fix: add missing code fencing
* chore: remove enable desktop rpc middleware
Now that we are adding the UI
there's no need for this rpc middleware
(as it was used to test desktop background
code)
* fix: display experimental tab for desktop
The network controller has a variety of methods that just retrieve
controller state. These methods are not necessary because controller
state is already part of the public API of the controller and can be
accessed directly.
These methods are:
- getCurrentChainId
- getCurrentRpcUrl
- getNetworkIdentifier
- getNetworkState
- getProviderConfig
- isNetworkLoading
This is part of a larger effort to normalize the API of both network
controllers, to make them easier to merge.
Use DesktopManager in background script to redirect internal and external connections to the desktop app.
Include DesktopController in the MetaMask controller.
Support desktop keyrings in MetaMask controller via the overrides object.
Create middleware handler to connect to the desktop app while UI code is pending.
Add build system support for desktop specific configuration variables.
* refactor class to functional component
* update messages
* fix: use classnames
* feat: add hold to reveal modal
* feat: add new zendesk url for secret recovery phrase and noncustodial wallet
* update: clipboard to clear copied text after delay
* fix: remove save to csv
* feat: update styles for reveal seed page
* fix: update reveal seed snapshot
* add test to check for modal
* fix: lint
* fix: unused messages locale
* fix: use new banner component
* fix: use new button from design system
* fix: update snapshot
* fix: lint
* revert text
* fix: lint
* fix: remove --copy-only
* fix: marginBottom prop value
* fix: iconName and prop error
* --made the QR code slightly smaller so it's less likely to have a scrollbar
--updated the snapshots
* fix: error message not displaying
* SRP hold to reveal using more DS components (#17583)
* Updating to add DS components and remove CSS
* Fixing rendered html and removing some unneeded props
* fix: set block to true
---------
Co-authored-by: Monte <monte.lai@consensys.net>
* fix: add descriptions to messages
* Update ui/components/ui/export-text-container/export-text-container.component.js
fix: lint
Co-authored-by: HowardBraham <HowardBraham@users.noreply.github.com>
* fix: remove using displayWarning in requestRevealSeedWords
* fix: update test to remove displayError
* fix: update design system enums
* fix: messages descriptions
* fix: banner to banneralert
* fix: update preview
* add additional tests
* fix: use jest instead of sinon
* add test if long press isn't completed
* add test if password is wrong
---------
Co-authored-by: Howard Braham <howrad@gmail.com>
Co-authored-by: George Marshall <george.marshall@consensys.net>
The network controller has some tests, but they are incomplete and don't
follow our latest best practices for writing unit tests.
This commit greatly increases the amount of test coverage for the API
that we want to retain in NetworkController, in particular the seemingly
myriad paths that the code takes starting from `initializeProvider`,
`resetConnection`, `setRpcTarget`, `setProviderType`,
`rollbackToPreviousProvider`, and `lookupNetwork`.
There were a couple of pieces of logic I noted which don't seem to have
any effect due to being redundant or unreachable, but they also don't
make our lives more difficult, either, so I opted to leave them in.
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Zachary Belford <belfordz66@gmail.com>
* detect and track ui customizations on personal sign requests
* add feature flag check to metrics
* clean up comments
* get data only if it exists
* updated with PR feedback
* moved constants
* lint
* Apply suggestions from code review
Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
---------
Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
This package has been updated to reduce the bundle size (we already use
the v4 version indirectly). The only breaking change applicable to the
usage of this package in the extension is to the package's exports. The
one import line has been updated accordingly.
This update comes with types (v3 was the TypeScript migration).
* Added translation for eth sign toggle
* Disabled the ability to call eth_sign by default. Added ability within advanced settings to renable support for eth_sign
* Add test case for eth_sign being enabled and disabled
* Modified copy
* Moved rpc method preference to its own object within store
* Complete work on moving rpc method preference into its own object within store
* Fix with prettier
* Fix lint
* Fix a unit test
* Fix test
* Renamed function and object keys to be more intuitive
* Fix e2e test
* Enabled eth_sign through preferences fixture
* Fix lint
* Fix e2e test
Wait for the notification popup to close, leaving 2 window handles the extension and the test dapp
* Fix e2e test
* Fix unit test
Enable eth_sign method
* Lint fix
---------
Co-authored-by: PeterYinusa <peter.yinusa@consensys.net>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
* Add hardcoded list of human-readable snap names
* Make the text properly bold
* Small style fixes to approval screen
* Run yarn lint:fix
* Update snapshots
Any methods in the Ethereum JSON-RPC spec are now included in our
network client tests. These tests were skipped previously because they
are not supported by Infura.
Closes#16938
* Adding browser outdated notification
* updating dependency
* adding unit tests for util function
* adding unit tests for selectors, lintfix
* Added Tests, refactored notification delay logic
* lint:fix
* adding test coverage for method parameter
* Update app/scripts/controllers/app-state.js
adding documentation details
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* moving declaration into test
* Update app/scripts/controllers/app-state.test.js
spacing in test file
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Update jest.config.js
removing duplicate entries
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* using async submitRequestToBackground method
* removing unused import
* removing unnecessary link syntax in notification
* adding opera and edge and associated tests
* handling the undefined case in bowser.satisfies
* setOutdatedBrowserWarningLastShown try/catch
* lint:fix
* Removing try/catch and letting errors bubble up
Removing deprecated displayWarning method
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* taking out forceMetamaskUpdateState call
* excludint app-state test from mocha test suite
* Added note: Jest files should match Mocha excluded
* syntax error, lint:fix
---------
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
Co-authored-by: brad-decker <bhdecker84@gmail.com>
* Add tests for `retryOnEmpty` middleware
Tests have been added for the `retryOnEmpty` middleware.
This middleware is only used on the Infura network client, so the tests
that demonstrate this retry behavior are only enabled for the `infura`
provider type.
Most of the tests added were to cover cases where the retry middleware
is skipped, so they were applicable for both provider types.
Closes#17004
* Improve readability of block number tests
The test cases for passing a block number parameter have been made more
readable. Specifically, a comment has been added each time params are
built to call attention to the block parameter and what value it has,
so that it's clear whether it's larger or smaller than the current
block number.
Additionally the blocks for "less than the current block number" and
"equal to the current block number" have been combined using
`describe.each`.
Tests have been added to ensure that our middleware will not return a
cached response to a request with unique parameters. Each parameter
supported by each method is tested independently.
Closes#17003
* Put hardware wallets behind an HARDWARE_WALLETS_MV3 flag
Disable Hardware connect buttons if the flag is set.
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
update to metamask/eth-keyring-controller
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
revert to eth-keyring-controller v8
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
LAvamost after rebase
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
lock file.
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
Added toaster for removed NFTs (#17297)
* added notification for remove nfts
* reverted names for tabs
* updated default key
* updated snapshot
* updated remove nft toast to danger
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.
Security provider check (OpenSea) (#16584)
chore: copy update for metamask fee on swaps (#17133)
* linter fix
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
* setLedgerTransportPreference in the metamask-controller should not be called, or should return immediately, if canUseHardwareWallets() is false
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
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
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.
* 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>
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>
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.
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.
* 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
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.
* fix: Display primaryType in signTyped instead of 'Message' string
* fix: added #17077 to changelog
* fix: remove unused signatureRequest1 message to fix test-lint failure
* Update CHANGELOG.md
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
* test: add assertion for the primaryType to signature-request component test
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
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.
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.
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.
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>
* dealt with most of the problems in the Create Account dialog
* Fixed "newAccountNumberName" localizations
* In another language, don't allow accounts named, for instance, Cuenta 3
* Editing an account name later now follows the same rules
* Fixing lint errors
* Responding to the review by @adonesky1
* Worked with @montelaidev to alter the RegExp, in order to catch spaces before and after the account name
* Fixed line breaks for eslint
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>
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").
* 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
This commit affects the network client tests, which were added in a
previous PR to test the behavior of `createInfuraClient`, a function
called that sets up a portion of the middleware stack in the JSON-RPC
layer.
An `if` statement appears in the tests which limits the execution of
certain tests. However, this seems to have been added for debugging
purposes and is not actually needed.
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
Five network controller methods have been renamed to start with an
underscore:
* `getLatestBlock`
* `setNetworkState`
* `setNetworkEIPSupport`
* `clearNetworkDetails`
* `setProviderConfig`
All of these methods were used solely within the network controller.
The leading underscore now documents these methods as being private.
A few tests required updates as well because they were stubbing out one
of these methods.
This should include zero functional changes.
This relates to https://github.com/MetaMask/controllers/issues/971
The network state is now passed to the TransactionController via a
getter function and a subscription function, instead of passing one of
the network controller stores directly.
This way of passing the state makes further refactoring easier, as we
don't have to change the input when the store is changed or replaced.
It's also more aligned with our conventions today.
This change was made as part of a larger refactor of the network
controller, as part of the effort to merge the mobile and extension
network controllers.
The network controller method `setProviderType` was marked as `async`
despite doing nothing async internally. The `async` has been dropped.
This should have zero functional impact.
This relates to https://github.com/MetaMask/controllers/issues/971
The network controller `setInfuraProjectId` method has been deleted.
The Infura project ID is only ever set upon construction, so it is now
passed in as a constructor parameter instead.
Rather than adding this as a second parameter, the network controller
now uses an "options bag" for constructor parameters. The initial state
was the first parameter, but it's now passed in as the `state` option
instead.
These changes make the API more similar to the mobile network
controller API.
This should have zero functional changes.
This relates to https://github.com/MetaMask/controllers/issues/971
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
* Fix shared mocks in RPC network client test
Some of the provider api unit tests were inadvertently sharing test
mocks. A `params` object used for mock RPC calls was being shared
between tests and between calls within individual tests. They have been
updated to generate a fresh `params` object for each mock RPC call.
* Explicitly set blockParam to undefined
* dapp: handle ext unloaded or reloaded error
* dapp: handle ext unloaded or reloaded error pt. 2
- use const
- mention case is unsupported in Firefox
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
* Privacy - Allow users to set a custom RPC from the onboarding process (#16767)
* Privacy - Allow adding custom IPFS from onboarding (#16782)
* Privacy - Show default selected network after a custom network has been added during onboarding
* WIP: Show dropdown list of networks
* Add network switcher to the onboarding advanced privacy screen
* Fix duplicate imports
* Provide default for networks
* Update ui/helpers/utils/ipfs.js
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
* Fix lint
* Remove unwanted changes
* Fix lint
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>