Skip to content

Commit f91f2cb

Browse files
committed
fix: fix migration version before rebase
1 parent 21511b1 commit f91f2cb

File tree

3 files changed

+97
-39
lines changed

3 files changed

+97
-39
lines changed

app/store/migrations/054.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.
File renamed without changes.

app/store/migrations/055.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { captureException } from '@sentry/react-native';
2+
import { hasProperty, isObject } from '@metamask/utils';
3+
import { ensureValidState } from './util';
4+
5+
export const version = 55;
6+
7+
/**
8+
* Adds built-in Infura network configurations.
9+
*
10+
* @param networkConfigurations - Existing network configurations.
11+
* @returns Updated network configurations including Infura networks.
12+
*/
13+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
14+
function addBuiltInInfuraNetworks(networkConfigurations: any[]) {
15+
return [
16+
{
17+
type: 'infura',
18+
id: 'mainnet',
19+
chainId: '0x1',
20+
ticker: 'ETH',
21+
nickname: 'Ethereum Mainnet',
22+
rpcUrl: 'https://mainnet.infura.io/v3/{infuraProjectId}',
23+
rpcPrefs: { blockExplorerUrl: 'https://etherscan.io' },
24+
},
25+
{
26+
type: 'infura',
27+
id: 'sepolia',
28+
chainId: '0xaa36a7',
29+
ticker: 'SepoliaETH',
30+
nickname: 'Sepolia',
31+
rpcUrl: 'https://sepolia.infura.io/v3/{infuraProjectId}',
32+
rpcPrefs: { blockExplorerUrl: 'https://sepolia.etherscan.io' },
33+
},
34+
{
35+
type: 'infura',
36+
id: 'linea-sepolia',
37+
chainId: '0xe705',
38+
ticker: 'LineaETH',
39+
nickname: 'Linea Sepolia',
40+
rpcUrl: 'https://linea-sepolia.infura.io/v3/{infuraProjectId}',
41+
rpcPrefs: { blockExplorerUrl: 'https://sepolia.lineascan.build' },
42+
},
43+
{
44+
type: 'infura',
45+
id: 'linea-mainnet',
46+
chainId: '0xe708',
47+
ticker: 'ETH',
48+
nickname: 'Linea Mainnet',
49+
rpcUrl: 'https://linea-mainnet.infura.io/v3/{infuraProjectId}',
50+
rpcPrefs: { blockExplorerUrl: 'https://lineascan.build' },
51+
},
52+
...networkConfigurations,
53+
];
54+
}
55+
56+
// Matches network controller validation
57+
function isValidUrl(url: string) {
58+
const uri = parse(url);
59+
return (
60+
uri.error === undefined && (uri.scheme === 'http' || uri.scheme === 'https')
61+
);
62+
}
63+
64+
export default function migrate(state: unknown) {
65+
if (!ensureValidState(state, 55)) {
66+
return state;
67+
}
68+
69+
const tokensControllerState = state.engine.backgroundState.TokensController;
70+
if (!isObject(tokensControllerState)) {
71+
captureException(
72+
new Error(
73+
`FATAL ERROR: Migration 54: Invalid TokensController state error: '${typeof tokensControllerState}'`,
74+
),
75+
);
76+
return state;
77+
}
78+
79+
if (Array.isArray(tokensControllerState.tokens)) {
80+
const migratedTokens = tokensControllerState.tokens.map((token) => {
81+
if (!hasProperty(token, 'balanceError')) {
82+
return token;
83+
}
84+
if (token?.balanceError === null || token?.balanceError === undefined) {
85+
token.hasBalanceError = false;
86+
} else {
87+
token.hasBalanceError = true;
88+
}
89+
delete token?.balanceError;
90+
return token;
91+
});
92+
tokensControllerState.tokens = migratedTokens;
93+
}
94+
95+
// Return the modified state
96+
return state;
97+
}

0 commit comments

Comments
 (0)