Fixed estimateGas which can return insufficient funds errors.
This commit is contained in:
parent
2845a3c4b6
commit
924cfef5de
@ -274,6 +274,14 @@ export class BaseEtherscanProvider extends AbstractProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (req.method === "estimateGas") {
|
||||
if (!message.match(/revert/i) && message.match(/insufficient funds/i)) {
|
||||
assert(false, "insufficient funds", "INSUFFICIENT_FUNDS", {
|
||||
transaction: req.transaction
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (req.method === "call" || req.method === "estimateGas") {
|
||||
if (message.match(/execution reverted/i)) {
|
||||
let data = "";
|
||||
@ -287,7 +295,6 @@ export class BaseEtherscanProvider extends AbstractProvider {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (message) {
|
||||
if (req.method === "broadcastTransaction") {
|
||||
const transaction = Transaction.from(req.signedTransaction);
|
||||
|
@ -787,6 +787,15 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
|
||||
const { method } = payload;
|
||||
const { error } = _error;
|
||||
|
||||
if (method === "eth_estimateGas" && error.message) {
|
||||
const msg = error.message;
|
||||
if (!msg.match(/revert/i) && msg.match(/insufficient funds/i)) {
|
||||
return makeError("insufficient funds", "INSUFFICIENT_FUNDS", {
|
||||
transaction: ((<any>payload).params[0]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (method === "eth_call" || method === "eth_estimateGas") {
|
||||
const result = spelunkData(error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user