mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-16 04:57:08 +00:00
* Add repo wide prettier command to prepush * Make config file explict, remove formatAll to prepush
37 lines
916 B
TypeScript
37 lines
916 B
TypeScript
import { CustomNode } from 'libs/nodes';
|
|
import { NODES, NodeConfig, CustomNodeConfig } from 'config/data';
|
|
|
|
export function makeCustomNodeId(config: CustomNodeConfig): string {
|
|
return `${config.url}:${config.port}`;
|
|
}
|
|
|
|
export function getCustomNodeConfigFromId(
|
|
id: string,
|
|
configs: CustomNodeConfig[]
|
|
): CustomNodeConfig | undefined {
|
|
return configs.find(node => makeCustomNodeId(node) === id);
|
|
}
|
|
|
|
export function getNodeConfigFromId(
|
|
id: string,
|
|
configs: CustomNodeConfig[]
|
|
): NodeConfig | undefined {
|
|
if (NODES[id]) {
|
|
return NODES[id];
|
|
}
|
|
|
|
const config = getCustomNodeConfigFromId(id, configs);
|
|
if (config) {
|
|
return makeNodeConfigFromCustomConfig(config);
|
|
}
|
|
}
|
|
|
|
export function makeNodeConfigFromCustomConfig(config: CustomNodeConfig): NodeConfig {
|
|
return {
|
|
network: config.network,
|
|
lib: new CustomNode(config),
|
|
service: 'your custom node',
|
|
estimateGas: true
|
|
};
|
|
}
|