From c9ac6b9c55f9d80c1e948bb6a909355df67337c4 Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:15:52 -0300 Subject: [PATCH 01/18] feat(build): add protocols to electron-build settings --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.json b/package.json index 2ce3f07..2a1ee70 100644 --- a/package.json +++ b/package.json @@ -175,6 +175,12 @@ "win": { "target": "nsis", "icon": "./build/icons/win/icon.ico" + }, + "protocols": { + "name": "zcash", + "schemes": [ + "zcash" + ] } }, "jest": { From 69fd24149a8f4acf713e5e021840096c11104cdb Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:17:13 -0300 Subject: [PATCH 02/18] chore(sidebar): fix isActive check --- app/components/sidebar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/components/sidebar.js b/app/components/sidebar.js index d852e34..0117511 100644 --- a/app/components/sidebar.js +++ b/app/components/sidebar.js @@ -67,7 +67,9 @@ type Props = { export const SidebarComponent = ({ options, location, history }: Props) => ( {(options || []).map((item) => { - const isActive = location.pathname === item.route; + const isActive = item.route === '/' + ? location.pathname === item.route + : location.pathname.startsWith(item.route); return ( Date: Thu, 14 Feb 2019 19:18:37 -0300 Subject: [PATCH 03/18] type(electron): fix eletron$app typedefs --- flow-custom-typedefs/electron.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flow-custom-typedefs/electron.js b/flow-custom-typedefs/electron.js index 1edc609..2fa586b 100644 --- a/flow-custom-typedefs/electron.js +++ b/flow-custom-typedefs/electron.js @@ -118,10 +118,11 @@ type electron$app = { getName(): string, setName(name: string): void, getLocale(): string, - makeSingleInstance(callback: (argv: Array, workingDirectory: string) => void): boolean, + requestSingleInstanceLock(): boolean, + setAsDefaultProtocolClient(schema: string): void, releaseSingleInstance(): void, disableHardwareAcceleration(): void, - on(event: string, callback: () => any): void, + on(event: string, callback: Function): void, }; /** From e70f03130d43ec434c366d58b9ccb1e99dda2639 Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:20:05 -0300 Subject: [PATCH 04/18] feat(deeplink): add handleDeeplink on app startup --- config/electron.js | 30 ++++++++++++++++++++++++++++++ config/handle-deeplink.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 config/handle-deeplink.js diff --git a/config/electron.js b/config/electron.js index 4d1da55..a99d309 100644 --- a/config/electron.js +++ b/config/electron.js @@ -14,6 +14,7 @@ import runDaemon from './daemon/zcashd-child-process'; import zcashLog from './daemon/logger'; import getZecPrice from '../services/zec-price'; import store from './electron-store'; +import { handleDeeplink } from './handle-deeplink'; dotenv.config(); @@ -79,6 +80,35 @@ const createWindow = () => { exports.mainWindow = mainWindow; }; +app.setAsDefaultProtocolClient('zcash'); + +const instanceLock = app.requestSingleInstanceLock(); +if (instanceLock) { + app.on('second-instance', (event: Object, argv: string[]) => { + handleDeeplink({ + app, + mainWindow, + argv, + listenOpenUrl: false, + }); + + if (mainWindow) { + if (mainWindow.isMinimized()) { + mainWindow.restore(); + } + + mainWindow.focus(); + } + }); +} else { + app.quit(); +} + +app.on('will-finish-launching', () => handleDeeplink({ + app, + mainWindow, +})); + /* eslint-disable-next-line consistent-return */ app.on('ready', async () => { createWindow(); diff --git a/config/handle-deeplink.js b/config/handle-deeplink.js new file mode 100644 index 0000000..98c1ce1 --- /dev/null +++ b/config/handle-deeplink.js @@ -0,0 +1,36 @@ +// @flow +import { typeof app as ElectronApp, type electron$BrowserWindow } from 'electron'; // eslint-disable-line + +const sendMessage = (mainWindow, url) => { + if (mainWindow) { + if (mainWindow.isVisible()) { + mainWindow.webContents.send('on-deep-link', url); + } else { + mainWindow.on('show', () => mainWindow.webContents.send('on-deep-link', url)); + } + } +}; + +export const handleDeeplink = ({ + app, + mainWindow, + argv = process.argv, + listenOpenUrl = true, +}: { + app: ElectronApp, + mainWindow: electron$BrowserWindow, + argv?: string[], + listenOpenUrl?: boolean, +}) => { + if (listenOpenUrl) { + app.on('open-url', (event: Object, url: string) => { + event.preventDefault(); + sendMessage(mainWindow, url); + }); + } + + if (process.platform === 'win32' || process.platform === 'linux') { + const argIndex = argv.findIndex(item => /zcash:(\/\/)?/.test(item)); + if (argIndex !== -1) sendMessage(mainWindow, argv[argIndex]); + } +}; From 03e3d33dece44c2488b302dfd991e32fcda2d95d Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:20:54 -0300 Subject: [PATCH 05/18] type(send): export redux types --- app/containers/send.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/app/containers/send.js b/app/containers/send.js index c4b62d3..c5d246c 100644 --- a/app/containers/send.js +++ b/app/containers/send.js @@ -36,7 +36,17 @@ export type SendTransactionInput = { memo: string, }; -const mapStateToProps = ({ sendStatus, receive }: AppState) => ({ +export type MapStateToProps = {| + balance: number, + zecPrice: number, + addresses: string[], + error: string | null, + isSending: boolean, + operationId: string | null, + isToAddressValid: boolean, +|}; + +const mapStateToProps = ({ sendStatus, receive }: AppState): MapStateToProps => ({ balance: sendStatus.addressBalance, zecPrice: sendStatus.zecPrice, addresses: receive.addresses, @@ -46,10 +56,19 @@ const mapStateToProps = ({ sendStatus, receive }: AppState) => ({ isToAddressValid: sendStatus.isToAddressValid, }); -const mapDispatchToProps = (dispatch: Dispatch) => ({ +export type MapDispatchToProps = {| + sendTransaction: SendTransactionInput => Promise, + loadAddresses: () => Promise, + resetSendView: () => void, + validateAddress: ({ address: string }) => Promise, + loadZECPrice: () => void, + getAddressBalance: ({ address: string }) => Promise, +|}; + +const mapDispatchToProps = (dispatch: Dispatch): MapDispatchToProps => ({ sendTransaction: async ({ from, to, amount, fee, memo, - }: SendTransactionInput) => { + }) => { dispatch(sendTransaction()); // $FlowFixMe @@ -142,7 +161,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ if (zAddressesErr || tAddressesErr) return dispatch(loadAddressesError({ error: 'Something went wrong!' })); - dispatch( + return dispatch( loadAddressesSuccess({ addresses: [...zAddresses, ...transparentAddresses], }), From 32816d2372f6560f6eb4981847a50b34e99c2f87 Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:22:00 -0300 Subject: [PATCH 06/18] feat(deeplink): add withDeepLink HOC --- app/components/with-deeplink.js | 27 +++++++++++++++++++++++++++ app/router/container.js | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 app/components/with-deeplink.js diff --git a/app/components/with-deeplink.js b/app/components/with-deeplink.js new file mode 100644 index 0000000..3d5848b --- /dev/null +++ b/app/components/with-deeplink.js @@ -0,0 +1,27 @@ +// @flow +import React, { type ComponentType, Component } from 'react'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { ipcRenderer } from 'electron'; +import { type RouterHistory } from 'react-router-dom'; + +export const withDeepLink = ( + WrappedComponent: ComponentType, +): ComponentType<$Diff> => class extends Component { + timer: ?IntervalID = null; + + componentDidMount() { + const { history } = this.props; + + ipcRenderer.on('on-deep-link', (event: Object, message: string) => { + history.replace(`/send/${message.replace(/zcash:(\/\/)?/, '')}`); + }); + } + + componentWillUnmount() { + ipcRenderer.removeAllListeners('on-deep-link'); + } + + render() { + return ; + } + }; diff --git a/app/router/container.js b/app/router/container.js index bbeac85..edbc9c2 100644 --- a/app/router/container.js +++ b/app/router/container.js @@ -4,8 +4,10 @@ import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; import { RouterComponent } from './router'; import { withDaemonStatusCheck } from '../components/with-daemon-status-check'; +import { withDeepLink } from '../components/with-deeplink'; export const Router = compose( withRouter, + withDeepLink, withDaemonStatusCheck, )(RouterComponent); From c29d0b5bdd8b27dafbaa34a68506ed7cb0c21a86 Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:22:48 -0300 Subject: [PATCH 07/18] feat(router): add to param in send route --- app/router/router.js | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/app/router/router.js b/app/router/router.js index d90851b..9165cf1 100644 --- a/app/router/router.js +++ b/app/router/router.js @@ -42,7 +42,7 @@ const ContentWrapper = styled.div` const getTitle = (path: string) => { if (path === '/') return 'Dashboard'; - return path.replace('/', ''); + return path.split('/')[1]; }; export const RouterComponent = ({ @@ -55,39 +55,16 @@ export const RouterComponent = ({ - - {/* $FlowFixMe */} + - - - - - - + + + + + + From 782425e052b9bec36a4a8877f0836136116b37dd Mon Sep 17 00:00:00 2001 From: George Lima Date: Thu, 14 Feb 2019 19:24:38 -0300 Subject: [PATCH 08/18] feat(send): fill up "to" field in send viiew --- app/views/send.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/app/views/send.js b/app/views/send.js index 52a0e70..1c16f8f 100644 --- a/app/views/send.js +++ b/app/views/send.js @@ -4,6 +4,7 @@ import React, { Fragment, PureComponent } from 'react'; import styled, { keyframes } from 'styled-components'; import { BigNumber } from 'bignumber.js'; import { Transition, animated } from 'react-spring'; +import { type Match } from 'react-router-dom'; import { FEES } from '../constants/fees'; @@ -20,8 +21,7 @@ import { ConfirmDialogComponent } from '../components/confirm-dialog'; import { formatNumber } from '../utils/format-number'; import { ascii2hex } from '../utils/ascii-to-hexadecimal'; -import type { SendTransactionInput } from '../containers/send'; -import type { State as SendState } from '../redux/modules/send'; +import type { MapDispatchToProps, MapStateToProps } from '../containers/send'; import SentIcon from '../assets/images/transaction_sent_icon.svg'; import MenuIcon from '../assets/images/menu_icon.svg'; @@ -238,19 +238,7 @@ const MaxAvailableAmountImg = styled.img` height: 20px; `; -type Props = { - ...SendState, - balance: number, - zecPrice: number, - addresses: string[], - sendTransaction: SendTransactionInput => void, - loadAddresses: () => void, - resetSendView: () => void, - validateAddress: ({ address: string }) => void, - loadAddresses: () => void, - loadZECPrice: () => void, - getAddressBalance: ({ address: string }) => void, -}; +type Props = { match: Match } & MapStateToProps & MapDispatchToProps; type State = { showFee: boolean, @@ -278,11 +266,24 @@ export class SendView extends PureComponent { state = initialState; componentDidMount() { - const { resetSendView, loadAddresses, loadZECPrice } = this.props; + const { + resetSendView, loadAddresses, loadZECPrice, match, + } = this.props; resetSendView(); loadAddresses(); loadZECPrice(); + + if (match.params.to) { + this.handleChange('to')(match.params.to); + } + } + + componentDidUpdate(prevProps: Props) { + const previousToAddress = prevProps.match.params.to; + const toAddress = this.props.match.params.to; // eslint-disable-line + + if (toAddress && previousToAddress !== toAddress) this.handleChange('to')(toAddress); } handleChange = (field: string) => (value: string | number) => { From 8683a73e90295b629d8ab17088d19cccfaab9108 Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 11:18:00 -0300 Subject: [PATCH 09/18] feat(loading-screen): fix theme usage --- app/components/loading-screen.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/components/loading-screen.js b/app/components/loading-screen.js index dc551ce..0a735f8 100644 --- a/app/components/loading-screen.js +++ b/app/components/loading-screen.js @@ -1,7 +1,7 @@ // @flow import React, { PureComponent } from 'react'; -import styled from 'styled-components'; +import styled, { withTheme } from 'styled-components'; import { Transition, animated } from 'react-spring'; // eslint-disable-next-line import/no-extraneous-dependencies import { ipcRenderer } from 'electron'; @@ -11,8 +11,6 @@ import { TextComponent } from './text'; import zcashLogo from '../assets/images/zcash-simple-icon.svg'; -import theme from '../theme'; - const Wrapper = styled.div` width: 100vw; height: 100vh; @@ -41,6 +39,7 @@ const Logo = styled.img` type Props = { progress: number, + theme: AppTheme, }; type State = { @@ -50,7 +49,7 @@ type State = { const TIME_DELAY_ANIM = 100; -export class LoadingScreen extends PureComponent { +export class Component extends PureComponent { state = { start: false, message: 'ZEC Wallet Starting' }; componentDidMount() { @@ -69,7 +68,7 @@ export class LoadingScreen extends PureComponent { render() { const { start, message } = this.state; - const { progress } = this.props; + const { progress, theme } = this.props; return ( @@ -100,11 +99,10 @@ export class LoadingScreen extends PureComponent { @@ -115,3 +113,5 @@ export class LoadingScreen extends PureComponent { ); } } + +export const LoadingScreen = withTheme(Component); From 162d710c134684091916d00d41db1fe4453ef480 Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 11:24:48 -0300 Subject: [PATCH 10/18] fix(router): compose hocs order --- app/router/container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/router/container.js b/app/router/container.js index edbc9c2..ff0ad75 100644 --- a/app/router/container.js +++ b/app/router/container.js @@ -8,6 +8,6 @@ import { withDeepLink } from '../components/with-deeplink'; export const Router = compose( withRouter, - withDeepLink, withDaemonStatusCheck, + withDeepLink, )(RouterComponent); From 8c566216e7bc1ad58e62df59bd3da98635e0385f Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 11:30:06 -0300 Subject: [PATCH 11/18] feat(logs): add process.argv log --- config/electron.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/electron.js b/config/electron.js index a99d309..887aa66 100644 --- a/config/electron.js +++ b/config/electron.js @@ -113,6 +113,8 @@ app.on('will-finish-launching', () => handleDeeplink({ app.on('ready', async () => { createWindow(); + console.log('[Process Argv]', process.argv); // eslint-disable-line + if (process.env.NODE_ENV === 'test') { zcashLog('Not running daemon, please run the mock API'); return; From b3c277f7fec4adbee5d99ddbd09df92d47f3906a Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 12:12:14 -0300 Subject: [PATCH 12/18] fix(debug): remove dock from debug-shortcut --- utils/debug-shortcut.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/debug-shortcut.js b/utils/debug-shortcut.js index 35fee02..7b9f378 100644 --- a/utils/debug-shortcut.js +++ b/utils/debug-shortcut.js @@ -4,7 +4,5 @@ import { globalShortcut, typeof BrowserWindow, typeof app as ElectronApp } from 'electron'; export const registerDebugShortcut = (app: ElectronApp, mainWindow: BrowserWindow) => globalShortcut.register('CommandOrControl+Option+B', () => { - // $FlowFixMe - app.dock.show(); mainWindow.webContents.openDevTools(); }); From 955e2d2f1eaa270d4eb6a7a167aad2f6006ab6ea Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 12:14:09 -0300 Subject: [PATCH 13/18] chore(deeplink): export searchUriInArgv --- config/handle-deeplink.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/handle-deeplink.js b/config/handle-deeplink.js index 98c1ce1..d423cf7 100644 --- a/config/handle-deeplink.js +++ b/config/handle-deeplink.js @@ -11,6 +11,11 @@ const sendMessage = (mainWindow, url) => { } }; +export const searchUriInArgv = (argv: string[]): ?string => { + const argIndex = argv.findIndex(item => /zcash:(\/\/)?/.test(item)); + return argv[argIndex]; +}; + export const handleDeeplink = ({ app, mainWindow, @@ -30,7 +35,10 @@ export const handleDeeplink = ({ } if (process.platform === 'win32' || process.platform === 'linux') { - const argIndex = argv.findIndex(item => /zcash:(\/\/)?/.test(item)); - if (argIndex !== -1) sendMessage(mainWindow, argv[argIndex]); + const arg = searchUriInArgv(argv); + + if (arg) { + sendMessage(mainWindow, arg); + } } }; From 7ca7db82d5fbaf7492598451d79820e4258c12ee Mon Sep 17 00:00:00 2001 From: George Lima Date: Fri, 15 Feb 2019 12:15:31 -0300 Subject: [PATCH 14/18] fix(deeplink): redirect to send on startup --- app/components/with-deeplink.js | 47 +++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/app/components/with-deeplink.js b/app/components/with-deeplink.js index 3d5848b..51935d1 100644 --- a/app/components/with-deeplink.js +++ b/app/components/with-deeplink.js @@ -1,27 +1,40 @@ // @flow import React, { type ComponentType, Component } from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies -import { ipcRenderer } from 'electron'; -import { type RouterHistory } from 'react-router-dom'; +import { ipcRenderer, remote } from 'electron'; +import { type RouterHistory, type Location } from 'react-router-dom'; +import { searchUriInArgv } from '../../config/handle-deeplink'; -export const withDeepLink = ( +type PassedProps = { + history: RouterHistory, + location: Location, + isRunning: boolean, +}; + +export const withDeepLink = ( WrappedComponent: ComponentType, ): ComponentType<$Diff> => class extends Component { - timer: ?IntervalID = null; + componentDidMount() { + const arg = searchUriInArgv(remote.process.argv); - componentDidMount() { - const { history } = this.props; + if (arg) this.redirect(arg); - ipcRenderer.on('on-deep-link', (event: Object, message: string) => { - history.replace(`/send/${message.replace(/zcash:(\/\/)?/, '')}`); - }); - } + ipcRenderer.on('on-deep-link', (event: Object, message: string) => { + this.redirect(message); + }); + } - componentWillUnmount() { - ipcRenderer.removeAllListeners('on-deep-link'); - } + componentWillUnmount() { + ipcRenderer.removeAllListeners('on-deep-link'); + } - render() { - return ; - } - }; + redirect(message: string) { + const { history } = this.props; + + history.replace(`/send/${message.replace(/zcash:(\/\/)?/, '')}`); + } + + render() { + return ; + } +}; From cbc92d0cff87dbfaa4314b389dc70c5700e9347b Mon Sep 17 00:00:00 2001 From: georgelima Date: Mon, 18 Feb 2019 20:22:07 -0500 Subject: [PATCH 15/18] fix(deeplink) - fix deeplink on osx startup --- app/components/with-deeplink.js | 10 +++++++++- config/electron.js | 5 +---- config/handle-deeplink.js | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/components/with-deeplink.js b/app/components/with-deeplink.js index 49093a3..4a599ce 100644 --- a/app/components/with-deeplink.js +++ b/app/components/with-deeplink.js @@ -4,6 +4,7 @@ import React, { type ComponentType, Component } from 'react'; import { ipcRenderer, remote } from 'electron'; import { type RouterHistory, type Location } from 'react-router-dom'; import { searchUriInArgv } from '../../config/handle-deeplink'; +import electronStore from "../../config/electron-store" type PassedProps = { history: RouterHistory, @@ -11,11 +12,13 @@ type PassedProps = { isRunning: boolean, }; +const OSX_DEEPLINK_URL_KEY = "OSX_DEEPLINK_URL" + export const withDeepLink = ( WrappedComponent: ComponentType, ): ComponentType<$Diff> => class extends Component { componentDidMount() { - const arg = searchUriInArgv(remote.process.argv); + const arg = searchUriInArgv([...remote.process.argv, electronStore.get(OSX_DEEPLINK_URL_KEY) || ""]); if (arg) this.redirect(arg); @@ -35,6 +38,11 @@ export const withDeepLink = ( redirect(message: string) { const { history } = this.props; + // clean osx deeplink storage + if (electronStore.has(OSX_DEEPLINK_URL_KEY)) { + electronStore.delete(OSX_DEEPLINK_URL_KEY) + } + history.replace(`/send/${message.replace(/zcash:(\/\/)?/, '')}`); } diff --git a/config/electron.js b/config/electron.js index 887aa66..e8cc7b8 100644 --- a/config/electron.js +++ b/config/electron.js @@ -104,10 +104,7 @@ if (instanceLock) { app.quit(); } -app.on('will-finish-launching', () => handleDeeplink({ - app, - mainWindow, -})); +handleDeeplink({ app, mainWindow }) /* eslint-disable-next-line consistent-return */ app.on('ready', async () => { diff --git a/config/handle-deeplink.js b/config/handle-deeplink.js index d423cf7..0572ced 100644 --- a/config/handle-deeplink.js +++ b/config/handle-deeplink.js @@ -1,5 +1,6 @@ // @flow -import { typeof app as ElectronApp, type electron$BrowserWindow } from 'electron'; // eslint-disable-line +import { typeof app as ElectronApp, type electron$BrowserWindow, remote } from 'electron'; // eslint-disable-line +import store from "./electron-store" const sendMessage = (mainWindow, url) => { if (mainWindow) { @@ -30,6 +31,7 @@ export const handleDeeplink = ({ if (listenOpenUrl) { app.on('open-url', (event: Object, url: string) => { event.preventDefault(); + store.set("OSX_DEEPLINK_URL", url) sendMessage(mainWindow, url); }); } From a5d0a511553918ce6228fd16943eaf966205ef5a Mon Sep 17 00:00:00 2001 From: georgelima Date: Mon, 18 Feb 2019 20:24:46 -0500 Subject: [PATCH 16/18] fix(fetch-params) - add mkdir cmd before create zcash.conf --- bin/zcash-fetch-params | 2 ++ public/flow-badge.svg | 2 +- public/flow-coverage-badge.svg | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/zcash-fetch-params b/bin/zcash-fetch-params index 2033cc9..7ddfc0c 100755 --- a/bin/zcash-fetch-params +++ b/bin/zcash-fetch-params @@ -5,10 +5,12 @@ set -eu # Create default zcash.conf if [[ "$OSTYPE" == "darwin"* ]]; then if [ ! -e "$HOME/Library/Application Support/Zcash/zcash.conf" ] ; then + mkdir -p "$HOME/Library/Application Support/Zcash" echo "server=1" > "$HOME/Library/Application Support/Zcash/zcash.conf" fi else if [ ! -e "$HOME/.zcash/zcash.conf" ] ; then + mkdir -p "$HOME/.zcash" echo "server=1" > "$HOME/.zcash/zcash.conf" fi fi diff --git a/public/flow-badge.svg b/public/flow-badge.svg index 037f59b..e8008e1 100644 --- a/public/flow-badge.svg +++ b/public/flow-badge.svg @@ -1 +1 @@ -flowflowpassingpassing \ No newline at end of file +flowflowfailingfailing \ No newline at end of file diff --git a/public/flow-coverage-badge.svg b/public/flow-coverage-badge.svg index cb8221e..f5dabfe 100644 --- a/public/flow-coverage-badge.svg +++ b/public/flow-coverage-badge.svg @@ -1 +1 @@ -flow-coverageflow-coverage90%90% \ No newline at end of file +flow-coverageflow-coverage89%89% \ No newline at end of file From d67b1f7a6598bd649c02fab0b8b1d31de2a67b4b Mon Sep 17 00:00:00 2001 From: George Lima Date: Mon, 18 Feb 2019 22:56:40 -0300 Subject: [PATCH 17/18] lint(deeplink): clean up and lint files --- app/components/loading-screen.js | 2 +- app/components/with-deeplink.js | 11 +++++++---- config/electron.js | 2 +- config/handle-deeplink.js | 5 +++-- package.json | 2 +- public/flow-badge.svg | 2 +- public/flow-coverage-badge.svg | 2 +- yarn.lock | 7 ++++--- 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/components/loading-screen.js b/app/components/loading-screen.js index a6863cc..1407975 100644 --- a/app/components/loading-screen.js +++ b/app/components/loading-screen.js @@ -48,7 +48,7 @@ type State = { const TIME_DELAY_ANIM = 100; export class Component extends PureComponent { - state = { start: false, message: 'ZEC Wallet Starting' }; + state = { start: false }; componentDidMount() { setTimeout(() => { diff --git a/app/components/with-deeplink.js b/app/components/with-deeplink.js index 4a599ce..b191e9b 100644 --- a/app/components/with-deeplink.js +++ b/app/components/with-deeplink.js @@ -4,7 +4,7 @@ import React, { type ComponentType, Component } from 'react'; import { ipcRenderer, remote } from 'electron'; import { type RouterHistory, type Location } from 'react-router-dom'; import { searchUriInArgv } from '../../config/handle-deeplink'; -import electronStore from "../../config/electron-store" +import electronStore from '../../config/electron-store'; type PassedProps = { history: RouterHistory, @@ -12,13 +12,16 @@ type PassedProps = { isRunning: boolean, }; -const OSX_DEEPLINK_URL_KEY = "OSX_DEEPLINK_URL" +const OSX_DEEPLINK_URL_KEY = 'OSX_DEEPLINK_URL'; export const withDeepLink = ( WrappedComponent: ComponentType, ): ComponentType<$Diff> => class extends Component { componentDidMount() { - const arg = searchUriInArgv([...remote.process.argv, electronStore.get(OSX_DEEPLINK_URL_KEY) || ""]); + const arg = searchUriInArgv([ + ...remote.process.argv, + electronStore.get(OSX_DEEPLINK_URL_KEY) || '', + ]); if (arg) this.redirect(arg); @@ -40,7 +43,7 @@ export const withDeepLink = ( // clean osx deeplink storage if (electronStore.has(OSX_DEEPLINK_URL_KEY)) { - electronStore.delete(OSX_DEEPLINK_URL_KEY) + electronStore.delete(OSX_DEEPLINK_URL_KEY); } history.replace(`/send/${message.replace(/zcash:(\/\/)?/, '')}`); diff --git a/config/electron.js b/config/electron.js index e8cc7b8..6dca7c2 100644 --- a/config/electron.js +++ b/config/electron.js @@ -104,7 +104,7 @@ if (instanceLock) { app.quit(); } -handleDeeplink({ app, mainWindow }) +handleDeeplink({ app, mainWindow }); /* eslint-disable-next-line consistent-return */ app.on('ready', async () => { diff --git a/config/handle-deeplink.js b/config/handle-deeplink.js index 0572ced..06f0f3e 100644 --- a/config/handle-deeplink.js +++ b/config/handle-deeplink.js @@ -1,6 +1,6 @@ // @flow import { typeof app as ElectronApp, type electron$BrowserWindow, remote } from 'electron'; // eslint-disable-line -import store from "./electron-store" +import store from './electron-store'; const sendMessage = (mainWindow, url) => { if (mainWindow) { @@ -31,7 +31,8 @@ export const handleDeeplink = ({ if (listenOpenUrl) { app.on('open-url', (event: Object, url: string) => { event.preventDefault(); - store.set("OSX_DEEPLINK_URL", url) + // Save the url on electron-store, so we can get the value on withDeeplink HOC + store.set('OSX_DEEPLINK_URL', url); sendMessage(mainWindow, url); }); } diff --git a/package.json b/package.json index e34d76a..46e2b30 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.12.4", "file-loader": "^2.0.0", - "flow-bin": "^0.92.1", + "flow-bin": "^0.93.0", "flow-coverage-report": "^0.6.1", "flow-typed": "^2.5.1", "glow": "^1.2.2", diff --git a/public/flow-badge.svg b/public/flow-badge.svg index e8008e1..037f59b 100644 --- a/public/flow-badge.svg +++ b/public/flow-badge.svg @@ -1 +1 @@ -flowflowfailingfailing \ No newline at end of file +flowflowpassingpassing \ No newline at end of file diff --git a/public/flow-coverage-badge.svg b/public/flow-coverage-badge.svg index f5dabfe..b36be62 100644 --- a/public/flow-coverage-badge.svg +++ b/public/flow-coverage-badge.svg @@ -1 +1 @@ -flow-coverageflow-coverage89%89% \ No newline at end of file +flow-coverageflow-coverage88%88% \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index afaffc2..9e80b68 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6408,9 +6408,10 @@ flow-annotation-check@1.8.1: glob "7.1.1" load-pkg "^3.0.1" -flow-bin@^0.92.1: - version "0.92.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.92.1.tgz#32c136c07235f30c42dc0549a0790f370fad4070" +flow-bin@^0.93.0: + version "0.93.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.93.0.tgz#9192a08d88db2a8da0ff55e42420f44539791430" + integrity sha512-p8yq4ocOlpyJgOEBEj0v0GzCP25c9WP0ilFQ8hXSbrTR7RPKuR+Whr+OitlVyp8ocdX0j1MrIwQ8x28dacy1pg== flow-coverage-report@^0.6.1: version "0.6.1" From 950b8b3bfb23f884b0938505c17b4251812936f7 Mon Sep 17 00:00:00 2001 From: George Lima Date: Tue, 19 Feb 2019 11:36:00 -0300 Subject: [PATCH 18/18] test(send): fix match --- __tests__/e2e/send.test.js | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/__tests__/e2e/send.test.js b/__tests__/e2e/send.test.js index 53ea662..108d00b 100644 --- a/__tests__/e2e/send.test.js +++ b/__tests__/e2e/send.test.js @@ -15,23 +15,25 @@ afterEach(() => app.stop()); describe('Send', () => { test('should load "Send Page"', async () => { - expect(app.client.element('#send-wrapper') - .isVisible()).resolves.toEqual(true); + expect(app.client.element('#send-wrapper').isVisible()).resolves.toEqual(true); }); test('should show Additional Options click', async () => { - expect(app.client.element('#send-wrapper #send-fee-wrapper') - .isVisible()).resolves.toEqual(false); + expect(app.client.element('#send-wrapper #send-fee-wrapper').isVisible()).resolves.toEqual( + false, + ); await app.client.element('#send-show-additional-options-button').click(); - expect(app.client.element('#send-wrapper #send-fee-wrapper') - .isVisible()).resolves.toEqual(true); + expect(app.client.element('#send-wrapper #send-fee-wrapper').isVisible()).resolves.toEqual( + true, + ); }); test('should disable send button if required fields are empty', async () => { - expect(app.client.element('#send-submit-button') - .getAttribute('disabled')).resolves.toEqual(true); + expect(app.client.element('#send-submit-button').getAttribute('disabled')).resolves.toEqual( + true, + ); }); test('should enable send button if required fields are filled', async () => { @@ -68,8 +70,9 @@ describe('Send', () => { await app.client.element('#send-submit-button').click(); - expect(app.client.element('#send-confirm-transaction-modal') - .isVisible()).resolves.toEqual(true); + expect(app.client.element('#send-confirm-transaction-modal').isVisible()).resolves.toEqual( + true, + ); }); test('should display a load indicator while the transaction is processed', async () => { @@ -91,15 +94,14 @@ describe('Send', () => { expect(app.client.getAttribute('#send-confirm-transaction-modal img', 'src')).resolves.toEqual( expect.stringContaining('/assets/sync_icon.png'), ); - expect(app.client.getText('#send-confirm-transaction-modal p')) - .resolves.toEqual('Processing transaction...'); - expect(app.client.element('#confirm-modal-button') - .isVisible()).resolves.toEqual(false); + expect(app.client.getText('#send-confirm-transaction-modal p')).resolves.toEqual( + 'Processing transaction...', + ); + expect(app.client.element('#confirm-modal-button').isVisible()).resolves.toEqual(false); }); test('should show an error in invalid transaction', async () => { - expect(app.client.element('#send-error-text') - .isVisible()).resolves.toEqual(false); + expect(app.client.element('#send-error-text').isVisible()).resolves.toEqual(false); await app.client.element('#sidebar a:nth-child(1)').click(); await app.client.element('#sidebar a:nth-child(2)').click(); @@ -124,8 +126,7 @@ describe('Send', () => { }); test('should show a success screen after transaction and show a transaction item', async () => { - expect(app.client.element('#send-success-wrapper') - .isVisible()).resolves.toEqual(false); + expect(app.client.element('#send-success-wrapper').isVisible()).resolves.toEqual(false); await app.client.element('#sidebar a:nth-child(1)').click(); await app.client.element('#sidebar a:nth-child(2)').click(); @@ -149,10 +150,11 @@ describe('Send', () => { await app.client.waitUntilTextExists('#transaction-item-operation-id-1', 'Send'); - expect(await app.client.element('#transaction-item-operation-id-1 img') - .isVisible()).toEqual(true); + expect(await app.client.element('#transaction-item-operation-id-1 img').isVisible()).toEqual( + true, + ); expect( await app.client.element('#transaction-item-operation-id-1 img').getAttribute('src'), - ).toEndWith('/assets/transaction_sent_icon.svg'); + ).toEndWith('/assets/transaction_sent_icon_dark.svg'); }); });