From 30e3afc0fbccd01ef5ce62de4dfb0154fd7b7892 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 5 Jul 2018 17:48:02 -0700 Subject: Add unmarshallTxData to marshaller --- packages/web3-wrapper/src/marshaller.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'packages/web3-wrapper/src') diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index e9fd35a11..15384417e 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -73,6 +73,19 @@ export const marshaller = { }; return tx; }, + unmarshalTxData(txDataRpc: TxDataRPC): TxData { + if (_.isUndefined(txDataRpc.from)) { + throw new Error(`txData must include valid 'from' value.`); + } + const txData = { + ...txDataRpc, + value: !_.isUndefined(txDataRpc.value) ? utils.convertHexToNumber(txDataRpc.value) : undefined, + gas: !_.isUndefined(txDataRpc.gas) ? utils.convertHexToNumber(txDataRpc.gas) : undefined, + gasPrice: !_.isUndefined(txDataRpc.gasPrice) ? utils.convertHexToNumber(txDataRpc.gasPrice) : undefined, + nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, + }; + return txData; + }, marshalTxData(txData: Partial): Partial { if (_.isUndefined(txData.from)) { throw new Error(`txData must include valid 'from' value.`); -- cgit v1.2.3