1 |
|
2 | "use strict";
|
3 | import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
|
4 | import { Logger } from "@ethersproject/logger";
|
5 | import { version } from "./_version";
|
6 | const logger = new Logger(version);
|
7 |
|
8 | const defaultApiKey = "ETHERS_JS_SHARED";
|
9 | export class NodesmithProvider extends UrlJsonRpcProvider {
|
10 | static getApiKey(apiKey) {
|
11 | if (apiKey && typeof (apiKey) !== "string") {
|
12 | logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
|
13 | }
|
14 | return apiKey || defaultApiKey;
|
15 | }
|
16 | static getUrl(network, apiKey) {
|
17 | logger.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
|
18 | let host = null;
|
19 | switch (network.name) {
|
20 | case "homestead":
|
21 | host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";
|
22 | break;
|
23 | case "ropsten":
|
24 | host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";
|
25 | break;
|
26 | case "rinkeby":
|
27 | host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";
|
28 | break;
|
29 | case "goerli":
|
30 | host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";
|
31 | break;
|
32 | case "kovan":
|
33 | host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";
|
34 | break;
|
35 | default:
|
36 | logger.throwArgumentError("unsupported network", "network", arguments[0]);
|
37 | }
|
38 | return (host + "?apiKey=" + apiKey);
|
39 | }
|
40 | }
|
41 |
|
\ | No newline at end of file |