Fixed receipt wait not throwing on reverted transactions.
This commit is contained in:
parent
ff80b04f31
commit
25fef4f8d7
@ -1460,12 +1460,27 @@ export class TransactionResponse implements TransactionLike<string>, Transaction
|
||||
return;
|
||||
};
|
||||
|
||||
const checkReceipt = (receipt: null | TransactionReceipt) => {
|
||||
if (receipt == null || receipt.status !== 0) { return receipt; }
|
||||
assert(false, "transaction execution reverted", "CALL_EXCEPTION", {
|
||||
action: "sendTransaction",
|
||||
data: null, reason: null, invocation: null, revert: null,
|
||||
transaction: {
|
||||
to: receipt.to,
|
||||
from: receipt.from,
|
||||
data: "" // @TODO: in v7, split out sendTransaction properties
|
||||
}, receipt
|
||||
});
|
||||
};
|
||||
|
||||
const receipt = await this.provider.getTransactionReceipt(this.hash);
|
||||
|
||||
if (confirms === 0) { return receipt; }
|
||||
if (confirms === 0) { return checkReceipt(receipt); }
|
||||
|
||||
if (receipt) {
|
||||
if ((await receipt.confirmations()) >= confirms) { return receipt; }
|
||||
if ((await receipt.confirmations()) >= confirms) {
|
||||
return checkReceipt(receipt);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Check for a replacement; throws if a replacement was found
|
||||
@ -1496,9 +1511,10 @@ export class TransactionResponse implements TransactionLike<string>, Transaction
|
||||
// Done; return it!
|
||||
if ((await receipt.confirmations()) >= confirms) {
|
||||
cancel();
|
||||
resolve(receipt);
|
||||
try {
|
||||
resolve(checkReceipt(receipt));
|
||||
} catch (error) { reject(error); }
|
||||
}
|
||||
|
||||
};
|
||||
cancellers.push(() => { this.provider.off(this.hash, txListener); });
|
||||
this.provider.on(this.hash, txListener);
|
||||
|
@ -385,9 +385,9 @@ export interface UnexpectedArgumentError extends EthersError<"UNEXPECTED_ARGUMEN
|
||||
// Blockchain Errors
|
||||
|
||||
/**
|
||||
* The action that resulted in the error.
|
||||
* The action that resulted in the call exception.
|
||||
*/
|
||||
export type CallExceptionAction = "call" | "estimateGas" | "getTransactionResult" | "unknown";
|
||||
export type CallExceptionAction = "call" | "estimateGas" | "getTransactionResult" | "sendTransaction" | "unknown";
|
||||
|
||||
/**
|
||||
* The related transaction that caused the error.
|
||||
@ -402,6 +402,7 @@ export type CallExceptionTransaction = {
|
||||
* This **Error** indicates a transaction reverted.
|
||||
*/
|
||||
export interface CallExceptionError extends EthersError<"CALL_EXCEPTION"> {
|
||||
|
||||
/**
|
||||
* The action being performed when the revert was encountered.
|
||||
*/
|
||||
@ -439,8 +440,15 @@ export interface CallExceptionError extends EthersError<"CALL_EXCEPTION"> {
|
||||
name: string;
|
||||
args: Array<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the error occurred in a transaction that was mined
|
||||
* (with a status of ``0``), this is the receipt.
|
||||
*/
|
||||
receipt?: TransactionReceipt; // @TODO: in v7, make this `null | TransactionReceipt`
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The sending account has insufficient funds to cover the
|
||||
* entire transaction cost.
|
||||
|
Loading…
Reference in New Issue
Block a user