Browse Source

Merge pull request #242 from SuperNETorg/v0.25

V0.25
pkg_automation_electrum
pbca26 7 years ago
committed by GitHub
parent
commit
2eadca3702
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 58
      README.md
  2. 97
      main.js

58
README.md

@ -6,53 +6,23 @@ You must have `node.js` and `npm` installed on your machine.
Clone Agama Desktop App with EasyDEX-GUI submodule Clone Agama Desktop App with EasyDEX-GUI submodule
```shell ```shell
git clone --recursive https://github.com/SuperNETorg/Agama.git 1) git clone https://github.com/supernetorg/agama --recursive --branch pkg_automation_electrum --single-branch
cd gui/EasyDEX-GUI/ with this command you git clone agama - but explicitly just the pkg_automation_electrum branch (therefore --single-branch) which we also use for the release packages.
git checkout master 2) cd agama && cd gui/EasyDEX-GUI/
git pull 3) git checkout electrum && git pull origin electrum
cd ../../ 4) npm install && npm install webpack
``` 5) ./binary_artifacts.sh
6) npm start in project root folder
Install Agama App 7) cd gui/EasyDEX-GUI/react/src
```shell 8) npm start
cd Agama 8) toggle dev and debug options in settings
npm install 9) restart the app
``` 10) sync komodod and/or asset chains
Then start Agama App You are ready to dev
```shell
npm start
``` ```
### Important dev notes ### Important dev notes
#### Use the following config.json for dev
Place it in ./iguana folder.
```
{
"edexGuiOnly": true,
"iguanaGuiOnly": false,
"manualIguanaStart": false,
"skipBasiliskNetworkCheck": true,
"minNotaries": 8,
"host": "127.0.0.1",
"agamaPort": 17777,
"iguanaCorePort": 7778,
"maxDescriptors": {
"darwin": 90000,
"linux": 1000000
},
"killIguanaOnStart": true,
"dev": true,
"v2": true,
"useBasiliskInstance": true,
"debug": true,
"iguanaAppPort": 17777,
"forks": {
"basilisk": false,
"all": false
}
}
```
#### Sockets.io #### Sockets.io
In dev mode backend is configured to send/receive messages from/to http://127.0.0.1:3000 address. If you open it as http://localhost:3000 sockets server will reject any messages. In dev mode backend is configured to send/receive messages from/to http://127.0.0.1:3000 address. If you open it as http://localhost:3000 sockets server will reject any messages.

97
main.js

@ -13,26 +13,25 @@ const { Menu } = require('electron');
const portscanner = require('portscanner'); const portscanner = require('portscanner');
const osPlatform = os.platform(); const osPlatform = os.platform();
const fixPath = require('fix-path'); const fixPath = require('fix-path');
const express = require('express'); const express = require('express');
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
const fsnode = require('fs'); const fsnode = require('fs');
const fs = require('fs-extra'); const fs = require('fs-extra');
const numCPUs = require('os').cpus().length; const numCPUs = require('os').cpus().length;
const Promise = require('bluebird');
Promise = require('bluebird'); const arch = require('arch');
if (osPlatform === 'linux') { if (osPlatform === 'linux') {
process.env.ELECTRON_RUN_AS_NODE = true; process.env.ELECTRON_RUN_AS_NODE = true;
} }
// GUI APP settings and starting gui on address http://120.0.0.1:17777 // GUI APP settings and starting gui on address http://120.0.0.1:17777
var shepherd = require('./routes/shepherd'); let shepherd = require('./routes/shepherd');
var guiapp = express(); let guiapp = express();
shepherd.createAgamaDirs(); shepherd.createAgamaDirs();
var appConfig = shepherd.loadLocalConfig(); // load app config let appConfig = shepherd.loadLocalConfig(); // load app config
const nativeCoindList = shepherd.scanNativeCoindBins(); const nativeCoindList = shepherd.scanNativeCoindBins();
shepherd.setVar('nativeCoindList', nativeCoindList); shepherd.setVar('nativeCoindList', nativeCoindList);
@ -92,7 +91,7 @@ shepherd.writeLog(`app started in ${(appConfig.dev ? 'dev mode' : ' user mode')}
shepherd.setConfKMD(); shepherd.setConfKMD();
shepherd.setConfKMD('CHIPS'); shepherd.setConfKMD('CHIPS');
guiapp.use(function(req, res, next) { guiapp.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', appConfig.dev ? '*' : 'http://127.0.0.1:3000'); res.header('Access-Control-Allow-Origin', appConfig.dev ? '*' : 'http://127.0.0.1:3000');
res.header('Access-Control-Allow-Headers', 'X-Requested-With'); res.header('Access-Control-Allow-Headers', 'X-Requested-With');
res.header('Access-Control-Allow-Credentials', 'true'); res.header('Access-Control-Allow-Credentials', 'true');
@ -138,7 +137,7 @@ guiapp.use(bodyParser.urlencoded({
extended: true, extended: true,
})); // support encoded bodies })); // support encoded bodies
guiapp.get('/', function(req, res) { guiapp.get('/', (req, res) => {
res.send('Agama app server'); res.send('Agama app server');
}); });
@ -184,10 +183,10 @@ function createLoadingWindow() {
loadingWindow.setResizable(false); loadingWindow.setResizable(false);
// check if agama is already running // check if agama is already running
portscanner.checkPortStatus(appConfig.agamaPort, '127.0.0.1', function(error, status) { portscanner.checkPortStatus(appConfig.agamaPort, '127.0.0.1', (error, status) => {
// Status is 'open' if currently in use or 'closed' if available // Status is 'open' if currently in use or 'closed' if available
if (status === 'closed') { if (status === 'closed') {
server.listen(appConfig.agamaPort, function() { server.listen(appConfig.agamaPort, () => {
shepherd.log(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`); shepherd.log(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`);
shepherd.writeLog(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`); shepherd.writeLog(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`);
// start sockets.io // start sockets.io
@ -211,7 +210,7 @@ function createLoadingWindow() {
}); });
} else { } else {
willQuitApp = true; willQuitApp = true;
server.listen(appConfig.agamaPort + 1, function() { server.listen(appConfig.agamaPort + 1, () => {
shepherd.log(`guiapp and sockets.io are listening on port ${appConfig.agamaPort + 1}`); shepherd.log(`guiapp and sockets.io are listening on port ${appConfig.agamaPort + 1}`);
shepherd.writeLog(`guiapp and sockets.io are listening on port ${appConfig.agamaPort + 1}`); shepherd.writeLog(`guiapp and sockets.io are listening on port ${appConfig.agamaPort + 1}`);
}); });
@ -234,15 +233,14 @@ function createLoadingWindow() {
// load our index.html (i.e. easyDEX GUI) // load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup`); loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup`);
loadingWindow.webContents.on('did-finish-load', function() { loadingWindow.webContents.on('did-finish-load', () => {
setTimeout(function() { setTimeout(() => {
loadingWindow.show(); loadingWindow.show();
}, 40); }, 40);
}); });
shepherd.writeLog('show loading window'); shepherd.writeLog('show loading window');
// if window closed we kill iguana proc loadingWindow.on('hide', () => {
loadingWindow.on('hide', function() {
// our app does not have multiwindow - so we dereference the window object instead of // our app does not have multiwindow - so we dereference the window object instead of
// putting them into an window_arr // putting them into an window_arr
loadingWindow = null; loadingWindow = null;
@ -277,7 +275,14 @@ function updateAppSettings(_settings) {
appConfig = _settings; appConfig = _settings;
} }
app.on('ready', createLoadingWindow); if (process.argv.indexOf('dexonly') > -1) {
app.on('ready', createLoadingWindow);
setTimeout(() => {
createWindow('open', true);
}, 100);
} else {
app.on('ready', createLoadingWindow);
}
function createAppCloseWindow() { function createAppCloseWindow() {
// initialise window // initialise window
@ -293,8 +298,8 @@ function createAppCloseWindow() {
appCloseWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup/app-closing.html`); appCloseWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup/app-closing.html`);
appCloseWindow.webContents.on('did-finish-load', function() { appCloseWindow.webContents.on('did-finish-load', () => {
setTimeout(function() { setTimeout(() => {
appCloseWindow.show(); appCloseWindow.show();
}, 40); }, 40);
}); });
@ -328,8 +333,8 @@ function createAppSettingsWindow() {
appSettingsWindow.zcashParamsExist = _zcashParamsExist; appSettingsWindow.zcashParamsExist = _zcashParamsExist;
appSettingsWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup/app-settings.html`); appSettingsWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/startup/app-settings.html`);
appSettingsWindow.webContents.on('did-finish-load', function() { appSettingsWindow.webContents.on('did-finish-load', () => {
setTimeout(function() { setTimeout(() => {
appSettingsWindow.show(); appSettingsWindow.show();
}, 40); }, 40);
}); });
@ -340,7 +345,7 @@ function destroyAppSettingsWindow() {
appSettingsWindow = null; appSettingsWindow = null;
} }
function createWindow(status) { function createWindow(status, hideLoadingWindow) {
if (appSettingsWindow) { if (appSettingsWindow) {
destroyAppSettingsWindow(); destroyAppSettingsWindow();
} }
@ -383,17 +388,17 @@ function createWindow(status) {
shepherd.writeLog('show edex gui'); shepherd.writeLog('show edex gui');
mainWindow.appConfig = appConfig; mainWindow.appConfig = appConfig;
mainWindow.appConfigSchema = shepherd.appConfigSchema; mainWindow.appConfigSchema = shepherd.appConfigSchema;
mainWindow.arch = os.arch(); mainWindow.arch = arch();
mainWindow.appBasicInfo = appBasicInfo; mainWindow.appBasicInfo = appBasicInfo;
mainWindow.appSessionHash = appSessionHash; mainWindow.appSessionHash = appSessionHash;
mainWindow.assetChainPorts = require('./routes/ports.js'); mainWindow.assetChainPorts = require('./routes/ports.js');
mainWindow.zcashParamsExist = _zcashParamsExist;
mainWindow.zcashParamsExistPromise = shepherd.zcashParamsExistPromise;
mainWindow.agamaIcon = agamaIcon; mainWindow.agamaIcon = agamaIcon;
mainWindow.testLocation = shepherd.testLocation; mainWindow.testLocation = shepherd.testLocation;
mainWindow.kmdMainPassiveMode = shepherd.kmdMainPassiveMode; mainWindow.kmdMainPassiveMode = shepherd.kmdMainPassiveMode;
mainWindow.getAppRuntimeLog = shepherd.getAppRuntimeLog; mainWindow.getAppRuntimeLog = shepherd.getAppRuntimeLog;
mainWindow.nativeCoindList = nativeCoindList; mainWindow.nativeCoindList = nativeCoindList;
mainWindow.zcashParamsExist = _zcashParamsExist;
mainWindow.zcashParamsExistPromise = shepherd.zcashParamsExistPromise;
mainWindow.zcashParamsDownloadLinks = shepherd.zcashParamsDownloadLinks; mainWindow.zcashParamsDownloadLinks = shepherd.zcashParamsDownloadLinks;
mainWindow.isWindows = os.platform() === 'win32' ? true : false; // obsolete(?) mainWindow.isWindows = os.platform() === 'win32' ? true : false; // obsolete(?)
mainWindow.appExit = appExit; mainWindow.appExit = appExit;
@ -401,6 +406,7 @@ function createWindow(status) {
mainWindow.setMaxconKMDConf = shepherd.setMaxconKMDConf; mainWindow.setMaxconKMDConf = shepherd.setMaxconKMDConf;
mainWindow.getMMCacheData = shepherd.getMMCacheData; mainWindow.getMMCacheData = shepherd.getMMCacheData;
mainWindow.activeSection = 'wallets'; mainWindow.activeSection = 'wallets';
mainWindow.argv = process.argv;
if (appConfig.dev) { if (appConfig.dev) {
mainWindow.loadURL('http://127.0.0.1:3000'); mainWindow.loadURL('http://127.0.0.1:3000');
@ -408,9 +414,14 @@ function createWindow(status) {
mainWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/EasyDEX-GUI/react/build`); mainWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/EasyDEX-GUI/react/build`);
} }
mainWindow.webContents.on('did-finish-load', function() { mainWindow.webContents.on('did-finish-load', () => {
setTimeout(function() { setTimeout(() => {
mainWindow.show(); mainWindow.show();
if (hideLoadingWindow &&
loadingWindow) {
loadingWindow.hide();
}
}, 40); }, 40);
}); });
@ -428,8 +439,8 @@ function createWindow(status) {
// mainWindow.webContents.openDevTools() // mainWindow.webContents.openDevTools()
function appExit() { function appExit() {
const CloseDaemons = function() { const CloseDaemons = () => {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
shepherd.log('Closing Main Window...'); shepherd.log('Closing Main Window...');
shepherd.writeLog('exiting app...'); shepherd.writeLog('exiting app...');
@ -440,11 +451,11 @@ function createWindow(status) {
shepherd.log(result); shepherd.log(result);
shepherd.writeLog(result); shepherd.writeLog(result);
resolve(result); resolve(result);
}) });
} }
const HideMainWindow = function() { const HideMainWindow = () => {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
const result = 'Hiding Main Window: done'; const result = 'Hiding Main Window: done';
shepherd.log('Exiting App...'); shepherd.log('Exiting App...');
@ -454,15 +465,15 @@ function createWindow(status) {
}); });
} }
const HideAppClosingWindow = function() { const HideAppClosingWindow = () => {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
appCloseWindow = null; appCloseWindow = null;
resolve(true); resolve(true);
}); });
} }
const QuitApp = function() { const QuitApp = () => {
return new Promise(function(resolve, reject) { return new Promise((resolve, reject) => {
const result = 'Quiting App: done'; const result = 'Quiting App: done';
app.quit(); app.quit();
@ -471,7 +482,7 @@ function createWindow(status) {
}); });
} }
const closeApp = function() { const closeApp = () => {
CloseDaemons() CloseDaemons()
.then(HideMainWindow) .then(HideMainWindow)
.then(HideAppClosingWindow) .then(HideAppClosingWindow)
@ -487,7 +498,7 @@ function createWindow(status) {
} else { } else {
createAppCloseWindow(); createAppCloseWindow();
shepherd.quitKomodod(appConfig.cliStopTimeout); shepherd.quitKomodod(appConfig.cliStopTimeout);
_appClosingInterval = setInterval(function() { _appClosingInterval = setInterval(() => {
if (!Object.keys(shepherd.coindInstanceRegistry).length) { if (!Object.keys(shepherd.coindInstanceRegistry).length) {
closeApp(); closeApp();
} }
@ -496,13 +507,13 @@ function createWindow(status) {
} }
// if window closed we kill iguana proc // if window closed we kill iguana proc
mainWindow.on('closed', function() { mainWindow.on('closed', () => {
appExit(); appExit();
}); });
} }
} }
app.on('window-all-closed', function() { app.on('window-all-closed', () => {
//if (os.platform() !== 'win32') { ig.kill(); } //if (os.platform() !== 'win32') { ig.kill(); }
// in osx apps stay active in menu bar until explictly closed or quitted by CMD Q // in osx apps stay active in menu bar until explictly closed or quitted by CMD Q
// so we do not kill the app --> for the case user clicks again on the iguana icon // so we do not kill the app --> for the case user clicks again on the iguana icon
@ -514,7 +525,7 @@ app.on('window-all-closed', function() {
// Emitted before the application starts closing its windows. // Emitted before the application starts closing its windows.
// Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('before-quit', function(event) { app.on('before-quit', (event) => {
shepherd.log('before-quit'); shepherd.log('before-quit');
// shepherd.killRogueProcess('marketmaker'); // shepherd.killRogueProcess('marketmaker');
@ -534,7 +545,7 @@ app.on('before-quit', function(event) {
// Emitted when all windows have been closed and the application will quit. // Emitted when all windows have been closed and the application will quit.
// Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('will-quit', function(event) { app.on('will-quit', (event) => {
if (!forceQuitApp && if (!forceQuitApp &&
mainWindow === null && mainWindow === null &&
loadingWindow != null) { loadingWindow != null) {
@ -546,7 +557,7 @@ app.on('will-quit', function(event) {
// Emitted when the application is quitting. // Emitted when the application is quitting.
// Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. // Calling event.preventDefault() will prevent the default behaviour, which is terminating the application.
app.on('quit', function(event) { app.on('quit', (event) => {
if (!forceQuitApp && if (!forceQuitApp &&
mainWindow === null && mainWindow === null &&
loadingWindow != null) { loadingWindow != null) {
@ -555,7 +566,7 @@ app.on('quit', function(event) {
} }
}) })
app.on('activate', function() { app.on('activate', () => {
if (mainWindow === null) {} if (mainWindow === null) {}
}); });

Loading…
Cancel
Save