-
-
Notifications
You must be signed in to change notification settings - Fork 358
/
Copy pathapi.ts
19 lines (15 loc) · 862 Bytes
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import {getClient, ApiClient} from "@lodestar/api";
import {ChainForkConfig, createChainForkConfig} from "@lodestar/config";
import {NetworkName, networksChainConfig} from "@lodestar/config/networks";
export function getApiFromUrl(url: string, network: NetworkName): ApiClient {
if (!(network in networksChainConfig)) {
throw Error(`Invalid network name "${network}". Valid options are: ${Object.keys(networksChainConfig).join()}`);
}
return getClient({urls: [url]}, {config: createChainForkConfig(networksChainConfig[network])});
}
export function getChainForkConfigFromNetwork(network: NetworkName): ChainForkConfig {
if (!(network in networksChainConfig)) {
throw Error(`Invalid network name "${network}". Valid options are: ${Object.keys(networksChainConfig).join()}`);
}
return createChainForkConfig(networksChainConfig[network]);
}