Commit f2ab799b authored by Luke Schoen's avatar Luke Schoen
Browse files

merge latest from master and fix merge conflict

parent 6fd7db61
Pipeline #35034 passed with stage
in 2 minutes
......@@ -20,3 +20,7 @@ lib
# os-generated files
.DS_Store
# parity binary
packages/fether-electron/static/parity
packages/fether-electron/static/parity.exe
\ No newline at end of file
BSD 3-Clause License
Copyright (c) 2015-2018 Parity Technologies (UK) Ltd.
Copyright (c) 2015-2019 Parity Technologies (UK) Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -17,7 +17,9 @@ Parity Fether connects to the light node using [`@parity/light.js`](https://gith
Parity Fether is licensed under the BSD 3-Clause, and can be used for all your Ethereum needs.
If you run into problems while using Parity Fether, feel free to file an issue in this repository or hop on our [Gitter](https://gitter.im/paritytech/fether) or [Riot](https://riot.im/app/#/group/+parity:matrix.parity.io) chat room to ask a question. We are glad to help! **For security-critical issues**, please refer to the security policy outlined in [SECURITY.md](https://github.com/paritytech/parity/blob/master/SECURITY.md).
If you run into problems while using Parity Fether, first check out the [FAQ](https://wiki.parity.io/Fether-FAQ) on our wiki and feel free to file an issue in this repository or hop on our [Gitter](https://gitter.im/paritytech/fether) or [Riot](https://riot.im/app/#/group/+parity:matrix.parity.io) chat rooms if you have any question. We are glad to help!
**For security-critical issues**, please refer to the security policy outlined in [SECURITY.md](https://github.com/paritytech/parity/blob/master/SECURITY.md).
---
......@@ -25,9 +27,27 @@ If you run into problems while using Parity Fether, feel free to file an issue i
![Parity Fether](https://wiki.parity.io/images/fether-screenshot-0.jpg)
## Install and start Parity Fether
## Join the chat!
Get in touch with us on Gitter:
[![Gitter](https://img.shields.io/badge/Gitter-Fether-brightgreen.svg)](https://gitter.im/paritytech/fether)
Official website: https://parity.io | Be sure to check out [our Wiki](https://wiki.parity.io) for more information.
## Install and start Parity Fether using binaries
### Mac
- Download the [`.dmg` file](https://github.com/paritytech/fether/releases).
- Double click on it to install Fether.
### Windows
- Download the [`.exe` file](https://github.com/paritytech/fether/releases).
- Double click on it to install Fether.
- Fether will be added to the program menu.
### Linux
#### Using the AppImage (any distro)
- Download the [`.AppImage` file](https://github.com/paritytech/fether/releases).
- Make it executable `chmod +x /path/to/fether-x.x.x-x86_64.AppImage`.
......@@ -42,49 +62,45 @@ If you run into problems while using Parity Fether, feel free to file an issue i
- Download the [`.deb` file](https://github.com/paritytech/fether/releases).
- Double click on the file to install Fether.
- Fether will be added to the program menu.
### Mac
- Download the [`.dmg` file](https://github.com/paritytech/fether/releases).
- Double click on it to install Fether.
### Windows
- Download the [`.exe` file](https://github.com/paritytech/fether/releases).
- Double click on it to install Fether.
- Fether will be added to the program menu.
### Passing config flags to the underlying Parity Ethereum node
You can pass specific flags for fether to launch the underlying Parity Ethereum with:
```bash
# Launching Parity Ethereum light client on Ropsten instead of Kovan (default) and connect Fether to it
$ /path/to/fether --chain ropsten --light
```
### Separately launch Parity Ethereum node
## Build from sources
You can also launch Parity Ethereum node before, with any flag you want:
### Install dependencies
```bash
# Launching Parity Ethereum light client on Ropsten instead of Kovan (default)
$ parity --chain ropsten --light
```
#### Mac
In another console launch Fether:
Install Xcode Command Line Tools, NVM, Node.js latest LTS, Yarn, and Git
```bash
# Fether will connect to the running node
$ /path/to/fether
xcode-select --install;
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash;
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
echo -e "Installing Node.js latest LTS version";
nvm install --lts
echo -e "Switching to use Node.js latest LTS version";
nvm use --lts;
brew install yarn --without-node;
brew install git --verbose;
brew upgrade git --verbose;
```
## Build from sources
### Dependencies
#### Linux and Windows (Git Bash)
Make sure you have at least `yarn` version 1.4.2 and [Node.js >=10.10.0](https://nodejs.org/en/)
Install Node.js 10.x, Yarn, Git, and increase amount of inotify watchers
```bash
yarn --version // Should be at least 1.4.2
sudo apt update;
sudo apt install -y git nodejs npm curl;
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -;
apt-get install -y nodejs;
sudo ln -s /usr/bin/nodejs /usr/bin/node;
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -;
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list;
sudo apt-get update && sudo apt-get install yarn;
sudo ln -s /usr/bin/yarn /usr/local/bin/yarn;
yarn global add windows-build-tools;
```
### Clone this repo
......@@ -95,81 +111,71 @@ cd ./fether
yarn install
```
### Build this repo and run
### Build and run
#### Build this repo and run
```bash
yarn electron
```
### Build binaries
#### Build binaries
```bash
yarn package
```
### Run with live reload for development
#### Run with live reload for development
```bash
yarn start
```
> Troubleshooting: If it hangs on a white screen in Electron even though it has compiled and has been syncing for a long time, then simply choose 'View > Reload' (CMD + R on macOS) from the Fether/Electron menu. If the Fether menu is not shown in the tray, then by clicking the Fether window and then holding down the ALT key to reveal it.
## Build binaries for production
> Developer Tools: Open developer tools automatically by running `DEBUG=true yarn start` when not in the production environment
### General Notes:
# Run without taskbar mode (no tray icon)
1) Alternative to `yarn; yarn build; DEBUG=electron-builder yarn release --mac;` is to just run `yarn package` and then run the `open "./packages/fether-electron/dist/mac/Parity Fether.app"` (i.e. no need to install)
```bash
TASKBAR=false yarn start
```
# Usage of taskbar mode
2) Publishing a new release to GitHub is performed by a maintainer of the repository. In this case you need to obtain the `GH_TOKEN` from GitHub settings and add it using `export GH_TOKEN="..."` to ~/.bashrc and then run `source ~/.bashrc`. If you get an error that the `GH_TOKEN` is missing and you are only building the binary but not publishing, then just ignore the error.
### macOS
### Mac
Taskbar mode is `true` by default.
Build and run binaries (i.e. .dmg) for production on Mac of a specific remote branch
* Enabled `true`
* Fether window may be toggled open/closed by clicking the Fether tray icon, but not the Fether dock icon
* Fether window does not have a frame (i.e. no close/minimise icons)
* Disabled `false`
* Fether window may be toggled open by clicking the Fether dock icon
* Fether window has a frame (with close/minimise icons)
* Always
* Fether menu shown in the tray by default
* Fether window position is saved upon move, minimising, and close so it is restored in the same position.
```bash
git fetch origin INSERT_BRANCH_NAME:INSERT_BRANCH_NAME;
git checkout INSERT_BRANCH_NAME;
rm -rf ./packages/fether-electron/dist/
rm -rf /Applications/Parity\ Fether.app/
yarn; yarn build; DEBUG=electron-builder yarn release --mac;
open ./packages/fether-electron/dist/Parity\ Fether-0.3.0.dmg
```
### Linux
Taskbar mode is `true` by default.
Build and run binaries (i.e. .deb) for production on Linux
* Enabled `true`
* Fether window may be toggled minimise/restore by clicking the Fether tray icon to reveal a tooltip that says "Click to toggle Fether window" and then clicking the tooltip.
* Fether window may not have a frame (i.e. no close/minimise icons) if `frame: false` in packages/fether-electron/src/main/app/options/config/index.js
* Disabled `false`
* Fether window may be toggled open by clicking the Fether dock icon
* Fether window has a frame (with close/minimise icons)
* Always
* Fether menu may not be not shown in the tray by default depending on whether `setMenuBarVisibility` has been set. Show the Fether menu in the tray by clicking the Fether window and then holding down the ALT key to reveal it.
* Fether menu may be configured to automatically hide by setting `setAutoHideMenuBar`
* Fether window position is saved upon move, minimising, and close so it is restored in the same position.
### Windows
> Note: If you want to save time building, then first edit electron-builder.json so that it only builds a single binary like .deb instead of all of them
Taskbar mode is always `false` since the Fether menu does not appear without a frame on the Fether window.
* Disabled `false`
* Fether window may be toggled open/minimise by clicking the Fether dock icon
* Fether window has a frame (with close/minimise icons).
* Always
* Fether menu is shown in the Fether window by clicking the Fether window and then holding down the ALT key to reveal it.
* Fether menu may be configured to automatically hide by setting `setAutoHideMenuBar`
* Fether tray icon does nothing
* Fether window position is saved upon move, minimising, and close so it is restored in the same position.
```bash
sudo rm -rf /opt/Parity\ Fether;
rm -rf ~/.config/Electron;
rm -rf ~/.config/fether;
rm -rf ./packages/fether-electron/dist/;
sudo rm /usr/local/bin/fether;
sudo apt remove -y fether;
yarn; yarn build; DEBUG=electron-builder yarn release --linux
sudo apt install -y ./packages/fether-electron/dist/fether_0.3.0_amd64.deb
fether
```
## Join the chat!
### Windows
Get in touch with us on Gitter:
[![Gitter](https://img.shields.io/badge/Gitter-Fether-brightgreen.svg)](https://gitter.im/paritytech/fether)
Build and run binaries (i.e. .exe) binary for production on Windows
Official website: https://parity.io | Be sure to check out [our Wiki](https://wiki.parity.io) for more information.
```bash
rm -rf /packages/fether-electron/dist;
yarn; yarn build; DEBUG=electron-builder yarn release --win;
./packages/fether-electron/dist/Parity\ Fether-0.3.0.exe
```
......@@ -40,11 +40,12 @@
"yarn": "^1.4.2"
},
"scripts": {
"postinstall": "cd scripts && node ./fetch-latest-parity.js",
"build": "lerna run build",
"preelectron": "yarn build",
"electron": "cd packages/fether-electron && yarn electron",
"lint-files": "./scripts/lint-files.sh",
"lint": "yarn lint-files '**/*.{js,ts}'",
"lint-files": "./scripts/lint-files.sh '**/*.js'",
"lint": "yarn lint-files",
"prepackage": "yarn build",
"package": "cd packages/fether-electron && yarn package",
"release": "cd packages/fether-electron && yarn release",
......@@ -52,7 +53,8 @@
"start-electron": "cd packages/fether-electron && yarn start",
"start-react": "cd packages/fether-react && yarn start",
"start-ui": "cd packages/fether-ui && yarn start",
"test": "semistandard '**/*.{js,ts}' --parser babel-eslint && CI=true lerna run test --parallel"
"test": "semistandard '**/*.js' --parser babel-eslint && CI=true lerna run test --parallel",
"update-tokens": "yarn run ts-node --project scripts/updateTokens/tsconfig.json scripts/updateTokens"
},
"husky": {
"hooks": {
......@@ -66,5 +68,12 @@
"npm-run-all": "^4.1.2",
"prettier": "^1.14.2",
"semistandard": "^13.0.1"
},
"dependencies": {
"download": "^7.1.0",
"node-fetch": "^2.3.0",
"semver": "^5.6.0",
"ts-node": "^8.0.3",
"typescript": "^3.3.4000"
}
}
}
\ No newline at end of file
{
"appId": "io.parity.fether",
"copyright": "Copyright 2015-2018 Parity Technologies (UK) Ltd.",
"copyright": "Copyright 2015-2019 Parity Technologies (UK) Ltd.",
"linux": {
"category": "Utility",
"target": ["AppImage", "snap", "deb", "tar.xz"]
......
......@@ -25,7 +25,7 @@
],
"homepage": "https://github.com/paritytech/fether",
"parity": {
"channel": "stable"
"version": "~2.4.1"
},
"scripts": {
"prebuild": "copyfiles -u 2 \"../fether-react/build/**/*\" static/ && ./scripts/fixElectronBug.sh",
......@@ -39,7 +39,7 @@
"test": "jest --all --color --coverage"
},
"dependencies": {
"@parity/electron": "^4.0.0",
"@parity/electron": "^5.1.0",
"ansi-styles": "^3.2.1",
"commander": "^2.15.1",
"commander-remaining-args": "^1.2.0",
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import electron from 'electron';
import { getContextMenuTemplate } from '../template';
import { getContextTrayMenuTemplate } from '../template';
const { Menu } = electron;
let hasCalledInitMenu = false;
class FetherContextMenu {
class FetherContextTrayMenu {
constructor (fetherApp) {
if (hasCalledInitMenu) {
throw new Error(
'Unable to initialise Fether context menu more than once'
'Unable to initialise Fether context tray menu more than once'
);
}
this.setMenuTemplate(getContextMenuTemplate(fetherApp));
this.setMenuTemplate(getContextTrayMenuTemplate(fetherApp));
this.buildMenuTemplate(this.menuTemplate);
}
......@@ -36,4 +36,4 @@ class FetherContextMenu {
};
}
export default FetherContextMenu;
export default FetherContextTrayMenu;
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import electron from 'electron';
import { getContextWindowMenuTemplate } from '../template';
const { Menu } = electron;
let hasCalledInitMenu = false;
class FetherContextWindowMenu {
constructor (fetherApp) {
if (hasCalledInitMenu) {
throw new Error(
'Unable to initialise Fether context window menu more than once'
);
}
this.setMenuTemplate(getContextWindowMenuTemplate(fetherApp));
this.buildMenuTemplate(this.menuTemplate);
}
setMenuTemplate = menuTemplate => {
this.menuTemplate = menuTemplate;
};
buildMenuTemplate = menuTemplate => {
this.builtMenu = Menu.buildFromTemplate(menuTemplate);
};
getMenu = () => {
return this.builtMenu;
};
}
export default FetherContextWindowMenu;
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import FetherMenubarMenu from './menubar';
import FetherContextMenu from './context';
import FetherContextTrayMenu from './contextTray';
import FetherContextWindowMenu from './contextWindow';
export { FetherMenubarMenu, FetherContextMenu };
export { FetherMenubarMenu, FetherContextTrayMenu, FetherContextWindowMenu };
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......@@ -48,6 +48,23 @@ const getMenubarMenuTemplate = fetherApp => {
submenu: [{ role: 'quit' }]
};
/* eslint-disable no-sparse-arrays */
const editTabMacOS = {
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },,
{ role: 'copy' },
{ role: 'paste' },
{ type: 'separator' },
{ role: 'delete' },
{ role: 'selectall' }
]
};
/* eslint-enable no-sparse-arrays */
/**
* On win32 we need to use `webContents` to make some of the menu items
* functional (whereas it is not required on Linux and macOS).
......@@ -115,9 +132,9 @@ const getMenubarMenuTemplate = fetherApp => {
]
};
let template = [
const template = [
fileTab,
editTab,
process.platform === 'darwin' ? editTabMacOS : editTab,
process.platform === 'win32' ? viewTabWindowsOS : viewTab,
windowTab,
helpTab
......@@ -198,8 +215,37 @@ const isChecked = fetherApp => {
return isLaunchOnStartup;
};
const getContextMenuTemplate = fetherApp => {
let template = getMenubarMenuTemplate(fetherApp);
const getContextTrayMenuTemplate = fetherApp => {
if (fetherApp.options.withTaskbar) {
const template = [
{
label: 'Show/Hide Fether',
click () {
if (fetherApp.win.isVisible() && fetherApp.win.isFocused()) {
fetherApp.win.hide();
} else {
fetherApp.win.show();
fetherApp.win.focus();
}
}
}
];
if (process.env.NODE_ENV !== 'production') {
template.push({
label: 'Reload',
click: () => fetherApp.win.webContents.reload()
});
}
template.push({ label: 'Quit', role: 'quit' });
return template;
}
};
const getContextWindowMenuTemplate = fetherApp => {
const template = getMenubarMenuTemplate(fetherApp);
// Set the checkbox value off in the context menu on first launch
let isFirstLaunch = settings.has('launch-on-startup');
......@@ -243,17 +289,17 @@ const getContextMenuTemplate = fetherApp => {
isFirstLaunch = undefined;
if (fetherApp.options.withTaskbar) {
// Remove File and Help menus in taskbar mode for context menu
// Remove File and Help menus in taskbar mode for window context menu
template.shift();
template.pop();
template.push({
label: 'Preferences',
submenu: [menuItemLaunchOnStartup]
});
template.push({
role: 'help',
submenu: [
{ role: 'about' },
{
label: 'Learn More',
click () {
......@@ -262,11 +308,21 @@ const getContextMenuTemplate = fetherApp => {
}
]
});
template.push({ type: 'separator' });
if (process.platform === 'darwin') {
template[2].submenu.push({ role: 'about' });
}
template.push({ label: 'Quit', role: 'quit' });
}
return template;
};
export { getMenubarMenuTemplate, getContextMenuTemplate };
export {
getContextTrayMenuTemplate,
getContextWindowMenuTemplate,
getMenubarMenuTemplate
};
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......@@ -6,6 +6,7 @@
import { checkClockSync, signerNewToken } from '@parity/electron';
import Pino from '../utils/pino';
import { bundledParityPath } from '../utils/paths';
const pino = Pino();
......@@ -18,22 +19,11 @@ export default async (fetherApp, event, action, ...args) => {
return;
}
switch (action) {
case 'app-resize': {
if (!fetherApp.win || !args[0]) {
return;
}
const [width] = fetherApp.win.getContentSize();
// Conversion to integer is required to pass as argument to setContentSize.
// Reference: https://electronjs.org/docs/all#winsetcontentsizewidth-height-animate
const newHeight = parseInt(args[0]);
fetherApp.win.setContentSize(width, Math.round(newHeight) + 2);
break;
}
case 'app-right-click': {
if (!fetherApp.win) {
return;
}
fetherApp.contextMenu.getMenu().popup({ window: fetherApp.win });
fetherApp.contextWindowMenu.getMenu().popup({ window: fetherApp.win });
break;
}
case 'check-clock-sync': {
......@@ -43,7 +33,7 @@ export default async (fetherApp, event, action, ...args) => {
break;
}
case 'signer-new-token': {
const token = await signerNewToken();
const token = await signerNewToken({ parityPath: bundledParityPath });
// Send back the token to the renderer process
event.sender.send('signer-new-token-reply', token);
break;
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.