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:
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "0.7.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Export `marshaller` utility file.",
|
||||
"pr": 829
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.7.2",
|
||||
|
@@ -1,2 +1,3 @@
|
||||
export { Web3Wrapper, uniqueVersionIds, NodeType } from './web3_wrapper';
|
||||
export { Web3WrapperErrors } from './types';
|
||||
export { marshaller } from './marshaller';
|
||||
|
@@ -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.`);
|
||||
|
Reference in New Issue
Block a user