2019-05-15 01:48:48 +03:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var abstract_provider_1 = require("@ethersproject/abstract-provider");
|
|
|
|
exports.Provider = abstract_provider_1.Provider;
|
|
|
|
var networks_1 = require("@ethersproject/networks");
|
|
|
|
exports.getNetwork = networks_1.getNetwork;
|
|
|
|
var base_provider_1 = require("./base-provider");
|
|
|
|
exports.BaseProvider = base_provider_1.BaseProvider;
|
2020-09-04 08:37:14 +03:00
|
|
|
exports.Resolver = base_provider_1.Resolver;
|
2019-05-15 01:48:48 +03:00
|
|
|
var alchemy_provider_1 = require("./alchemy-provider");
|
|
|
|
exports.AlchemyProvider = alchemy_provider_1.AlchemyProvider;
|
2020-10-08 03:10:50 +03:00
|
|
|
exports.AlchemyWebSocketProvider = alchemy_provider_1.AlchemyWebSocketProvider;
|
2019-08-21 08:52:13 +03:00
|
|
|
var cloudflare_provider_1 = require("./cloudflare-provider");
|
|
|
|
exports.CloudflareProvider = cloudflare_provider_1.CloudflareProvider;
|
2019-05-15 01:48:48 +03:00
|
|
|
var etherscan_provider_1 = require("./etherscan-provider");
|
|
|
|
exports.EtherscanProvider = etherscan_provider_1.EtherscanProvider;
|
|
|
|
var fallback_provider_1 = require("./fallback-provider");
|
|
|
|
exports.FallbackProvider = fallback_provider_1.FallbackProvider;
|
|
|
|
var ipc_provider_1 = require("./ipc-provider");
|
|
|
|
exports.IpcProvider = ipc_provider_1.IpcProvider;
|
|
|
|
var infura_provider_1 = require("./infura-provider");
|
|
|
|
exports.InfuraProvider = infura_provider_1.InfuraProvider;
|
2020-10-08 03:10:50 +03:00
|
|
|
exports.InfuraWebSocketProvider = infura_provider_1.InfuraWebSocketProvider;
|
2019-05-15 01:48:48 +03:00
|
|
|
var json_rpc_provider_1 = require("./json-rpc-provider");
|
|
|
|
exports.JsonRpcProvider = json_rpc_provider_1.JsonRpcProvider;
|
|
|
|
exports.JsonRpcSigner = json_rpc_provider_1.JsonRpcSigner;
|
|
|
|
var nodesmith_provider_1 = require("./nodesmith-provider");
|
|
|
|
exports.NodesmithProvider = nodesmith_provider_1.NodesmithProvider;
|
2020-10-19 06:19:16 +03:00
|
|
|
var pocket_provider_1 = require("./pocket-provider");
|
|
|
|
exports.PocketProvider = pocket_provider_1.PocketProvider;
|
2020-06-29 07:54:30 +03:00
|
|
|
var url_json_rpc_provider_1 = require("./url-json-rpc-provider");
|
|
|
|
exports.StaticJsonRpcProvider = url_json_rpc_provider_1.StaticJsonRpcProvider;
|
|
|
|
exports.UrlJsonRpcProvider = url_json_rpc_provider_1.UrlJsonRpcProvider;
|
2019-05-15 01:48:48 +03:00
|
|
|
var web3_provider_1 = require("./web3-provider");
|
|
|
|
exports.Web3Provider = web3_provider_1.Web3Provider;
|
2020-03-12 21:14:50 +03:00
|
|
|
var websocket_provider_1 = require("./websocket-provider");
|
|
|
|
exports.WebSocketProvider = websocket_provider_1.WebSocketProvider;
|
2019-07-21 02:13:00 +03:00
|
|
|
var formatter_1 = require("./formatter");
|
|
|
|
exports.Formatter = formatter_1.Formatter;
|
2020-10-08 03:10:50 +03:00
|
|
|
exports.isCommunityResourcable = formatter_1.isCommunityResourcable;
|
|
|
|
exports.isCommunityResource = formatter_1.isCommunityResource;
|
|
|
|
exports.showThrottleMessage = 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
|