From 71ba843c66f52d750198fe3ef7713ad4e7ed5109 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Mon, 18 Feb 2019 11:30:31 +0100 Subject: [PATCH 01/24] hide sidebar in default state on small screens --- src/reducers/WalletReducer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reducers/WalletReducer.js b/src/reducers/WalletReducer.js index 35df8b18..2bd6d657 100644 --- a/src/reducers/WalletReducer.js +++ b/src/reducers/WalletReducer.js @@ -29,7 +29,7 @@ const initialState: State = { dropdownOpened: false, firstLocationChange: true, showBetaDisclaimer: false, - showSidebar: true, + showSidebar: false, initialParams: null, initialPathname: null, disconnectRequest: null, From 83b2cd7e10f2e8de841eb63e25a6bcc422d07436 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Mon, 18 Feb 2019 11:45:40 +0100 Subject: [PATCH 02/24] 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( Date: Tue, 19 Feb 2019 12:07:59 +0100 Subject: [PATCH 03/24] changelog adjusted --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d772cfce..440a3eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +## 1.1.0-beta +__added__ +- Ripple support enabled +- responsive sidebar +- QR code scanner in send form +- clear send form button + +__changed__ +- update dependencies +- upgrade babel7 +- split icons for T1 and TT +- device header styles +- input styles +- split sign and verify title + +__fixed__ +- beta disclaimer wrapper position +- sidebar scrollbar + ## 1.0.3-beta __added__ - Ethereum: sign & verify tab From 4e11e3ee0d6cf65e710f1105e8173eb70f0b8986 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 19 Feb 2019 15:49:17 +0100 Subject: [PATCH 04/24] fix missing indicator on account change --- src/views/Wallet/components/TopNavigationAccount/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/Wallet/components/TopNavigationAccount/index.js b/src/views/Wallet/components/TopNavigationAccount/index.js index 94977803..8d41e095 100644 --- a/src/views/Wallet/components/TopNavigationAccount/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/index.js @@ -69,6 +69,7 @@ const StyledNavLink = styled(NavLink)` class TopNavigationAccount extends React.PureComponent { wrapperRefCallback = (element: ?HTMLElement) => { this.wrapper = element; + this.forceUpdate(); } wrapper: ?HTMLElement; From 1d431afef970291f7419a693c19fdb591af92cee Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 19 Feb 2019 17:05:25 +0100 Subject: [PATCH 05/24] Update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 714cf0ac..6d1c987e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trezor-wallet", - "version": "1.0.0", + "version": "1.0.3-beta", "author": "TREZOR ", "description": "", "bin": { From e116cb17cd879bee73caac076682be6cd8276469 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 19 Feb 2019 17:07:44 +0100 Subject: [PATCH 06/24] fix missing indicator on account change --- .../components/TopNavigationAccount/index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/views/Wallet/components/TopNavigationAccount/index.js b/src/views/Wallet/components/TopNavigationAccount/index.js index 8d41e095..a320ebcc 100644 --- a/src/views/Wallet/components/TopNavigationAccount/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/index.js @@ -14,6 +14,9 @@ type Props = { router: $ElementType, selectedAccount: $ElementType, }; +type StateProps = { + wrapper: ?HTMLElement, +}; const Wrapper = styled.div` position: relative; @@ -66,10 +69,18 @@ const StyledNavLink = styled(NavLink)` } `; -class TopNavigationAccount extends React.PureComponent { +class TopNavigationAccount extends React.PureComponent { + constructor(props) { + super(props); + this.state = { + wrapper: null, + }; + } + wrapperRefCallback = (element: ?HTMLElement) => { - this.wrapper = element; - this.forceUpdate(); + this.setState({ + wrapper: element, + }); } wrapper: ?HTMLElement; @@ -90,7 +101,7 @@ class TopNavigationAccount extends React.PureComponent { {network.type === 'ethereum' && Sign & Verify } - this.wrapper} /> + this.state.wrapper} /> ); } From 8da8544316ec3f1ebf9836a6d36814daa695d0cb Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 19 Feb 2019 17:12:56 +0100 Subject: [PATCH 07/24] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f016fcf9..06ecf42d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Trezor Wallet +You can try this wallet live [HERE](https://beta-wallet.trezor.io/next/) + To install dependencies run `npm install` or `yarn` To start locally run `npm run dev` or `yarn run dev` To build the project run `npm run build` or `yarn run build` From 0422dc78baed5d4dce74e566818f324f17f6d9d6 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 19 Feb 2019 17:21:17 +0100 Subject: [PATCH 08/24] rename types --- src/views/Wallet/components/TopNavigationAccount/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/Wallet/components/TopNavigationAccount/index.js b/src/views/Wallet/components/TopNavigationAccount/index.js index a320ebcc..192c1164 100644 --- a/src/views/Wallet/components/TopNavigationAccount/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/index.js @@ -14,7 +14,7 @@ type Props = { router: $ElementType, selectedAccount: $ElementType, }; -type StateProps = { +type LocalState = { wrapper: ?HTMLElement, }; @@ -69,7 +69,7 @@ const StyledNavLink = styled(NavLink)` } `; -class TopNavigationAccount extends React.PureComponent { +class TopNavigationAccount extends React.PureComponent { constructor(props) { super(props); this.state = { From 53c7c20a29f7da755f70990c80e0d969bd428ee8 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 19 Feb 2019 19:10:47 +0100 Subject: [PATCH 09/24] throw exception when non-num string is passed to Bignumber() --- src/actions/ethereum/SendFormValidationActions.js | 7 ++++++- src/actions/ripple/SendFormValidationActions.js | 7 ++++++- src/flowtype/npm/bignumber.js | 1 + src/utils/formatUtils.js | 14 ++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/actions/ethereum/SendFormValidationActions.js b/src/actions/ethereum/SendFormValidationActions.js index f8ddecea..66d787d4 100644 --- a/src/actions/ethereum/SendFormValidationActions.js +++ b/src/actions/ethereum/SendFormValidationActions.js @@ -347,7 +347,12 @@ export const calculateFee = (gasPrice: string, gasLimit: string): string => { export const calculateTotal = (amount: string, gasPrice: string, gasLimit: string): string => { try { - return new BigNumber(amount).plus(calculateFee(gasPrice, gasLimit)).toFixed(); + const bAmount = new BigNumber(amount); + // BigNumber() returns NaN on non-numeric string + if (bAmount.isNaN()) { + throw new Error('Amount is not a number'); + } + return bAmount.plus(calculateFee(gasPrice, gasLimit)).toFixed(); } catch (error) { return '0'; } diff --git a/src/actions/ripple/SendFormValidationActions.js b/src/actions/ripple/SendFormValidationActions.js index d4f4c765..6ef5bbca 100644 --- a/src/actions/ripple/SendFormValidationActions.js +++ b/src/actions/ripple/SendFormValidationActions.js @@ -300,7 +300,12 @@ export const destinationTagValidation = ($state: State): PayloadAction => const calculateTotal = (amount: string, fee: string): string => { try { - return new BigNumber(amount).plus(fee).toFixed(); + const bAmount = new BigNumber(amount); + // BigNumber() returns NaN on non-numeric string + if (bAmount.isNaN()) { + throw new Error('Amount is not a number'); + } + return bAmount.plus(fee).toFixed(); } catch (error) { return '0'; } diff --git a/src/flowtype/npm/bignumber.js b/src/flowtype/npm/bignumber.js index fd1a31ef..d7bca1a4 100644 --- a/src/flowtype/npm/bignumber.js +++ b/src/flowtype/npm/bignumber.js @@ -37,6 +37,7 @@ declare module 'bignumber.js' { isLessThan(n: $npm$big$number$object): boolean; lte(n: $npm$big$number$object): boolean; isLessThanOrEqualTo(n: $npm$big$number$object): boolean; + isNaN(): boolean; minus(n: $npm$big$number$object): T_BigNumber; mod(n: $npm$big$number$object): T_BigNumber; plus(n: $npm$big$number$object): T_BigNumber; diff --git a/src/utils/formatUtils.js b/src/utils/formatUtils.js index a273959c..37231d7c 100644 --- a/src/utils/formatUtils.js +++ b/src/utils/formatUtils.js @@ -56,7 +56,12 @@ export const hexToString = (hex: string): string => { export const toDecimalAmount = (amount: string | number, decimals: number): string => { try { - return new BigNumber(amount).div(10 ** decimals).toString(10); + const bAmount = new BigNumber(amount); + // BigNumber() returns NaN on non-numeric string + if (bAmount.isNaN()) { + throw new Error('Amount is not a number'); + } + return bAmount.div(10 ** decimals).toString(10); } catch (error) { return '0'; } @@ -64,7 +69,12 @@ export const toDecimalAmount = (amount: string | number, decimals: number): stri export const fromDecimalAmount = (amount: string | number, decimals: number): string => { try { - return new BigNumber(amount).times(10 ** decimals).toString(10); + const bAmount = new BigNumber(amount); + // BigNumber() returns NaN on non-numeric string + if (bAmount.isNaN()) { + throw new Error('Amount is not a number'); + } + return bAmount.times(10 ** decimals).toString(10); } catch (error) { return '0'; } From 2927f5ebafec79202488f89017e5df8cdef8439e Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 19 Feb 2019 19:30:39 +0100 Subject: [PATCH 10/24] same send button text for xrp and eth --- src/views/Wallet/views/Account/Send/ripple/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/Wallet/views/Account/Send/ripple/index.js b/src/views/Wallet/views/Account/Send/ripple/index.js index 096a63ef..ce761231 100644 --- a/src/views/Wallet/views/Account/Send/ripple/index.js +++ b/src/views/Wallet/views/Account/Send/ripple/index.js @@ -248,7 +248,10 @@ const AccountSend = (props: Props) => { } let isSendButtonDisabled: boolean = Object.keys(errors).length > 0 || total === '0' || amount.length === 0 || address.length === 0 || sending; - let sendButtonText: string = ` ${total} ${network.symbol}`; + let sendButtonText: string = 'Send'; + if (total !== '0') { + sendButtonText = `${sendButtonText} ${total} ${network.symbol}`; + } if (!device.connected) { sendButtonText = 'Device is not connected'; From c975303469ac68e9f25ce620ad21066fa8bb5b06 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 19 Feb 2019 21:48:48 +0100 Subject: [PATCH 11/24] Add app version page (#375) * Add app version page * add github link --- .eslintrc | 3 ++- src/components/Footer/index.js | 4 +-- src/support/routes.js | 5 ++++ src/views/Landing/views/Version/index.js | 33 ++++++++++++++++++++++++ src/views/index.js | 2 ++ webpack/dev.babel.js | 8 +++--- webpack/production.babel.js | 2 ++ 7 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/views/Landing/views/Version/index.js diff --git a/.eslintrc b/.eslintrc index 4e457674..37d11b68 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,7 +6,8 @@ ], "globals": { "LOCAL": true, - "COMMITHASH": true + "COMMITHASH": true, + "VERSION": true }, "env": { "browser": true, diff --git a/src/components/Footer/index.js b/src/components/Footer/index.js index b9df79fc..7dfd026c 100644 --- a/src/components/Footer/index.js +++ b/src/components/Footer/index.js @@ -12,8 +12,6 @@ import colors from 'config/colors'; import { FONT_SIZE } from 'config/variables'; import * as LogActions from 'actions/LogActions'; -declare var COMMITHASH: string; - type Props = { opened: boolean, isLanding: boolean, @@ -60,7 +58,7 @@ const Right = styled.div` const Footer = ({ opened, toggle, isLanding }: Props) => ( - © {getYear(new Date())} + © {getYear(new Date())} SatoshiLabs Terms { opened ? 'Hide Log' : 'Show Log' } diff --git a/src/support/routes.js b/src/support/routes.js index 90452679..717bed03 100644 --- a/src/support/routes.js +++ b/src/support/routes.js @@ -12,6 +12,11 @@ export const routes: Array = [ pattern: '/', fields: [], }, + { + name: 'landing-version', + pattern: '/version', + fields: ['version'], + }, { name: 'landing-bridge', pattern: '/bridge', diff --git a/src/views/Landing/views/Version/index.js b/src/views/Landing/views/Version/index.js new file mode 100644 index 00000000..dee88428 --- /dev/null +++ b/src/views/Landing/views/Version/index.js @@ -0,0 +1,33 @@ +import React from 'react'; +import styled from 'styled-components'; +import { H3, H2 } from 'components/Heading'; +import LandingWrapper from 'views/Landing/components/LandingWrapper'; +import Link from 'components/Link'; + +const Wrapper = styled.div` + display: flex; + flex: 1; + flex-direction: column; + align-items: center; + justify-content: center; +`; + +const Line = styled.div` + padding: 20px; +`; + +const Version = () => ( + + +

APPLICATION VERSION

+

{VERSION}

+ +

LAST COMMIT HASH

+ +

{COMMITHASH}

+ +
+
+); + +export default Version; \ No newline at end of file diff --git a/src/views/index.js b/src/views/index.js index 62221dce..1b0a8963 100644 --- a/src/views/index.js +++ b/src/views/index.js @@ -7,6 +7,7 @@ import { ConnectedRouter } from 'connected-react-router'; // general import ErrorBoundary from 'support/ErrorBoundary'; import ImagesPreloader from 'support/ImagesPreloader'; +import Version from 'views/Landing/views/Version'; import { getPattern } from 'support/routes'; // landing views @@ -38,6 +39,7 @@ const App = () => ( + diff --git a/webpack/dev.babel.js b/webpack/dev.babel.js index 89e45dab..5c770fc9 100644 --- a/webpack/dev.babel.js +++ b/webpack/dev.babel.js @@ -3,14 +3,15 @@ import GitRevisionPlugin from 'git-revision-webpack-plugin'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin'; import WebpackBuildNotifierPlugin from 'webpack-build-notifier'; - -// turn on for bundle analyzing -// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; +import packageJson from '../package.json'; import { SRC, BUILD, PORT, PUBLIC, } from './constants'; +// turn on for bundle analyzing +// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; + const gitRevisionPlugin = new GitRevisionPlugin(); module.exports = { @@ -103,6 +104,7 @@ module.exports = { suppressSuccess: true, }), new webpack.DefinePlugin({ + VERSION: JSON.stringify(packageJson.version), COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()), }), new HtmlWebpackPlugin({ diff --git a/webpack/production.babel.js b/webpack/production.babel.js index 0a6bc979..9be7e0b5 100644 --- a/webpack/production.babel.js +++ b/webpack/production.babel.js @@ -3,6 +3,7 @@ import GitRevisionPlugin from 'git-revision-webpack-plugin'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin'; import CopyWebpackPlugin from 'copy-webpack-plugin'; +import packageJson from '../package.json'; import { SRC, BUILD, PUBLIC } from './constants'; const gitRevisionPlugin = new GitRevisionPlugin(); @@ -65,6 +66,7 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env.BUILD': JSON.stringify(process.env.BUILD), + VERSION: JSON.stringify(packageJson.version), COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()), }), new HtmlWebpackPlugin({ From e9d3f3ff92026812d0a686a198b5510849582c19 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 20 Feb 2019 12:04:21 +0100 Subject: [PATCH 12/24] Fixed trezor one name, padding adjusted --- src/actions/SelectedAccountActions.js | 4 +++- .../Content/components/FirmwareUnsupported/index.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/actions/SelectedAccountActions.js b/src/actions/SelectedAccountActions.js index 868b7155..bddee57b 100644 --- a/src/actions/SelectedAccountActions.js +++ b/src/actions/SelectedAccountActions.js @@ -52,9 +52,11 @@ const getExceptionPage = (state: State, selectedAccount: SelectedAccountState): }; } if (discovery.fwNotSupported) { + const trezorModel = device.features.model; + const trezorName = trezorModel.toString() === '1' ? 'One' : trezorModel; return { type: 'fwNotSupported', - title: `${network.name} is not supported with Trezor ${device.features.model}`, + title: `${network.name} is not supported with Trezor ${trezorName}`, message: 'Find more information on Trezor Wiki.', shortcut: network.shortcut, }; diff --git a/src/views/Wallet/components/Content/components/FirmwareUnsupported/index.js b/src/views/Wallet/components/Content/components/FirmwareUnsupported/index.js index b48f562b..9d7afdbc 100644 --- a/src/views/Wallet/components/Content/components/FirmwareUnsupported/index.js +++ b/src/views/Wallet/components/Content/components/FirmwareUnsupported/index.js @@ -32,7 +32,7 @@ const Wrapper = styled.div` `; const CoinLogoWrapper = styled.div` - margin: 10px 0; + margin: 10px 0 20px 0; `; const StyledCoinLogo = styled(CoinLogo)` From 8e4dd7c471d62fd9c4f941145d1152bd1b9bea05 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 20 Feb 2019 12:17:28 +0100 Subject: [PATCH 13/24] Use utils for trezor model --- src/actions/SelectedAccountActions.js | 6 +++--- src/components/images/TrezorImage/index.js | 3 ++- src/utils/device.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/actions/SelectedAccountActions.js b/src/actions/SelectedAccountActions.js index bddee57b..c71c0457 100644 --- a/src/actions/SelectedAccountActions.js +++ b/src/actions/SelectedAccountActions.js @@ -8,6 +8,7 @@ import * as TOKEN from 'actions/constants/token'; import * as PENDING from 'actions/constants/pendingTx'; import * as reducerUtils from 'reducers/utils'; +import { getVersion } from 'utils/device'; import { initialState } from 'reducers/SelectedAccountReducer'; import type { @@ -51,12 +52,11 @@ const getExceptionPage = (state: State, selectedAccount: SelectedAccountState): shortcut: 'not-used', }; } + if (discovery.fwNotSupported) { - const trezorModel = device.features.model; - const trezorName = trezorModel.toString() === '1' ? 'One' : trezorModel; return { type: 'fwNotSupported', - title: `${network.name} is not supported with Trezor ${trezorName}`, + title: `${network.name} is not supported with Trezor ${getVersion(device)}`, message: 'Find more information on Trezor Wiki.', shortcut: network.shortcut, }; diff --git a/src/components/images/TrezorImage/index.js b/src/components/images/TrezorImage/index.js index abc6fdf0..7a106b68 100644 --- a/src/components/images/TrezorImage/index.js +++ b/src/components/images/TrezorImage/index.js @@ -16,7 +16,8 @@ const Img = styled.img` const TrezorImage = ({ model }: Props) => { // $FlowIssue: `require` must be a string literal. - const src = require(`./images/trezor-${model}.png`); // eslint-disable-line + const imageName = model === 'One' ? 1 : model; + const src = require(`./images/trezor-${imageName}.png`); // eslint-disable-line return ( diff --git a/src/utils/device.js b/src/utils/device.js index e0cada08..b1b4db72 100644 --- a/src/utils/device.js +++ b/src/utils/device.js @@ -104,7 +104,7 @@ export const getVersion = (device: TrezorDevice): string => { if (device.features && device.features.major_version > 1) { version = 'T'; } else { - version = '1'; + version = 'One'; } return version; }; From 46984d6e794480de539e72ee91304e3d06626a87 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Wed, 20 Feb 2019 13:59:15 +0100 Subject: [PATCH 14/24] fix proptypes --- src/components/Tooltip/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Tooltip/index.js b/src/components/Tooltip/index.js index 9bd4ec68..17cb2344 100644 --- a/src/components/Tooltip/index.js +++ b/src/components/Tooltip/index.js @@ -68,7 +68,7 @@ Tooltip.propTypes = { PropTypes.string, ]), readMoreLink: PropTypes.string, - enterDelayMs: PropTypes.bool, + enterDelayMs: PropTypes.number, }; export default Tooltip; From 1ddac8eabffe0422936d97a697f68eee872929c2 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Wed, 20 Feb 2019 14:28:11 +0100 Subject: [PATCH 15/24] downgrade connected-react-router@6.0.0 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6d1c987e..b9e7d27f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "bignumber.js": "8.0.2", "color-hash": "^1.0.3", "commander": "^2.19.0", - "connected-react-router": "^6.2.2", + "connected-react-router": "6.0.0", "copy-webpack-plugin": "^4.6.0", "cross-env": "^5.2.0", "date-fns": "^1.30.1", diff --git a/yarn.lock b/yarn.lock index c8ed20a3..f42ab115 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2949,10 +2949,10 @@ connect-history-api-fallback@^1.3.0: version "1.5.0" resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz#b06873934bc5e344fef611a196a6faae0aee015a" -connected-react-router@^6.2.2: - version "6.2.2" - resolved "https://registry.yarnpkg.com/connected-react-router/-/connected-react-router-6.2.2.tgz#10ed0942ee2032de7cb0fd8479bde526853906ed" - integrity sha512-tPI3s7yYtnTt/XLoQFsQqIEQxdQCrsZltEdozjG7LPkOTNglJJ7WqUqnlnh9thC6ebavfaJoTtPa9G2EibuJbg== +connected-react-router@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/connected-react-router/-/connected-react-router-6.0.0.tgz#cb7ccbbc5ed353832ecd91d68289c916e8aba734" + integrity sha512-TarPqf2wY3cz993Mw3eBg2U12M5OmaGwKzJsinvRQh61nKb8WMUvimyhu6u2HeWS8625PHFXjNOU0OIAMWj/bQ== dependencies: immutable "^3.8.1" seamless-immutable "^7.1.3" From faa837c6ddcca6e25d36a18eaf31c14020159584 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 20 Feb 2019 14:58:01 +0100 Subject: [PATCH 16/24] fix unit tests --- src/utils/__tests__/__snapshots__/device.test.js.snap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/__tests__/__snapshots__/device.test.js.snap b/src/utils/__tests__/__snapshots__/device.test.js.snap index 8ce5ffe6..d7109016 100644 --- a/src/utils/__tests__/__snapshots__/device.test.js.snap +++ b/src/utils/__tests__/__snapshots__/device.test.js.snap @@ -44,15 +44,15 @@ exports[`device utils get status name 7`] = `"Disconnected"`; exports[`device utils get status name 8`] = `"Unavailable"`; -exports[`device utils get version 1`] = `"1"`; +exports[`device utils get version 1`] = `"One"`; -exports[`device utils get version 2`] = `"1"`; +exports[`device utils get version 2`] = `"One"`; -exports[`device utils get version 3`] = `"1"`; +exports[`device utils get version 3`] = `"One"`; -exports[`device utils get version 4`] = `"1"`; +exports[`device utils get version 4`] = `"One"`; -exports[`device utils get version 5`] = `"1"`; +exports[`device utils get version 5`] = `"One"`; exports[`device utils get version 6`] = `"T"`; From ea52c526ff48db8ab7a7ba943d31119fdc27dbe9 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 20 Feb 2019 15:16:22 +0100 Subject: [PATCH 17/24] fix flow --- src/components/images/TrezorImage/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/images/TrezorImage/index.js b/src/components/images/TrezorImage/index.js index 7a106b68..0e0c716b 100644 --- a/src/components/images/TrezorImage/index.js +++ b/src/components/images/TrezorImage/index.js @@ -15,8 +15,8 @@ const Img = styled.img` `; const TrezorImage = ({ model }: Props) => { - // $FlowIssue: `require` must be a string literal. const imageName = model === 'One' ? 1 : model; + // $FlowIssue: `require` must be a string literal. const src = require(`./images/trezor-${imageName}.png`); // eslint-disable-line return ( From a9d5cf4344bb1b36ab36cfb64c50ef8328a408cc Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 20 Feb 2019 15:32:04 +0100 Subject: [PATCH 18/24] Removed docker readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 06ecf42d..2162d8c7 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,6 @@ To install dependencies run `npm install` or `yarn` To start locally run `npm run dev` or `yarn run dev` To build the project run `npm run build` or `yarn run build` -## Docker -- Build `./scripts/docker-build.sh` -- Run `./scripts/docker-run.sh` - ## Project structure The project is divided into two parts - data that are used when compiling the project and data that aren't. From 48c0b2afcebdb68d4b556f953fad2916757fe412 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Wed, 20 Feb 2019 16:35:28 +0100 Subject: [PATCH 19/24] add more user-friendly error messages --- src/components/modals/QrModal/index.js | 64 ++++++++++++++++---------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/src/components/modals/QrModal/index.js b/src/components/modals/QrModal/index.js index 1eef2b10..25fb353f 100644 --- a/src/components/modals/QrModal/index.js +++ b/src/components/modals/QrModal/index.js @@ -38,11 +38,18 @@ const CameraPlaceholder = styled(P)` padding: 10px 0; `; -const Error = styled(P)` - text-align: center; +const Error = styled.div` padding: 10px 0; +`; + +const ErrorTitle = styled(P)` + text-align: center; color: ${colors.ERROR_PRIMARY}; `; +const ErrorMessage = styled.span` + text-align: center; + color: ${colors.TEXT_PRIMARY}; +`; const StyledQrReader = styled(QrReader)` padding: 10px 0; @@ -95,14 +102,25 @@ class QrModal extends React.Component { } handleError = (err: any) => { - console.log(err); - this.setState({ - error: err, - }); - + // log thrown error + console.error(err); if (this.props.onError) { this.props.onError(err); } + + if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError') { + this.setState({ + error: 'Permission to access the camera was denied.', + }); + } else if (err.name === 'NotFoundError' || err.name === 'DevicesNotFoundError') { + this.setState({ + error: 'The camera was not recognized.', + }); + } else { + this.setState({ + error: 'Unknown error. See console logs for details.', + }); + } } handleCancel = () => { @@ -123,29 +141,25 @@ class QrModal extends React.Component { /> -

Scan an address from a QR code

- {!this.state.readerLoaded && ( - - Waiting for camera... - - ) - } -
- - +

Scan QR code

+ {!this.state.readerLoaded && !this.state.error && Waiting for camera...} {this.state.error && ( - {this.state.error.toString()} + Oops! Something went wrong! + {this.state.error.toString()} )}
+ {!this.state.error && ( + + )}
); } From c7f4796191532c71f35d31bec826be4edd7072ad Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Wed, 20 Feb 2019 16:49:49 +0100 Subject: [PATCH 20/24] handle NotReadableError --- src/components/modals/QrModal/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/modals/QrModal/index.js b/src/components/modals/QrModal/index.js index 25fb353f..2666584a 100644 --- a/src/components/modals/QrModal/index.js +++ b/src/components/modals/QrModal/index.js @@ -108,7 +108,8 @@ class QrModal extends React.Component { this.props.onError(err); } - if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError') { + if (err.name === 'NotAllowedError' || err.name === 'PermissionDeniedError' + || err.name === 'NotReadableError' || err.name === 'TrackStartError') { this.setState({ error: 'Permission to access the camera was denied.', }); From 6ddc1de56879ca3f3b1b59ac3a27193dd5578317 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Wed, 20 Feb 2019 17:55:48 +0100 Subject: [PATCH 21/24] fix sign verify alignment --- .../Wallet/views/Account/SignVerify/index.js | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/views/Wallet/views/Account/SignVerify/index.js b/src/views/Wallet/views/Account/SignVerify/index.js index 85817467..dccccaf6 100644 --- a/src/views/Wallet/views/Account/SignVerify/index.js +++ b/src/views/Wallet/views/Account/SignVerify/index.js @@ -16,8 +16,11 @@ const Wrapper = styled.div` display: flex; flex: 1; flex-direction: row; - flex-wrap: wrap; background: ${colors.WHITE}; + + @media screen and (max-width: ${SCREEN_SIZE.MD}) { + flex-wrap: wrap; + } `; const Row = styled.div` @@ -28,11 +31,6 @@ const RowButtons = styled(Row)` display: flex; align-items: center; justify-content: flex-end; - - @media all and (max-width: 850px) { - flex-wrap: wrap; - margin: -5px; - } `; const StyledButton = styled(Button)` @@ -42,15 +40,6 @@ const StyledButton = styled(Button)` &:first-child { margin-left: 0; } - - @media all and (max-width: 850px) { - flex: 1; - margin: 5px; - - &:first-child { - margin-left: 5px; - } - } `; const Column = styled.div` @@ -58,7 +47,7 @@ const Column = styled.div` flex: 1 1 50%; flex-direction: column; - @media screen and (max-width: ${SCREEN_SIZE.XS}) { + @media screen and (max-width: ${SCREEN_SIZE.MD}) { flex: 1 1 100%; } `; @@ -68,7 +57,7 @@ const Sign = styled(Column)``; const Verify = styled(Column)` padding-left: 20px; - @media screen and (max-width: ${SCREEN_SIZE.XS}) { + @media screen and (max-width: ${SCREEN_SIZE.MD}) { padding-left: 0px; } `; From f41a799eee63ce1babb5c194c81fa670868e6e56 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 21 Feb 2019 00:44:13 +0100 Subject: [PATCH 22/24] add hamburger icon --- src/config/icons.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/config/icons.js b/src/config/icons.js index 1190fa88..2e15dcc1 100644 --- a/src/config/icons.js +++ b/src/config/icons.js @@ -79,6 +79,9 @@ export default { QRCODE: [ 'M832 1024l-64 0l0 -128l64 0l0 128Zm-320 0l-64 0l0 -128l64 0l0 128Zm192 0l-128 0l0 -128l128 0l0 128Zm192 -192l64 0l0 64l64 0l0 128l-128 0l0 -192Zm-896 -192l384 0l0 384l-384 0l0 -384Zm320 320l0 -256l-256 0l0 256l256 0Zm-64 -64l-128 0l0 -128l128 0l0 128Zm512 0l-64 0l0 -64l64 0l0 64Zm-192 -128l0 128l-64 0l0 -64l-64 0l0 -64l128 0Zm128 64l-64 0l0 -64l64 0l0 64Zm192 0l-128 0l0 -64l128 0l0 64Zm-256 -64l-64 0l0 -64l64 0l0 64Zm320 -64l-64 0l0 -64l128 0l0 128l-64 0l0 -64Zm-384 0l-128 0l0 -128l128 0l0 128Zm64 -64l64 0l0 -64l128 0l0 128l-192 0l0 -64Zm-320 -128l64 0l0 -64l64 0l0 128l-128 0l0 -64Zm256 0l-64 0l0 -64l192 0l0 128l-128 0l0 -64Zm-576 -64l128 0l0 64l64 0l0 64l-192 0l0 -128Zm896 64l-128 0l0 -64l256 0l0 128l-128 0l0 -64Zm-576 0l-128 0l0 -64l128 0l0 64Zm192 -64l-64 0l0 -64l64 0l0 64Zm-512 -448l384 0l0 384l-384 0l0 -384Zm576 384l-64 0l0 -128l64 0l0 128Zm64 -384l384 0l0 384l-384 0l0 -384Zm-320 320l0 -256l-256 0l0 256l256 0Zm640 0l0 -256l-256 0l0 256l256 0Zm-704 -64l-128 0l0 -128l128 0l0 128Zm640 0l-128 0l0 -128l128 0l0 128Zm-384 -256l0 64l64 0l0 128l-64 0l0 64l-64 0l0 -256l64 0Z', ], + MENU: [ + 'M192,265.497l640,0l0,119.906l-640,0l0,-119.906Zm0,186.56l640,0l0,119.946l-640,0l0,-119.946Zm0,186.56l640,0l0,119.886l-640,0l0,-119.886Z', + ], }; /* From 7b1d5551383ea5331250e01d01485034ba351fac Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 21 Feb 2019 00:46:37 +0100 Subject: [PATCH 23/24] use svg icons for menu toggler instead of utf chars --- src/components/Header/index.js | 46 ++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/components/Header/index.js b/src/components/Header/index.js index 35bbcd2c..a0cf1fa9 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -4,6 +4,9 @@ import styled from 'styled-components'; import { NavLink } from 'react-router-dom'; import colors from 'config/colors'; import { SCREEN_SIZE } from 'config/variables'; +import Icon from 'components/Icon'; +import icons from 'config/icons'; + import type { toggleSidebar as toggleSidebarType } from 'actions/WalletActions'; const Wrapper = styled.header` @@ -12,12 +15,6 @@ const Wrapper = styled.header` background: ${colors.HEADER}; overflow: hidden; z-index: 200; - - svg { - fill: ${colors.WHITE}; - height: 28px; - width: 100px; - } `; const LayoutWrapper = styled.div` @@ -48,21 +45,32 @@ const MenuToggler = styled.div` white-space: nowrap; color: ${colors.WHITE}; align-self: center; + align-items: center; cursor: pointer; user-select: none; padding: 10px 0px; transition: all .1s ease-in; @media screen and (max-width: ${SCREEN_SIZE.SM}) { - display: initial; + display: flex; } `; +const TogglerText = styled.div` + +`; + const Logo = styled.div` flex: 1; justify-content: flex-start; display: flex; + svg { + fill: ${colors.WHITE}; + height: 28px; + width: 100px; + } + @media screen and (max-width: ${SCREEN_SIZE.SM}) { flex: 1 0 33%; justify-content: center; @@ -115,7 +123,29 @@ const Header = ({ sidebarEnabled, sidebarOpened, toggleSidebar }: Props) => ( - { sidebarEnabled && {sidebarOpened ? '✕ Close' : '☰ Menu'}} + { sidebarEnabled && ( + {sidebarOpened + ? ( + <> + + Close + + ) : ( + <> + + Menu + + )} + + )} From 8c07d457500fbd1c6c530998b266cf31f299291c Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 21 Feb 2019 00:50:22 +0100 Subject: [PATCH 24/24] move condition to a new line --- src/components/Header/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Header/index.js b/src/components/Header/index.js index a0cf1fa9..e6a1cef2 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -124,8 +124,8 @@ const Header = ({ sidebarEnabled, sidebarOpened, toggleSidebar }: Props) => ( { sidebarEnabled && ( - {sidebarOpened - ? ( + + {sidebarOpened ? ( <>