1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/test/unit/app/controllers
Mark Stacey 17f7ca2cfe
Update address book state upon custom RPC chainId edit (#9493)
When the `chainId` for a custom RPC endpoint is edited, we now migrate
the corresponding address book entries to ensure they are not orphaned.

The address book entries are grouped by the `metamask.network` state,
which unfortunately was sometimes the `chainId`, and sometimes the
`networkId`. It was always the `networkId` for built-in Infura
networks, but for custom RPC endpoints it would be set to the user-set
`chainId` field, with a fallback to the `networkId` of the network.

A recent change will force users to enter valid `chainId`s on all
custom networks, which will be normalized to be hex-prefixed. As a
result, address book contacts will now be keyed by a different string.
The contact entries are now migrated when this edit takes place.

There are some edge cases where two separate entries share the same set
of contacts. For example, if two entries have the same `chainId`, or if
they had the same `networkId` and had no `chainId` set. When the
`chainId` is edited in such cases, the contacts are duplicated on both
networks. This is the best we can do, as we don't have any way to know
which network the contacts _should_ be on.

The `typed-message-manager` unit tests have also been updated as part
of this commit because the addition of `sinon.restore()` to the
preferences controller tests ended up clearing a test object in-between
individual tests in that file. The test object is now re-constructed
before each individual test.
2020-10-07 15:02:17 -02:30
..
network Merge pull request from GHSA-c2xw-px2x-pr65 2020-10-06 15:27:02 -02:30
permissions Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
transactions Use networkVersion for network state; chainId for signing transactions (#9487) 2020-10-06 17:48:24 -02:30
cached-balances-test.js Fix no-empty-function issues (#9216) 2020-08-14 09:17:02 -02:30
detect-tokens-test.js Use Infura v3 API (#9368) 2020-09-10 13:46:00 -02:30
ens-controller-test.js Fix import/no-extraneous-dependencies issues (#9232) 2020-08-14 17:34:56 -02:30
incoming-transactions-test.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
metamask-controller-test.js Add MetaMask Swaps (#9482) 2020-10-06 15:58:38 -02:30
preferences-controller-test.js Update address book state upon custom RPC chainId edit (#9493) 2020-10-07 15:02:17 -02:30
swaps-test.js Add MetaMask Swaps (#9482) 2020-10-06 15:58:38 -02:30
token-rates-controller.js Fix import/order issues (#9239) 2020-08-18 16:48:25 -02:30