1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix migration 048 chainId conversion (#9567)

This commit is contained in:
Erik Marks 2020-10-12 19:24:45 -07:00 committed by GitHub
parent 31d373e62c
commit f9e0c64abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -92,7 +92,7 @@ function transformState (state = {}) {
const addressBook = state.AddressBookController?.addressBook || {} const addressBook = state.AddressBookController?.addressBook || {}
Object.keys(addressBook).forEach((networkKey) => { Object.keys(addressBook).forEach((networkKey) => {
if ((/^\d+$/ui).test(networkKey)) { if ((/^\d+$/ui).test(networkKey)) {
const chainId = `0x${networkKey.toString(16)}` const chainId = `0x${parseInt(networkKey, 10).toString(16)}`
updateChainIds(addressBook[networkKey], chainId) updateChainIds(addressBook[networkKey], chainId)
if (addressBook[chainId]) { if (addressBook[chainId]) {

View File

@ -237,8 +237,8 @@ describe('migration #48', function () {
const newStorage = await migration48.migrate(oldStorage) const newStorage = await migration48.migrate(oldStorage)
assert.deepEqual( assert.deepEqual(
{ ...oldStorage.data, ...expectedPreferencesState }, { ...expectedPreferencesState, ...oldStorage.data },
{ ...newStorage.data, ...expectedPreferencesState }, { ...expectedPreferencesState, ...newStorage.data },
) )
}) })
@ -361,6 +361,12 @@ describe('migration #48', function () {
foo: 'bar', foo: 'bar',
}, },
}, },
'100': {
'address1': {
chainId: '100',
foo: 'bar',
},
},
'0x2': { '0x2': {
'address2': { 'address2': {
chainId: '0x2', chainId: '0x2',
@ -387,6 +393,12 @@ describe('migration #48', function () {
foo: 'bar', foo: 'bar',
}, },
}, },
'0x64': {
'address1': {
chainId: '0x64',
foo: 'bar',
},
},
'0x2': { '0x2': {
'address2': { 'address2': {
chainId: '0x2', chainId: '0x2',