From 22cfdd9f0b5cd2b8d53384e16defc956570ccd6a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 20 Nov 2018 14:48:32 +0100 Subject: Properly unmarshall TransactionReceiptRPC to TransactionReceipt --- packages/web3-wrapper/src/marshaller.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/web3-wrapper/src/marshaller.ts') diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index 299c6a64c..7bd274c85 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -9,6 +9,7 @@ import { LogEntry, RawLogEntry, Transaction, + TransactionReceipt, TxData, } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); @@ -21,6 +22,7 @@ import { BlockWithTransactionDataRPC, CallDataRPC, CallTxDataBaseRPC, + TransactionReceiptRPC, TransactionRPC, TxDataRPC, } from './types'; @@ -91,6 +93,22 @@ export const marshaller = { }; return tx; }, + /** + * Unmarshall transaction receipt + * @param txReceiptRpc transaction receipt to unmarshall + * @return unmarshalled transaction receipt + */ + unmarshalTransactionReceipt(txReceiptRpc: TransactionReceiptRPC): TransactionReceipt { + const txReceipt = { + ...txReceiptRpc, + blockNumber: utils.convertHexToNumber(txReceiptRpc.blockNumber), + transactionIndex: utils.convertHexToNumber(txReceiptRpc.transactionIndex), + cumulativeGasUsed: utils.convertHexToNumber(txReceiptRpc.cumulativeGasUsed), + gasUsed: utils.convertHexToNumber(txReceiptRpc.gasUsed), + logs: _.map(txReceiptRpc.logs, marshaller.unmarshalLog.bind(marshaller)), + }; + return txReceipt; + }, /** * Unmarshall transaction data * @param txDataRpc transaction data to unmarshall -- cgit v1.2.3