1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/unit
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
..
actions Merge pull request from GHSA-c2xw-px2x-pr65 2020-10-06 15:27:02 -02:30
app Update address book state upon custom RPC chainId edit (#9493) 2020-10-07 15:02:17 -02:30
lib Fix import/order issues (#9239) 2020-08-18 16:48:25 -02:30
migrations Merge pull request from GHSA-c2xw-px2x-pr65 2020-10-06 15:27:02 -02:30
responsive/components Remove mountWithStore enzyme component wrapper (#9309) 2020-08-26 15:55:24 -07:00
ui Add MetaMask Swaps (#9482) 2020-10-06 15:58:38 -02:30
balance-formatter-test.js Migrate codebase to use ESM (#7730) 2020-01-09 00:04:58 -03:30
localhostState.js Merge pull request from GHSA-c2xw-px2x-pr65 2020-10-06 15:27:02 -02:30