Browse Source

resolved merge conflicts

all-modes
pbca26 8 years ago
parent
commit
144f0617b7
  1. 23
      buildscripts/AgamaApp-osx.xml
  2. 23
      buildscripts/AgamaApp-windows.xml
  3. 2
      gui/EasyDEX-GUI
  4. 28
      gui/agama-instance-error.html
  5. 25
      gui/app-closing.html
  6. BIN
      gui/bg.jpg
  7. BIN
      gui/bg2.jpg
  8. 31
      gui/bluebird.min.js
  9. 34
      gui/index.html
  10. 48
      gui/init.js
  11. 6
      gui/jRoll.min.css
  12. 1
      gui/jRoll.min.js
  13. 28
      gui/loading.css
  14. 189
      gui/loading.js
  15. 4
      gui/module-hack.js
  16. 272
      main.js
  17. 30
      make-patch.sh
  18. 6
      package.json
  19. 498
      routes/cache.js
  20. 24
      routes/ports.js
  21. 838
      routes/shepherd.js
  22. 3
      version

23
buildscripts/AgamaApp-osx.xml

@ -116,6 +116,28 @@
</compareValues>
</ruleList>
</deleteFile>
<deleteFile>
<explanation>Deleting iguana config json</explanation>
<path>${user_home_directory}/Library/Application Support/Iguana/config.json</path>
<progressText>Deleting iguana config</progressText>
<ruleList>
<compareValues>
<logic>equals</logic>
<value1>${previous_installation_exists}</value1>
<value2>1</value2>
</compareValues>
<compareValues>
<logic>equals</logic>
<value1>${installation_type}</value1>
<value2>uninstall</value2>
</compareValues>
<compareValues>
<logic>equals</logic>
<value1>${delete_config_data}</value1>
<value2>1</value2>
</compareValues>
</ruleList>
</deleteFile>
<deleteFile>
<explanation>Deleting ZcashParams</explanation>
<path>${user_home_directory}/Library/Application Support/ZcashParams/</path>
@ -320,4 +342,3 @@
</choiceParameterGroup>
</parameterList>
</project>

23
buildscripts/AgamaApp-windows.xml

@ -214,6 +214,28 @@
</compareValues>
</ruleList>
</deleteFile>
<deleteFile>
<explanation>Deleting iguana config json</explanation>
<path>${windows_folder_appdata}/Iguana/config.json</path>
<progressText>Deleting iguana config</progressText>
<ruleList>
<compareValues>
<logic>equals</logic>
<value1>${previous_installation_exists}</value1>
<value2>1</value2>
</compareValues>
<compareValues>
<logic>equals</logic>
<value1>${installation_type}</value1>
<value2>uninstall</value2>
</compareValues>
<compareValues>
<logic>equals</logic>
<value1>${delete_config_data}</value1>
<value2>1</value2>
</compareValues>
</ruleList>
</deleteFile>
<deleteFile>
<explanation>Deleting zcash params</explanation>
<path>${windows_folder_appdata}/ZcashParams/</path>
@ -512,4 +534,3 @@
</platformOptions>
</platformOptionsList>
</project>

2
gui/EasyDEX-GUI

@ -1 +1 @@
Subproject commit ba50df3108aa7c3dc27583f15e4f85d80ac08cda
Subproject commit 7399c05db6464596edf4c242f5a3a57445c70ded

28
gui/agama-instance-error.html

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="EasyDEX-GUI/assets/global/css/bootstrap.min.css">
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/jRoll.min.css">
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/loading.css">
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/module-hack.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/global/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/scripts/config.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/bluebird.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/loading.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script>
</head>
<body class="agamaMode">
<div class="text-center">
<div id="agamaMode">
<img src="EasyDEX-GUI/assets/mainWindow/img/agama-icon.svg" class="agama-logo" alt="Agama Wallet" width="80" height="100" />
<div id="agamaModeStatus">Another Agama instance is already running!</div>
<div>Please close all other instances and restart the app.</div>
<br />
<button onClick="quitApp()" class="btn btn-primary btn-close-app">Quit</button>
</div>
</div>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/init.js"></script>
</body>
</html>

25
gui/app-closing.html

@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="EasyDEX-GUI/assets/global/css/bootstrap.min.css">
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/jRoll.min.css">
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/loading.css">
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/module-hack.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/global/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/scripts/config.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/bluebird.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/loading.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script>
</head>
<body class="agamaMode">
<div class="text-center">
<div id="agamaMode" class="app-closing">
<img src="EasyDEX-GUI/assets/mainWindow/img/agama-icon.svg" class="agama-logo" alt="Agama Wallet" width="80" height="100" />
<div id="agamaModeStatus">App is closing. Please wait...</div>
</div>
</div>
<!--script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/init.js"></script-->
</body>
</html>

BIN
gui/bg.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

BIN
gui/bg2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

31
gui/bluebird.min.js

File diff suppressed because one or more lines are too long

34
gui/index.html

@ -3,25 +3,33 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="EasyDEX-GUI/assets/global/css/bootstrap.min.css">
<link rel="stylesheet" href="jRoll.min.css">
<link rel="stylesheet" href="loading.css">
<script type="text/javascript" src="module-hack.js"></script>
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/jRoll.min.css">
<link rel="stylesheet" href="EasyDEX-GUI/assets/mainWindow/css/loading.css">
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/module-hack.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/global/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/scripts/config.js"></script>
<script type="text/javascript" src="bluebird.min.js"></script>
<script type="text/javascript" src="loading.js"></script>
<script type="text/javascript" src="jRoll.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/bluebird.min.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/loading.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/jRoll.min.js"></script>
<script>if (window.module) module = window.module;</script>
</head>
<body>
<body class="agamaMode">
<div class="text-center">
<div class="loader-block">
<div id="loading_status_text">Starting Wallet. Please wait...</div>
<div id="loading_sub_status_text"></div>
<div id="loading_sub_status_output_text"></div>
<!--div id="normalStart">
<div class="loader-block">
<div id="loading_status_text">Starting Wallet. Please wait...</div>
<div id="loading_sub_status_text"></div>
<div id="loading_sub_status_output_text"></div>
</div>
<div id="pulse" class="pulse-loader"></div>
</div-->
<div id="agamaMode">
<img src="EasyDEX-GUI/assets/mainWindow/img/agama-icon.svg" class="agama-logo" alt="Agama Wallet" width="80" height="100" />
<div id="agamaModeStatus">Choose Agama mode</div>
<button onClick="closeMainWindow()" class="btn btn-primary">Native only</button>
<button onClick="normalStart()" class="btn btn-primary">Normal start</button>
</div>
<div id="pulse" class="pulse-loader"></div>
</div>
<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="EasyDEX-GUI/assets/mainWindow/js/init.js"></script>
</body>
</html>

48
gui/init.js

@ -1,48 +0,0 @@
$(document).ready(function() {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
$('#pulse').jRoll({
radius: 100,
animation: 'pulse'
});
$('#loading_status_text').text('Starting Iguana daemon...');
GetAppConf(inititalWalletLoading);
function inititalWalletLoading(appConf) {
if (appConf && !appConf.manualIguanaStart) {
StartIguana();
}
var portcheck;
function startcheck() {
portcheck = setInterval(function(){
Iguana_activehandle(appConf).then(function(result){
console.log(result);
if (result !== 'error') {
stopcheck();
if (appConf && appConf.useBasiliskInstance) {
StartIguana_Cache();
}
$('#loading_status_text').text('Connecting to Basilisk Network...');
EDEX_DEXgetinfoAll(appConf.skipBasiliskNetworkCheck, appConf.minNotaries, appConf);
}
})
//var check = Iguana_activehandle();
//console.log(check[0])
}, 2000);
}
function stopcheck() {
clearInterval(portcheck);
}
startcheck();
}
});

6
gui/jRoll.min.css

File diff suppressed because one or more lines are too long

1
gui/jRoll.min.js

File diff suppressed because one or more lines are too long

28
gui/loading.css

@ -1,28 +0,0 @@
body {
overflow: hidden !important;
border: solid 1px #ccc;
height: 300px;
}
.text-center {
text-align: center;
}
.loader-block {
height: 240px;
width: 100%;
position: absolute;
top: -30px;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.pulse-loader {
position: absolute;
top: 10px;
left: -100px;
margin: 80px 50px;
width: 400px !important;
}

189
gui/loading.js

@ -1,189 +0,0 @@
function IguanaAJAX(url, ajax_data, timeout) {
return $.ajax({
data: JSON.stringify(ajax_data),
url: url,
type: 'POST',
dataType: 'json',
timeout: timeout ? timeout : 120000
//beforeSend: showLoadingImgFn
})
.fail(function(xhr, textStatus, error) {
// handle request failures
});
}
function Iguana_activehandle(appConf) {
return new Promise((resolve) => {
var ajax_data = {
'agent': 'SuperNET',
'method': 'activehandle'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:' + appConf.iguanaCorePort, ajax_data).done(function(data) {
//$('#loading_status_text').text('Retrieving active handle...');
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
})
.fail(function(xhr, textStatus, error) {
// $('#loading_status_text').text('Retrieving active handle error!');
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
});
}
//Iguana_activehandle().then(function(result){
//console.log(result)
//})
function StartIguana() {
var ajax_data = { 'herd': 'iguana'};
console.log(ajax_data);
$.ajax({
type: 'POST',
data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/herd',
dataType: 'xml/html/script/json', // expected format for response
contentType: 'application/json', // send as JSON
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data);
console.log('== ActiveHandle Data OutPut ==');
console.log(AjaxOutputData);
},
error: function(xhr, textStatus, error) {
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
}
});
}
function StartIguana_Cache() {
var ajax_data = {
'mode': 'basilisk',
'coin': 'all'
};
var start_iguana_cache= $.ajax({
type: 'POST',
data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/forks',
contentType: 'application/json', // send as JSON
})
start_iguana_cache.done(function(data) {
_data = JSON.parse(data);
console.log(_data.result);
sessionStorage.setItem('IguanaCachePort', _data.result);
});
}
function GetAppConf(cb) { // get iguana app conf
var ajax_data = { 'herd': 'iguana' },
data = false;
console.log(ajax_data);
$.ajax({
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
})
.done(function(_data) {
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;
cb.call(this, data);
})
.fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
cb.call(this, data);
});
return data;
}
function EDEX_DEXgetinfoAll(skip, minNotaries, appConf) {
const remote = require('electron').remote;
var window = remote.getCurrentWindow();
if (!skip) {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'dpow',
'method': 'notarychains'
},
tmp_index = 0,
tmp_index_failed = 0,
get_dex_notarychains = IguanaAJAX('http://127.0.0.1:' + appConf.iguanaCorePort, ajax_data, 10000).done(function(data) {
get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText);
if (minNotaries > get_dex_notarychains.length) { // if config value exceeds total num of notaries
minNotaries = get_dex_notarychains.length;
}
get_dex_notarychains = get_dex_notarychains.splice(0, minNotaries);
$.each(get_dex_notarychains, function( coin_index, coin_value ) {
console.log(coin_index + ': ' + coin_value);
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'dex',
'method': 'getinfo',
'symbol': coin_value
};
console.log(ajax_data);
if (coin_value !== 'MESH' || coin_value !== 'CEAL') {
var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:' + appConf.iguanaCorePort, ajax_data, 10000).done(function(data) {
getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText);
console.log(getinfo_each_chain);
tmp_index++;
$('#loading_sub_status_text').text('Connection status... ' + tmp_index + '/' + get_dex_notarychains.length + ': ' + coin_value);
if (getinfo_each_chain.error === 'less than required responses') {
$('#loading_sub_status_output_text').text('Output: ' + getinfo_each_chain.error);
} else {
$('#loading_sub_status_output_text').text('Output: Connected');
}
if ( tmp_index + tmp_index_failed === minNotaries ) {
console.log('min notaries connected');
window.createWindow('open');
window.hide();
}
})
.fail(function(xhr, textStatus, error) {
tmp_index_failed++;
if ( tmp_index + tmp_index_failed === minNotaries ) {
console.log('min notaries connected');
window.createWindow('open');
window.hide();
}
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
}
});
});
} else {
window.createWindow('open');
window.hide();
}
}

4
gui/module-hack.js

@ -1,4 +0,0 @@
if (typeof module === 'object') {
window.module = module;
module = undefined;
}

272
main.js

@ -11,6 +11,8 @@ const electron = require('electron'),
spawn = require('child_process').spawn,
exec = require('child_process').exec,
{ Menu } = require('electron'),
portscanner = require('portscanner'),
osPlatform = os.platform(),
fixPath = require('fix-path');
var express = require('express'),
@ -26,23 +28,32 @@ var express = require('express'),
Promise = require('bluebird');
if (osPlatform === 'linux') {
process.env.ELECTRON_RUN_AS_NODE = true;
// console.log(process.env);
}
// GUI APP settings and starting gui on address http://120.0.0.1:17777
var shepherd = require('./routes/shepherd');
var guiapp = express();
let localVersion;
let localVersionFile = shepherd.readVersionFile();
if (localVersionFile.indexOf('\r\n') > -1) {
localVersion = localVersionFile.split('\r\n');
} else {
localVersion = localVersionFile.split('\n');
}
const appBasicInfo = {
name: 'Agama',
version: '0.2.0.1a-beta'
version: localVersion[0],
};
app.setName(appBasicInfo.name);
app.setVersion(appBasicInfo.version);
if (os.platform() === 'linux') {
process.env.ELECTRON_RUN_AS_NODE = true;
// console.log(process.env);
}
// GUI APP settings and starting gui on address http://120.0.0.1:17777
var shepherd = require('./routes/shepherd'),
guiapp = express();
shepherd.createIguanaDirs();
const appSessionHash = md5(Date.now());
@ -54,7 +65,7 @@ shepherd.writeLog(`totalmem_readable: ${formatBytes(os.totalmem())}`);
shepherd.writeLog(`arch: ${os.arch()}`);
shepherd.writeLog(`cpu: ${os.cpus()[0].model}`);
shepherd.writeLog(`cpu_cores: ${os.cpus().length}`);
shepherd.writeLog(`platform: ${os.platform()}`);
shepherd.writeLog(`platform: ${osPlatform}`);
shepherd.writeLog(`os_release: ${os.release()}`);
shepherd.writeLog(`os_type: ${os.type()}`);
@ -64,21 +75,25 @@ shepherd.writeLog(`app started in ${(appConfig.dev ? 'dev mode' : ' user mode')}
shepherd.setConfKMD();
// kill rogue iguana copies on start
if (appConfig.killIguanaOnStart) {
let iguanaGrep;
if (os.platform() === 'darwin') {
iguanaGrep = "ps -p $(ps -A | grep -m1 iguana | awk '{print $1}') | grep -i iguana";
}
if (os.platform() === 'linux') {
iguanaGrep = 'ps -p $(pidof iguana) | grep -i iguana';
}
if (os.platform() === 'win32') {
iguanaGrep = 'tasklist';
switch (osPlatform) {
case 'darwin':
iguanaGrep = "ps -p $(ps -A | grep -m1 iguana | awk '{print $1}') | grep -i iguana";
break;
case 'linux':
iguanaGrep = 'ps -p $(pidof iguana) | grep -i iguana';
break;
case 'win32':
iguanaGrep = 'tasklist';
break;
}
exec(iguanaGrep, function(error, stdout, stderr) {
if (stdout.indexOf('iguana') > -1) {
const pkillCmd = os.platform() === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill -15 iguana';
const pkillCmd = osPlatform === 'win32' ? 'taskkill /f /im iguana.exe' : 'pkill -15 iguana';
console.log('found another iguana process(es)');
shepherd.writeLog('found another iguana process(es)');
@ -111,14 +126,14 @@ guiapp.use(function(req, res, next) {
});
// preload.js
const _setImmediate = setImmediate,
_clearImmediate = clearImmediate;
const _setImmediate = setImmediate;
const _clearImmediate = clearImmediate;
process.once('loaded', () => {
global.setImmediate = _setImmediate;
global.clearImmediate = _clearImmediate;
if (os.platform() === 'darwin') {
if (osPlatform === 'darwin') {
process.setFdLimit(appConfig.maxDescriptors.darwin);
app.setAboutPanelOptions({
applicationName: app.getName(),
@ -127,7 +142,7 @@ process.once('loaded', () => {
credits: 'SuperNET Team'
})
}
if (os.platform() === 'linux') {
if (osPlatform === 'linux') {
process.setFdLimit(appConfig.maxDescriptors.linux);
}
});
@ -135,7 +150,7 @@ process.once('loaded', () => {
guiapp.use(bodyParser.json({ limit: '50mb' })); // support json encoded bodies
guiapp.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
extended: true,
})); // support encoded bodies
guiapp.get('/', function (req, res) {
@ -148,36 +163,14 @@ guiapp.use('/shepherd', shepherd);
const server = require('http').createServer(guiapp);
const io = require('socket.io').listen(server);
server.listen(appConfig.agamaPort, function() {
console.log(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`);
shepherd.writeLog(`guiapp and sockets.io are listening on port ${appConfig.agamaPort}`);
});
io.set('origins', appConfig.dev ? 'http://127.0.0.1:3000' : `http://127.0.0.1:${appConfig.agamaPort}`); // set origin
io.on('connection', function(client) {
console.log('EDEX GUI is connected...');
shepherd.writeLog('EDEX GUI is connected...');
client.on('event', function(data) { // listen for client requests
console.log(data);
});
client.on('disconnect', function(data) {
console.log('EDEX GUI is disconnected');
});
client.on('join', function(data) {
console.log(data);
client.emit('messages', 'Sockets server is listening');
});
});
shepherd.setIO(io); // pass sockets object to shepherd router
shepherd.setVar('appBasicInfo', appBasicInfo);
shepherd.setVar('appSessionHash', appSessionHash);
let willQuitApp = false;
let mainWindow;
let loadingWindow;
let appCloseWindow;
let closeAppAfterLoading = false;
module.exports = guiapp;
var iguanaIcon;
let iguanaIcon;
if (os.platform() === 'linux') {
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png');
@ -186,26 +179,72 @@ if (os.platform() === 'win32') {
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico');
}
let mainWindow;
let loadingWindow;
let willQuitApp = false;
let closeAppAfterLoading = false;
function createLoadingWindow() {
mainWindow = null;
// initialise window
loadingWindow = new BrowserWindow({
width: 500,
height: 300,
frame: false,
icon: iguanaIcon
});
try {
loadingWindow = new BrowserWindow({
width: 500,
height: 300,
frame: false,
icon: iguanaIcon,
show: false,
});
} catch(e) {}
// check if agama is already running
portscanner.checkPortStatus(appConfig.agamaPort, '127.0.0.1', function(error, status) {
// Status is 'open' if currently in use or 'closed' if available
if (status === 'closed') {
server.listen(appConfig.agamaPort, function() {
console.log(`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
io.set('origins', appConfig.dev ? 'http://127.0.0.1:3000' : `http://127.0.0.1:${appConfig.agamaPort}`); // set origin
io.on('connection', function(client) {
console.log('EDEX GUI is connected...');
shepherd.writeLog('EDEX GUI is connected...');
client.on('event', function(data) { // listen for client requests
console.log(data);
});
client.on('disconnect', function(data) {
console.log('EDEX GUI is disconnected');
});
client.on('join', function(data) {
console.log(data);
client.emit('messages', 'Sockets server is listening');
});
});
});
} else {
willQuitApp = true;
server.listen(appConfig.agamaPort + 1, function() {
console.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}`);
});
loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort + 1}/gui/agama-instance-error.html`);
console.log('another agama app is already running');
}
})
shepherd.setIO(io); // pass sockets object to shepherd router
shepherd.setVar('appBasicInfo', appBasicInfo);
shepherd.setVar('appSessionHash', appSessionHash);
loadingWindow.createWindow = createWindow; // expose createWindow to front-end scripts
loadingWindow.appConfig = appConfig;
loadingWindow.forseCloseApp = forseCloseApp;
// load our index.html (i.e. easyDEX GUI)
loadingWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/`);
loadingWindow.webContents.on('did-finish-load', function() {
setTimeout(function() {
loadingWindow.show();
}, 40);
});
shepherd.writeLog('show loading window');
// DEVTOOLS - only for dev purposes - ca333
@ -230,17 +269,44 @@ function createLoadingWindow() {
});
}
// close app
function forseCloseApp() {
loadingWindow = null;
mainWindow = null;
app.quit();
}
app.on('ready', createLoadingWindow);
function createWindow (status) {
if ( status === 'open') {
function createAppCloseWindow() {
// initialise window
appCloseWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit
width: 500,
height: 300,
frame: false,
icon: iguanaIcon,
show: false,
});
appCloseWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/app-closing.html`);
appCloseWindow.webContents.on('did-finish-load', function() {
setTimeout(function() {
appCloseWindow.show();
}, 40);
});
}
function createWindow(status) {
if (status === 'open') {
require(path.join(__dirname, 'private/mainmenu'));
// initialise window
mainWindow = new BrowserWindow({ // dirty hack to prevent main window flash on quit
width: closeAppAfterLoading ? 1 : 1280,
height: closeAppAfterLoading ? 1 : 800,
icon: iguanaIcon
icon: iguanaIcon,
show: false,
});
if (closeAppAfterLoading) {
@ -271,13 +337,22 @@ function createWindow (status) {
if (appConfig.v2) {
shepherd.writeLog('show edex gui');
mainWindow.appConfig = appConfig;
mainWindow.appBasicInfo = appBasicInfo;
mainWindow.appSessionHash = appSessionHash;
mainWindow.assetChainPorts = require('./routes/ports.js');
mainWindow.zcashParamsExist = shepherd.zcashParamsExist();
if (appConfig.dev) {
mainWindow.loadURL('http://127.0.0.1:3000');
} else {
mainWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/EasyDEX-GUI/react/build`);
}
mainWindow.webContents.on('did-finish-load', function() {
setTimeout(function() {
mainWindow.show();
}, 40);
});
} else {
shepherd.writeLog('show edex gui');
mainWindow.loadURL(`http://${appConfig.host}:${appConfig.agamaPort}/gui/EasyDEX-GUI/`);
@ -307,10 +382,6 @@ function createWindow (status) {
shepherd.dumpCacheBeforeExit();
shepherd.quitKomodod();
// if komodod is under heavy load it may not respond to cli stop the first time
setInterval(function() {
shepherd.quitKomodod();
}, 100);
pm2.connect(true, function(err) {
console.log('connecting to pm2...');
@ -356,34 +427,60 @@ function createWindow (status) {
const HideMainWindow = function() {
return new Promise(function(resolve, reject) {
const result = 'Hiding Main Window: done';
console.log('Exiting App...');
mainWindow = null;
const result = 'Hiding Main Window: done';
console.log(result);
resolve(result);
});
}
const HideAppClosingWindow = function() {
return new Promise(function(resolve, reject) {
appCloseWindow = null;
resolve(true);
});
}
const QuitApp = function() {
return new Promise(function(resolve, reject) {
app.quit();
const result = 'Quiting App: done';
KillPm2(); // required for normal app quit in iguana-less mode
app.quit();
console.log(result);
resolve(result);
});
}
ConnectToPm2()
.then(function(result) {
return KillPm2();
})
.then(HideMainWindow)
.then(QuitApp);
const closeApp = function() {
ConnectToPm2()
.then(function(result) {
return KillPm2();
})
.then(HideMainWindow)
.then(HideAppClosingWindow)
.then(QuitApp);
}
let _appClosingInterval;
if (!Object.keys(shepherd.coindInstanceRegistry).length) {
closeApp();
} else {
createAppCloseWindow();
shepherd.quitKomodod(1000);
_appClosingInterval = setInterval(function() {
if (!Object.keys(shepherd.coindInstanceRegistry).length) {
closeApp();
}
}, 1000);
}
}
// if window closed we kill iguana proc
mainWindow.on('closed', function () {
mainWindow.on('closed', function() {
pm2Exit();
});
}
@ -440,12 +537,13 @@ app.on('activate', function () {
});
function formatBytes(bytes, decimals) {
if (bytes === 0)
if (bytes === 0) {
return '0 Bytes';
}
const k = 1000,
dm = decimals + 1 || 3,
sizes = [
const k = 1000;
const dm = decimals + 1 || 3;
const sizes = [
'Bytes',
'KB',
'MB',
@ -455,8 +553,8 @@ function formatBytes(bytes, decimals) {
'EB',
'ZB',
'YB'
],
i = Math.floor(Math.log(bytes) / Math.log(k));
];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
}

30
make-patch.sh

@ -0,0 +1,30 @@
cd gui/EasyDEX-GUI/react
echo "building gui..."
rm -rf ./build
mkdir build
mkdir build/assets
cp -R src/assets build/
NODE_ENV="production" webpack
cd ../../../
echo "copy patch files"
rm -rf ./patch.zip
rm -rf ./patch
mkdir patch
mkdir patch/gui
mkdir patch/gui/EasyDEX-GUI
mkdir patch/gui/EasyDEX-GUI/react
mkdir patch/gui/EasyDEX-GUI/react
cp -R gui/EasyDEX-GUI/react/build patch/gui/EasyDEX-GUI/react/build
cp -R gui/EasyDEX-GUI/assets patch/gui/EasyDEX-GUI
cp gui/index.html patch/gui/index.html
cp ./main.js patch
cp ./version patch
cp -R routes patch/routes
cp -R private patch/private
echo "package patch.zip"
cd patch
zip -r patch.zip gui routes private main.js version
cd ../
cp patch/patch.zip ./
rm -rf patch
echo "patch.zip is ready"

6
package.json

@ -5,7 +5,8 @@
"description": "Agama Desktop App",
"main": "main.js",
"scripts": {
"start": "electron ."
"start": "electron .",
"make-patch": "./make-patch.sh"
},
"repository": "https://github.com/SuperNETorg/Agama/",
"keywords": [
@ -23,9 +24,9 @@
"electron": "^1.4.1"
},
"dependencies": {
"adm-zip": "^0.4.7",
"bluebird": "^3.4.7",
"body-parser": "^1.15.2",
"corsproxy": "^1.5.0",
"electron": "^1.6.5",
"express": "^4.14.0",
"fix-path": "^2.1.0",
@ -37,6 +38,7 @@
"pm2": "^2.4.3",
"portscanner": "^2.1.1",
"ps-node": "^0.1.5",
"remote-file-size": "^3.0.3",
"request": "^2.80.0",
"rimraf": "^2.6.1",
"socket.io": "^1.7.3"

498
routes/cache.js

@ -1,6 +1,6 @@
const fs = require('fs-extra'),
request = require('request'),
async = require('async');
const fs = require('fs-extra');
const request = require('request');
const async = require('async');
var cache = {};
var inMemCache;
@ -33,18 +33,18 @@ cache.get = function(req, res, next) {
fs.readFile(`${cache.iguanaDir}/shepherd/cache-${pubkey}.json`, 'utf8', function (err, data) {
if (err) {
const errorObj = {
'msg': 'error',
'result': err
msg: 'error',
result: err,
};
res.end(JSON.stringify(errorObj));
} else {
} else { // deprecated
try {
const parsedJSON = JSON.parse(data),
successObj = {
'msg': 'success',
'result': parsedJSON
};
const parsedJSON = JSON.parse(data);
const successObj = {
msg: 'success',
result: parsedJSON,
};
inMemCache = parsedJSON;
res.end(JSON.stringify(successObj));
@ -59,8 +59,8 @@ cache.get = function(req, res, next) {
fs.writeFile(`${cache.iguanaDir}/shepherd/cache-${pubkey}.json`, data.substring(0, errorPos[errorPos.length - 1]), function(err) {
const successObj = {
'msg': 'success',
'result': data.substring(0, errorPos[errorPos.length - 1])
msg: 'success',
result: data.substring(0, errorPos[errorPos.length - 1]),
};
inMemCache = JSON.parse(data.substring(0, errorPos[errorPos.length - 1]));
@ -72,16 +72,16 @@ cache.get = function(req, res, next) {
});
} else {
const errorObj = {
'msg': 'error',
'result': `no file with handle ${pubkey}`
msg: 'error',
result: `no file with handle ${pubkey}`,
};
res.end(JSON.stringify(errorObj));
}
} else {
const successObj = {
'msg': 'success',
'result': inMemCache
msg: 'success',
result: inMemCache,
};
res.end(JSON.stringify(successObj));
@ -89,7 +89,7 @@ cache.get = function(req, res, next) {
} else {
const errorObj = {
'msg': 'error',
'result': 'no pubkey provided'
'result': 'no pubkey provided',
};
res.end(JSON.stringify(errorObj));
@ -104,15 +104,15 @@ cache.groomGet = function(req, res, next) {
fs.readFile(`${cache.iguanaDir}/shepherd/cache-${_filename}.json`, 'utf8', function (err, data) {
if (err) {
const errorObj = {
'msg': 'error',
'result': err
msg: 'error',
result: err,
};
res.end(JSON.stringify(errorObj));
} else {
const successObj = {
'msg': 'success',
'result': data ? JSON.parse(data) : ''
msg: 'success',
result: data ? JSON.parse(data) : '',
};
res.end(JSON.stringify(successObj));
@ -120,16 +120,16 @@ cache.groomGet = function(req, res, next) {
});
} else {
const errorObj = {
'msg': 'error',
'result': `no file with name ${_filename}`
msg: 'error',
result: `no file with name ${_filename}`,
};
res.end(JSON.stringify(errorObj));
}
} else {
const errorObj = {
'msg': 'error',
'result': 'no file name provided'
msg: 'error',
result: 'no file name provided',
};
res.end(JSON.stringify(errorObj));
@ -146,15 +146,15 @@ cache.groomDelete = function(req, res, next) {
fs.unlink(`${cache.iguanaDir}/shepherd/cache-${_filename}.json`, function(err) {
if (err) {
const errorObj = {
'msg': 'error',
'result': err
msg: 'error',
result: err,
};
res.end(JSON.stringify(errorObj));
} else {
const successObj = {
'msg': 'success',
'result': 'deleted'
msg: 'success',
result: 'deleted',
};
res.end(JSON.stringify(successObj));
@ -162,16 +162,16 @@ cache.groomDelete = function(req, res, next) {
});
} else {
const errorObj = {
'msg': 'error',
'result': `no file with name ${_filename}`
msg: 'error',
result: `no file with name ${_filename}`,
};
res.end(JSON.stringify(errorObj));
}
} else {
const errorObj = {
'msg': 'error',
'result': 'no file name provided'
msg: 'error',
result: 'no file name provided',
};
res.end(JSON.stringify(errorObj));
@ -179,8 +179,8 @@ cache.groomDelete = function(req, res, next) {
}
cache.groomPost = function(req, res) {
const _filename = req.body.filename,
_payload = req.body.payload;
const _filename = req.body.filename;
const _payload = req.body.payload;
if (!cacheCallInProgress) {
cacheCallInProgress = true;
@ -188,8 +188,8 @@ cache.groomPost = function(req, res) {
if (_filename) {
if (!_payload) {
const errorObj = {
'msg': 'error',
'result': 'no payload provided'
msg: 'error',
result: 'no payload provided',
};
res.end(JSON.stringify(errorObj));
@ -201,16 +201,16 @@ cache.groomPost = function(req, res) {
fs.writeFile(`${cache.iguanaDir}/shepherd/cache-${_filename}.json`, _payload, function (err) {
if (err) {
const errorObj = {
'msg': 'error',
'result': err
msg: 'error',
result: err,
};
cacheCallInProgress = false;
res.end(JSON.stringify(errorObj));
} else {
const successObj = {
'msg': 'success',
'result': 'done'
msg: 'success',
result: 'done',
};
cacheCallInProgress = false;
@ -220,33 +220,33 @@ cache.groomPost = function(req, res) {
}
} else {
const errorObj = {
'msg': 'error',
'result': 'no file name provided'
msg: 'error',
result: 'no file name provided',
};
res.end(JSON.stringify(errorObj));
}
} else {
const errorObj = {
'msg': 'error',
'result': 'another job is in progress'
msg: 'error',
result: 'another job is in progress',
};
res.end(JSON.stringify(errorObj));
}
}
var cacheCallInProgress = false,
cacheGlobLifetime = 600; // sec
var cacheCallInProgress = false;
const cacheGlobLifetime = 600; // sec
// TODO: reset calls' states on new /cache call start
var mock = require('./mock');
var callStack = {},
checkCallStack = function() {
var total = 0;
var callStack = {};
const checkCallStack = function() {
let total = 0;
for (var coin in callStack) {
for (let coin in callStack) {
total =+ callStack[coin];
}
@ -254,13 +254,13 @@ checkCallStack = function() {
cache.dumpCacheBeforeExit();
cacheCallInProgress = false;
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'done',
'resp': 'success'
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'done',
resp: 'success',
},
},
});
}
};
@ -284,45 +284,45 @@ cache.one = function(req, res, next) {
if (fs.existsSync(`${cache.iguanaDir}/shepherd/cache-${req.query.pubkey}.json`)) {
let _data = fs.readFileSync(`${cache.iguanaDir}/shepherd/cache-${req.query.pubkey}.json`, 'utf8');
if (_data) {
inMemCache = JSON.parse(_data);
_data = _data.replace('waiting', 'failed');
cache.dumpCacheBeforeExit();
inMemCache = JSON.parse(_data);
_data = _data.replace('waiting', 'failed');
cache.dumpCacheBeforeExit();
}
}
// TODO: add check to allow only one cache call/sequence in progress
cacheCallInProgress = true;
var sessionKey = req.query.userpass,
coin = req.query.coin,
address = req.query.address,
addresses = req.query.addresses && req.query.addresses.indexOf(':') > -1 ? req.query.addresses.split(':') : null,
pubkey = req.query.pubkey,
mock = req.query.mock,
skipTimeout = req.query.skip,
callsArray = req.query.calls.split(':'),
iguanaCorePort = req.query.port ? req.query.port : cache.appConfig.iguanaCorePort,
errorObj = {
'msg': 'error',
'result': 'error'
},
outObj = {},
pubkey,
writeCache = function(timeStamp) {
if (timeStamp) {
outObj.timestamp = timeStamp;
}
let sessionKey = req.query.userpass;
let coin = req.query.coin;
let address = req.query.address;
let addresses = req.query.addresses && req.query.addresses.indexOf(':') > -1 ? req.query.addresses.split(':') : null;
let pubkey = req.query.pubkey;
let mock = req.query.mock;
let skipTimeout = req.query.skip;
let callsArray = req.query.calls.split(':');
let iguanaCorePort = req.query.port ? req.query.port : cache.appConfig.iguanaCorePort;
let errorObj = {
msg: 'error',
result: 'error'
};
let outObj = {};
const writeCache = function(timeStamp) {
if (timeStamp) {
outObj.timestamp = timeStamp;
}
inMemCache = outObj;
},
checkTimestamp = function(dateToCheck) {
var currentEpochTime = new Date(Date.now()) / 1000,
secondsElapsed = Number(currentEpochTime) - Number(dateToCheck / 1000);
inMemCache = outObj;
};
const checkTimestamp = function(dateToCheck) {
const currentEpochTime = new Date(Date.now()) / 1000;
const secondsElapsed = Number(currentEpochTime) - Number(dateToCheck / 1000);
return Math.floor(secondsElapsed);
},
internalError = false;
return Math.floor(secondsElapsed);
};
let internalError = false;
inMemPubkey = pubkey;
callStack[coin] = 1;
@ -331,8 +331,8 @@ cache.one = function(req, res, next) {
if (!sessionKey) {
const errorObj = {
'msg': 'error',
'result': 'no session key provided'
msg: 'error',
result: 'no session key provided',
};
res.end(JSON.stringify(errorObj));
@ -341,8 +341,8 @@ cache.one = function(req, res, next) {
if (!pubkey) {
const errorObj = {
'msg': 'error',
'result': 'no pubkey provided'
msg: 'error',
result: 'no pubkey provided',
};
res.end(JSON.stringify(errorObj));
@ -352,7 +352,8 @@ cache.one = function(req, res, next) {
console.log('cache-one call started');
function fixJSON(data) {
if (data && data.length) {
if (data &&
data.length) {
try {
const parsedJSON = JSON.parse(data);
@ -381,6 +382,7 @@ cache.one = function(req, res, next) {
outObj = inMemCache;
} else {
const _file = fs.readFileSync(`${cache.iguanaDir}/shepherd/cache-${pubkey}.json`, 'utf8');
console.log('cache one from disk');
outObj = fixJSON(_file);
}
@ -402,28 +404,28 @@ cache.one = function(req, res, next) {
}
res.end(JSON.stringify({
'msg': 'success',
'result': 'call is initiated'
msg: 'success',
result: 'call is initiated',
}));
if (!internalError) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress'
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
},
},
});
function execDEXRequests(coin, address) {
let dexUrls = {
'listunspent': `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/listunspent?userpass=${sessionKey}&symbol=${coin}&address=${address}`,
'listtransactions': `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/listtransactions?userpass=${sessionKey}&count=100&skip=0&symbol=${coin}&address=${address}`,
'getbalance': `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/getbalance?userpass=${sessionKey}&symbol=${coin}&address=${address}`,
'refresh': `http://${cache.appConfig.host}:${iguanaCorePort}/api/basilisk/refresh?userpass=${sessionKey}&symbol=${coin}&address=${address}`
},
_dexUrls = {};
listunspent: `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/listunspent?userpass=${sessionKey}&symbol=${coin}&address=${address}`,
listtransactions: `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/listtransactions?userpass=${sessionKey}&count=100&skip=0&symbol=${coin}&address=${address}`,
getbalance: `http://${cache.appConfig.host}:${iguanaCorePort}/api/dex/getbalance?userpass=${sessionKey}&symbol=${coin}&address=${address}`,
refresh: `http://${cache.appConfig.host}:${iguanaCorePort}/api/basilisk/refresh?userpass=${sessionKey}&symbol=${coin}&address=${address}`
};
let _dexUrls = {};
for (let a = 0; a < callsArray.length; a++) {
_dexUrls[callsArray[a]] = dexUrls[callsArray[a]];
@ -457,39 +459,39 @@ cache.one = function(req, res, next) {
var tooEarly = false;
if (outObj.basilisk[coin][address][key] &&
outObj.basilisk[coin][address][key].timestamp &&
checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime) {
(!skipTimeout && checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime)) {
tooEarly = true;
outObj.basilisk[coin][address][key].status = 'done';
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'done',
'resp': 'too early'
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: key,
coin: coin,
address: address,
status: 'done',
resp: 'too early',
},
},
},
});
}
if (!tooEarly) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'in progress'
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: key,
coin: coin,
address: address,
status: 'in progress',
},
},
},
});
outObj.basilisk[coin][address][key].status = 'in progress';
request({
@ -500,25 +502,25 @@ cache.one = function(req, res, next) {
response.statusCode &&
response.statusCode === 200) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': key,
'coin': coin,
'address': address,
'status': 'done',
'resp': body
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: key,
coin: coin,
address: address,
status: 'done',
resp: body,
},
},
},
});
// basilisk balance fallback
const _parsedJSON = JSON.parse(body);
if (key === 'getbalance' &&
coin === 'KMD'/* &&
coin === 'KMD'/* &&
((_parsedJSON && _parsedJSON.balance === 0) || body === [])*/) {
console.log('fallback to kmd explorer ======>');
request({
@ -559,15 +561,15 @@ cache.one = function(req, res, next) {
callStack[coin]--;
console.log(`${coin} _stack len ${callStack[coin]}`);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'currentStackLength': callStack[coin]
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
currentStackLength: callStack[coin],
},
},
},
});
checkCallStack();
@ -583,15 +585,15 @@ cache.one = function(req, res, next) {
callStack[coin]--;
console.log(`${coin} _stack len ${callStack[coin]}`);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'currentStackLength': callStack[coin]
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
currentStackLength: callStack[coin],
},
},
},
});
checkCallStack();
writeCache();
@ -602,15 +604,15 @@ cache.one = function(req, res, next) {
callStack[coin]--;
console.log(`${coin} _stack len ${callStack[coin]}`);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'currentStackLength': callStack[coin]
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
currentStackLength: callStack[coin],
},
},
},
});
checkCallStack();
}
@ -619,18 +621,18 @@ cache.one = function(req, res, next) {
function parseAddresses(coin, addrArray) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'done',
'resp': addrArray
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: 'getaddressesbyaccount',
coin: coin,
status: 'done',
resp: addrArray,
},
},
},
});
outObj.basilisk[coin].addresses = addrArray;
console.log(addrArray);
@ -649,15 +651,15 @@ cache.one = function(req, res, next) {
console.log(`${coin} stack len ${callStack[coin]}`);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'totalStackLength': callStack[coin]
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
totalStackLength: callStack[coin],
},
},
},
});
async.each(outObj.basilisk[coin].addresses, function(address) {
execDEXRequests(coin, address);
@ -687,17 +689,17 @@ cache.one = function(req, res, next) {
// update all available coin addresses
if (!address) {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'in progress'
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: 'getaddressesbyaccount',
coin: coin,
status: 'in progress',
},
},
},
});
if (coin === 'all') {
@ -711,17 +713,17 @@ cache.one = function(req, res, next) {
response.statusCode === 200) {
console.log(JSON.parse(body).basilisk);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'allcoins',
'status': 'done',
'resp': body
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: 'allcoins',
status: 'done',
resp: body,
},
},
},
});
body = JSON.parse(body);
// basilisk coins
@ -737,17 +739,17 @@ cache.one = function(req, res, next) {
writeCache();
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'method': 'getaddressesbyaccount',
'coin': coin,
'status': 'in progress'
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
method: 'getaddressesbyaccount',
coin: coin,
status: 'in progress',
},
},
},
});
getAddresses(coin);
@ -776,36 +778,36 @@ cache.one = function(req, res, next) {
console.log(`${coin} stack len ${callStack[coin]}`);
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-one',
'status': 'in progress',
'iguanaAPI': {
'totalStackLength': callStack[coin],
'currentStackLength': callStack[coin]
}
}
}
message: {
shepherd: {
method: 'cache-one',
status: 'in progress',
iguanaAPI: {
totalStackLength: callStack[coin],
currentStackLength: callStack[coin],
},
},
},
});
execDEXRequests(coin, address);
}
} else {
cache.io.emit('messages', {
'message': {
'shepherd': {
'method': 'cache-all',
'status': 'done',
'resp': 'internal error'
}
}
message: {
shepherd: {
method: 'cache-all',
status: 'done',
resp: 'internal error',
},
},
});
cacheCallInProgress = false;
}
} else {
res.end(JSON.stringify({
'msg': 'error',
'result': 'another call is in progress already'
msg: 'error',
result: 'another call is in progress already',
}));
}
};

24
routes/ports.js

@ -3,19 +3,20 @@ const assetChainPorts = {
'SUPERNET': '11341',
'REVS': '10196',
'WLC': '12167',
'PANGEA': '10074',
'DEX': '9503',
'JUMBLR': '10789',
'BET': '11222',
'CRYPTO': '10420',
'PANGEA': '14068',
'DEX': '11890',
'JUMBLR': '15106',
'BET': '14250',
'CRYPTO': '8516',
'HODL': '8010',
'SHARK': '14104',
'BOTS': '10151',
'MGW': '15524',
'SHARK': '10114',
'BOTS': '11964',
'MGW': '12386',
'COQUI': '14276',
'MVP': '11676',
'KV': '9747',
'CEAL': '13097',
'MESH': '8400',
'KV': '8299',
'CEAL': '11116',
'MESH': '9455',
'USD': '13967',
'CHF': '15312',
'CAD': '8720',
@ -35,6 +36,7 @@ const assetChainPorts = {
'IDR': '14459',
'HKD': '15409',
'HUF': '13699',
'HRK': '12617',
'GBP': '11505',
'EUR': '8065',
'DKK': '13830',

838
routes/shepherd.js

File diff suppressed because it is too large

3
version

@ -1,2 +1,3 @@
version=0.2.0.1
version=0.2.0.21a
type=e-beta
minversion=0.2.0.2
Loading…
Cancel
Save