1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/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
..
ens Fix import/order issues (#9239) 2020-08-18 16:48:25 -02:30
network Use networkVersion for network state; chainId for signing transactions (#9487) 2020-10-06 17:48:24 -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
alert.js Merge pull request from GHSA-c2xw-px2x-pr65 2020-10-06 15:27:02 -02:30
app-state.js Add MetaMask Swaps (#9482) 2020-10-06 15:58:38 -02:30
cached-balances.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
detect-tokens.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
incoming-transactions.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
onboarding.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30
preferences.js Update address book state upon custom RPC chainId edit (#9493) 2020-10-07 15:02:17 -02:30
swaps.js Fix unbound function in swaps controller (#9496) 2020-10-06 20:03:59 -07:00
threebox.js Fix 3Box sync and e2e tests (#9422) 2020-09-29 14:17:55 -02:30
token-rates.js Update ESLint shared config to v3 (#9274) 2020-08-19 13:57:05 -02:30