fix: txData returned so that value and gasPrice are BigNumbers to avoid precision errors

This commit is contained in:
Fabio Berger
2018-12-07 15:21:55 +00:00
committed by Fred Carlsen
parent 785981ce58
commit e368106932
2 changed files with 12 additions and 4 deletions

View File

@@ -1,4 +1,12 @@
[
{
"version": "3.2.0",
"changes": [
{
"note": "Return `value` and `gasPrice` as BigNumbers to avoid loss of precision errors"
}
]
},
{
"version": "3.1.6",
"changes": [

View File

@@ -1,4 +1,4 @@
import { addressUtils } from '@0x/utils';
import { addressUtils, BigNumber } from '@0x/utils';
import {
BlockParam,
BlockParamLiteral,
@@ -120,10 +120,10 @@ export const marshaller = {
}
const txData = {
...txDataRpc,
value: !_.isUndefined(txDataRpc.value) ? utils.convertHexToNumber(txDataRpc.value) : undefined,
value: !_.isUndefined(txDataRpc.value) ? utils.convertAmountToBigNumber(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,
gasPrice: !_.isUndefined(txDataRpc.gasPrice) ? utils.convertAmountToBigNumber(txDataRpc.gasPrice) : undefined,
nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, , , , , , , ,
};
return txData;
},