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

64 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2020-07-14 02:33:30 -04:00
/* istanbul ignore file */
2019-05-14 18:48:48 -04:00
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2021-03-07 18:24:04 -05:00
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2019-05-14 18:48:48 -04:00
return extendStatics(d, b);
};
return function (d, b) {
2021-03-07 18:24:04 -05:00
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2019-05-14 18:48:48 -04:00
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
2021-03-07 18:24:04 -05:00
exports.NodesmithProvider = void 0;
2019-05-14 18:48:48 -04:00
var url_json_rpc_provider_1 = require("./url-json-rpc-provider");
2019-08-02 02:10:58 -04:00
var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version);
2019-05-14 18:48:48 -04:00
// Special API key provided by Nodesmith for ethers.js
var defaultApiKey = "ETHERS_JS_SHARED";
var NodesmithProvider = /** @class */ (function (_super) {
__extends(NodesmithProvider, _super);
function NodesmithProvider() {
return _super !== null && _super.apply(this, arguments) || this;
}
NodesmithProvider.getApiKey = function (apiKey) {
2019-11-20 18:57:38 +09:00
if (apiKey && typeof (apiKey) !== "string") {
logger.throwArgumentError("invalid apiKey", "apiKey", apiKey);
}
2019-05-14 18:48:48 -04:00
return apiKey || defaultApiKey;
};
NodesmithProvider.getUrl = function (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.");
2019-05-14 18:48:48 -04:00
var 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:
2019-08-02 02:10:58 -04:00
logger.throwArgumentError("unsupported network", "network", arguments[0]);
2019-05-14 18:48:48 -04:00
}
return (host + "?apiKey=" + apiKey);
};
return NodesmithProvider;
}(url_json_rpc_provider_1.UrlJsonRpcProvider));
exports.NodesmithProvider = NodesmithProvider;
2020-07-13 08:03:56 -04:00
//# sourceMappingURL=nodesmith-provider.js.map