Merge pull request #105 from andrerfneves/bugfix/daemon-mode-startup
Bugfix/daemon mode startup
This commit is contained in:
commit
0ba7968892
|
@ -1,10 +1,12 @@
|
|||
# Zepio | ZEC Wallet
|
||||
|
||||
Zepio is a modern cross-platform full-node desktop wallet for the Zcash Network.
|
||||
Zepio is a Sapling-enabled shielded-address first Zcash wallet, featuring cross-platform applications (macOS, Windows and Linux), built-in full node with support for `mainnet` and `testnet`, as well as `dark` and `light` themes.
|
||||
|
||||
[![Build Status](https://app.bitrise.io/app/e3e2de9d817688f9/status.svg?token=JsSLjbxa6yt6-oy5MgU9uQ)](https://app.bitrise.io/app/e3e2de9d817688f9)
|
||||
![Flow Coverage](./public/flow-coverage-badge.svg)
|
||||
|
||||
### [Latest Documentation at https://zepiowallet.com](https://zepiowallet.com)
|
||||
|
||||
|
||||
## Stack Information
|
||||
|
||||
- [Electron](https://github.com/electron/electron): desktop application builder
|
||||
|
|
|
@ -181,11 +181,11 @@ class Component extends PureComponent<Props, State> {
|
|||
|
||||
switch (nodeSyncType) {
|
||||
case 'syncing':
|
||||
return "Syncing blockchain data. You may not send funds or see latest transactions until it's synced 100%";
|
||||
return 'Syncing blockchain data. You may not send funds or see latest transactions until it\'s synced.';
|
||||
case 'ready':
|
||||
return 'Your chain data is up to date';
|
||||
return 'Your node is synced.';
|
||||
case 'error':
|
||||
return 'There was an error. Try restarting Zepio';
|
||||
return 'There was an error. Try restarting Zepio.';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import isDev from 'electron-is-dev';
|
||||
import { isTestnet } from '../../config/is-testnet';
|
||||
|
||||
export const ZCASH_EXPLORER_BASE_URL = isDev
|
||||
export const ZCASH_EXPLORER_BASE_URL = isTestnet()
|
||||
? 'https://chain.so/tx/ZECTEST/'
|
||||
: 'https://zcha.in/transactions/';
|
||||
|
|
|
@ -72,9 +72,7 @@ class Component extends PureComponent<Props, State> {
|
|||
|
||||
componentDidMount() {
|
||||
ipcRenderer.on('zcashd-log', (event: empty, message: string) => {
|
||||
if (message.indexOf('Downloading') !== -1) {
|
||||
this.setState(() => ({ log: initialLog + message }));
|
||||
}
|
||||
this.setState(() => ({ log: initialLog + message }));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @flow
|
||||
/* eslint-disable no-unused-vars */
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
@ -248,7 +249,7 @@ export class SettingsView extends PureComponent<Props, State> {
|
|||
|
||||
const zAddresses = addresses.filter(({ address }) => address.startsWith('z'));
|
||||
|
||||
this.setState({ isLoading: true });
|
||||
this.setState(() => ({ isLoading: true }));
|
||||
|
||||
Promise.all(
|
||||
zAddresses.map(async ({ address }) => {
|
||||
|
@ -256,18 +257,18 @@ export class SettingsView extends PureComponent<Props, State> {
|
|||
return { zAddress: address, key: viewKey };
|
||||
}),
|
||||
).then((viewKeys) => {
|
||||
this.setState({
|
||||
this.setState(() => ({
|
||||
viewKeys,
|
||||
successExportViewKeys: true,
|
||||
isLoading: false,
|
||||
});
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
exportPrivateKeys = () => {
|
||||
const { addresses } = this.props;
|
||||
|
||||
this.setState({ isLoading: true });
|
||||
this.setState(() => ({ isLoading: true }));
|
||||
|
||||
Promise.all(
|
||||
addresses.map(async ({ address }) => {
|
||||
|
@ -278,13 +279,16 @@ export class SettingsView extends PureComponent<Props, State> {
|
|||
}),
|
||||
)
|
||||
.then((privateKeys) => {
|
||||
this.setState({
|
||||
this.setState(() => ({
|
||||
privateKeys,
|
||||
successExportPrivateKeys: true,
|
||||
isLoading: false,
|
||||
});
|
||||
}));
|
||||
})
|
||||
.catch(error => this.setState({ isLoading: false, error: error.message }));
|
||||
.catch((error) => {
|
||||
console.log({ error });
|
||||
this.setState(() => ({ isLoading: false, error: error.message }));
|
||||
});
|
||||
};
|
||||
|
||||
importPrivateKeys = () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ export default (processName: string): Promise<void> => new Promise((resolve) =>
|
|||
|
||||
if (!isRunning) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
setTimeout(resolve, 1000);
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
|
|
@ -46,7 +46,6 @@ const getDaemonOptions = ({
|
|||
|
||||
const defaultOptions = [
|
||||
'-server=1',
|
||||
'-rest=1',
|
||||
'-showmetrics',
|
||||
'--metricsui=0',
|
||||
'-metricsrefreshtime=1',
|
||||
|
@ -69,6 +68,7 @@ const ZCASHD_PROCESS_NAME = getDaemonName();
|
|||
// eslint-disable-next-line
|
||||
const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve, reject) => {
|
||||
const processName = path.join(getBinariesPath(), getOsFolder(), ZCASHD_PROCESS_NAME);
|
||||
const isRelaunch = Boolean(process.argv.find(arg => arg === '--relaunch'));
|
||||
|
||||
if (!mainWindow.isDestroyed()) mainWindow.webContents.send('zcashd-params-download', 'Fetching params...');
|
||||
|
||||
|
@ -86,7 +86,7 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
|
|||
|
||||
// In case of --relaunch on argv, we need wait to close the old zcash daemon
|
||||
// a workaround is use a interval to check if there is a old process running
|
||||
if (process.argv.find(arg => arg === '--relaunch')) {
|
||||
if (isRelaunch) {
|
||||
await waitForDaemonClose(ZCASHD_PROCESS_NAME);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,9 @@ const runDaemon: () => Promise<?ChildProcess> = () => new Promise(async (resolve
|
|||
|
||||
store.set(EMBEDDED_DAEMON, true);
|
||||
|
||||
store.set(ZCASH_NETWORK, optionsFromZcashConf.testnet === '1' ? TESTNET : MAINNET);
|
||||
if (!isRelaunch) {
|
||||
store.set(ZCASH_NETWORK, optionsFromZcashConf.testnet === '1' ? TESTNET : MAINNET);
|
||||
}
|
||||
|
||||
if (!optionsFromZcashConf.rpcuser) store.set('rpcuser', uuid());
|
||||
if (!optionsFromZcashConf.rpcpassword) store.set('rpcpassword', uuid());
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
/* eslint-disable */
|
||||
import { css } from 'docz-plugin-css';
|
||||
|
||||
export default {
|
||||
title: 'Zcash Foundation',
|
||||
description: 'Zcash Foundation User Interface Styleguide',
|
||||
title: 'Zepio',
|
||||
description: 'Zepio Component Styleguide',
|
||||
plugins: [css()],
|
||||
htmlContext: {
|
||||
head: {
|
||||
|
|
|
@ -6,17 +6,11 @@ import { METHODS, type APIMethods } from './utils';
|
|||
import store from '../config/electron-store';
|
||||
import { isTestnet } from '../config/is-testnet';
|
||||
|
||||
const RPC = {
|
||||
const getRPCConfig = () => ({
|
||||
host: '127.0.0.1',
|
||||
port: isTestnet() ? 18232 : 8232,
|
||||
user: store.get('rpcuser'),
|
||||
password: store.get('rpcpassword'),
|
||||
};
|
||||
|
||||
const client = got.extend({
|
||||
method: 'POST',
|
||||
json: true,
|
||||
auth: `${RPC.user}:${RPC.password}`,
|
||||
});
|
||||
|
||||
const getMessage = (statusCode) => {
|
||||
|
@ -31,21 +25,29 @@ const getMessage = (statusCode) => {
|
|||
const api: APIMethods = METHODS.reduce(
|
||||
(obj, method) => ({
|
||||
...obj,
|
||||
[method]: (...args) => client
|
||||
.post(`http://${RPC.host}:${RPC.port}`, {
|
||||
body: {
|
||||
method,
|
||||
jsonrpc: '2.0',
|
||||
id: Date.now(),
|
||||
params: args,
|
||||
},
|
||||
})
|
||||
.then(data => Promise.resolve(data.body && data.body.result))
|
||||
// eslint-disable-next-line
|
||||
.catch(payload => Promise.reject({
|
||||
message: payload.body?.error?.message || getMessage(payload.statusCode),
|
||||
statusCode: payload.statusCode,
|
||||
})),
|
||||
[method]: (...args) => {
|
||||
const RPC = getRPCConfig();
|
||||
return (
|
||||
got
|
||||
.post(`http://${RPC.host}:${RPC.port}`, {
|
||||
method: 'POST',
|
||||
json: true,
|
||||
auth: `${RPC.user}:${RPC.password}`,
|
||||
body: {
|
||||
method,
|
||||
jsonrpc: '2.0',
|
||||
id: Date.now(),
|
||||
params: args,
|
||||
},
|
||||
})
|
||||
.then(data => Promise.resolve(data.body && data.body.result))
|
||||
// eslint-disable-next-line
|
||||
.catch(payload => Promise.reject({
|
||||
message: payload.body?.error?.message || getMessage(payload.statusCode),
|
||||
statusCode: payload.statusCode,
|
||||
}))
|
||||
);
|
||||
},
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue