Updated dist files.

This commit is contained in:
Richard Moore 2020-09-16 03:08:36 -04:00
parent 49f71574f4
commit d15c097dba
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
57 changed files with 643 additions and 353 deletions

@ -3,6 +3,13 @@ Changelog
This change log is managed by `admin/cmds/update-versions` but may be manually updated. This change log is managed by `admin/cmds/update-versions` but may be manually updated.
ethers/v5.0.14 (2020-09-16 02:39)
---------------------------------
- More robust blockchain error detection ([#1047](https://github.com/ethers-io/ethers.js/issues/1047); [49f7157](https://github.com/ethers-io/ethers.js/commit/49f71574f4799d685a5ae8fd24fe1134f752d70a))
- Forward blockchain errors from Signer during gas estimation. ([#1047](https://github.com/ethers-io/ethers.js/issues/1047); [9ee685d](https://github.com/ethers-io/ethers.js/commit/9ee685df46753c46cbbde12d05d6ea04f2b5ea3f))
- Improve fetch errors with looser mime-type detection. ([#1047](https://github.com/ethers-io/ethers.js/issues/1047); [263bfe5](https://github.com/ethers-io/ethers.js/commit/263bfe5ce632790e0399d06a0ab660a501997998))
ethers/v5.0.13 (2020-09-11 02:10) ethers/v5.0.13 (2020-09-11 02:10)
--------------------------------- ---------------------------------

@ -1 +1 @@
export declare const version = "abstract-signer/5.0.4"; export declare const version = "abstract-signer/5.0.5";

@ -1,2 +1,2 @@
export const version = "abstract-signer/5.0.4"; export const version = "abstract-signer/5.0.5";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -15,6 +15,11 @@ const logger = new Logger(version);
const allowedTransactionKeys = [ const allowedTransactionKeys = [
"chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value"
]; ];
const forwardErrors = [
Logger.errors.INSUFFICIENT_FUNDS,
Logger.errors.NONCE_EXPIRED,
Logger.errors.REPLACEMENT_UNDERPRICED,
];
// Sub-Class Notes: // Sub-Class Notes:
// - A Signer MUST always make sure, that if present, the "from" field // - A Signer MUST always make sure, that if present, the "from" field
// matches the Signer, before sending or signing a transaction // matches the Signer, before sending or signing a transaction
@ -137,6 +142,9 @@ export class Signer {
} }
if (tx.gasLimit == null) { if (tx.gasLimit == null) {
tx.gasLimit = this.estimateGas(tx).catch((error) => { tx.gasLimit = this.estimateGas(tx).catch((error) => {
if (forwardErrors.indexOf(error.code) >= 0) {
throw error;
}
return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, error: error,
tx: tx tx: tx

File diff suppressed because one or more lines are too long

@ -1 +1 @@
export declare const version = "abstract-signer/5.0.4"; export declare const version = "abstract-signer/5.0.5";

@ -1,4 +1,4 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abstract-signer/5.0.4"; exports.version = "abstract-signer/5.0.5";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -56,6 +56,11 @@ var logger = new logger_1.Logger(_version_1.version);
var allowedTransactionKeys = [ var allowedTransactionKeys = [
"chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value"
]; ];
var forwardErrors = [
logger_1.Logger.errors.INSUFFICIENT_FUNDS,
logger_1.Logger.errors.NONCE_EXPIRED,
logger_1.Logger.errors.REPLACEMENT_UNDERPRICED,
];
// Sub-Class Notes: // Sub-Class Notes:
// - A Signer MUST always make sure, that if present, the "from" field // - A Signer MUST always make sure, that if present, the "from" field
// matches the Signer, before sending or signing a transaction // matches the Signer, before sending or signing a transaction
@ -236,6 +241,9 @@ var Signer = /** @class */ (function () {
} }
if (tx.gasLimit == null) { if (tx.gasLimit == null) {
tx.gasLimit = this.estimateGas(tx).catch(function (error) { tx.gasLimit = this.estimateGas(tx).catch(function (error) {
if (forwardErrors.indexOf(error.code) >= 0) {
throw error;
}
return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, error: error,
tx: tx tx: tx

File diff suppressed because one or more lines are too long

@ -27,7 +27,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"tarballHash": "0x63dce90d05ad50bcaae39d4a18f6b64b5194b03ff445543f49f6de4b2df08fd1", "tarballHash": "0x01b03b3690c98369da51c196e581f04693c08365805bb6e036ec3fce8e58fa08",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"version": "5.0.4" "version": "5.0.5"
} }

@ -1 +1 @@
export const version = "abstract-signer/5.0.4"; export const version = "abstract-signer/5.0.5";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -8070,7 +8070,7 @@ class Provider {
} }
} }
const version$a = "abstract-signer/5.0.4"; const version$a = "abstract-signer/5.0.5";
"use strict"; "use strict";
var __awaiter$1 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter$1 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
@ -8086,6 +8086,11 @@ const logger$e = new Logger(version$a);
const allowedTransactionKeys = [ const allowedTransactionKeys = [
"chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value"
]; ];
const forwardErrors = [
Logger.errors.INSUFFICIENT_FUNDS,
Logger.errors.NONCE_EXPIRED,
Logger.errors.REPLACEMENT_UNDERPRICED,
];
// Sub-Class Notes: // Sub-Class Notes:
// - A Signer MUST always make sure, that if present, the "from" field // - A Signer MUST always make sure, that if present, the "from" field
// matches the Signer, before sending or signing a transaction // matches the Signer, before sending or signing a transaction
@ -8208,6 +8213,9 @@ class Signer {
} }
if (tx.gasLimit == null) { if (tx.gasLimit == null) {
tx.gasLimit = this.estimateGas(tx).catch((error) => { tx.gasLimit = this.estimateGas(tx).catch((error) => {
if (forwardErrors.indexOf(error.code) >= 0) {
throw error;
}
return logger$e.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { return logger$e.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, error: error,
tx: tx tx: tx
@ -19253,7 +19261,7 @@ var browser$2 = /*#__PURE__*/Object.freeze({
encode: encode$1 encode: encode$1
}); });
const version$l = "web/5.0.6"; const version$l = "web/5.0.7";
"use strict"; "use strict";
var __awaiter$4 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter$4 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
@ -19326,7 +19334,7 @@ function bodyify(value, type) {
return value; return value;
} }
if (isBytesLike(value)) { if (isBytesLike(value)) {
if (type && (type.split("/")[0] === "text" || type === "application/json")) { if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
try { try {
return toUtf8String(value); return toUtf8String(value);
} }
@ -19840,7 +19848,7 @@ var bech32_5 = bech32.toWords;
var bech32_6 = bech32.fromWordsUnsafe; var bech32_6 = bech32.fromWordsUnsafe;
var bech32_7 = bech32.fromWords; var bech32_7 = bech32.fromWords;
const version$m = "providers/5.0.8"; const version$m = "providers/5.0.9";
"use strict"; "use strict";
const logger$q = new Logger(version$m); const logger$q = new Logger(version$m);
@ -21538,7 +21546,7 @@ class BaseProvider extends Provider {
var _version$2 = createCommonjsModule(function (module, exports) { var _version$2 = createCommonjsModule(function (module, exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.8"; exports.version = "providers/5.0.9";
}); });
@ -21582,16 +21590,44 @@ var __awaiter$7 = (window && window.__awaiter) || function (thisArg, _arguments,
}); });
}; };
const logger$s = new Logger(version$m); const logger$s = new Logger(version$m);
const ErrorGas = ["call", "estimateGas"]; const errorGas = ["call", "estimateGas"];
function getMessage(error) { function checkError(method, error, params) {
let message = error.message; let message = error.message;
if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
message = error.error.message; message = error.error.message;
} }
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") { else if (typeof (error.responseText) === "string") {
message = error.responseText; message = error.responseText;
} }
return message || ""; message = (message || "").toLowerCase();
const transaction = params.transaction || params.signedTransaction;
// "insufficient funds for gas * price + value + cost(data)"
if (message.match(/insufficient funds/)) {
logger$s.throwError("insufficient funds for intrinsic transaction cost", Logger.errors.INSUFFICIENT_FUNDS, {
error, method, transaction
});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger$s.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
error, method, transaction
});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger$s.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
error, method, transaction
});
}
if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger$s.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error, method, transaction
});
}
throw error;
} }
function timer(timeout) { function timer(timeout) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
@ -21691,25 +21727,7 @@ class JsonRpcSigner extends Signer {
return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => { return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => {
return hash; return hash;
}, (error) => { }, (error) => {
if (error.responseText) { return checkError("sendTransaction", error, hexTx);
// See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??)
if (error.responseText.indexOf("insufficient funds") >= 0) {
logger$s.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {
transaction: tx
});
}
if (error.responseText.indexOf("nonce too low") >= 0) {
logger$s.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
transaction: tx
});
}
if (error.responseText.indexOf("replacement transaction underpriced") >= 0) {
logger$s.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
transaction: tx
});
}
}
throw error;
}); });
}); });
} }
@ -21926,39 +21944,11 @@ class JsonRpcProvider extends BaseProvider {
if (args == null) { if (args == null) {
logger$s.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); logger$s.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method });
} }
// We need a little extra logic to process errors from sendTransaction
if (method === "sendTransaction") {
try {
return yield this.send(args[0], args[1]);
}
catch (error) {
const message = getMessage(error);
// "insufficient funds for gas * price + value"
if (message.match(/insufficient funds/)) {
logger$s.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger$s.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger$s.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
throw error;
}
}
try { try {
return yield this.send(args[0], args[1]); return yield this.send(args[0], args[1]);
} }
catch (error) { catch (error) {
if (ErrorGas.indexOf(method) >= 0 && getMessage(error).match(/gas required exceeds allowance|always failing transaction|execution reverted/)) { return checkError(method, error, params);
logger$s.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
transaction: params.transaction,
error: error
});
}
throw error;
} }
}); });
} }
@ -22579,14 +22569,42 @@ function checkLogTag(blockTag) {
return parseInt(blockTag.substring(2), 16); return parseInt(blockTag.substring(2), 16);
} }
const defaultApiKey$1 = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"; const defaultApiKey$1 = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
function checkGasError(error, transaction) { function checkError$1(method, error, transaction) {
// Get the message from any nested error structure
let message = error.message; let message = error.message;
if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === Logger.errors.SERVER_ERROR) {
message = error.error.message; if (error.error && typeof (error.error.message) === "string") {
message = error.error.message;
}
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") {
message = error.responseText;
}
}
message = (message || "").toLowerCase();
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (message.match(/insufficient funds/)) {
logger$x.throwError("insufficient funds for intrinsic transaction cost", Logger.errors.INSUFFICIENT_FUNDS, {
error, method, transaction
});
}
// "Transaction with the same hash was already imported."
if (message.match(/same hash was already imported|transaction nonce is too low/)) {
logger$x.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
error, method, transaction
});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (message.match(/another transaction with same nonce/)) {
logger$x.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
error, method, transaction
});
} }
if (message.match(/execution failed due to an exception/)) { if (message.match(/execution failed due to an exception/)) {
logger$x.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { logger$x.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error, transaction error, method, transaction
}); });
} }
throw error; throw error;
@ -22691,21 +22709,7 @@ class EtherscanProvider extends BaseProvider {
url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction;
url += apiKey; url += apiKey;
return get(url).catch((error) => { return get(url).catch((error) => {
if (error.responseText) { return checkError$1("sendTransaction", error, params.signedTransaction);
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) {
logger$x.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "Transaction with the same hash was already imported."
if (error.responseText.indexOf("same hash was already imported") >= 0) {
logger$x.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (error.responseText.indexOf("another transaction with same nonce") >= 0) {
logger$x.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
}
throw error;
}); });
case "getBlock": case "getBlock":
if (params.blockTag) { if (params.blockTag) {
@ -22743,7 +22747,7 @@ class EtherscanProvider extends BaseProvider {
return yield get(url); return yield get(url);
} }
catch (error) { catch (error) {
return checkGasError(error, params.transaction); return checkError$1("call", error, params.transaction);
} }
} }
case "estimateGas": { case "estimateGas": {
@ -22757,7 +22761,7 @@ class EtherscanProvider extends BaseProvider {
return yield get(url); return yield get(url);
} }
catch (error) { catch (error) {
return checkGasError(error, params.transaction); return checkError$1("estimateGas", error, params.transaction);
} }
} }
case "getLogs": { case "getLogs": {
@ -23993,7 +23997,7 @@ var utils$1 = /*#__PURE__*/Object.freeze({
Indexed: Indexed Indexed: Indexed
}); });
const version$o = "ethers/5.0.13"; const version$o = "ethers/5.0.14";
"use strict"; "use strict";
const logger$E = new Logger(version$o); const logger$E = new Logger(version$o);

File diff suppressed because one or more lines are too long

@ -9021,7 +9021,7 @@
var _version$k = createCommonjsModule(function (module, exports) { var _version$k = createCommonjsModule(function (module, exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abstract-signer/5.0.4"; exports.version = "abstract-signer/5.0.5";
}); });
@ -9087,6 +9087,11 @@
var allowedTransactionKeys = [ var allowedTransactionKeys = [
"chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value"
]; ];
var forwardErrors = [
lib.Logger.errors.INSUFFICIENT_FUNDS,
lib.Logger.errors.NONCE_EXPIRED,
lib.Logger.errors.REPLACEMENT_UNDERPRICED,
];
// Sub-Class Notes: // Sub-Class Notes:
// - A Signer MUST always make sure, that if present, the "from" field // - A Signer MUST always make sure, that if present, the "from" field
// matches the Signer, before sending or signing a transaction // matches the Signer, before sending or signing a transaction
@ -9267,6 +9272,9 @@
} }
if (tx.gasLimit == null) { if (tx.gasLimit == null) {
tx.gasLimit = this.estimateGas(tx).catch(function (error) { tx.gasLimit = this.estimateGas(tx).catch(function (error) {
if (forwardErrors.indexOf(error.code) >= 0) {
throw error;
}
return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { return logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, error: error,
tx: tx tx: tx
@ -21027,7 +21035,7 @@
var _version$G = createCommonjsModule(function (module, exports) { var _version$G = createCommonjsModule(function (module, exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "web/5.0.6"; exports.version = "web/5.0.7";
}); });
@ -21187,7 +21195,7 @@
return value; return value;
} }
if (lib$1.isBytesLike(value)) { if (lib$1.isBytesLike(value)) {
if (type && (type.split("/")[0] === "text" || type === "application/json")) { if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
try { try {
return lib$8.toUtf8String(value); return lib$8.toUtf8String(value);
} }
@ -21742,7 +21750,7 @@
var _version$I = createCommonjsModule(function (module, exports) { var _version$I = createCommonjsModule(function (module, exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.8"; exports.version = "providers/5.0.9";
}); });
@ -23997,16 +24005,44 @@
var logger = new lib.Logger(_version$I.version); var logger = new lib.Logger(_version$I.version);
var ErrorGas = ["call", "estimateGas"]; var errorGas = ["call", "estimateGas"];
function getMessage(error) { function checkError(method, error, params) {
var message = error.message; var message = error.message;
if (error.code === lib.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === lib.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
message = error.error.message; message = error.error.message;
} }
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") { else if (typeof (error.responseText) === "string") {
message = error.responseText; message = error.responseText;
} }
return message || ""; message = (message || "").toLowerCase();
var transaction = params.transaction || params.signedTransaction;
// "insufficient funds for gas * price + value + cost(data)"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", lib.Logger.errors.INSUFFICIENT_FUNDS, {
error: error, method: method, transaction: transaction
});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {
error: error, method: method, transaction: transaction
});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {
error: error, method: method, transaction: transaction
});
}
if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, method: method, transaction: transaction
});
}
throw error;
} }
function timer(timeout) { function timer(timeout) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
@ -24113,25 +24149,7 @@
return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) { return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
return hash; return hash;
}, function (error) { }, function (error) {
if (error.responseText) { return checkError("sendTransaction", error, hexTx);
// See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??)
if (error.responseText.indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, {
transaction: tx
});
}
if (error.responseText.indexOf("nonce too low") >= 0) {
logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {
transaction: tx
});
}
if (error.responseText.indexOf("replacement transaction underpriced") >= 0) {
logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {
transaction: tx
});
}
}
throw error;
}); });
}); });
}; };
@ -24379,7 +24397,7 @@
}; };
JsonRpcProvider.prototype.perform = function (method, params) { JsonRpcProvider.prototype.perform = function (method, params) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var args, error_3, message, error_4; var args, error_3;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
@ -24387,7 +24405,6 @@
if (args == null) { if (args == null) {
logger.throwError(method + " not implemented", lib.Logger.errors.NOT_IMPLEMENTED, { operation: method }); logger.throwError(method + " not implemented", lib.Logger.errors.NOT_IMPLEMENTED, { operation: method });
} }
if (!(method === "sendTransaction")) return [3 /*break*/, 4];
_a.label = 1; _a.label = 1;
case 1: case 1:
_a.trys.push([1, 3, , 4]); _a.trys.push([1, 3, , 4]);
@ -24395,34 +24412,8 @@
case 2: return [2 /*return*/, _a.sent()]; case 2: return [2 /*return*/, _a.sent()];
case 3: case 3:
error_3 = _a.sent(); error_3 = _a.sent();
message = getMessage(error_3); return [2 /*return*/, checkError(method, error_3, params)];
// "insufficient funds for gas * price + value" case 4: return [2 /*return*/];
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
throw error_3;
case 4:
_a.trys.push([4, 6, , 7]);
return [4 /*yield*/, this.send(args[0], args[1])];
case 5: return [2 /*return*/, _a.sent()];
case 6:
error_4 = _a.sent();
if (ErrorGas.indexOf(method) >= 0 && getMessage(error_4).match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
transaction: params.transaction,
error: error_4
});
}
throw error_4;
case 7: return [2 /*return*/];
} }
}); });
}); });
@ -25352,14 +25343,42 @@
return parseInt(blockTag.substring(2), 16); return parseInt(blockTag.substring(2), 16);
} }
var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"; var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
function checkGasError(error, transaction) { function checkError(method, error, transaction) {
// Get the message from any nested error structure
var message = error.message; var message = error.message;
if (error.code === lib.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === lib.Logger.errors.SERVER_ERROR) {
message = error.error.message; if (error.error && typeof (error.error.message) === "string") {
message = error.error.message;
}
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") {
message = error.responseText;
}
}
message = (message || "").toLowerCase();
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", lib.Logger.errors.INSUFFICIENT_FUNDS, {
error: error, method: method, transaction: transaction
});
}
// "Transaction with the same hash was already imported."
if (message.match(/same hash was already imported|transaction nonce is too low/)) {
logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {
error: error, method: method, transaction: transaction
});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (message.match(/another transaction with same nonce/)) {
logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {
error: error, method: method, transaction: transaction
});
} }
if (message.match(/execution failed due to an exception/)) { if (message.match(/execution failed due to an exception/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, transaction: transaction error: error, method: method, transaction: transaction
}); });
} }
throw error; throw error;
@ -25498,21 +25517,7 @@
url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction;
url += apiKey; url += apiKey;
return [2 /*return*/, get(url).catch(function (error) { return [2 /*return*/, get(url).catch(function (error) {
if (error.responseText) { return checkError("sendTransaction", error, params.signedTransaction);
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "Transaction with the same hash was already imported."
if (error.responseText.indexOf("same hash was already imported") >= 0) {
logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (error.responseText.indexOf("another transaction with same nonce") >= 0) {
logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
}
throw error;
})]; })];
case 8: case 8:
if (params.blockTag) { if (params.blockTag) {
@ -25553,7 +25558,7 @@
case 13: return [2 /*return*/, _c.sent()]; case 13: return [2 /*return*/, _c.sent()];
case 14: case 14:
error_1 = _c.sent(); error_1 = _c.sent();
return [2 /*return*/, checkGasError(error_1, params.transaction)]; return [2 /*return*/, checkError("call", error_1, params.transaction)];
case 15: case 15:
transaction = getTransactionString(params.transaction); transaction = getTransactionString(params.transaction);
if (transaction) { if (transaction) {
@ -25568,7 +25573,7 @@
case 17: return [2 /*return*/, _c.sent()]; case 17: return [2 /*return*/, _c.sent()];
case 18: case 18:
error_2 = _c.sent(); error_2 = _c.sent();
return [2 /*return*/, checkGasError(error_2, params.transaction)]; return [2 /*return*/, checkError("estimateGas", error_2, params.transaction)];
case 19: case 19:
url += "/api?module=logs&action=getLogs"; url += "/api?module=logs&action=getLogs";
if (params.filter.fromBlock) { if (params.filter.fromBlock) {
@ -27248,7 +27253,7 @@
var _version$M = createCommonjsModule(function (module, exports) { var _version$M = createCommonjsModule(function (module, exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "ethers/5.0.13"; exports.version = "ethers/5.0.14";
}); });

File diff suppressed because one or more lines are too long

@ -1 +1 @@
export declare const version = "ethers/5.0.13"; export declare const version = "ethers/5.0.14";

@ -1,2 +1,2 @@
export const version = "ethers/5.0.13"; export const version = "ethers/5.0.14";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -1 +1 @@
export declare const version = "ethers/5.0.13"; export declare const version = "ethers/5.0.14";

@ -1,4 +1,4 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "ethers/5.0.13"; exports.version = "ethers/5.0.14";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -50,7 +50,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"tarballHash": "0xb8476f841c067f73428c25fb242f7921ea6c3e5b1b234dd4d0ffc9d677911176", "tarballHash": "0xd6a863af707ae407c539e1f12dcc3bf2dc97c355a1b187547ff3957f0ed0d897",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"version": "5.0.13" "version": "5.0.14"
} }

@ -1 +1 @@
export const version = "ethers/5.0.13"; export const version = "ethers/5.0.14";

@ -1 +1 @@
export declare const version = "providers/5.0.8"; export declare const version = "providers/5.0.9";

@ -1,2 +1,2 @@
export const version = "providers/5.0.8"; export const version = "providers/5.0.9";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -84,14 +84,42 @@ function checkLogTag(blockTag) {
return parseInt(blockTag.substring(2), 16); return parseInt(blockTag.substring(2), 16);
} }
const defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"; const defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
function checkGasError(error, transaction) { function checkError(method, error, transaction) {
// Get the message from any nested error structure
let message = error.message; let message = error.message;
if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === Logger.errors.SERVER_ERROR) {
message = error.error.message; if (error.error && typeof (error.error.message) === "string") {
message = error.error.message;
}
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") {
message = error.responseText;
}
}
message = (message || "").toLowerCase();
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", Logger.errors.INSUFFICIENT_FUNDS, {
error, method, transaction
});
}
// "Transaction with the same hash was already imported."
if (message.match(/same hash was already imported|transaction nonce is too low/)) {
logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
error, method, transaction
});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (message.match(/another transaction with same nonce/)) {
logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
error, method, transaction
});
} }
if (message.match(/execution failed due to an exception/)) { if (message.match(/execution failed due to an exception/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error, transaction error, method, transaction
}); });
} }
throw error; throw error;
@ -196,21 +224,7 @@ export class EtherscanProvider extends BaseProvider {
url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction;
url += apiKey; url += apiKey;
return get(url).catch((error) => { return get(url).catch((error) => {
if (error.responseText) { return checkError("sendTransaction", error, params.signedTransaction);
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "Transaction with the same hash was already imported."
if (error.responseText.indexOf("same hash was already imported") >= 0) {
logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (error.responseText.indexOf("another transaction with same nonce") >= 0) {
logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
}
throw error;
}); });
case "getBlock": case "getBlock":
if (params.blockTag) { if (params.blockTag) {
@ -248,7 +262,7 @@ export class EtherscanProvider extends BaseProvider {
return yield get(url); return yield get(url);
} }
catch (error) { catch (error) {
return checkGasError(error, params.transaction); return checkError("call", error, params.transaction);
} }
} }
case "estimateGas": { case "estimateGas": {
@ -262,7 +276,7 @@ export class EtherscanProvider extends BaseProvider {
return yield get(url); return yield get(url);
} }
catch (error) { catch (error) {
return checkGasError(error, params.transaction); return checkError("estimateGas", error, params.transaction);
} }
} }
case "getLogs": { case "getLogs": {

File diff suppressed because one or more lines are too long

@ -18,16 +18,44 @@ import { Logger } from "@ethersproject/logger";
import { version } from "./_version"; import { version } from "./_version";
const logger = new Logger(version); const logger = new Logger(version);
import { BaseProvider } from "./base-provider"; import { BaseProvider } from "./base-provider";
const ErrorGas = ["call", "estimateGas"]; const errorGas = ["call", "estimateGas"];
function getMessage(error) { function checkError(method, error, params) {
let message = error.message; let message = error.message;
if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
message = error.error.message; message = error.error.message;
} }
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") { else if (typeof (error.responseText) === "string") {
message = error.responseText; message = error.responseText;
} }
return message || ""; message = (message || "").toLowerCase();
const transaction = params.transaction || params.signedTransaction;
// "insufficient funds for gas * price + value + cost(data)"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", Logger.errors.INSUFFICIENT_FUNDS, {
error, method, transaction
});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
error, method, transaction
});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
error, method, transaction
});
}
if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error, method, transaction
});
}
throw error;
} }
function timer(timeout) { function timer(timeout) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
@ -127,25 +155,7 @@ export class JsonRpcSigner extends Signer {
return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => { return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => {
return hash; return hash;
}, (error) => { }, (error) => {
if (error.responseText) { return checkError("sendTransaction", error, hexTx);
// See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??)
if (error.responseText.indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {
transaction: tx
});
}
if (error.responseText.indexOf("nonce too low") >= 0) {
logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {
transaction: tx
});
}
if (error.responseText.indexOf("replacement transaction underpriced") >= 0) {
logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {
transaction: tx
});
}
}
throw error;
}); });
}); });
} }
@ -362,39 +372,11 @@ export class JsonRpcProvider extends BaseProvider {
if (args == null) { if (args == null) {
logger.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); logger.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method });
} }
// We need a little extra logic to process errors from sendTransaction
if (method === "sendTransaction") {
try {
return yield this.send(args[0], args[1]);
}
catch (error) {
const message = getMessage(error);
// "insufficient funds for gas * price + value"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
throw error;
}
}
try { try {
return yield this.send(args[0], args[1]); return yield this.send(args[0], args[1]);
} }
catch (error) { catch (error) {
if (ErrorGas.indexOf(method) >= 0 && getMessage(error).match(/gas required exceeds allowance|always failing transaction|execution reverted/)) { return checkError(method, error, params);
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
transaction: params.transaction,
error: error
});
}
throw error;
} }
}); });
} }

File diff suppressed because one or more lines are too long

@ -1 +1 @@
export declare const version = "providers/5.0.8"; export declare const version = "providers/5.0.9";

@ -1,4 +1,4 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "providers/5.0.8"; exports.version = "providers/5.0.9";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -125,14 +125,42 @@ function checkLogTag(blockTag) {
return parseInt(blockTag.substring(2), 16); return parseInt(blockTag.substring(2), 16);
} }
var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB"; var defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
function checkGasError(error, transaction) { function checkError(method, error, transaction) {
// Get the message from any nested error structure
var message = error.message; var message = error.message;
if (error.code === logger_1.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === logger_1.Logger.errors.SERVER_ERROR) {
message = error.error.message; if (error.error && typeof (error.error.message) === "string") {
message = error.error.message;
}
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") {
message = error.responseText;
}
}
message = (message || "").toLowerCase();
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
error: error, method: method, transaction: transaction
});
}
// "Transaction with the same hash was already imported."
if (message.match(/same hash was already imported|transaction nonce is too low/)) {
logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
error: error, method: method, transaction: transaction
});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (message.match(/another transaction with same nonce/)) {
logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
error: error, method: method, transaction: transaction
});
} }
if (message.match(/execution failed due to an exception/)) { if (message.match(/execution failed due to an exception/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, transaction: transaction error: error, method: method, transaction: transaction
}); });
} }
throw error; throw error;
@ -271,21 +299,7 @@ var EtherscanProvider = /** @class */ (function (_super) {
url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction;
url += apiKey; url += apiKey;
return [2 /*return*/, get(url).catch(function (error) { return [2 /*return*/, get(url).catch(function (error) {
if (error.responseText) { return checkError("sendTransaction", error, params.signedTransaction);
// "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0"
if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "Transaction with the same hash was already imported."
if (error.responseText.indexOf("same hash was already imported") >= 0) {
logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {});
}
// "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce."
if (error.responseText.indexOf("another transaction with same nonce") >= 0) {
logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
}
throw error;
})]; })];
case 8: case 8:
if (params.blockTag) { if (params.blockTag) {
@ -326,7 +340,7 @@ var EtherscanProvider = /** @class */ (function (_super) {
case 13: return [2 /*return*/, _c.sent()]; case 13: return [2 /*return*/, _c.sent()];
case 14: case 14:
error_1 = _c.sent(); error_1 = _c.sent();
return [2 /*return*/, checkGasError(error_1, params.transaction)]; return [2 /*return*/, checkError("call", error_1, params.transaction)];
case 15: case 15:
transaction = getTransactionString(params.transaction); transaction = getTransactionString(params.transaction);
if (transaction) { if (transaction) {
@ -341,7 +355,7 @@ var EtherscanProvider = /** @class */ (function (_super) {
case 17: return [2 /*return*/, _c.sent()]; case 17: return [2 /*return*/, _c.sent()];
case 18: case 18:
error_2 = _c.sent(); error_2 = _c.sent();
return [2 /*return*/, checkGasError(error_2, params.transaction)]; return [2 /*return*/, checkError("estimateGas", error_2, params.transaction)];
case 19: case 19:
url += "/api?module=logs&action=getLogs"; url += "/api?module=logs&action=getLogs";
if (params.filter.fromBlock) { if (params.filter.fromBlock) {

File diff suppressed because one or more lines are too long

@ -59,16 +59,44 @@ var logger_1 = require("@ethersproject/logger");
var _version_1 = require("./_version"); var _version_1 = require("./_version");
var logger = new logger_1.Logger(_version_1.version); var logger = new logger_1.Logger(_version_1.version);
var base_provider_1 = require("./base-provider"); var base_provider_1 = require("./base-provider");
var ErrorGas = ["call", "estimateGas"]; var errorGas = ["call", "estimateGas"];
function getMessage(error) { function checkError(method, error, params) {
var message = error.message; var message = error.message;
if (error.code === logger_1.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") { if (error.code === logger_1.Logger.errors.SERVER_ERROR && error.error && typeof (error.error.message) === "string") {
message = error.error.message; message = error.error.message;
} }
else if (typeof (error.body) === "string") {
message = error.body;
}
else if (typeof (error.responseText) === "string") { else if (typeof (error.responseText) === "string") {
message = error.responseText; message = error.responseText;
} }
return message || ""; message = (message || "").toLowerCase();
var transaction = params.transaction || params.signedTransaction;
// "insufficient funds for gas * price + value + cost(data)"
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds for intrinsic transaction cost", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
error: error, method: method, transaction: transaction
});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
error: error, method: method, transaction: transaction
});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
error: error, method: method, transaction: transaction
});
}
if (errorGas.indexOf(method) >= 0 && message.match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
error: error, method: method, transaction: transaction
});
}
throw error;
} }
function timer(timeout) { function timer(timeout) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
@ -175,25 +203,7 @@ var JsonRpcSigner = /** @class */ (function (_super) {
return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) { return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) {
return hash; return hash;
}, function (error) { }, function (error) {
if (error.responseText) { return checkError("sendTransaction", error, hexTx);
// See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??)
if (error.responseText.indexOf("insufficient funds") >= 0) {
logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {
transaction: tx
});
}
if (error.responseText.indexOf("nonce too low") >= 0) {
logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {
transaction: tx
});
}
if (error.responseText.indexOf("replacement transaction underpriced") >= 0) {
logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {
transaction: tx
});
}
}
throw error;
}); });
}); });
}; };
@ -441,7 +451,7 @@ var JsonRpcProvider = /** @class */ (function (_super) {
}; };
JsonRpcProvider.prototype.perform = function (method, params) { JsonRpcProvider.prototype.perform = function (method, params) {
return __awaiter(this, void 0, void 0, function () { return __awaiter(this, void 0, void 0, function () {
var args, error_3, message, error_4; var args, error_3;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
@ -449,7 +459,6 @@ var JsonRpcProvider = /** @class */ (function (_super) {
if (args == null) { if (args == null) {
logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
} }
if (!(method === "sendTransaction")) return [3 /*break*/, 4];
_a.label = 1; _a.label = 1;
case 1: case 1:
_a.trys.push([1, 3, , 4]); _a.trys.push([1, 3, , 4]);
@ -457,34 +466,8 @@ var JsonRpcProvider = /** @class */ (function (_super) {
case 2: return [2 /*return*/, _a.sent()]; case 2: return [2 /*return*/, _a.sent()];
case 3: case 3:
error_3 = _a.sent(); error_3 = _a.sent();
message = getMessage(error_3); return [2 /*return*/, checkError(method, error_3, params)];
// "insufficient funds for gas * price + value" case 4: return [2 /*return*/];
if (message.match(/insufficient funds/)) {
logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {});
}
// "nonce too low"
if (message.match(/nonce too low/)) {
logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {});
}
// "replacement transaction underpriced"
if (message.match(/replacement transaction underpriced/)) {
logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {});
}
throw error_3;
case 4:
_a.trys.push([4, 6, , 7]);
return [4 /*yield*/, this.send(args[0], args[1])];
case 5: return [2 /*return*/, _a.sent()];
case 6:
error_4 = _a.sent();
if (ErrorGas.indexOf(method) >= 0 && getMessage(error_4).match(/gas required exceeds allowance|always failing transaction|execution reverted/)) {
logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, {
transaction: params.transaction,
error: error_4
});
}
throw error_4;
case 7: return [2 /*return*/];
} }
}); });
}); });

File diff suppressed because one or more lines are too long

@ -59,7 +59,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"tarballHash": "0x6497c83c317c075e1d3ec251abbafb15b297694697fe000fd9642f71c5b44350", "tarballHash": "0x2437a85e3c64aeff5af6d691b30c19bded65bafac5cbee29ff05c341584d9b03",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"version": "5.0.8" "version": "5.0.9"
} }

@ -1 +1 @@
export const version = "providers/5.0.8"; export const version = "providers/5.0.9";

@ -1 +1 @@
export declare const version = "tests/5.0.7"; export declare const version = "tests/5.0.8";

@ -1,2 +1,2 @@
export const version = "tests/5.0.7"; export const version = "tests/5.0.8";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -534,6 +534,99 @@ function testProvider(providerName, networkName) {
return testTransactionReceipt(test); return testTransactionReceipt(test);
}); });
}); });
if (networkName === "ropsten") {
it("throws correct NONCE_EXPIRED errors", function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(60000);
try {
const tx = yield provider.sendTransaction("0xf86480850218711a0082520894000000000000000000000000000000000000000002801ba038aaddcaaae7d3fa066dfd6f196c8348e1bb210f2c121d36cb2c24ef20cea1fba008ae378075d3cd75aae99ab75a70da82161dffb2c8263dabc5d8adecfa9447fa");
console.log(tx);
assert.ok(false);
}
catch (error) {
assert.equal(error.code, ethers.utils.Logger.errors.NONCE_EXPIRED);
}
yield waiter(delay);
});
});
it("throws correct INSUFFICIENT_FUNDS errors", function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(60000);
const txProps = {
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
gasPrice: 9000000000,
gasLimit: 21000,
value: 1
};
const wallet = ethers.Wallet.createRandom();
const tx = yield wallet.signTransaction(txProps);
try {
yield provider.sendTransaction(tx);
assert.ok(false);
}
catch (error) {
assert.equal(error.code, ethers.utils.Logger.errors.INSUFFICIENT_FUNDS);
}
yield waiter(delay);
});
});
it("throws correct INSUFFICIENT_FUNDS errors (signer)", function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(60000);
const txProps = {
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
gasPrice: 9000000000,
gasLimit: 21000,
value: 1
};
const wallet = ethers.Wallet.createRandom().connect(provider);
try {
yield wallet.sendTransaction(txProps);
assert.ok(false);
}
catch (error) {
assert.equal(error.code, ethers.utils.Logger.errors.INSUFFICIENT_FUNDS);
}
yield waiter(delay);
});
});
it("throws correct UNPREDICTABLE_GAS_LIMIT errors", function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(60000);
try {
yield provider.estimateGas({
to: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" // ENS; no payable fallback
});
assert.ok(false);
}
catch (error) {
assert.equal(error.code, ethers.utils.Logger.errors.UNPREDICTABLE_GAS_LIMIT);
}
yield waiter(delay);
});
});
it("sends a transaction", function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(360000);
const wallet = ethers.Wallet.createRandom().connect(provider);
const funder = yield ethers.utils.fetchJson(`https:/\/api.ethers.io/api/v1/?action=fundAccount&address=${wallet.address.toLowerCase()}`);
yield provider.waitForTransaction(funder.hash);
const addr = "0x8210357f377E901f18E45294e86a2A32215Cc3C9";
const gasPrice = 9000000000;
let balance = yield provider.getBalance(wallet.address);
assert.ok(balance.eq(ethers.utils.parseEther("3.141592653589793238")), "balance is pi after funding");
const tx = yield wallet.sendTransaction({
to: addr,
gasPrice: gasPrice,
value: balance.sub(21000 * gasPrice)
});
yield tx.wait();
balance = yield provider.getBalance(wallet.address);
assert.ok(balance.eq(ethers.constants.Zero), "balance is zero after after sweeping");
yield waiter(delay);
});
});
}
// Obviously many more cases to add here // Obviously many more cases to add here
// - getTransactionCount // - getTransactionCount
// - getBlockNumber // - getBlockNumber

File diff suppressed because one or more lines are too long

@ -1 +1 @@
export declare const version = "tests/5.0.7"; export declare const version = "tests/5.0.8";

@ -1,4 +1,4 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "tests/5.0.7"; exports.version = "tests/5.0.8";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -565,6 +565,178 @@ function testProvider(providerName, networkName) {
return testTransactionReceipt(test); return testTransactionReceipt(test);
}); });
}); });
if (networkName === "ropsten") {
it("throws correct NONCE_EXPIRED errors", function () {
return __awaiter(this, void 0, void 0, function () {
var tx, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.timeout(60000);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, provider.sendTransaction("0xf86480850218711a0082520894000000000000000000000000000000000000000002801ba038aaddcaaae7d3fa066dfd6f196c8348e1bb210f2c121d36cb2c24ef20cea1fba008ae378075d3cd75aae99ab75a70da82161dffb2c8263dabc5d8adecfa9447fa")];
case 2:
tx = _a.sent();
console.log(tx);
assert_1.default.ok(false);
return [3 /*break*/, 4];
case 3:
error_1 = _a.sent();
assert_1.default.equal(error_1.code, ethers_1.ethers.utils.Logger.errors.NONCE_EXPIRED);
return [3 /*break*/, 4];
case 4: return [4 /*yield*/, waiter(delay)];
case 5:
_a.sent();
return [2 /*return*/];
}
});
});
});
it("throws correct INSUFFICIENT_FUNDS errors", function () {
return __awaiter(this, void 0, void 0, function () {
var txProps, wallet, tx, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.timeout(60000);
txProps = {
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
gasPrice: 9000000000,
gasLimit: 21000,
value: 1
};
wallet = ethers_1.ethers.Wallet.createRandom();
return [4 /*yield*/, wallet.signTransaction(txProps)];
case 1:
tx = _a.sent();
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, provider.sendTransaction(tx)];
case 3:
_a.sent();
assert_1.default.ok(false);
return [3 /*break*/, 5];
case 4:
error_2 = _a.sent();
assert_1.default.equal(error_2.code, ethers_1.ethers.utils.Logger.errors.INSUFFICIENT_FUNDS);
return [3 /*break*/, 5];
case 5: return [4 /*yield*/, waiter(delay)];
case 6:
_a.sent();
return [2 /*return*/];
}
});
});
});
it("throws correct INSUFFICIENT_FUNDS errors (signer)", function () {
return __awaiter(this, void 0, void 0, function () {
var txProps, wallet, error_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.timeout(60000);
txProps = {
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
gasPrice: 9000000000,
gasLimit: 21000,
value: 1
};
wallet = ethers_1.ethers.Wallet.createRandom().connect(provider);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, wallet.sendTransaction(txProps)];
case 2:
_a.sent();
assert_1.default.ok(false);
return [3 /*break*/, 4];
case 3:
error_3 = _a.sent();
assert_1.default.equal(error_3.code, ethers_1.ethers.utils.Logger.errors.INSUFFICIENT_FUNDS);
return [3 /*break*/, 4];
case 4: return [4 /*yield*/, waiter(delay)];
case 5:
_a.sent();
return [2 /*return*/];
}
});
});
});
it("throws correct UNPREDICTABLE_GAS_LIMIT errors", function () {
return __awaiter(this, void 0, void 0, function () {
var error_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.timeout(60000);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, provider.estimateGas({
to: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" // ENS; no payable fallback
})];
case 2:
_a.sent();
assert_1.default.ok(false);
return [3 /*break*/, 4];
case 3:
error_4 = _a.sent();
assert_1.default.equal(error_4.code, ethers_1.ethers.utils.Logger.errors.UNPREDICTABLE_GAS_LIMIT);
return [3 /*break*/, 4];
case 4: return [4 /*yield*/, waiter(delay)];
case 5:
_a.sent();
return [2 /*return*/];
}
});
});
});
it("sends a transaction", function () {
return __awaiter(this, void 0, void 0, function () {
var wallet, funder, addr, gasPrice, balance, tx;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.timeout(360000);
wallet = ethers_1.ethers.Wallet.createRandom().connect(provider);
return [4 /*yield*/, ethers_1.ethers.utils.fetchJson("https://api.ethers.io/api/v1/?action=fundAccount&address=" + wallet.address.toLowerCase())];
case 1:
funder = _a.sent();
return [4 /*yield*/, provider.waitForTransaction(funder.hash)];
case 2:
_a.sent();
addr = "0x8210357f377E901f18E45294e86a2A32215Cc3C9";
gasPrice = 9000000000;
return [4 /*yield*/, provider.getBalance(wallet.address)];
case 3:
balance = _a.sent();
assert_1.default.ok(balance.eq(ethers_1.ethers.utils.parseEther("3.141592653589793238")), "balance is pi after funding");
return [4 /*yield*/, wallet.sendTransaction({
to: addr,
gasPrice: gasPrice,
value: balance.sub(21000 * gasPrice)
})];
case 4:
tx = _a.sent();
return [4 /*yield*/, tx.wait()];
case 5:
_a.sent();
return [4 /*yield*/, provider.getBalance(wallet.address)];
case 6:
balance = _a.sent();
assert_1.default.ok(balance.eq(ethers_1.ethers.constants.Zero), "balance is zero after after sweeping");
return [4 /*yield*/, waiter(delay)];
case 7:
_a.sent();
return [2 /*return*/];
}
});
});
});
}
// Obviously many more cases to add here // Obviously many more cases to add here
// - getTransactionCount // - getTransactionCount
// - getBlockNumber // - getBlockNumber

File diff suppressed because one or more lines are too long

@ -39,7 +39,7 @@
"scripts": { "scripts": {
"test": "exit 1" "test": "exit 1"
}, },
"tarballHash": "0x25213910eebf653a9cf2daafdf8e9b87d9bfa604ef840b08027e3f657787fd84", "tarballHash": "0xeba001b6d7814b9df776d8a5b395ba7080d99ea8a6dfc8fad70888a5f7d01f3e",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"version": "5.0.7" "version": "5.0.8"
} }

@ -1 +1 @@
export const version = "tests/5.0.7"; export const version = "tests/5.0.8";

@ -1 +1 @@
export declare const version = "web/5.0.6"; export declare const version = "web/5.0.7";

@ -1,2 +1,2 @@
export const version = "web/5.0.6"; export const version = "web/5.0.7";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -29,7 +29,7 @@ function bodyify(value, type) {
return value; return value;
} }
if (isBytesLike(value)) { if (isBytesLike(value)) {
if (type && (type.split("/")[0] === "text" || type === "application/json")) { if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
try { try {
return toUtf8String(value); return toUtf8String(value);
} }

File diff suppressed because one or more lines are too long

@ -1 +1 @@
export declare const version = "web/5.0.6"; export declare const version = "web/5.0.7";

@ -1,4 +1,4 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "web/5.0.6"; exports.version = "web/5.0.7";
//# sourceMappingURL=_version.js.map //# sourceMappingURL=_version.js.map

@ -57,7 +57,7 @@ function bodyify(value, type) {
return value; return value;
} }
if (bytes_1.isBytesLike(value)) { if (bytes_1.isBytesLike(value)) {
if (type && (type.split("/")[0] === "text" || type === "application/json")) { if (type && (type.split("/")[0] === "text" || type.split(";")[0].trim() === "application/json")) {
try { try {
return strings_1.toUtf8String(value); return strings_1.toUtf8String(value);
} }

File diff suppressed because one or more lines are too long

@ -36,7 +36,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"tarballHash": "0x15cf7ac63d44623bbad9c1aa766639af3008658cea3bc6b9309bd0eb3f7f3e85", "tarballHash": "0x1f274a77544d4f64d2f8a10c084670396dba509920a9fc5dbca2e321c7dde98d",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"version": "5.0.6" "version": "5.0.7"
} }

@ -1 +1 @@
export const version = "web/5.0.6"; export const version = "web/5.0.7";