Skip to content

Commit

Permalink
Updated dist files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 30, 2020
1 parent 01a248b commit 1261953
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib.esm/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "providers/5.0.0-beta.168";
export declare const version = "providers/5.0.0-beta.169";
2 changes: 1 addition & 1 deletion lib.esm/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "providers/5.0.0-beta.168";
export const version = "providers/5.0.0-beta.169";
13 changes: 8 additions & 5 deletions lib.esm/base-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,14 @@ export class BaseProvider extends Provider {
network = yield this.detectNetwork();
}
// This should never happen; every Provider sub-class should have
// suggested a network by here (or thrown).
// suggested a network by here (or have thrown).
if (!network) {
logger.throwError("no network detected", Logger.errors.UNKNOWN_ERROR, {});
}
defineReadOnly(this, "_network", network);
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
defineReadOnly(this, "_network", network);
}
}
return this._network;
});
Expand Down Expand Up @@ -732,7 +735,7 @@ export class BaseProvider extends Provider {
return this.formatter.blockWithTransactions(block);
}
return this.formatter.block(block);
}), { onceBlock: this });
}), { oncePoll: this });
});
}
getBlock(blockHashOrBlockTag) {
Expand Down Expand Up @@ -770,7 +773,7 @@ export class BaseProvider extends Provider {
tx.confirmations = confirmations;
}
return this._wrapTransaction(tx);
}), { onceBlock: this });
}), { oncePoll: this });
});
}
getTransactionReceipt(transactionHash) {
Expand Down Expand Up @@ -806,7 +809,7 @@ export class BaseProvider extends Provider {
receipt.confirmations = confirmations;
}
return receipt;
}), { onceBlock: this });
}), { oncePoll: this });
});
}
getLogs(filter) {
Expand Down
20 changes: 17 additions & 3 deletions lib.esm/websocket-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export class WebSocketProvider extends JsonRpcProvider {
console.warn("this should not happen");
}
};
// This Provider does not actually poll, but we want to trigger
// poll events for things that depend on them (like stalling for
// block and transaction lookups)
const fauxPoll = setInterval(() => {
this.emit("poll");
}, 1000);
if (fauxPoll.unref) {
fauxPoll.unref();
}
}
get pollingInterval() {
return 0;
Expand Down Expand Up @@ -149,8 +158,10 @@ export class WebSocketProvider extends JsonRpcProvider {
_startEvent(event) {
switch (event.type) {
case "block":
this._subscribe("block", ["newHeads", {}], (result) => {
this.emit("block", BigNumber.from(result.number).toNumber());
this._subscribe("block", ["newHeads"], (result) => {
const blockNumber = BigNumber.from(result.number).toNumber();
this._emitted.block = blockNumber;
this.emit("block", blockNumber);
});
break;
case "pending":
Expand Down Expand Up @@ -182,13 +193,16 @@ export class WebSocketProvider extends JsonRpcProvider {
// to keep an eye out for transactions we are watching for.
// Starting a subscription for an event (i.e. "tx") that is already
// running is (basically) a nop.
this._subscribe("tx", ["newHeads", {}], (result) => {
this._subscribe("tx", ["newHeads"], (result) => {
this._events.filter((e) => (e.type === "tx")).forEach(emitReceipt);
});
break;
}
// Nothing is needed
case "debug":
case "poll":
case "willPoll":
case "didPoll":
case "error":
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion lib/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "providers/5.0.0-beta.168";
export declare const version = "providers/5.0.0-beta.169";
2 changes: 1 addition & 1 deletion lib/_version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.0-beta.168";
exports.version = "providers/5.0.0-beta.169";
13 changes: 8 additions & 5 deletions lib/base-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,14 @@ var BaseProvider = /** @class */ (function (_super) {
_a.label = 6;
case 6:
// This should never happen; every Provider sub-class should have
// suggested a network by here (or thrown).
// suggested a network by here (or have thrown).
if (!network) {
logger.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {});
}
properties_1.defineReadOnly(this, "_network", network);
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
properties_1.defineReadOnly(this, "_network", network);
}
_a.label = 7;
case 7: return [2 /*return*/, this._network];
}
Expand Down Expand Up @@ -1015,7 +1018,7 @@ var BaseProvider = /** @class */ (function (_super) {
case 8: return [2 /*return*/, this.formatter.block(block)];
}
});
}); }, { onceBlock: this })];
}); }, { oncePoll: this })];
}
});
});
Expand Down Expand Up @@ -1073,7 +1076,7 @@ var BaseProvider = /** @class */ (function (_super) {
case 4: return [2 /*return*/, this._wrapTransaction(tx)];
}
});
}); }, { onceBlock: this })];
}); }, { oncePoll: this })];
}
});
});
Expand Down Expand Up @@ -1129,7 +1132,7 @@ var BaseProvider = /** @class */ (function (_super) {
case 4: return [2 /*return*/, receipt];
}
});
}); }, { onceBlock: this })];
}); }, { oncePoll: this })];
}
});
});
Expand Down
20 changes: 17 additions & 3 deletions lib/websocket-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ var WebSocketProvider = /** @class */ (function (_super) {
console.warn("this should not happen");
}
};
// This Provider does not actually poll, but we want to trigger
// poll events for things that depend on them (like stalling for
// block and transaction lookups)
var fauxPoll = setInterval(function () {
_this.emit("poll");
}, 1000);
if (fauxPoll.unref) {
fauxPoll.unref();
}
return _this;
}
Object.defineProperty(WebSocketProvider.prototype, "pollingInterval", {
Expand Down Expand Up @@ -217,8 +226,10 @@ var WebSocketProvider = /** @class */ (function (_super) {
var _this = this;
switch (event.type) {
case "block":
this._subscribe("block", ["newHeads", {}], function (result) {
_this.emit("block", bignumber_1.BigNumber.from(result.number).toNumber());
this._subscribe("block", ["newHeads"], function (result) {
var blockNumber = bignumber_1.BigNumber.from(result.number).toNumber();
_this._emitted.block = blockNumber;
_this.emit("block", blockNumber);
});
break;
case "pending":
Expand Down Expand Up @@ -250,13 +261,16 @@ var WebSocketProvider = /** @class */ (function (_super) {
// to keep an eye out for transactions we are watching for.
// Starting a subscription for an event (i.e. "tx") that is already
// running is (basically) a nop.
this._subscribe("tx", ["newHeads", {}], function (result) {
this._subscribe("tx", ["newHeads"], function (result) {
_this._events.filter(function (e) { return (e.type === "tx"); }).forEach(emitReceipt_1);
});
break;
}
// Nothing is needed
case "debug":
case "poll":
case "willPoll":
case "didPoll":
case "error":
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x04e34eb73e41646f6dd85015b26d8aa77676d53896f60341d34809deb87f701a",
"tarballHash": "0x2c7517b23e6eb918b668110c930001103934b54b78a357e775e232be9dfc7c25",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.168"
"version": "5.0.0-beta.169"
}
2 changes: 1 addition & 1 deletion src.ts/_version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "providers/5.0.0-beta.168";
export const version = "providers/5.0.0-beta.169";

0 comments on commit 1261953

Please sign in to comment.