Merge pull request #829 from 0xProject/bug/web3-wrapper/fix-invalid-transaction-format

Fix invalid transaction format errors when going through `SingerSubprovider`
This commit is contained in:
Francesco Agosti
2018-07-06 11:46:03 -07:00
committed by GitHub
4 changed files with 26 additions and 2 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "0.7.3",
"changes": [
{
"note": "Export `marshaller` utility file.",
"pr": 829
}
]
},
{
"timestamp": 1529397769,
"version": "0.7.2",

View File

@@ -1,2 +1,3 @@
export { Web3Wrapper, uniqueVersionIds, NodeType } from './web3_wrapper';
export { Web3WrapperErrors } from './types';
export { marshaller } from './marshaller';

View File

@@ -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<TxData>): Partial<TxDataRPC> {
if (_.isUndefined(txData.from)) {
throw new Error(`txData must include valid 'from' value.`);