MyCrypto/shared/types/node.d.ts

60 lines
1.3 KiB
TypeScript
Raw Normal View History

import { StaticNetworkIds } from './network';
2018-01-29 17:41:59 -08:00
import { StaticNodesState, CustomNodesState } from 'reducers/config/nodes';
import CustomNode from 'libs/nodes/custom';
2018-02-10 18:09:40 -08:00
import RPCNode from 'libs/nodes/rpc';
import Web3Node from 'libs/nodes/web3';
2018-01-29 17:41:59 -08:00
interface CustomNodeConfig {
id: string;
isCustom: true;
2018-01-29 17:41:59 -08:00
name: string;
lib: CustomNode;
2018-02-10 18:09:40 -08:00
pLib: CustomNode;
service: 'your custom node';
2018-01-29 17:41:59 -08:00
url: string;
port: number;
network: string;
auth?: {
username: string;
password: string;
};
}
interface StaticNodeConfig {
isCustom: false;
network: StaticNetworkIds;
2018-01-29 17:41:59 -08:00
lib: RPCNode | Web3Node;
2018-02-10 18:09:40 -08:00
pLib: RPCNode | Web3Node;
2018-01-29 17:41:59 -08:00
service: string;
estimateGas?: boolean;
hidden?: boolean;
}
interface Web3NodeConfig extends StaticNodeConfig {
lib: Web3Node;
}
declare enum StaticNodeId {
2018-01-29 17:41:59 -08:00
ETH_MYCRYPTO = 'eth_mycrypto',
ETH_ETHSCAN = 'eth_ethscan',
ETH_INFURA = 'eth_infura',
ROP_INFURA = 'rop_infura',
KOV_ETHSCAN = 'kov_ethscan',
RIN_ETHSCAN = 'rin_ethscan',
RIN_INFURA = 'rin_infura',
ETC_EPOOL = 'etc_epool',
UBQ = 'ubq',
EXP_TECH = 'exp_tech'
}
2018-02-01 19:49:37 -08:00
type StaticNodeWithWeb3Id = StaticNodeId | 'web3';
type NonWeb3NodeConfigs = { [key in StaticNodeId]: StaticNodeConfig };
2018-01-29 17:41:59 -08:00
interface Web3NodeConfigs {
web3?: Web3NodeConfig;
2018-01-29 17:41:59 -08:00
}
type NodeConfig = StaticNodesState[StaticNodeId] | CustomNodesState[string];