mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-09 09:43:34 +00:00
* Add warning about matching nodes, only allow one url:port combination of nodes. * Fix up alert styling. * Custom network form. * Add custom network to redux store. Setup infrastructure for removal and display. * Persist custom networks to LS, show them in display. * Force chain id, make typing happy. * Display custom networks in network dropdown. * Fix form validation, purge unused custom networks.
31 lines
760 B
TypeScript
31 lines
760 B
TypeScript
import { NETWORKS, NetworkConfig, CustomNetworkConfig } from 'config/data';
|
|
|
|
export function makeCustomNetworkId(config: CustomNetworkConfig): string {
|
|
return config.chainId ? `${config.chainId}` : `${config.name}:${config.unit}`;
|
|
}
|
|
|
|
export function makeNetworkConfigFromCustomConfig(
|
|
config: CustomNetworkConfig
|
|
): NetworkConfig {
|
|
return {
|
|
...config,
|
|
color: '#000',
|
|
tokens: [],
|
|
contracts: []
|
|
};
|
|
}
|
|
|
|
export function getNetworkConfigFromId(
|
|
id: string,
|
|
configs: CustomNetworkConfig[]
|
|
): NetworkConfig | undefined {
|
|
if (NETWORKS[id]) {
|
|
return NETWORKS[id];
|
|
}
|
|
|
|
const customConfig = configs.find(conf => makeCustomNetworkId(conf) === id);
|
|
if (customConfig) {
|
|
return makeNetworkConfigFromCustomConfig(customConfig);
|
|
}
|
|
}
|