2022-09-14 16:55:31 +02:00
|
|
|
import { CHAIN_IDS } from '../../../shared/constants/network';
|
2021-03-19 18:17:39 +01:00
|
|
|
import migration54 from './054';
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('migration #54', () => {
|
|
|
|
it('should update the version metadata', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {
|
|
|
|
version: 53,
|
|
|
|
},
|
|
|
|
data: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.meta).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
version: 54,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should retype instance of 0 decimal values to numbers [tokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
accountTokens: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
accountTokens: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if all decimal value typings are correct [tokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
accountTokens: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
accountTokens: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should retype instance of 0 decimal values to numbers [accountTokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should do nothing if all decimal value typings are correct [accountTokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should retype instance of 0 decimal values to numbers [accountTokens and tokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
it('should retype instance of 0 decimal values to numbers, and remove tokens with corrupted decimal values [accountTokens and tokens]', async () => {
|
2021-03-19 18:17:39 +01:00
|
|
|
const oldStorage = {
|
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 'corrupted_decimal?',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: '0',
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: '18xx',
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const newStorage = await migration54.migrate(oldStorage);
|
2021-09-21 18:28:13 +02:00
|
|
|
expect(newStorage.data).toStrictEqual({
|
2021-03-19 18:17:39 +01:00
|
|
|
PreferencesController: {
|
|
|
|
accountTokens: {
|
|
|
|
'0x1111': {
|
2022-09-14 16:55:31 +02:00
|
|
|
[CHAIN_IDS.MAINNET]: [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x629a673a8242c2ac4b7b8c5d8735fbeac21a6205',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'SOR',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'0x1112': {
|
2022-09-29 05:26:01 +02:00
|
|
|
'0x3': [
|
2021-03-19 18:17:39 +01:00
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tokens: [
|
|
|
|
{
|
|
|
|
address: '0x06012c8cf97bead5deae237070f9587f8e7a266d',
|
|
|
|
decimals: 0,
|
|
|
|
symbol: 'CK',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x0d8775f648430679a709e98d2b0cb6250d2887ef',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'BAT',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
address: '0x514910771af9ca656af840dff83e8264ecf986ca',
|
|
|
|
decimals: 18,
|
|
|
|
symbol: 'LINK',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|