Update dist files.
This commit is contained in:
parent
99ae946476
commit
3f37d15b88
@ -7,9 +7,15 @@ may change. It is generally recommended that you remove your `node_modules/`,
|
||||
`package-lock.json` (and similar files for yarn, etc.) and doing an `npm install`
|
||||
after upgrading to a newer version of the v5-BETA.
|
||||
|
||||
ethers/v5.0.0-beta.185 (2020-05-01 16:45)
|
||||
ethers/v5.0.0-beta.185 (2020-05-03 17:38)
|
||||
-----------------------------------------
|
||||
|
||||
- Allow providers to detect their network after instantiation. ([#814](https://github.com/ethers-io/ethers.js/issues/814); [99ae946](https://github.com/ethers-io/ethers.js/commit/99ae946476a317a9d89e5d8f57cf37f8680bfa2b))
|
||||
- Better messaging on low-level network errors. ([#814](https://github.com/ethers-io/ethers.js/issues/814); [0e3a66c](https://github.com/ethers-io/ethers.js/commit/0e3a66c82959a08f3f4e4ffbca3ae3792ff2548f))
|
||||
- Manage FallbackProvider stalling without unref. ([#815](https://github.com/ethers-io/ethers.js/issues/815); [7b1a7c7](https://github.com/ethers-io/ethers.js/commit/7b1a7c7f31a3631e12c2a341b562983360e670e9))
|
||||
- Only error on duplicate signatures in Contract ABI. ([#499](https://github.com/ethers-io/ethers.js/issues/499); [098d7ef](https://github.com/ethers-io/ethers.js/commit/098d7efb21bd648c2660342297d2419904a10925))
|
||||
- Added getWebSocketProvider static method to InfuraProvider. ([a6c1174](https://github.com/ethers-io/ethers.js/commit/a6c1174dffe6dca1a3a64d1d472cec6e12372117))
|
||||
- Fix WebSocketProvider responses when message result is null. ([#813](https://github.com/ethers-io/ethers.js/issues/813); [472e5b0](https://github.com/ethers-io/ethers.js/commit/472e5b07eab180baa12185c8f00e5079ce4c671f))
|
||||
- Allow modifiers on Human-Readable ABI for tuples and arrays. ([83fba3d](https://github.com/ethers-io/ethers.js/commit/83fba3de25b524cc48975b1952f4319d63874205))
|
||||
- Added initial renew support to ENS CLI. ([54dfb75](https://github.com/ethers-io/ethers.js/commit/54dfb757c4c88e4bcada1890c4016fadfb25581a))
|
||||
- Allow contract filters to include OR-ed values. ([#437](https://github.com/ethers-io/ethers.js/issues/437); [28800d7](https://github.com/ethers-io/ethers.js/commit/28800d7681f3bab08f6d30a22f0813e04feee18a))
|
||||
|
@ -12,7 +12,7 @@ const Words = fs.readFileSync("/usr/share/dict/words").toString().split("\n").re
|
||||
// Words missing from the dictionary
|
||||
accessing addresses aligned autofill called cancelled censored
|
||||
compiled computed configured consumed creating decoded decoding
|
||||
decrypt decrypted decrypting deployed deploying deprecated
|
||||
decrypt decrypted decrypting deployed deploying deprecated detected
|
||||
discontinued earliest email enabled encoded encoding encrypt
|
||||
encrypted encrypting entries euro exceeded existing expected
|
||||
expired failed fetches formatted formatting funding generated
|
||||
@ -44,13 +44,13 @@ ABIEncoder testcase numberish Wordlist
|
||||
// Common Code Strings
|
||||
abi addr api app arg arrayify asm basex bigint bn byte bytecode
|
||||
callback calldata checksum ciphertext cli codepoint config
|
||||
contenthash ctr ctrl debug dklen eexist encseed eof ethaddr
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof ethaddr
|
||||
ethseed ethers eval exec filename func gz hid http https hw iv
|
||||
info init ipc json kdf kdfparams labelhash lang lib multihash nfc
|
||||
info init ipc json kdf kdfparams labelhash lang lib mm multihash nfc
|
||||
nfkc nfd nfkd nodehash oob opcode pbkdf pc plugin pragma pre prf
|
||||
repl rpc sighash topichash solc stdin stdout subclasses subnode
|
||||
timeout todo txt ufixed utc utf util url uuid vm vs websocket
|
||||
wikipedia wx xe zlib
|
||||
wikipedia wx xe yyyy zlib
|
||||
|
||||
// AbiV2
|
||||
abiv
|
||||
|
@ -31,7 +31,7 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0x7fd77ad0e6f0df98c7f7b5f91552b5c5ce359a2fbd05a9ab852bec00530a7712",
|
||||
"tarballHash": "0x7f866470aabd8bbe47af1ff527fedbd86445cbfcd3bbf340d34c96b38b8e8606",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.153"
|
||||
}
|
||||
|
2
packages/contracts/lib.esm/_version.d.ts
vendored
2
packages/contracts/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
||||
export declare const version = "contracts/5.0.0-beta.150";
|
||||
export declare const version = "contracts/5.0.0-beta.151";
|
||||
|
@ -1 +1 @@
|
||||
export const version = "contracts/5.0.0-beta.150";
|
||||
export const version = "contracts/5.0.0-beta.151";
|
||||
|
@ -389,44 +389,66 @@ export class Contract {
|
||||
logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName);
|
||||
}
|
||||
}
|
||||
const uniqueFunctions = {};
|
||||
Object.keys(this.interface.functions).forEach((name) => {
|
||||
const fragment = this.interface.functions[name];
|
||||
// @TODO: This should take in fragment
|
||||
const run = runMethod(this, name, {});
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, run);
|
||||
}
|
||||
if (this.functions[name] == null) {
|
||||
defineReadOnly(this.functions, name, run);
|
||||
}
|
||||
if (this.callStatic[name] == null) {
|
||||
defineReadOnly(this.callStatic, name, runMethod(this, name, { callStatic: true }));
|
||||
}
|
||||
if (this.populateTransaction[name] == null) {
|
||||
defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true }));
|
||||
}
|
||||
if (this.estimateGas[name] == null) {
|
||||
defineReadOnly(this.estimateGas, name, runMethod(this, name, { estimate: true }));
|
||||
}
|
||||
if (!uniqueFunctions[fragment.name]) {
|
||||
uniqueFunctions[fragment.name] = [];
|
||||
}
|
||||
uniqueFunctions[fragment.name].push(name);
|
||||
});
|
||||
Object.keys(uniqueFunctions).forEach((name) => {
|
||||
const signatures = uniqueFunctions[name];
|
||||
if (signatures.length > 1) {
|
||||
logger.warn(`Duplicate definition of ${name} (${signatures.join(", ")})`);
|
||||
const uniqueNames = {};
|
||||
const uniqueSignatures = {};
|
||||
Object.keys(this.interface.functions).forEach((signature) => {
|
||||
const fragment = this.interface.functions[signature];
|
||||
// Check that the signature is unique; if not the ABI generation has
|
||||
// not been cleaned or may be incorrectly generated
|
||||
if (uniqueSignatures[signature]) {
|
||||
logger.warn(`Duplicate ABI entry for ${JSON.stringify(name)}`);
|
||||
return;
|
||||
}
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, this[signatures[0]]);
|
||||
uniqueSignatures[signature] = true;
|
||||
// Track unique names; we only expose bare named functions if they
|
||||
// are ambiguous
|
||||
{
|
||||
const name = fragment.name;
|
||||
if (!uniqueNames[name]) {
|
||||
uniqueNames[name] = [];
|
||||
}
|
||||
uniqueNames[name].push(signature);
|
||||
}
|
||||
// @TODO: This should take in fragment
|
||||
const run = runMethod(this, signature, {});
|
||||
if (this[signature] == null) {
|
||||
defineReadOnly(this, signature, run);
|
||||
}
|
||||
if (this.functions[signature] == null) {
|
||||
defineReadOnly(this.functions, signature, run);
|
||||
}
|
||||
if (this.callStatic[signature] == null) {
|
||||
defineReadOnly(this.callStatic, signature, runMethod(this, signature, { callStatic: true }));
|
||||
}
|
||||
if (this.populateTransaction[signature] == null) {
|
||||
defineReadOnly(this.populateTransaction, signature, runMethod(this, signature, { transaction: true }));
|
||||
}
|
||||
if (this.estimateGas[signature] == null) {
|
||||
defineReadOnly(this.estimateGas, signature, runMethod(this, signature, { estimate: true }));
|
||||
}
|
||||
});
|
||||
Object.keys(uniqueNames).forEach((name) => {
|
||||
// Ambiguous names to not get attached as bare names
|
||||
const signatures = uniqueNames[name];
|
||||
if (signatures.length > 1) {
|
||||
return;
|
||||
}
|
||||
const signature = signatures[0];
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, this[signature]);
|
||||
}
|
||||
if (this.functions[name] == null) {
|
||||
defineReadOnly(this.functions, name, this.functions[signature]);
|
||||
}
|
||||
if (this.callStatic[name] == null) {
|
||||
defineReadOnly(this.callStatic, name, this.callStatic[signature]);
|
||||
}
|
||||
if (this.populateTransaction[name] == null) {
|
||||
defineReadOnly(this.populateTransaction, name, this.populateTransaction[signature]);
|
||||
}
|
||||
if (this.estimateGas[name] == null) {
|
||||
defineReadOnly(this.estimateGas, name, this.estimateGas[signature]);
|
||||
}
|
||||
defineReadOnly(this.functions, name, this.functions[signatures[0]]);
|
||||
defineReadOnly(this.callStatic, name, this.callStatic[signatures[0]]);
|
||||
defineReadOnly(this.populateTransaction, name, this.populateTransaction[signatures[0]]);
|
||||
defineReadOnly(this.estimateGas, name, this.estimateGas[signatures[0]]);
|
||||
});
|
||||
}
|
||||
static getContractAddress(transaction) {
|
||||
|
2
packages/contracts/lib/_version.d.ts
vendored
2
packages/contracts/lib/_version.d.ts
vendored
@ -1 +1 @@
|
||||
export declare const version = "contracts/5.0.0-beta.150";
|
||||
export declare const version = "contracts/5.0.0-beta.151";
|
||||
|
@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "contracts/5.0.0-beta.150";
|
||||
exports.version = "contracts/5.0.0-beta.151";
|
||||
|
@ -461,44 +461,66 @@ var Contract = /** @class */ (function () {
|
||||
logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName);
|
||||
}
|
||||
}
|
||||
var uniqueFunctions = {};
|
||||
Object.keys(this.interface.functions).forEach(function (name) {
|
||||
var fragment = _this.interface.functions[name];
|
||||
// @TODO: This should take in fragment
|
||||
var run = runMethod(_this, name, {});
|
||||
if (_this[name] == null) {
|
||||
properties_1.defineReadOnly(_this, name, run);
|
||||
}
|
||||
if (_this.functions[name] == null) {
|
||||
properties_1.defineReadOnly(_this.functions, name, run);
|
||||
}
|
||||
if (_this.callStatic[name] == null) {
|
||||
properties_1.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true }));
|
||||
}
|
||||
if (_this.populateTransaction[name] == null) {
|
||||
properties_1.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true }));
|
||||
}
|
||||
if (_this.estimateGas[name] == null) {
|
||||
properties_1.defineReadOnly(_this.estimateGas, name, runMethod(_this, name, { estimate: true }));
|
||||
}
|
||||
if (!uniqueFunctions[fragment.name]) {
|
||||
uniqueFunctions[fragment.name] = [];
|
||||
}
|
||||
uniqueFunctions[fragment.name].push(name);
|
||||
});
|
||||
Object.keys(uniqueFunctions).forEach(function (name) {
|
||||
var signatures = uniqueFunctions[name];
|
||||
if (signatures.length > 1) {
|
||||
logger.warn("Duplicate definition of " + name + " (" + signatures.join(", ") + ")");
|
||||
var uniqueNames = {};
|
||||
var uniqueSignatures = {};
|
||||
Object.keys(this.interface.functions).forEach(function (signature) {
|
||||
var fragment = _this.interface.functions[signature];
|
||||
// Check that the signature is unique; if not the ABI generation has
|
||||
// not been cleaned or may be incorrectly generated
|
||||
if (uniqueSignatures[signature]) {
|
||||
logger.warn("Duplicate ABI entry for " + JSON.stringify(name));
|
||||
return;
|
||||
}
|
||||
if (_this[name] == null) {
|
||||
properties_1.defineReadOnly(_this, name, _this[signatures[0]]);
|
||||
uniqueSignatures[signature] = true;
|
||||
// Track unique names; we only expose bare named functions if they
|
||||
// are ambiguous
|
||||
{
|
||||
var name_1 = fragment.name;
|
||||
if (!uniqueNames[name_1]) {
|
||||
uniqueNames[name_1] = [];
|
||||
}
|
||||
uniqueNames[name_1].push(signature);
|
||||
}
|
||||
// @TODO: This should take in fragment
|
||||
var run = runMethod(_this, signature, {});
|
||||
if (_this[signature] == null) {
|
||||
properties_1.defineReadOnly(_this, signature, run);
|
||||
}
|
||||
if (_this.functions[signature] == null) {
|
||||
properties_1.defineReadOnly(_this.functions, signature, run);
|
||||
}
|
||||
if (_this.callStatic[signature] == null) {
|
||||
properties_1.defineReadOnly(_this.callStatic, signature, runMethod(_this, signature, { callStatic: true }));
|
||||
}
|
||||
if (_this.populateTransaction[signature] == null) {
|
||||
properties_1.defineReadOnly(_this.populateTransaction, signature, runMethod(_this, signature, { transaction: true }));
|
||||
}
|
||||
if (_this.estimateGas[signature] == null) {
|
||||
properties_1.defineReadOnly(_this.estimateGas, signature, runMethod(_this, signature, { estimate: true }));
|
||||
}
|
||||
});
|
||||
Object.keys(uniqueNames).forEach(function (name) {
|
||||
// Ambiguous names to not get attached as bare names
|
||||
var signatures = uniqueNames[name];
|
||||
if (signatures.length > 1) {
|
||||
return;
|
||||
}
|
||||
var signature = signatures[0];
|
||||
if (_this[name] == null) {
|
||||
properties_1.defineReadOnly(_this, name, _this[signature]);
|
||||
}
|
||||
if (_this.functions[name] == null) {
|
||||
properties_1.defineReadOnly(_this.functions, name, _this.functions[signature]);
|
||||
}
|
||||
if (_this.callStatic[name] == null) {
|
||||
properties_1.defineReadOnly(_this.callStatic, name, _this.callStatic[signature]);
|
||||
}
|
||||
if (_this.populateTransaction[name] == null) {
|
||||
properties_1.defineReadOnly(_this.populateTransaction, name, _this.populateTransaction[signature]);
|
||||
}
|
||||
if (_this.estimateGas[name] == null) {
|
||||
properties_1.defineReadOnly(_this.estimateGas, name, _this.estimateGas[signature]);
|
||||
}
|
||||
properties_1.defineReadOnly(_this.functions, name, _this.functions[signatures[0]]);
|
||||
properties_1.defineReadOnly(_this.callStatic, name, _this.callStatic[signatures[0]]);
|
||||
properties_1.defineReadOnly(_this.populateTransaction, name, _this.populateTransaction[signatures[0]]);
|
||||
properties_1.defineReadOnly(_this.estimateGas, name, _this.estimateGas[signatures[0]]);
|
||||
});
|
||||
}
|
||||
Contract.getContractAddress = function (transaction) {
|
||||
|
@ -32,7 +32,7 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0x5030e873ef0ebc78913b3a1344a86cd92873b60418a342048ad165f751c342e5",
|
||||
"tarballHash": "0x918c40fdb8ee8be8cc4d0094b6b936fb8a35203af97b33f227fb80d30b337f5e",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.150"
|
||||
"version": "5.0.0-beta.151"
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
export const version = "contracts/5.0.0-beta.150";
|
||||
export const version = "contracts/5.0.0-beta.151";
|
||||
|
4
packages/ethers/dist/ethers-all.esm.min.js
vendored
4
packages/ethers/dist/ethers-all.esm.min.js
vendored
File diff suppressed because one or more lines are too long
2
packages/ethers/dist/ethers-all.umd.min.js
vendored
2
packages/ethers/dist/ethers-all.umd.min.js
vendored
File diff suppressed because one or more lines are too long
725
packages/ethers/dist/ethers.esm.js
vendored
725
packages/ethers/dist/ethers.esm.js
vendored
@ -8162,7 +8162,7 @@ class VoidSigner extends Signer {
|
||||
}
|
||||
}
|
||||
|
||||
const version$b = "contracts/5.0.0-beta.150";
|
||||
const version$b = "contracts/5.0.0-beta.151";
|
||||
|
||||
"use strict";
|
||||
var __awaiter$2 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
@ -8545,44 +8545,66 @@ class Contract {
|
||||
logger$f.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName);
|
||||
}
|
||||
}
|
||||
const uniqueFunctions = {};
|
||||
Object.keys(this.interface.functions).forEach((name) => {
|
||||
const fragment = this.interface.functions[name];
|
||||
// @TODO: This should take in fragment
|
||||
const run = runMethod(this, name, {});
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, run);
|
||||
}
|
||||
if (this.functions[name] == null) {
|
||||
defineReadOnly(this.functions, name, run);
|
||||
}
|
||||
if (this.callStatic[name] == null) {
|
||||
defineReadOnly(this.callStatic, name, runMethod(this, name, { callStatic: true }));
|
||||
}
|
||||
if (this.populateTransaction[name] == null) {
|
||||
defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true }));
|
||||
}
|
||||
if (this.estimateGas[name] == null) {
|
||||
defineReadOnly(this.estimateGas, name, runMethod(this, name, { estimate: true }));
|
||||
}
|
||||
if (!uniqueFunctions[fragment.name]) {
|
||||
uniqueFunctions[fragment.name] = [];
|
||||
}
|
||||
uniqueFunctions[fragment.name].push(name);
|
||||
});
|
||||
Object.keys(uniqueFunctions).forEach((name) => {
|
||||
const signatures = uniqueFunctions[name];
|
||||
if (signatures.length > 1) {
|
||||
logger$f.warn(`Duplicate definition of ${name} (${signatures.join(", ")})`);
|
||||
const uniqueNames = {};
|
||||
const uniqueSignatures = {};
|
||||
Object.keys(this.interface.functions).forEach((signature) => {
|
||||
const fragment = this.interface.functions[signature];
|
||||
// Check that the signature is unique; if not the ABI generation has
|
||||
// not been cleaned or may be incorrectly generated
|
||||
if (uniqueSignatures[signature]) {
|
||||
logger$f.warn(`Duplicate ABI entry for ${JSON.stringify(name)}`);
|
||||
return;
|
||||
}
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, this[signatures[0]]);
|
||||
uniqueSignatures[signature] = true;
|
||||
// Track unique names; we only expose bare named functions if they
|
||||
// are ambiguous
|
||||
{
|
||||
const name = fragment.name;
|
||||
if (!uniqueNames[name]) {
|
||||
uniqueNames[name] = [];
|
||||
}
|
||||
uniqueNames[name].push(signature);
|
||||
}
|
||||
// @TODO: This should take in fragment
|
||||
const run = runMethod(this, signature, {});
|
||||
if (this[signature] == null) {
|
||||
defineReadOnly(this, signature, run);
|
||||
}
|
||||
if (this.functions[signature] == null) {
|
||||
defineReadOnly(this.functions, signature, run);
|
||||
}
|
||||
if (this.callStatic[signature] == null) {
|
||||
defineReadOnly(this.callStatic, signature, runMethod(this, signature, { callStatic: true }));
|
||||
}
|
||||
if (this.populateTransaction[signature] == null) {
|
||||
defineReadOnly(this.populateTransaction, signature, runMethod(this, signature, { transaction: true }));
|
||||
}
|
||||
if (this.estimateGas[signature] == null) {
|
||||
defineReadOnly(this.estimateGas, signature, runMethod(this, signature, { estimate: true }));
|
||||
}
|
||||
});
|
||||
Object.keys(uniqueNames).forEach((name) => {
|
||||
// Ambiguous names to not get attached as bare names
|
||||
const signatures = uniqueNames[name];
|
||||
if (signatures.length > 1) {
|
||||
return;
|
||||
}
|
||||
const signature = signatures[0];
|
||||
if (this[name] == null) {
|
||||
defineReadOnly(this, name, this[signature]);
|
||||
}
|
||||
if (this.functions[name] == null) {
|
||||
defineReadOnly(this.functions, name, this.functions[signature]);
|
||||
}
|
||||
if (this.callStatic[name] == null) {
|
||||
defineReadOnly(this.callStatic, name, this.callStatic[signature]);
|
||||
}
|
||||
if (this.populateTransaction[name] == null) {
|
||||
defineReadOnly(this.populateTransaction, name, this.populateTransaction[signature]);
|
||||
}
|
||||
if (this.estimateGas[name] == null) {
|
||||
defineReadOnly(this.estimateGas, name, this.estimateGas[signature]);
|
||||
}
|
||||
defineReadOnly(this.functions, name, this.functions[signatures[0]]);
|
||||
defineReadOnly(this.callStatic, name, this.callStatic[signatures[0]]);
|
||||
defineReadOnly(this.populateTransaction, name, this.populateTransaction[signatures[0]]);
|
||||
defineReadOnly(this.estimateGas, name, this.estimateGas[signatures[0]]);
|
||||
});
|
||||
}
|
||||
static getContractAddress(transaction) {
|
||||
@ -15706,7 +15728,7 @@ var browser$2 = /*#__PURE__*/Object.freeze({
|
||||
encode: encode$1
|
||||
});
|
||||
|
||||
const version$l = "web/5.0.0-beta.137";
|
||||
const version$l = "web/5.0.0-beta.138";
|
||||
|
||||
"use strict";
|
||||
var __awaiter$4 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
@ -15845,8 +15867,13 @@ function fetchJson(connection, json, processFunc) {
|
||||
response = yield getUrl(url, options);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
response = error.response;
|
||||
if (response == null) {
|
||||
logger$p.throwError("missing response", Logger.errors.SERVER_ERROR, {
|
||||
serverError: error,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
let body = response.body;
|
||||
if (allow304 && response.statusCode === 304) {
|
||||
@ -16490,23 +16517,28 @@ class Event {
|
||||
let defaultFormatter = null;
|
||||
let nextPollId = 1;
|
||||
class BaseProvider extends Provider {
|
||||
/**
|
||||
* ready
|
||||
*
|
||||
* A Promise<Network> that resolves only once the provider is ready.
|
||||
*
|
||||
* Sub-classes that call the super with a network without a chainId
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
constructor(network) {
|
||||
logger$r.checkNew(new.target, Provider);
|
||||
super();
|
||||
this.formatter = new.target.getFormatter();
|
||||
if (network instanceof Promise) {
|
||||
defineReadOnly(this, "ready", network.then((network) => {
|
||||
defineReadOnly(this, "_network", network);
|
||||
return network;
|
||||
}));
|
||||
this._networkPromise = network;
|
||||
// Squash any "unhandled promise" errors; that do not need to be handled
|
||||
this.ready.catch((error) => { });
|
||||
network.catch((error) => { });
|
||||
}
|
||||
else {
|
||||
const knownNetwork = getStatic((new.target), "getNetwork")(network);
|
||||
if (knownNetwork) {
|
||||
defineReadOnly(this, "_network", knownNetwork);
|
||||
defineReadOnly(this, "ready", Promise.resolve(this._network));
|
||||
}
|
||||
else {
|
||||
logger$r.throwArgumentError("invalid network", "network", network);
|
||||
@ -16520,6 +16552,40 @@ class BaseProvider extends Provider {
|
||||
this._emitted = { block: -2 };
|
||||
this._fastQueryDate = 0;
|
||||
}
|
||||
_ready() {
|
||||
return __awaiter$6(this, void 0, void 0, function* () {
|
||||
if (this._network == null) {
|
||||
let network = null;
|
||||
if (this._networkPromise) {
|
||||
try {
|
||||
network = yield this._networkPromise;
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
// Try the Provider's network detection (this MUST throw if it cannot)
|
||||
if (network == null) {
|
||||
network = yield this.detectNetwork();
|
||||
}
|
||||
// This should never happen; every Provider sub-class should have
|
||||
// suggested a network by here (or thrown).
|
||||
if (!network) {
|
||||
logger$r.throwError("no network detected", Logger.errors.UNKNOWN_ERROR, {});
|
||||
}
|
||||
defineReadOnly(this, "_network", network);
|
||||
}
|
||||
return this._network;
|
||||
});
|
||||
}
|
||||
get ready() {
|
||||
return this._ready();
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter$6(this, void 0, void 0, function* () {
|
||||
return logger$r.throwError("provider does not support network detection", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "provider.detectNetwork"
|
||||
});
|
||||
});
|
||||
}
|
||||
static getFormatter() {
|
||||
if (defaultFormatter == null) {
|
||||
defaultFormatter = new Formatter();
|
||||
@ -17327,9 +17393,7 @@ var __awaiter$7 = (window && window.__awaiter) || function (thisArg, _arguments,
|
||||
const logger$s = new Logger(version$m);
|
||||
function timer(timeout) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
}, timeout);
|
||||
setTimeout(resolve, timeout);
|
||||
});
|
||||
}
|
||||
function getResult(payload) {
|
||||
@ -17514,28 +17578,7 @@ class JsonRpcProvider extends BaseProvider {
|
||||
}
|
||||
else {
|
||||
// The network is unknown, query the JSON-RPC for it
|
||||
const ready = new Promise((resolve, reject) => {
|
||||
setTimeout(() => __awaiter$7(this, void 0, void 0, function* () {
|
||||
let chainId = null;
|
||||
try {
|
||||
chainId = yield this.send("eth_chainId", []);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
chainId = yield this.send("net_version", []);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (chainId != null) {
|
||||
try {
|
||||
return resolve(getNetwork(BigNumber.from(chainId).toNumber()));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
reject(logger$s.makeError("could not detect network", Logger.errors.NETWORK_ERROR));
|
||||
}), 0);
|
||||
});
|
||||
super(ready);
|
||||
super(this.detectNetwork());
|
||||
}
|
||||
// Default URL
|
||||
if (!url) {
|
||||
@ -17554,6 +17597,34 @@ class JsonRpcProvider extends BaseProvider {
|
||||
static defaultUrl() {
|
||||
return "http:/\/localhost:8545";
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter$7(this, void 0, void 0, function* () {
|
||||
yield timer(0);
|
||||
let chainId = null;
|
||||
try {
|
||||
chainId = yield this.send("eth_chainId", []);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
chainId = yield this.send("net_version", []);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (chainId != null) {
|
||||
const getNetwork = getStatic(this.constructor, "getNetwork");
|
||||
try {
|
||||
return getNetwork(BigNumber.from(chainId).toNumber());
|
||||
}
|
||||
catch (error) {
|
||||
return logger$s.throwError("could not detect network", Logger.errors.NETWORK_ERROR, {
|
||||
chainId: chainId,
|
||||
serverError: error
|
||||
});
|
||||
}
|
||||
}
|
||||
return logger$s.throwError("could not detect network", Logger.errors.NETWORK_ERROR);
|
||||
});
|
||||
}
|
||||
getSigner(addressOrIndex) {
|
||||
return new JsonRpcSigner(_constructorGuard$4, this, addressOrIndex);
|
||||
}
|
||||
@ -17763,6 +17834,15 @@ class JsonRpcProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
"use strict";
|
||||
var __awaiter$8 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
const logger$t = new Logger(version$m);
|
||||
class UrlJsonRpcProvider extends JsonRpcProvider {
|
||||
constructor(network, apiKey) {
|
||||
@ -17781,6 +17861,11 @@ class UrlJsonRpcProvider extends JsonRpcProvider {
|
||||
});
|
||||
}
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter$8(this, void 0, void 0, function* () {
|
||||
return this.network;
|
||||
});
|
||||
}
|
||||
_startPending() {
|
||||
logger$t.warn("WARNING: API provider does not support pending filters");
|
||||
}
|
||||
@ -17844,7 +17929,7 @@ class AlchemyProvider extends UrlJsonRpcProvider {
|
||||
}
|
||||
|
||||
"use strict";
|
||||
var __awaiter$8 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
var __awaiter$9 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
@ -17876,7 +17961,7 @@ class CloudflareProvider extends UrlJsonRpcProvider {
|
||||
const _super = Object.create(null, {
|
||||
perform: { get: () => super.perform }
|
||||
});
|
||||
return __awaiter$8(this, void 0, void 0, function* () {
|
||||
return __awaiter$9(this, void 0, void 0, function* () {
|
||||
// The Cloudflare provider does not support eth_blockNumber,
|
||||
// so we get the latest block and pull it from that
|
||||
if (method === "getBlockNumber") {
|
||||
@ -17889,7 +17974,7 @@ class CloudflareProvider extends UrlJsonRpcProvider {
|
||||
}
|
||||
|
||||
"use strict";
|
||||
var __awaiter$9 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
var __awaiter$a = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
@ -17989,17 +18074,22 @@ class EtherscanProvider extends BaseProvider {
|
||||
defineReadOnly(this, "baseUrl", baseUrl);
|
||||
defineReadOnly(this, "apiKey", apiKey || defaultApiKey$1);
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter$a(this, void 0, void 0, function* () {
|
||||
return this.network;
|
||||
});
|
||||
}
|
||||
perform(method, params) {
|
||||
const _super = Object.create(null, {
|
||||
perform: { get: () => super.perform }
|
||||
});
|
||||
return __awaiter$9(this, void 0, void 0, function* () {
|
||||
return __awaiter$a(this, void 0, void 0, function* () {
|
||||
let url = this.baseUrl;
|
||||
let apiKey = "";
|
||||
if (this.apiKey) {
|
||||
apiKey += "&apikey=" + this.apiKey;
|
||||
}
|
||||
const get = (url, procFunc) => __awaiter$9(this, void 0, void 0, function* () {
|
||||
const get = (url, procFunc) => __awaiter$a(this, void 0, void 0, function* () {
|
||||
this.emit("debug", {
|
||||
action: "request",
|
||||
request: url,
|
||||
@ -18212,7 +18302,7 @@ class EtherscanProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
"use strict";
|
||||
var __awaiter$a = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
var __awaiter$b = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
@ -18295,14 +18385,27 @@ function serialize$1(value) {
|
||||
// Next request ID to use for emitting debug info
|
||||
let nextRid = 1;
|
||||
;
|
||||
// Returns a promise that delays for duration
|
||||
function stall(duration) {
|
||||
return new Promise((resolve) => {
|
||||
const timer = setTimeout(resolve, duration);
|
||||
if (timer.unref) {
|
||||
timer.unref();
|
||||
let cancel = null;
|
||||
let timer = null;
|
||||
let promise = (new Promise((resolve) => {
|
||||
cancel = function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
};
|
||||
timer = setTimeout(cancel, duration);
|
||||
}));
|
||||
const wait = (func) => {
|
||||
promise = promise.then(func);
|
||||
return promise;
|
||||
};
|
||||
function getPromise() {
|
||||
return promise;
|
||||
}
|
||||
return { cancel, getPromise, wait };
|
||||
}
|
||||
;
|
||||
function exposeDebugConfig(config, now) {
|
||||
@ -18515,28 +18618,30 @@ class FallbackProvider extends BaseProvider {
|
||||
super(network);
|
||||
}
|
||||
else {
|
||||
// The network won't be known until all child providers know
|
||||
const ready = Promise.all(providerConfigs.map((c) => c.provider.getNetwork())).then((networks) => {
|
||||
return checkNetworks(networks);
|
||||
});
|
||||
super(ready);
|
||||
super(this.detectNetwork());
|
||||
}
|
||||
// Preserve a copy, so we do not get mutated
|
||||
defineReadOnly(this, "providerConfigs", Object.freeze(providerConfigs));
|
||||
defineReadOnly(this, "quorum", quorum);
|
||||
this._highestBlockNumber = -1;
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter$b(this, void 0, void 0, function* () {
|
||||
const networks = yield Promise.all(this.providerConfigs.map((c) => c.provider.getNetwork()));
|
||||
return checkNetworks(networks);
|
||||
});
|
||||
}
|
||||
perform(method, params) {
|
||||
return __awaiter$a(this, void 0, void 0, function* () {
|
||||
return __awaiter$b(this, void 0, void 0, function* () {
|
||||
// Sending transactions is special; always broadcast it to all backends
|
||||
if (method === "sendTransaction") {
|
||||
return Promise.all(this.providerConfigs.map((c) => {
|
||||
const results = yield Promise.all(this.providerConfigs.map((c) => {
|
||||
return c.provider.sendTransaction(params.signedTransaction).then((result) => {
|
||||
return result.hash;
|
||||
}, (error) => {
|
||||
return error;
|
||||
});
|
||||
})).then((results) => {
|
||||
}));
|
||||
// Any success is good enough (other errors are likely "already seen" errors
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const result = results[i];
|
||||
@ -18545,13 +18650,12 @@ class FallbackProvider extends BaseProvider {
|
||||
}
|
||||
}
|
||||
// They were all an error; pick the first error
|
||||
return Promise.reject(results[0]);
|
||||
});
|
||||
throw results[0];
|
||||
}
|
||||
const processFunc = getProcessFunc(this, method, params);
|
||||
// Shuffle the providers and then sort them by their priority; we
|
||||
// shallowCopy them since we will store the result in them too
|
||||
const configs = shuffled(this.providerConfigs.map((c) => shallowCopy(c)));
|
||||
const configs = shuffled(this.providerConfigs.map(shallowCopy));
|
||||
configs.sort((a, b) => (a.priority - b.priority));
|
||||
let i = 0;
|
||||
let first = true;
|
||||
@ -18567,7 +18671,8 @@ class FallbackProvider extends BaseProvider {
|
||||
const config = configs[i++];
|
||||
const rid = nextRid++;
|
||||
config.start = now();
|
||||
config.staller = stall(config.stallTimeout).then(() => { config.staller = null; });
|
||||
config.staller = stall(config.stallTimeout);
|
||||
config.staller.wait(() => { config.staller = null; });
|
||||
config.runner = getRunner(config.provider, method, params).then((result) => {
|
||||
config.done = true;
|
||||
config.result = result;
|
||||
@ -18593,7 +18698,6 @@ class FallbackProvider extends BaseProvider {
|
||||
});
|
||||
}
|
||||
});
|
||||
//running.push(config);
|
||||
if (this.listenerCount("debug")) {
|
||||
this.emit("debug", {
|
||||
action: "request",
|
||||
@ -18613,7 +18717,7 @@ class FallbackProvider extends BaseProvider {
|
||||
}
|
||||
waiting.push(c.runner);
|
||||
if (c.staller) {
|
||||
waiting.push(c.staller);
|
||||
waiting.push(c.staller.getPromise());
|
||||
}
|
||||
});
|
||||
if (waiting.length) {
|
||||
@ -18625,10 +18729,12 @@ class FallbackProvider extends BaseProvider {
|
||||
if (results.length >= this.quorum) {
|
||||
const result = processFunc(results);
|
||||
if (result !== undefined) {
|
||||
// Shut down any stallers
|
||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
||||
return result;
|
||||
}
|
||||
if (!first) {
|
||||
yield stall(100);
|
||||
yield stall(100).getPromise();
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
@ -18637,6 +18743,8 @@ class FallbackProvider extends BaseProvider {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Shut down any stallers; shouldn't be any
|
||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
||||
return logger$x.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
||||
method: method,
|
||||
params: params,
|
||||
@ -18656,204 +18764,6 @@ var browserIpcProvider = {
|
||||
IpcProvider: IpcProvider
|
||||
};
|
||||
|
||||
"use strict";
|
||||
const logger$y = new Logger(version$m);
|
||||
const defaultProjectId = "84842078b09946638c03157f83405213";
|
||||
class InfuraProvider extends UrlJsonRpcProvider {
|
||||
static getApiKey(apiKey) {
|
||||
const apiKeyObj = {
|
||||
apiKey: defaultProjectId,
|
||||
projectId: defaultProjectId,
|
||||
projectSecret: null
|
||||
};
|
||||
if (apiKey == null) {
|
||||
return apiKeyObj;
|
||||
}
|
||||
if (typeof (apiKey) === "string") {
|
||||
apiKeyObj.projectId = apiKey;
|
||||
}
|
||||
else if (apiKey.projectSecret != null) {
|
||||
if (typeof (apiKey.projectId) !== "string") {
|
||||
logger$y.throwArgumentError("projectSecret requires a projectId", "projectId", apiKey.projectId);
|
||||
}
|
||||
if (typeof (apiKey.projectSecret) !== "string") {
|
||||
logger$y.throwArgumentError("invalid projectSecret", "projectSecret", "[REDACTED]");
|
||||
}
|
||||
apiKeyObj.projectId = apiKey.projectId;
|
||||
apiKeyObj.projectSecret = apiKey.projectSecret;
|
||||
}
|
||||
else if (apiKey.projectId) {
|
||||
apiKeyObj.projectId = apiKey.projectId;
|
||||
}
|
||||
apiKeyObj.apiKey = apiKeyObj.projectId;
|
||||
return apiKeyObj;
|
||||
}
|
||||
static getUrl(network, apiKey) {
|
||||
let host = null;
|
||||
switch (network.name) {
|
||||
case "homestead":
|
||||
host = "mainnet.infura.io";
|
||||
break;
|
||||
case "ropsten":
|
||||
host = "ropsten.infura.io";
|
||||
break;
|
||||
case "rinkeby":
|
||||
host = "rinkeby.infura.io";
|
||||
break;
|
||||
case "kovan":
|
||||
host = "kovan.infura.io";
|
||||
break;
|
||||
case "goerli":
|
||||
host = "goerli.infura.io";
|
||||
break;
|
||||
default:
|
||||
logger$y.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, {
|
||||
argument: "network",
|
||||
value: network
|
||||
});
|
||||
}
|
||||
const connection = {
|
||||
url: ("https:/" + "/" + host + "/v3/" + apiKey.projectId)
|
||||
};
|
||||
if (apiKey.projectSecret != null) {
|
||||
connection.user = "";
|
||||
connection.password = apiKey.projectSecret;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$z = new Logger(version$m);
|
||||
// Special API key provided by Nodesmith for ethers.js
|
||||
const defaultApiKey$2 = "ETHERS_JS_SHARED";
|
||||
class NodesmithProvider extends UrlJsonRpcProvider {
|
||||
static getApiKey(apiKey) {
|
||||
if (apiKey && typeof (apiKey) !== "string") {
|
||||
logger$z.throwArgumentError("invalid apiKey", "apiKey", apiKey);
|
||||
}
|
||||
return apiKey || defaultApiKey$2;
|
||||
}
|
||||
static getUrl(network, apiKey) {
|
||||
logger$z.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
|
||||
let 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:
|
||||
logger$z.throwArgumentError("unsupported network", "network", arguments[0]);
|
||||
}
|
||||
return (host + "?apiKey=" + apiKey);
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$A = new Logger(version$m);
|
||||
let _nextId = 1;
|
||||
function buildWeb3LegacyFetcher(provider, sendFunc) {
|
||||
return function (method, params) {
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && provider.isMetaMask) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [params[1], params[0]];
|
||||
}
|
||||
const request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
sendFunc(request, function (error, result) {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
if (result.error) {
|
||||
const error = new Error(result.error.message);
|
||||
error.code = result.error.code;
|
||||
error.data = result.error.data;
|
||||
return reject(error);
|
||||
}
|
||||
resolve(result.result);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
function buildEip1193Fetcher(provider) {
|
||||
return function (method, params) {
|
||||
if (params == null) {
|
||||
params = [];
|
||||
}
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && provider.isMetaMask) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [params[1], params[0]];
|
||||
}
|
||||
return provider.request({ method, params });
|
||||
};
|
||||
}
|
||||
class Web3Provider extends JsonRpcProvider {
|
||||
constructor(provider, network) {
|
||||
logger$A.checkNew(new.target, Web3Provider);
|
||||
if (provider == null) {
|
||||
logger$A.throwArgumentError("missing provider", "provider", provider);
|
||||
}
|
||||
let path = null;
|
||||
let jsonRpcFetchFunc = null;
|
||||
let subprovider = null;
|
||||
if (typeof (provider) === "function") {
|
||||
path = "unknown:";
|
||||
jsonRpcFetchFunc = provider;
|
||||
}
|
||||
else {
|
||||
path = provider.host || provider.path || "";
|
||||
if (!path && provider.isMetaMask) {
|
||||
path = "metamask";
|
||||
}
|
||||
subprovider = provider;
|
||||
if (provider.request) {
|
||||
if (path === "") {
|
||||
path = "eip-1193:";
|
||||
}
|
||||
jsonRpcFetchFunc = buildEip1193Fetcher(provider);
|
||||
}
|
||||
else if (provider.sendAsync) {
|
||||
jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider));
|
||||
}
|
||||
else if (provider.send) {
|
||||
jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider));
|
||||
}
|
||||
else {
|
||||
logger$A.throwArgumentError("unsupported provider", "provider", provider);
|
||||
}
|
||||
if (!path) {
|
||||
path = "unknown:";
|
||||
}
|
||||
}
|
||||
super(path, network);
|
||||
defineReadOnly(this, "jsonRpcFetchFunc", jsonRpcFetchFunc);
|
||||
defineReadOnly(this, "provider", subprovider);
|
||||
}
|
||||
send(method, params) {
|
||||
return this.jsonRpcFetchFunc(method, params);
|
||||
}
|
||||
}
|
||||
|
||||
var _version$2 = createCommonjsModule(function (module, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@ -18889,7 +18799,7 @@ module.exports = WS;
|
||||
var WebSocket$1 = unwrapExports(browserWs);
|
||||
|
||||
"use strict";
|
||||
var __awaiter$b = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
var __awaiter$c = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
@ -18898,7 +18808,7 @@ var __awaiter$b = (window && window.__awaiter) || function (thisArg, _arguments,
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
const logger$B = new Logger(version$m);
|
||||
const logger$y = new Logger(version$m);
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
@ -18935,11 +18845,11 @@ class WebSocketProvider extends JsonRpcProvider {
|
||||
this._websocket.onmessage = (messageEvent) => {
|
||||
const data = messageEvent.data;
|
||||
const result = JSON.parse(data);
|
||||
if (result.id) {
|
||||
if (result.id != null) {
|
||||
const id = String(result.id);
|
||||
const request = this._requests[id];
|
||||
delete this._requests[id];
|
||||
if (result.result) {
|
||||
if (result.result !== undefined) {
|
||||
request.callback(null, result.result);
|
||||
}
|
||||
else {
|
||||
@ -18971,17 +18881,17 @@ class WebSocketProvider extends JsonRpcProvider {
|
||||
return 0;
|
||||
}
|
||||
resetEventsBlock(blockNumber) {
|
||||
logger$B.throwError("cannot reset events block on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
logger$y.throwError("cannot reset events block on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "resetEventBlock"
|
||||
});
|
||||
}
|
||||
set pollingInterval(value) {
|
||||
logger$B.throwError("cannot set polling interval on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
logger$y.throwError("cannot set polling interval on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setPollingInterval"
|
||||
});
|
||||
}
|
||||
poll() {
|
||||
return __awaiter$b(this, void 0, void 0, function* () {
|
||||
return __awaiter$c(this, void 0, void 0, function* () {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@ -18989,7 +18899,7 @@ class WebSocketProvider extends JsonRpcProvider {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
logger$B.throwError("cannot set polling on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
logger$y.throwError("cannot set polling on WebSocketProvider", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setPolling"
|
||||
});
|
||||
}
|
||||
@ -19018,7 +18928,7 @@ class WebSocketProvider extends JsonRpcProvider {
|
||||
return "ws:/\/localhost:8546";
|
||||
}
|
||||
_subscribe(tag, param, processFunc) {
|
||||
return __awaiter$b(this, void 0, void 0, function* () {
|
||||
return __awaiter$c(this, void 0, void 0, function* () {
|
||||
let subIdPromise = this._subIds[tag];
|
||||
if (subIdPromise == null) {
|
||||
subIdPromise = Promise.all(param).then((param) => {
|
||||
@ -19108,6 +19018,215 @@ class WebSocketProvider extends JsonRpcProvider {
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$z = new Logger(version$m);
|
||||
const defaultProjectId = "84842078b09946638c03157f83405213";
|
||||
class InfuraProvider extends UrlJsonRpcProvider {
|
||||
static getWebSocketProvider(network, apiKey) {
|
||||
const provider = new InfuraProvider(network, apiKey);
|
||||
const connection = provider.connection;
|
||||
if (connection.password) {
|
||||
logger$z.throwError("INFURA WebSocket project secrets unsupported", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "InfuraProvider.getWebSocketProvider()"
|
||||
});
|
||||
}
|
||||
const url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
||||
return new WebSocketProvider(url, network);
|
||||
}
|
||||
static getApiKey(apiKey) {
|
||||
const apiKeyObj = {
|
||||
apiKey: defaultProjectId,
|
||||
projectId: defaultProjectId,
|
||||
projectSecret: null
|
||||
};
|
||||
if (apiKey == null) {
|
||||
return apiKeyObj;
|
||||
}
|
||||
if (typeof (apiKey) === "string") {
|
||||
apiKeyObj.projectId = apiKey;
|
||||
}
|
||||
else if (apiKey.projectSecret != null) {
|
||||
if (typeof (apiKey.projectId) !== "string") {
|
||||
logger$z.throwArgumentError("projectSecret requires a projectId", "projectId", apiKey.projectId);
|
||||
}
|
||||
if (typeof (apiKey.projectSecret) !== "string") {
|
||||
logger$z.throwArgumentError("invalid projectSecret", "projectSecret", "[REDACTED]");
|
||||
}
|
||||
apiKeyObj.projectId = apiKey.projectId;
|
||||
apiKeyObj.projectSecret = apiKey.projectSecret;
|
||||
}
|
||||
else if (apiKey.projectId) {
|
||||
apiKeyObj.projectId = apiKey.projectId;
|
||||
}
|
||||
apiKeyObj.apiKey = apiKeyObj.projectId;
|
||||
return apiKeyObj;
|
||||
}
|
||||
static getUrl(network, apiKey) {
|
||||
let host = null;
|
||||
switch (network.name) {
|
||||
case "homestead":
|
||||
host = "mainnet.infura.io";
|
||||
break;
|
||||
case "ropsten":
|
||||
host = "ropsten.infura.io";
|
||||
break;
|
||||
case "rinkeby":
|
||||
host = "rinkeby.infura.io";
|
||||
break;
|
||||
case "kovan":
|
||||
host = "kovan.infura.io";
|
||||
break;
|
||||
case "goerli":
|
||||
host = "goerli.infura.io";
|
||||
break;
|
||||
default:
|
||||
logger$z.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, {
|
||||
argument: "network",
|
||||
value: network
|
||||
});
|
||||
}
|
||||
const connection = {
|
||||
url: ("https:/" + "/" + host + "/v3/" + apiKey.projectId)
|
||||
};
|
||||
if (apiKey.projectSecret != null) {
|
||||
connection.user = "";
|
||||
connection.password = apiKey.projectSecret;
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$A = new Logger(version$m);
|
||||
// Special API key provided by Nodesmith for ethers.js
|
||||
const defaultApiKey$2 = "ETHERS_JS_SHARED";
|
||||
class NodesmithProvider extends UrlJsonRpcProvider {
|
||||
static getApiKey(apiKey) {
|
||||
if (apiKey && typeof (apiKey) !== "string") {
|
||||
logger$A.throwArgumentError("invalid apiKey", "apiKey", apiKey);
|
||||
}
|
||||
return apiKey || defaultApiKey$2;
|
||||
}
|
||||
static getUrl(network, apiKey) {
|
||||
logger$A.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform.");
|
||||
let 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:
|
||||
logger$A.throwArgumentError("unsupported network", "network", arguments[0]);
|
||||
}
|
||||
return (host + "?apiKey=" + apiKey);
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$B = new Logger(version$m);
|
||||
let _nextId = 1;
|
||||
function buildWeb3LegacyFetcher(provider, sendFunc) {
|
||||
return function (method, params) {
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && provider.isMetaMask) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [params[1], params[0]];
|
||||
}
|
||||
const request = {
|
||||
method: method,
|
||||
params: params,
|
||||
id: (_nextId++),
|
||||
jsonrpc: "2.0"
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
sendFunc(request, function (error, result) {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
if (result.error) {
|
||||
const error = new Error(result.error.message);
|
||||
error.code = result.error.code;
|
||||
error.data = result.error.data;
|
||||
return reject(error);
|
||||
}
|
||||
resolve(result.result);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
function buildEip1193Fetcher(provider) {
|
||||
return function (method, params) {
|
||||
if (params == null) {
|
||||
params = [];
|
||||
}
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && provider.isMetaMask) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [params[1], params[0]];
|
||||
}
|
||||
return provider.request({ method, params });
|
||||
};
|
||||
}
|
||||
class Web3Provider extends JsonRpcProvider {
|
||||
constructor(provider, network) {
|
||||
logger$B.checkNew(new.target, Web3Provider);
|
||||
if (provider == null) {
|
||||
logger$B.throwArgumentError("missing provider", "provider", provider);
|
||||
}
|
||||
let path = null;
|
||||
let jsonRpcFetchFunc = null;
|
||||
let subprovider = null;
|
||||
if (typeof (provider) === "function") {
|
||||
path = "unknown:";
|
||||
jsonRpcFetchFunc = provider;
|
||||
}
|
||||
else {
|
||||
path = provider.host || provider.path || "";
|
||||
if (!path && provider.isMetaMask) {
|
||||
path = "metamask";
|
||||
}
|
||||
subprovider = provider;
|
||||
if (provider.request) {
|
||||
if (path === "") {
|
||||
path = "eip-1193:";
|
||||
}
|
||||
jsonRpcFetchFunc = buildEip1193Fetcher(provider);
|
||||
}
|
||||
else if (provider.sendAsync) {
|
||||
jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider));
|
||||
}
|
||||
else if (provider.send) {
|
||||
jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider));
|
||||
}
|
||||
else {
|
||||
logger$B.throwArgumentError("unsupported provider", "provider", provider);
|
||||
}
|
||||
if (!path) {
|
||||
path = "unknown:";
|
||||
}
|
||||
}
|
||||
super(path, network);
|
||||
defineReadOnly(this, "jsonRpcFetchFunc", jsonRpcFetchFunc);
|
||||
defineReadOnly(this, "provider", subprovider);
|
||||
}
|
||||
send(method, params) {
|
||||
return this.jsonRpcFetchFunc(method, params);
|
||||
}
|
||||
}
|
||||
|
||||
"use strict";
|
||||
const logger$C = new Logger(version$m);
|
||||
////////////////////////
|
||||
|
4
packages/ethers/dist/ethers.esm.min.js
vendored
4
packages/ethers/dist/ethers.esm.min.js
vendored
File diff suppressed because one or more lines are too long
1090
packages/ethers/dist/ethers.umd.js
vendored
1090
packages/ethers/dist/ethers.umd.js
vendored
File diff suppressed because it is too large
Load Diff
4
packages/ethers/dist/ethers.umd.min.js
vendored
4
packages/ethers/dist/ethers.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -52,7 +52,7 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0xe9daa152b8c9f669a2a20427db554a49d87d64060a3851a5ace3bdcab47e3173",
|
||||
"tarballHash": "0x1c30ae49addbeee1a530704a69d38cd067932db413c4643b38409be32c7c04e1",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.185"
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ export declare class Event {
|
||||
pollable(): boolean;
|
||||
}
|
||||
export declare class BaseProvider extends Provider {
|
||||
_networkPromise: Promise<Network>;
|
||||
_network: Network;
|
||||
_events: Array<Event>;
|
||||
formatter: Formatter;
|
||||
@ -52,8 +53,10 @@ export declare class BaseProvider extends Provider {
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
ready: Promise<Network>;
|
||||
constructor(network: Networkish | Promise<Network>);
|
||||
_ready(): Promise<Network>;
|
||||
get ready(): Promise<Network>;
|
||||
detectNetwork(): Promise<Network>;
|
||||
static getFormatter(): Formatter;
|
||||
static getNetwork(network: Networkish): Network;
|
||||
_getInternalBlockNumber(maxAge: number): Promise<number>;
|
||||
|
@ -154,23 +154,28 @@ export class Event {
|
||||
let defaultFormatter = null;
|
||||
let nextPollId = 1;
|
||||
export class BaseProvider extends Provider {
|
||||
/**
|
||||
* ready
|
||||
*
|
||||
* A Promise<Network> that resolves only once the provider is ready.
|
||||
*
|
||||
* Sub-classes that call the super with a network without a chainId
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
constructor(network) {
|
||||
logger.checkNew(new.target, Provider);
|
||||
super();
|
||||
this.formatter = new.target.getFormatter();
|
||||
if (network instanceof Promise) {
|
||||
defineReadOnly(this, "ready", network.then((network) => {
|
||||
defineReadOnly(this, "_network", network);
|
||||
return network;
|
||||
}));
|
||||
this._networkPromise = network;
|
||||
// Squash any "unhandled promise" errors; that do not need to be handled
|
||||
this.ready.catch((error) => { });
|
||||
network.catch((error) => { });
|
||||
}
|
||||
else {
|
||||
const knownNetwork = getStatic((new.target), "getNetwork")(network);
|
||||
if (knownNetwork) {
|
||||
defineReadOnly(this, "_network", knownNetwork);
|
||||
defineReadOnly(this, "ready", Promise.resolve(this._network));
|
||||
}
|
||||
else {
|
||||
logger.throwArgumentError("invalid network", "network", network);
|
||||
@ -184,6 +189,40 @@ export class BaseProvider extends Provider {
|
||||
this._emitted = { block: -2 };
|
||||
this._fastQueryDate = 0;
|
||||
}
|
||||
_ready() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this._network == null) {
|
||||
let network = null;
|
||||
if (this._networkPromise) {
|
||||
try {
|
||||
network = yield this._networkPromise;
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
// Try the Provider's network detection (this MUST throw if it cannot)
|
||||
if (network == null) {
|
||||
network = yield this.detectNetwork();
|
||||
}
|
||||
// This should never happen; every Provider sub-class should have
|
||||
// suggested a network by here (or thrown).
|
||||
if (!network) {
|
||||
logger.throwError("no network detected", Logger.errors.UNKNOWN_ERROR, {});
|
||||
}
|
||||
defineReadOnly(this, "_network", network);
|
||||
}
|
||||
return this._network;
|
||||
});
|
||||
}
|
||||
get ready() {
|
||||
return this._ready();
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return logger.throwError("provider does not support network detection", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "provider.detectNetwork"
|
||||
});
|
||||
});
|
||||
}
|
||||
static getFormatter() {
|
||||
if (defaultFormatter == null) {
|
||||
defaultFormatter = new Formatter();
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { BlockTag, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { Networkish } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { BaseProvider } from "./base-provider";
|
||||
export declare class EtherscanProvider extends BaseProvider {
|
||||
readonly baseUrl: string;
|
||||
readonly apiKey: string;
|
||||
constructor(network?: Networkish, apiKey?: string);
|
||||
detectNetwork(): Promise<Network>;
|
||||
perform(method: string, params: any): Promise<any>;
|
||||
getHistory(addressOrName: string | Promise<string>, startBlock?: BlockTag, endBlock?: BlockTag): Promise<Array<TransactionResponse>>;
|
||||
}
|
||||
|
@ -105,6 +105,11 @@ export class EtherscanProvider extends BaseProvider {
|
||||
defineReadOnly(this, "baseUrl", baseUrl);
|
||||
defineReadOnly(this, "apiKey", apiKey || defaultApiKey);
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.network;
|
||||
});
|
||||
}
|
||||
perform(method, params) {
|
||||
const _super = Object.create(null, {
|
||||
perform: { get: () => super.perform }
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Network } from "@ethersproject/networks";
|
||||
import { Provider } from "@ethersproject/abstract-provider";
|
||||
import { BaseProvider } from "./base-provider";
|
||||
export interface FallbackProviderConfig {
|
||||
@ -11,6 +12,7 @@ export declare class FallbackProvider extends BaseProvider {
|
||||
readonly quorum: number;
|
||||
_highestBlockNumber: number;
|
||||
constructor(providers: Array<Provider | FallbackProviderConfig>, quorum?: number);
|
||||
detectNetwork(): Promise<Network>;
|
||||
perform(method: string, params: {
|
||||
[name: string]: any;
|
||||
}): Promise<any>;
|
||||
|
@ -89,14 +89,27 @@ function serialize(value) {
|
||||
// Next request ID to use for emitting debug info
|
||||
let nextRid = 1;
|
||||
;
|
||||
// Returns a promise that delays for duration
|
||||
function stall(duration) {
|
||||
return new Promise((resolve) => {
|
||||
const timer = setTimeout(resolve, duration);
|
||||
if (timer.unref) {
|
||||
timer.unref();
|
||||
let cancel = null;
|
||||
let timer = null;
|
||||
let promise = (new Promise((resolve) => {
|
||||
cancel = function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
};
|
||||
timer = setTimeout(cancel, duration);
|
||||
}));
|
||||
const wait = (func) => {
|
||||
promise = promise.then(func);
|
||||
return promise;
|
||||
};
|
||||
function getPromise() {
|
||||
return promise;
|
||||
}
|
||||
return { cancel, getPromise, wait };
|
||||
}
|
||||
;
|
||||
function exposeDebugConfig(config, now) {
|
||||
@ -309,28 +322,30 @@ export class FallbackProvider extends BaseProvider {
|
||||
super(network);
|
||||
}
|
||||
else {
|
||||
// The network won't be known until all child providers know
|
||||
const ready = Promise.all(providerConfigs.map((c) => c.provider.getNetwork())).then((networks) => {
|
||||
return checkNetworks(networks);
|
||||
});
|
||||
super(ready);
|
||||
super(this.detectNetwork());
|
||||
}
|
||||
// Preserve a copy, so we do not get mutated
|
||||
defineReadOnly(this, "providerConfigs", Object.freeze(providerConfigs));
|
||||
defineReadOnly(this, "quorum", quorum);
|
||||
this._highestBlockNumber = -1;
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const networks = yield Promise.all(this.providerConfigs.map((c) => c.provider.getNetwork()));
|
||||
return checkNetworks(networks);
|
||||
});
|
||||
}
|
||||
perform(method, params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Sending transactions is special; always broadcast it to all backends
|
||||
if (method === "sendTransaction") {
|
||||
return Promise.all(this.providerConfigs.map((c) => {
|
||||
const results = yield Promise.all(this.providerConfigs.map((c) => {
|
||||
return c.provider.sendTransaction(params.signedTransaction).then((result) => {
|
||||
return result.hash;
|
||||
}, (error) => {
|
||||
return error;
|
||||
});
|
||||
})).then((results) => {
|
||||
}));
|
||||
// Any success is good enough (other errors are likely "already seen" errors
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const result = results[i];
|
||||
@ -339,13 +354,12 @@ export class FallbackProvider extends BaseProvider {
|
||||
}
|
||||
}
|
||||
// They were all an error; pick the first error
|
||||
return Promise.reject(results[0]);
|
||||
});
|
||||
throw results[0];
|
||||
}
|
||||
const processFunc = getProcessFunc(this, method, params);
|
||||
// Shuffle the providers and then sort them by their priority; we
|
||||
// shallowCopy them since we will store the result in them too
|
||||
const configs = shuffled(this.providerConfigs.map((c) => shallowCopy(c)));
|
||||
const configs = shuffled(this.providerConfigs.map(shallowCopy));
|
||||
configs.sort((a, b) => (a.priority - b.priority));
|
||||
let i = 0;
|
||||
let first = true;
|
||||
@ -361,7 +375,8 @@ export class FallbackProvider extends BaseProvider {
|
||||
const config = configs[i++];
|
||||
const rid = nextRid++;
|
||||
config.start = now();
|
||||
config.staller = stall(config.stallTimeout).then(() => { config.staller = null; });
|
||||
config.staller = stall(config.stallTimeout);
|
||||
config.staller.wait(() => { config.staller = null; });
|
||||
config.runner = getRunner(config.provider, method, params).then((result) => {
|
||||
config.done = true;
|
||||
config.result = result;
|
||||
@ -387,7 +402,6 @@ export class FallbackProvider extends BaseProvider {
|
||||
});
|
||||
}
|
||||
});
|
||||
//running.push(config);
|
||||
if (this.listenerCount("debug")) {
|
||||
this.emit("debug", {
|
||||
action: "request",
|
||||
@ -407,7 +421,7 @@ export class FallbackProvider extends BaseProvider {
|
||||
}
|
||||
waiting.push(c.runner);
|
||||
if (c.staller) {
|
||||
waiting.push(c.staller);
|
||||
waiting.push(c.staller.getPromise());
|
||||
}
|
||||
});
|
||||
if (waiting.length) {
|
||||
@ -419,10 +433,12 @@ export class FallbackProvider extends BaseProvider {
|
||||
if (results.length >= this.quorum) {
|
||||
const result = processFunc(results);
|
||||
if (result !== undefined) {
|
||||
// Shut down any stallers
|
||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
||||
return result;
|
||||
}
|
||||
if (!first) {
|
||||
yield stall(100);
|
||||
yield stall(100).getPromise();
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
@ -431,6 +447,8 @@ export class FallbackProvider extends BaseProvider {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Shut down any stallers; shouldn't be any
|
||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
||||
return logger.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
||||
method: method,
|
||||
params: params,
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { Network } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { ConnectionInfo } from "@ethersproject/web";
|
||||
import { WebSocketProvider } from "./websocket-provider";
|
||||
import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
|
||||
export declare class InfuraProvider extends UrlJsonRpcProvider {
|
||||
readonly projectId: string;
|
||||
readonly projectSecret: string;
|
||||
static getWebSocketProvider(network: Networkish, apiKey: any): WebSocketProvider;
|
||||
static getApiKey(apiKey: any): any;
|
||||
static getUrl(network: Network, apiKey: any): string | ConnectionInfo;
|
||||
}
|
||||
|
@ -1,10 +1,22 @@
|
||||
"use strict";
|
||||
import { WebSocketProvider } from "./websocket-provider";
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
const logger = new Logger(version);
|
||||
import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
|
||||
const defaultProjectId = "84842078b09946638c03157f83405213";
|
||||
export class InfuraProvider extends UrlJsonRpcProvider {
|
||||
static getWebSocketProvider(network, apiKey) {
|
||||
const provider = new InfuraProvider(network, apiKey);
|
||||
const connection = provider.connection;
|
||||
if (connection.password) {
|
||||
logger.throwError("INFURA WebSocket project secrets unsupported", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "InfuraProvider.getWebSocketProvider()"
|
||||
});
|
||||
}
|
||||
const url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
||||
return new WebSocketProvider(url, network);
|
||||
}
|
||||
static getApiKey(apiKey) {
|
||||
const apiKeyObj = {
|
||||
apiKey: defaultProjectId,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { Signer } from "@ethersproject/abstract-signer";
|
||||
import { Bytes } from "@ethersproject/bytes";
|
||||
import { Networkish } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { ConnectionInfo } from "@ethersproject/web";
|
||||
import { BaseProvider, Event } from "./base-provider";
|
||||
export declare class JsonRpcSigner extends Signer {
|
||||
@ -27,6 +27,7 @@ export declare class JsonRpcProvider extends BaseProvider {
|
||||
_nextId: number;
|
||||
constructor(url?: ConnectionInfo | string, network?: Networkish);
|
||||
static defaultUrl(): string;
|
||||
detectNetwork(): Promise<Network>;
|
||||
getSigner(addressOrIndex?: string | number): JsonRpcSigner;
|
||||
getUncheckedSigner(addressOrIndex?: string | number): UncheckedJsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
|
@ -20,9 +20,7 @@ const logger = new Logger(version);
|
||||
import { BaseProvider } from "./base-provider";
|
||||
function timer(timeout) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
}, timeout);
|
||||
setTimeout(resolve, timeout);
|
||||
});
|
||||
}
|
||||
function getResult(payload) {
|
||||
@ -207,28 +205,7 @@ export class JsonRpcProvider extends BaseProvider {
|
||||
}
|
||||
else {
|
||||
// The network is unknown, query the JSON-RPC for it
|
||||
const ready = new Promise((resolve, reject) => {
|
||||
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
||||
let chainId = null;
|
||||
try {
|
||||
chainId = yield this.send("eth_chainId", []);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
chainId = yield this.send("net_version", []);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (chainId != null) {
|
||||
try {
|
||||
return resolve(getNetwork(BigNumber.from(chainId).toNumber()));
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
reject(logger.makeError("could not detect network", Logger.errors.NETWORK_ERROR));
|
||||
}), 0);
|
||||
});
|
||||
super(ready);
|
||||
super(this.detectNetwork());
|
||||
}
|
||||
// Default URL
|
||||
if (!url) {
|
||||
@ -247,6 +224,34 @@ export class JsonRpcProvider extends BaseProvider {
|
||||
static defaultUrl() {
|
||||
return "http:/\/localhost:8545";
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield timer(0);
|
||||
let chainId = null;
|
||||
try {
|
||||
chainId = yield this.send("eth_chainId", []);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
chainId = yield this.send("net_version", []);
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
if (chainId != null) {
|
||||
const getNetwork = getStatic(this.constructor, "getNetwork");
|
||||
try {
|
||||
return getNetwork(BigNumber.from(chainId).toNumber());
|
||||
}
|
||||
catch (error) {
|
||||
return logger.throwError("could not detect network", Logger.errors.NETWORK_ERROR, {
|
||||
chainId: chainId,
|
||||
serverError: error
|
||||
});
|
||||
}
|
||||
}
|
||||
return logger.throwError("could not detect network", Logger.errors.NETWORK_ERROR);
|
||||
});
|
||||
}
|
||||
getSigner(addressOrIndex) {
|
||||
return new JsonRpcSigner(_constructorGuard, this, addressOrIndex);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider";
|
||||
export declare abstract class UrlJsonRpcProvider extends JsonRpcProvider {
|
||||
readonly apiKey: any;
|
||||
constructor(network?: Networkish, apiKey?: any);
|
||||
detectNetwork(): Promise<Network>;
|
||||
_startPending(): void;
|
||||
getSigner(address?: string): JsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
|
@ -1,4 +1,13 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
import { defineReadOnly, getStatic } from "@ethersproject/properties";
|
||||
import { Logger } from "@ethersproject/logger";
|
||||
import { version } from "./_version";
|
||||
@ -21,6 +30,11 @@ export class UrlJsonRpcProvider extends JsonRpcProvider {
|
||||
});
|
||||
}
|
||||
}
|
||||
detectNetwork() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.network;
|
||||
});
|
||||
}
|
||||
_startPending() {
|
||||
logger.warn("WARNING: API provider does not support pending filters");
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ export class WebSocketProvider extends JsonRpcProvider {
|
||||
this._websocket.onmessage = (messageEvent) => {
|
||||
const data = messageEvent.data;
|
||||
const result = JSON.parse(data);
|
||||
if (result.id) {
|
||||
if (result.id != null) {
|
||||
const id = String(result.id);
|
||||
const request = this._requests[id];
|
||||
delete this._requests[id];
|
||||
if (result.result) {
|
||||
if (result.result !== undefined) {
|
||||
request.callback(null, result.result);
|
||||
}
|
||||
else {
|
||||
|
5
packages/providers/lib/base-provider.d.ts
vendored
5
packages/providers/lib/base-provider.d.ts
vendored
@ -25,6 +25,7 @@ export declare class Event {
|
||||
pollable(): boolean;
|
||||
}
|
||||
export declare class BaseProvider extends Provider {
|
||||
_networkPromise: Promise<Network>;
|
||||
_network: Network;
|
||||
_events: Array<Event>;
|
||||
formatter: Formatter;
|
||||
@ -52,8 +53,10 @@ export declare class BaseProvider extends Provider {
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
ready: Promise<Network>;
|
||||
constructor(network: Networkish | Promise<Network>);
|
||||
_ready(): Promise<Network>;
|
||||
get ready(): Promise<Network>;
|
||||
detectNetwork(): Promise<Network>;
|
||||
static getFormatter(): Formatter;
|
||||
static getNetwork(network: Networkish): Network;
|
||||
_getInternalBlockNumber(maxAge: number): Promise<number>;
|
||||
|
@ -214,6 +214,15 @@ var defaultFormatter = null;
|
||||
var nextPollId = 1;
|
||||
var BaseProvider = /** @class */ (function (_super) {
|
||||
__extends(BaseProvider, _super);
|
||||
/**
|
||||
* ready
|
||||
*
|
||||
* A Promise<Network> that resolves only once the provider is ready.
|
||||
*
|
||||
* Sub-classes that call the super with a network without a chainId
|
||||
* MUST set this. Standard named networks have a known chainId.
|
||||
*
|
||||
*/
|
||||
function BaseProvider(network) {
|
||||
var _newTarget = this.constructor;
|
||||
var _this = this;
|
||||
@ -221,18 +230,14 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
_this = _super.call(this) || this;
|
||||
_this.formatter = _newTarget.getFormatter();
|
||||
if (network instanceof Promise) {
|
||||
properties_1.defineReadOnly(_this, "ready", network.then(function (network) {
|
||||
properties_1.defineReadOnly(_this, "_network", network);
|
||||
return network;
|
||||
}));
|
||||
_this._networkPromise = network;
|
||||
// Squash any "unhandled promise" errors; that do not need to be handled
|
||||
_this.ready.catch(function (error) { });
|
||||
network.catch(function (error) { });
|
||||
}
|
||||
else {
|
||||
var knownNetwork = properties_1.getStatic((_newTarget), "getNetwork")(network);
|
||||
if (knownNetwork) {
|
||||
properties_1.defineReadOnly(_this, "_network", knownNetwork);
|
||||
properties_1.defineReadOnly(_this, "ready", Promise.resolve(_this._network));
|
||||
}
|
||||
else {
|
||||
logger.throwArgumentError("invalid network", "network", network);
|
||||
@ -247,6 +252,60 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
_this._fastQueryDate = 0;
|
||||
return _this;
|
||||
}
|
||||
BaseProvider.prototype._ready = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var network, error_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!(this._network == null)) return [3 /*break*/, 7];
|
||||
network = null;
|
||||
if (!this._networkPromise) return [3 /*break*/, 4];
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this._networkPromise];
|
||||
case 2:
|
||||
network = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
error_1 = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
if (!(network == null)) return [3 /*break*/, 6];
|
||||
return [4 /*yield*/, this.detectNetwork()];
|
||||
case 5:
|
||||
network = _a.sent();
|
||||
_a.label = 6;
|
||||
case 6:
|
||||
// This should never happen; every Provider sub-class should have
|
||||
// suggested a network by here (or thrown).
|
||||
if (!network) {
|
||||
logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
|
||||
}
|
||||
properties_1.defineReadOnly(this, "_network", network);
|
||||
_a.label = 7;
|
||||
case 7: return [2 /*return*/, this._network];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Object.defineProperty(BaseProvider.prototype, "ready", {
|
||||
get: function () {
|
||||
return this._ready();
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
BaseProvider.prototype.detectNetwork = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, logger.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "provider.detectNetwork"
|
||||
})];
|
||||
});
|
||||
});
|
||||
};
|
||||
BaseProvider.getFormatter = function () {
|
||||
if (defaultFormatter == null) {
|
||||
defaultFormatter = new formatter_1.Formatter();
|
||||
@ -684,7 +743,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
};
|
||||
BaseProvider.prototype.sendTransaction = function (signedTransaction) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var hexTx, tx, hash, error_1;
|
||||
var hexTx, tx, hash, error_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this.ready];
|
||||
@ -702,10 +761,10 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
hash = _a.sent();
|
||||
return [2 /*return*/, this._wrapTransaction(tx, hash)];
|
||||
case 5:
|
||||
error_1 = _a.sent();
|
||||
error_1.transaction = tx;
|
||||
error_1.transactionHash = tx.hash;
|
||||
throw error_1;
|
||||
error_2 = _a.sent();
|
||||
error_2.transaction = tx;
|
||||
error_2.transactionHash = tx.hash;
|
||||
throw error_2;
|
||||
case 6: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
@ -843,7 +902,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
};
|
||||
BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var blockNumber, params, _a, _b, _c, error_2;
|
||||
var blockNumber, params, _a, _b, _c, error_3;
|
||||
var _this = this;
|
||||
return __generator(this, function (_d) {
|
||||
switch (_d.label) {
|
||||
@ -875,7 +934,7 @@ var BaseProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
return [3 /*break*/, 7];
|
||||
case 6:
|
||||
error_2 = _d.sent();
|
||||
error_3 = _d.sent();
|
||||
logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag);
|
||||
return [3 /*break*/, 7];
|
||||
case 7: return [2 /*return*/, web_1.poll(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { BlockTag, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { Networkish } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { BaseProvider } from "./base-provider";
|
||||
export declare class EtherscanProvider extends BaseProvider {
|
||||
readonly baseUrl: string;
|
||||
readonly apiKey: string;
|
||||
constructor(network?: Networkish, apiKey?: string);
|
||||
detectNetwork(): Promise<Network>;
|
||||
perform(method: string, params: any): Promise<any>;
|
||||
getHistory(addressOrName: string | Promise<string>, startBlock?: BlockTag, endBlock?: BlockTag): Promise<Array<TransactionResponse>>;
|
||||
}
|
||||
|
@ -150,6 +150,13 @@ var EtherscanProvider = /** @class */ (function (_super) {
|
||||
properties_1.defineReadOnly(_this, "apiKey", apiKey || defaultApiKey);
|
||||
return _this;
|
||||
}
|
||||
EtherscanProvider.prototype.detectNetwork = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, this.network];
|
||||
});
|
||||
});
|
||||
};
|
||||
EtherscanProvider.prototype.perform = function (method, params) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, apiKey, get, _a, transaction, transaction, topic0, logs, txs, i, log, tx, _b;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Network } from "@ethersproject/networks";
|
||||
import { Provider } from "@ethersproject/abstract-provider";
|
||||
import { BaseProvider } from "./base-provider";
|
||||
export interface FallbackProviderConfig {
|
||||
@ -11,6 +12,7 @@ export declare class FallbackProvider extends BaseProvider {
|
||||
readonly quorum: number;
|
||||
_highestBlockNumber: number;
|
||||
constructor(providers: Array<Provider | FallbackProviderConfig>, quorum?: number);
|
||||
detectNetwork(): Promise<Network>;
|
||||
perform(method: string, params: {
|
||||
[name: string]: any;
|
||||
}): Promise<any>;
|
||||
|
@ -130,14 +130,27 @@ function serialize(value) {
|
||||
// Next request ID to use for emitting debug info
|
||||
var nextRid = 1;
|
||||
;
|
||||
// Returns a promise that delays for duration
|
||||
function stall(duration) {
|
||||
return new Promise(function (resolve) {
|
||||
var timer = setTimeout(resolve, duration);
|
||||
if (timer.unref) {
|
||||
timer.unref();
|
||||
var cancel = null;
|
||||
var timer = null;
|
||||
var promise = (new Promise(function (resolve) {
|
||||
cancel = function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
};
|
||||
timer = setTimeout(cancel, duration);
|
||||
}));
|
||||
var wait = function (func) {
|
||||
promise = promise.then(func);
|
||||
return promise;
|
||||
};
|
||||
function getPromise() {
|
||||
return promise;
|
||||
}
|
||||
return { cancel: cancel, getPromise: getPromise, wait: wait };
|
||||
}
|
||||
;
|
||||
function exposeDebugConfig(config, now) {
|
||||
@ -353,11 +366,7 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
_this = _super.call(this, network) || this;
|
||||
}
|
||||
else {
|
||||
// The network won't be known until all child providers know
|
||||
var ready = Promise.all(providerConfigs.map(function (c) { return c.provider.getNetwork(); })).then(function (networks) {
|
||||
return checkNetworks(networks);
|
||||
});
|
||||
_this = _super.call(this, ready) || this;
|
||||
_this = _super.call(this, _this.detectNetwork()) || this;
|
||||
}
|
||||
// Preserve a copy, so we do not get mutated
|
||||
properties_1.defineReadOnly(_this, "providerConfigs", Object.freeze(providerConfigs));
|
||||
@ -365,35 +374,48 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
_this._highestBlockNumber = -1;
|
||||
return _this;
|
||||
}
|
||||
FallbackProvider.prototype.detectNetwork = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var networks;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) { return c.provider.getNetwork(); }))];
|
||||
case 1:
|
||||
networks = _a.sent();
|
||||
return [2 /*return*/, checkNetworks(networks)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
FallbackProvider.prototype.perform = function (method, params) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var processFunc, configs, i, first, _loop_1, this_1, state_1;
|
||||
var results, i_1, result, processFunc, configs, i, first, _loop_1, this_1, state_1;
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
// Sending transactions is special; always broadcast it to all backends
|
||||
if (method === "sendTransaction") {
|
||||
return [2 /*return*/, Promise.all(this.providerConfigs.map(function (c) {
|
||||
if (!(method === "sendTransaction")) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, Promise.all(this.providerConfigs.map(function (c) {
|
||||
return c.provider.sendTransaction(params.signedTransaction).then(function (result) {
|
||||
return result.hash;
|
||||
}, function (error) {
|
||||
return error;
|
||||
});
|
||||
})).then(function (results) {
|
||||
}))];
|
||||
case 1:
|
||||
results = _a.sent();
|
||||
// Any success is good enough (other errors are likely "already seen" errors
|
||||
for (var i_1 = 0; i_1 < results.length; i_1++) {
|
||||
var result = results[i_1];
|
||||
for (i_1 = 0; i_1 < results.length; i_1++) {
|
||||
result = results[i_1];
|
||||
if (typeof (result) === "string") {
|
||||
return result;
|
||||
return [2 /*return*/, result];
|
||||
}
|
||||
}
|
||||
// They were all an error; pick the first error
|
||||
return Promise.reject(results[0]);
|
||||
})];
|
||||
}
|
||||
throw results[0];
|
||||
case 2:
|
||||
processFunc = getProcessFunc(this, method, params);
|
||||
configs = random_1.shuffled(this.providerConfigs.map(function (c) { return properties_1.shallowCopy(c); }));
|
||||
configs = random_1.shuffled(this.providerConfigs.map(properties_1.shallowCopy));
|
||||
configs.sort(function (a, b) { return (a.priority - b.priority); });
|
||||
i = 0;
|
||||
first = true;
|
||||
@ -409,7 +431,8 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
var config = configs[i++];
|
||||
var rid = nextRid++;
|
||||
config.start = now();
|
||||
config.staller = stall(config.stallTimeout).then(function () { config.staller = null; });
|
||||
config.staller = stall(config.stallTimeout);
|
||||
config.staller.wait(function () { config.staller = null; });
|
||||
config.runner = getRunner(config.provider, method, params).then(function (result) {
|
||||
config.done = true;
|
||||
config.result = result;
|
||||
@ -435,7 +458,6 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
});
|
||||
}
|
||||
});
|
||||
//running.push(config);
|
||||
if (this_1.listenerCount("debug")) {
|
||||
this_1.emit("debug", {
|
||||
action: "request",
|
||||
@ -458,7 +480,7 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
waiting.push(c.runner);
|
||||
if (c.staller) {
|
||||
waiting.push(c.staller);
|
||||
waiting.push(c.staller.getPromise());
|
||||
}
|
||||
});
|
||||
if (!waiting.length) return [3 /*break*/, 2];
|
||||
@ -471,10 +493,12 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
if (!(results.length >= this_1.quorum)) return [3 /*break*/, 5];
|
||||
result = processFunc(results);
|
||||
if (result !== undefined) {
|
||||
// Shut down any stallers
|
||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
||||
return [2 /*return*/, { value: result }];
|
||||
}
|
||||
if (!!first) return [3 /*break*/, 4];
|
||||
return [4 /*yield*/, stall(100)];
|
||||
return [4 /*yield*/, stall(100).getPromise()];
|
||||
case 3:
|
||||
_a.sent();
|
||||
_a.label = 4;
|
||||
@ -491,18 +515,21 @@ var FallbackProvider = /** @class */ (function (_super) {
|
||||
});
|
||||
};
|
||||
this_1 = this;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
if (!true) return [3 /*break*/, 3];
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
if (!true) return [3 /*break*/, 5];
|
||||
return [5 /*yield**/, _loop_1()];
|
||||
case 2:
|
||||
case 4:
|
||||
state_1 = _a.sent();
|
||||
if (typeof state_1 === "object")
|
||||
return [2 /*return*/, state_1.value];
|
||||
if (state_1 === "break")
|
||||
return [3 /*break*/, 5];
|
||||
return [3 /*break*/, 3];
|
||||
return [3 /*break*/, 1];
|
||||
case 3: return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
|
||||
case 5:
|
||||
// Shut down any stallers; shouldn't be any
|
||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
||||
return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
|
||||
method: method,
|
||||
params: params,
|
||||
//results: configs.map((c) => c.result),
|
||||
|
4
packages/providers/lib/infura-provider.d.ts
vendored
4
packages/providers/lib/infura-provider.d.ts
vendored
@ -1,9 +1,11 @@
|
||||
import { Network } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { ConnectionInfo } from "@ethersproject/web";
|
||||
import { WebSocketProvider } from "./websocket-provider";
|
||||
import { UrlJsonRpcProvider } from "./url-json-rpc-provider";
|
||||
export declare class InfuraProvider extends UrlJsonRpcProvider {
|
||||
readonly projectId: string;
|
||||
readonly projectSecret: string;
|
||||
static getWebSocketProvider(network: Networkish, apiKey: any): WebSocketProvider;
|
||||
static getApiKey(apiKey: any): any;
|
||||
static getUrl(network: Network, apiKey: any): string | ConnectionInfo;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var websocket_provider_1 = require("./websocket-provider");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
var _version_1 = require("./_version");
|
||||
var logger = new logger_1.Logger(_version_1.version);
|
||||
@ -23,6 +24,17 @@ var InfuraProvider = /** @class */ (function (_super) {
|
||||
function InfuraProvider() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
InfuraProvider.getWebSocketProvider = function (network, apiKey) {
|
||||
var provider = new InfuraProvider(network, apiKey);
|
||||
var connection = provider.connection;
|
||||
if (connection.password) {
|
||||
logger.throwError("INFURA WebSocket project secrets unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "InfuraProvider.getWebSocketProvider()"
|
||||
});
|
||||
}
|
||||
var url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
||||
return new websocket_provider_1.WebSocketProvider(url, network);
|
||||
};
|
||||
InfuraProvider.getApiKey = function (apiKey) {
|
||||
var apiKeyObj = {
|
||||
apiKey: defaultProjectId,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider";
|
||||
import { Signer } from "@ethersproject/abstract-signer";
|
||||
import { Bytes } from "@ethersproject/bytes";
|
||||
import { Networkish } from "@ethersproject/networks";
|
||||
import { Network, Networkish } from "@ethersproject/networks";
|
||||
import { ConnectionInfo } from "@ethersproject/web";
|
||||
import { BaseProvider, Event } from "./base-provider";
|
||||
export declare class JsonRpcSigner extends Signer {
|
||||
@ -27,6 +27,7 @@ export declare class JsonRpcProvider extends BaseProvider {
|
||||
_nextId: number;
|
||||
constructor(url?: ConnectionInfo | string, network?: Networkish);
|
||||
static defaultUrl(): string;
|
||||
detectNetwork(): Promise<Network>;
|
||||
getSigner(addressOrIndex?: string | number): JsonRpcSigner;
|
||||
getUncheckedSigner(addressOrIndex?: string | number): UncheckedJsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
|
@ -61,9 +61,7 @@ var logger = new logger_1.Logger(_version_1.version);
|
||||
var base_provider_1 = require("./base-provider");
|
||||
function timer(timeout) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
}, timeout);
|
||||
setTimeout(resolve, timeout);
|
||||
});
|
||||
}
|
||||
function getResult(payload) {
|
||||
@ -267,47 +265,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
else {
|
||||
// The network is unknown, query the JSON-RPC for it
|
||||
var ready = new Promise(function (resolve, reject) {
|
||||
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var chainId, error_1, error_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
chainId = null;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 8]);
|
||||
return [4 /*yield*/, this.send("eth_chainId", [])];
|
||||
case 2:
|
||||
chainId = _a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 3:
|
||||
error_1 = _a.sent();
|
||||
_a.label = 4;
|
||||
case 4:
|
||||
_a.trys.push([4, 6, , 7]);
|
||||
return [4 /*yield*/, this.send("net_version", [])];
|
||||
case 5:
|
||||
chainId = _a.sent();
|
||||
return [3 /*break*/, 7];
|
||||
case 6:
|
||||
error_2 = _a.sent();
|
||||
return [3 /*break*/, 7];
|
||||
case 7: return [3 /*break*/, 8];
|
||||
case 8:
|
||||
if (chainId != null) {
|
||||
try {
|
||||
return [2 /*return*/, resolve(getNetwork(bignumber_1.BigNumber.from(chainId).toNumber()))];
|
||||
}
|
||||
catch (error) { }
|
||||
}
|
||||
reject(logger.makeError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR));
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); }, 0);
|
||||
});
|
||||
_this = _super.call(this, ready) || this;
|
||||
_this = _super.call(this, _this.detectNetwork()) || this;
|
||||
}
|
||||
// Default URL
|
||||
if (!url) {
|
||||
@ -327,6 +285,53 @@ var JsonRpcProvider = /** @class */ (function (_super) {
|
||||
JsonRpcProvider.defaultUrl = function () {
|
||||
return "http:/\/localhost:8545";
|
||||
};
|
||||
JsonRpcProvider.prototype.detectNetwork = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var chainId, error_1, error_2, getNetwork;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, timer(0)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
chainId = null;
|
||||
_a.label = 2;
|
||||
case 2:
|
||||
_a.trys.push([2, 4, , 9]);
|
||||
return [4 /*yield*/, this.send("eth_chainId", [])];
|
||||
case 3:
|
||||
chainId = _a.sent();
|
||||
return [3 /*break*/, 9];
|
||||
case 4:
|
||||
error_1 = _a.sent();
|
||||
_a.label = 5;
|
||||
case 5:
|
||||
_a.trys.push([5, 7, , 8]);
|
||||
return [4 /*yield*/, this.send("net_version", [])];
|
||||
case 6:
|
||||
chainId = _a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
error_2 = _a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 8: return [3 /*break*/, 9];
|
||||
case 9:
|
||||
if (chainId != null) {
|
||||
getNetwork = properties_1.getStatic(this.constructor, "getNetwork");
|
||||
try {
|
||||
return [2 /*return*/, getNetwork(bignumber_1.BigNumber.from(chainId).toNumber())];
|
||||
}
|
||||
catch (error) {
|
||||
return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, {
|
||||
chainId: chainId,
|
||||
serverError: error
|
||||
})];
|
||||
}
|
||||
}
|
||||
return [2 /*return*/, logger.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
JsonRpcProvider.prototype.getSigner = function (addressOrIndex) {
|
||||
return new JsonRpcSigner(_constructorGuard, this, addressOrIndex);
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider";
|
||||
export declare abstract class UrlJsonRpcProvider extends JsonRpcProvider {
|
||||
readonly apiKey: any;
|
||||
constructor(network?: Networkish, apiKey?: any);
|
||||
detectNetwork(): Promise<Network>;
|
||||
_startPending(): void;
|
||||
getSigner(address?: string): JsonRpcSigner;
|
||||
listAccounts(): Promise<Array<string>>;
|
||||
|
@ -12,6 +12,42 @@ var __extends = (this && this.__extends) || (function () {
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var properties_1 = require("@ethersproject/properties");
|
||||
var logger_1 = require("@ethersproject/logger");
|
||||
@ -39,6 +75,13 @@ var UrlJsonRpcProvider = /** @class */ (function (_super) {
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
UrlJsonRpcProvider.prototype.detectNetwork = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, this.network];
|
||||
});
|
||||
});
|
||||
};
|
||||
UrlJsonRpcProvider.prototype._startPending = function () {
|
||||
logger.warn("WARNING: API provider does not support pending filters");
|
||||
};
|
||||
|
@ -96,11 +96,11 @@ var WebSocketProvider = /** @class */ (function (_super) {
|
||||
_this._websocket.onmessage = function (messageEvent) {
|
||||
var data = messageEvent.data;
|
||||
var result = JSON.parse(data);
|
||||
if (result.id) {
|
||||
if (result.id != null) {
|
||||
var id = String(result.id);
|
||||
var request = _this._requests[id];
|
||||
delete _this._requests[id];
|
||||
if (result.result) {
|
||||
if (result.result !== undefined) {
|
||||
request.callback(null, result.result);
|
||||
}
|
||||
else {
|
||||
|
@ -56,7 +56,7 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0x1f418141b6b57ca25d4399fdab8eb941be425422a1ee37cefc764652f64aeb11",
|
||||
"tarballHash": "0xa23d77e6439556382bb60e82fc8ec1a3ba9504d90c381815ec813496cd497daa",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.165"
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
import assert from "assert";
|
||||
import { ethers } from "ethers";
|
||||
import contractData from "./test-contract.json";
|
||||
const provider = new ethers.providers.InfuraProvider('rinkeby');
|
||||
//const provider = new ethers.providers.InfuraProvider('rinkeby');
|
||||
const provider = ethers.getDefaultProvider("rinkeby");
|
||||
const TIMEOUT_PERIOD = 120000;
|
||||
const contract = (function () {
|
||||
return new ethers.Contract(contractData.contractAddress, contractData.interface, provider);
|
||||
|
@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var assert_1 = __importDefault(require("assert"));
|
||||
var ethers_1 = require("ethers");
|
||||
var test_contract_json_1 = __importDefault(require("./test-contract.json"));
|
||||
var provider = new ethers_1.ethers.providers.InfuraProvider('rinkeby');
|
||||
//const provider = new ethers.providers.InfuraProvider('rinkeby');
|
||||
var provider = ethers_1.ethers.getDefaultProvider("rinkeby");
|
||||
var TIMEOUT_PERIOD = 120000;
|
||||
var contract = (function () {
|
||||
return new ethers_1.ethers.Contract(test_contract_json_1.default.contractAddress, test_contract_json_1.default.interface, provider);
|
||||
|
@ -39,7 +39,7 @@
|
||||
"scripts": {
|
||||
"test": "exit 1"
|
||||
},
|
||||
"tarballHash": "0x5dde69881b3dce2e3827d00926af541802a2b3995d55346fbeda99a4cb3b7dc0",
|
||||
"tarballHash": "0xac8cf0ee9074b69de2a45675de01bd995355f887a1daed7fadd95cc43195d1d8",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.158"
|
||||
}
|
||||
|
2
packages/web/lib.esm/_version.d.ts
vendored
2
packages/web/lib.esm/_version.d.ts
vendored
@ -1 +1 @@
|
||||
export declare const version = "web/5.0.0-beta.137";
|
||||
export declare const version = "web/5.0.0-beta.138";
|
||||
|
@ -1 +1 @@
|
||||
export const version = "web/5.0.0-beta.137";
|
||||
export const version = "web/5.0.0-beta.138";
|
||||
|
@ -94,8 +94,13 @@ export function fetchJson(connection, json, processFunc) {
|
||||
response = yield getUrl(url, options);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
response = error.response;
|
||||
if (response == null) {
|
||||
logger.throwError("missing response", Logger.errors.SERVER_ERROR, {
|
||||
serverError: error,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
let body = response.body;
|
||||
if (allow304 && response.statusCode === 304) {
|
||||
|
2
packages/web/lib/_version.d.ts
vendored
2
packages/web/lib/_version.d.ts
vendored
@ -1 +1 @@
|
||||
export declare const version = "web/5.0.0-beta.137";
|
||||
export declare const version = "web/5.0.0-beta.138";
|
||||
|
@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "web/5.0.0-beta.137";
|
||||
exports.version = "web/5.0.0-beta.138";
|
||||
|
@ -131,8 +131,13 @@ function fetchJson(connection, json, processFunc) {
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
error_1 = _a.sent();
|
||||
console.log(error_1);
|
||||
response = error_1.response;
|
||||
if (response == null) {
|
||||
logger.throwError("missing response", logger_1.Logger.errors.SERVER_ERROR, {
|
||||
serverError: error_1,
|
||||
url: url
|
||||
});
|
||||
}
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
body = response.body;
|
||||
|
@ -35,7 +35,7 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0x61705e91a9250f3d5b7cbf031c2aff7c41be3557228d156de9b27bed652ac282",
|
||||
"tarballHash": "0xb65d230f34fff51296199d36c8963829b38d278b9a14f0eefe8dd45f544a1b90",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.0-beta.137"
|
||||
"version": "5.0.0-beta.138"
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
export const version = "web/5.0.0-beta.137";
|
||||
export const version = "web/5.0.0-beta.138";
|
||||
|
Loading…
Reference in New Issue
Block a user