The Byzantinum fork, IIRC, enabled adding the status to the transaction receipts. But for chains that did not activate it, the status is still null instead of 0x0 or 0x1. Following is the code that parses it to boolean:
When testing with some transactions in a chain that did not fork, we saw the status field was incorrectly parsed as false for receipts with status coming as null, which might not be correct as status is actually not provided. This is not enough to say the transaction failed or not.
The condition might be changed to something like the following to properly account for null, 0x0 and 0x1 values:
if(typeof receipt.status === 'string') {
receipt.status = Boolean(parseInt(receipt.status));
}
@frozeman & team, can you please provide your thoughts?
Thanks for submitting this issue. That's true will change it as soon as possible.
@alcuadrado @cgewecke this issue was patched in 1ac78d1 @ #2429 on the 2.x branch but that PR cannot be backported to 1.x. Actually, the only line that needs to be backported, strictly speaking, is this:
--- a/packages/web3-core-helpers/src/formatters.js
+++ b/packages/web3-core-helpers/src/formatters.js
@@ -216,7 +216,7 @@ var outputTransactionReceiptFormatter = function (receipt){
receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress);
}
- if(typeof receipt.status !== 'undefined') {
+ if(typeof receipt.status !== 'undefined' && receipt.status !== null) {
receipt.status = Boolean(parseInt(receipt.status));
}
Issue #3070 says "change causes many 1.x test failures" but it looks like applying this patch on top of v1.2.1 does not break any test.
2495 passing (25s)
Of course some tests should be added to cover the case of a receipt being returned as null.
@gabmontes Ok excellent. Will open a PR fixing rn Will update #3090 to include this.
Most helpful comment
@alcuadrado @cgewecke this issue was patched in 1ac78d1 @ #2429 on the
2.xbranch but that PR cannot be backported to1.x. Actually, the only line that needs to be backported, strictly speaking, is this:Issue #3070 says "change causes many 1.x test failures" but it looks like applying this patch on top of
v1.2.1does not break any test.Of course some tests should be added to cover the case of a receipt being returned as
null.