UNPKG

2.88 kBJavaScriptView Raw
1/* istanbul ignore file */
2"use strict";
3var __extends = (this && this.__extends) || (function () {
4 var extendStatics = function (d, b) {
5 extendStatics = Object.setPrototypeOf ||
6 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8 return extendStatics(d, b);
9 };
10 return function (d, b) {
11 if (typeof b !== "function" && b !== null)
12 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13 extendStatics(d, b);
14 function __() { this.constructor = d; }
15 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16 };
17})();
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.NodesmithProvider = void 0;
20var url_json_rpc_provider_1 = require("./url-json-rpc-provider");
21var logger_1 = require("@ethersproject/logger");
22var _version_1 = require("./_version");
23var logger = new logger_1.Logger(_version_1.version);
24// Special API key provided by Nodesmith for ethers.js
25var defaultApiKey = "ETHERS_JS_SHARED";
26var NodesmithProvider = /** @class */ (function (_super) {
27 __extends(NodesmithProvider, _super);
28 function NodesmithProvider() {
29 return _super !== null && _super.apply(this, arguments) || this;
30 }
31 NodesmithProvider.getApiKey = function (apiKey) {
32 if (apiKey && typeof (apiKey) !== "string") {
33 logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
34 }
35 return apiKey || defaultApiKey;
36 };
37 NodesmithProvider.getUrl = function (network, apiKey) {
38 logger.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
39 var host = null;
40 switch (network.name) {
41 case "homestead":
42 host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";
43 break;
44 case "ropsten":
45 host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";
46 break;
47 case "rinkeby":
48 host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";
49 break;
50 case "goerli":
51 host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";
52 break;
53 case "kovan":
54 host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";
55 break;
56 default:
57 logger.throwArgumentError("unsupported network", "network", arguments[0]);
58 }
59 return (host + "?apiKey=" + apiKey);
60 };
61 return NodesmithProvider;
62}(url_json_rpc_provider_1.UrlJsonRpcProvider));
63exports.NodesmithProvider = NodesmithProvider;
64//# sourceMappingURL=nodesmith-provider.js.map
\No newline at end of file