it('should return state unaltered if there is a providerConfig.id value in state but it is not a string',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
ticker:'NET',
type:NetworkType.rpc,
chainId:'0x189123',
nickname:'A Network',
id:{not:'a string'},
},
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldData);
});
it('should return state unaltered if there is a providerConfig.type value in state but it equals NetworkType.rpc and there is no providerConfig.id value in state',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
ticker:'ETH',
type:NetworkType.rpc,
chainId:'0x189123',
nickname:'A Network',
},
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual(oldData);
});
it('should add a selectedNetworkClientId property and a default networksMetadata object to the NetworkController state if there is a providerConfig.id value in state and it is a string (and there are no networkStatus or networkDetails values)',async()=>{
it('should add a selectedNetworkClientId property and a default networksMetadata object to the NetworkController state if there is a providerConfig.type value in state and it is not NetworkType.rpc (and there are no networkStatus or networkDetails values)',async()=>{
it('should migrate networkStatus into networksMetadata keyed by the active providerConfig.id value, calling the new value "status" and deleting the root networkStatus value',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networkStatus: NetworkStatus.Available,
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networksMetadata:{
'test-network-client-id':{
status: NetworkStatus.Available,
EIPS:{},
},
},
selectedNetworkClientId:'test-network-client-id',
},
});
});
it('should migrate networkStatus into networksMetadata keyed by the active providerConfig.type value (if providerConfig.type is not NetworkType.rpc), calling the new value "status" and deleting the root networkStatus value',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.sepolia,
ticker:'sepoliaETH',
chainId:'0xaa36a7',
nickname:'Sepolia TestNet',
},
networkStatus: NetworkStatus.Available,
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.sepolia,
ticker:'sepoliaETH',
chainId:'0xaa36a7',
nickname:'Sepolia TestNet',
},
networksMetadata:{
[NetworkType.sepolia]:{
status: NetworkStatus.Available,
EIPS:{},
},
},
selectedNetworkClientId: NetworkType.sepolia,
},
});
});
it('should migrate the contents of networkDetails into networksMetadata keyed by the active providerConfig.id value, and delete the root networkDetails value',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networkDetails:{
EIPS:{1559: false},
},
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networksMetadata:{
'test-network-client-id':{
status: NetworkStatus.Unknown,
EIPS:{
1559: false,
},
},
},
selectedNetworkClientId:'test-network-client-id',
},
});
});
it('should migrate the contents of networkDetails into networksMetadata keyed by the active providerConfig.type (if providerConfig.type does not equal NetworkType.rpc) value, and delete the root networkDetails value',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.sepolia,
ticker:'sepoliaETH',
chainId:'0xaa36a7',
nickname:'Sepolia TestNet',
},
networkDetails:{
EIPS:{1559: false},
},
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.sepolia,
ticker:'sepoliaETH',
chainId:'0xaa36a7',
nickname:'Sepolia TestNet',
},
networksMetadata:{
[NetworkType.sepolia]:{
status: NetworkStatus.Unknown,
EIPS:{1559: false},
},
},
selectedNetworkClientId: NetworkType.sepolia,
},
});
});
it('should migrate both networkStatus and networkDetails state into networksMetadata keyed by the active providerConfig.id value',async()=>{
constoldData={
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networkStatus: NetworkStatus.Available,
networkDetails:{
EIPS:{1559: false},
},
},
};
constoldStorage={
meta:{
version: 93,
},
data: oldData,
};
constnewStorage=awaitmigrate(oldStorage);
expect(newStorage.data).toStrictEqual({
other:'data',
NetworkController:{
providerConfig:{
type:NetworkType.rpc,
chainId:'0x9393',
nickname:'Funky Town Chain',
ticker:'ETH',
id:'test-network-client-id',
},
networksMetadata:{
'test-network-client-id':{
status: NetworkStatus.Available,
EIPS:{1559: false},
},
},
selectedNetworkClientId:'test-network-client-id',
},
});
});
it('should migrate both networkStatus and networkDetails state into networksMetadata keyed by the active providerConfig.type (if providerConfig.type does not equal NetworkType.rpc)',async()=>{