From 83b2cd7e10f2e8de841eb63e25a6bcc422d07436 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Mon, 18 Feb 2019 11:45:40 +0100 Subject: [PATCH] Update bignumber and methods + other non breaking packages (#364) * Update bignumber and methods + other non breaking packages * Removed unused flowtype * Removed unused flowtype 2 --- package.json | 12 +- .../ethereum/SendFormValidationActions.js | 22 +- .../ripple/SendFormValidationActions.js | 8 +- .../Context/components/Static/index.js | 2 +- src/flowtype/npm/bignumber.js | 8 +- yarn.lock | 387 +++++++++--------- 6 files changed, 226 insertions(+), 213 deletions(-) diff --git a/package.json b/package.json index 4b15be37..714cf0ac 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@babel/polyfill": "^7.2.5", - "bignumber.js": "2.4.0", + "bignumber.js": "8.0.2", "color-hash": "^1.0.3", "commander": "^2.19.0", "connected-react-router": "^6.2.2", @@ -38,7 +38,7 @@ "date-fns": "^1.30.1", "ethereumjs-tx": "^1.3.7", "ethereumjs-units": "^0.2.0", - "ethereumjs-util": "^5.2.0", + "ethereumjs-util": "^6.0.0", "express": "^4.16.4", "friendly-errors-webpack-plugin": "^1.7.0", "git-revision-webpack-plugin": "^3.0.3", @@ -52,8 +52,8 @@ "raf": "^3.4.1", "raven-js": "^3.27.0", "rc-tooltip": "^3.7.3", - "react": "^16.8.0", - "react-dom": "^16.8.0", + "react": "^16.8.1", + "react-dom": "^16.8.1", "react-hot-loader": "^4.6.5", "react-json-view": "^1.19.1", "react-qr-reader": "^2.1.2", @@ -77,8 +77,8 @@ "trezor-bridge-communicator": "1.0.2", "trezor-connect": "7.0.0-beta.2", "wallet-address-validator": "^0.2.4", - "web3": "1.0.0-beta.41", - "webpack": "^4.29.1", + "web3": "1.0.0-beta.43", + "webpack": "^4.29.3", "webpack-build-notifier": "^0.1.30", "webpack-bundle-analyzer": "^3.0.3", "whatwg-fetch": "^3.0.0", diff --git a/src/actions/ethereum/SendFormValidationActions.js b/src/actions/ethereum/SendFormValidationActions.js index 16a30c7f..f8ddecea 100644 --- a/src/actions/ethereum/SendFormValidationActions.js +++ b/src/actions/ethereum/SendFormValidationActions.js @@ -226,16 +226,16 @@ export const amountValidation = ($state: State): PayloadAction => (dispat if (!state.amount.match(decimalRegExp)) { state.errors.amount = `Maximum ${token.decimals} decimals allowed`; - } else if (new BigNumber(state.total).greaterThan(account.balance)) { + } else if (new BigNumber(state.total).isGreaterThan(account.balance)) { state.errors.amount = `Not enough ${state.networkSymbol} to cover transaction fee`; - } else if (new BigNumber(state.amount).greaterThan(new BigNumber(token.balance).minus(pendingAmount))) { + } else if (new BigNumber(state.amount).isGreaterThan(new BigNumber(token.balance).minus(pendingAmount))) { state.errors.amount = 'Not enough funds'; - } else if (new BigNumber(state.amount).lessThanOrEqualTo('0')) { + } else if (new BigNumber(state.amount).isLessThanOrEqualTo('0')) { state.errors.amount = 'Amount is too low'; } } else if (!state.amount.match(ETH_18_RE)) { state.errors.amount = 'Maximum 18 decimals allowed'; - } else if (new BigNumber(state.total).greaterThan(new BigNumber(account.balance).minus(pendingAmount))) { + } else if (new BigNumber(state.total).isGreaterThan(new BigNumber(account.balance).minus(pendingAmount))) { state.errors.amount = 'Not enough funds'; } } @@ -261,9 +261,9 @@ export const gasLimitValidation = ($state: State): PayloadAction => (disp state.errors.gasLimit = 'Gas limit is not a number'; } else { const gl: BigNumber = new BigNumber(gasLimit); - if (gl.lessThan(1)) { + if (gl.isLessThan(1)) { state.errors.gasLimit = 'Gas limit is too low'; - } else if (gl.lessThan(state.currency !== state.networkSymbol ? network.defaultGasLimitTokens : network.defaultGasLimit)) { + } else if (gl.isLessThan(state.currency !== state.networkSymbol ? network.defaultGasLimitTokens : network.defaultGasLimit)) { state.warnings.gasLimit = 'Gas limit is below recommended'; } } @@ -284,9 +284,9 @@ export const gasPriceValidation = ($state: State): PayloadAction => (): S state.errors.gasPrice = 'Gas price is not a number'; } else { const gp: BigNumber = new BigNumber(gasPrice); - if (gp.greaterThan(1000)) { + if (gp.isGreaterThan(1000)) { state.warnings.gasPrice = 'Gas price is too high'; - } else if (gp.lessThanOrEqualTo('0')) { + } else if (gp.isLessThanOrEqualTo('0')) { state.errors.gasPrice = 'Gas price is too low'; } } @@ -312,9 +312,9 @@ export const nonceValidation = ($state: State): PayloadAction => (dispatc state.errors.nonce = 'Nonce is not a valid number'; } else { const n: BigNumber = new BigNumber(nonce); - if (n.lessThan(account.nonce)) { + if (n.isLessThan(account.nonce)) { state.warnings.nonce = 'Nonce is lower than recommended'; - } else if (n.greaterThan(account.nonce)) { + } else if (n.isGreaterThan(account.nonce)) { state.warnings.nonce = 'Nonce is greater than recommended'; } } @@ -358,7 +358,7 @@ export const calculateMaxAmount = (balance: BigNumber, gasPrice: string, gasLimi // TODO - minus pendings const fee = calculateFee(gasPrice, gasLimit); const max = balance.minus(fee); - if (max.lessThan(0)) return '0'; + if (max.isLessThan(0)) return '0'; return max.toFixed(); } catch (error) { return '0'; diff --git a/src/actions/ripple/SendFormValidationActions.js b/src/actions/ripple/SendFormValidationActions.js index 4ee3a2f9..d4f4c765 100644 --- a/src/actions/ripple/SendFormValidationActions.js +++ b/src/actions/ripple/SendFormValidationActions.js @@ -236,7 +236,7 @@ const amountValidation = ($state: State): PayloadAction => (dispatch: Dis const pendingAmount: BigNumber = getPendingAmount(pending, state.networkSymbol); if (!state.amount.match(XRP_6_RE)) { state.errors.amount = 'Maximum 6 decimals allowed'; - } else if (new BigNumber(state.total).greaterThan(new BigNumber(account.balance).minus(pendingAmount))) { + } else if (new BigNumber(state.total).isGreaterThan(new BigNumber(account.balance).minus(pendingAmount))) { state.errors.amount = 'Not enough funds'; } } @@ -271,9 +271,9 @@ export const feeValidation = ($state: State): PayloadAction => (dispatch: state.errors.fee = 'Fee must be an absolute number'; } else { const gl: BigNumber = new BigNumber(fee); - if (gl.lessThan(network.fee.minFee)) { + if (gl.isLessThan(network.fee.minFee)) { state.errors.fee = 'Fee is below recommended'; - } else if (gl.greaterThan(network.fee.maxFee)) { + } else if (gl.isGreaterThan(network.fee.maxFee)) { state.errors.fee = 'Fee is above recommended'; } } @@ -310,7 +310,7 @@ const calculateMaxAmount = (balance: BigNumber, fee: string): string => { try { // TODO - minus pendings const max = balance.minus(fee); - if (max.lessThan(0)) return '0'; + if (max.isLessThan(0)) return '0'; return max.toFixed(); } catch (error) { return '0'; diff --git a/src/components/notifications/Context/components/Static/index.js b/src/components/notifications/Context/components/Static/index.js index af8b09d5..912569cf 100644 --- a/src/components/notifications/Context/components/Static/index.js +++ b/src/components/notifications/Context/components/Static/index.js @@ -19,7 +19,7 @@ export default (props: Props) => { const { reserve, balance } = account; const bigBalance = new Bignumber(balance); const bigReserve = new Bignumber(reserve); - if (bigBalance.lessThan(bigReserve)) { + if (bigBalance.isLessThan(bigReserve)) { notifications.push(