Skip to content

Commit

Permalink
Merge pull request #18 from consensus-ai/development
Browse files Browse the repository at this point in the history
Merge development into master - v1.0.3
  • Loading branch information
AlexanderBelonogov authored Feb 28, 2019
2 parents 011f947 + d22cdd7 commit 8ccda91
Show file tree
Hide file tree
Showing 46 changed files with 2,489 additions and 262 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated Items
release
tools
node_modules
npm-debug.log
config.json
Expand Down
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Prerequisites

- [sentientd](https://github.com/consensus-ai/sentient-network)
- [sentient-miner](https://github.com/consensus-ai/sentient-miner)
- [node & npm 6.9.0 LTS](https://nodejs.org/download/)
Earlier node versions may work, but they do not have guaranteed support.
- `libxss` is a required dependency for Electron on Debian, it can be installed with `sudo apt-get install libxss1`.
Expand All @@ -15,26 +16,18 @@ Earlier node versions may work, but they do not have guaranteed support.

Run from source

0. Install dependencies mentioned above
1. Download or `git clone` the repository
2. `npm install`
3. `npm start`
1. Install dependencies mentioned above
2. Download or `git clone` the repository
3. `npm install`
4. `npm start`

## Build new release

### Prerequisites

For Mac OS
`NOTE` if you are running from source please specify path to sentientd and sentient-miner using these environment variables: _SENTIENTD_PATH_ and _SENTIENT_MINER_PATH_.

0. brew install wine
1. brew install gnu-sed --with-default-names
2. brew install wget

Steps for bulding new release
## Build new release

0. Download latest [Sentient Network](https://github.com/consensus-ai/sentient-network/releases) files and put to home directory.
1. Bump [version](https://github.com/consensus-ai/sentient-ui/blob/26c672315cff0380e7481def00852455c974b6d6/package.json#L3)
2. Run from working directory `./release.sh PRIVATE_KEY PUBLIC_KEY [UI_VERSION] [SENTIENT-NETWORK_VERSION] [ELECTRON_VERSION]`
1. Bump [version](https://github.com/consensus-ai/sentient-ui/blob/master/package.json#L3)
2. Run commad `npm run release`. This command will upload all needed files to S3 bucket for auto-updating app.
3. From working directory `./sign.sh PRIVATE_KEY PUBLIC_KEY [UI_VERSION]`. This command will create a signed archive for github release files.

## [Contributing](doc/Developers.md)

Expand Down
Binary file added assets/linux-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ html, body {

color: #3D4B66;
margin-left: 3px;
padding-left: 37px;
padding-left: 48px;
}

.sidebar-button:hover {
Expand Down Expand Up @@ -178,7 +178,7 @@ html, body {
}

.button .text {
padding: 4px;
padding: 4px 4px 4px 6px;
}

/* Mainbar */
Expand Down
2 changes: 1 addition & 1 deletion css/plugin-standard.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ select:hover {
}
.button:active {
transform: translateX(2px) translateY(2px);
}
}
2 changes: 1 addition & 1 deletion doc/Developers.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developers

To get Sentient-UI running, ensure you have installed node, npm, and [sentientd](https://github.com/consensus-ai/sentient-network).
To get Sentient-UI running, ensure you have installed node, npm, [sentientd](https://github.com/consensus-ai/sentient-network) and [sentient-miner](https://github.com/consensus-ai/sentient-miner)
After that, starting the application is as easy as running: `npm install && npm start`

## Resources
Expand Down
10 changes: 2 additions & 8 deletions doc/DevelopmentFlow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ the UI, you don't have to wait for the daemon to start up and get into a synced

## Packaging & Releasing Sentient-UI

There is a [release.sh](https://github.com/consensus-ai/sentient-ui/blob/master/release.sh) script that can help package a release of Sentient UI.
For packaging releases we are using [electron-builder](https://github.com/electron-userland/electron-builder). When release candidate is ready just need to run `npm run release` command. This command will build all binaries for all platforms (darwin, windows, linux) and upload them to S3 bucket for auto-update.

It is mostly automated, but requires you to have a local release of [sentient-network](https://github.com/consensus-ai/sentient-network) ready. See the [Release Process](https://github.com/consensus-ai/sentient-network/blob/master/doc/Release%20Process.md) documentation for `sentient-network` for instructions on how to create a release.

You will want to update the path to those releases here: https://github.com/consensus-ai/sentient-ui/blob/master/release.sh#L56

Protip: if you have extra time, you could improve the `release.sh` script to pull the release
from Github so we don't have to rely on local filepaths.
There is a [sign.sh](https://github.com/consensus-ai/sentient-ui/blob/master/sign.sh) script that will pack and sign files for github releases.

## Other Commands

Expand All @@ -31,4 +26,3 @@ will generate documentation about the UI's classes and functions. It's somewhat
messy though.
* `npm run lint`
will output style suggestions for the UI's javascript, including for plugins.

3 changes: 0 additions & 3 deletions doc/PluginTutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,3 @@ document.getElementById('create-address').onclick = function() {
IPCRenderer.sendToHost('api-call', '/wallet/address', 'new-address');
};
```

Which will make this tooltip appear on click as such:

1 change: 1 addition & 0 deletions doc/Plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ plugin:

1. It must be self-contained in a directory of its name.
2. It must have an index.html in this directory.
3. It must have own css folder.
4 changes: 4 additions & 0 deletions doc/Structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The full root level structure is as follows
├── plugins/ // Plugins give the UI its functionality
+├── release/ // Release bundles are placed here
├── test/ // Testing scripts ran with mocha
+├── tools/ // Binaries are placed here
├── LICENSE // MIT Open Source License
├── README.md // Readme doc
├── index.html // The first markup page that loads
Expand Down Expand Up @@ -72,6 +73,9 @@ users
## [test/](/doc/Testing.md)
Tests written using [spectron](https://github.com/kevinsawicki/spectron).

## tools/
Created upon running `./prepare.sh`. Contains binaries for sentientd and sentient-miner.

## index.html
The starting point of the renderer process. This file structures the layout of
the general UI and loads `/js/rendererjs/uiManager.js` and
Expand Down
13 changes: 11 additions & 2 deletions doc/Technologies.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Technologies

We use three major tools in this application and they follow this hierarchy:
Javascript -> Node/NPM -> Electron.
Javascript -> Node/NPM -> Electron.

### Javascript

This should be familiar to most webdevs. We mostly adhere to [certain style
conventions](http://javascript.crockford.com/code.html)

### [Reactjs](https://github.com/facebook/react/)

React is a JavaScript library for building user interfaces.

### [NPM](https://www.npmjs.com/)

Node Package Manager gives easy package management. We use NPM to manage our
Expand Down Expand Up @@ -37,7 +41,7 @@ for creating cross-platform desktop applications.

Making this a desktop application instead of a webapp gives us libraries to
access filepaths and other OS resources (via Node libraries) that a webapp
would be limited from.
would be limited from.

The code does not have to adhere to compatibility for all browsers (looking
at you, Internet Explorer) because electron is run on chromium. This extends
Expand All @@ -46,3 +50,8 @@ from JS to CSS (with the use of -webkit- rules when applicable).
We do occasionally use ES2015 and ES2016 conventions and syntax in the code
base with no worries for the same reason

### [Recharts](https://github.com/recharts/recharts)

Recharts is a Redefined chart library built with React and D3. The main purpose of
this library is to help you to write charts in React applications without any pain.
It is using for displaying poll stats history and hashrate history graphs in the Sentient-UI.
12 changes: 12 additions & 0 deletions doc/spec/SentientdMiner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Sentient-UI sentient-miner specification

## Introduction

The purpose of this spec is to outline the desired behaviour of Sentient-UI as it relates to starting, stopping miner process.

## Desired Functionality

- Sentient-UI is starting own [sentient-miner](https://github.com/consensus-ai/sentient-miner) process under the hood.
- User can start/stop miner process.
- User can choose desired intensety value using UI.
- In case of crashing miner process error message will be shown.
49 changes: 49 additions & 0 deletions js/mainjs/appUpdater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { dialog } from 'electron'
import { autoUpdater } from "electron-updater"
import Path from 'path'
const iconPath = Path.join(__dirname, '../', 'assets', 'icon.png')
import request from 'request'

export default function () {
autoUpdater.on('error', (err) => {
let message = err.toString()
if (/ERR_INTERNET_DISCONNECTED/.test(message)){
message = "Sentient UI currently is unable to connect to the update server. Please check your connection settings or try checking for an update later"
}
dialog.showMessageBox({
type: 'error',
defaultId: 0,
icon: iconPath,
message: 'Error during update',
detail: message
})
})

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
let message = 'A new version of Sentient UI is now available. It will be installed the next time you restart the application.'
request('https://api.github.com/repos/consensus-ai/sentient-ui/releases/latest',
{ headers: { 'User-Agent': ' Sentient-UI' }, json: true }, (err, res, { body }) => {
if (body) {
message += '\n\n'
const splitNotes = body.split(/[^\r]\n/)
splitNotes.forEach(notes => {
message += notes + '\n\n'
})
}
dialog.showMessageBox({
type: 'question',
buttons: ['Install and Relaunch', 'Later'],
defaultId: 0,
icon: iconPath,
message: 'A new version of Sentient UI has been downloaded',
detail: message
}, response => {
if (response === 0) {
setTimeout(() => autoUpdater.quitAndInstall(), 1)
}
})
})
})
// init for updates
autoUpdater.checkForUpdates()
}
15 changes: 10 additions & 5 deletions js/mainjs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ import { version } from '../../package.json'
import semver from 'semver'
import os from 'os'

const defaultSentientdPath = Path.join(__dirname, '../sentient-network', (process.platform === 'win32' ? 'sentientd.exe' : 'sentientd'))
const defaultSentientMinerPath = Path.join(__dirname, '../sentient-miner', (process.platform === 'win32' ? 'sentient-miner.exe' : 'sentient-miner'))
const defaultGenesisFile = Path.join(__dirname, '../sentient-network', 'config', 'genesis.json')
const defaultSentientdPath = process.env.SENTIENTD_PATH || Path.join(app.getAppPath(), '../sentient-network', (process.platform === 'win32' ? 'sentientd.exe' : 'sentientd'))
const defaultSentientMinerPath = process.env.SENTIENT_MINER_PATH || Path.join(app.getAppPath(), '../sentient-miner', (process.platform === 'win32' ? 'sentient-miner.exe' : 'sentient-miner'))
const defaultGenesisFile = Path.join(app.getAppPath(), '../sentient-network', 'config', 'genesis.json')
const defaultDataDir = Path.join(app.getPath('userData'), 'data')
const defaultHashRateLogsUrl = 'http://localhost:5555/hashrate'
const defaultPoolHostUrl = 'http://pool.sentient.org:9910'
const defaultStratumHostUrl = 'stratum+tcp://pool.sentient.org:3333'
const minerName = `${os.hostname()}-${os.platform()}`.replace(/[^A-Z0-9]+/ig, '_')
const miningType = 'pool'
const intensity = 18

// The default settings
const defaultConfig = {
sentientd: {
path: process.env.SENTIENTD_PATH || defaultSentientdPath,
path: defaultSentientdPath,
datadir: process.env.SENTIENTD_DATA_DIR || defaultDataDir,
genesisfile: process.env.SENTIENTD_GENESIS_FILE || defaultGenesisFile,
address: process.env.SENTIENTD_API_ADDR || '127.0.0.1:9910',
rpcaddr: process.env.SENTIENTD_RPC_ADDR || ':9911',
detached: false,
},
sentient_miner: {
path: process.env.SENTIENT_MINER_PATH || defaultSentientMinerPath,
path: defaultSentientMinerPath,
pool_host: process.env.SENTIENT_POOL_HOST || defaultPoolHostUrl,
stratum_host: process.env.SENTIENT_STRATUM_HOST || defaultStratumHostUrl,
hashrate_host: defaultHashRateLogsUrl,
Expand All @@ -39,6 +40,7 @@ const defaultConfig = {
version: version,
minerName: minerName,
miningType: miningType,
intensity: intensity,
}

/**
Expand Down Expand Up @@ -103,6 +105,9 @@ export default function configManager(filepath) {
config.defaultSentientdPath = defaultSentientdPath
config.defaultGenesisFile = defaultGenesisFile

// expose the default miner path
config.defaultSentientMinerPath = defaultSentientMinerPath

// Save to disk immediately when loaded
try {
config.save()
Expand Down
21 changes: 13 additions & 8 deletions js/mainjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { app } from 'electron'
import Path from 'path'
import loadConfig from './config.js'
import initWindow from './initWindow.js'
import appUpdater from './appUpdater.js'
import { v4 as uuid } from 'uuid'
import Analytics from 'electron-google-analytics'
import ua from 'universal-analytics'
import os from 'os'
import { version } from '../../package.json'

// load config.json manager
const basePath = process.env.SENTIENTD_DATA_DIR || app.getPath('userData')
global.config = loadConfig(Path.join(basePath, 'config.json'))
let mainWindow

// initialize GA objects
const analytics = new Analytics('UA-131311702-2')

// create uniq user id
if (!config.userid) {
config.userid = uuid()
}

analytics.set('uid', config.userid)
// initialize GA objects
const analytics = new ua('UA-131311702-2', config.userid)
global.analytics = analytics

// disable hardware accelerated rendering
Expand All @@ -42,15 +42,20 @@ if (!gotTheLock) {

// When Electron loading has finished, start Sentient-UI.
app.on('ready', () => {
appUpdater()
// Send GA on open APP
analytics.event('App', 'open', { clientID: config.userid })
analytics.pageview("/wallet", "http://sentient-ui.consensus.ai", "Wallet")
.event('App', 'open')
.event('Platform', os.platform())
.event('Version', version)
.send()
// Load mainWindow
mainWindow = initWindow(config)
})

// Quit once all windows have been closed.
app.on('window-all-closed', () => {
analytics.event('App', 'close', { clientID: config.userid }).then(() => {
analytics.event('App', 'close', () => {
app.quit()
})
})
Expand Down
7 changes: 5 additions & 2 deletions js/rendererjs/plugins.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This module handles the construction of Sentient-UI plugins.
import { List } from 'immutable'
import Path from 'path'
import fs from 'graceful-fs'
import { remote } from 'electron'
const analytics = remote.getGlobal('analytics')

const devtoolsShortcut = 'Ctrl+Shift+P'

Expand Down Expand Up @@ -74,7 +74,10 @@ export const setCurrentPlugin = (pluginName) => {
// Construct a plugin button element from an icon path and title
const hookUpPluginButton = (title) => {
const elem = document.getElementById(title+'-button')
elem.onclick = () => setCurrentPlugin(title)
elem.onclick = () => {
analytics.pageview(`/${title.toLowerCase()}`, "http://sentient-ui.consensus.ai", title).send()
setCurrentPlugin(title)
}
return elem
}

Expand Down
Loading

0 comments on commit 8ccda91

Please sign in to comment.