2019-05-15 01:48:48 +03: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; }) ||
|
|
|
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
|
return extendStatics(d, b);
|
|
|
|
};
|
|
|
|
return function (d, b) {
|
|
|
|
extendStatics(d, b);
|
|
|
|
function __() { this.constructor = d; }
|
|
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var networks_1 = require("@ethersproject/networks");
|
|
|
|
var properties_1 = require("@ethersproject/properties");
|
2019-08-02 09:10:58 +03:00
|
|
|
var logger_1 = require("@ethersproject/logger");
|
|
|
|
var _version_1 = require("./_version");
|
|
|
|
var logger = new logger_1.Logger(_version_1.version);
|
2019-05-15 01:48:48 +03:00
|
|
|
var json_rpc_provider_1 = require("./json-rpc-provider");
|
|
|
|
var UrlJsonRpcProvider = /** @class */ (function (_super) {
|
|
|
|
__extends(UrlJsonRpcProvider, _super);
|
|
|
|
function UrlJsonRpcProvider(network, apiKey) {
|
|
|
|
var _newTarget = this.constructor;
|
|
|
|
var _this = this;
|
2019-08-02 09:10:58 +03:00
|
|
|
logger.checkAbstract(_newTarget, UrlJsonRpcProvider);
|
2019-05-24 02:13:44 +03:00
|
|
|
// Normalize the Network and API Key
|
2019-08-21 08:52:13 +03:00
|
|
|
network = properties_1.getStatic((_newTarget), "getNetwork")(network);
|
|
|
|
apiKey = properties_1.getStatic((_newTarget), "getApiKey")(apiKey);
|
|
|
|
var url = properties_1.getStatic((_newTarget), "getUrl")(network, apiKey);
|
2019-05-15 01:48:48 +03:00
|
|
|
_this = _super.call(this, url, network) || this;
|
|
|
|
properties_1.defineReadOnly(_this, "apiKey", apiKey);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
UrlJsonRpcProvider.prototype._startPending = function () {
|
2019-08-02 09:10:58 +03:00
|
|
|
logger.warn("WARNING: API provider does not support pending filters");
|
2019-05-15 01:48:48 +03:00
|
|
|
};
|
|
|
|
UrlJsonRpcProvider.prototype.getSigner = function (address) {
|
2019-08-02 09:10:58 +03:00
|
|
|
logger.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" });
|
2019-05-15 01:48:48 +03:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
UrlJsonRpcProvider.prototype.listAccounts = function () {
|
|
|
|
return Promise.resolve([]);
|
|
|
|
};
|
2019-05-24 02:13:44 +03:00
|
|
|
UrlJsonRpcProvider.getNetwork = function (network) {
|
|
|
|
return networks_1.getNetwork((network == null) ? "homestead" : network);
|
|
|
|
};
|
2019-05-15 01:48:48 +03:00
|
|
|
// Return a defaultApiKey if null, otherwise validate the API key
|
|
|
|
UrlJsonRpcProvider.getApiKey = function (apiKey) {
|
|
|
|
return apiKey;
|
|
|
|
};
|
|
|
|
// Returns the url for the given network and API key
|
|
|
|
UrlJsonRpcProvider.getUrl = function (network, apiKey) {
|
2019-08-02 09:10:58 +03:00
|
|
|
return logger.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, {
|
2019-05-15 01:48:48 +03:00
|
|
|
operation: "getUrl"
|
|
|
|
});
|
|
|
|
};
|
|
|
|
return UrlJsonRpcProvider;
|
|
|
|
}(json_rpc_provider_1.JsonRpcProvider));
|
|
|
|
exports.UrlJsonRpcProvider = UrlJsonRpcProvider;
|