From 84f1d1107ab5b723d4dc176945d6778a6c91dafd Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 7 Dec 2018 15:21:55 +0000 Subject: fix: txData returned so that `value` and `gasPrice` are BigNumbers to avoid precision errors --- packages/web3-wrapper/CHANGELOG.json | 8 ++++++++ packages/web3-wrapper/src/marshaller.ts | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 9f5194e0d..cb7cc16e5 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -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": [ diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index 7bd274c85..b368695bd 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -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; }, -- cgit v1.2.3 From ccd8d4ac30f363bfe4302a35f57ac3828b4bcf15 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 7 Dec 2018 15:25:07 +0000 Subject: Remove excess commas --- packages/web3-wrapper/src/marshaller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index b368695bd..7091a3bdb 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -123,7 +123,7 @@ export const marshaller = { value: !_.isUndefined(txDataRpc.value) ? utils.convertAmountToBigNumber(txDataRpc.value) : undefined, gas: !_.isUndefined(txDataRpc.gas) ? utils.convertHexToNumber(txDataRpc.gas) : undefined, gasPrice: !_.isUndefined(txDataRpc.gasPrice) ? utils.convertAmountToBigNumber(txDataRpc.gasPrice) : undefined, - nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, , , , , , , , + nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, }; return txData; }, -- cgit v1.2.3 From 4034eb7655b8ebacc39ba9164cefe079e110ff49 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 7 Dec 2018 15:30:36 +0000 Subject: Add PR number --- packages/web3-wrapper/CHANGELOG.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index cb7cc16e5..ed484c8e8 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -3,7 +3,8 @@ "version": "3.2.0", "changes": [ { - "note": "Return `value` and `gasPrice` as BigNumbers to avoid loss of precision errors" + "note": "Return `value` and `gasPrice` as BigNumbers to avoid loss of precision errors", + "pr": 1402 } ] }, -- cgit v1.2.3 From 1a44d86c59fea7b08a8f30b078d8e2c9b730b1b3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 7 Dec 2018 17:55:38 +0000 Subject: Fix linter --- packages/web3-wrapper/src/marshaller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts index 7091a3bdb..4230f8eab 100644 --- a/packages/web3-wrapper/src/marshaller.ts +++ b/packages/web3-wrapper/src/marshaller.ts @@ -1,4 +1,4 @@ -import { addressUtils, BigNumber } from '@0x/utils'; +import { addressUtils } from '@0x/utils'; import { BlockParam, BlockParamLiteral, @@ -122,7 +122,9 @@ export const marshaller = { ...txDataRpc, value: !_.isUndefined(txDataRpc.value) ? utils.convertAmountToBigNumber(txDataRpc.value) : undefined, gas: !_.isUndefined(txDataRpc.gas) ? utils.convertHexToNumber(txDataRpc.gas) : undefined, - gasPrice: !_.isUndefined(txDataRpc.gasPrice) ? utils.convertAmountToBigNumber(txDataRpc.gasPrice) : undefined, + gasPrice: !_.isUndefined(txDataRpc.gasPrice) + ? utils.convertAmountToBigNumber(txDataRpc.gasPrice) + : undefined, nonce: !_.isUndefined(txDataRpc.nonce) ? utils.convertHexToNumber(txDataRpc.nonce) : undefined, }; return txData; -- cgit v1.2.3