bug: Only unmarshall receipt if blockNumber present.

https://github.com/paritytech/parity-ethereum/issues/1180
Parity can return a pending transaction receipt with a number of null values
This commit is contained in:
Jacob Evans 2018-11-23 15:20:33 +11:00
parent a5359df002
commit 03b3b80a65
No known key found for this signature in database
GPG Key ID: 2036DA2ADDFB0842
2 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,13 @@
[ [
{
"version": "3.1.6",
"changes": [
{
"note": "Unmarshall mined transaction receipts",
"pr": 1308
}
]
},
{ {
"version": "3.1.5", "version": "3.1.5",
"changes": [ "changes": [

View File

@ -223,7 +223,10 @@ export class Web3Wrapper {
method: 'eth_getTransactionReceipt', method: 'eth_getTransactionReceipt',
params: [txHash], params: [txHash],
}); });
if (!_.isNull(transactionReceiptRpc)) { // HACK Parity can return a pending transaction receipt. We check for a non null
// block number before continuing with returning a fully realised receipt.
// ref: https://github.com/paritytech/parity-ethereum/issues/1180
if (!_.isNull(transactionReceiptRpc) && !_.isNull(transactionReceiptRpc.blockNumber)) {
transactionReceiptRpc.status = Web3Wrapper._normalizeTxReceiptStatus(transactionReceiptRpc.status); transactionReceiptRpc.status = Web3Wrapper._normalizeTxReceiptStatus(transactionReceiptRpc.status);
const transactionReceipt = marshaller.unmarshalTransactionReceipt(transactionReceiptRpc); const transactionReceipt = marshaller.unmarshalTransactionReceipt(transactionReceiptRpc);
return transactionReceipt; return transactionReceipt;
@ -577,7 +580,7 @@ export class Web3Wrapper {
} }
// Immediately check if the transaction has already been mined. // Immediately check if the transaction has already been mined.
let transactionReceipt = await this.getTransactionReceiptIfExistsAsync(txHash); let transactionReceipt = await this.getTransactionReceiptIfExistsAsync(txHash);
if (!_.isUndefined(transactionReceipt) && !_.isNull(transactionReceipt.blockNumber)) { if (!_.isUndefined(transactionReceipt)) {
const logsWithDecodedArgs = _.map( const logsWithDecodedArgs = _.map(
transactionReceipt.logs, transactionReceipt.logs,
this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder), this.abiDecoder.tryToDecodeLogOrNoop.bind(this.abiDecoder),