From d2d184773da05bb7714adf39911b45c1e34ffc49 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 13:21:55 +0200 Subject: [PATCH 01/50] quickfix: remove unnecessary condition from ModalReducer TrezorConnect will emit UI.CLOSE_UI_WINDOW which will close modal window --- src/reducers/ModalReducer.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/reducers/ModalReducer.js b/src/reducers/ModalReducer.js index a425676a..4f3168df 100644 --- a/src/reducers/ModalReducer.js +++ b/src/reducers/ModalReducer.js @@ -44,14 +44,6 @@ export default function modal(state: State = initialState, action: Action): Stat windowType: action.type, }; - // device acquired - // close modal - case DEVICE.CHANGED: - if (state.context === MODAL.CONTEXT_DEVICE && action.device.path === state.device.path && action.device.status === 'occupied') { - return initialState; - } - return state; - // device connected // close modal if modal context is not 'device' case DEVICE.CONNECT: From fa5fbf890361b3c959690ff0b84c2917603e313c Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Fri, 19 Oct 2018 01:10:24 +0200 Subject: [PATCH 02/50] Better account title --- src/config/variables.js | 1 + src/views/Wallet/views/Account/Summary/index.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config/variables.js b/src/config/variables.js index 4c900387..5435a7ee 100644 --- a/src/config/variables.js +++ b/src/config/variables.js @@ -3,6 +3,7 @@ export const FONT_SIZE = { SMALLER: '12px', SMALL: '14px', BASE: '16px', + WALLET_TITLE: '18px', TOP_MENU: '17px', BIG: '21px', BIGGER: '32px', diff --git a/src/views/Wallet/views/Account/Summary/index.js b/src/views/Wallet/views/Account/Summary/index.js index 6dc91de2..36a88475 100644 --- a/src/views/Wallet/views/Account/Summary/index.js +++ b/src/views/Wallet/views/Account/Summary/index.js @@ -13,10 +13,11 @@ import Content from 'views/Wallet/components/Content'; import CoinLogo from 'components/images/CoinLogo'; import * as stateUtils from 'reducers/utils'; import Link from 'components/Link'; +import { FONT_WEIGHT, FONT_SIZE } from 'config/variables'; import AccountBalance from './components/Balance'; import AddedToken from './components/Token'; -import type { Props } from './Container'; +import { Props } from './Container'; const AccountHeading = styled.div` padding: 0 0 30px 0; @@ -38,9 +39,16 @@ const StyledTooltip = styled(Tooltip)` const AccountName = styled.div` display: flex; + justify-content: center; align-items: center; `; +const AccountTitle = styled.div` + font-size: ${FONT_SIZE.WALLET_TITLE}; + font-weight: ${FONT_WEIGHT.BASE}; + color: ${colors.WALLET_TITLE}; +`; + const StyledCoinLogo = styled(CoinLogo)` margin-right: 10px; `; @@ -82,7 +90,7 @@ const AccountSummary = (props: Props) => { -

Account #{parseInt(account.index, 10) + 1}

+ Account #{parseInt(account.index, 10) + 1}
See full transaction history
From 81aa4e108b4a28211355e4dbfa0f3231fd307c60 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 13:32:59 +0200 Subject: [PATCH 03/50] change meta tags in index.html --- src/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 7278523f..fc560aef 100644 --- a/src/index.html +++ b/src/index.html @@ -4,15 +4,15 @@ - Ethereum Wallet | Trezor + Trezor Wallet - - + + From 46acf38364207e23bbcda821dd66c771b3e68815 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 13:37:15 +0200 Subject: [PATCH 04/50] flowtype fix for Account/Summary --- src/views/Wallet/views/Account/Summary/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Wallet/views/Account/Summary/index.js b/src/views/Wallet/views/Account/Summary/index.js index 36a88475..90da7d41 100644 --- a/src/views/Wallet/views/Account/Summary/index.js +++ b/src/views/Wallet/views/Account/Summary/index.js @@ -17,7 +17,7 @@ import { FONT_WEIGHT, FONT_SIZE } from 'config/variables'; import AccountBalance from './components/Balance'; import AddedToken from './components/Token'; -import { Props } from './Container'; +import type { Props } from './Container'; const AccountHeading = styled.div` padding: 0 0 30px 0; From df9276903f27ae96e61ec2fda3e9d355490b3437 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 19 Oct 2018 13:45:46 +0200 Subject: [PATCH 05/50] fix license in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9db39d70..421e79d7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bin": { "flow": "./node_modules/flow-bin" }, - "license": "T-RSL", + "license": "SEE LICENSE IN LICENSE.md", "scripts": { "dev": "npx webpack-dev-server --config webpack/dev.babel.js", "dev:local": "npx webpack-dev-server --config webpack/local.babel.js", From ae50572a87969c28b939c4258b27601a10e1e14f Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 15:28:16 +0200 Subject: [PATCH 06/50] bump trezor-connect 6.0.0 --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 421e79d7..d966c6c4 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "styled-components": "^3.4.9", "styled-media-query": "^2.0.2", "styled-normalize": "^8.0.0", - "trezor-connect": "^5.0.32", + "trezor-connect": "6.0.0", "web3": "1.0.0-beta.35", "webpack": "^4.16.3", "webpack-build-notifier": "^0.1.29", diff --git a/yarn.lock b/yarn.lock index 0c415b76..d222ae8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10211,9 +10211,9 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" -trezor-connect@^5.0.32: - version "5.0.32" - resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-5.0.32.tgz#a8077f46653fec16d8dc25358e157ed1048a4def" +trezor-connect@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-6.0.0.tgz#2a45336f29a4a3f2a8ad2d121363b0e7a1b767ef" dependencies: babel-runtime "^6.26.0" events "^1.1.1" From a074d79348dfd3892d9c05f4a7ea2078ccd02a9a Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 15:32:43 +0200 Subject: [PATCH 07/50] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e196b09..0b2f694d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Trezor Ethereum Wallet +# Trezor Wallet To install dependencies run `npm install` or `yarn` To start locally run `npm run dev` or `yarn run dev` From cb30af097f1b9d0a885a574a83c0e5288f4beb3f Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 16:03:58 +0200 Subject: [PATCH 08/50] changed bridge installation package domain --- src/views/Landing/views/InstallBridge/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Landing/views/InstallBridge/index.js b/src/views/Landing/views/InstallBridge/index.js index d0b3834b..e648ae16 100644 --- a/src/views/Landing/views/InstallBridge/index.js +++ b/src/views/Landing/views/InstallBridge/index.js @@ -135,7 +135,7 @@ class InstallBridge extends PureComponent { latestVersion: props.transport.bridge.version.join('.'), installers, target: currentTarget || installers[0], - uri: 'https://wallet.trezor.io/data/', + uri: 'https://data.trezor.io/', }; } From ffbbbee16676d0377597b941d5ec7a349e79f8d7 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 17:02:30 +0200 Subject: [PATCH 09/50] added Makefile and s3sync script --- Makefile | 5 +++++ scripts/s3sync.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Makefile create mode 100644 scripts/s3sync.sh diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..8c84f3b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: + sh ./scripts/docker-build.sh + +sync-%: + sh ./scripts/s3sync.sh $* \ No newline at end of file diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh new file mode 100644 index 00000000..44a141a2 --- /dev/null +++ b/scripts/s3sync.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Before first use: +# Install awscli (pip install awscli) +# Configure access credentials (aws configure), region is "eu-central-1" + +function confirm { + read -r -p "Are you sure? [y/N] " response + if [[ $response =~ ^(yes|y)$ ]]; then + echo "let's go!" + else + exit 2 + fi +} + +if [ "x$1" == "x" ]; then + echo "./s3sync.sh stage|beta|wallet [-d]" + exit 1 +fi + +if [ "x$1" == "xstage" ]; then + DIST=../build/beta + BUCKET=stage.mytrezor.com + DISTRIBUTION_ID="E24M0QWO692FQL" + +elif [ "x$1" == "xbeta" ]; then + DIST=../build/beta + BUCKET=beta.mytrezor.com + DISTRIBUTION_ID="E1PONNHWUNCQ9M" + + confirm + +elif [ "x$1" == "xwallet" ]; then + DIST=../build/prod + BUCKET=wallet.mytrezor.com + DISTRIBUTION_ID="EZM01GFTITGVD" + + confirm + +fi + +set -e +cd `dirname $0` + +if [ "x$2" == "x-d" ]; then + aws s3 sync --delete --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next +else + aws s3 sync --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next +fi + +aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' + +echo "DONE" \ No newline at end of file From c7701d3a989b2894dada2bb56440f0b7361ecf42 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Fri, 19 Oct 2018 17:58:12 +0200 Subject: [PATCH 10/50] move solidity from ./public to ./scripts --- {public => scripts}/solidity/erc20.json | 0 {public => scripts}/solidity/grzegorz-token.js | 0 {public => scripts}/solidity/lahodka-token.js | 0 {public => scripts}/solidity/rinkeby-token.js | 0 {public => scripts}/solidity/test-token.js | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {public => scripts}/solidity/erc20.json (100%) rename {public => scripts}/solidity/grzegorz-token.js (100%) rename {public => scripts}/solidity/lahodka-token.js (100%) rename {public => scripts}/solidity/rinkeby-token.js (100%) rename {public => scripts}/solidity/test-token.js (100%) diff --git a/public/solidity/erc20.json b/scripts/solidity/erc20.json similarity index 100% rename from public/solidity/erc20.json rename to scripts/solidity/erc20.json diff --git a/public/solidity/grzegorz-token.js b/scripts/solidity/grzegorz-token.js similarity index 100% rename from public/solidity/grzegorz-token.js rename to scripts/solidity/grzegorz-token.js diff --git a/public/solidity/lahodka-token.js b/scripts/solidity/lahodka-token.js similarity index 100% rename from public/solidity/lahodka-token.js rename to scripts/solidity/lahodka-token.js diff --git a/public/solidity/rinkeby-token.js b/scripts/solidity/rinkeby-token.js similarity index 100% rename from public/solidity/rinkeby-token.js rename to scripts/solidity/rinkeby-token.js diff --git a/public/solidity/test-token.js b/scripts/solidity/test-token.js similarity index 100% rename from public/solidity/test-token.js rename to scripts/solidity/test-token.js From 1f517733fcf7201b1f11b53edb53fa465a792cd2 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Sat, 20 Oct 2018 00:18:48 +0200 Subject: [PATCH 11/50] eslint and flow ignore ./scripts/solidity --- .eslintignore | 1 + .flowconfig | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintignore b/.eslintignore index 089ce7a5..94a7b116 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,5 @@ build coverage node_modules src/flowtype/npm +scripts/solidity/.* **/_old/* \ No newline at end of file diff --git a/.flowconfig b/.flowconfig index e42f6028..a3a80352 100644 --- a/.flowconfig +++ b/.flowconfig @@ -9,7 +9,7 @@ .*/node_modules/react-router-redux/.* .*/node_modules/oboe/test/.* .*/_old/.* -.*/public/solidity/.* +.*/scripts/solidity/.* .*/build/.* [libs] From fe41a0d302a12bbde35e67c761b44d9637f98e1c Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Sun, 21 Oct 2018 16:31:45 +0200 Subject: [PATCH 12/50] Fixed underline --- src/views/Wallet/views/Account/Send/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/Wallet/views/Account/Send/index.js b/src/views/Wallet/views/Account/Send/index.js index f57bab8c..74f17322 100644 --- a/src/views/Wallet/views/Account/Send/index.js +++ b/src/views/Wallet/views/Account/Send/index.js @@ -105,6 +105,7 @@ const UpdateFeeWrapper = styled.span` const StyledLink = styled(Link)` margin-left: 4px; + white-space: nowrap; `; const ToggleAdvancedSettingsWrapper = styled.div` From dca466ed8a648f8e86a322aaa7939eb1c1a8be7c Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Sun, 21 Oct 2018 16:31:45 +0200 Subject: [PATCH 13/50] Fixed underline --- src/views/Wallet/views/Account/Send/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/Wallet/views/Account/Send/index.js b/src/views/Wallet/views/Account/Send/index.js index f57bab8c..74f17322 100644 --- a/src/views/Wallet/views/Account/Send/index.js +++ b/src/views/Wallet/views/Account/Send/index.js @@ -105,6 +105,7 @@ const UpdateFeeWrapper = styled.span` const StyledLink = styled(Link)` margin-left: 4px; + white-space: nowrap; `; const ToggleAdvancedSettingsWrapper = styled.div` From a534830dfff08b4bce8bba3bc0ad323aa47d5a3a Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 10:02:30 +0200 Subject: [PATCH 14/50] discovery status css fix - DiscoveryStatusWrapper css fix (wodth 100%) - rewriten first condition --- .../components/AccountMenu/index.js | 107 +++++++++--------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index dfd38016..06d9a216 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -78,7 +78,7 @@ const AddAccountIconWrapper = styled.div` const DiscoveryStatusWrapper = styled.div` display: flex; flex-direction: column; - + width: 100%; font-size: ${FONT_SIZE.SMALL}; padding: ${LEFT_NAVIGATION_ROW.PADDING}; white-space: nowrap; @@ -164,15 +164,34 @@ const AccountMenu = (props: Props) => { let discoveryStatus = null; const discovery = props.discovery.find(d => d.deviceState === selected.state && d.network === location.state.network); - if (discovery) { - if (discovery.completed) { - // TODO: add only if last one is not empty - //if (selectedAccounts.length > 0 && selectedAccounts[selectedAccounts.length - 1]) - const lastAccount = deviceAccounts[deviceAccounts.length - 1]; - if (lastAccount && (new BigNumber(lastAccount.balance).greaterThan(0) || lastAccount.nonce > 0)) { - discoveryStatus = ( - - + if (discovery && discovery.completed) { + // TODO: add only if last one is not empty + //if (selectedAccounts.length > 0 && selectedAccounts[selectedAccounts.length - 1]) + const lastAccount = deviceAccounts[deviceAccounts.length - 1]; + if (lastAccount && (new BigNumber(lastAccount.balance).greaterThan(0) || lastAccount.nonce > 0)) { + discoveryStatus = ( + + + + + + Add account + + + ); + } else { + discoveryStatus = ( + To add a new account, last account must have some transactions.} + placement="bottom" + > + + { Add account - ); - } else { - discoveryStatus = ( - To add a new account, last account must have some transactions.} - placement="bottom" - > - - - - - - Add account - - - - ); - } - } else if (!selected.connected || !selected.available) { - discoveryStatus = ( - - - Accounts could not be loaded - - {`Connect ${selected.instanceLabel} device`} - - - - ); - } else { - discoveryStatus = ( - - - - - Loading... - - - + ); } + } else if (!selected.connected) { + discoveryStatus = ( + + + Accounts could not be loaded + + {`Connect ${selected.instanceLabel} device`} + + + + ); + } else { + discoveryStatus = ( + + + + + Loading... + + + + ); } + return ( From 0c61bcb08de3f79712c6c6c570c43306376ead72 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 10:04:19 +0200 Subject: [PATCH 15/50] local storage prefix - common prefix for localstorage and sessionstorage - code refactoring --- src/actions/LocalStorageActions.js | 84 ++++++++++++---------------- src/actions/SessionStorageActions.js | 63 +++++++++------------ src/utils/storage.js | 62 ++++++++++++++++++++ 3 files changed, 123 insertions(+), 86 deletions(-) create mode 100644 src/utils/storage.js diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index 49fbf0fa..786da55c 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -10,6 +10,7 @@ import * as PENDING from 'actions/constants/pendingTx'; import * as WALLET from 'actions/constants/wallet'; import { httpRequest } from 'utils/networkUtils'; import * as buildUtils from 'utils/build'; +import * as storageUtils from 'utils/storage'; import { findAccountTokens } from 'reducers/TokensReducer'; import type { Account } from 'reducers/AccountsReducer'; @@ -17,7 +18,6 @@ import type { Token } from 'reducers/TokensReducer'; import type { PendingTx } from 'reducers/PendingTxReducer'; import type { Discovery } from 'reducers/DiscoveryReducer'; - import type { TrezorDevice, ThunkAction, @@ -43,22 +43,15 @@ export type StorageAction = { error: string, }; -const get = (key: string): ?string => { - try { - return window.localStorage.getItem(key); - } catch (error) { - // available = false; - return null; - } -}; - -const set = (key: string, value: string | boolean): void => { - try { - window.localStorage.setItem(key, value); - } catch (error) { - console.error(`Local Storage ERROR: ${error}`); - } -}; +const TYPE: 'local' = 'local'; +const { STORAGE_PATH } = storageUtils; +const KEY_VERSION: string = `${STORAGE_PATH}version`; +const KEY_DEVICES: string = `${STORAGE_PATH}devices`; +const KEY_ACCOUNTS: string = `${STORAGE_PATH}accounts`; +const KEY_DISCOVERY: string = `${STORAGE_PATH}discovery`; +const KEY_TOKENS: string = `${STORAGE_PATH}tokens`; +const KEY_PENDING: string = `${STORAGE_PATH}pending`; +const KEY_BETA_MODAL: string = '/betaModalPrivacy'; // this key needs to be compatible with "parent" (old) wallet // https://github.com/STRML/react-localstorage/blob/master/react-localstorage.js // or @@ -80,25 +73,25 @@ export const save = (): ThunkAction => (dispatch: Dispatch, getState: GetState): const discovery: Array = findDiscovery(devices, getState().discovery); // save devices - set('devices', JSON.stringify(devices)); + storageUtils.set(TYPE, KEY_DEVICES, JSON.stringify(devices)); // save already preloaded accounts - set('accounts', JSON.stringify(accounts)); + storageUtils.set(TYPE, KEY_ACCOUNTS, JSON.stringify(accounts)); // save discovery state - set('discovery', JSON.stringify(discovery)); + storageUtils.set(TYPE, KEY_DISCOVERY, JSON.stringify(discovery)); // tokens - set('tokens', JSON.stringify(tokens)); + storageUtils.set(TYPE, KEY_TOKENS, JSON.stringify(tokens)); // pending transactions - set('pending', JSON.stringify(pending)); + storageUtils.set(TYPE, KEY_PENDING, JSON.stringify(pending)); }; export const update = (event: StorageEvent): ThunkAction => (dispatch: Dispatch): void => { if (!event.newValue) return; - if (event.key === 'devices') { + if (event.key === KEY_DEVICES) { // check if device was added/ removed // const newDevices: Array = JSON.parse(event.newValue); // const myDevices: Array = getState().connect.devices.filter(d => d.features); @@ -113,28 +106,28 @@ export const update = (event: StorageEvent): ThunkAction => (dispatch: Dispatch) // const diff = oldDevices.filter(d => newDevices.indexOf()) } - if (event.key === 'accounts') { + if (event.key === KEY_ACCOUNTS) { dispatch({ type: ACCOUNT.FROM_STORAGE, payload: JSON.parse(event.newValue), }); } - if (event.key === 'tokens') { + if (event.key === KEY_TOKENS) { dispatch({ type: TOKEN.FROM_STORAGE, payload: JSON.parse(event.newValue), }); } - if (event.key === 'pending') { + if (event.key === KEY_PENDING) { dispatch({ type: PENDING.FROM_STORAGE, payload: JSON.parse(event.newValue), }); } - if (event.key === 'discovery') { + if (event.key === KEY_DISCOVERY) { dispatch({ type: DISCOVERY.FROM_STORAGE, payload: JSON.parse(event.newValue), @@ -142,14 +135,13 @@ export const update = (event: StorageEvent): ThunkAction => (dispatch: Dispatch) } }; -const VERSION: string = '1'; - const loadJSON = (): AsyncAction => async (dispatch: Dispatch): Promise => { if (typeof window.localStorage === 'undefined') return; try { const config: Config = await httpRequest(AppConfigJSON, 'json'); + // remove ropsten testnet from config networks if (!buildUtils.isDev()) { const index = config.networks.findIndex(c => c.shortcut === 'trop'); delete config.networks[index]; @@ -161,18 +153,6 @@ const loadJSON = (): AsyncAction => async (dispatch: Dispatch): Promise => dispatch(update(event)); }); - // validate version - const version: ?string = get('version'); - if (version !== VERSION) { - try { - window.localStorage.clear(); - window.sessionStorage.clear(); - } catch (error) { - // empty - } - set('version', VERSION); - } - // load tokens const tokens = await config.networks.reduce(async (promise: Promise, network: Network): Promise => { const collection: TokensCollection = await promise; @@ -195,9 +175,17 @@ const loadJSON = (): AsyncAction => async (dispatch: Dispatch): Promise => } }; +const VERSION: string = '1'; const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { - const devices: ?string = get('devices'); + // validate version + const version: ?string = storageUtils.get(TYPE, KEY_VERSION); + if (version && version !== VERSION) { + storageUtils.clearAll(); + } + storageUtils.set(TYPE, KEY_VERSION, VERSION); + + const devices: ?string = storageUtils.get(TYPE, KEY_DEVICES); if (devices) { dispatch({ type: CONNECT.DEVICE_FROM_STORAGE, @@ -205,7 +193,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { }); } - const accounts: ?string = get('accounts'); + const accounts: ?string = storageUtils.get(TYPE, KEY_ACCOUNTS); if (accounts) { dispatch({ type: ACCOUNT.FROM_STORAGE, @@ -213,7 +201,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { }); } - const userTokens: ?string = get('tokens'); + const userTokens: ?string = storageUtils.get(TYPE, KEY_TOKENS); if (userTokens) { dispatch({ type: TOKEN.FROM_STORAGE, @@ -221,7 +209,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { }); } - const pending: ?string = get('pending'); + const pending: ?string = storageUtils.get(TYPE, KEY_PENDING); if (pending) { dispatch({ type: PENDING.FROM_STORAGE, @@ -229,7 +217,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { }); } - const discovery: ?string = get('discovery'); + const discovery: ?string = storageUtils.get(TYPE, KEY_DISCOVERY); if (discovery) { dispatch({ type: DISCOVERY.FROM_STORAGE, @@ -238,7 +226,7 @@ const loadStorageData = (): ThunkAction => (dispatch: Dispatch): void => { } if (buildUtils.isDev() || buildUtils.isBeta()) { - const betaModal = get('/betaModalPrivacy'); + const betaModal = Object.keys(window.localStorage).find(key => key.indexOf(KEY_BETA_MODAL) >= 0); if (!betaModal) { dispatch({ type: WALLET.SHOW_BETA_DISCLAIMER, @@ -258,6 +246,6 @@ export const loadData = (): ThunkAction => (dispatch: Dispatch, getState: GetSta }; export const hideBetaDisclaimer = (): ThunkAction => (dispatch: Dispatch): void => { - set('/betaModalPrivacy', true); + storageUtils.set(TYPE, KEY_BETA_MODAL, true); dispatch(loadJSON()); }; diff --git a/src/actions/SessionStorageActions.js b/src/actions/SessionStorageActions.js index 33c953c8..e713a791 100644 --- a/src/actions/SessionStorageActions.js +++ b/src/actions/SessionStorageActions.js @@ -1,5 +1,5 @@ /* @flow */ - +import * as storageUtils from 'utils/storage'; import type { State as SendFormState } from 'reducers/SendFormReducer'; import type { @@ -9,52 +9,39 @@ import type { Dispatch, } from 'flowtype'; -const TX_PREFIX: string = 'trezor:draft-tx:'; +const TYPE: 'session' = 'session'; +const { STORAGE_PATH } = storageUtils; +const KEY_TX_DRAFT: string = `${STORAGE_PATH}txdraft`; -export const saveDraftTransaction = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { - if (typeof window.localStorage === 'undefined') return; +const getTxDraftKey = (getState: GetState): string => { + const { pathname } = getState().router.location; + return `${KEY_TX_DRAFT}${pathname}`; +}; +export const saveDraftTransaction = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { const state = getState().sendForm; if (state.untouched) return; - const location = getState().router.location.pathname; - try { - // save state as it is - // "loadDraftTransaction" will do the validation - window.sessionStorage.setItem(`${TX_PREFIX}${location}`, JSON.stringify(state)); - } catch (error) { - console.error(`Saving sessionStorage error: ${error}`); - } + const key = getTxDraftKey(getState); + storageUtils.set(TYPE, key, JSON.stringify(state)); }; export const loadDraftTransaction = (): PayloadAction => (dispatch: Dispatch, getState: GetState): ?SendFormState => { - if (typeof window.localStorage === 'undefined') return null; - - try { - const location = getState().router.location.pathname; - const value: string = window.sessionStorage.getItem(`${TX_PREFIX}${location}`); - const state: ?SendFormState = JSON.parse(value); - if (state) { - // decide if draft is valid and should be returned - // ignore this draft if has any error - if (Object.keys(state.errors).length > 0) { - window.sessionStorage.removeItem(`${TX_PREFIX}${location}`); - return null; - } - return state; - } - } catch (error) { - console.error(`Loading sessionStorage error: ${error}`); + const key = getTxDraftKey(getState); + const value: ?string = storageUtils.get(TYPE, key); + if (!value) return null; + const state: ?SendFormState = JSON.parse(value); + if (!state) return null; + // decide if draft is valid and should be returned + // ignore this draft if has any error + if (Object.keys(state.errors).length > 0) { + storageUtils.remove(TYPE, key); + return null; } - return null; + return state; }; export const clear = (): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { - if (typeof window.localStorage === 'undefined') return; - const location = getState().router.location.pathname; - try { - window.sessionStorage.removeItem(`${TX_PREFIX}${location}`); - } catch (error) { - console.error(`Clearing sessionStorage error: ${error}`); - } -}; \ No newline at end of file + const key = getTxDraftKey(getState); + storageUtils.remove(TYPE, key); +}; diff --git a/src/utils/storage.js b/src/utils/storage.js new file mode 100644 index 00000000..dd89c7ef --- /dev/null +++ b/src/utils/storage.js @@ -0,0 +1,62 @@ +/* @flow */ + +// Copy-paste from mytrezor (old wallet) +// https://github.com/satoshilabs/mytrezor/blob/develop/app/scripts/storage/BackendLocalStorage.js +export const getStoragePath = (): string => { + const regexHash = /^([^#]*)#.*$/; + const path = window.location.href.replace(regexHash, '$1'); + const regexStart = /^[^:]*:\/\/[^/]*\//; + return path.replace(regexStart, '/'); +}; + +export const STORAGE_PATH: string = getStoragePath(); + +type StorageType = 'local' | 'session'; + +export const get: (type: StorageType, key: string) => T | null = (type, key) => { + const storage = type === 'local' ? window.localStorage : window.sessionStorage; + try { + return storage.getItem(key); + } catch (error) { + console.warn(`Get ${type} storage: ${error}`); + return null; + } +}; + +export const set = (type: StorageType, key: string, value: string | number | boolean): void => { + const storage = type === 'local' ? window.localStorage : window.sessionStorage; + try { + storage.setItem(key, value); + } catch (error) { + console.warn(`Save ${type} storage: ${error}`); + } +}; + +export const remove = (type: StorageType, key: string): void => { + const storage = type === 'local' ? window.localStorage : window.sessionStorage; + try { + storage.removeItem(key); + } catch (error) { + console.warn(`Remove ${type} storage: ${error}`); + } +}; + +export const clearAll = (type: ?StorageType): void => { + let clearLocal: boolean = true; + let clearSession: boolean = true; + if (typeof type === 'string') { + clearLocal = type === 'local'; + clearSession = !clearLocal; + } + + try { + if (clearLocal) { + Object.keys(window.localStorage).forEach(key => key.indexOf(STORAGE_PATH) >= 0 && window.localStorage.removeItem(key)); + } + if (clearSession) { + Object.keys(window.sessionStorage).forEach(key => key.indexOf(STORAGE_PATH) >= 0 && window.sessionStorage.removeItem(key)); + } + } catch (error) { + console.error(`Clearing sessionStorage error: ${error}`); + } +}; \ No newline at end of file From 16f830ff9d2d53dca733e8357fd497da0e5034aa Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 10:07:00 +0200 Subject: [PATCH 16/50] fix for indicator first render --- .../TopNavigationAccount/components/Indicator/index.js | 6 +++--- src/views/Wallet/components/TopNavigationAccount/index.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js b/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js index 9a414a7d..0e5eda43 100644 --- a/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/components/Indicator/index.js @@ -6,7 +6,7 @@ import React, { PureComponent } from 'react'; type Props = { pathname: string; - wrapper: ?HTMLElement; + wrapper: () => ?HTMLElement; } type State = { @@ -71,8 +71,8 @@ class Indicator extends PureComponent { handleResize: () => void; reposition(resetAnimation: boolean = true) { - if (!this.props.wrapper) return; - const { wrapper } = this.props; + const wrapper = this.props.wrapper(); + if (!wrapper) return; const active = wrapper.querySelector('.active'); if (!active) return; const bounds = active.getBoundingClientRect(); diff --git a/src/views/Wallet/components/TopNavigationAccount/index.js b/src/views/Wallet/components/TopNavigationAccount/index.js index 2d0f105e..05d52489 100644 --- a/src/views/Wallet/components/TopNavigationAccount/index.js +++ b/src/views/Wallet/components/TopNavigationAccount/index.js @@ -65,7 +65,7 @@ class TopNavigationAccount extends React.PureComponent { Receive Send {/* Sign & Verify */} - + this.wrapper} /> ); } From 5e85c9fef0483c10d42d8e9b360ed4514589e2c3 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Mon, 22 Oct 2018 12:25:12 +0200 Subject: [PATCH 17/50] Build app using gitlab --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c0f6536..bb3ca3f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,16 @@ image: node:8 before_script: - yarn install +build site: + stage: build + script: + - yarn install --progress=false + - yarn run build + artifacts: + expire_in: 1 week + paths: + - build + cache: paths: - node_modules/ From 63bfe4c6b9c693e9de5d542ecd1bea817a6c6697 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Mon, 22 Oct 2018 13:04:16 +0200 Subject: [PATCH 18/50] Build app using gitlab 2 --- .gitlab-ci.yml | 64 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb3ca3f9..804b0445 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,62 @@ image: node:8 +cache: + paths: + - node_modules + before_script: - yarn install -build site: - stage: build - script: - - yarn install --progress=false - - yarn run build - artifacts: - expire_in: 1 week - paths: - - build +stages: + - test + - build + - deploy -cache: - paths: - - node_modules/ +lint: + stage: test + script: + - yarn run lint flow: + stage: test script: - yarn run flow -test:lint: +test: + stage: test script: - - yarn run lint + - yarn run test -test:unit: +build-development: + stage: build script: - - yarn run test + - yarn run build:dev + artifacts: + expire_in: 1 month + paths: + - build/dev + +build-beta: + stage: build + script: + - yarn run build:beta + artifacts: + expire_in: 1 month + paths: + - build/beta + +build-production: + stage: build + script: + - yarn run build:prod + artifacts: + expire_in: 1 month + paths: + - build/production + +deploy_dev: + stage: echo "Deploy dev" + +deploy_staging: + stage: deploy + script: echo "Deploy staging" \ No newline at end of file From b48b1970034b32fc0d45c866616c13783ef83735 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 13:31:10 +0200 Subject: [PATCH 19/50] quickfix: ethUtils test "sanitizeHex" fix sanitizeHex expects only strings --- src/utils/__tests__/ethUtils.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/__tests__/ethUtils.test.js b/src/utils/__tests__/ethUtils.test.js index 07bd1250..119b90e5 100644 --- a/src/utils/__tests__/ethUtils.test.js +++ b/src/utils/__tests__/ethUtils.test.js @@ -27,7 +27,7 @@ describe('eth utils', () => { }); it('sanitizeHex', () => { - const input = ['0x2540be3ff', '1', '2', '100', 999, '']; + const input = ['0x2540be3ff', '1', '2', '100', '999', '']; input.forEach((entry) => { expect(ethUtils.sanitizeHex(entry)).toMatchSnapshot(); From 3347c54cffdbce8bb3aa110d3febb7bd7b1205bd Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 13:46:15 +0200 Subject: [PATCH 20/50] quickfix: deviceUtils test "transport.version" fix "version" should a be a string not an array --- src/utils/__tests__/device.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/__tests__/device.test.js b/src/utils/__tests__/device.test.js index e135a151..68f8e2a2 100644 --- a/src/utils/__tests__/device.test.js +++ b/src/utils/__tests__/device.test.js @@ -40,9 +40,9 @@ describe('device utils', () => { it('isWebUSB', () => { const data = [ - { transport: { version: ['webusb'] } }, - { transport: { version: ['aaaaaa'] } }, - { transport: { version: ['webusb', 'test'] } }, + { transport: { version: 'webusb' } }, + { transport: { version: 'aaaaaa' } }, + { transport: { version: 'webusb' } }, ]; data.forEach((item) => { @@ -52,8 +52,8 @@ describe('device utils', () => { it('isDisabled', () => { const data = [ - { selectedDevice: { features: null }, devices: [1, 2, 3], transport: { version: ['webusb', 'test'] } }, - { selectedDevice: { features: null }, devices: [], transport: { version: ['test'] } }, + { selectedDevice: { features: null }, devices: [1, 2, 3], transport: { version: 'webusb' } }, + { selectedDevice: { features: null }, devices: [], transport: { version: 'test' } }, ]; data.forEach((item) => { From 95623474aaae5dfd496cbf2f289bede4aff6f874 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 22 Oct 2018 17:22:04 +0200 Subject: [PATCH 21/50] quickfix: deviceUtils test add missing "type" field + update ethUtils snapshot --- src/utils/__tests__/__snapshots__/ethUtils.test.js.snap | 2 +- src/utils/__tests__/device.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/__tests__/__snapshots__/ethUtils.test.js.snap b/src/utils/__tests__/__snapshots__/ethUtils.test.js.snap index f5b70d96..ad90b78c 100644 --- a/src/utils/__tests__/__snapshots__/ethUtils.test.js.snap +++ b/src/utils/__tests__/__snapshots__/ethUtils.test.js.snap @@ -34,7 +34,7 @@ exports[`eth utils sanitizeHex 3`] = `"0x02"`; exports[`eth utils sanitizeHex 4`] = `"0x0100"`; -exports[`eth utils sanitizeHex 5`] = `null`; +exports[`eth utils sanitizeHex 5`] = `"0x0999"`; exports[`eth utils sanitizeHex 6`] = `""`; diff --git a/src/utils/__tests__/device.test.js b/src/utils/__tests__/device.test.js index 68f8e2a2..78281035 100644 --- a/src/utils/__tests__/device.test.js +++ b/src/utils/__tests__/device.test.js @@ -40,9 +40,9 @@ describe('device utils', () => { it('isWebUSB', () => { const data = [ - { transport: { version: 'webusb' } }, - { transport: { version: 'aaaaaa' } }, - { transport: { version: 'webusb' } }, + { transport: { type: 'ParallelTransport', version: 'webusb' } }, + { transport: { type: null, version: 'aaaaaa' } }, + { transport: { type: 'ParallelTransport', version: 'webusb' } }, ]; data.forEach((item) => { From 1c356b0417eeab10be1339c1fbe9092c658b9baf Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 11:26:41 +0200 Subject: [PATCH 22/50] fix yaml --- .gitlab-ci.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 804b0445..b18884a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,11 +52,4 @@ build-production: artifacts: expire_in: 1 month paths: - - build/production - -deploy_dev: - stage: echo "Deploy dev" - -deploy_staging: - stage: deploy - script: echo "Deploy staging" \ No newline at end of file + - build/production \ No newline at end of file From 2ff10255bdcce6833b0faba110d03fde1dec2dce Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 11:30:53 +0200 Subject: [PATCH 23/50] fix eslint --- .../components/LeftNavigation/components/AccountMenu/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index 06d9a216..f41efa2a 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -228,7 +228,6 @@ const AccountMenu = (props: Props) => { ); } - return ( From c70464cccd95a0dbe212e8d2513dc8563bf81903 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 11:51:40 +0200 Subject: [PATCH 24/50] fix prod build --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b18884a8..9cad201b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,4 +52,4 @@ build-production: artifacts: expire_in: 1 month paths: - - build/production \ No newline at end of file + - build/prod \ No newline at end of file From cae4c6e9c1965188f4780b5c0a2bb6ecd9764f64 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 16:29:33 +0200 Subject: [PATCH 25/50] Added step for deploy review --- .gitlab-ci.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cad201b..8e0d426d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,29 +27,42 @@ test: script: - yarn run test -build-development: +build development: stage: build script: - yarn run build:dev artifacts: expire_in: 1 month paths: - - build/dev + - /build -build-beta: +build beta: stage: build script: - yarn run build:beta artifacts: expire_in: 1 month paths: - - build/beta + - /build -build-production: +build production: stage: build script: - yarn run build:prod artifacts: expire_in: 1 month paths: - - build/prod \ No newline at end of file + - /build + +# deploy +deploy review: + stage: deploy + script: + - echo "Deploy a review app" + environment: + name: review/$CI_COMMIT_REF_NAME + url: https://$CI_ENVIRONMENT_SLUG.example.com + only: + - branches + except: + - master \ No newline at end of file From 5acfaf772074da1b5d06f2e1e415a2bb21f8852a Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 16:31:10 +0200 Subject: [PATCH 26/50] Renamed step --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e0d426d..4dee6ff4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ flow: script: - yarn run flow -test: +unit: stage: test script: - yarn run test From 2cf8088252845921adb8fa0def42d5878f9afc7d Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 16:41:40 +0200 Subject: [PATCH 27/50] fix folder --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4dee6ff4..ca0552dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ build development: artifacts: expire_in: 1 month paths: - - /build + - /build/dev build beta: stage: build @@ -43,7 +43,7 @@ build beta: artifacts: expire_in: 1 month paths: - - /build + - /build/beta build production: stage: build @@ -52,7 +52,7 @@ build production: artifacts: expire_in: 1 month paths: - - /build + - /build/prod # deploy deploy review: From fcd05eced049d3b8c888e236cb993e43e0a96f3b Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 23 Oct 2018 16:48:54 +0200 Subject: [PATCH 28/50] fix folder 2 --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca0552dc..94a353f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ build development: artifacts: expire_in: 1 month paths: - - /build/dev + - build/dev build beta: stage: build @@ -43,7 +43,7 @@ build beta: artifacts: expire_in: 1 month paths: - - /build/beta + - build/beta build production: stage: build @@ -52,7 +52,7 @@ build production: artifacts: expire_in: 1 month paths: - - /build/prod + - build/prod # deploy deploy review: From d91a04396773fb5a21809c6bb45270a679716942 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 14:50:28 +0200 Subject: [PATCH 29/50] update old-wallet urls --- src/constants/coins.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/constants/coins.js b/src/constants/coins.js index ac70469c..4014242c 100644 --- a/src/constants/coins.js +++ b/src/constants/coins.js @@ -2,47 +2,47 @@ export default [ { id: 'btc', coinName: 'Bitcoin', - url: '../#/?coin=btc', + url: '../?coin=btc', }, { id: 'bch', coinName: 'Bitcoin Cash', - url: '../#/?coin=bch', + url: '../?coin=bch', }, { id: 'btg', coinName: 'Bitcoin Gold', - url: '../#/?coin=btg', + url: '../?coin=btg', }, { id: 'dash', coinName: 'Dash', - url: '../#/?coin=dash', + url: '../?coin=dash', }, { id: 'doge', coinName: 'Dogecoin', - url: '../#/?coin=doge', + url: '../?coin=doge', }, { id: 'ltc', coinName: 'Litecoin', - url: '../#/?coin=ltc', + url: '../?coin=ltc', }, { id: 'nmc', coinName: 'Namecoin', - url: '../#/?coin=nmc', + url: '../?coin=nmc', }, { id: 'vtc', coinName: 'Vertcoin', - url: '../#/?coin=vtc', + url: '../?coin=vtc', }, { id: 'zec', coinName: 'Zcash', - url: '../#/?coin=zec', + url: '../?coin=zec', }, { id: 'xem', From b1fe64867d889c78dd9f8c1f7d5fba52359dcac5 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 24 Oct 2018 17:18:28 +0200 Subject: [PATCH 30/50] Export resources while docker build --- Dockerfile | 4 +++- scripts/docker-build.sh | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48abcd1d..040ede72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM node:8 +ARG BUILD_TYPE=prod + WORKDIR /trezor-wallet-app COPY package.json /trezor-wallet-app @@ -9,7 +11,7 @@ RUN yarn install COPY . /trezor-wallet-app -RUN yarn run build:prod +RUN yarn run build:${BUILD_TYPE} EXPOSE 8080 CMD [ "yarn", "run", "prod-server" ] \ No newline at end of file diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index b4bceccd..eaab7c0b 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -1,4 +1,16 @@ #!/bin/bash cd "$(dirname "$0")" -docker build -t trezor-wallet ../ \ No newline at end of file + +if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] + then + docker stop trezor-wallet + docker rm trezor-wallet + docker build -t trezor-wallet ../ --build-arg BUILD_TYPE=$1 + docker run -p 8080:8080 -d --name trezor-wallet trezor-wallet:latest + docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/ + docker stop trezor-wallet + docker rm trezor-wallet + else + echo "invalid parameters... valid parameters are (beta, dev, prod)" +fi \ No newline at end of file From 15e4ee383fc827975ce3a40180af68d192a9d641 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 24 Oct 2018 17:31:49 +0200 Subject: [PATCH 31/50] Export resources while docker build - fix --- scripts/docker-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index eaab7c0b..501c4a97 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -4,8 +4,8 @@ cd "$(dirname "$0")" if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] then - docker stop trezor-wallet - docker rm trezor-wallet + rm -rf ../build/$1 + docker ps -q --filter "name=trezor-wallet" | grep -q . && docker stop trezor-wallet && docker rm -fv trezor-wallet docker build -t trezor-wallet ../ --build-arg BUILD_TYPE=$1 docker run -p 8080:8080 -d --name trezor-wallet trezor-wallet:latest docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/ From 76a09e39b6b7794df345e5a865ffced02ab825de Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 17:55:28 +0200 Subject: [PATCH 32/50] updated Makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8c84f3b5..1bd83788 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -build: - sh ./scripts/docker-build.sh +build-%: + sh ./scripts/docker-build.sh $* sync-%: sh ./scripts/s3sync.sh $* \ No newline at end of file From 258df74c0d66e46fbbde47587b2e188d2c258af0 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Wed, 24 Oct 2018 17:58:10 +0200 Subject: [PATCH 33/50] Fix prod and beta local servers --- package.json | 4 +++- server/index.js | 10 ++++++++-- yarn.lock | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d966c6c4..32617cbc 100644 --- a/package.json +++ b/package.json @@ -21,13 +21,15 @@ "test": "run-s test:*", "test:unit": "npx jest", "test-unit:watch": "npx jest -o --watch", - "prod-server": "node ./server/index.js" + "server:beta": "node ./server/index.js --buildType=beta", + "server:prod": "node ./server/index.js --buildType=prod" }, "dependencies": { "babel": "^6.23.0", "babel-core": "^6.26.3", "bignumber.js": "2.4.0", "color-hash": "^1.0.3", + "commander": "^2.19.0", "copy-webpack-plugin": "^4.5.2", "cross-env": "^5.2.0", "date-fns": "^1.29.0", diff --git a/server/index.js b/server/index.js index e179367b..7bdd18cd 100644 --- a/server/index.js +++ b/server/index.js @@ -3,6 +3,12 @@ const morgan = require('morgan'); const fs = require('fs'); const path = require('path'); const https = require('https'); +const commander = require('commander'); + +commander + .version('0.1.0') + .option('-b, --buildType [type]', 'Set the build type') + .parse(process.argv); const privateKey = fs.readFileSync('server/key.pem').toString(); const certificate = fs.readFileSync('server/cert.pem').toString(); @@ -16,11 +22,11 @@ const PORT = process.env.PORT || 8080; app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] :response-time ms')); // Serve static assets -app.use(express.static(path.resolve(__dirname, '..', 'build'))); +app.use(express.static(path.resolve(__dirname, '..', 'build', commander.buildType))); // Always return the main index.html, so react-router render the route in the client app.get('*', (req, res) => { - res.sendFile(path.resolve(__dirname, '..', 'build', 'index.html')); + res.sendFile(path.resolve(__dirname, '..', 'build', commander.buildType, 'index.html')); }); const httpsServer = https.createServer(credentials, app); diff --git a/yarn.lock b/yarn.lock index d222ae8a..6e1855a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2570,6 +2570,10 @@ commander@^2.13.0: version "2.18.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" +commander@^2.19.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" + commander@^2.8.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" From 074d59a4c88fdb7b4711ccf44672962ff8abcb92 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 18:00:11 +0200 Subject: [PATCH 34/50] Makefile without sh command --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1bd83788..b9aabd01 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build-%: - sh ./scripts/docker-build.sh $* + ./scripts/docker-build.sh $* sync-%: - sh ./scripts/s3sync.sh $* \ No newline at end of file + ./scripts/s3sync.sh $* \ No newline at end of file From 1c0cf528e0e02f58716a37a86d82e73e93176d99 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 18:38:39 +0200 Subject: [PATCH 35/50] docekrbuild script: add missing target directory --- scripts/docker-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 501c4a97..2ca8c314 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -8,7 +8,7 @@ if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] docker ps -q --filter "name=trezor-wallet" | grep -q . && docker stop trezor-wallet && docker rm -fv trezor-wallet docker build -t trezor-wallet ../ --build-arg BUILD_TYPE=$1 docker run -p 8080:8080 -d --name trezor-wallet trezor-wallet:latest - docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/ + docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/$1 docker stop trezor-wallet docker rm trezor-wallet else From 79f349608de2d739bf8a8320225688336386929d Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 18:46:38 +0200 Subject: [PATCH 36/50] Dokckerfile: bump node version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 040ede72..d1dd82de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8 +FROM node:9.3 ARG BUILD_TYPE=prod From 36361429119582c5f371988bb5a56708e43b7e12 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 18:47:04 +0200 Subject: [PATCH 37/50] dockerbuild script: create build file if not exists --- scripts/docker-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 2ca8c314..630b3efc 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -4,6 +4,7 @@ cd "$(dirname "$0")" if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] then + mkdir -p ../build rm -rf ../build/$1 docker ps -q --filter "name=trezor-wallet" | grep -q . && docker stop trezor-wallet && docker rm -fv trezor-wallet docker build -t trezor-wallet ../ --build-arg BUILD_TYPE=$1 From efc82b90c18d363116b5d8f6b8860b0e3791c4e4 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:00:32 +0200 Subject: [PATCH 38/50] update Makefile and s3sync scripts --- Makefile | 27 +++++++++++++++++++-- scripts/s3sync.sh | 60 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 66 insertions(+), 21 deletions(-) mode change 100644 => 100755 scripts/s3sync.sh diff --git a/Makefile b/Makefile index b9aabd01..e40ce5de 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,28 @@ +# Run docker build +# usage: +# make build-beta +# make build-stable build-%: ./scripts/docker-build.sh $* -sync-%: - ./scripts/s3sync.sh $* \ No newline at end of file +# s3sync with stage.mytrezor.com +# Upload requested build for testing purposes +# usage: +# make stage-beta +# make stage-stable +stage-%: + ./scripts/s3sync.sh stage $* + +# s3sync with beta.mytrezor.com +# Upload build/beta only +# usage: +# make beta +beta: + ./scripts/s3sync.sh beta beta + +# s3sync with wallet.mytrezor.com +# Upload build/stable only +# usage: +# make stable +stable: + ./scripts/s3sync.sh stable stable \ No newline at end of file diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh old mode 100644 new mode 100755 index 44a141a2..a4904366 --- a/scripts/s3sync.sh +++ b/scripts/s3sync.sh @@ -13,41 +13,63 @@ function confirm { fi } -if [ "x$1" == "x" ]; then - echo "./s3sync.sh stage|beta|wallet [-d]" + +# Validate params +if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then + echo "Invalid params" + echo "./s3sync.sh beta|stable stage|beta|stable [clear]" exit 1 fi +# Validate destination param +if [ "x$1" != "xstage" ] && [ "x$1" != "xbeta" ] && [ "x$1" != "xstable" ]; then + echo "Invalid destination: "$1 + echo "use: stage|beta|stable" + exit 1 +fi + +# Validate source param +if [ "x$2" != "xbeta" ] && [ "x$2" != "xstable" ]; then + echo "Invalid source: "$2 + echo "use: beta|stable" + exit 1 +fi + +# Set source directory +if [ "x$2" == "xbeta" ]; then + SOURCE=../build/beta + +elif [ "x$2" == "xstable" ]; then + SOURCE=../build/stable +fi + +# Set destination if [ "x$1" == "xstage" ]; then - DIST=../build/beta BUCKET=stage.mytrezor.com DISTRIBUTION_ID="E24M0QWO692FQL" - elif [ "x$1" == "xbeta" ]; then - DIST=../build/beta BUCKET=beta.mytrezor.com DISTRIBUTION_ID="E1PONNHWUNCQ9M" - - confirm - -elif [ "x$1" == "xwallet" ]; then - DIST=../build/prod +elif [ "x$2" == "xstable" ]; then BUCKET=wallet.mytrezor.com DISTRIBUTION_ID="EZM01GFTITGVD" +fi - confirm +echo "sync "$SOURCE" with "$BUCKET"/next" +if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then + confirm fi -set -e -cd `dirname $0` +# set -e +# cd `dirname $0` -if [ "x$2" == "x-d" ]; then - aws s3 sync --delete --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next -else - aws s3 sync --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next -fi +# if [ "x$3" == "x-d" ]; then +# aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +# else +# aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +# fi -aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' +# aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' echo "DONE" \ No newline at end of file From c21573b1cde12bf47cdb9310313439dd38423c5f Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:01:23 +0200 Subject: [PATCH 39/50] renamed "prod" directory to "stable" --- .gitlab-ci.yml | 4 ++-- Dockerfile | 2 +- package.json | 4 ++-- scripts/docker-build.sh | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94a353f3..168202be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,11 +48,11 @@ build beta: build production: stage: build script: - - yarn run build:prod + - yarn run build:stable artifacts: expire_in: 1 month paths: - - build/prod + - build/stable # deploy deploy review: diff --git a/Dockerfile b/Dockerfile index d1dd82de..7d2db3a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:9.3 -ARG BUILD_TYPE=prod +ARG BUILD_TYPE=stable WORKDIR /trezor-wallet-app diff --git a/package.json b/package.json index 32617cbc..80a26712 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dev": "npx webpack-dev-server --config webpack/dev.babel.js", "dev:local": "npx webpack-dev-server --config webpack/local.babel.js", "build": "rimraf build && run-s build:*", - "build:prod": "rimraf build/prod && npx webpack --config webpack/production.babel.js --output-path build/prod --progress --bail", + "build:stable": "rimraf build/stable && npx webpack --config webpack/production.babel.js --output-path build/stable --progress --bail", "build:beta": "rimraf build/beta && cross-env BUILD=beta npx webpack --config webpack/production.babel.js --output-path build/beta --progress --bail", "build:dev": "rimraf build.dev && cross-env BUILD=development npx webpack --config webpack/production.babel.js --output-path build/dev --progress --bail", "flow": "flow check src", @@ -22,7 +22,7 @@ "test:unit": "npx jest", "test-unit:watch": "npx jest -o --watch", "server:beta": "node ./server/index.js --buildType=beta", - "server:prod": "node ./server/index.js --buildType=prod" + "server:stable": "node ./server/index.js --buildType=stable" }, "dependencies": { "babel": "^6.23.0", diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 630b3efc..bea0d4e1 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -2,7 +2,7 @@ cd "$(dirname "$0")" -if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] +if [[ "$1" == "dev" || "$1" == "beta" || "$1" == "stable" ]] then mkdir -p ../build rm -rf ../build/$1 @@ -12,6 +12,8 @@ if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/$1 docker stop trezor-wallet docker rm trezor-wallet + echo "DONE!" + echo "Build directory: "$1 else - echo "invalid parameters... valid parameters are (beta, dev, prod)" + echo "invalid parameters... valid parameters are (dev, beta, stable)" fi \ No newline at end of file From 867156562d45c072a3c2c2dabd20fc729b9b0ed5 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:34:38 +0200 Subject: [PATCH 40/50] uncomment s3sync, add usage --- scripts/s3sync.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh index a4904366..41fc5e3f 100755 --- a/scripts/s3sync.sh +++ b/scripts/s3sync.sh @@ -4,6 +4,17 @@ # Install awscli (pip install awscli) # Configure access credentials (aws configure), region is "eu-central-1" +# Usage: +# ./s3sync.sh DESTINATION SOURCE [clear] +# @DESTINATION: required, destination server +# @SOURCE: required, build +# @CLEAR: optional, delete previous uploads +# ./s3sync.sh stage beta +# ./s3sync.sh stage stable +# ./s3sync.sh stage stable clear +# ./s3sync.sh beta beta +# ./s3sync.sh stable stable + function confirm { read -r -p "Are you sure? [y/N] " response if [[ $response =~ ^(yes|y)$ ]]; then @@ -17,7 +28,7 @@ function confirm { # Validate params if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then echo "Invalid params" - echo "./s3sync.sh beta|stable stage|beta|stable [clear]" + echo "./s3sync.sh stage|beta|stable beta|stable [clear]" exit 1 fi @@ -61,15 +72,15 @@ if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then confirm fi -# set -e -# cd `dirname $0` +set -e +cd `dirname $0` -# if [ "x$3" == "x-d" ]; then -# aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next -# else -# aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next -# fi +if [ "x$3" == "x-clear" ]; then + aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +else + aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +fi -# aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' +aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' echo "DONE" \ No newline at end of file From 539b7ed5d1ccb095ba5441c9e6d6e32cd77007ce Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:35:48 +0200 Subject: [PATCH 41/50] echo build directory from docker-build --- scripts/docker-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index bea0d4e1..3d94f9d3 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -13,7 +13,7 @@ if [[ "$1" == "dev" || "$1" == "beta" || "$1" == "stable" ]] docker stop trezor-wallet docker rm trezor-wallet echo "DONE!" - echo "Build directory: "$1 + echo "Build directory: build/"$1 else echo "invalid parameters... valid parameters are (dev, beta, stable)" fi \ No newline at end of file From 835906bf9602de4c5372e2e171675e5152d04eb2 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 11:58:32 +0200 Subject: [PATCH 42/50] FIxed icon overflow --- src/components/Notification/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Notification/index.js b/src/components/Notification/index.js index 8b4e5bb2..fdff20e7 100644 --- a/src/components/Notification/index.js +++ b/src/components/Notification/index.js @@ -87,7 +87,7 @@ const StyledIcon = styled(Icon)` `; const IconWrapper = styled.div` - min-width: 20px; + min-width: 30px; `; const Texts = styled.div` From 0aa1cb75edefc9bd2d6605cdbd67814aaa63c225 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 13:56:31 +0200 Subject: [PATCH 43/50] Automatically deploy review branches to dev server --- .gitlab-ci.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 168202be..39a4de52 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,6 +40,7 @@ build beta: stage: build script: - yarn run build:beta + when: manual artifacts: expire_in: 1 month paths: @@ -49,20 +50,26 @@ build production: stage: build script: - yarn run build:stable + when: manual artifacts: expire_in: 1 month paths: - build/stable -# deploy deploy review: stage: deploy + variables: + GIT_STRATEGY: none + dependencies: + - build development script: - echo "Deploy a review app" - environment: - name: review/$CI_COMMIT_REF_NAME - url: https://$CI_ENVIRONMENT_SLUG.example.com + - '[ -z "${DEPLOY_BASE_DIR}" ] && echo "Deploy base dir cannot be empty" && exit 255' + - env + - mkdir -p "${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}" + - echo "Copy dev build to web server ${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}..." + - rsync --delete -va build/dev/ "${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}/" only: - branches - except: - - master \ No newline at end of file + tags: + - deploy From f0e45b6c332533cc5867eef06ecc2324e5c8bc22 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 14:47:39 +0200 Subject: [PATCH 44/50] Prepare gitlab configs --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39a4de52..2ba88ca3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,17 +40,15 @@ build beta: stage: build script: - yarn run build:beta - when: manual artifacts: expire_in: 1 month paths: - build/beta -build production: +build stable: stage: build script: - yarn run build:stable - when: manual artifacts: expire_in: 1 month paths: @@ -73,3 +71,33 @@ deploy review: - branches tags: - deploy + +deploy stage beta: + stage: deploy + variables: + GIT_STRATEGY: none + when: + - manual + dependencies: + - build beta + script: + - echo "Deploy staging beta version" + only: + - beta + tags: + - deploy + +deploy stage stable: + stage: deploy + variables: + GIT_STRATEGY: none + when: + - manual + dependencies: + - build stable + script: + - echo "Deploy staging stable version" + only: + - stable + tags: + - deploy From e9cf52ae8017762cb923a7c719fb32251a4913c4 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 14:50:15 +0200 Subject: [PATCH 45/50] fix yaml --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ba88ca3..d8551c1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,8 +76,7 @@ deploy stage beta: stage: deploy variables: GIT_STRATEGY: none - when: - - manual + when: manual dependencies: - build beta script: @@ -91,8 +90,7 @@ deploy stage stable: stage: deploy variables: GIT_STRATEGY: none - when: - - manual + when: manual dependencies: - build stable script: From ad183068e150b7e5238308c1210563a321a277d5 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 15:39:17 +0200 Subject: [PATCH 46/50] Added sync to aws --- .gitlab-ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8551c1b..154cca61 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,7 @@ build beta: expire_in: 1 month paths: - build/beta + - scripts/s3sync.sh build stable: stage: build @@ -53,6 +54,7 @@ build stable: expire_in: 1 month paths: - build/stable + - scripts/s3sync.sh deploy review: stage: deploy @@ -76,11 +78,13 @@ deploy stage beta: stage: deploy variables: GIT_STRATEGY: none + AWS_ACCESS_KEY_ID: $STAGE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: $STAGE_AWS_SECRET_ACCESS_KEY when: manual dependencies: - build beta script: - - echo "Deploy staging beta version" + - scripts/s3sync.sh beta only: - beta tags: @@ -90,11 +94,13 @@ deploy stage stable: stage: deploy variables: GIT_STRATEGY: none + AWS_ACCESS_KEY_ID: $STAGE_AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: $STAGE_AWS_SECRET_ACCESS_KEY when: manual dependencies: - build stable script: - - echo "Deploy staging stable version" + - scripts/s3sync.sh stable only: - stable tags: From 29d5d2ca2686f991d5f83ba759be687ea3e2be6b Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 15:53:02 +0200 Subject: [PATCH 47/50] Added missing param --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 154cca61..c9344d5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -84,7 +84,7 @@ deploy stage beta: dependencies: - build beta script: - - scripts/s3sync.sh beta + - scripts/s3sync.sh stage beta only: - beta tags: @@ -100,7 +100,7 @@ deploy stage stable: dependencies: - build stable script: - - scripts/s3sync.sh stable + - scripts/s3sync.sh stage stable only: - stable tags: From 2ab0120e21d6f5f0172a84425475ee7f2e68e76b Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 15:56:55 +0200 Subject: [PATCH 48/50] Install modules only if needed --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c9344d5e..7436df22 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,9 +4,6 @@ cache: paths: - node_modules -before_script: - - yarn install - stages: - test - build @@ -15,6 +12,7 @@ stages: lint: stage: test script: + - yarn install - yarn run lint flow: @@ -25,11 +23,13 @@ flow: unit: stage: test script: + - yarn install - yarn run test build development: stage: build script: + - yarn install - yarn run build:dev artifacts: expire_in: 1 month @@ -39,6 +39,7 @@ build development: build beta: stage: build script: + - yarn install - yarn run build:beta artifacts: expire_in: 1 month @@ -49,6 +50,7 @@ build beta: build stable: stage: build script: + - yarn install - yarn run build:stable artifacts: expire_in: 1 month From b259075a837d9b95f6cfb2600ac83fcb068c8d9e Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 25 Oct 2018 16:00:29 +0200 Subject: [PATCH 49/50] Expire artifacts in one week --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7436df22..2ec28061 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,7 @@ build development: - yarn install - yarn run build:dev artifacts: - expire_in: 1 month + expire_in: 1 week paths: - build/dev @@ -42,7 +42,7 @@ build beta: - yarn install - yarn run build:beta artifacts: - expire_in: 1 month + expire_in: 1 week paths: - build/beta - scripts/s3sync.sh @@ -53,7 +53,7 @@ build stable: - yarn install - yarn run build:stable artifacts: - expire_in: 1 month + expire_in: 1 week paths: - build/stable - scripts/s3sync.sh From 20c503c1648f8b0266f3de1f630a60a8eb415876 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Thu, 25 Oct 2018 17:05:02 +0200 Subject: [PATCH 50/50] redirect to initial url after acquiring device 1. try to redirect after DEVICE.CONNECT event 2. clear initial url when redirection is done --- src/actions/RouterActions.js | 10 +++++++++- src/services/WalletService.js | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/actions/RouterActions.js b/src/actions/RouterActions.js index d4c5842b..18eae118 100644 --- a/src/actions/RouterActions.js +++ b/src/actions/RouterActions.js @@ -2,6 +2,7 @@ import { push, LOCATION_CHANGE } from 'react-router-redux'; import { CONTEXT_NONE } from 'actions/constants/modal'; +import { SET_INITIAL_URL } from 'actions/constants/wallet'; import { routes } from 'support/routes'; import * as deviceUtils from 'utils/device'; @@ -57,7 +58,7 @@ export const paramsValidation = (params: RouterLocationState): PayloadAction d.features && d.features.device_id === params.device && d.instance === parseInt(params.deviceInstance, 10)); } else { - device = devices.find(d => d.path === params.device || (d.features && d.features.device_id === params.device)); + device = devices.find(d => ((!d.features || d.mode === 'bootloader') && d.path === params.device) || (d.features && d.features.device_id === params.device)); } if (!device) return false; @@ -247,6 +248,8 @@ const sortDevices = (devices: Array): Array => devic * Redirect to requested device */ export const selectDevice = (device: TrezorDevice | Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => { + if (dispatch(setInitialUrl())) return; + const url: ?string = dispatch(getDeviceUrl(device)); if (!url) return; @@ -352,7 +355,12 @@ export const setInitialUrl = (): PayloadAction => (dispatch: Dispatch, state: {}, }, })); + if (valid === initialPathname) { + // reset initial url + dispatch({ + type: SET_INITIAL_URL, + }); dispatch(goto(valid)); return true; } diff --git a/src/services/WalletService.js b/src/services/WalletService.js index 597f1b3c..2ad40df0 100644 --- a/src/services/WalletService.js +++ b/src/services/WalletService.js @@ -47,7 +47,9 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa switch (action.type) { case WALLET.SET_INITIAL_URL: - api.dispatch(LocalStorageActions.loadData()); + if (action.pathname) { + api.dispatch(LocalStorageActions.loadData()); + } break; case WALLET.SET_SELECTED_DEVICE: // try to authorize device