1- import { cloneDeep } from 'lodash' ;
2- import {
3- CHAIN_IDS ,
4- DEFAULT_CUSTOM_TESTNET_MAP ,
5- } from '../../../shared/constants/network' ;
1+ import { ChainId } from '@metamask/controller-utils' ;
2+
63import { migrate , version } from './146' ;
74
85const oldVersion = 145 ;
6+ const megaEthChainId = ChainId [ 'megaeth-testnet' ] ;
7+
8+ /**
9+ * Get the MegaETH testnet network configuration object as snapshot.
10+ *
11+ * @returns The MegaETH testnet network configuration object.
12+ */
13+ const getMegaEthTestnetConfiguration = ( ) => ( {
14+ chainId : megaEthChainId ,
15+ name : 'Mega Testnet' ,
16+ nativeCurrency : 'MegaETH' ,
17+ blockExplorerUrls : [ 'https://megaexplorer.xyz' ] ,
18+ defaultRpcEndpointIndex : 0 ,
19+ defaultBlockExplorerUrlIndex : 0 ,
20+ rpcEndpoints : [
21+ {
22+ networkClientId : 'megaeth-testnet' ,
23+ url : 'https://carrot.megaeth.com/rpc' ,
24+ type : 'custom' ,
25+ } ,
26+ ] ,
27+ } ) ;
928
1029describe ( `migration #${ version } ` , ( ) => {
1130 it ( 'updates the version metadata' , async ( ) => {
@@ -129,9 +148,7 @@ describe(`migration #${version}`, () => {
129148 ...oldState . data . NetworkController ,
130149 networkConfigurationsByChainId : {
131150 ...oldState . data . NetworkController . networkConfigurationsByChainId ,
132- [ CHAIN_IDS . MEGAETH_TESTNET ] : cloneDeep (
133- DEFAULT_CUSTOM_TESTNET_MAP [ CHAIN_IDS . MEGAETH_TESTNET ] ,
134- ) ,
151+ [ megaEthChainId ] : getMegaEthTestnetConfiguration ( ) ,
135152 } ,
136153 } ,
137154 } ;
@@ -148,10 +165,8 @@ describe(`migration #${version}`, () => {
148165 selectedNetworkClientId : 'mainnet' ,
149166 networksMetadata : { } ,
150167 networkConfigurationsByChainId : {
151- [ CHAIN_IDS . MEGAETH_TESTNET ] : {
152- ...cloneDeep (
153- DEFAULT_CUSTOM_TESTNET_MAP [ CHAIN_IDS . MEGAETH_TESTNET ] ,
154- ) ,
168+ [ megaEthChainId ] : {
169+ ...getMegaEthTestnetConfiguration ( ) ,
155170 name : 'Some other name' ,
156171 } ,
157172 } ,
@@ -164,9 +179,7 @@ describe(`migration #${version}`, () => {
164179 ...oldStorage . data . NetworkController ,
165180 networkConfigurationsByChainId : {
166181 ...oldStorage . data . NetworkController . networkConfigurationsByChainId ,
167- [ CHAIN_IDS . MEGAETH_TESTNET ] : cloneDeep (
168- DEFAULT_CUSTOM_TESTNET_MAP [ CHAIN_IDS . MEGAETH_TESTNET ] ,
169- ) ,
182+ [ megaEthChainId ] : getMegaEthTestnetConfiguration ( ) ,
170183 } ,
171184 } ,
172185 } ;
0 commit comments