Updated dist files.

This commit is contained in:
Richard Moore 2020-06-03 03:47:17 -04:00
parent d2406c42a1
commit ddad98ab32
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
44 changed files with 792 additions and 418 deletions

View File

@ -3,6 +3,13 @@ Changelog
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
ethers/v5.0.0-beta.191 (2020-06-03 03:41)
-----------------------------------------
- Allow undefined properties in transaction object and fix stray this. ([#860](https://github.com/ethers-io/ethers.js/issues/860); [98bb589](https://github.com/ethers-io/ethers.js/commit/98bb58964bec7dff0ccf481d474354ec1ca6f376), [d2406c4](https://github.com/ethers-io/ethers.js/commit/d2406c42a18c123205918eb46bf24de0ff97ee23))
- Allow JsonRpcSigner to override from if it matches Signer. ([#862](https://github.com/ethers-io/ethers.js/issues/862); [1a89c59](https://github.com/ethers-io/ethers.js/commit/1a89c591c26a7fcc2031d0df90137d8a096c5c01))
- Added initial support for spontaneous network changes. ([#495](https://github.com/ethers-io/ethers.js/issues/495), [#861](https://github.com/ethers-io/ethers.js/issues/861); [2bc7bb6](https://github.com/ethers-io/ethers.js/commit/2bc7bb6e61219a40cfe2acd95c115c2195c21223), [d2ca4fb](https://github.com/ethers-io/ethers.js/commit/d2ca4fb443b2653063ca5aa349b52ecd0ff79e2f))
ethers/v5.0.0-beta.190 (2020-06-01 05:02)
-----------------------------------------

View File

@ -10,7 +10,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
accessing addresses aligned autofill called cancelled changed censored
compiled computed configured consumed creating decoded decoding
decrypt decrypted decrypting deployed deploying deprecated detected
discontinued earliest email enabled encoded encoding encrypt
@ -47,7 +47,7 @@ callback calldata checksum ciphertext cli codepoint config
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 mm multihash nfc
nfkc nfd nfkd nodehash oob opcode pbkdf pc plugin pragma pre prf
nfkc nfd nfkd nodehash nullish 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 yyyy zlib

View File

@ -1 +1 @@
export declare const version = "contracts/5.0.0-beta.155";
export declare const version = "contracts/5.0.0-beta.156";

View File

@ -1 +1 @@
export const version = "contracts/5.0.0-beta.155";
export const version = "contracts/5.0.0-beta.156";

View File

@ -149,7 +149,7 @@ function populateTransaction(contract, fragment, args) {
delete overrides.value;
// Make sure there are no stray overrides, which may indicate a
// typo or using an unsupported key.
const leftovers = Object.keys(overrides);
const leftovers = Object.keys(overrides).filter((key) => (overrides[key] != null));
if (leftovers.length) {
logger.throwError(`cannot override ${leftovers.map((l) => JSON.stringify(l)).join(",")}`, Logger.errors.UNSUPPORTED_OPERATION, {
operation: "overrides",
@ -188,10 +188,10 @@ function buildCall(contract, fragment, collapseSimple) {
let blockTag = undefined;
if (args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
const overrides = shallowCopy(args.pop());
if (overrides.blockTag) {
if (overrides.blockTag != null) {
blockTag = yield overrides.blockTag;
delete overrides.blockTag;
}
delete overrides.blockTag;
args.push(overrides);
}
// If the contract was just deployed, wait until it is mined
@ -248,7 +248,7 @@ function buildSend(contract, fragment) {
if (parsed) {
event.args = parsed.args;
event.decode = (data, topics) => {
return this.interface.decodeEventLog(parsed.eventFragment, data, topics);
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
};
event.event = parsed.name;
event.eventSignature = parsed.signature;

View File

@ -1 +1 @@
export declare const version = "contracts/5.0.0-beta.155";
export declare const version = "contracts/5.0.0-beta.156";

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "contracts/5.0.0-beta.155";
exports.version = "contracts/5.0.0-beta.156";

View File

@ -208,7 +208,7 @@ function populateTransaction(contract, fragment, args) {
delete overrides.gasPrice;
delete overrides.from;
delete overrides.value;
leftovers = Object.keys(overrides);
leftovers = Object.keys(overrides).filter(function (key) { return (overrides[key] != null); });
if (leftovers.length) {
logger.throwError("cannot override " + leftovers.map(function (l) { return JSON.stringify(l); }).join(","), logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "overrides",
@ -275,13 +275,13 @@ function buildCall(contract, fragment, collapseSimple) {
blockTag = undefined;
if (!(args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object")) return [3 /*break*/, 3];
overrides = properties_1.shallowCopy(args.pop());
if (!overrides.blockTag) return [3 /*break*/, 2];
if (!(overrides.blockTag != null)) return [3 /*break*/, 2];
return [4 /*yield*/, overrides.blockTag];
case 1:
blockTag = _a.sent();
delete overrides.blockTag;
_a.label = 2;
case 2:
delete overrides.blockTag;
args.push(overrides);
_a.label = 3;
case 3:
@ -325,7 +325,6 @@ function buildSend(contract, fragment) {
}
return __awaiter(this, void 0, void 0, function () {
var txRequest, tx, wait;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@ -359,7 +358,7 @@ function buildSend(contract, fragment) {
if (parsed) {
event.args = parsed.args;
event.decode = function (data, topics) {
return _this.interface.decodeEventLog(parsed.eventFragment, data, topics);
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
};
event.event = parsed.name;
event.eventSignature = parsed.signature;

View File

@ -31,7 +31,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0xccc2bced42f75b771c52745a7f9736b37b1adbb9d4e67c694c143422fe1e6ad4",
"tarballHash": "0x1f5752f4056760cac39b4b5229a082a135170ea8f65f49a949c3228e89fba1a2",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.155"
"version": "5.0.0-beta.156"
}

View File

@ -1 +1 @@
export const version = "contracts/5.0.0-beta.155";
export const version = "contracts/5.0.0-beta.156";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8192,7 +8192,7 @@ class VoidSigner extends Signer {
}
}
const version$b = "contracts/5.0.0-beta.155";
const version$b = "contracts/5.0.0-beta.156";
"use strict";
var __awaiter$2 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
@ -8334,7 +8334,7 @@ function populateTransaction(contract, fragment, args) {
delete overrides.value;
// Make sure there are no stray overrides, which may indicate a
// typo or using an unsupported key.
const leftovers = Object.keys(overrides);
const leftovers = Object.keys(overrides).filter((key) => (overrides[key] != null));
if (leftovers.length) {
logger$f.throwError(`cannot override ${leftovers.map((l) => JSON.stringify(l)).join(",")}`, Logger.errors.UNSUPPORTED_OPERATION, {
operation: "overrides",
@ -8373,10 +8373,10 @@ function buildCall(contract, fragment, collapseSimple) {
let blockTag = undefined;
if (args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object") {
const overrides = shallowCopy(args.pop());
if (overrides.blockTag) {
if (overrides.blockTag != null) {
blockTag = yield overrides.blockTag;
delete overrides.blockTag;
}
delete overrides.blockTag;
args.push(overrides);
}
// If the contract was just deployed, wait until it is mined
@ -8433,7 +8433,7 @@ function buildSend(contract, fragment) {
if (parsed) {
event.args = parsed.args;
event.decode = (data, topics) => {
return this.interface.decodeEventLog(parsed.eventFragment, data, topics);
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
};
event.event = parsed.name;
event.eventSignature = parsed.signature;
@ -16141,7 +16141,7 @@ function poll(func, options) {
});
}
const version$m = "providers/5.0.0-beta.170";
const version$m = "providers/5.0.0-beta.171";
"use strict";
const logger$q = new Logger(version$m);
@ -16604,18 +16604,26 @@ function getEventTag$1(eventName) {
function getTime() {
return (new Date()).getTime();
}
function stall(duration) {
return new Promise((resolve) => {
setTimeout(resolve, duration);
});
}
//////////////////////////////
// Provider Object
/**
* EventType
* - "block"
* - "poll"
* - "didPoll"
* - "pending"
* - "error"
* - "network"
* - filter
* - topics array
* - transaction hash
*/
const PollableEvents = ["block", "network", "pending", "poll"];
class Event {
constructor(tag, listener, once) {
defineReadOnly(this, "tag", tag);
@ -16658,7 +16666,7 @@ class Event {
return filter;
}
pollable() {
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
}
}
let defaultFormatter = null;
@ -16676,16 +16684,29 @@ class BaseProvider extends Provider {
constructor(network) {
logger$r.checkNew(new.target, Provider);
super();
// Events being listened to
this._events = [];
this._emitted = { block: -2 };
this.formatter = new.target.getFormatter();
// If network is any, this Provider allows the underlying
// network to change dynamically, and we auto-detect the
// current network
defineReadOnly(this, "anyNetwork", (network === "any"));
if (this.anyNetwork) {
network = this.detectNetwork();
}
if (network instanceof Promise) {
this._networkPromise = network;
// Squash any "unhandled promise" errors; that do not need to be handled
network.catch((error) => { });
// Trigger initial network setting (async)
this._ready();
}
else {
const knownNetwork = getStatic((new.target), "getNetwork")(network);
if (knownNetwork) {
defineReadOnly(this, "_network", knownNetwork);
this.emit("network", knownNetwork, null);
}
else {
logger$r.throwArgumentError("invalid network", "network", network);
@ -16693,10 +16714,7 @@ class BaseProvider extends Provider {
}
this._maxInternalBlockNumber = -1024;
this._lastBlockNumber = -2;
// Events being listened to
this._events = [];
this._pollingInterval = 4000;
this._emitted = { block: -2 };
this._fastQueryDate = 0;
}
_ready() {
@ -16720,31 +16738,37 @@ class BaseProvider extends Provider {
}
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
defineReadOnly(this, "_network", network);
if (this.anyNetwork) {
this._network = network;
}
else {
defineReadOnly(this, "_network", network);
}
this.emit("network", network, null);
}
}
return this._network;
});
}
// This will always return the most recently established network.
// For "any", this can change (a "network" event is emitted before
// any change is refelcted); otherwise this cannot change
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"
});
});
}
// @TODO: Remove this and just create a singleton formatter
static getFormatter() {
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
}
return defaultFormatter;
}
// @TODO: Remove this and just use getNetwork
static getNetwork(network) {
return getNetwork((network == null) ? "homestead" : network);
}
// Fetches the blockNumber, but will reuse any result that is less
// than maxAge old or has been requested since the last request
_getInternalBlockNumber(maxAge) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
@ -16756,7 +16780,17 @@ class BaseProvider extends Provider {
}
}
const reqTime = getTime();
this._internalBlockNumber = this.perform("getBlockNumber", {}).then((blockNumber) => {
const checkInternalBlockNumber = resolveProperties({
blockNumber: this.perform("getBlockNumber", {}),
networkError: this.getNetwork().then((network) => (null), (error) => (error))
}).then(({ blockNumber, networkError }) => {
if (networkError) {
// Unremember this bad internal block number
if (this._internalBlockNumber === checkInternalBlockNumber) {
this._internalBlockNumber = null;
}
throw networkError;
}
const respTime = getTime();
blockNumber = BigNumber.from(blockNumber).toNumber();
if (blockNumber < this._maxInternalBlockNumber) {
@ -16766,13 +16800,13 @@ class BaseProvider extends Provider {
this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
return { blockNumber, reqTime, respTime };
});
return (yield this._internalBlockNumber).blockNumber;
this._internalBlockNumber = checkInternalBlockNumber;
return (yield checkInternalBlockNumber).blockNumber;
});
}
poll() {
return __awaiter$6(this, void 0, void 0, function* () {
const pollId = nextPollId++;
this.emit("willPoll", pollId);
// Track all running promises, so we can trigger a post-poll once they are complete
const runners = [];
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
@ -16788,9 +16822,19 @@ class BaseProvider extends Provider {
if (this._emitted.block === -2) {
this._emitted.block = blockNumber - 1;
}
// Notify all listener for each block that has passed
for (let i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
logger$r.warn("network block skew detected; skipping block events");
this.emit("error", logger$r.makeError("network block skew detected", Logger.errors.NETWORK_ERROR, {
blockNumber: blockNumber,
previousBlockNumber: this._emitted.block
}));
this.emit("block", blockNumber);
}
else {
// Notify all listener for each block that has passed
for (let i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
}
}
// The emitted block was updated, check for obsolete events
if (this._emitted.block !== blockNumber) {
@ -16855,12 +16899,14 @@ class BaseProvider extends Provider {
}
});
this._lastBlockNumber = blockNumber;
// Once all events for this loop have been processed, emit "didPoll"
Promise.all(runners).then(() => {
this.emit("didPoll", pollId);
});
return null;
});
}
// Deprecated; do not use this
resetEventsBlock(blockNumber) {
this._lastBlockNumber = blockNumber - 1;
if (this.polling) {
@ -16870,8 +16916,52 @@ class BaseProvider extends Provider {
get network() {
return this._network;
}
// This method should query the network if the underlying network
// can change, such as when connected to a JSON-RPC backend
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"
});
});
}
getNetwork() {
return this.ready;
return __awaiter$6(this, void 0, void 0, function* () {
const network = yield this.ready;
// Make sure we are still connected to the same network; this is
// only an external call for backends which can have the underlying
// network change spontaneously
const currentNetwork = yield this.detectNetwork();
if (network.chainId !== currentNetwork.chainId) {
// We are allowing network changes, things can get complex fast;
// make sure you know what you are doing if you use "any"
if (this.anyNetwork) {
this._network = currentNetwork;
// Reset all internal block number guards and caches
this._lastBlockNumber = -2;
this._fastBlockNumber = null;
this._fastBlockNumberPromise = null;
this._fastQueryDate = 0;
this._emitted.block = -2;
this._maxInternalBlockNumber = -1024;
this._internalBlockNumber = null;
// The "network" event MUST happen before this method resolves
// so any events have a chance to unregister, so we stall an
// additional event loop before returning from /this/ call
this.emit("network", currentNetwork, network);
yield stall(0);
return this._network;
}
const error = logger$r.makeError("underlying network changed", Logger.errors.NETWORK_ERROR, {
event: "changed",
network: network,
detectedNetwork: currentNetwork
});
this.emit("error", error);
throw error;
}
return network;
});
}
get blockNumber() {
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => {
@ -16947,8 +17037,6 @@ class BaseProvider extends Provider {
this._fastBlockNumberPromise = Promise.resolve(blockNumber);
}
}
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
// this will be used once we move to the WebSocket or other alternatives to polling
waitForTransaction(transactionHash, confirmations, timeout) {
return __awaiter$6(this, void 0, void 0, function* () {
if (confirmations == null) {
@ -16996,17 +17084,19 @@ class BaseProvider extends Provider {
});
}
getBlockNumber() {
return this._getInternalBlockNumber(0);
return __awaiter$6(this, void 0, void 0, function* () {
return this._getInternalBlockNumber(0);
});
}
getGasPrice() {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
return BigNumber.from(yield this.perform("getGasPrice", {}));
});
}
getBalance(addressOrName, blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -17016,7 +17106,7 @@ class BaseProvider extends Provider {
}
getTransactionCount(addressOrName, blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -17026,7 +17116,7 @@ class BaseProvider extends Provider {
}
getCode(addressOrName, blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -17036,7 +17126,7 @@ class BaseProvider extends Provider {
}
getStorageAt(addressOrName, position, blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag),
@ -17082,7 +17172,7 @@ class BaseProvider extends Provider {
}
sendTransaction(signedTransaction) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const hexTx = yield Promise.resolve(signedTransaction).then(t => hexlify(t));
const tx = this.formatter.transaction(signedTransaction);
try {
@ -17123,9 +17213,7 @@ class BaseProvider extends Provider {
}
_getFilter(filter) {
return __awaiter$6(this, void 0, void 0, function* () {
if (filter instanceof Promise) {
filter = yield filter;
}
filter = yield filter;
const result = {};
if (filter.address != null) {
result.address = this._getAddress(filter.address);
@ -17147,7 +17235,7 @@ class BaseProvider extends Provider {
}
call(transaction, blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
transaction: this._getTransactionRequest(transaction),
blockTag: this._getBlockTag(blockTag)
@ -17157,7 +17245,7 @@ class BaseProvider extends Provider {
}
estimateGas(transaction) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
transaction: this._getTransactionRequest(transaction)
});
@ -17177,10 +17265,8 @@ class BaseProvider extends Provider {
}
_getBlock(blockHashOrBlockTag, includeTransactions) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
if (blockHashOrBlockTag instanceof Promise) {
blockHashOrBlockTag = yield blockHashOrBlockTag;
}
yield this.getNetwork();
blockHashOrBlockTag = yield blockHashOrBlockTag;
// If blockTag is a number (not "latest", etc), this is the block number
let blockNumber = -128;
const params = {
@ -17255,10 +17341,8 @@ class BaseProvider extends Provider {
}
getTransaction(transactionHash) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
if (transactionHash instanceof Promise) {
transactionHash = yield transactionHash;
}
yield this.getNetwork();
transactionHash = yield transactionHash;
const params = { transactionHash: this.formatter.hash(transactionHash, true) };
return poll(() => __awaiter$6(this, void 0, void 0, function* () {
const result = yield this.perform("getTransaction", params);
@ -17287,10 +17371,8 @@ class BaseProvider extends Provider {
}
getTransactionReceipt(transactionHash) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
if (transactionHash instanceof Promise) {
transactionHash = yield transactionHash;
}
yield this.getNetwork();
transactionHash = yield transactionHash;
const params = { transactionHash: this.formatter.hash(transactionHash, true) };
return poll(() => __awaiter$6(this, void 0, void 0, function* () {
const result = yield this.perform("getTransactionReceipt", params);
@ -17323,7 +17405,7 @@ class BaseProvider extends Provider {
}
getLogs(filter) {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({ filter: this._getFilter(filter) });
const logs = yield this.perform("getLogs", params);
logs.forEach((log) => {
@ -17336,15 +17418,13 @@ class BaseProvider extends Provider {
}
getEtherPrice() {
return __awaiter$6(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
return this.perform("getEtherPrice", {});
});
}
_getBlockTag(blockTag) {
return __awaiter$6(this, void 0, void 0, function* () {
if (blockTag instanceof Promise) {
blockTag = yield blockTag;
}
blockTag = yield blockTag;
if (typeof (blockTag) === "number" && blockTag < 0) {
if (blockTag % 1) {
logger$r.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
@ -17377,9 +17457,7 @@ class BaseProvider extends Provider {
}
resolveName(name) {
return __awaiter$6(this, void 0, void 0, function* () {
if (name instanceof Promise) {
name = yield name;
}
name = yield name;
// If it is already an address, nothing to resolve
try {
return Promise.resolve(this.formatter.address(name));
@ -17408,9 +17486,7 @@ class BaseProvider extends Provider {
}
lookupAddress(address) {
return __awaiter$6(this, void 0, void 0, function* () {
if (address instanceof Promise) {
address = yield address;
}
address = yield address;
address = this.formatter.address(address);
const reverseName = address.substring(2).toLowerCase() + ".addr.reverse";
const resolverAddress = yield this._getResolver(reverseName);
@ -17568,7 +17644,7 @@ function timer(timeout) {
function getResult(payload) {
if (payload.error) {
// @TODO: not any
let error = new Error(payload.error.message);
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
throw error;
@ -17628,7 +17704,7 @@ class JsonRpcSigner extends Signer {
}
sendUncheckedTransaction(transaction) {
transaction = shallowCopy(transaction);
let fromAddress = this.getAddress().then((address) => {
const fromAddress = this.getAddress().then((address) => {
if (address) {
address = address.toLowerCase();
}
@ -17638,17 +17714,23 @@ class JsonRpcSigner extends Signer {
// wishes to use this, it is easy to specify explicitly, otherwise
// we look it up for them.
if (transaction.gasLimit == null) {
let estimate = shallowCopy(transaction);
const estimate = shallowCopy(transaction);
estimate.from = fromAddress;
transaction.gasLimit = this.provider.estimateGas(estimate);
}
return Promise.all([
resolveProperties(transaction),
fromAddress
]).then((results) => {
let tx = results[0];
let hexTx = this.provider.constructor.hexlifyTransaction(tx);
hexTx.from = results[1];
return resolveProperties({
tx: resolveProperties(transaction),
sender: fromAddress
}).then(({ tx, sender }) => {
if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) {
logger$s.throwArgumentError("from address mismatch", "transaction", transaction);
}
}
else {
tx.from = sender;
}
const hexTx = this.provider.constructor.hexlifyTransaction(tx, { from: true });
return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => {
return hash;
}, (error) => {
@ -17695,14 +17777,14 @@ class JsonRpcSigner extends Signer {
});
}
signMessage(message) {
let data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message);
const data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message);
return this.getAddress().then((address) => {
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
return this.provider.send("eth_sign", [address.toLowerCase(), hexlify(data)]);
});
}
unlock(password) {
let provider = this.provider;
const provider = this.provider;
return this.getAddress().then(function (address) {
return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]);
});
@ -17803,7 +17885,7 @@ class JsonRpcProvider extends BaseProvider {
});
}
send(method, params) {
let request = {
const request = {
method: method,
params: params,
id: (this._nextId++),
@ -17915,8 +17997,8 @@ class JsonRpcProvider extends BaseProvider {
if (this._pendingFilter != null) {
return;
}
let self = this;
let pendingFilter = this.send("eth_newPendingTransactionFilter", []);
const self = this;
const pendingFilter = this.send("eth_newPendingTransactionFilter", []);
this._pendingFilter = pendingFilter;
pendingFilter.then(function (filterId) {
function poll() {
@ -17970,7 +18052,7 @@ class JsonRpcProvider extends BaseProvider {
// Check only allowed properties are given
const allowed = shallowCopy(allowedTransactionKeys$3);
if (allowExtra) {
for (let key in allowExtra) {
for (const key in allowExtra) {
if (allowExtra[key]) {
allowed[key] = true;
}
@ -18554,7 +18636,7 @@ function serialize$1(value) {
// Next request ID to use for emitting debug info
let nextRid = 1;
;
function stall(duration) {
function stall$1(duration) {
let cancel = null;
let timer = null;
let promise = (new Promise((resolve) => {
@ -18893,7 +18975,7 @@ class FallbackProvider extends BaseProvider {
const config = configs[i++];
const rid = nextRid++;
config.start = now();
config.staller = stall(config.stallTimeout);
config.staller = stall$1(config.stallTimeout);
config.staller.wait(() => { config.staller = null; });
config.runner = getRunner(config, currentBlockNumber, method, params).then((result) => {
config.done = true;
@ -18961,7 +19043,7 @@ class FallbackProvider extends BaseProvider {
return result;
}
if (!first) {
yield stall(100).getPromise();
yield stall$1(100).getPromise();
}
first = false;
}
@ -18999,7 +19081,7 @@ var browserIpcProvider = {
var _version$2 = createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.0-beta.170";
exports.version = "providers/5.0.0-beta.171";
});
var _version$3 = unwrapExports(_version$2);
@ -19060,6 +19142,12 @@ let NextId = 1;
// https://geth.ethereum.org/docs/rpc/pubsub
class WebSocketProvider extends JsonRpcProvider {
constructor(url, network) {
// This will be added in the future; please open an issue to expedite
if (network === "any") {
logger$y.throwError("WebSocketProvider does not support 'any' network yet", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "network:any"
});
}
super(url, network);
this._pollingInterval = -1;
defineReadOnly(this, "_websocket", new WebSocket$1(this.connection.url));
@ -19773,7 +19861,7 @@ var utils$1 = /*#__PURE__*/Object.freeze({
Indexed: Indexed
});
const version$o = "ethers/5.0.0-beta.190";
const version$o = "ethers/5.0.0-beta.191";
"use strict";
const logger$E = new Logger(version$o);

File diff suppressed because one or more lines are too long

View File

@ -9228,7 +9228,7 @@
var _version$m = createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "contracts/5.0.0-beta.155";
exports.version = "contracts/5.0.0-beta.156";
});
var _version$n = unwrapExports(_version$m);
@ -9445,7 +9445,7 @@
delete overrides.gasPrice;
delete overrides.from;
delete overrides.value;
leftovers = Object.keys(overrides);
leftovers = Object.keys(overrides).filter(function (key) { return (overrides[key] != null); });
if (leftovers.length) {
logger.throwError("cannot override " + leftovers.map(function (l) { return JSON.stringify(l); }).join(","), lib.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "overrides",
@ -9512,13 +9512,13 @@
blockTag = undefined;
if (!(args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object")) return [3 /*break*/, 3];
overrides = lib$3.shallowCopy(args.pop());
if (!overrides.blockTag) return [3 /*break*/, 2];
if (!(overrides.blockTag != null)) return [3 /*break*/, 2];
return [4 /*yield*/, overrides.blockTag];
case 1:
blockTag = _a.sent();
delete overrides.blockTag;
_a.label = 2;
case 2:
delete overrides.blockTag;
args.push(overrides);
_a.label = 3;
case 3:
@ -9562,7 +9562,6 @@
}
return __awaiter(this, void 0, void 0, function () {
var txRequest, tx, wait;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@ -9596,7 +9595,7 @@
if (parsed) {
event.args = parsed.args;
event.decode = function (data, topics) {
return _this.interface.decodeEventLog(parsed.eventFragment, data, topics);
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics);
};
event.event = parsed.name;
event.eventSignature = parsed.signature;
@ -17953,7 +17952,7 @@
var _version$I = createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.0-beta.170";
exports.version = "providers/5.0.0-beta.171";
});
var _version$J = unwrapExports(_version$I);
@ -18492,18 +18491,26 @@
function getTime() {
return (new Date()).getTime();
}
function stall(duration) {
return new Promise(function (resolve) {
setTimeout(resolve, duration);
});
}
//////////////////////////////
// Provider Object
/**
* EventType
* - "block"
* - "poll"
* - "didPoll"
* - "pending"
* - "error"
* - "network"
* - filter
* - topics array
* - transaction hash
*/
var PollableEvents = ["block", "network", "pending", "poll"];
var Event = /** @class */ (function () {
function Event(tag, listener, once) {
lib$3.defineReadOnly(this, "tag", tag);
@ -18562,7 +18569,7 @@
configurable: true
});
Event.prototype.pollable = function () {
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
};
return Event;
}());
@ -18585,16 +18592,29 @@
var _this = this;
logger.checkNew(_newTarget, lib$b.Provider);
_this = _super.call(this) || this;
// Events being listened to
_this._events = [];
_this._emitted = { block: -2 };
_this.formatter = _newTarget.getFormatter();
// If network is any, this Provider allows the underlying
// network to change dynamically, and we auto-detect the
// current network
lib$3.defineReadOnly(_this, "anyNetwork", (network === "any"));
if (_this.anyNetwork) {
network = _this.detectNetwork();
}
if (network instanceof Promise) {
_this._networkPromise = network;
// Squash any "unhandled promise" errors; that do not need to be handled
network.catch(function (error) { });
// Trigger initial network setting (async)
_this._ready();
}
else {
var knownNetwork = lib$3.getStatic((_newTarget), "getNetwork")(network);
if (knownNetwork) {
lib$3.defineReadOnly(_this, "_network", knownNetwork);
_this.emit("network", knownNetwork, null);
}
else {
logger.throwArgumentError("invalid network", "network", network);
@ -18602,10 +18622,7 @@
}
_this._maxInternalBlockNumber = -1024;
_this._lastBlockNumber = -2;
// Events being listened to
_this._events = [];
_this._pollingInterval = 4000;
_this._emitted = { block: -2 };
_this._fastQueryDate = 0;
return _this;
}
@ -18642,7 +18659,13 @@
}
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
lib$3.defineReadOnly(this, "_network", network);
if (this.anyNetwork) {
this._network = network;
}
else {
lib$3.defineReadOnly(this, "_network", network);
}
this.emit("network", network, null);
}
_a.label = 7;
case 7: return [2 /*return*/, this._network];
@ -18651,33 +18674,31 @@
});
};
Object.defineProperty(BaseProvider.prototype, "ready", {
// This will always return the most recently established network.
// For "any", this can change (a "network" event is emitted before
// any change is refelcted); otherwise this cannot change
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", lib.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "provider.detectNetwork"
})];
});
});
};
// @TODO: Remove this and just create a singleton formatter
BaseProvider.getFormatter = function () {
if (defaultFormatter == null) {
defaultFormatter = new formatter.Formatter();
}
return defaultFormatter;
};
// @TODO: Remove this and just use getNetwork
BaseProvider.getNetwork = function (network) {
return lib$k.getNetwork((network == null) ? "homestead" : network);
};
// Fetches the blockNumber, but will reuse any result that is less
// than maxAge old or has been requested since the last request
BaseProvider.prototype._getInternalBlockNumber = function (maxAge) {
return __awaiter(this, void 0, void 0, function () {
var internalBlockNumber, result, reqTime;
var internalBlockNumber, result, reqTime, checkInternalBlockNumber;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
@ -18695,7 +18716,18 @@
_a.label = 3;
case 3:
reqTime = getTime();
this._internalBlockNumber = this.perform("getBlockNumber", {}).then(function (blockNumber) {
checkInternalBlockNumber = lib$3.resolveProperties({
blockNumber: this.perform("getBlockNumber", {}),
networkError: this.getNetwork().then(function (network) { return (null); }, function (error) { return (error); })
}).then(function (_a) {
var blockNumber = _a.blockNumber, networkError = _a.networkError;
if (networkError) {
// Unremember this bad internal block number
if (_this._internalBlockNumber === checkInternalBlockNumber) {
_this._internalBlockNumber = null;
}
throw networkError;
}
var respTime = getTime();
blockNumber = lib$2.BigNumber.from(blockNumber).toNumber();
if (blockNumber < _this._maxInternalBlockNumber) {
@ -18705,7 +18737,8 @@
_this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
return { blockNumber: blockNumber, reqTime: reqTime, respTime: respTime };
});
return [4 /*yield*/, this._internalBlockNumber];
this._internalBlockNumber = checkInternalBlockNumber;
return [4 /*yield*/, checkInternalBlockNumber];
case 4: return [2 /*return*/, (_a.sent()).blockNumber];
}
});
@ -18719,7 +18752,6 @@
switch (_a.label) {
case 0:
pollId = nextPollId++;
this.emit("willPoll", pollId);
runners = [];
return [4 /*yield*/, this._getInternalBlockNumber(100 + this.pollingInterval / 2)];
case 1:
@ -18736,9 +18768,19 @@
if (this._emitted.block === -2) {
this._emitted.block = blockNumber - 1;
}
// Notify all listener for each block that has passed
for (i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
logger.warn("network block skew detected; skipping block events");
this.emit("error", logger.makeError("network block skew detected", lib.Logger.errors.NETWORK_ERROR, {
blockNumber: blockNumber,
previousBlockNumber: this._emitted.block
}));
this.emit("block", blockNumber);
}
else {
// Notify all listener for each block that has passed
for (i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
}
}
// The emitted block was updated, check for obsolete events
if (this._emitted.block !== blockNumber) {
@ -18803,6 +18845,7 @@
}
});
this._lastBlockNumber = blockNumber;
// Once all events for this loop have been processed, emit "didPoll"
Promise.all(runners).then(function () {
_this.emit("didPoll", pollId);
});
@ -18811,6 +18854,7 @@
});
});
};
// Deprecated; do not use this
BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
this._lastBlockNumber = blockNumber - 1;
if (this.polling) {
@ -18824,8 +18868,59 @@
enumerable: true,
configurable: true
});
// This method should query the network if the underlying network
// can change, such as when connected to a JSON-RPC backend
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", lib.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "provider.detectNetwork"
})];
});
});
};
BaseProvider.prototype.getNetwork = function () {
return this.ready;
return __awaiter(this, void 0, void 0, function () {
var network, currentNetwork, error;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 1:
network = _a.sent();
return [4 /*yield*/, this.detectNetwork()];
case 2:
currentNetwork = _a.sent();
if (!(network.chainId !== currentNetwork.chainId)) return [3 /*break*/, 5];
if (!this.anyNetwork) return [3 /*break*/, 4];
this._network = currentNetwork;
// Reset all internal block number guards and caches
this._lastBlockNumber = -2;
this._fastBlockNumber = null;
this._fastBlockNumberPromise = null;
this._fastQueryDate = 0;
this._emitted.block = -2;
this._maxInternalBlockNumber = -1024;
this._internalBlockNumber = null;
// The "network" event MUST happen before this method resolves
// so any events have a chance to unregister, so we stall an
// additional event loop before returning from /this/ call
this.emit("network", currentNetwork, network);
return [4 /*yield*/, stall(0)];
case 3:
_a.sent();
return [2 /*return*/, this._network];
case 4:
error = logger.makeError("underlying network changed", lib.Logger.errors.NETWORK_ERROR, {
event: "changed",
network: network,
detectedNetwork: currentNetwork
});
this.emit("error", error);
throw error;
case 5: return [2 /*return*/, network];
}
});
});
};
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
get: function () {
@ -18917,8 +19012,6 @@
this._fastBlockNumberPromise = Promise.resolve(blockNumber);
}
};
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
// this will be used once we move to the WebSocket or other alternatives to polling
BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations, timeout) {
return __awaiter(this, void 0, void 0, function () {
var receipt;
@ -18975,14 +19068,18 @@
});
};
BaseProvider.prototype.getBlockNumber = function () {
return this._getInternalBlockNumber(0);
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._getInternalBlockNumber(0)];
});
});
};
BaseProvider.prototype.getGasPrice = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
_b = (_a = lib$2.BigNumber).from;
@ -18997,7 +19094,7 @@
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19018,7 +19115,7 @@
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19039,7 +19136,7 @@
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19060,7 +19157,7 @@
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19126,7 +19223,7 @@
var hexTx, tx, hash, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [4 /*yield*/, Promise.resolve(signedTransaction).then(function (t) { return lib$1.hexlify(t); })];
@ -19191,13 +19288,9 @@
var _this = this;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!(filter instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, filter];
case 0: return [4 /*yield*/, filter];
case 1:
filter = _c.sent();
_c.label = 2;
case 2:
result = {};
if (filter.address != null) {
result.address = this._getAddress(filter.address);
@ -19216,7 +19309,7 @@
});
_b = (_a = this.formatter).filter;
return [4 /*yield*/, lib$3.resolveProperties(result)];
case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
}
});
});
@ -19226,7 +19319,7 @@
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19247,7 +19340,7 @@
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, lib$3.resolveProperties({
@ -19286,38 +19379,35 @@
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_d.sent();
if (!(blockHashOrBlockTag instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, blockHashOrBlockTag];
case 2:
blockHashOrBlockTag = _d.sent();
_d.label = 3;
case 3:
blockNumber = -128;
params = {
includeTransactions: !!includeTransactions
};
if (!lib$1.isHexString(blockHashOrBlockTag, 32)) return [3 /*break*/, 4];
if (!lib$1.isHexString(blockHashOrBlockTag, 32)) return [3 /*break*/, 3];
params.blockHash = blockHashOrBlockTag;
return [3 /*break*/, 7];
case 4:
_d.trys.push([4, 6, , 7]);
return [3 /*break*/, 6];
case 3:
_d.trys.push([3, 5, , 6]);
_a = params;
_c = (_b = this.formatter).blockTag;
return [4 /*yield*/, this._getBlockTag(blockHashOrBlockTag)];
case 5:
case 4:
_a.blockTag = _c.apply(_b, [_d.sent()]);
if (lib$1.isHexString(params.blockTag)) {
blockNumber = parseInt(params.blockTag.substring(2), 16);
}
return [3 /*break*/, 7];
case 6:
return [3 /*break*/, 6];
case 5:
error_3 = _d.sent();
logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag);
return [3 /*break*/, 7];
case 7: return [2 /*return*/, lib$l.poll(function () { return __awaiter(_this, void 0, void 0, function () {
return [3 /*break*/, 6];
case 6: return [2 /*return*/, lib$l.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var block, blockNumber_1, i, tx, confirmations;
return __generator(this, function (_a) {
switch (_a.label) {
@ -19391,15 +19481,12 @@
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
if (!(transactionHash instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, transactionHash];
case 2:
transactionHash = _a.sent();
_a.label = 3;
case 3:
params = { transactionHash: this.formatter.hash(transactionHash, true) };
return [2 /*return*/, lib$l.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var result, tx, blockNumber, confirmations;
@ -19443,15 +19530,12 @@
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
if (!(transactionHash instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, transactionHash];
case 2:
transactionHash = _a.sent();
_a.label = 3;
case 3:
params = { transactionHash: this.formatter.hash(transactionHash, true) };
return [2 /*return*/, lib$l.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var result, receipt, blockNumber, confirmations;
@ -19498,7 +19582,7 @@
var params, logs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [4 /*yield*/, lib$3.resolveProperties({ filter: this._getFilter(filter) })];
@ -19521,7 +19605,7 @@
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [2 /*return*/, this.perform("getEtherPrice", {})];
@ -19534,26 +19618,22 @@
var blockNumber;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(blockTag instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, blockTag];
case 0: return [4 /*yield*/, blockTag];
case 1:
blockTag = _a.sent();
_a.label = 2;
case 2:
if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 4];
if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 3];
if (blockTag % 1) {
logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
}
return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
case 3:
case 2:
blockNumber = _a.sent();
blockNumber += blockTag;
if (blockNumber < 0) {
blockNumber = 0;
}
return [2 /*return*/, this.formatter.blockTag(blockNumber)];
case 4: return [2 /*return*/, this.formatter.blockTag(blockTag)];
case 3: return [2 /*return*/, this.formatter.blockTag(blockTag)];
}
});
});
@ -19586,13 +19666,9 @@
var resolverAddress, transaction, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!(name instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, name];
case 0: return [4 /*yield*/, name];
case 1:
name = _c.sent();
_c.label = 2;
case 2:
// If it is already an address, nothing to resolve
try {
return [2 /*return*/, Promise.resolve(this.formatter.address(name))];
@ -19607,7 +19683,7 @@
logger.throwArgumentError("invalid ENS name", "name", name);
}
return [4 /*yield*/, this._getResolver(name)];
case 3:
case 2:
resolverAddress = _c.sent();
if (!resolverAddress) {
return [2 /*return*/, null];
@ -19618,7 +19694,7 @@
};
_b = (_a = this.formatter).callAddress;
return [4 /*yield*/, this.call(transaction)];
case 4: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
}
});
});
@ -19628,17 +19704,13 @@
var reverseName, resolverAddress, bytes, _a, length, name, addr;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(address instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, address];
case 0: return [4 /*yield*/, address];
case 1:
address = _b.sent();
_b.label = 2;
case 2:
address = this.formatter.address(address);
reverseName = address.substring(2).toLowerCase() + ".addr.reverse";
return [4 /*yield*/, this._getResolver(reverseName)];
case 3:
case 2:
resolverAddress = _b.sent();
if (!resolverAddress) {
return [2 /*return*/, null];
@ -19648,7 +19720,7 @@
to: resolverAddress,
data: ("0x691f3431" + lib$9.namehash(reverseName).substring(2))
})];
case 4:
case 3:
bytes = _a.apply(void 0, [_b.sent()]);
// Strip off the dynamic string pointer (0x20)
if (bytes.length < 32 || !lib$2.BigNumber.from(bytes.slice(0, 32)).eq(32)) {
@ -19667,7 +19739,7 @@
}
name = lib$8.toUtf8String(bytes.slice(0, length));
return [4 /*yield*/, this.resolveName(name)];
case 5:
case 4:
addr = _b.sent();
if (addr != address) {
return [2 /*return*/, null];
@ -19943,13 +20015,20 @@
estimate.from = fromAddress;
transaction.gasLimit = this.provider.estimateGas(estimate);
}
return Promise.all([
lib$3.resolveProperties(transaction),
fromAddress
]).then(function (results) {
var tx = results[0];
var hexTx = _this.provider.constructor.hexlifyTransaction(tx);
hexTx.from = results[1];
return lib$3.resolveProperties({
tx: lib$3.resolveProperties(transaction),
sender: fromAddress
}).then(function (_a) {
var tx = _a.tx, sender = _a.sender;
if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) {
logger.throwArgumentError("from address mismatch", "transaction", transaction);
}
}
else {
tx.from = sender;
}
var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true });
return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
return hash;
}, function (error) {
@ -21818,7 +21897,14 @@
var WebSocketProvider = /** @class */ (function (_super) {
__extends(WebSocketProvider, _super);
function WebSocketProvider(url, network) {
var _this = _super.call(this, url, network) || this;
var _this = this;
// This will be added in the future; please open an issue to expedite
if (network === "any") {
logger.throwError("WebSocketProvider does not support 'any' network yet", lib.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "network:any"
});
}
_this = _super.call(this, url, network) || this;
_this._pollingInterval = -1;
lib$3.defineReadOnly(_this, "_websocket", new ws_1.default(_this.connection.url));
lib$3.defineReadOnly(_this, "_requests", {});
@ -22846,7 +22932,7 @@
var _version$M = createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "ethers/5.0.0-beta.190";
exports.version = "ethers/5.0.0-beta.191";
});
var _version$N = unwrapExports(_version$M);

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
export declare const version = "ethers/5.0.0-beta.190";
export declare const version = "ethers/5.0.0-beta.191";

View File

@ -1 +1 @@
export const version = "ethers/5.0.0-beta.190";
export const version = "ethers/5.0.0-beta.191";

View File

@ -1 +1 @@
export declare const version = "ethers/5.0.0-beta.190";
export declare const version = "ethers/5.0.0-beta.191";

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "ethers/5.0.0-beta.190";
exports.version = "ethers/5.0.0-beta.191";

View File

@ -52,7 +52,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0x3bc54c9421df3189104c1902b41f6f7966e48e38bc5e5469968758e231393931",
"tarballHash": "0xa66669ff741f946f58b2b150bf7c545445f44df8e967f1c437091da6a0a17e06",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.190"
"version": "5.0.0-beta.191"
}

View File

@ -1 +1 @@
export const version = "ethers/5.0.0-beta.190";
export const version = "ethers/5.0.0-beta.191";

View File

@ -1 +1 @@
export declare const version = "providers/5.0.0-beta.170";
export declare const version = "providers/5.0.0-beta.171";

View File

@ -1 +1 @@
export const version = "providers/5.0.0-beta.170";
export const version = "providers/5.0.0-beta.171";

View File

@ -5,16 +5,6 @@ import { Network, Networkish } from "@ethersproject/networks";
import { Deferrable } from "@ethersproject/properties";
import { Transaction } from "@ethersproject/transactions";
import { Formatter } from "./formatter";
/**
* EventType
* - "block"
* - "poll"
* - "pending"
* - "error"
* - filter
* - topics array
* - transaction hash
*/
export declare class Event {
readonly listener: Listener;
readonly once: boolean;
@ -47,6 +37,7 @@ export declare class BaseProvider extends Provider {
reqTime: number;
respTime: number;
}>;
readonly anyNetwork: boolean;
/**
* ready
*
@ -59,13 +50,13 @@ export declare class BaseProvider extends Provider {
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>;
poll(): Promise<void>;
resetEventsBlock(blockNumber: number): void;
get network(): Network;
detectNetwork(): Promise<Network>;
getNetwork(): Promise<Network>;
get blockNumber(): number;
get polling(): boolean;

View File

@ -95,18 +95,26 @@ function getEventTag(eventName) {
function getTime() {
return (new Date()).getTime();
}
function stall(duration) {
return new Promise((resolve) => {
setTimeout(resolve, duration);
});
}
//////////////////////////////
// Provider Object
/**
* EventType
* - "block"
* - "poll"
* - "didPoll"
* - "pending"
* - "error"
* - "network"
* - filter
* - topics array
* - transaction hash
*/
const PollableEvents = ["block", "network", "pending", "poll"];
export class Event {
constructor(tag, listener, once) {
defineReadOnly(this, "tag", tag);
@ -149,7 +157,7 @@ export class Event {
return filter;
}
pollable() {
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
}
}
let defaultFormatter = null;
@ -167,16 +175,29 @@ export class BaseProvider extends Provider {
constructor(network) {
logger.checkNew(new.target, Provider);
super();
// Events being listened to
this._events = [];
this._emitted = { block: -2 };
this.formatter = new.target.getFormatter();
// If network is any, this Provider allows the underlying
// network to change dynamically, and we auto-detect the
// current network
defineReadOnly(this, "anyNetwork", (network === "any"));
if (this.anyNetwork) {
network = this.detectNetwork();
}
if (network instanceof Promise) {
this._networkPromise = network;
// Squash any "unhandled promise" errors; that do not need to be handled
network.catch((error) => { });
// Trigger initial network setting (async)
this._ready();
}
else {
const knownNetwork = getStatic((new.target), "getNetwork")(network);
if (knownNetwork) {
defineReadOnly(this, "_network", knownNetwork);
this.emit("network", knownNetwork, null);
}
else {
logger.throwArgumentError("invalid network", "network", network);
@ -184,10 +205,7 @@ export class BaseProvider extends Provider {
}
this._maxInternalBlockNumber = -1024;
this._lastBlockNumber = -2;
// Events being listened to
this._events = [];
this._pollingInterval = 4000;
this._emitted = { block: -2 };
this._fastQueryDate = 0;
}
_ready() {
@ -211,31 +229,37 @@ export class BaseProvider extends Provider {
}
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
defineReadOnly(this, "_network", network);
if (this.anyNetwork) {
this._network = network;
}
else {
defineReadOnly(this, "_network", network);
}
this.emit("network", network, null);
}
}
return this._network;
});
}
// This will always return the most recently established network.
// For "any", this can change (a "network" event is emitted before
// any change is refelcted); otherwise this cannot change
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"
});
});
}
// @TODO: Remove this and just create a singleton formatter
static getFormatter() {
if (defaultFormatter == null) {
defaultFormatter = new Formatter();
}
return defaultFormatter;
}
// @TODO: Remove this and just use getNetwork
static getNetwork(network) {
return getNetwork((network == null) ? "homestead" : network);
}
// Fetches the blockNumber, but will reuse any result that is less
// than maxAge old or has been requested since the last request
_getInternalBlockNumber(maxAge) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
@ -247,7 +271,17 @@ export class BaseProvider extends Provider {
}
}
const reqTime = getTime();
this._internalBlockNumber = this.perform("getBlockNumber", {}).then((blockNumber) => {
const checkInternalBlockNumber = resolveProperties({
blockNumber: this.perform("getBlockNumber", {}),
networkError: this.getNetwork().then((network) => (null), (error) => (error))
}).then(({ blockNumber, networkError }) => {
if (networkError) {
// Unremember this bad internal block number
if (this._internalBlockNumber === checkInternalBlockNumber) {
this._internalBlockNumber = null;
}
throw networkError;
}
const respTime = getTime();
blockNumber = BigNumber.from(blockNumber).toNumber();
if (blockNumber < this._maxInternalBlockNumber) {
@ -257,13 +291,13 @@ export class BaseProvider extends Provider {
this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
return { blockNumber, reqTime, respTime };
});
return (yield this._internalBlockNumber).blockNumber;
this._internalBlockNumber = checkInternalBlockNumber;
return (yield checkInternalBlockNumber).blockNumber;
});
}
poll() {
return __awaiter(this, void 0, void 0, function* () {
const pollId = nextPollId++;
this.emit("willPoll", pollId);
// Track all running promises, so we can trigger a post-poll once they are complete
const runners = [];
const blockNumber = yield this._getInternalBlockNumber(100 + this.pollingInterval / 2);
@ -279,9 +313,19 @@ export class BaseProvider extends Provider {
if (this._emitted.block === -2) {
this._emitted.block = blockNumber - 1;
}
// Notify all listener for each block that has passed
for (let i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
logger.warn("network block skew detected; skipping block events");
this.emit("error", logger.makeError("network block skew detected", Logger.errors.NETWORK_ERROR, {
blockNumber: blockNumber,
previousBlockNumber: this._emitted.block
}));
this.emit("block", blockNumber);
}
else {
// Notify all listener for each block that has passed
for (let i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
}
}
// The emitted block was updated, check for obsolete events
if (this._emitted.block !== blockNumber) {
@ -346,12 +390,14 @@ export class BaseProvider extends Provider {
}
});
this._lastBlockNumber = blockNumber;
// Once all events for this loop have been processed, emit "didPoll"
Promise.all(runners).then(() => {
this.emit("didPoll", pollId);
});
return null;
});
}
// Deprecated; do not use this
resetEventsBlock(blockNumber) {
this._lastBlockNumber = blockNumber - 1;
if (this.polling) {
@ -361,8 +407,52 @@ export class BaseProvider extends Provider {
get network() {
return this._network;
}
// This method should query the network if the underlying network
// can change, such as when connected to a JSON-RPC backend
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"
});
});
}
getNetwork() {
return this.ready;
return __awaiter(this, void 0, void 0, function* () {
const network = yield this.ready;
// Make sure we are still connected to the same network; this is
// only an external call for backends which can have the underlying
// network change spontaneously
const currentNetwork = yield this.detectNetwork();
if (network.chainId !== currentNetwork.chainId) {
// We are allowing network changes, things can get complex fast;
// make sure you know what you are doing if you use "any"
if (this.anyNetwork) {
this._network = currentNetwork;
// Reset all internal block number guards and caches
this._lastBlockNumber = -2;
this._fastBlockNumber = null;
this._fastBlockNumberPromise = null;
this._fastQueryDate = 0;
this._emitted.block = -2;
this._maxInternalBlockNumber = -1024;
this._internalBlockNumber = null;
// The "network" event MUST happen before this method resolves
// so any events have a chance to unregister, so we stall an
// additional event loop before returning from /this/ call
this.emit("network", currentNetwork, network);
yield stall(0);
return this._network;
}
const error = logger.makeError("underlying network changed", Logger.errors.NETWORK_ERROR, {
event: "changed",
network: network,
detectedNetwork: currentNetwork
});
this.emit("error", error);
throw error;
}
return network;
});
}
get blockNumber() {
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => {
@ -438,8 +528,6 @@ export class BaseProvider extends Provider {
this._fastBlockNumberPromise = Promise.resolve(blockNumber);
}
}
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
// this will be used once we move to the WebSocket or other alternatives to polling
waitForTransaction(transactionHash, confirmations, timeout) {
return __awaiter(this, void 0, void 0, function* () {
if (confirmations == null) {
@ -487,17 +575,19 @@ export class BaseProvider extends Provider {
});
}
getBlockNumber() {
return this._getInternalBlockNumber(0);
return __awaiter(this, void 0, void 0, function* () {
return this._getInternalBlockNumber(0);
});
}
getGasPrice() {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
return BigNumber.from(yield this.perform("getGasPrice", {}));
});
}
getBalance(addressOrName, blockTag) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -507,7 +597,7 @@ export class BaseProvider extends Provider {
}
getTransactionCount(addressOrName, blockTag) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -517,7 +607,7 @@ export class BaseProvider extends Provider {
}
getCode(addressOrName, blockTag) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag)
@ -527,7 +617,7 @@ export class BaseProvider extends Provider {
}
getStorageAt(addressOrName, position, blockTag) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
address: this._getAddress(addressOrName),
blockTag: this._getBlockTag(blockTag),
@ -573,7 +663,7 @@ export class BaseProvider extends Provider {
}
sendTransaction(signedTransaction) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const hexTx = yield Promise.resolve(signedTransaction).then(t => hexlify(t));
const tx = this.formatter.transaction(signedTransaction);
try {
@ -614,9 +704,7 @@ export class BaseProvider extends Provider {
}
_getFilter(filter) {
return __awaiter(this, void 0, void 0, function* () {
if (filter instanceof Promise) {
filter = yield filter;
}
filter = yield filter;
const result = {};
if (filter.address != null) {
result.address = this._getAddress(filter.address);
@ -638,7 +726,7 @@ export class BaseProvider extends Provider {
}
call(transaction, blockTag) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
transaction: this._getTransactionRequest(transaction),
blockTag: this._getBlockTag(blockTag)
@ -648,7 +736,7 @@ export class BaseProvider extends Provider {
}
estimateGas(transaction) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({
transaction: this._getTransactionRequest(transaction)
});
@ -668,10 +756,8 @@ export class BaseProvider extends Provider {
}
_getBlock(blockHashOrBlockTag, includeTransactions) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
if (blockHashOrBlockTag instanceof Promise) {
blockHashOrBlockTag = yield blockHashOrBlockTag;
}
yield this.getNetwork();
blockHashOrBlockTag = yield blockHashOrBlockTag;
// If blockTag is a number (not "latest", etc), this is the block number
let blockNumber = -128;
const params = {
@ -746,10 +832,8 @@ export class BaseProvider extends Provider {
}
getTransaction(transactionHash) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
if (transactionHash instanceof Promise) {
transactionHash = yield transactionHash;
}
yield this.getNetwork();
transactionHash = yield transactionHash;
const params = { transactionHash: this.formatter.hash(transactionHash, true) };
return poll(() => __awaiter(this, void 0, void 0, function* () {
const result = yield this.perform("getTransaction", params);
@ -778,10 +862,8 @@ export class BaseProvider extends Provider {
}
getTransactionReceipt(transactionHash) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
if (transactionHash instanceof Promise) {
transactionHash = yield transactionHash;
}
yield this.getNetwork();
transactionHash = yield transactionHash;
const params = { transactionHash: this.formatter.hash(transactionHash, true) };
return poll(() => __awaiter(this, void 0, void 0, function* () {
const result = yield this.perform("getTransactionReceipt", params);
@ -814,7 +896,7 @@ export class BaseProvider extends Provider {
}
getLogs(filter) {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
const params = yield resolveProperties({ filter: this._getFilter(filter) });
const logs = yield this.perform("getLogs", params);
logs.forEach((log) => {
@ -827,15 +909,13 @@ export class BaseProvider extends Provider {
}
getEtherPrice() {
return __awaiter(this, void 0, void 0, function* () {
yield this.ready;
yield this.getNetwork();
return this.perform("getEtherPrice", {});
});
}
_getBlockTag(blockTag) {
return __awaiter(this, void 0, void 0, function* () {
if (blockTag instanceof Promise) {
blockTag = yield blockTag;
}
blockTag = yield blockTag;
if (typeof (blockTag) === "number" && blockTag < 0) {
if (blockTag % 1) {
logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
@ -868,9 +948,7 @@ export class BaseProvider extends Provider {
}
resolveName(name) {
return __awaiter(this, void 0, void 0, function* () {
if (name instanceof Promise) {
name = yield name;
}
name = yield name;
// If it is already an address, nothing to resolve
try {
return Promise.resolve(this.formatter.address(name));
@ -899,9 +977,7 @@ export class BaseProvider extends Provider {
}
lookupAddress(address) {
return __awaiter(this, void 0, void 0, function* () {
if (address instanceof Promise) {
address = yield address;
}
address = yield address;
address = this.formatter.address(address);
const reverseName = address.substring(2).toLowerCase() + ".addr.reverse";
const resolverAddress = yield this._getResolver(reverseName);

View File

@ -26,7 +26,7 @@ function timer(timeout) {
function getResult(payload) {
if (payload.error) {
// @TODO: not any
let error = new Error(payload.error.message);
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
throw error;
@ -86,7 +86,7 @@ export class JsonRpcSigner extends Signer {
}
sendUncheckedTransaction(transaction) {
transaction = shallowCopy(transaction);
let fromAddress = this.getAddress().then((address) => {
const fromAddress = this.getAddress().then((address) => {
if (address) {
address = address.toLowerCase();
}
@ -96,17 +96,23 @@ export class JsonRpcSigner extends Signer {
// wishes to use this, it is easy to specify explicitly, otherwise
// we look it up for them.
if (transaction.gasLimit == null) {
let estimate = shallowCopy(transaction);
const estimate = shallowCopy(transaction);
estimate.from = fromAddress;
transaction.gasLimit = this.provider.estimateGas(estimate);
}
return Promise.all([
resolveProperties(transaction),
fromAddress
]).then((results) => {
let tx = results[0];
let hexTx = this.provider.constructor.hexlifyTransaction(tx);
hexTx.from = results[1];
return resolveProperties({
tx: resolveProperties(transaction),
sender: fromAddress
}).then(({ tx, sender }) => {
if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) {
logger.throwArgumentError("from address mismatch", "transaction", transaction);
}
}
else {
tx.from = sender;
}
const hexTx = this.provider.constructor.hexlifyTransaction(tx, { from: true });
return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => {
return hash;
}, (error) => {
@ -153,14 +159,14 @@ export class JsonRpcSigner extends Signer {
});
}
signMessage(message) {
let data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message);
const data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message);
return this.getAddress().then((address) => {
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
return this.provider.send("eth_sign", [address.toLowerCase(), hexlify(data)]);
});
}
unlock(password) {
let provider = this.provider;
const provider = this.provider;
return this.getAddress().then(function (address) {
return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]);
});
@ -261,7 +267,7 @@ export class JsonRpcProvider extends BaseProvider {
});
}
send(method, params) {
let request = {
const request = {
method: method,
params: params,
id: (this._nextId++),
@ -373,8 +379,8 @@ export class JsonRpcProvider extends BaseProvider {
if (this._pendingFilter != null) {
return;
}
let self = this;
let pendingFilter = this.send("eth_newPendingTransactionFilter", []);
const self = this;
const pendingFilter = this.send("eth_newPendingTransactionFilter", []);
this._pendingFilter = pendingFilter;
pendingFilter.then(function (filterId) {
function poll() {
@ -428,7 +434,7 @@ export class JsonRpcProvider extends BaseProvider {
// Check only allowed properties are given
const allowed = shallowCopy(allowedTransactionKeys);
if (allowExtra) {
for (let key in allowExtra) {
for (const key in allowExtra) {
if (allowExtra[key]) {
allowed[key] = true;
}

View File

@ -34,6 +34,12 @@ let NextId = 1;
// https://geth.ethereum.org/docs/rpc/pubsub
export class WebSocketProvider extends JsonRpcProvider {
constructor(url, network) {
// This will be added in the future; please open an issue to expedite
if (network === "any") {
logger.throwError("WebSocketProvider does not support 'any' network yet", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "network:any"
});
}
super(url, network);
this._pollingInterval = -1;
defineReadOnly(this, "_websocket", new WebSocket(this.connection.url));

View File

@ -1 +1 @@
export declare const version = "providers/5.0.0-beta.170";
export declare const version = "providers/5.0.0-beta.171";

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.0-beta.170";
exports.version = "providers/5.0.0-beta.171";

View File

@ -5,16 +5,6 @@ import { Network, Networkish } from "@ethersproject/networks";
import { Deferrable } from "@ethersproject/properties";
import { Transaction } from "@ethersproject/transactions";
import { Formatter } from "./formatter";
/**
* EventType
* - "block"
* - "poll"
* - "pending"
* - "error"
* - filter
* - topics array
* - transaction hash
*/
export declare class Event {
readonly listener: Listener;
readonly once: boolean;
@ -47,6 +37,7 @@ export declare class BaseProvider extends Provider {
reqTime: number;
respTime: number;
}>;
readonly anyNetwork: boolean;
/**
* ready
*
@ -59,13 +50,13 @@ export declare class BaseProvider extends Provider {
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>;
poll(): Promise<void>;
resetEventsBlock(blockNumber: number): void;
get network(): Network;
detectNetwork(): Promise<Network>;
getNetwork(): Promise<Network>;
get blockNumber(): number;
get polling(): boolean;

View File

@ -136,18 +136,26 @@ function getEventTag(eventName) {
function getTime() {
return (new Date()).getTime();
}
function stall(duration) {
return new Promise(function (resolve) {
setTimeout(resolve, duration);
});
}
//////////////////////////////
// Provider Object
/**
* EventType
* - "block"
* - "poll"
* - "didPoll"
* - "pending"
* - "error"
* - "network"
* - filter
* - topics array
* - transaction hash
*/
var PollableEvents = ["block", "network", "pending", "poll"];
var Event = /** @class */ (function () {
function Event(tag, listener, once) {
properties_1.defineReadOnly(this, "tag", tag);
@ -206,7 +214,7 @@ var Event = /** @class */ (function () {
configurable: true
});
Event.prototype.pollable = function () {
return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending" || this.tag === "poll");
return (this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0);
};
return Event;
}());
@ -229,16 +237,29 @@ var BaseProvider = /** @class */ (function (_super) {
var _this = this;
logger.checkNew(_newTarget, abstract_provider_1.Provider);
_this = _super.call(this) || this;
// Events being listened to
_this._events = [];
_this._emitted = { block: -2 };
_this.formatter = _newTarget.getFormatter();
// If network is any, this Provider allows the underlying
// network to change dynamically, and we auto-detect the
// current network
properties_1.defineReadOnly(_this, "anyNetwork", (network === "any"));
if (_this.anyNetwork) {
network = _this.detectNetwork();
}
if (network instanceof Promise) {
_this._networkPromise = network;
// Squash any "unhandled promise" errors; that do not need to be handled
network.catch(function (error) { });
// Trigger initial network setting (async)
_this._ready();
}
else {
var knownNetwork = properties_1.getStatic((_newTarget), "getNetwork")(network);
if (knownNetwork) {
properties_1.defineReadOnly(_this, "_network", knownNetwork);
_this.emit("network", knownNetwork, null);
}
else {
logger.throwArgumentError("invalid network", "network", network);
@ -246,10 +267,7 @@ var BaseProvider = /** @class */ (function (_super) {
}
_this._maxInternalBlockNumber = -1024;
_this._lastBlockNumber = -2;
// Events being listened to
_this._events = [];
_this._pollingInterval = 4000;
_this._emitted = { block: -2 };
_this._fastQueryDate = 0;
return _this;
}
@ -286,7 +304,13 @@ var BaseProvider = /** @class */ (function (_super) {
}
// Possible this call stacked so do not call defineReadOnly again
if (this._network == null) {
properties_1.defineReadOnly(this, "_network", network);
if (this.anyNetwork) {
this._network = network;
}
else {
properties_1.defineReadOnly(this, "_network", network);
}
this.emit("network", network, null);
}
_a.label = 7;
case 7: return [2 /*return*/, this._network];
@ -295,33 +319,31 @@ var BaseProvider = /** @class */ (function (_super) {
});
};
Object.defineProperty(BaseProvider.prototype, "ready", {
// This will always return the most recently established network.
// For "any", this can change (a "network" event is emitted before
// any change is refelcted); otherwise this cannot change
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"
})];
});
});
};
// @TODO: Remove this and just create a singleton formatter
BaseProvider.getFormatter = function () {
if (defaultFormatter == null) {
defaultFormatter = new formatter_1.Formatter();
}
return defaultFormatter;
};
// @TODO: Remove this and just use getNetwork
BaseProvider.getNetwork = function (network) {
return networks_1.getNetwork((network == null) ? "homestead" : network);
};
// Fetches the blockNumber, but will reuse any result that is less
// than maxAge old or has been requested since the last request
BaseProvider.prototype._getInternalBlockNumber = function (maxAge) {
return __awaiter(this, void 0, void 0, function () {
var internalBlockNumber, result, reqTime;
var internalBlockNumber, result, reqTime, checkInternalBlockNumber;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
@ -339,7 +361,18 @@ var BaseProvider = /** @class */ (function (_super) {
_a.label = 3;
case 3:
reqTime = getTime();
this._internalBlockNumber = this.perform("getBlockNumber", {}).then(function (blockNumber) {
checkInternalBlockNumber = properties_1.resolveProperties({
blockNumber: this.perform("getBlockNumber", {}),
networkError: this.getNetwork().then(function (network) { return (null); }, function (error) { return (error); })
}).then(function (_a) {
var blockNumber = _a.blockNumber, networkError = _a.networkError;
if (networkError) {
// Unremember this bad internal block number
if (_this._internalBlockNumber === checkInternalBlockNumber) {
_this._internalBlockNumber = null;
}
throw networkError;
}
var respTime = getTime();
blockNumber = bignumber_1.BigNumber.from(blockNumber).toNumber();
if (blockNumber < _this._maxInternalBlockNumber) {
@ -349,7 +382,8 @@ var BaseProvider = /** @class */ (function (_super) {
_this._setFastBlockNumber(blockNumber); // @TODO: Still need this?
return { blockNumber: blockNumber, reqTime: reqTime, respTime: respTime };
});
return [4 /*yield*/, this._internalBlockNumber];
this._internalBlockNumber = checkInternalBlockNumber;
return [4 /*yield*/, checkInternalBlockNumber];
case 4: return [2 /*return*/, (_a.sent()).blockNumber];
}
});
@ -363,7 +397,6 @@ var BaseProvider = /** @class */ (function (_super) {
switch (_a.label) {
case 0:
pollId = nextPollId++;
this.emit("willPoll", pollId);
runners = [];
return [4 /*yield*/, this._getInternalBlockNumber(100 + this.pollingInterval / 2)];
case 1:
@ -380,9 +413,19 @@ var BaseProvider = /** @class */ (function (_super) {
if (this._emitted.block === -2) {
this._emitted.block = blockNumber - 1;
}
// Notify all listener for each block that has passed
for (i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
if (Math.abs((this._emitted.block) - blockNumber) > 1000) {
logger.warn("network block skew detected; skipping block events");
this.emit("error", logger.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, {
blockNumber: blockNumber,
previousBlockNumber: this._emitted.block
}));
this.emit("block", blockNumber);
}
else {
// Notify all listener for each block that has passed
for (i = this._emitted.block + 1; i <= blockNumber; i++) {
this.emit("block", i);
}
}
// The emitted block was updated, check for obsolete events
if (this._emitted.block !== blockNumber) {
@ -447,6 +490,7 @@ var BaseProvider = /** @class */ (function (_super) {
}
});
this._lastBlockNumber = blockNumber;
// Once all events for this loop have been processed, emit "didPoll"
Promise.all(runners).then(function () {
_this.emit("didPoll", pollId);
});
@ -455,6 +499,7 @@ var BaseProvider = /** @class */ (function (_super) {
});
});
};
// Deprecated; do not use this
BaseProvider.prototype.resetEventsBlock = function (blockNumber) {
this._lastBlockNumber = blockNumber - 1;
if (this.polling) {
@ -468,8 +513,59 @@ var BaseProvider = /** @class */ (function (_super) {
enumerable: true,
configurable: true
});
// This method should query the network if the underlying network
// can change, such as when connected to a JSON-RPC backend
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.prototype.getNetwork = function () {
return this.ready;
return __awaiter(this, void 0, void 0, function () {
var network, currentNetwork, error;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 1:
network = _a.sent();
return [4 /*yield*/, this.detectNetwork()];
case 2:
currentNetwork = _a.sent();
if (!(network.chainId !== currentNetwork.chainId)) return [3 /*break*/, 5];
if (!this.anyNetwork) return [3 /*break*/, 4];
this._network = currentNetwork;
// Reset all internal block number guards and caches
this._lastBlockNumber = -2;
this._fastBlockNumber = null;
this._fastBlockNumberPromise = null;
this._fastQueryDate = 0;
this._emitted.block = -2;
this._maxInternalBlockNumber = -1024;
this._internalBlockNumber = null;
// The "network" event MUST happen before this method resolves
// so any events have a chance to unregister, so we stall an
// additional event loop before returning from /this/ call
this.emit("network", currentNetwork, network);
return [4 /*yield*/, stall(0)];
case 3:
_a.sent();
return [2 /*return*/, this._network];
case 4:
error = logger.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, {
event: "changed",
network: network,
detectedNetwork: currentNetwork
});
this.emit("error", error);
throw error;
case 5: return [2 /*return*/, network];
}
});
});
};
Object.defineProperty(BaseProvider.prototype, "blockNumber", {
get: function () {
@ -561,8 +657,6 @@ var BaseProvider = /** @class */ (function (_super) {
this._fastBlockNumberPromise = Promise.resolve(blockNumber);
}
};
// @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event;
// this will be used once we move to the WebSocket or other alternatives to polling
BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations, timeout) {
return __awaiter(this, void 0, void 0, function () {
var receipt;
@ -619,14 +713,18 @@ var BaseProvider = /** @class */ (function (_super) {
});
};
BaseProvider.prototype.getBlockNumber = function () {
return this._getInternalBlockNumber(0);
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._getInternalBlockNumber(0)];
});
});
};
BaseProvider.prototype.getGasPrice = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
_b = (_a = bignumber_1.BigNumber).from;
@ -641,7 +739,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -662,7 +760,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -683,7 +781,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -704,7 +802,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -770,7 +868,7 @@ var BaseProvider = /** @class */ (function (_super) {
var hexTx, tx, hash, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [4 /*yield*/, Promise.resolve(signedTransaction).then(function (t) { return bytes_1.hexlify(t); })];
@ -835,13 +933,9 @@ var BaseProvider = /** @class */ (function (_super) {
var _this = this;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!(filter instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, filter];
case 0: return [4 /*yield*/, filter];
case 1:
filter = _c.sent();
_c.label = 2;
case 2:
result = {};
if (filter.address != null) {
result.address = this._getAddress(filter.address);
@ -860,7 +954,7 @@ var BaseProvider = /** @class */ (function (_super) {
});
_b = (_a = this.formatter).filter;
return [4 /*yield*/, properties_1.resolveProperties(result)];
case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
}
});
});
@ -870,7 +964,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_b.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -891,7 +985,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_c.sent();
return [4 /*yield*/, properties_1.resolveProperties({
@ -930,38 +1024,35 @@ var BaseProvider = /** @class */ (function (_super) {
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_d.sent();
if (!(blockHashOrBlockTag instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, blockHashOrBlockTag];
case 2:
blockHashOrBlockTag = _d.sent();
_d.label = 3;
case 3:
blockNumber = -128;
params = {
includeTransactions: !!includeTransactions
};
if (!bytes_1.isHexString(blockHashOrBlockTag, 32)) return [3 /*break*/, 4];
if (!bytes_1.isHexString(blockHashOrBlockTag, 32)) return [3 /*break*/, 3];
params.blockHash = blockHashOrBlockTag;
return [3 /*break*/, 7];
case 4:
_d.trys.push([4, 6, , 7]);
return [3 /*break*/, 6];
case 3:
_d.trys.push([3, 5, , 6]);
_a = params;
_c = (_b = this.formatter).blockTag;
return [4 /*yield*/, this._getBlockTag(blockHashOrBlockTag)];
case 5:
case 4:
_a.blockTag = _c.apply(_b, [_d.sent()]);
if (bytes_1.isHexString(params.blockTag)) {
blockNumber = parseInt(params.blockTag.substring(2), 16);
}
return [3 /*break*/, 7];
case 6:
return [3 /*break*/, 6];
case 5:
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 () {
return [3 /*break*/, 6];
case 6: return [2 /*return*/, web_1.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var block, blockNumber_1, i, tx, confirmations;
return __generator(this, function (_a) {
switch (_a.label) {
@ -1035,15 +1126,12 @@ var BaseProvider = /** @class */ (function (_super) {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
if (!(transactionHash instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, transactionHash];
case 2:
transactionHash = _a.sent();
_a.label = 3;
case 3:
params = { transactionHash: this.formatter.hash(transactionHash, true) };
return [2 /*return*/, web_1.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var result, tx, blockNumber, confirmations;
@ -1087,15 +1175,12 @@ var BaseProvider = /** @class */ (function (_super) {
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
if (!(transactionHash instanceof Promise)) return [3 /*break*/, 3];
return [4 /*yield*/, transactionHash];
case 2:
transactionHash = _a.sent();
_a.label = 3;
case 3:
params = { transactionHash: this.formatter.hash(transactionHash, true) };
return [2 /*return*/, web_1.poll(function () { return __awaiter(_this, void 0, void 0, function () {
var result, receipt, blockNumber, confirmations;
@ -1142,7 +1227,7 @@ var BaseProvider = /** @class */ (function (_super) {
var params, logs;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [4 /*yield*/, properties_1.resolveProperties({ filter: this._getFilter(filter) })];
@ -1165,7 +1250,7 @@ var BaseProvider = /** @class */ (function (_super) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ready];
case 0: return [4 /*yield*/, this.getNetwork()];
case 1:
_a.sent();
return [2 /*return*/, this.perform("getEtherPrice", {})];
@ -1178,26 +1263,22 @@ var BaseProvider = /** @class */ (function (_super) {
var blockNumber;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(blockTag instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, blockTag];
case 0: return [4 /*yield*/, blockTag];
case 1:
blockTag = _a.sent();
_a.label = 2;
case 2:
if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 4];
if (!(typeof (blockTag) === "number" && blockTag < 0)) return [3 /*break*/, 3];
if (blockTag % 1) {
logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
}
return [4 /*yield*/, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)];
case 3:
case 2:
blockNumber = _a.sent();
blockNumber += blockTag;
if (blockNumber < 0) {
blockNumber = 0;
}
return [2 /*return*/, this.formatter.blockTag(blockNumber)];
case 4: return [2 /*return*/, this.formatter.blockTag(blockTag)];
case 3: return [2 /*return*/, this.formatter.blockTag(blockTag)];
}
});
});
@ -1230,13 +1311,9 @@ var BaseProvider = /** @class */ (function (_super) {
var resolverAddress, transaction, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!(name instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, name];
case 0: return [4 /*yield*/, name];
case 1:
name = _c.sent();
_c.label = 2;
case 2:
// If it is already an address, nothing to resolve
try {
return [2 /*return*/, Promise.resolve(this.formatter.address(name))];
@ -1251,7 +1328,7 @@ var BaseProvider = /** @class */ (function (_super) {
logger.throwArgumentError("invalid ENS name", "name", name);
}
return [4 /*yield*/, this._getResolver(name)];
case 3:
case 2:
resolverAddress = _c.sent();
if (!resolverAddress) {
return [2 /*return*/, null];
@ -1262,7 +1339,7 @@ var BaseProvider = /** @class */ (function (_super) {
};
_b = (_a = this.formatter).callAddress;
return [4 /*yield*/, this.call(transaction)];
case 4: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
}
});
});
@ -1272,17 +1349,13 @@ var BaseProvider = /** @class */ (function (_super) {
var reverseName, resolverAddress, bytes, _a, length, name, addr;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(address instanceof Promise)) return [3 /*break*/, 2];
return [4 /*yield*/, address];
case 0: return [4 /*yield*/, address];
case 1:
address = _b.sent();
_b.label = 2;
case 2:
address = this.formatter.address(address);
reverseName = address.substring(2).toLowerCase() + ".addr.reverse";
return [4 /*yield*/, this._getResolver(reverseName)];
case 3:
case 2:
resolverAddress = _b.sent();
if (!resolverAddress) {
return [2 /*return*/, null];
@ -1292,7 +1365,7 @@ var BaseProvider = /** @class */ (function (_super) {
to: resolverAddress,
data: ("0x691f3431" + hash_1.namehash(reverseName).substring(2))
})];
case 4:
case 3:
bytes = _a.apply(void 0, [_b.sent()]);
// Strip off the dynamic string pointer (0x20)
if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) {
@ -1311,7 +1384,7 @@ var BaseProvider = /** @class */ (function (_super) {
}
name = strings_1.toUtf8String(bytes.slice(0, length));
return [4 /*yield*/, this.resolveName(name)];
case 5:
case 4:
addr = _b.sent();
if (addr != address) {
return [2 /*return*/, null];

View File

@ -147,13 +147,20 @@ var JsonRpcSigner = /** @class */ (function (_super) {
estimate.from = fromAddress;
transaction.gasLimit = this.provider.estimateGas(estimate);
}
return Promise.all([
properties_1.resolveProperties(transaction),
fromAddress
]).then(function (results) {
var tx = results[0];
var hexTx = _this.provider.constructor.hexlifyTransaction(tx);
hexTx.from = results[1];
return properties_1.resolveProperties({
tx: properties_1.resolveProperties(transaction),
sender: fromAddress
}).then(function (_a) {
var tx = _a.tx, sender = _a.sender;
if (tx.from != null) {
if (tx.from.toLowerCase() !== sender) {
logger.throwArgumentError("from address mismatch", "transaction", transaction);
}
}
else {
tx.from = sender;
}
var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true });
return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
return hash;
}, function (error) {

View File

@ -79,7 +79,14 @@ var NextId = 1;
var WebSocketProvider = /** @class */ (function (_super) {
__extends(WebSocketProvider, _super);
function WebSocketProvider(url, network) {
var _this = _super.call(this, url, network) || this;
var _this = this;
// This will be added in the future; please open an issue to expedite
if (network === "any") {
logger.throwError("WebSocketProvider does not support 'any' network yet", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
operation: "network:any"
});
}
_this = _super.call(this, url, network) || this;
_this._pollingInterval = -1;
properties_1.defineReadOnly(_this, "_websocket", new ws_1.default(_this.connection.url));
properties_1.defineReadOnly(_this, "_requests", {});

View File

@ -56,7 +56,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"tarballHash": "0xb29152a4cc4705e1721fabf15e707a0cec56c3b86feb02756e5cd53a2b9fc230",
"tarballHash": "0xe343d4f28955a33a42fa54e47662c63a5ec55c9b7c6515d210ddf7c142c87ba9",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.170"
"version": "5.0.0-beta.171"
}

View File

@ -1 +1 @@
export const version = "providers/5.0.0-beta.170";
export const version = "providers/5.0.0-beta.171";

View File

@ -1 +1 @@
export declare const version = "tests/5.0.0-beta.161";
export declare const version = "tests/5.0.0-beta.162";

View File

@ -1 +1 @@
export const version = "tests/5.0.0-beta.161";
export const version = "tests/5.0.0-beta.162";

View File

@ -267,4 +267,18 @@ describe("Test Contract Transaction Population", function () {
}
});
});
it("allows overriding with invalid, but nullish values", function () {
return __awaiter(this, void 0, void 0, function* () {
const contractSigner = contract.connect(testAddress);
const tx = yield contractSigner.populateTransaction.unstake({
blockTag: null,
from: null
});
//console.log("Tx", tx);
assert.equal(Object.keys(tx).length, 3, "correct number of keys");
assert.equal(tx.data, "0x2def6620", "data matches");
assert.equal(tx.to, testAddressCheck, "to address matches");
assert.equal(tx.from, testAddressCheck.toLowerCase(), "from address matches");
});
});
});

View File

@ -1 +1 @@
export declare const version = "tests/5.0.0-beta.161";
export declare const version = "tests/5.0.0-beta.162";

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "tests/5.0.0-beta.161";
exports.version = "tests/5.0.0-beta.162";

View File

@ -377,4 +377,27 @@ describe("Test Contract Transaction Population", function () {
});
});
});
it("allows overriding with invalid, but nullish values", function () {
return __awaiter(this, void 0, void 0, function () {
var contractSigner, tx;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
contractSigner = contract.connect(testAddress);
return [4 /*yield*/, contractSigner.populateTransaction.unstake({
blockTag: null,
from: null
})];
case 1:
tx = _a.sent();
//console.log("Tx", tx);
assert_1.default.equal(Object.keys(tx).length, 3, "correct number of keys");
assert_1.default.equal(tx.data, "0x2def6620", "data matches");
assert_1.default.equal(tx.to, testAddressCheck, "to address matches");
assert_1.default.equal(tx.from, testAddressCheck.toLowerCase(), "from address matches");
return [2 /*return*/];
}
});
});
});
});

View File

@ -39,7 +39,7 @@
"scripts": {
"test": "exit 1"
},
"tarballHash": "0xae7bf1faa5e6862fca833a04adb8844c354d3c56964483c684b69bea57dede01",
"tarballHash": "0x08897eebab9a8685b85a42269e40f2485d95642f8ad58dc721045aa2178ed0ec",
"types": "./lib/index.d.ts",
"version": "5.0.0-beta.161"
"version": "5.0.0-beta.162"
}

View File

@ -1 +1 @@
export const version = "tests/5.0.0-beta.161";
export const version = "tests/5.0.0-beta.162";