Updated dist files.
This commit is contained in:
parent
8eeda23e98
commit
7f0374c5a5
@ -2,14 +2,20 @@ Changelog
|
|||||||
=========
|
=========
|
||||||
|
|
||||||
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
||||||
|
|
||||||
During the v5-BETA, although attempts are made to minimize it, some of the APIs
|
During the v5-BETA, although attempts are made to minimize it, some of the APIs
|
||||||
may change. It is generally recommended that you remove your `node_modules/`,
|
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`
|
`package-lock.json` (and similar files for yarn, etc.) and doing an `npm install`
|
||||||
after upgrading to a newer version of the v5-BETA.
|
after upgrading to a newer version of the v5-BETA.
|
||||||
|
|
||||||
ethers/v5.0.0-beta.185 (2020-05-03 21:57)
|
ethers/v5.0.0-beta.185 (2020-05-04 22:54)
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
- More robust FallbackProvider on clean exits. ([8eeda23](https://github.com/ethers-io/ethers.js/commit/8eeda23e989fcb0126bd20b17c67f62466d19259))
|
||||||
|
- Safer test suite reporter timer. ([657a039](https://github.com/ethers-io/ethers.js/commit/657a0394f56b51a13c691477c2b0dcf74678fd7c))
|
||||||
|
- Added goerli to AlchemyProvider tests. ([ab7c781](https://github.com/ethers-io/ethers.js/commit/ab7c78118ab80990a3e3368749599a1cf6e9d4ae))
|
||||||
|
- Added more robust poll event to Provider. ([dc48bfb](https://github.com/ethers-io/ethers.js/commit/dc48bfb7adb9334848c93173ba2c634f22a9a72f))
|
||||||
|
- Added goerli to AlchemyProvider. ([86670eb](https://github.com/ethers-io/ethers.js/commit/86670eb80e96fc4ba4e3664c9389f8130bbfea73))
|
||||||
- Removed Cloudflare from test suite; it is down again. ([17dc022](https://github.com/ethers-io/ethers.js/commit/17dc022603afdfe4147638ab4b2704bcef09533f))
|
- Removed Cloudflare from test suite; it is down again. ([17dc022](https://github.com/ethers-io/ethers.js/commit/17dc022603afdfe4147638ab4b2704bcef09533f))
|
||||||
- Prevent forceOutput in test reporter from crashing. ([cafd344](https://github.com/ethers-io/ethers.js/commit/cafd34460b194d78092021f1d7e0307130340b68))
|
- Prevent forceOutput in test reporter from crashing. ([cafd344](https://github.com/ethers-io/ethers.js/commit/cafd34460b194d78092021f1d7e0307130340b68))
|
||||||
- Stall FallbackProvider backends from requests if not in-sync. ([fa6904f](https://github.com/ethers-io/ethers.js/commit/fa6904fef35e7ab888221f3a0613bfe7e6df3594))
|
- Stall FallbackProvider backends from requests if not in-sync. ([fa6904f](https://github.com/ethers-io/ethers.js/commit/fa6904fef35e7ab888221f3a0613bfe7e6df3594))
|
||||||
|
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
84
packages/ethers/dist/ethers.esm.js
vendored
84
packages/ethers/dist/ethers.esm.js
vendored
@ -15963,6 +15963,9 @@ function poll(func, options) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (options.oncePoll) {
|
||||||
|
options.oncePoll.once("poll", check);
|
||||||
|
}
|
||||||
else if (options.onceBlock) {
|
else if (options.onceBlock) {
|
||||||
options.onceBlock.once("block", check);
|
options.onceBlock.once("block", check);
|
||||||
// Otherwise, exponential back-off (up to 10s) our next request
|
// Otherwise, exponential back-off (up to 10s) our next request
|
||||||
@ -16463,6 +16466,7 @@ function getTime() {
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -16511,7 +16515,7 @@ class Event {
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
pollable() {
|
pollable() {
|
||||||
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending");
|
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let defaultFormatter = null;
|
let defaultFormatter = null;
|
||||||
@ -16627,8 +16631,11 @@ class BaseProvider extends Provider {
|
|||||||
const runners = [];
|
const runners = [];
|
||||||
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
|
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
|
||||||
this._setFastBlockNumber(blockNumber);
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
// Emit a poll event after we have the latest (fast) block number
|
||||||
|
this.emit("poll", pollId, blockNumber);
|
||||||
// If the block has not changed, meh.
|
// If the block has not changed, meh.
|
||||||
if (blockNumber === this._lastBlockNumber) {
|
if (blockNumber === this._lastBlockNumber) {
|
||||||
|
this.emit("didPoll", pollId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// First polling cycle, trigger a "block" events
|
// First polling cycle, trigger a "block" events
|
||||||
@ -16721,22 +16728,38 @@ class BaseProvider extends Provider {
|
|||||||
return this.ready;
|
return this.ready;
|
||||||
}
|
}
|
||||||
get blockNumber() {
|
get blockNumber() {
|
||||||
return this._fastBlockNumber;
|
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => {
|
||||||
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
});
|
||||||
|
return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
|
||||||
}
|
}
|
||||||
get polling() {
|
get polling() {
|
||||||
return (this._poller != null);
|
return (this._poller != null);
|
||||||
}
|
}
|
||||||
set polling(value) {
|
set polling(value) {
|
||||||
setTimeout(() => {
|
|
||||||
if (value && !this._poller) {
|
if (value && !this._poller) {
|
||||||
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
||||||
|
if (!this._bootstrapPoll) {
|
||||||
|
this._bootstrapPoll = setTimeout(() => {
|
||||||
this.poll();
|
this.poll();
|
||||||
|
// We block additional polls until the polling interval
|
||||||
|
// is done, to prevent overwhelming the poll function
|
||||||
|
this._bootstrapPoll = setTimeout(() => {
|
||||||
|
// If polling was disabled, something may require a poke
|
||||||
|
// since starting the bootstrap poll and it was disabled
|
||||||
|
if (!this._poller) {
|
||||||
|
this.poll();
|
||||||
|
}
|
||||||
|
// Clear out the bootstrap so we can do another
|
||||||
|
this._bootstrapPoll = null;
|
||||||
|
}, this.pollingInterval);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!value && this._poller) {
|
else if (!value && this._poller) {
|
||||||
clearInterval(this._poller);
|
clearInterval(this._poller);
|
||||||
this._poller = null;
|
this._poller = null;
|
||||||
}
|
}
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
get pollingInterval() {
|
get pollingInterval() {
|
||||||
return this._pollingInterval;
|
return this._pollingInterval;
|
||||||
@ -17918,6 +17941,9 @@ class AlchemyProvider extends UrlJsonRpcProvider {
|
|||||||
case "rinkeby":
|
case "rinkeby":
|
||||||
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
case "goerli":
|
||||||
|
host = "eth-goerli.alchemyapi.io/jsonrpc/";
|
||||||
|
break;
|
||||||
case "kovan":
|
case "kovan":
|
||||||
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
@ -18549,23 +18575,33 @@ function getProcessFunc(provider, method, params) {
|
|||||||
}
|
}
|
||||||
// If we are doing a blockTag query, we need to make sure the backend is
|
// If we are doing a blockTag query, we need to make sure the backend is
|
||||||
// caught up to the FallbackProvider, before sending a request to it.
|
// caught up to the FallbackProvider, before sending a request to it.
|
||||||
function waitForSync(provider, blockNumber) {
|
function waitForSync(config, blockNumber) {
|
||||||
return __awaiter$b(this, void 0, void 0, function* () {
|
return __awaiter$b(this, void 0, void 0, function* () {
|
||||||
|
const provider = (config.provider);
|
||||||
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
return poll(() => {
|
return poll(() => {
|
||||||
return provider.getBlockNumber().then((b) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (b >= blockNumber) {
|
setTimeout(function () {
|
||||||
return Provider;
|
// We are synced
|
||||||
|
if (provider.blockNumber >= blockNumber) {
|
||||||
|
return resolve(Provider);
|
||||||
}
|
}
|
||||||
return undefined;
|
// We're done; just quit
|
||||||
|
if (config.cancelled) {
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
// Try again, next block
|
||||||
|
return resolve(undefined);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
}, { onceBlock: provider });
|
}, { oncePoll: provider });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getRunner(provider, currentBlockNumber, method, params) {
|
function getRunner(config, currentBlockNumber, method, params) {
|
||||||
return __awaiter$b(this, void 0, void 0, function* () {
|
return __awaiter$b(this, void 0, void 0, function* () {
|
||||||
|
let provider = config.provider;
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "getBlockNumber":
|
case "getBlockNumber":
|
||||||
case "getGasPrice":
|
case "getGasPrice":
|
||||||
@ -18579,23 +18615,23 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
case "getTransactionCount":
|
case "getTransactionCount":
|
||||||
case "getCode":
|
case "getCode":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[method](params.address, params.blockTag || "latest");
|
return provider[method](params.address, params.blockTag || "latest");
|
||||||
case "getStorageAt":
|
case "getStorageAt":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider.getStorageAt(params.address, params.position, params.blockTag || "latest");
|
return provider.getStorageAt(params.address, params.position, params.blockTag || "latest");
|
||||||
case "getBlock":
|
case "getBlock":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash);
|
return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash);
|
||||||
case "call":
|
case "call":
|
||||||
case "estimateGas":
|
case "estimateGas":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[method](params.transaction);
|
return provider[method](params.transaction);
|
||||||
case "getTransaction":
|
case "getTransaction":
|
||||||
@ -18604,7 +18640,7 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
case "getLogs": {
|
case "getLogs": {
|
||||||
let filter = params.filter;
|
let filter = params.filter;
|
||||||
if ((filter.fromBlock && isHexString(filter.fromBlock)) || (filter.toBlock && isHexString(filter.toBlock))) {
|
if ((filter.fromBlock && isHexString(filter.fromBlock)) || (filter.toBlock && isHexString(filter.toBlock))) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider.getLogs(filter);
|
return provider.getLogs(filter);
|
||||||
}
|
}
|
||||||
@ -18713,7 +18749,7 @@ class FallbackProvider extends BaseProvider {
|
|||||||
config.start = now();
|
config.start = now();
|
||||||
config.staller = stall(config.stallTimeout);
|
config.staller = stall(config.stallTimeout);
|
||||||
config.staller.wait(() => { config.staller = null; });
|
config.staller.wait(() => { config.staller = null; });
|
||||||
config.runner = getRunner((config.provider), currentBlockNumber, method, params).then((result) => {
|
config.runner = getRunner(config, currentBlockNumber, method, params).then((result) => {
|
||||||
config.done = true;
|
config.done = true;
|
||||||
config.result = result;
|
config.result = result;
|
||||||
if (this.listenerCount("debug")) {
|
if (this.listenerCount("debug")) {
|
||||||
@ -18770,7 +18806,12 @@ class FallbackProvider extends BaseProvider {
|
|||||||
const result = processFunc(results);
|
const result = processFunc(results);
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
// Shut down any stallers
|
// Shut down any stallers
|
||||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
configs.forEach(c => {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (!first) {
|
if (!first) {
|
||||||
@ -18784,7 +18825,12 @@ class FallbackProvider extends BaseProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Shut down any stallers; shouldn't be any
|
// Shut down any stallers; shouldn't be any
|
||||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
configs.forEach(c => {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return logger$x.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
return logger$x.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
2
packages/ethers/dist/ethers.esm.min.js
vendored
2
packages/ethers/dist/ethers.esm.min.js
vendored
File diff suppressed because one or more lines are too long
98
packages/ethers/dist/ethers.umd.js
vendored
98
packages/ethers/dist/ethers.umd.js
vendored
@ -17705,6 +17705,9 @@
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (options.oncePoll) {
|
||||||
|
options.oncePoll.once("poll", check);
|
||||||
|
}
|
||||||
else if (options.onceBlock) {
|
else if (options.onceBlock) {
|
||||||
options.onceBlock.once("block", check);
|
options.onceBlock.once("block", check);
|
||||||
// Otherwise, exponential back-off (up to 10s) our next request
|
// Otherwise, exponential back-off (up to 10s) our next request
|
||||||
@ -18290,6 +18293,7 @@
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -18354,7 +18358,7 @@
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Event.prototype.pollable = function () {
|
Event.prototype.pollable = function () {
|
||||||
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending");
|
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
|
||||||
};
|
};
|
||||||
return Event;
|
return Event;
|
||||||
}());
|
}());
|
||||||
@ -18514,8 +18518,11 @@
|
|||||||
case 1:
|
case 1:
|
||||||
blockNumber = _a.sent();
|
blockNumber = _a.sent();
|
||||||
this._setFastBlockNumber(blockNumber);
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
// Emit a poll event after we have the latest (fast) block number
|
||||||
|
this.emit("poll", pollId, blockNumber);
|
||||||
// If the block has not changed, meh.
|
// If the block has not changed, meh.
|
||||||
if (blockNumber === this._lastBlockNumber) {
|
if (blockNumber === this._lastBlockNumber) {
|
||||||
|
this.emit("didPoll", pollId);
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
// First polling cycle, trigger a "block" events
|
// First polling cycle, trigger a "block" events
|
||||||
@ -18615,7 +18622,11 @@
|
|||||||
};
|
};
|
||||||
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this._fastBlockNumber;
|
var _this = this;
|
||||||
|
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function (blockNumber) {
|
||||||
|
_this._setFastBlockNumber(blockNumber);
|
||||||
|
});
|
||||||
|
return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
@ -18626,16 +18637,29 @@
|
|||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
setTimeout(function () {
|
if (value && !this._poller) {
|
||||||
if (value && !_this._poller) {
|
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
||||||
_this._poller = setInterval(_this.poll.bind(_this), _this.pollingInterval);
|
if (!this._bootstrapPoll) {
|
||||||
|
this._bootstrapPoll = setTimeout(function () {
|
||||||
|
_this.poll();
|
||||||
|
// We block additional polls until the polling interval
|
||||||
|
// is done, to prevent overwhelming the poll function
|
||||||
|
_this._bootstrapPoll = setTimeout(function () {
|
||||||
|
// If polling was disabled, something may require a poke
|
||||||
|
// since starting the bootstrap poll and it was disabled
|
||||||
|
if (!_this._poller) {
|
||||||
_this.poll();
|
_this.poll();
|
||||||
}
|
}
|
||||||
else if (!value && _this._poller) {
|
// Clear out the bootstrap so we can do another
|
||||||
clearInterval(_this._poller);
|
_this._bootstrapPoll = null;
|
||||||
_this._poller = null;
|
}, _this.pollingInterval);
|
||||||
}
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!value && this._poller) {
|
||||||
|
clearInterval(this._poller);
|
||||||
|
this._poller = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
@ -20279,6 +20303,9 @@
|
|||||||
case "rinkeby":
|
case "rinkeby":
|
||||||
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
case "goerli":
|
||||||
|
host = "eth-goerli.alchemyapi.io/jsonrpc/";
|
||||||
|
break;
|
||||||
case "kovan":
|
case "kovan":
|
||||||
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
@ -21126,29 +21153,40 @@
|
|||||||
}
|
}
|
||||||
// If we are doing a blockTag query, we need to make sure the backend is
|
// If we are doing a blockTag query, we need to make sure the backend is
|
||||||
// caught up to the FallbackProvider, before sending a request to it.
|
// caught up to the FallbackProvider, before sending a request to it.
|
||||||
function waitForSync(provider, blockNumber) {
|
function waitForSync(config, blockNumber) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
|
var provider;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
|
provider = (config.provider);
|
||||||
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
||||||
return [2 /*return*/, provider];
|
return [2 /*return*/, provider];
|
||||||
}
|
}
|
||||||
return [2 /*return*/, lib$l.poll(function () {
|
return [2 /*return*/, lib$l.poll(function () {
|
||||||
return provider.getBlockNumber().then(function (b) {
|
return new Promise(function (resolve, reject) {
|
||||||
if (b >= blockNumber) {
|
setTimeout(function () {
|
||||||
return lib$b.Provider;
|
// We are synced
|
||||||
|
if (provider.blockNumber >= blockNumber) {
|
||||||
|
return resolve(lib$b.Provider);
|
||||||
}
|
}
|
||||||
return undefined;
|
// We're done; just quit
|
||||||
|
if (config.cancelled) {
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
// Try again, next block
|
||||||
|
return resolve(undefined);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
}, { onceBlock: provider })];
|
}, { oncePoll: provider })];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getRunner(provider, currentBlockNumber, method, params) {
|
function getRunner(config, currentBlockNumber, method, params) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var _a, filter;
|
var provider, _a, filter;
|
||||||
return __generator(this, function (_b) {
|
return __generator(this, function (_b) {
|
||||||
switch (_b.label) {
|
switch (_b.label) {
|
||||||
case 0:
|
case 0:
|
||||||
|
provider = config.provider;
|
||||||
_a = method;
|
_a = method;
|
||||||
switch (_a) {
|
switch (_a) {
|
||||||
case "getBlockNumber": return [3 /*break*/, 1];
|
case "getBlockNumber": return [3 /*break*/, 1];
|
||||||
@ -21174,28 +21212,28 @@
|
|||||||
return [3 /*break*/, 19];
|
return [3 /*break*/, 19];
|
||||||
case 3:
|
case 3:
|
||||||
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 5];
|
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 5];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 4:
|
case 4:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 5;
|
_b.label = 5;
|
||||||
case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
|
case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
|
||||||
case 6:
|
case 6:
|
||||||
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 8];
|
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 8];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 7:
|
case 7:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 8;
|
_b.label = 8;
|
||||||
case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
|
case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
|
||||||
case 9:
|
case 9:
|
||||||
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 11];
|
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 11];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 10:
|
case 10:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 11;
|
_b.label = 11;
|
||||||
case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
|
case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
|
||||||
case 12:
|
case 12:
|
||||||
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 14];
|
if (!(params.blockTag && lib$1.isHexString(params.blockTag))) return [3 /*break*/, 14];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 13:
|
case 13:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 14;
|
_b.label = 14;
|
||||||
@ -21204,7 +21242,7 @@
|
|||||||
case 16:
|
case 16:
|
||||||
filter = params.filter;
|
filter = params.filter;
|
||||||
if (!((filter.fromBlock && lib$1.isHexString(filter.fromBlock)) || (filter.toBlock && lib$1.isHexString(filter.toBlock)))) return [3 /*break*/, 18];
|
if (!((filter.fromBlock && lib$1.isHexString(filter.fromBlock)) || (filter.toBlock && lib$1.isHexString(filter.toBlock)))) return [3 /*break*/, 18];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 17:
|
case 17:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 18;
|
_b.label = 18;
|
||||||
@ -21333,7 +21371,7 @@
|
|||||||
config.start = now();
|
config.start = now();
|
||||||
config.staller = stall(config.stallTimeout);
|
config.staller = stall(config.stallTimeout);
|
||||||
config.staller.wait(function () { config.staller = null; });
|
config.staller.wait(function () { config.staller = null; });
|
||||||
config.runner = getRunner((config.provider), currentBlockNumber, method, params).then(function (result) {
|
config.runner = getRunner(config, currentBlockNumber, method, params).then(function (result) {
|
||||||
config.done = true;
|
config.done = true;
|
||||||
config.result = result;
|
config.result = result;
|
||||||
if (_this.listenerCount("debug")) {
|
if (_this.listenerCount("debug")) {
|
||||||
@ -21394,7 +21432,12 @@
|
|||||||
result = processFunc(results);
|
result = processFunc(results);
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
// Shut down any stallers
|
// Shut down any stallers
|
||||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
configs.forEach(function (c) {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return [2 /*return*/, { value: result }];
|
return [2 /*return*/, { value: result }];
|
||||||
}
|
}
|
||||||
if (!!first) return [3 /*break*/, 4];
|
if (!!first) return [3 /*break*/, 4];
|
||||||
@ -21428,7 +21471,12 @@
|
|||||||
return [3 /*break*/, 5];
|
return [3 /*break*/, 5];
|
||||||
case 7:
|
case 7:
|
||||||
// Shut down any stallers; shouldn't be any
|
// Shut down any stallers; shouldn't be any
|
||||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
configs.forEach(function (c) {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return [2 /*return*/, logger.throwError("failed to meet quorum", lib.Logger.errors.SERVER_ERROR, {
|
return [2 /*return*/, logger.throwError("failed to meet quorum", lib.Logger.errors.SERVER_ERROR, {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
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
4
packages/ethers/lib.esm/utils.d.ts
vendored
4
packages/ethers/lib.esm/utils.d.ts
vendored
@ -26,5 +26,5 @@ import { Bytes, BytesLike, Hexable } from "@ethersproject/bytes";
|
|||||||
import { Mnemonic } from "@ethersproject/hdnode";
|
import { Mnemonic } from "@ethersproject/hdnode";
|
||||||
import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets";
|
import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets";
|
||||||
import { Utf8ErrorFunc } from "@ethersproject/strings";
|
import { Utf8ErrorFunc } from "@ethersproject/strings";
|
||||||
import { ConnectionInfo, FetchJsonResponse, OnceBlockable, PollOptions } from "@ethersproject/web";
|
import { ConnectionInfo, FetchJsonResponse, OnceBlockable, OncePollable, PollOptions } from "@ethersproject/web";
|
||||||
export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, checkResultErrors, Result, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, isBytes, isBytesLike, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, computeHmac, keccak256, ripemd160, sha256, sha512, randomBytes, shuffled, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, SupportedAlgorithm, UnicodeNormalizationForm, Utf8ErrorReason, Bytes, BytesLike, Hexable, UnsignedTransaction, CoerceFunc, Indexed, Mnemonic, Utf8ErrorFunc, ConnectionInfo, OnceBlockable, PollOptions, FetchJsonResponse, EncryptOptions, ProgressCallback };
|
export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, checkResultErrors, Result, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, isBytes, isBytesLike, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, computeHmac, keccak256, ripemd160, sha256, sha512, randomBytes, shuffled, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, SupportedAlgorithm, UnicodeNormalizationForm, Utf8ErrorReason, Bytes, BytesLike, Hexable, UnsignedTransaction, CoerceFunc, Indexed, Mnemonic, Utf8ErrorFunc, ConnectionInfo, OnceBlockable, OncePollable, PollOptions, FetchJsonResponse, EncryptOptions, ProgressCallback };
|
||||||
|
4
packages/ethers/lib/utils.d.ts
vendored
4
packages/ethers/lib/utils.d.ts
vendored
@ -26,5 +26,5 @@ import { Bytes, BytesLike, Hexable } from "@ethersproject/bytes";
|
|||||||
import { Mnemonic } from "@ethersproject/hdnode";
|
import { Mnemonic } from "@ethersproject/hdnode";
|
||||||
import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets";
|
import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets";
|
||||||
import { Utf8ErrorFunc } from "@ethersproject/strings";
|
import { Utf8ErrorFunc } from "@ethersproject/strings";
|
||||||
import { ConnectionInfo, FetchJsonResponse, OnceBlockable, PollOptions } from "@ethersproject/web";
|
import { ConnectionInfo, FetchJsonResponse, OnceBlockable, OncePollable, PollOptions } from "@ethersproject/web";
|
||||||
export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, checkResultErrors, Result, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, isBytes, isBytesLike, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, computeHmac, keccak256, ripemd160, sha256, sha512, randomBytes, shuffled, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, SupportedAlgorithm, UnicodeNormalizationForm, Utf8ErrorReason, Bytes, BytesLike, Hexable, UnsignedTransaction, CoerceFunc, Indexed, Mnemonic, Utf8ErrorFunc, ConnectionInfo, OnceBlockable, PollOptions, FetchJsonResponse, EncryptOptions, ProgressCallback };
|
export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, checkResultErrors, Result, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, isBytes, isBytesLike, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, computeHmac, keccak256, ripemd160, sha256, sha512, randomBytes, shuffled, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, SupportedAlgorithm, UnicodeNormalizationForm, Utf8ErrorReason, Bytes, BytesLike, Hexable, UnsignedTransaction, CoerceFunc, Indexed, Mnemonic, Utf8ErrorFunc, ConnectionInfo, OnceBlockable, OncePollable, PollOptions, FetchJsonResponse, EncryptOptions, ProgressCallback };
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0xee6633babeaf42a27299a2d3d14780efecf6fbe4cee7681493f807d71055d759",
|
"tarballHash": "0xfaa41aecf50c97b6d1560bf37604bb05359cd0d8a6f1f2be70ddf55156acef60",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.185"
|
"version": "5.0.0-beta.185"
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ export class AlchemyProvider extends UrlJsonRpcProvider {
|
|||||||
case "rinkeby":
|
case "rinkeby":
|
||||||
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
case "goerli":
|
||||||
|
host = "eth-goerli.alchemyapi.io/jsonrpc/";
|
||||||
|
break;
|
||||||
case "kovan":
|
case "kovan":
|
||||||
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
@ -7,6 +7,7 @@ import { Formatter } from "./formatter";
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -34,6 +35,7 @@ export declare class BaseProvider extends Provider {
|
|||||||
};
|
};
|
||||||
_pollingInterval: number;
|
_pollingInterval: number;
|
||||||
_poller: NodeJS.Timer;
|
_poller: NodeJS.Timer;
|
||||||
|
_bootstrapPoll: NodeJS.Timer;
|
||||||
_lastBlockNumber: number;
|
_lastBlockNumber: number;
|
||||||
_fastBlockNumber: number;
|
_fastBlockNumber: number;
|
||||||
_fastBlockNumberPromise: Promise<number>;
|
_fastBlockNumberPromise: Promise<number>;
|
||||||
|
@ -100,6 +100,7 @@ function getTime() {
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -148,7 +149,7 @@ export class Event {
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
pollable() {
|
pollable() {
|
||||||
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending");
|
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let defaultFormatter = null;
|
let defaultFormatter = null;
|
||||||
@ -264,8 +265,11 @@ export class BaseProvider extends Provider {
|
|||||||
const runners = [];
|
const runners = [];
|
||||||
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
|
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
|
||||||
this._setFastBlockNumber(blockNumber);
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
// Emit a poll event after we have the latest (fast) block number
|
||||||
|
this.emit("poll", pollId, blockNumber);
|
||||||
// If the block has not changed, meh.
|
// If the block has not changed, meh.
|
||||||
if (blockNumber === this._lastBlockNumber) {
|
if (blockNumber === this._lastBlockNumber) {
|
||||||
|
this.emit("didPoll", pollId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// First polling cycle, trigger a "block" events
|
// First polling cycle, trigger a "block" events
|
||||||
@ -358,22 +362,38 @@ export class BaseProvider extends Provider {
|
|||||||
return this.ready;
|
return this.ready;
|
||||||
}
|
}
|
||||||
get blockNumber() {
|
get blockNumber() {
|
||||||
return this._fastBlockNumber;
|
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => {
|
||||||
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
});
|
||||||
|
return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
|
||||||
}
|
}
|
||||||
get polling() {
|
get polling() {
|
||||||
return (this._poller != null);
|
return (this._poller != null);
|
||||||
}
|
}
|
||||||
set polling(value) {
|
set polling(value) {
|
||||||
setTimeout(() => {
|
|
||||||
if (value && !this._poller) {
|
if (value && !this._poller) {
|
||||||
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
||||||
|
if (!this._bootstrapPoll) {
|
||||||
|
this._bootstrapPoll = setTimeout(() => {
|
||||||
this.poll();
|
this.poll();
|
||||||
|
// We block additional polls until the polling interval
|
||||||
|
// is done, to prevent overwhelming the poll function
|
||||||
|
this._bootstrapPoll = setTimeout(() => {
|
||||||
|
// If polling was disabled, something may require a poke
|
||||||
|
// since starting the bootstrap poll and it was disabled
|
||||||
|
if (!this._poller) {
|
||||||
|
this.poll();
|
||||||
|
}
|
||||||
|
// Clear out the bootstrap so we can do another
|
||||||
|
this._bootstrapPoll = null;
|
||||||
|
}, this.pollingInterval);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!value && this._poller) {
|
else if (!value && this._poller) {
|
||||||
clearInterval(this._poller);
|
clearInterval(this._poller);
|
||||||
this._poller = null;
|
this._poller = null;
|
||||||
}
|
}
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
get pollingInterval() {
|
get pollingInterval() {
|
||||||
return this._pollingInterval;
|
return this._pollingInterval;
|
||||||
|
@ -255,23 +255,33 @@ function getProcessFunc(provider, method, params) {
|
|||||||
}
|
}
|
||||||
// If we are doing a blockTag query, we need to make sure the backend is
|
// If we are doing a blockTag query, we need to make sure the backend is
|
||||||
// caught up to the FallbackProvider, before sending a request to it.
|
// caught up to the FallbackProvider, before sending a request to it.
|
||||||
function waitForSync(provider, blockNumber) {
|
function waitForSync(config, blockNumber) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const provider = (config.provider);
|
||||||
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
return poll(() => {
|
return poll(() => {
|
||||||
return provider.getBlockNumber().then((b) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (b >= blockNumber) {
|
setTimeout(function () {
|
||||||
return Provider;
|
// We are synced
|
||||||
|
if (provider.blockNumber >= blockNumber) {
|
||||||
|
return resolve(Provider);
|
||||||
}
|
}
|
||||||
return undefined;
|
// We're done; just quit
|
||||||
|
if (config.cancelled) {
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
// Try again, next block
|
||||||
|
return resolve(undefined);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
}, { onceBlock: provider });
|
}, { oncePoll: provider });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getRunner(provider, currentBlockNumber, method, params) {
|
function getRunner(config, currentBlockNumber, method, params) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let provider = config.provider;
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "getBlockNumber":
|
case "getBlockNumber":
|
||||||
case "getGasPrice":
|
case "getGasPrice":
|
||||||
@ -285,23 +295,23 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
case "getTransactionCount":
|
case "getTransactionCount":
|
||||||
case "getCode":
|
case "getCode":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[method](params.address, params.blockTag || "latest");
|
return provider[method](params.address, params.blockTag || "latest");
|
||||||
case "getStorageAt":
|
case "getStorageAt":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider.getStorageAt(params.address, params.position, params.blockTag || "latest");
|
return provider.getStorageAt(params.address, params.position, params.blockTag || "latest");
|
||||||
case "getBlock":
|
case "getBlock":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash);
|
return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash);
|
||||||
case "call":
|
case "call":
|
||||||
case "estimateGas":
|
case "estimateGas":
|
||||||
if (params.blockTag && isHexString(params.blockTag)) {
|
if (params.blockTag && isHexString(params.blockTag)) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider[method](params.transaction);
|
return provider[method](params.transaction);
|
||||||
case "getTransaction":
|
case "getTransaction":
|
||||||
@ -310,7 +320,7 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
case "getLogs": {
|
case "getLogs": {
|
||||||
let filter = params.filter;
|
let filter = params.filter;
|
||||||
if ((filter.fromBlock && isHexString(filter.fromBlock)) || (filter.toBlock && isHexString(filter.toBlock))) {
|
if ((filter.fromBlock && isHexString(filter.fromBlock)) || (filter.toBlock && isHexString(filter.toBlock))) {
|
||||||
provider = yield waitForSync(provider, currentBlockNumber);
|
provider = yield waitForSync(config, currentBlockNumber);
|
||||||
}
|
}
|
||||||
return provider.getLogs(filter);
|
return provider.getLogs(filter);
|
||||||
}
|
}
|
||||||
@ -419,7 +429,7 @@ export class FallbackProvider extends BaseProvider {
|
|||||||
config.start = now();
|
config.start = now();
|
||||||
config.staller = stall(config.stallTimeout);
|
config.staller = stall(config.stallTimeout);
|
||||||
config.staller.wait(() => { config.staller = null; });
|
config.staller.wait(() => { config.staller = null; });
|
||||||
config.runner = getRunner((config.provider), currentBlockNumber, method, params).then((result) => {
|
config.runner = getRunner(config, currentBlockNumber, method, params).then((result) => {
|
||||||
config.done = true;
|
config.done = true;
|
||||||
config.result = result;
|
config.result = result;
|
||||||
if (this.listenerCount("debug")) {
|
if (this.listenerCount("debug")) {
|
||||||
@ -476,7 +486,12 @@ export class FallbackProvider extends BaseProvider {
|
|||||||
const result = processFunc(results);
|
const result = processFunc(results);
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
// Shut down any stallers
|
// Shut down any stallers
|
||||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
configs.forEach(c => {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (!first) {
|
if (!first) {
|
||||||
@ -490,7 +505,12 @@ export class FallbackProvider extends BaseProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Shut down any stallers; shouldn't be any
|
// Shut down any stallers; shouldn't be any
|
||||||
configs.filter(c => c.staller).forEach(c => c.staller.cancel());
|
configs.forEach(c => {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return logger.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
return logger.throwError("failed to meet quorum", Logger.errors.SERVER_ERROR, {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
@ -48,6 +48,9 @@ var AlchemyProvider = /** @class */ (function (_super) {
|
|||||||
case "rinkeby":
|
case "rinkeby":
|
||||||
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
host = "eth-rinkeby.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
case "goerli":
|
||||||
|
host = "eth-goerli.alchemyapi.io/jsonrpc/";
|
||||||
|
break;
|
||||||
case "kovan":
|
case "kovan":
|
||||||
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
host = "eth-kovan.alchemyapi.io/jsonrpc/";
|
||||||
break;
|
break;
|
||||||
|
2
packages/providers/lib/base-provider.d.ts
vendored
2
packages/providers/lib/base-provider.d.ts
vendored
@ -7,6 +7,7 @@ import { Formatter } from "./formatter";
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -34,6 +35,7 @@ export declare class BaseProvider extends Provider {
|
|||||||
};
|
};
|
||||||
_pollingInterval: number;
|
_pollingInterval: number;
|
||||||
_poller: NodeJS.Timer;
|
_poller: NodeJS.Timer;
|
||||||
|
_bootstrapPoll: NodeJS.Timer;
|
||||||
_lastBlockNumber: number;
|
_lastBlockNumber: number;
|
||||||
_fastBlockNumber: number;
|
_fastBlockNumber: number;
|
||||||
_fastBlockNumberPromise: Promise<number>;
|
_fastBlockNumberPromise: Promise<number>;
|
||||||
|
@ -141,6 +141,7 @@ function getTime() {
|
|||||||
/**
|
/**
|
||||||
* EventType
|
* EventType
|
||||||
* - "block"
|
* - "block"
|
||||||
|
* - "poll"
|
||||||
* - "pending"
|
* - "pending"
|
||||||
* - "error"
|
* - "error"
|
||||||
* - filter
|
* - filter
|
||||||
@ -205,7 +206,7 @@ var Event = /** @class */ (function () {
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Event.prototype.pollable = function () {
|
Event.prototype.pollable = function () {
|
||||||
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending");
|
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
|
||||||
};
|
};
|
||||||
return Event;
|
return Event;
|
||||||
}());
|
}());
|
||||||
@ -365,8 +366,11 @@ var BaseProvider = /** @class */ (function (_super) {
|
|||||||
case 1:
|
case 1:
|
||||||
blockNumber = _a.sent();
|
blockNumber = _a.sent();
|
||||||
this._setFastBlockNumber(blockNumber);
|
this._setFastBlockNumber(blockNumber);
|
||||||
|
// Emit a poll event after we have the latest (fast) block number
|
||||||
|
this.emit("poll", pollId, blockNumber);
|
||||||
// If the block has not changed, meh.
|
// If the block has not changed, meh.
|
||||||
if (blockNumber === this._lastBlockNumber) {
|
if (blockNumber === this._lastBlockNumber) {
|
||||||
|
this.emit("didPoll", pollId);
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
// First polling cycle, trigger a "block" events
|
// First polling cycle, trigger a "block" events
|
||||||
@ -466,7 +470,11 @@ var BaseProvider = /** @class */ (function (_super) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this._fastBlockNumber;
|
var _this = this;
|
||||||
|
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function (blockNumber) {
|
||||||
|
_this._setFastBlockNumber(blockNumber);
|
||||||
|
});
|
||||||
|
return (this._fastBlockNumber != null) ? this._fastBlockNumber : -1;
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
@ -477,16 +485,29 @@ var BaseProvider = /** @class */ (function (_super) {
|
|||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
setTimeout(function () {
|
if (value && !this._poller) {
|
||||||
if (value && !_this._poller) {
|
this._poller = setInterval(this.poll.bind(this), this.pollingInterval);
|
||||||
_this._poller = setInterval(_this.poll.bind(_this), _this.pollingInterval);
|
if (!this._bootstrapPoll) {
|
||||||
|
this._bootstrapPoll = setTimeout(function () {
|
||||||
|
_this.poll();
|
||||||
|
// We block additional polls until the polling interval
|
||||||
|
// is done, to prevent overwhelming the poll function
|
||||||
|
_this._bootstrapPoll = setTimeout(function () {
|
||||||
|
// If polling was disabled, something may require a poke
|
||||||
|
// since starting the bootstrap poll and it was disabled
|
||||||
|
if (!_this._poller) {
|
||||||
_this.poll();
|
_this.poll();
|
||||||
}
|
}
|
||||||
else if (!value && _this._poller) {
|
// Clear out the bootstrap so we can do another
|
||||||
clearInterval(_this._poller);
|
_this._bootstrapPoll = null;
|
||||||
_this._poller = null;
|
}, _this.pollingInterval);
|
||||||
}
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!value && this._poller) {
|
||||||
|
clearInterval(this._poller);
|
||||||
|
this._poller = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
|
@ -296,29 +296,40 @@ function getProcessFunc(provider, method, params) {
|
|||||||
}
|
}
|
||||||
// If we are doing a blockTag query, we need to make sure the backend is
|
// If we are doing a blockTag query, we need to make sure the backend is
|
||||||
// caught up to the FallbackProvider, before sending a request to it.
|
// caught up to the FallbackProvider, before sending a request to it.
|
||||||
function waitForSync(provider, blockNumber) {
|
function waitForSync(config, blockNumber) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
|
var provider;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
|
provider = (config.provider);
|
||||||
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
|
||||||
return [2 /*return*/, provider];
|
return [2 /*return*/, provider];
|
||||||
}
|
}
|
||||||
return [2 /*return*/, web_1.poll(function () {
|
return [2 /*return*/, web_1.poll(function () {
|
||||||
return provider.getBlockNumber().then(function (b) {
|
return new Promise(function (resolve, reject) {
|
||||||
if (b >= blockNumber) {
|
setTimeout(function () {
|
||||||
return abstract_provider_1.Provider;
|
// We are synced
|
||||||
|
if (provider.blockNumber >= blockNumber) {
|
||||||
|
return resolve(abstract_provider_1.Provider);
|
||||||
}
|
}
|
||||||
return undefined;
|
// We're done; just quit
|
||||||
|
if (config.cancelled) {
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
// Try again, next block
|
||||||
|
return resolve(undefined);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
}, { onceBlock: provider })];
|
}, { oncePoll: provider })];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getRunner(provider, currentBlockNumber, method, params) {
|
function getRunner(config, currentBlockNumber, method, params) {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var _a, filter;
|
var provider, _a, filter;
|
||||||
return __generator(this, function (_b) {
|
return __generator(this, function (_b) {
|
||||||
switch (_b.label) {
|
switch (_b.label) {
|
||||||
case 0:
|
case 0:
|
||||||
|
provider = config.provider;
|
||||||
_a = method;
|
_a = method;
|
||||||
switch (_a) {
|
switch (_a) {
|
||||||
case "getBlockNumber": return [3 /*break*/, 1];
|
case "getBlockNumber": return [3 /*break*/, 1];
|
||||||
@ -344,28 +355,28 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
return [3 /*break*/, 19];
|
return [3 /*break*/, 19];
|
||||||
case 3:
|
case 3:
|
||||||
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 5];
|
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 5];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 4:
|
case 4:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 5;
|
_b.label = 5;
|
||||||
case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
|
case 5: return [2 /*return*/, provider[method](params.address, params.blockTag || "latest")];
|
||||||
case 6:
|
case 6:
|
||||||
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 8];
|
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 8];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 7:
|
case 7:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 8;
|
_b.label = 8;
|
||||||
case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
|
case 8: return [2 /*return*/, provider.getStorageAt(params.address, params.position, params.blockTag || "latest")];
|
||||||
case 9:
|
case 9:
|
||||||
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 11];
|
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 11];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 10:
|
case 10:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 11;
|
_b.label = 11;
|
||||||
case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
|
case 11: return [2 /*return*/, provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash)];
|
||||||
case 12:
|
case 12:
|
||||||
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 14];
|
if (!(params.blockTag && bytes_1.isHexString(params.blockTag))) return [3 /*break*/, 14];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 13:
|
case 13:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 14;
|
_b.label = 14;
|
||||||
@ -374,7 +385,7 @@ function getRunner(provider, currentBlockNumber, method, params) {
|
|||||||
case 16:
|
case 16:
|
||||||
filter = params.filter;
|
filter = params.filter;
|
||||||
if (!((filter.fromBlock && bytes_1.isHexString(filter.fromBlock)) || (filter.toBlock && bytes_1.isHexString(filter.toBlock)))) return [3 /*break*/, 18];
|
if (!((filter.fromBlock && bytes_1.isHexString(filter.fromBlock)) || (filter.toBlock && bytes_1.isHexString(filter.toBlock)))) return [3 /*break*/, 18];
|
||||||
return [4 /*yield*/, waitForSync(provider, currentBlockNumber)];
|
return [4 /*yield*/, waitForSync(config, currentBlockNumber)];
|
||||||
case 17:
|
case 17:
|
||||||
provider = _b.sent();
|
provider = _b.sent();
|
||||||
_b.label = 18;
|
_b.label = 18;
|
||||||
@ -503,7 +514,7 @@ var FallbackProvider = /** @class */ (function (_super) {
|
|||||||
config.start = now();
|
config.start = now();
|
||||||
config.staller = stall(config.stallTimeout);
|
config.staller = stall(config.stallTimeout);
|
||||||
config.staller.wait(function () { config.staller = null; });
|
config.staller.wait(function () { config.staller = null; });
|
||||||
config.runner = getRunner((config.provider), currentBlockNumber, method, params).then(function (result) {
|
config.runner = getRunner(config, currentBlockNumber, method, params).then(function (result) {
|
||||||
config.done = true;
|
config.done = true;
|
||||||
config.result = result;
|
config.result = result;
|
||||||
if (_this.listenerCount("debug")) {
|
if (_this.listenerCount("debug")) {
|
||||||
@ -564,7 +575,12 @@ var FallbackProvider = /** @class */ (function (_super) {
|
|||||||
result = processFunc(results);
|
result = processFunc(results);
|
||||||
if (result !== undefined) {
|
if (result !== undefined) {
|
||||||
// Shut down any stallers
|
// Shut down any stallers
|
||||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
configs.forEach(function (c) {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return [2 /*return*/, { value: result }];
|
return [2 /*return*/, { value: result }];
|
||||||
}
|
}
|
||||||
if (!!first) return [3 /*break*/, 4];
|
if (!!first) return [3 /*break*/, 4];
|
||||||
@ -598,7 +614,12 @@ var FallbackProvider = /** @class */ (function (_super) {
|
|||||||
return [3 /*break*/, 5];
|
return [3 /*break*/, 5];
|
||||||
case 7:
|
case 7:
|
||||||
// Shut down any stallers; shouldn't be any
|
// Shut down any stallers; shouldn't be any
|
||||||
configs.filter(function (c) { return c.staller; }).forEach(function (c) { return c.staller.cancel(); });
|
configs.forEach(function (c) {
|
||||||
|
if (c.staller) {
|
||||||
|
c.staller.cancel();
|
||||||
|
}
|
||||||
|
c.cancelled = true;
|
||||||
|
});
|
||||||
return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
|
return [2 /*return*/, logger.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, {
|
||||||
method: method,
|
method: method,
|
||||||
params: params,
|
params: params,
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0x8af51f5043e8b3d30f54fbe3b0b010949bb211324d6eaef0f89354cacf9de4b5",
|
"tarballHash": "0x37c5f15bcb70eac5b469a51a292980bfcef861eef0bff51eb6dbe23192a2bbc6",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.165"
|
"version": "5.0.0-beta.165"
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,15 @@ function getDelta(t0) {
|
|||||||
}
|
}
|
||||||
export function Reporter(runner) {
|
export function Reporter(runner) {
|
||||||
let suites = [];
|
let suites = [];
|
||||||
|
// Force Output; Keeps the console output alive with periodic updates
|
||||||
let lastOutput = getTime();
|
let lastOutput = getTime();
|
||||||
|
function forceOutput() {
|
||||||
|
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
|
||||||
|
const currentSuite = suites[suites.length - 1];
|
||||||
|
log(`[ Still running suite - test # ${(currentSuite ? currentSuite._countTotal : "0")} ]`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const timer = setInterval(forceOutput, 1000);
|
||||||
function getIndent() {
|
function getIndent() {
|
||||||
let result = '';
|
let result = '';
|
||||||
for (let i = 0; i < suites.length; i++) {
|
for (let i = 0; i < suites.length; i++) {
|
||||||
@ -57,7 +65,7 @@ export function Reporter(runner) {
|
|||||||
let suite = suites.pop();
|
let suite = suites.pop();
|
||||||
let failure = '';
|
let failure = '';
|
||||||
if (suite._countTotal > suite._countPass) {
|
if (suite._countTotal > suite._countPass) {
|
||||||
failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)';
|
failure = ' (' + (suite._countTotal - suite._countPass) + ' failed) *****';
|
||||||
}
|
}
|
||||||
log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure);
|
log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure);
|
||||||
log();
|
log();
|
||||||
@ -67,17 +75,10 @@ export function Reporter(runner) {
|
|||||||
currentSuite._countPass += suite._countPass;
|
currentSuite._countPass += suite._countPass;
|
||||||
currentSuite._countTotal += suite._countTotal;
|
currentSuite._countTotal += suite._countTotal;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
function forceOutput() {
|
|
||||||
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
|
|
||||||
const currentSuite = suites[suites.length - 1];
|
|
||||||
log(`[ Still running suite - test # ${(currentSuite ? currentSuite._countTotal : "0")} ]`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const timer = setInterval(forceOutput, 1000);
|
|
||||||
if (timer.unref) {
|
|
||||||
timer.unref();
|
|
||||||
}
|
|
||||||
runner.on('test', function (test) {
|
runner.on('test', function (test) {
|
||||||
forceOutput();
|
forceOutput();
|
||||||
const currentSuite = suites[suites.length - 1];
|
const currentSuite = suites[suites.length - 1];
|
||||||
|
@ -402,12 +402,6 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "getDefaultProvider") {
|
if (providerName === "getDefaultProvider") {
|
||||||
provider = ethers.getDefaultProvider();
|
provider = ethers.getDefaultProvider();
|
||||||
}
|
}
|
||||||
else if (providerName === "Web3Provider") {
|
|
||||||
//let infuraUrl = (new ethers.providers.InfuraProvider()).connection.url;
|
|
||||||
//provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl));
|
|
||||||
//throw new Error("skipping Web3 tests; archos error on npm install");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
provider = new (ethers.providers)[providerName]();
|
provider = new (ethers.providers)[providerName]();
|
||||||
}
|
}
|
||||||
@ -416,12 +410,6 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "getDefaultProvider") {
|
if (providerName === "getDefaultProvider") {
|
||||||
provider = ethers.getDefaultProvider(networkName);
|
provider = ethers.getDefaultProvider(networkName);
|
||||||
}
|
}
|
||||||
else if (providerName === "Web3Provider") {
|
|
||||||
//let infuraUrl = (new ethers.providers.InfuraProvider(networkName)).connection.url;
|
|
||||||
//provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl), networkName);
|
|
||||||
//throw new Error("skipping Web3 tests; archos error on npm install");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
provider = new (ethers.providers)[providerName](networkName);
|
provider = new (ethers.providers)[providerName](networkName);
|
||||||
}
|
}
|
||||||
@ -559,7 +547,7 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "CloudflareProvider") {
|
if (providerName === "CloudflareProvider") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (networkName === "goerli" && providerName === "AlchemyProvider") {
|
if (providerName === "Web3Provider") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((networkName !== "homestead" && networkName !== "default") && providerName === "CloudflareProvider") {
|
if ((networkName !== "homestead" && networkName !== "default") && providerName === "CloudflareProvider") {
|
||||||
|
@ -22,7 +22,15 @@ function getDelta(t0) {
|
|||||||
}
|
}
|
||||||
function Reporter(runner) {
|
function Reporter(runner) {
|
||||||
var suites = [];
|
var suites = [];
|
||||||
|
// Force Output; Keeps the console output alive with periodic updates
|
||||||
var lastOutput = getTime();
|
var lastOutput = getTime();
|
||||||
|
function forceOutput() {
|
||||||
|
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
|
||||||
|
var currentSuite = suites[suites.length - 1];
|
||||||
|
log("[ Still running suite - test # " + (currentSuite ? currentSuite._countTotal : "0") + " ]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var timer = setInterval(forceOutput, 1000);
|
||||||
function getIndent() {
|
function getIndent() {
|
||||||
var result = '';
|
var result = '';
|
||||||
for (var i = 0; i < suites.length; i++) {
|
for (var i = 0; i < suites.length; i++) {
|
||||||
@ -58,7 +66,7 @@ function Reporter(runner) {
|
|||||||
var suite = suites.pop();
|
var suite = suites.pop();
|
||||||
var failure = '';
|
var failure = '';
|
||||||
if (suite._countTotal > suite._countPass) {
|
if (suite._countTotal > suite._countPass) {
|
||||||
failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)';
|
failure = ' (' + (suite._countTotal - suite._countPass) + ' failed) *****';
|
||||||
}
|
}
|
||||||
log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure);
|
log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure);
|
||||||
log();
|
log();
|
||||||
@ -68,17 +76,10 @@ function Reporter(runner) {
|
|||||||
currentSuite._countPass += suite._countPass;
|
currentSuite._countPass += suite._countPass;
|
||||||
currentSuite._countTotal += suite._countTotal;
|
currentSuite._countTotal += suite._countTotal;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
function forceOutput() {
|
|
||||||
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
|
|
||||||
var currentSuite = suites[suites.length - 1];
|
|
||||||
log("[ Still running suite - test # " + (currentSuite ? currentSuite._countTotal : "0") + " ]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var timer = setInterval(forceOutput, 1000);
|
|
||||||
if (timer.unref) {
|
|
||||||
timer.unref();
|
|
||||||
}
|
|
||||||
runner.on('test', function (test) {
|
runner.on('test', function (test) {
|
||||||
forceOutput();
|
forceOutput();
|
||||||
var currentSuite = suites[suites.length - 1];
|
var currentSuite = suites[suites.length - 1];
|
||||||
|
@ -406,12 +406,6 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "getDefaultProvider") {
|
if (providerName === "getDefaultProvider") {
|
||||||
provider = ethers_1.ethers.getDefaultProvider();
|
provider = ethers_1.ethers.getDefaultProvider();
|
||||||
}
|
}
|
||||||
else if (providerName === "Web3Provider") {
|
|
||||||
//let infuraUrl = (new ethers.providers.InfuraProvider()).connection.url;
|
|
||||||
//provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl));
|
|
||||||
//throw new Error("skipping Web3 tests; archos error on npm install");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
provider = new (ethers_1.ethers.providers)[providerName]();
|
provider = new (ethers_1.ethers.providers)[providerName]();
|
||||||
}
|
}
|
||||||
@ -420,12 +414,6 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "getDefaultProvider") {
|
if (providerName === "getDefaultProvider") {
|
||||||
provider = ethers_1.ethers.getDefaultProvider(networkName);
|
provider = ethers_1.ethers.getDefaultProvider(networkName);
|
||||||
}
|
}
|
||||||
else if (providerName === "Web3Provider") {
|
|
||||||
//let infuraUrl = (new ethers.providers.InfuraProvider(networkName)).connection.url;
|
|
||||||
//provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl), networkName);
|
|
||||||
//throw new Error("skipping Web3 tests; archos error on npm install");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
provider = new (ethers_1.ethers.providers)[providerName](networkName);
|
provider = new (ethers_1.ethers.providers)[providerName](networkName);
|
||||||
}
|
}
|
||||||
@ -563,7 +551,7 @@ function testProvider(providerName, networkName) {
|
|||||||
if (providerName === "CloudflareProvider") {
|
if (providerName === "CloudflareProvider") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (networkName === "goerli" && providerName === "AlchemyProvider") {
|
if (providerName === "Web3Provider") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((networkName !== "homestead" && networkName !== "default") && providerName === "CloudflareProvider") {
|
if ((networkName !== "homestead" && networkName !== "default") && providerName === "CloudflareProvider") {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "exit 1"
|
"test": "exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0x70cc8736dfbf68427e0ed236bebee488a50d64222fd81ff16eb04950a9ca3d4b",
|
"tarballHash": "0x39652f5cf5adf63d747b3decc96aab331f8f59697de93cc8bca8232f0e7be863",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.158"
|
"version": "5.0.0-beta.158"
|
||||||
}
|
}
|
||||||
|
4
packages/web/lib.esm/index.d.ts
vendored
4
packages/web/lib.esm/index.d.ts
vendored
@ -12,6 +12,9 @@ export declare type ConnectionInfo = {
|
|||||||
export interface OnceBlockable {
|
export interface OnceBlockable {
|
||||||
once(eventName: "block", handler: () => void): void;
|
once(eventName: "block", handler: () => void): void;
|
||||||
}
|
}
|
||||||
|
export interface OncePollable {
|
||||||
|
once(eventName: "poll", handler: () => void): void;
|
||||||
|
}
|
||||||
export declare type PollOptions = {
|
export declare type PollOptions = {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
floor?: number;
|
floor?: number;
|
||||||
@ -19,6 +22,7 @@ export declare type PollOptions = {
|
|||||||
interval?: number;
|
interval?: number;
|
||||||
retryLimit?: number;
|
retryLimit?: number;
|
||||||
onceBlock?: OnceBlockable;
|
onceBlock?: OnceBlockable;
|
||||||
|
oncePoll?: OncePollable;
|
||||||
};
|
};
|
||||||
export declare type FetchJsonResponse = {
|
export declare type FetchJsonResponse = {
|
||||||
statusCode: number;
|
statusCode: number;
|
||||||
|
@ -190,6 +190,9 @@ export function poll(func, options) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (options.oncePoll) {
|
||||||
|
options.oncePoll.once("poll", check);
|
||||||
|
}
|
||||||
else if (options.onceBlock) {
|
else if (options.onceBlock) {
|
||||||
options.onceBlock.once("block", check);
|
options.onceBlock.once("block", check);
|
||||||
// Otherwise, exponential back-off (up to 10s) our next request
|
// Otherwise, exponential back-off (up to 10s) our next request
|
||||||
|
4
packages/web/lib/index.d.ts
vendored
4
packages/web/lib/index.d.ts
vendored
@ -12,6 +12,9 @@ export declare type ConnectionInfo = {
|
|||||||
export interface OnceBlockable {
|
export interface OnceBlockable {
|
||||||
once(eventName: "block", handler: () => void): void;
|
once(eventName: "block", handler: () => void): void;
|
||||||
}
|
}
|
||||||
|
export interface OncePollable {
|
||||||
|
once(eventName: "poll", handler: () => void): void;
|
||||||
|
}
|
||||||
export declare type PollOptions = {
|
export declare type PollOptions = {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
floor?: number;
|
floor?: number;
|
||||||
@ -19,6 +22,7 @@ export declare type PollOptions = {
|
|||||||
interval?: number;
|
interval?: number;
|
||||||
retryLimit?: number;
|
retryLimit?: number;
|
||||||
onceBlock?: OnceBlockable;
|
onceBlock?: OnceBlockable;
|
||||||
|
oncePoll?: OncePollable;
|
||||||
};
|
};
|
||||||
export declare type FetchJsonResponse = {
|
export declare type FetchJsonResponse = {
|
||||||
statusCode: number;
|
statusCode: number;
|
||||||
|
@ -235,6 +235,9 @@ function poll(func, options) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (options.oncePoll) {
|
||||||
|
options.oncePoll.once("poll", check);
|
||||||
|
}
|
||||||
else if (options.onceBlock) {
|
else if (options.onceBlock) {
|
||||||
options.onceBlock.once("block", check);
|
options.onceBlock.once("block", check);
|
||||||
// Otherwise, exponential back-off (up to 10s) our next request
|
// Otherwise, exponential back-off (up to 10s) our next request
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"tarballHash": "0xb65d230f34fff51296199d36c8963829b38d278b9a14f0eefe8dd45f544a1b90",
|
"tarballHash": "0xfc2c320ae603870cf3abd09b8a0f2c42f49821f21194f4bffa8354144eca6693",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
"version": "5.0.0-beta.138"
|
"version": "5.0.0-beta.138"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user