ethers.js/packages/providers/lib.esm/nodesmith-provider.js

41 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2020-07-14 02:33:30 -04:00
/* istanbul ignore file */
"use strict";
import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
// Special API key provided by Nodesmith for ethers.js
const defaultApiKey = "ETHERS_JS_SHARED";
export class NodesmithProvider extends UrlJsonRpcProvider {
static getApiKey(apiKey) {
2019-11-20 18:57:38 +09:00
if (apiKey && typeof (apiKey) !== "string") {
logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
}
return apiKey || defaultApiKey;
}
static getUrl(network, apiKey) {
2019-11-20 18:57:38 +09:00
logger.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
let host = null;
switch (network.name) {
case "homestead":
host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";
break;
case "ropsten":
host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";
break;
case "rinkeby":
host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";
break;
case "goerli":
host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";
break;
case "kovan":
host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";
break;
default:
logger.throwArgumentError("unsupported network", "network", arguments[0]);
}
return (host + "?apiKey=" + apiKey);
}
}
2020-07-13 08:03:56 -04:00
//# sourceMappingURL=nodesmith-provider.js.map