2019-05-15 01:48:48 +03:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2021-04-18 05:41:09 +03:00
|
|
|
exports.Formatter = exports.showThrottleMessage = exports.isCommunityResourcable = exports.isCommunityResource = exports.getNetwork = exports.getDefaultProvider = exports.JsonRpcSigner = exports.IpcProvider = exports.WebSocketProvider = exports.Web3Provider = exports.StaticJsonRpcProvider = exports.PocketProvider = exports.NodesmithProvider = exports.JsonRpcBatchProvider = exports.JsonRpcProvider = exports.InfuraWebSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AlchemyWebSocketProvider = exports.AlchemyProvider = exports.FallbackProvider = exports.UrlJsonRpcProvider = exports.Resolver = exports.BaseProvider = exports.Provider = void 0;
|
2019-05-15 01:48:48 +03:00
|
|
|
var abstract_provider_1 = require("@ethersproject/abstract-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return abstract_provider_1.Provider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var networks_1 = require("@ethersproject/networks");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "getNetwork", { enumerable: true, get: function () { return networks_1.getNetwork; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var base_provider_1 = require("./base-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "BaseProvider", { enumerable: true, get: function () { return base_provider_1.BaseProvider; } });
|
|
|
|
Object.defineProperty(exports, "Resolver", { enumerable: true, get: function () { return base_provider_1.Resolver; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var alchemy_provider_1 = require("./alchemy-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "AlchemyProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyProvider; } });
|
|
|
|
Object.defineProperty(exports, "AlchemyWebSocketProvider", { enumerable: true, get: function () { return alchemy_provider_1.AlchemyWebSocketProvider; } });
|
2019-08-21 08:52:13 +03:00
|
|
|
var cloudflare_provider_1 = require("./cloudflare-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "CloudflareProvider", { enumerable: true, get: function () { return cloudflare_provider_1.CloudflareProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var etherscan_provider_1 = require("./etherscan-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "EtherscanProvider", { enumerable: true, get: function () { return etherscan_provider_1.EtherscanProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var fallback_provider_1 = require("./fallback-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return fallback_provider_1.FallbackProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var ipc_provider_1 = require("./ipc-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "IpcProvider", { enumerable: true, get: function () { return ipc_provider_1.IpcProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var infura_provider_1 = require("./infura-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "InfuraProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraProvider; } });
|
|
|
|
Object.defineProperty(exports, "InfuraWebSocketProvider", { enumerable: true, get: function () { return infura_provider_1.InfuraWebSocketProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var json_rpc_provider_1 = require("./json-rpc-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcProvider; } });
|
|
|
|
Object.defineProperty(exports, "JsonRpcSigner", { enumerable: true, get: function () { return json_rpc_provider_1.JsonRpcSigner; } });
|
2021-04-18 05:41:09 +03:00
|
|
|
var json_rpc_batch_provider_1 = require("./json-rpc-batch-provider");
|
|
|
|
Object.defineProperty(exports, "JsonRpcBatchProvider", { enumerable: true, get: function () { return json_rpc_batch_provider_1.JsonRpcBatchProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var nodesmith_provider_1 = require("./nodesmith-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "NodesmithProvider", { enumerable: true, get: function () { return nodesmith_provider_1.NodesmithProvider; } });
|
2020-10-19 06:19:16 +03:00
|
|
|
var pocket_provider_1 = require("./pocket-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "PocketProvider", { enumerable: true, get: function () { return pocket_provider_1.PocketProvider; } });
|
2020-06-29 07:54:30 +03:00
|
|
|
var url_json_rpc_provider_1 = require("./url-json-rpc-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "StaticJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.StaticJsonRpcProvider; } });
|
|
|
|
Object.defineProperty(exports, "UrlJsonRpcProvider", { enumerable: true, get: function () { return url_json_rpc_provider_1.UrlJsonRpcProvider; } });
|
2019-05-15 01:48:48 +03:00
|
|
|
var web3_provider_1 = require("./web3-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "Web3Provider", { enumerable: true, get: function () { return web3_provider_1.Web3Provider; } });
|
2020-03-12 21:14:50 +03:00
|
|
|
var websocket_provider_1 = require("./websocket-provider");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "WebSocketProvider", { enumerable: true, get: function () { return websocket_provider_1.WebSocketProvider; } });
|
2019-07-21 02:13:00 +03:00
|
|
|
var formatter_1 = require("./formatter");
|
2021-03-08 02:24:04 +03:00
|
|
|
Object.defineProperty(exports, "Formatter", { enumerable: true, get: function () { return formatter_1.Formatter; } });
|
|
|
|
Object.defineProperty(exports, "isCommunityResourcable", { enumerable: true, get: function () { return formatter_1.isCommunityResourcable; } });
|
|
|
|
Object.defineProperty(exports, "isCommunityResource", { enumerable: true, get: function () { return formatter_1.isCommunityResource; } });
|
|
|
|
Object.defineProperty(exports, "showThrottleMessage", { enumerable: true, get: function () { return formatter_1.showThrottleMessage; } });
|
2019-11-20 12:57:38 +03:00
|
|
|
var logger_1 = require("@ethersproject/logger");
|
|
|
|
var _version_1 = require("./_version");
|
|
|
|
var logger = new logger_1.Logger(_version_1.version);
|
|
|
|
////////////////////////
|
|
|
|
// Helper Functions
|
|
|
|
function getDefaultProvider(network, options) {
|
|
|
|
if (network == null) {
|
|
|
|
network = "homestead";
|
|
|
|
}
|
2020-06-29 07:54:30 +03:00
|
|
|
// If passed a URL, figure out the right type of provider based on the scheme
|
|
|
|
if (typeof (network) === "string") {
|
|
|
|
// @TODO: Add support for IpcProvider; maybe if it ends in ".ipc"?
|
|
|
|
// Handle http and ws (and their secure variants)
|
|
|
|
var match = network.match(/^(ws|http)s?:/i);
|
|
|
|
if (match) {
|
|
|
|
switch (match[1]) {
|
|
|
|
case "http":
|
|
|
|
return new json_rpc_provider_1.JsonRpcProvider(network);
|
|
|
|
case "ws":
|
|
|
|
return new websocket_provider_1.WebSocketProvider(network);
|
|
|
|
default:
|
|
|
|
logger.throwArgumentError("unsupported URL scheme", "network", network);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-20 12:57:38 +03:00
|
|
|
var n = networks_1.getNetwork(network);
|
|
|
|
if (!n || !n._defaultProvider) {
|
|
|
|
logger.throwError("unsupported getDefaultProvider network", logger_1.Logger.errors.NETWORK_ERROR, {
|
|
|
|
operation: "getDefaultProvider",
|
|
|
|
network: network
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return n._defaultProvider({
|
|
|
|
FallbackProvider: fallback_provider_1.FallbackProvider,
|
|
|
|
AlchemyProvider: alchemy_provider_1.AlchemyProvider,
|
|
|
|
CloudflareProvider: cloudflare_provider_1.CloudflareProvider,
|
|
|
|
EtherscanProvider: etherscan_provider_1.EtherscanProvider,
|
|
|
|
InfuraProvider: infura_provider_1.InfuraProvider,
|
|
|
|
JsonRpcProvider: json_rpc_provider_1.JsonRpcProvider,
|
|
|
|
NodesmithProvider: nodesmith_provider_1.NodesmithProvider,
|
2020-10-19 06:19:16 +03:00
|
|
|
PocketProvider: pocket_provider_1.PocketProvider,
|
2019-11-20 12:57:38 +03:00
|
|
|
Web3Provider: web3_provider_1.Web3Provider,
|
|
|
|
IpcProvider: ipc_provider_1.IpcProvider,
|
|
|
|
}, options);
|
|
|
|
}
|
|
|
|
exports.getDefaultProvider = getDefaultProvider;
|
2020-07-13 15:03:56 +03:00
|
|
|
//# sourceMappingURL=index.js.map
|