+ beautifier

* version info
This commit is contained in:
Taegus
2019-03-03 10:37:19 +01:00
parent de73afd5cd
commit b0cd7d517a
19 changed files with 1648 additions and 1697 deletions

7
.unibeautifyrc.json Normal file
View File

@@ -0,0 +1,7 @@
{
"LANGUAGE_NAME": {
"beautifiers": [
"JS-Beautify"
]
}
}

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Ether-1 Desktop Wallet</title> <title>Ether-1 Desktop Wallet</title>
@@ -17,7 +18,12 @@
<link rel="stylesheet" href="./assets/styles/style.css"> <link rel="stylesheet" href="./assets/styles/style.css">
<link rel="stylesheet" href="./assets/styles/forms.css"> <link rel="stylesheet" href="./assets/styles/forms.css">
<!-- Insert this line above script imports --> <!-- Insert this line above script imports -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script> <script>
if (typeof module === 'object') {
window.module = module;
module = undefined;
}
</script>
<!-- normal script imports etc --> <!-- normal script imports etc -->
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.36/dist/web3.min.js" integrity="sha256-nWBTbvxhJgjslRyuAKJHK+XcZPlCnmIAAMixz6EefVk=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.36/dist/web3.min.js" integrity="sha256-nWBTbvxhJgjslRyuAKJHK+XcZPlCnmIAAMixz6EefVk=" crossorigin="anonymous"></script>
@@ -39,21 +45,21 @@
<script src="./assets/scripts/Chart.js"></script> <script src="./assets/scripts/Chart.js"></script>
<!-- Insert this line after script imports --> <!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script> <script>
if (window.module)
module = window.module;
</script>
</head> </head>
<body> <body>
<script> <script>
var loading_screen = pleaseWait({ var loading_screen = pleaseWait({logo: "assets/images/logo.png", backgroundColor: '#000000', loadingHtml: "<div class='spinner'><div class='bounce bounce1'></div><div class='bounce bounce2'></div><div class='bounce bounce3'></div></div><div class='loadingText'>Starting the node and loading app, please wait...</div>"});
logo: "assets/images/logo.png",
backgroundColor: '#000000',
loadingHtml: "<div class='spinner'><div class='bounce bounce1'></div><div class='bounce bounce2'></div><div class='bounce bounce3'></div></div><div class='loadingText'>Starting the node and loading app, please wait...</div>"
});
$(document).on("onGethReady", function() { $(document).on("onGethReady", function () {
loading_screen.finish(); loading_screen.finish();
}); });
$(window).on("beforeunload", function() { $(window).on("beforeunload", function () {
EthoBlockchain.closeConnection(); EthoBlockchain.closeConnection();
}) })
</script> </script>
@@ -61,22 +67,34 @@
<!-- The sidebar --> <!-- The sidebar -->
<div class="sidebar"> <div class="sidebar">
<div class="sidebarIconWrapper iconSelected" id="mainNavBtnWalletsWrapper" data-tippy="Wallets" data-tippy-delay="500"> <div class="sidebarIconWrapper iconSelected" id="mainNavBtnWalletsWrapper" data-tippy="Wallets" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnWallets" href="#"><i class="fas fa-wallet fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnWallets" href="#">
<i class="fas fa-wallet fa-2x"></i>
</a>
</div> </div>
<div class="sidebarIconWrapper iconSelected" id="mainNavBtnAddressBoookWrapper" data-tippy="Address Book" data-tippy-delay="500"> <div class="sidebarIconWrapper iconSelected" id="mainNavBtnAddressBoookWrapper" data-tippy="Address Book" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnAddressBoook" href="#"><i class="far fa-address-book fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnAddressBoook" href="#">
<i class="far fa-address-book fa-2x"></i>
</a>
</div> </div>
<div class="sidebarIconWrapper" id="mainNavBtnSendWrapper" data-tippy="Send Funds" data-tippy-delay="500"> <div class="sidebarIconWrapper" id="mainNavBtnSendWrapper" data-tippy="Send Funds" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnSend" href="#"><i class="fas fas fa-share-square fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnSend" href="#">
<i class="fas fas fa-share-square fa-2x"></i>
</a>
</div> </div>
<div class="sidebarIconWrapper" id="mainNavBtnTransactionsWrapper" data-tippy="Transactions" data-tippy-delay="500"> <div class="sidebarIconWrapper" id="mainNavBtnTransactionsWrapper" data-tippy="Transactions" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnTransactions" href="#"><i class="fas fa-exchange-alt fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnTransactions" href="#">
<i class="fas fa-exchange-alt fa-2x"></i>
</a>
</div> </div>
<div class="sidebarIconWrapper" id="mainNavBtnMarketsWrapper" data-tippy="Markets" data-tippy-delay="500"> <div class="sidebarIconWrapper" id="mainNavBtnMarketsWrapper" data-tippy="Markets" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnMarkets" href="#"><i class="fas fa-poll fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnMarkets" href="#">
<i class="fas fa-poll fa-2x"></i>
</a>
</div> </div>
<div class="sidebarIconWrapper" id="mainNavBtnSettingsWrapper" data-tippy="Settings" data-tippy-delay="500"> <div class="sidebarIconWrapper" id="mainNavBtnSettingsWrapper" data-tippy="Settings" data-tippy-delay="500">
<a class="sidebarIcon" id="mainNavBtnSettings" href="#"><i class="fas fa-cog fa-2x"></i></a> <a class="sidebarIcon" id="mainNavBtnSettings" href="#">
<i class="fas fa-cog fa-2x"></i>
</a>
</div> </div>
<div id="peerCount"> <div id="peerCount">
Peer Count: 0 Peer Count: 0
@@ -102,7 +120,7 @@
</div> </div>
<!-- The modal for general error --> <!-- The modal for general error -->
<div id="dlgGeneralError" class="modalDialog" data-iziModal-title="Application Error" data-iziModal-subtitle="Something went wrong, don't kill the fish..." data-iziModal-icon="icon-home"> <div id="dlgGeneralError" class="modalDialog" data-izimodal-title="Application Error" data-izimodal-subtitle="Something went wrong, don't kill the fish..." data-izimodal-icon="icon-home">
<div class="modalBody"> <div class="modalBody">
<div class="form-group"> <div class="form-group">
<span id="txtGeneralError"></span> <span id="txtGeneralError"></span>
@@ -112,7 +130,7 @@
</div> </div>
<!-- The modal for general confirmation --> <!-- The modal for general confirmation -->
<div id="dlgGeneralConfirm" class="modalDialog" data-iziModal-title="Confirmation" data-iziModal-subtitle="" data-iziModal-icon="icon-home"> <div id="dlgGeneralConfirm" class="modalDialog" data-izimodal-title="Confirmation" data-izimodal-subtitle="" data-izimodal-icon="icon-home">
<div class="modalBody"> <div class="modalBody">
<div class="form-group"> <div class="form-group">
<span id="txtGeneralConfirm"></span> <span id="txtGeneralConfirm"></span>
@@ -123,16 +141,22 @@
</div> </div>
<!-- The modal for about info --> <!-- The modal for about info -->
<div id="dlgAboutInfo" class="modalDialog" data-iziModal-title="About Ether1 Wallet" data-iziModal-icon="icon-home"> <div id="dlgAboutInfo" class="modalDialog" data-izimodal-title="About Ether1 Wallet" data-izimodal-icon="icon-home">
<div class="modalBody"> <div class="modalBody">
<div class="aboutInfo"> <div class="aboutInfo">
<div class="infoText" id="aboutInfoWallet">Ether1 Wallet</div> <div class="infoText" id="aboutInfoWallet">Ether1 Wallet</div>
<div class="infoText" id="aboutInfoGitHub">GitHub: <a id="urlOpenGitHub" href="https://github.com/taeguscromis/Ether1DesktopWallet">https://github.com/taeguscromis/Ether1DesktopWallet</a></div> <div class="infoText" id="aboutInfoGitHub">GitHub:
<div class="infoText" id="aboutInfoLicence">Made under <a id="urlOpenLicence" href="https://choosealicense.com/licenses/gpl-3.0">GPL v3.0</a> licence</div> <a id="urlOpenGitHub" href="https://github.com/taeguscromis/Ether1DesktopWallet">https://github.com/taeguscromis/Ether1DesktopWallet</a>
<div class="infoText" id="aboutInfoVersion">Version: <span id="versionNumber"></span></div> </div>
<div class="infoText" id="aboutInfoLicence">Made under
<a id="urlOpenLicence" href="https://choosealicense.com/licenses/gpl-3.0">GPL v3.0</a>
licence</div>
<div class="infoText" id="aboutInfoVersion">Version:
<span id="versionNumber"></span></div>
</div> </div>
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnAboutInfoClose">Close</button> <button type="button" class="btn btn-etho btn-dialog-confirm" id="btnAboutInfoClose">Close</button>
</div> </div>
</div> </div>
</body> </body>
</html> </html>

56
main.js
View File

@@ -1,17 +1,17 @@
// Modules to control application life and create native browser window // Modules to control application life and create native browser window
const {app, Menu, ipcMain, BrowserWindow} = require('electron'); const {app, Menu, ipcMain, BrowserWindow} = require("electron");
const singleInstance = require('single-instance'); const singleInstance = require("single-instance");
const path = require('path'); const path = require("path");
const fs = require('fs'); const fs = require("fs");
var locker = new singleInstance('Ether1DesktopWallet'); var locker = new singleInstance("Ether1DesktopWallet");
locker.lock().then(function() { locker.lock().then(function () {
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected. // be closed automatically when the JavaScript object is garbage collected.
mainWindow = null; mainWindow = null;
function createWindow () { function createWindow() {
// Create the browser window. // Create the browser window.
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 1200, width: 1200,
@@ -19,69 +19,67 @@ locker.lock().then(function() {
minWidth: 1100, minWidth: 1100,
minHeight: 700, minHeight: 700,
backgroundColor: "#000000", backgroundColor: "#000000",
icon: 'assets/images/icon.png' icon: "assets/images/icon.png"
}); });
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.loadFile('index.html'); mainWindow.loadFile("index.html");
EthoGeth.startGeth(); EthoGeth.startGeth();
// Open the DevTools. // Open the DevTools.
// mainWindow.webContents.openDevTools() // mainWindow.webContents.openDevTools()
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', function () { mainWindow.on("closed", function () {
// Dereference the window object, usually you would store windows // Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time // in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element. // when you should delete the corresponding element.
mainWindow = null mainWindow = null;
}); });
require('./modules/menu.js'); require("./modules/menu.js");
} }
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.on('ready', createWindow) app.on("ready", createWindow);
// Quit when all windows are closed. // Quit when all windows are closed.
app.on('window-all-closed', function () { app.on("window-all-closed", function () {
// On OS X it is common for applications and their menu bar // On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') { if (process.platform !== "darwin") {
EthoGeth.stopGeth(); EthoGeth.stopGeth();
app.quit(); app.quit();
} }
}) });
app.on('activate', function () { app.on("activate", function () {
// On OS X it's common to re-create a window in the app when the // On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open. // dock icon is clicked and there are no other windows open.
if (mainWindow === null) { if (mainWindow === null) {
createWindow() createWindow();
} }
}) });
// In this file you can include the rest of your app's specific main process // In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here. // code. You can also put them in separate files and require them here.
// listen for request to get template // listen for request to get template
// get the template content from file // get the template content from file
ipcMain.on('getTemplateContent', (event, arg) => { ipcMain.on("getTemplateContent", (event, arg) => {
event.returnValue = fs.readFileSync(path.join(app.getAppPath(), "assets/templates/") + arg, 'utf8'); event.returnValue = fs.readFileSync(path.join(app.getAppPath(), "assets/templates/") + arg, "utf8");
}); });
// quit the app on coomand // quit the app on coomand
ipcMain.on('appQuit', (event, arg) => { ipcMain.on("appQuit", (event, arg) => {
app.quit(); app.quit();
}); });
}).catch(function (err) {
})
.catch(function(err) {
app.quit(); app.quit();
}) });
require('./modules/geth.js'); require("./modules/geth.js");
require('./modules/accounts.js'); require("./modules/accounts.js");
require('./modules/database.js'); require("./modules/database.js");

View File

@@ -1,35 +1,34 @@
const {app, dialog, ipcMain} = require('electron'); const {app, dialog, ipcMain} = require("electron");
const admZip = require('adm-zip'); const admZip = require("adm-zip");
const path = require('path'); const path = require("path");
const fs = require('fs-extra'); const fs = require("fs-extra");
const os = require('os'); const os = require("os");
class Accounts { class Accounts {
constructor() { constructor() {}
}
getKeyStoreLocation() { getKeyStoreLocation() {
switch(os.type()) { switch (os.type()) {
case "Darwin": case "Darwin":
return path.join(os.homedir(), 'Library', 'Ether1', 'keystore'); return path.join(os.homedir(), "Library", "Ether1", "keystore");
break; break;
default: default:
return path.join(process.env.APPDATA, 'Ether1', 'keystore'); return path.join(process.env.APPDATA, "Ether1", "keystore");
} }
} }
exportAccounts() { exportAccounts() {
var savePath = dialog.showSaveDialog({ var savePath = dialog.showSaveDialog({
defaultPath: path.join(app.getPath('documents'), 'accounts.zip') defaultPath: path.join(app.getPath("documents"), "accounts.zip")
}); });
if (savePath) { if (savePath) {
const accPath = EthoAccounts.getKeyStoreLocation(); const accPath = EthoAccounts.getKeyStoreLocation();
fs.readdir(accPath, function(err, files) { fs.readdir(accPath, function (err, files) {
var zip = new admZip(); var zip = new admZip();
for(let filePath of files) { for (let filePath of files) {
zip.addFile(filePath, fs.readFileSync(path.join(accPath, filePath))); zip.addFile(filePath, fs.readFileSync(path.join(accPath, filePath)));
} }
@@ -43,47 +42,44 @@ class Accounts {
var extName = path.extname(accountsFile).toUpperCase(); var extName = path.extname(accountsFile).toUpperCase();
const accPath = EthoAccounts.getKeyStoreLocation(); const accPath = EthoAccounts.getKeyStoreLocation();
if (extName == '.ZIP') { if (extName == ".ZIP") {
var zip = new admZip(accountsFile); var zip = new admZip(accountsFile);
zip.extractAllTo(accPath, true); zip.extractAllTo(accPath, true);
return { success: true, text: "Accounts ware successfully imported."}; return {success: true, text: "Accounts ware successfully imported."};
} else { } else {
try { try {
fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile))); fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
return { success: true, text: "Account was successfully imported."}; return {success: true, text: "Account was successfully imported."};
} catch (err) { } catch (err) {
return { success: false, text: err}; return {success: false, text: err};
} }
} }
} }
saveAccount(account) { saveAccount(account) {
fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), '0x' + account.address), JSON.stringify(account), 'utf8', function() { fs.writeFile(path.join(tEthoAccountshis.getKeyStoreLocation(), "0x" + account.address), JSON.stringify(account), "utf8", function () {
// file was written // file was written
}); });
} }
} }
ipcMain.on('exportAccounts', (event, arg) => { ipcMain.on("exportAccounts", (event, arg) => {
EthoAccounts.exportAccounts(); EthoAccounts.exportAccounts();
}); });
ipcMain.on('importAccounts', (event, arg) => { ipcMain.on("importAccounts", (event, arg) => {
var openPath = dialog.showOpenDialog({ var openPath = dialog.showOpenDialog({
defaultPath: app.getPath('documents'), defaultPath: app.getPath("documents"),
"filters": filters: [
[
{ {
"name": "archive", name: "archive",
"extensions": ["zip"] extensions: ["zip"]
}, }, {
{ name: "json",
"name": "json", extensions: ["json"]
"extensions": ["json"] }, {
}, name: "All",
{ extensions: ["*.*"]
"name": "All",
"extensions": ["*.*"]
} }
] ]
}); });
@@ -95,7 +91,7 @@ ipcMain.on('importAccounts', (event, arg) => {
} }
}); });
ipcMain.on('saveAccount', (event, arg) => { ipcMain.on("saveAccount", (event, arg) => {
EthoAccounts.saveAccount(arg); EthoAccounts.saveAccount(arg);
event.returnValue = true; event.returnValue = true;
}); });

View File

@@ -1,45 +1,54 @@
const {app, dialog, ipcMain} = require('electron'); const {app, dialog, ipcMain} = require("electron");
const storage = require('electron-storage'); const storage = require("electron-storage");
const datastore = require('nedb'); const datastore = require("nedb");
const moment = require('moment'); const moment = require("moment");
const path = require('path'); const path = require("path");
const fs = require('fs'); const fs = require("fs");
const os = require('os'); const os = require("os");
const dbPath = path.join(app.getPath('userData'), 'storage.db'); const dbPath = path.join(app.getPath("userData"), "storage.db");
const db = new datastore({ filename: dbPath }); const db = new datastore({filename: dbPath});
db.loadDatabase(function (err) { db.loadDatabase(function (err) {
// Now commands will be executed // Now commands will be executed
}); });
// index the block field // index the block field
db.ensureIndex({ fieldName: 'block' }, function (err) { db.ensureIndex({
fieldName: "block"
}, function (err) {
// If there was an error, err is not null // If there was an error, err is not null
}); });
// index the txhash field // index the txhash field
db.ensureIndex({ fieldName: 'txhash', unique: true }, function (err) { db.ensureIndex({
fieldName: "txhash",
unique: true
}, function (err) {
// If there was an error, err is not null // If there was an error, err is not null
}); });
ipcMain.on('storeTransaction', (event, arg) => { ipcMain.on("storeTransaction", (event, arg) => {
db.update({ txhash: arg.txhash }, arg, { upsert: true }, function (err, numReplaced, upsert) { db.update({
txhash: arg.txhash
}, arg, {
upsert: true
}, function (err, numReplaced, upsert) {
// do nothing for now // do nothing for now
}); });
}); });
ipcMain.on('getTransactions', (event, arg) => { ipcMain.on("getTransactions", (event, arg) => {
db.find({}).exec(function (err, docs) { db.find({}).exec(function (err, docs) {
ResultData = []; ResultData = [];
// sort the data // sort the data
docs.sort((a, b)=>{ docs.sort((a, b) => {
if ((!b.block) && (a.block)) { if (!b.block && a.block) {
return 1; return 1;
} else if ((b.block) && (!a.block)) { } else if (b.block && !a.block) {
return -1; return -1;
} else if ((!b.block) && (!a.block)) { } else if (!b.block && !a.block) {
return moment(b.timestamp, "YYYY-MM-DD HH:mm:ss").toDate() - moment(a.timestamp, "YYYY-MM-DD HH:mm:ss").toDate(); return (moment(b.timestamp, "YYYY-MM-DD HH:mm:ss").toDate() - moment(a.timestamp, "YYYY-MM-DD HH:mm:ss").toDate());
} else { } else {
return b.block - a.block; return b.block - a.block;
} }
@@ -60,7 +69,7 @@ ipcMain.on('getTransactions', (event, arg) => {
}); });
}); });
ipcMain.on('getJSONFile', (event, arg) => { ipcMain.on("getJSONFile", (event, arg) => {
storage.get(arg, (err, data) => { storage.get(arg, (err, data) => {
if (err) { if (err) {
event.returnValue = null; event.returnValue = null;
@@ -70,44 +79,64 @@ ipcMain.on('getJSONFile', (event, arg) => {
}); });
}); });
ipcMain.on('setJSONFile', (event, arg) => { ipcMain.on("setJSONFile", (event, arg) => {
storage.set(arg.file, arg.data, (err) => { storage.set(arg.file, arg.data, err => {
if (err) { if (err) {
event.returnValue = { success: false, error: err }; event.returnValue = {
success: false,
error: err
};
} else { } else {
event.returnValue = { success: true, error: null }; event.returnValue = {
success: true,
error: null
};
} }
}); });
}); });
ipcMain.on('deleteTransactions', (event, arg) => { ipcMain.on("deleteTransactions", (event, arg) => {
fs.unlink(dbPath, (err) => { fs.unlink(dbPath, err => {
if (err) { if (err) {
event.returnValue = { success: false, error: err }; event.returnValue = {
success: false,
error: err
};
} else { } else {
event.returnValue = { success: true, error: null }; event.returnValue = {
success: true,
error: null
};
} }
}); });
}); });
ipcMain.on('deleteWalletData', (event, arg) => { ipcMain.on("deleteWalletData", (event, arg) => {
fs.unlink(path.join(app.getPath('userData'), 'wallets.json'), (err) => { fs.unlink(path.join(app.getPath("userData"), "wallets.json"), err => {
if (err) { if (err) {
event.returnValue = { success: false, error: err }; event.returnValue = {
success: false,
error: err
};
} else { } else {
event.returnValue = { success: true, error: null }; event.returnValue = {
success: true,
error: null
};
} }
}); });
}); });
ipcMain.on('deleteBlockchainData', (event, arg) => { ipcMain.on("deleteBlockchainData", (event, arg) => {
var deleteFolderRecursive = function(path) { var deleteFolderRecursive = function (path) {
if( fs.existsSync(path) ) { if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file,index){ fs.readdirSync(path).forEach(function (file, index) {
var curPath = path + "/" + file; var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath); deleteFolderRecursive(curPath);
} else { // delete file } else {
// delete file
fs.unlinkSync(curPath); fs.unlinkSync(curPath);
} }
}); });
@@ -116,12 +145,12 @@ ipcMain.on('deleteBlockchainData', (event, arg) => {
}; };
function getBlockchainDataLocation() { function getBlockchainDataLocation() {
switch(os.type()) { switch (os.type()) {
case "Darwin": case "Darwin":
return path.join(os.homedir(), 'Library', 'Ether1', 'geth'); return path.join(os.homedir(), "Library", "Ether1", "geth");
break; break;
default: default:
return path.join(process.env.APPDATA, 'Ether1', 'geth'); return path.join(process.env.APPDATA, "Ether1", "geth");
} }
} }

View File

@@ -1,45 +1,42 @@
const {app, dialog, ipcMain} = require('electron'); const {app, dialog, ipcMain} = require("electron");
const child_process = require('child_process'); const child_process = require("child_process");
const appRoot = require('app-root-path'); const appRoot = require("app-root-path");
const path = require('path'); const path = require("path");
const fs = require('fs'); const fs = require("fs");
const os = require('os'); const os = require("os");
class Geth { class Geth {
constructor() { constructor() {
this.gethProcess = null; this.gethProcess = null;
this.logGethEvents = false; this.logGethEvents = false;
// create the user data dir (needed for MacOS) // create the user data dir (needed for MacOS)
if (!fs.existsSync(app.getPath('userData'))) { if (!fs.existsSync(app.getPath("userData"))) {
fs.mkdirSync(app.getPath('userData')); fs.mkdirSync(app.getPath("userData"));
} }
if (this.logGethEvents) { if (this.logGethEvents) {
this.logStream = fs.createWriteStream(path.join(app.getPath('userData'), 'gethlog.txt'), { flags: 'a' }); this.logStream = fs.createWriteStream(path.join(app.getPath("userData"), "gethlog.txt"), {flags: "a"});
} }
if (appRoot.path.indexOf('app.asar') > -1) { if (appRoot.path.indexOf("app.asar") > -1) {
this.rootPath = path.dirname(appRoot.path); this.rootPath = path.dirname(appRoot.path);
} else { } else {
this.rootPath = appRoot.path; this.rootPath = appRoot.path;
} }
switch(os.type()) { switch (os.type()) {
case "Linux": case "Linux":
this.binaries = path.join(this.rootPath, 'bin', 'linux'); this.binaries = path.join(this.rootPath, "bin", "linux");
break; break;
case "Darwin": case "Darwin":
this.binaries = path.join(this.rootPath, 'bin', 'macos'); this.binaries = path.join(this.rootPath, "bin", "macos");
break; break;
case "Windows_NT": case "Windows_NT":
this.binaries = path.join(this.rootPath, 'bin', 'win'); this.binaries = path.join(this.rootPath, "bin", "win");
break; break;
default: default:
this.binaries = path.join(this.rootPath, 'bin', 'win'); this.binaries = path.join(this.rootPath, "bin", "win");
} }
} }
_writeLog(text) { _writeLog(text) {
@@ -51,22 +48,32 @@ class Geth {
startGeth() { startGeth() {
// get the path of get and execute the child process // get the path of get and execute the child process
try { try {
const gethPath = path.join(this.binaries, 'geth'); const gethPath = path.join(this.binaries, "geth");
this.gethProcess = child_process.spawn(gethPath, ['--ws', '--wsorigins', '*', '--wsaddr', '127.0.0.1', '--wsport', '8546', '--wsapi', 'admin,db,eth,net,miner,personal,web3']); this.gethProcess = child_process.spawn(gethPath, [
"--ws",
"--wsorigins",
"*",
"--wsaddr",
"127.0.0.1",
"--wsport",
"8546",
"--wsapi",
"admin,db,eth,net,miner,personal,web3"
]);
if (!this.gethProcess) { if (!this.gethProcess) {
dialog.showErrorBox("Error starting application", "Geth failed to start!"); dialog.showErrorBox("Error starting application", "Geth failed to start!");
app.quit(); app.quit();
} else { } else {
this.gethProcess.on('error', function(err) { this.gethProcess.on("error", function (err) {
dialog.showErrorBox("Error starting application", "Geth failed to start!"); dialog.showErrorBox("Error starting application", "Geth failed to start!");
app.quit(); app.quit();
}); });
this.gethProcess.stderr.on('data', function(data) { this.gethProcess.stderr.on("data", function (data) {
EthoGeth._writeLog(data.toString() + '\n'); EthoGeth._writeLog(data.toString() + "\n");
}); });
this.gethProcess.stdout.on('data', function(data) { this.gethProcess.stdout.on("data", function (data) {
EthoGeth._writeLog(data.toString() + '\n'); EthoGeth._writeLog(data.toString() + "\n");
}); });
} }
} catch (err) { } catch (err) {
@@ -77,15 +84,15 @@ class Geth {
stopGeth() { stopGeth() {
if (os.type() == "Windows_NT") { if (os.type() == "Windows_NT") {
const gethWrapePath = path.join(this.binaries, 'WrapGeth.exe'); const gethWrapePath = path.join(this.binaries, "WrapGeth.exe");
child_process.spawnSync(gethWrapePath, [this.gethProcess.pid]); child_process.spawnSync(gethWrapePath, [this.gethProcess.pid]);
} else { } else {
this.gethProcess.kill('SIGTERM'); this.gethProcess.kill("SIGTERM");
} }
} }
} }
ipcMain.on('stopGeth', (event, arg) => { ipcMain.on("stopGeth", (event, arg) => {
EthoGeth.stopGeth(); EthoGeth.stopGeth();
}); });

View File

@@ -1,202 +1,170 @@
const {app, Menu, ipcMain} = require('electron'); const {app, Menu, ipcMain} = require("electron");
const open = require("open"); const open = require("open");
const template = [ const template = [
{ {
label: 'File', label: "File",
submenu: [ submenu: [
{ {
label:'Exit', label: "Exit",
click() { click() {
app.quit() app.quit();
} } }
]
},
{
label: 'Edit',
submenu: [
{
role: 'undo'
},
{
role: 'redo'
},
{
type: 'separator'
},
{
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'delete'
},
{
role: 'selectall'
} }
] ]
}, }, {
{ label: "Edit",
label: 'View',
submenu: [ submenu: [
{ {
label: 'Reload', role: "undo"
accelerator: 'CmdOrCtrl+R', }, {
click (item, focusedWindow) { role: "redo"
if (focusedWindow) focusedWindow.reload() }, {
} type: "separator"
}, }, {
{ role: "cut"
label: 'Toggle Developer Tools', }, {
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', role: "copy"
click (item, focusedWindow) { }, {
if (focusedWindow) focusedWindow.webContents.toggleDevTools() role: "paste"
} }, {
}, role: "delete"
{ }, {
type: 'separator' role: "selectall"
},
{
role: 'resetzoom'
},
{
role: 'zoomin'
},
{
role: 'zoomout'
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
} }
] ]
}, }, {
{ label: "View",
role: 'window',
submenu: [ submenu: [
{ {
role: 'minimize' label: "Reload",
}, accelerator: "CmdOrCtrl+R",
{ click(item, focusedWindow) {
role: 'close' if (focusedWindow)
focusedWindow.reload();
}
}, {
label: "Toggle Developer Tools",
accelerator: process.platform === "darwin"
? "Alt+Command+I"
: "Ctrl+Shift+I",
click(item, focusedWindow) {
if (focusedWindow)
focusedWindow.webContents.toggleDevTools();
}
}, {
type: "separator"
}, {
role: "resetzoom"
}, {
role: "zoomin"
}, {
role: "zoomout"
}, {
type: "separator"
}, {
role: "togglefullscreen"
} }
] ]
}, }, {
{ role: "window",
role: 'help',
submenu: [ submenu: [
{ {
label: 'About Ether1 wallet', role: "minimize"
click () { }, {
role: "close"
}
]
}, {
role: "help",
submenu: [
{
label: "About Ether1 wallet",
click() {
var infoData = {}; var infoData = {};
infoData.version = app.getVersion(); infoData.version = app.getVersion();
mainWindow.webContents.send('showAboutDialog', infoData); mainWindow.webContents.send("showAboutDialog", infoData);
} }
}, }, {
{ label: "Ether1 documentation",
label: 'Ether1 documentation', click() {
click () {
open("https://docs.ether1.org"); open("https://docs.ether1.org");
} }
}, }, {
{ label: "Report issue on GitHub",
label: 'Report issue on GitHub', click() {
click () {
open("https://github.com/taeguscromis/Ether1DesktopWallet/issues"); open("https://github.com/taeguscromis/Ether1DesktopWallet/issues");
} }
} }
] ]
} }
] ];
if (process.platform === 'darwin') { if (process.platform === "darwin") {
const name = app.getName() const name = app.getName();
template.unshift({ template.unshift({
label: name, label: name,
submenu: [ submenu: [
{ {
role: 'about' role: "about"
}, }, {
{ type: "separator"
type: 'separator' }, {
}, role: "services",
{
role: 'services',
submenu: [] submenu: []
}, }, {
{ type: "separator"
type: 'separator' }, {
}, role: "hide"
{ }, {
role: 'hide' role: "hideothers"
}, }, {
{ role: "unhide"
role: 'hideothers' }, {
}, type: "separator"
{ }, {
role: 'unhide' role: "quit"
},
{
type: 'separator'
},
{
role: 'quit'
} }
] ]
}) });
// Edit menu. // Edit menu.
template[1].submenu.push( template[1].submenu.push({
{ type: "separator"
type: 'separator' }, {
}, label: "Speech",
{
label: 'Speech',
submenu: [ submenu: [
{ {
role: 'startspeaking' role: "startspeaking"
}, }, {
{ role: "stopspeaking"
role: 'stopspeaking'
} }
] ]
} });
)
// Window menu. // Window menu.
template[3].submenu = [ template[3].submenu = [
{ {
label: 'Close', label: "Close",
accelerator: 'CmdOrCtrl+W', accelerator: "CmdOrCtrl+W",
role: 'close' role: "close"
}, }, {
{ label: "Minimize",
label: 'Minimize', accelerator: "CmdOrCtrl+M",
accelerator: 'CmdOrCtrl+M', role: "minimize"
role: 'minimize' }, {
}, label: "Zoom",
{ role: "zoom"
label: 'Zoom', }, {
role: 'zoom' type: "separator"
}, }, {
{ label: "Bring All to Front",
type: 'separator' role: "front"
},
{
label: 'Bring All to Front',
role: 'front'
} }
] ];
} }
ipcMain.on('openURL', (event, arg) => { ipcMain.on("openURL", (event, arg) => {
open(arg); open(arg);
}); });
const menu = Menu.buildFromTemplate(template) const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu) Menu.setApplicationMenu(menu);

View File

@@ -1,6 +1,6 @@
{ {
"name": "Ether1Wallet", "name": "Ether1Wallet",
"version": "0.2.6", "version": "0.2.7",
"description": "Desktop wallet for Ether1 currency", "description": "Desktop wallet for Ether1 currency",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
@@ -22,41 +22,34 @@
"target": "7z", "target": "7z",
"icon": "build/icon.png", "icon": "build/icon.png",
"artifactName": "Windows-${productName}-${version}.${ext}", "artifactName": "Windows-${productName}-${version}.${ext}",
"extraResources": [ "extraResources": ["bin/win/*"]
"bin/win/*"
]
}, },
"linux": { "linux": {
"target": "tar.gz", "target": "tar.gz",
"icon": "build/icon.icns", "icon": "build/icon.icns",
"artifactName": "Linux-${productName}-${version}.${ext}", "artifactName": "Linux-${productName}-${version}.${ext}",
"extraResources": [ "extraResources": ["bin/linux/*"]
"bin/linux/*"
]
}, },
"mac": { "mac": {
"target": "pkg", "target": "pkg",
"icon": "build/icon.icns", "icon": "build/icon.icns",
"artifactName": "MacOS-${productName}-${version}.${ext}", "artifactName": "MacOS-${productName}-${version}.${ext}",
"extraResources": [ "extraResources": ["bin/macos/*"]
"bin/macos/*"
]
} }
}, },
"repository": "https://github.com/taeguscromis/Ether1DesktopWallet", "repository": "https://github.com/taeguscromis/Ether1DesktopWallet",
"keywords": [ "keywords": [
"Ether1", "Ether1", "Desktop", "Wallet"
"Desktop",
"Wallet"
], ],
"author": "Ether1", "author": "Ether1",
"license": "CC0-1.0", "license": "CC0-1.0",
"dependencies": { "dependencies": {
"@unibeautify/beautifier-js-beautify": "^0.4.0",
"adm-zip": "^0.4.13", "adm-zip": "^0.4.13",
"app-root-path": "^2.1.0", "app-root-path": "^2.1.0",
"electron-storage": "^1.0.7", "electron-storage": "^1.0.7",
"fs-extra": "^7.0.1", "fs-extra": "^7.0.1",
"handlebars": "^4.0.12", "handlebars": "^4.1.0",
"moment": "^2.23.0", "moment": "^2.23.0",
"nedb": "^1.8.0", "nedb": "^1.8.0",
"open": "0.0.5", "open": "0.0.5",
@@ -64,6 +57,9 @@
}, },
"devDependencies": { "devDependencies": {
"electron": "^3.0.12", "electron": "^3.0.12",
"electron-builder": "^20.38.3" "electron-builder": "^20.38.3",
"js-beautify": "^1.9.0",
"unibeautify": "^0.17.0",
"unibeautify-cli": "^0.2.1"
} }
} }

View File

@@ -1,5 +1,5 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Blockchain { class Blockchain {
constructor() { constructor() {
@@ -8,7 +8,7 @@ class Blockchain {
} }
getBlock(blockToGet, includeData, clbError, clbSuccess) { getBlock(blockToGet, includeData, clbError, clbSuccess) {
web3Local.eth.getBlock(blockToGet, includeData, function(error, block) { web3Local.eth.getBlock(blockToGet, includeData, function (error, block) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -18,7 +18,7 @@ class Blockchain {
} }
getAccounts(clbError, clbSuccess) { getAccounts(clbError, clbSuccess) {
web3Local.eth.getAccounts(function(err, res) { web3Local.eth.getAccounts(function (err, res) {
if (err) { if (err) {
clbError(err); clbError(err);
} else { } else {
@@ -32,7 +32,7 @@ class Blockchain {
} }
getTransaction(thxid, clbError, clbSuccess) { getTransaction(thxid, clbError, clbSuccess) {
web3Local.eth.getTransaction(thxid, function( error, result ) { web3Local.eth.getTransaction(thxid, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -42,7 +42,7 @@ class Blockchain {
} }
getTranasctionFee(fromAddress, toAddress, value, clbError, clbSuccess) { getTranasctionFee(fromAddress, toAddress, value, clbError, clbSuccess) {
web3Local.eth.getTransactionCount(fromAddress, function( error, result ) { web3Local.eth.getTransactionCount(fromAddress, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -54,12 +54,12 @@ class Blockchain {
nonce: result nonce: result
}; };
web3Local.eth.estimateGas(RawTransaction, function( error, result ) { web3Local.eth.estimateGas(RawTransaction, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
var usedGas = result + 1; var usedGas = result + 1;
web3Local.eth.getGasPrice(function( error, result ) { web3Local.eth.getGasPrice(function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -73,12 +73,11 @@ class Blockchain {
} }
prepareTransaction(password, fromAddress, toAddress, value, clbError, clbSuccess) { prepareTransaction(password, fromAddress, toAddress, value, clbError, clbSuccess) {
web3Local.eth.personal.unlockAccount(fromAddress, password, function( error, result ) { web3Local.eth.personal.unlockAccount(fromAddress, password, function (error, result) {
if (error) { if (error) {
clbError("Wrong password for the selected address!"); clbError("Wrong password for the selected address!");
} else } else {
{ web3Local.eth.getTransactionCount(fromAddress, "pending", function (error, result) {
web3Local.eth.getTransactionCount(fromAddress, 'pending', function( error, result ) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -90,17 +89,17 @@ class Blockchain {
nonce: result nonce: result
}; };
web3Local.eth.estimateGas(RawTransaction, function( error, result ) { web3Local.eth.estimateGas(RawTransaction, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
RawTransaction.gas = result + 1; RawTransaction.gas = result + 1;
web3Local.eth.getGasPrice(function( error, result ) { web3Local.eth.getGasPrice(function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
RawTransaction.gasPrice = result; RawTransaction.gasPrice = result;
web3Local.eth.signTransaction(RawTransaction, fromAddress, function( error, result ) { web3Local.eth.signTransaction(RawTransaction, fromAddress, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -118,7 +117,7 @@ class Blockchain {
} }
sendTransaction(rawTransaction, clbError, clbSuccess) { sendTransaction(rawTransaction, clbError, clbSuccess) {
web3Local.eth.sendSignedTransaction(rawTransaction, function( error, result ) { web3Local.eth.sendSignedTransaction(rawTransaction, function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -135,7 +134,7 @@ class Blockchain {
var wallets = EthoDatatabse.getWallets(); var wallets = EthoDatatabse.getWallets();
var counter = 0; var counter = 0;
web3Local.eth.getAccounts(function(err, res) { web3Local.eth.getAccounts(function (err, res) {
if (err) { if (err) {
clbError(err); clbError(err);
} else { } else {
@@ -160,11 +159,10 @@ class Blockchain {
} }
}); });
function updateBalance(index) function updateBalance(index) {
{ web3Local.eth.getBalance(rendererData.addressData[index].address, function (error, balance) {
web3Local.eth.getBalance(rendererData.addressData[index].address, function(error, balance) { rendererData.addressData[index].balance = parseFloat(web3Local.utils.fromWei(balance, "ether")).toFixed(2);
rendererData.addressData[index].balance = parseFloat(web3Local.utils.fromWei(balance, 'ether')).toFixed(2); rendererData.sumBalance = rendererData.sumBalance + parseFloat(web3Local.utils.fromWei(balance, "ether"));
rendererData.sumBalance = rendererData.sumBalance + parseFloat(web3Local.utils.fromWei(balance, 'ether'));
if (counter < rendererData.addressData.length - 1) { if (counter < rendererData.addressData.length - 1) {
counter++; counter++;
@@ -184,7 +182,7 @@ class Blockchain {
var wallets = EthoDatatabse.getWallets(); var wallets = EthoDatatabse.getWallets();
var counter = 0; var counter = 0;
web3Local.eth.getAccounts(function(err, res) { web3Local.eth.getAccounts(function (err, res) {
if (err) { if (err) {
clbError(err); clbError(err);
} else { } else {
@@ -206,7 +204,7 @@ class Blockchain {
} }
createNewAccount(password, clbError, clbSuccess) { createNewAccount(password, clbError, clbSuccess) {
web3Local.eth.personal.newAccount(password, function(error, account) { web3Local.eth.personal.newAccount(password, function (error, account) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
@@ -218,17 +216,17 @@ class Blockchain {
importFromPrivateKey(privateKey, password) { importFromPrivateKey(privateKey, password) {
web3Local.eth.accounts.wallet.clear(); web3Local.eth.accounts.wallet.clear();
web3Local.eth.accounts.wallet.add(privateKey); web3Local.eth.accounts.wallet.add(privateKey);
return web3Local.eth.accounts.wallet.encrypt('123456789'); return web3Local.eth.accounts.wallet.encrypt("123456789");
} }
subsribePendingTransactions(clbError, clbSuccess, clbData) { subsribePendingTransactions(clbError, clbSuccess, clbData) {
this.txSubscribe = web3Local.eth.subscribe('pendingTransactions', function(error, result){ this.txSubscribe = web3Local.eth.subscribe("pendingTransactions", function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
clbSuccess(result); clbSuccess(result);
} }
}).on("data", function(transaction){ }).on("data", function (transaction) {
if (clbData) { if (clbData) {
clbData(transaction); clbData(transaction);
} }
@@ -237,24 +235,24 @@ class Blockchain {
unsubsribePendingTransactions(clbError, clbSuccess) { unsubsribePendingTransactions(clbError, clbSuccess) {
if (this.txSubscribe) { if (this.txSubscribe) {
this.txSubscribe.unsubscribe(function(error, success){ this.txSubscribe.unsubscribe(function (error, success) {
if(error) { if (error) {
clbError(error); clbError(error);
} else { } else {
clbSuccess(success) ; clbSuccess(success);
} }
}); });
} }
} }
subsribeNewBlockHeaders(clbError, clbSuccess, clbData) { subsribeNewBlockHeaders(clbError, clbSuccess, clbData) {
this.bhSubscribe = web3Local.eth.subscribe('newBlockHeaders', function(error, result){ this.bhSubscribe = web3Local.eth.subscribe("newBlockHeaders", function (error, result) {
if (error) { if (error) {
clbError(error); clbError(error);
} else { } else {
clbSuccess(result); clbSuccess(result);
} }
}).on("data", function(blockHeader){ }).on("data", function (blockHeader) {
if (clbData) { if (clbData) {
clbData(blockHeader); clbData(blockHeader);
} }
@@ -263,11 +261,11 @@ class Blockchain {
unsubsribeNewBlockHeaders(clbError, clbSuccess) { unsubsribeNewBlockHeaders(clbError, clbSuccess) {
if (this.bhSubscribe) { if (this.bhSubscribe) {
this.bhSubscribe.unsubscribe(function(error, success){ this.bhSubscribe.unsubscribe(function (error, success) {
if(error) { if (error) {
clbError(error); clbError(error);
} else { } else {
clbSuccess(success) ; clbSuccess(success);
} }
}); });
} }

View File

@@ -1,11 +1,11 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Datatabse { class Datatabse {
constructor() {} constructor() {}
getCounters() { getCounters() {
var counters = ipcRenderer.sendSync('getJSONFile', 'counters.json'); var counters = ipcRenderer.sendSync("getJSONFile", "counters.json");
if (counters == null) { if (counters == null) {
counters = {}; counters = {};
@@ -15,45 +15,46 @@ class Datatabse {
} }
setCounters(counters) { setCounters(counters) {
ipcRenderer.sendSync('setJSONFile', ipcRenderer.sendSync("setJSONFile", {
{ file: "counters.json",
file: 'counters.json',
data: counters data: counters
}); });
} }
getWallets() { getWallets() {
var wallets = ipcRenderer.sendSync('getJSONFile', 'wallets.json'); var wallets = ipcRenderer.sendSync("getJSONFile", "wallets.json");
if (!wallets) { if (!wallets) {
wallets = { names: {} }; wallets = {
names: {}
};
} }
return wallets; return wallets;
} }
setWallets(wallets) { setWallets(wallets) {
ipcRenderer.sendSync('setJSONFile', ipcRenderer.sendSync("setJSONFile", {
{ file: "wallets.json",
file: 'wallets.json',
data: wallets data: wallets
}); });
} }
getAddresses() { getAddresses() {
var addressBook = ipcRenderer.sendSync('getJSONFile', 'addresses.json'); var addressBook = ipcRenderer.sendSync("getJSONFile", "addresses.json");
if (!addressBook) { if (!addressBook) {
addressBook = { names: {} }; addressBook = {
names: {}
};
} }
return addressBook; return addressBook;
} }
setAddresses(addresses) { setAddresses(addresses) {
ipcRenderer.sendSync('setJSONFile', ipcRenderer.sendSync("setJSONFile", {
{ file: "addresses.json",
file: 'addresses.json',
data: addresses data: addresses
}); });
} }

View File

@@ -1,5 +1,5 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class MainGUI { class MainGUI {
constructor() { constructor() {
@@ -10,7 +10,7 @@ class MainGUI {
this.appState = newState; this.appState = newState;
$(".sidebarIconWrapper").removeClass("iconSelected"); $(".sidebarIconWrapper").removeClass("iconSelected");
switch(this.appState) { switch (this.appState) {
case "account": case "account":
$("#mainNavBtnWalletsWrapper").addClass("iconSelected"); $("#mainNavBtnWalletsWrapper").addClass("iconSelected");
break; break;
@@ -42,10 +42,10 @@ class MainGUI {
// create and open the dialog // create and open the dialog
$("#dlgGeneralError").iziModal(); $("#dlgGeneralError").iziModal();
$('#dlgGeneralError').iziModal('open'); $("#dlgGeneralError").iziModal("open");
$("#btnGeneralErrorOK").click(function() { $("#btnGeneralErrorOK").click(function () {
$('#dlgGeneralError').iziModal('close'); $("#dlgGeneralError").iziModal("close");
}); });
} }
@@ -54,15 +54,15 @@ class MainGUI {
// create and open the dialog // create and open the dialog
$("#dlgGeneralConfirm").iziModal(); $("#dlgGeneralConfirm").iziModal();
$('#dlgGeneralConfirm').iziModal('open'); $("#dlgGeneralConfirm").iziModal("open");
$("#btnGeneralConfirmYes").click(function() { $("#btnGeneralConfirmYes").click(function () {
$('#dlgGeneralConfirm').iziModal('close'); $("#dlgGeneralConfirm").iziModal("close");
callback(true); callback(true);
}); });
$("#btnGeneralConfirmNo").click(function() { $("#btnGeneralConfirmNo").click(function () {
$('#dlgGeneralConfirm').iziModal('close'); $("#dlgGeneralConfirm").iziModal("close");
callback(false); callback(false);
}); });
} }
@@ -72,23 +72,23 @@ class MainGUI {
// create and open the dialog // create and open the dialog
$("#dlgAboutInfo").iziModal(); $("#dlgAboutInfo").iziModal();
$('#dlgAboutInfo').iziModal('open'); $("#dlgAboutInfo").iziModal("open");
$("#urlOpenLicence, #urlOpenGitHub").off("click").on("click", function(even) { $("#urlOpenLicence, #urlOpenGitHub").off("click").on("click", function (even) {
event.preventDefault(); event.preventDefault();
ipcRenderer.send('openURL', $(this).attr("href")); ipcRenderer.send("openURL", $(this).attr("href"));
}); });
$("#btnAboutInfoClose").off("click").on("click", function(even) { $("#btnAboutInfoClose").off("click").on("click", function (even) {
$('#dlgAboutInfo').iziModal('close'); $("#dlgAboutInfo").iziModal("close");
}); });
} }
renderTemplate(template, data, container) { renderTemplate(template, data, container) {
var template = Handlebars.compile(ipcRenderer.sendSync('getTemplateContent', template)); var template = Handlebars.compile(ipcRenderer.sendSync("getTemplateContent", template));
if (!container) { if (!container) {
container = $("#mainContent") container = $("#mainContent");
} }
container.empty(); container.empty();
@@ -104,37 +104,37 @@ class MainGUI {
} }
} }
ipcRenderer.on('showAboutDialog', function(event, message) { ipcRenderer.on("showAboutDialog", function (event, message) {
EthoMainGUI.showAboutDialog(message); EthoMainGUI.showAboutDialog(message);
}); });
$("#mainNavBtnTransactions").click(function() { $("#mainNavBtnTransactions").click(function () {
EthoTransactions.clearFilter(); EthoTransactions.clearFilter();
EthoMainGUI.changeAppState("transactions"); EthoMainGUI.changeAppState("transactions");
EthoTransactions.renderTransactions(); EthoTransactions.renderTransactions();
}); });
$("#mainNavBtnAddressBoook").click(function() { $("#mainNavBtnAddressBoook").click(function () {
EthoMainGUI.changeAppState("addressBook"); EthoMainGUI.changeAppState("addressBook");
EthoAddressBook.renderAddressBook(); EthoAddressBook.renderAddressBook();
}); });
$("#mainNavBtnSend").click(function() { $("#mainNavBtnSend").click(function () {
EthoMainGUI.changeAppState("send"); EthoMainGUI.changeAppState("send");
EthoSend.renderSendState(); EthoSend.renderSendState();
}); });
$("#mainNavBtnWallets").click(function() { $("#mainNavBtnWallets").click(function () {
EthoMainGUI.changeAppState("account"); EthoMainGUI.changeAppState("account");
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
}); });
$("#mainNavBtnMarkets").click(function() { $("#mainNavBtnMarkets").click(function () {
EthoMainGUI.changeAppState("markets"); EthoMainGUI.changeAppState("markets");
EthoMarkets.renderMarkets(); EthoMarkets.renderMarkets();
}); });
$("#mainNavBtnSettings").click(function() { $("#mainNavBtnSettings").click(function () {
EthoMainGUI.changeAppState("settings"); EthoMainGUI.changeAppState("settings");
EthoSettings.renderSettingsState(); EthoSettings.renderSettingsState();
}); });

View File

@@ -1,4 +1,4 @@
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Markets { class Markets {
constructor() {} constructor() {}
@@ -7,7 +7,7 @@ class Markets {
EthoMainGUI.renderTemplate("markets.html", {}); EthoMainGUI.renderTemplate("markets.html", {});
$(document).trigger("render_markets"); $(document).trigger("render_markets");
$.getJSON("https://api.coingecko.com/api/v3/coins/ether-1?sparkline=true", function( data ) { $.getJSON("https://api.coingecko.com/api/v3/coins/ether-1?sparkline=true", function (data) {
$("#ETHOToUSD").html(data.market_data.current_price.usd.toFixed(5) + " $"); $("#ETHOToUSD").html(data.market_data.current_price.usd.toFixed(5) + " $");
$("#ETHOToBTC").html(data.market_data.current_price.btc.toFixed(8)) + " sats"; $("#ETHOToBTC").html(data.market_data.current_price.btc.toFixed(8)) + " sats";
$("#marketcap").html(data.market_data.market_cap.usd.toFixed(0) + " $ (" + data.market_cap_rank + ")"); $("#marketcap").html(data.market_data.market_cap.usd.toFixed(0) + " $ (" + data.market_cap_rank + ")");
@@ -18,18 +18,20 @@ class Markets {
$("#changeMarketcap").html("high 24h: " + data.market_data.high_24h.usd.toFixed(5) + " $"); $("#changeMarketcap").html("high 24h: " + data.market_data.high_24h.usd.toFixed(5) + " $");
$("#changeVolume").html("all time high: " + data.market_data.ath.usd.toFixed(5) + " $"); $("#changeVolume").html("all time high: " + data.market_data.ath.usd.toFixed(5) + " $");
new Chart(document.getElementById('chartMarketPriceCanvas'), { new Chart(document.getElementById("chartMarketPriceCanvas"), {
type: 'line', type: "line",
data: { data: {
labels: data.market_data.sparkline_7d.price, labels: data.market_data.sparkline_7d.price,
datasets: [{ datasets: [
{
data: data.market_data.sparkline_7d.price, data: data.market_data.sparkline_7d.price,
backgroundColor: 'rgb(122,19,54,0.1)', backgroundColor: "rgb(122,19,54,0.1)",
fill: true, fill: true,
borderWidth: 3, borderWidth: 3,
pointRadius: 0, pointRadius: 0,
borderColor: '#7A1336' borderColor: "#7A1336"
}] }
]
}, },
options: { options: {
animation: false, animation: false,
@@ -42,22 +44,26 @@ class Markets {
} }
}, },
scales: { scales: {
yAxes: [{ yAxes: [
{
ticks: { ticks: {
maxTicksLimit: 5, maxTicksLimit: 5,
beginAtZero:true, beginAtZero: true,
fontSize: 10, fontSize: 10,
callback: function(value, index, values) { callback: function (value, index, values) {
return value.toFixed(2) + ' $'; return value.toFixed(2) + " $";
} }
}, },
gridLines: { gridLines: {
color: 'rgba(255,255,255,.08)' color: "rgba(255,255,255,.08)"
} }
}], }
xAxes: [{ ],
xAxes: [
{
display: false display: false
}] }
]
} }
} }
}); });

View File

@@ -1,20 +1,16 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class SendTransaction { class SendTransaction {
constructor() {} constructor() {}
renderSendState() { renderSendState() {
EthoBlockchain.getAccountsData( EthoBlockchain.getAccountsData(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
EthoMainGUI.renderTemplate("send.html", data); EthoMainGUI.renderTemplate("send.html", data);
$(document).trigger("render_send"); $(document).trigger("render_send");
} });
);
} }
validateSendForm() { validateSendForm() {
@@ -59,27 +55,27 @@ class SendTransaction {
} }
} }
$(document).on("render_send", function() { $(document).on("render_send", function () {
$('select').formSelect( {classes: "fromAddressSelect"}); $("select").formSelect({classes: "fromAddressSelect"});
$("#sendFromAddress").on("change", function() { $("#sendFromAddress").on("change", function () {
var optionText = $(this).find("option:selected").text(); var optionText = $(this).find("option:selected").text();
var addrName = optionText.substr(0, optionText.indexOf('-')); var addrName = optionText.substr(0, optionText.indexOf("-"));
var addrValue = optionText.substr(optionText.indexOf("-") + 1); var addrValue = optionText.substr(optionText.indexOf("-") + 1);
$(".fromAddressSelect input").val(addrValue.trim()); $(".fromAddressSelect input").val(addrValue.trim());
$("#sendFromAddressName").html(addrName.trim()); $("#sendFromAddressName").html(addrName.trim());
web3Local.eth.getBalance(this.value, function(error, balance) { web3Local.eth.getBalance(this.value, function (error, balance) {
$("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, 'ether'))); $("#sendMaxAmmount").html(parseFloat(web3Local.utils.fromWei(balance, "ether")));
}); });
}); });
$("#btnSendAll").off('click').on('click', function() { $("#btnSendAll").off("click").on("click", function () {
$("#sendAmmount").focus(); $("#sendAmmount").focus();
$("#sendAmmount").val($("#sendMaxAmmount").html()); $("#sendAmmount").val($("#sendMaxAmmount").html());
}); });
$("#sendToAddress").off('input').on('input', function() { $("#sendToAddress").off("input").on("input", function () {
var addressName = null; var addressName = null;
$("#sendToAddressName").html(""); $("#sendToAddressName").html("");
addressName = EthoAddressBook.getAddressName($("#sendToAddress").val()); addressName = EthoAddressBook.getAddressName($("#sendToAddress").val());
@@ -91,151 +87,121 @@ $(document).on("render_send", function() {
$("#sendToAddressName").html(addressName); $("#sendToAddressName").html(addressName);
}); });
$("#btnLookForToAddress").off('click').on('click', function() { $("#btnLookForToAddress").off("click").on("click", function () {
EthoBlockchain.getAddressListData( EthoBlockchain.getAddressListData(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (addressList) {
function(addressList) {
var addressBook = EthoAddressBook.getAddressList(); var addressBook = EthoAddressBook.getAddressList();
for (var key in addressBook) { for (var key in addressBook) {
if (addressBook.hasOwnProperty(key)) { if (addressBook.hasOwnProperty(key)) {
var adddressObject = {}; var adddressObject = {};
adddressObject.address = key adddressObject.address = key;
adddressObject.name = addressBook[key]; adddressObject.name = addressBook[key];
addressList.addressData.push(adddressObject); addressList.addressData.push(adddressObject);
} }
} }
$("#dlgAddressList").iziModal({ width: "800px" }); $("#dlgAddressList").iziModal({width: "800px"});
EthoMainGUI.renderTemplate("addresslist.html", addressList, $("#dlgAddressListBody")); EthoMainGUI.renderTemplate("addresslist.html", addressList, $("#dlgAddressListBody"));
$('#dlgAddressList').iziModal('open'); $("#dlgAddressList").iziModal("open");
$(".btnSelectToAddress").off('click').on('click', function() { $(".btnSelectToAddress").off("click").on("click", function () {
$("#sendToAddressName").html($(this).attr('data-name')); $("#sendToAddressName").html($(this).attr("data-name"));
$("#sendToAddress").val($(this).attr('data-wallet')); $("#sendToAddress").val($(this).attr("data-wallet"));
$('#dlgAddressList').iziModal('close'); $("#dlgAddressList").iziModal("close");
}); });
$('#addressListFilter').off('input').on('input',function(e){ $("#addressListFilter").off("input").on("input", function (e) {
EthoUtils.filterTable($("#addressTable"), $('#addressListFilter').val()); EthoUtils.filterTable($("#addressTable"), $("#addressListFilter").val());
}); });
$("#btnClearSearchField").off('click').on('click', function() { $("#btnClearSearchField").off("click").on("click", function () {
EthoUtils.filterTable($("#addressTable"), ""); EthoUtils.filterTable($("#addressTable"), "");
$('#addressListFilter').val("") $("#addressListFilter").val("");
});
}); });
}
);
}); });
$("#btnAddToAddressBook").off('click').on('click', function() { $("#btnAddToAddressBook").off("click").on("click", function () {
if (EthoBlockchain.isAddress($("#sendToAddress").val())) { if (EthoBlockchain.isAddress($("#sendToAddress").val())) {
$("#dlgAddAddressToBook").iziModal(); $("#dlgAddAddressToBook").iziModal();
$("#inputAddressName").val(""); $("#inputAddressName").val("");
$('#dlgAddAddressToBook').iziModal('open'); $("#dlgAddAddressToBook").iziModal("open");
function doAddAddressToAddressBook() { function doAddAddressToAddressBook() {
EthoAddressBook.setAddressName($("#sendToAddress").val(), $("#inputAddressName").val()); EthoAddressBook.setAddressName($("#sendToAddress").val(), $("#inputAddressName").val());
$('#dlgAddAddressToBook').iziModal('close'); $("#dlgAddAddressToBook").iziModal("close");
iziToast.success({ iziToast.success({title: "Success", message: "Address was added to address book", position: "topRight", timeout: 2000});
title: 'Success',
message: 'Address was added to address book',
position: 'topRight',
timeout: 2000
});
} }
} else { } else {
EthoMainGUI.showGeneralError("Recipient address is not valid!"); EthoMainGUI.showGeneralError("Recipient address is not valid!");
} }
$("#btnAddAddressToBookConfirm").off('click').on('click', function() { $("#btnAddAddressToBookConfirm").off("click").on("click", function () {
doAddAddressToAddressBook(); doAddAddressToAddressBook();
}); });
$("#dlgAddAddressToBook").off('keypress').on('keypress', function(e) { $("#dlgAddAddressToBook").off("keypress").on("keypress", function (e) {
if(e.which == 13) { if (e.which == 13) {
doAddAddressToAddressBook(); doAddAddressToAddressBook();
} }
}); });
}); });
$("#btnSendTransaction").off("click").on("click", function () {
$("#btnSendTransaction").off('click').on('click', function() {
if (EthoSend.validateSendForm()) { if (EthoSend.validateSendForm()) {
EthoBlockchain.getTranasctionFee($("#sendFromAddress").val(), $("#sendToAddress").val(), $("#sendAmmount").val(), EthoBlockchain.getTranasctionFee($("#sendFromAddress").val(), $("#sendToAddress").val(), $("#sendAmmount").val(), function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
$("#dlgSendWalletPassword").iziModal(); $("#dlgSendWalletPassword").iziModal();
$("#walletPassword").val(""); $("#walletPassword").val("");
$("#fromAddressInfo").html($("#sendFromAddress").val()); $("#fromAddressInfo").html($("#sendFromAddress").val());
$("#toAddressInfo").html($("#sendToAddress").val()); $("#toAddressInfo").html($("#sendToAddress").val());
$("#valueToSendInfo").html($("#sendAmmount").val()); $("#valueToSendInfo").html($("#sendAmmount").val());
$("#feeToPayInfo").html(parseFloat(web3Local.utils.fromWei(data.toString(), 'ether'))); $("#feeToPayInfo").html(parseFloat(web3Local.utils.fromWei(data.toString(), "ether")));
$('#dlgSendWalletPassword').iziModal('open'); $("#dlgSendWalletPassword").iziModal("open");
function doSendTransaction() { function doSendTransaction() {
$('#dlgSendWalletPassword').iziModal('close'); $("#dlgSendWalletPassword").iziModal("close");
EthoBlockchain.prepareTransaction( EthoBlockchain.prepareTransaction($("#walletPassword").val(), $("#sendFromAddress").val(), $("#sendToAddress").val(), $("#sendAmmount").val(), function (error) {
$("#walletPassword").val(),
$("#sendFromAddress").val(),
$("#sendToAddress").val(),
$("#sendAmmount").val(),
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) { EthoBlockchain.sendTransaction(data.raw, function (error) {
EthoBlockchain.sendTransaction(data.raw,
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
EthoSend.resetSendForm(); EthoSend.resetSendForm();
iziToast.success({ iziToast.success({title: "Sent", message: "Transaction was successfully sent to the chain", position: "topRight", timeout: 5000});
title: 'Sent',
message: 'Transaction was successfully sent to the chain',
position: 'topRight',
timeout: 5000
});
EthoBlockchain.getTransaction(data, EthoBlockchain.getTransaction(data, function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (transaction) {
function(transaction) { ipcRenderer.send("storeTransaction", {
ipcRenderer.send('storeTransaction', {
block: transaction.blockNumber, block: transaction.blockNumber,
txhash: transaction.hash.toLowerCase(), txhash: transaction.hash.toLowerCase(),
fromaddr: transaction.from.toLowerCase(), fromaddr: transaction.from.toLowerCase(),
timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), timestamp: moment().format("YYYY-MM-DD HH:mm:ss"),
toaddr: transaction.to.toLowerCase(), toaddr: transaction.to.toLowerCase(),
value: transaction.value value: transaction.value
}); });
} });
); });
} });
);
}
);
} }
$("#btnSendWalletPasswordConfirm").off('click').on('click', function() { $("#btnSendWalletPasswordConfirm").off("click").on("click", function () {
doSendTransaction(); doSendTransaction();
}); });
$("#dlgSendWalletPassword").off('keypress').on('keypress', function(e) { $("#dlgSendWalletPassword").off("keypress").on("keypress", function (e) {
if(e.which == 13) { if (e.which == 13) {
doSendTransaction(); doSendTransaction();
} }
}); });
} });
);
} }
}); });
}); });

View File

@@ -1,5 +1,5 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Settings { class Settings {
constructor() {} constructor() {}
@@ -10,10 +10,10 @@ class Settings {
} }
} }
$(document).on("render_settings", function() { $(document).on("render_settings", function () {
$("#btnSettingsCleanTransactions").off('click').on('click', function() { $("#btnSettingsCleanTransactions").off("click").on("click", function () {
if (isFullySynced) { if (isFullySynced) {
EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) { EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function (result) {
if (result) { if (result) {
if (EthoTransactions.getIsSyncing()) { if (EthoTransactions.getIsSyncing()) {
EthoMainGUI.showGeneralError("Transactions sync is currently in progress"); EthoMainGUI.showGeneralError("Transactions sync is currently in progress");
@@ -24,23 +24,18 @@ $(document).on("render_settings", function() {
var counters = EthoDatatabse.getCounters(); var counters = EthoDatatabse.getCounters();
counters.transactions = 0; counters.transactions = 0;
EthoDatatabse.setCounters(counters); EthoDatatabse.setCounters(counters);
ipcResult = ipcRenderer.sendSync('deleteTransactions', null); ipcResult = ipcRenderer.sendSync("deleteTransactions", null);
if (ipcResult.success) { if (ipcResult.success) {
// sync all the transactions to the current block // sync all the transactions to the current block
web3Local.eth.getBlock("latest", function(error, localBlock) { web3Local.eth.getBlock("latest", function (error, localBlock) {
if (error) { if (error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
} else { } else {
EthoTransactions.enableKeepInSync(); EthoTransactions.enableKeepInSync();
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number); EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
iziToast.success({ iziToast.success({title: "Success", message: "Transactions are being resynced", position: "topRight", timeout: 5000});
title: 'Success',
message: 'Transactions are being resynced',
position: 'topRight',
timeout: 5000
});
} }
}); });
} else { } else {
@@ -50,27 +45,17 @@ $(document).on("render_settings", function() {
} }
}); });
} else { } else {
iziToast.info({ iziToast.info({title: "Wait...", message: "You need to be fully sync before cleaning transactions", position: "topRight", timeout: 5000});
title: 'Wait...',
message: 'You need to be fully sync before cleaning transactions',
position: 'topRight',
timeout: 5000
});
} }
}); });
$("#btnSettingsCleanWallets").off('click').on('click', function() { $("#btnSettingsCleanWallets").off("click").on("click", function () {
EthoMainGUI.showGeneralConfirmation("Do you really want to delete wallets data?", function(result) { EthoMainGUI.showGeneralConfirmation("Do you really want to delete wallets data?", function (result) {
if (result) { if (result) {
ipcResult = ipcRenderer.sendSync('deleteWalletData', null); ipcResult = ipcRenderer.sendSync("deleteWalletData", null);
if (ipcResult.success) { if (ipcResult.success) {
iziToast.success({ iziToast.success({title: "Success", message: "Wallet names were succesfully cleaned", position: "topRight", timeout: 5000});
title: 'Success',
message: 'Wallet names were succesfully cleaned',
position: 'topRight',
timeout: 5000
});
} else { } else {
EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error); EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
} }
@@ -78,24 +63,20 @@ $(document).on("render_settings", function() {
}); });
}); });
$("#btnSettingsCleanBlockchain").off('click').on('click', function() { $("#btnSettingsCleanBlockchain").off("click").on("click", function () {
EthoMainGUI.showGeneralConfirmation("Do you really want to delete the blockchain data? Wallet will close and you will need to restart it!", function(result) { EthoMainGUI.showGeneralConfirmation("Do you really want to delete the blockchain data? Wallet will close and you will need to restart it!", function (result) {
if (result) { if (result) {
var loading_screen = pleaseWait({ var loading_screen = pleaseWait({logo: "assets/images/logo.png", backgroundColor: "#000000", loadingHtml: "<div class='spinner'><div class='bounce bounce1'></div><div class='bounce bounce2'></div><div class='bounce bounce3'></div></div><div class='loadingText'>Deleting blockchain data, wallet will automatically close, please wait...</div>"});
logo: "assets/images/logo.png",
backgroundColor: '#000000',
loadingHtml: "<div class='spinner'><div class='bounce bounce1'></div><div class='bounce bounce2'></div><div class='bounce bounce3'></div></div><div class='loadingText'>Deleting blockchain data, wallet will automatically close, please wait...</div>"
});
setTimeout(() => { setTimeout(() => {
// first stop the geth process // first stop the geth process
ipcResult = ipcRenderer.send('stopGeth', null); ipcResult = ipcRenderer.send("stopGeth", null);
setTimeout(() => { setTimeout(() => {
// delete the blockchain date async and wait for 5 seconds // delete the blockchain date async and wait for 5 seconds
ipcResult = ipcRenderer.sendSync('deleteBlockchainData', null); ipcResult = ipcRenderer.sendSync("deleteBlockchainData", null);
// finally quit the application // finally quit the application
ipcResult = ipcRenderer.send('appQuit', null); ipcResult = ipcRenderer.send("appQuit", null);
}, 5000); }, 5000);
}, 2000); }, 2000);
} }

View File

@@ -1,18 +1,17 @@
// In renderer process (web page). // In renderer process (web page).
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
// Set the provider you want from Web3.providers // Set the provider you want from Web3.providers
SyncProgress = new ProgressBar.Line('#syncProgress', SyncProgress = new ProgressBar.Line("#syncProgress", {
{
strokeWidth: 6, strokeWidth: 6,
easing: 'easeInOut', easing: "easeInOut",
duration: 1400, duration: 1400,
color: "#7A1336", color: "#7A1336",
trailColor: '#eee', trailColor: "#eee",
trailWidth: 1, trailWidth: 1,
text: { text: {
style: { style: {
color: '#bbb', color: "#bbb",
position: "absolute", position: "absolute",
left: "50%", left: "50%",
top: "-1px", top: "-1px",
@@ -23,17 +22,20 @@ SyncProgress = new ProgressBar.Line('#syncProgress',
}, },
autoStyleContainer: false autoStyleContainer: false
}, },
from: {color: '#FFEA82'}, from: {
to: {color: '#ED6A5A'} color: "#FFEA82"
},
to: {
color: "#ED6A5A"
}
}); });
// set initial value for the progress text // set initial value for the progress text
SyncProgress.setText("Waiting for blockchain, please wait..."); SyncProgress.setText("Waiting for blockchain, please wait...");
isFullySynced = false; isFullySynced = false;
var peerCountInterval = setInterval(function() var peerCountInterval = setInterval(function () {
{ web3Local.eth.net.getPeerCount(function (error, count) {
web3Local.eth.net.getPeerCount(function(error, count) {
$("#peerCount").html(vsprintf("Peer Count: %d", [count])); $("#peerCount").html(vsprintf("Peer Count: %d", [count]));
}); });
}, 5000); }, 5000);
@@ -42,25 +44,23 @@ function StartSyncProcess() {
var alreadyCatchedUp = false; var alreadyCatchedUp = false;
var nodeSyncInterval = null; var nodeSyncInterval = null;
var subscription = web3Local.eth.subscribe('syncing', function(error, sync){ var subscription = web3Local.eth.subscribe("syncing", function (error, sync) {
if (!error) { if (!error) {
if (!sync) { if (!sync) {
if (nodeSyncInterval) { if (nodeSyncInterval) {
clearInterval(nodeSyncInterval); clearInterval(nodeSyncInterval);
} }
nodeSyncInterval = setInterval(function() nodeSyncInterval = setInterval(function () {
{ web3Local.eth.getBlock("latest", function (error, localBlock) {
web3Local.eth.getBlock("latest", function(error, localBlock) {
if (!error) { if (!error) {
if (localBlock.number > 0) { if (localBlock.number > 0) {
if (!EthoTransactions.getIsSyncing()) { if (!EthoTransactions.getIsSyncing()) {
SyncProgress.animate(1); SyncProgress.animate(1);
SyncProgress.setText(vsprintf('%d/%d (100%%)', [localBlock.number, localBlock.number])); SyncProgress.setText(vsprintf("%d/%d (100%%)", [localBlock.number, localBlock.number]));
} }
if (alreadyCatchedUp == false) if (alreadyCatchedUp == false) {
{
// clear the repeat interval and render wallets // clear the repeat interval and render wallets
$(document).trigger("onNewAccountTransaction"); $(document).trigger("onNewAccountTransaction");
alreadyCatchedUp = true; alreadyCatchedUp = true;
@@ -84,19 +84,26 @@ function StartSyncProcess() {
} else { } else {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
} }
}).on("data", function(sync){ }).on("data", function (sync) {
if ((sync) && (sync.HighestBlock > 0)) { if (sync && sync.HighestBlock > 0) {
SyncProgress.animate(sync.CurrentBlock / sync.HighestBlock); SyncProgress.animate(sync.CurrentBlock / sync.HighestBlock);
SyncProgress.setText(vsprintf('%d/%d (%d%%)', [sync.CurrentBlock, sync.HighestBlock, Math.floor(sync.CurrentBlock / sync.HighestBlock * 100)])); SyncProgress.setText(vsprintf("%d/%d (%d%%)", [
sync.CurrentBlock,
sync.HighestBlock,
Math.floor(sync.CurrentBlock / sync.HighestBlock * 100)
]));
} }
}).on("changed", function(isSyncing){ }).on("changed", function (isSyncing) {
if(isSyncing) { if (isSyncing) {
nodeSyncInterval = setInterval(function() nodeSyncInterval = setInterval(function () {
{ web3Local.eth.isSyncing(function (error, sync) {
web3Local.eth.isSyncing(function(error, sync){ if (!error && sync) {
if ((!error) && (sync)) {
SyncProgress.animate(sync.currentBlock / sync.highestBlock); SyncProgress.animate(sync.currentBlock / sync.highestBlock);
SyncProgress.setText(vsprintf('%d/%d (%d%%)', [sync.currentBlock, sync.highestBlock, Math.floor(sync.currentBlock / sync.highestBlock * 100)])); SyncProgress.setText(vsprintf("%d/%d (%d%%)", [
sync.currentBlock,
sync.highestBlock,
Math.floor(sync.currentBlock / sync.highestBlock * 100)
]));
} else if (error) { } else if (error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
} }
@@ -110,20 +117,18 @@ function StartSyncProcess() {
}); });
} }
var InitWeb3 = setInterval(function() var InitWeb3 = setInterval(function () {
{
try { try {
web3Local = new Web3(new Web3.providers.WebsocketProvider('ws://localhost:8546')); web3Local = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
web3Local.eth.net.isListening(function(error, success) { web3Local.eth.net.isListening(function (error, success) {
if (!error) { if (!error) {
$(document).trigger("onGethReady"); $(document).trigger("onGethReady");
clearInterval(InitWeb3); clearInterval(InitWeb3);
StartSyncProcess(); StartSyncProcess();
} }
}); });
} } catch (err) {
catch(err) {
EthoMainGUI.showGeneralError(err); EthoMainGUI.showGeneralError(err);
} }
}, 2000); }, 2000);

View File

@@ -5,35 +5,40 @@ class tableTransactions {
initialize(id, data) { initialize(id, data) {
// register the sort datetime format // register the sort datetime format
$.fn.dataTable.moment('MMM Do YYYY HH:mm:ss'); $.fn.dataTable.moment("MMM Do YYYY HH:mm:ss");
var namesType = $.fn.dataTable.absoluteOrderNumber( var namesType = $.fn.dataTable.absoluteOrderNumber([
[ {
{ value: null, position: 'top' } value: null,
position: "top"
}
]); ]);
// render the transactions // render the transactions
$(id).DataTable({ $(id).DataTable({
"dom": 'Bfrtip', dom: "Bfrtip",
"paging": false, paging: false,
"scrollY": "calc(100vh - 115px)", scrollY: "calc(100vh - 115px)",
"responsive": true, responsive: true,
"processing": true, processing: true,
"order": [[ 1, "desc" ]], order: [
"data": data, [1, "desc"]
"oSearch": {"sSearch": EthoTransactions.getFilter() }, ],
"buttons": data: data,
[ oSearch: {
sSearch: EthoTransactions.getFilter()
},
buttons: [
{ {
text: '<i class="fas fa-sync-alt"></i>', text: '<i class="fas fa-sync-alt"></i>',
action: function ( e, dt, node, config ) { action: function (e, dt, node, config) {
EthoTransactions.renderTransactions(); EthoTransactions.renderTransactions();
} }
} }
], ],
"columnDefs": [ columnDefs: [
{ {
"targets": 0, targets: 0,
"render": function ( data, type, row ) { render: function (data, type, row) {
if (data == 0) { if (data == 0) {
return '<i class="fas fa-arrow-left"></i>'; return '<i class="fas fa-arrow-left"></i>';
} else if (data == 1) { } else if (data == 1) {
@@ -42,28 +47,24 @@ class tableTransactions {
return '<i class="fas fa-arrows-alt-h"></i>'; return '<i class="fas fa-arrows-alt-h"></i>';
} }
} }
}, }, {
{ className: "transactionsBlockNum",
"className": "transactionsBlockNum", type: namesType,
"type": namesType, targets: 1
"targets": 1 }, {
}, targets: 2,
{ render: function (data, type, row) {
"targets": 2,
"render": function ( data, type, row ) {
return moment(data, "YYYY-MM-DD HH:mm:ss").format("MMM Do YYYY HH:mm:ss"); return moment(data, "YYYY-MM-DD HH:mm:ss").format("MMM Do YYYY HH:mm:ss");
} }
}, }, {
{ targets: 5,
"targets": 5, render: function (data, type, row) {
"render": function ( data, type, row ) { return parseFloat(web3Local.utils.fromWei(EthoUtils.toFixed(parseFloat(data)).toString(), "ether")).toFixed(2);
return parseFloat(web3Local.utils.fromWei(EthoUtils.toFixed(parseFloat(data)).toString(), 'ether')).toFixed(2);
} }
}, }, {
{ targets: 6,
"targets": 6, defaultContent: "",
"defaultContent": "", render: function (data, type, row) {
"render": function ( data, type, row ) {
if (row[1]) { if (row[1]) {
return '<i class="fas fa-check"></i>'; return '<i class="fas fa-check"></i>';
} else { } else {
@@ -72,7 +73,7 @@ class tableTransactions {
} }
} }
], ],
"drawCallback": function( settings ) { drawCallback: function (settings) {
$("#loadingTransactionsOverlay").css("display", "none"); $("#loadingTransactionsOverlay").css("display", "none");
} }
}); });

View File

@@ -1,4 +1,4 @@
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Transactions { class Transactions {
constructor() { constructor() {
@@ -40,12 +40,16 @@ class Transactions {
SyncProgress.setText(vsprintf("Syncing address transactions %d/%d, please wait...", [counter, addressList.length])); SyncProgress.setText(vsprintf("Syncing address transactions %d/%d, please wait...", [counter, addressList.length]));
var startBlock = parseInt(counters.transactions) || 0; var startBlock = parseInt(counters.transactions) || 0;
var params = vsprintf('?address=%s&fromBlock=%d&toBlock=%d', [addressList[counter].toLowerCase(), startBlock, lastBlock]); var params = vsprintf("?address=%s&fromBlock=%d&toBlock=%d", [
addressList[counter].toLowerCase(),
startBlock,
lastBlock
]);
$.getJSON("https://richlist.ether1.org/transactions_list.php" + params, function( result ) { $.getJSON("https://richlist.ether1.org/transactions_list.php" + params, function (result) {
result.data.forEach(element => { result.data.forEach(element => {
if (element.fromaddr && element.toaddr) { if (element.fromaddr && element.toaddr) {
ipcRenderer.send('storeTransaction', { ipcRenderer.send("storeTransaction", {
block: element.block.toString(), block: element.block.toString(),
txhash: element.txhash.toLowerCase(), txhash: element.txhash.toLowerCase(),
fromaddr: element.fromaddr.toLowerCase(), fromaddr: element.fromaddr.toLowerCase(),
@@ -73,15 +77,12 @@ class Transactions {
var counters = EthoDatatabse.getCounters(); var counters = EthoDatatabse.getCounters();
var counter = 0; var counter = 0;
EthoBlockchain.getAccounts( EthoBlockchain.getAccounts(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
EthoTransactions.setIsSyncing(true); EthoTransactions.setIsSyncing(true);
EthoTransactions.syncTransactionsForSingleAddress(data, counters, lastBlock, counter); EthoTransactions.syncTransactionsForSingleAddress(data, counters, lastBlock, counter);
} });
);
} }
renderTransactions() { renderTransactions() {
@@ -94,66 +95,61 @@ class Transactions {
$("#loadingTransactionsOverlay").css("display", "block"); $("#loadingTransactionsOverlay").css("display", "block");
setTimeout(() => { setTimeout(() => {
var dataTransactions = ipcRenderer.sendSync('getTransactions'); var dataTransactions = ipcRenderer.sendSync("getTransactions");
var addressList = EthoWallets.getAddressList(); var addressList = EthoWallets.getAddressList();
dataTransactions.forEach(function(element) { dataTransactions.forEach(function (element) {
var isFromValid = (addressList.indexOf(element[2].toLowerCase()) > -1); var isFromValid = addressList.indexOf(element[2].toLowerCase()) > -1;
var isToValid = (addressList.indexOf(element[3].toLowerCase()) > -1); var isToValid = addressList.indexOf(element[3].toLowerCase()) > -1;
if ((isToValid) && (!isFromValid)) { if (isToValid && !isFromValid) {
element.unshift(0); element.unshift(0);
} else if ((!isToValid) && (isFromValid)) { } else if (!isToValid && isFromValid) {
element.unshift(1); element.unshift(1);
} else { } else {
element.unshift(2); element.unshift(2);
} }
}); });
EthoTableTransactions.initialize('#tableTransactionsForAll', dataTransactions); EthoTableTransactions.initialize("#tableTransactionsForAll", dataTransactions);
EthoTransactions.setIsLoading(false); EthoTransactions.setIsLoading(false);
}, 200); }, 200);
} }
} }
enableKeepInSync() { enableKeepInSync() {
EthoBlockchain.subsribeNewBlockHeaders( EthoBlockchain.subsribeNewBlockHeaders(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) EthoBlockchain.getBlock(data.number, true, function (error) {
{
EthoBlockchain.getBlock(data.number, true,
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
if (data.transactions) { if (data.transactions) {
data.transactions.forEach(element => { data.transactions.forEach(element => {
if (element.from && element.to) { if (element.from && element.to) {
if ((EthoWallets.getAddressExists(element.from)) || (EthoWallets.getAddressExists(element.to))) { if (EthoWallets.getAddressExists(element.from) || EthoWallets.getAddressExists(element.to)) {
var Transaction = { var Transaction = {
block: element.blockNumber.toString(), block: element.blockNumber.toString(),
txhash: element.hash.toLowerCase(), txhash: element.hash.toLowerCase(),
fromaddr: element.from.toLowerCase(), fromaddr: element.from.toLowerCase(),
timestamp: moment.unix(data.timestamp).format('YYYY-MM-DD HH:mm:ss'), timestamp: moment.unix(data.timestamp).format("YYYY-MM-DD HH:mm:ss"),
toaddr: element.to.toLowerCase(), toaddr: element.to.toLowerCase(),
value: Number(element.value).toExponential(5).toString().replace('+','') value: Number(element.value).toExponential(5).toString().replace("+", "")
} };
// store transaction and notify about new transactions // store transaction and notify about new transactions
ipcRenderer.send('storeTransaction', Transaction); ipcRenderer.send("storeTransaction", Transaction);
$(document).trigger("onNewAccountTransaction"); $(document).trigger("onNewAccountTransaction");
iziToast.info({ iziToast.info({
title: 'New Transaction', title: "New Transaction",
message: vsprintf('Transaction from address %s to address %s was just processed', [Transaction.fromaddr, Transaction.toaddr]), message: vsprintf("Transaction from address %s to address %s was just processed", [Transaction.fromaddr, Transaction.toaddr]),
position: 'topRight', position: "topRight",
timeout: 10000 timeout: 10000
}); });
if (EthoMainGUI.getAppState() == "transactions") { if (EthoMainGUI.getAppState() == "transactions") {
setTimeout(function() { setTimeout(function () {
EthoTransactions.renderTransactions(); EthoTransactions.renderTransactions();
}, 500); }, 500);
} }
@@ -161,21 +157,16 @@ class Transactions {
} }
}); });
} }
} });
); });
}
);
} }
disableKeepInSync() { disableKeepInSync() {
EthoBlockchain.unsubsribeNewBlockHeaders( EthoBlockchain.unsubsribeNewBlockHeaders(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
// success // success
} });
);
} }
} }

View File

@@ -3,17 +3,17 @@ class Utils {
toFixed(x) { toFixed(x) {
if (Math.abs(x) < 1.0) { if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split('e-')[1]); var e = parseInt(x.toString().split("e-")[1]);
if (e) { if (e) {
x *= Math.pow(10,e-1); x *= Math.pow(10, e - 1);
x = '0.' + (new Array(e)).join('0') + x.toString().substring(2); x = "0." + new Array(e).join("0") + x.toString().substring(2);
} }
} else { } else {
var e = parseInt(x.toString().split('+')[1]); var e = parseInt(x.toString().split("+")[1]);
if (e > 20) { if (e > 20) {
e -= 20; e -= 20;
x /= Math.pow(10,e); x /= Math.pow(10, e);
x += (new Array(e+1)).join('0'); x += new Array(e + 1).join("0");
} }
} }
return x; return x;
@@ -21,7 +21,11 @@ class Utils {
filterTable(table, text) { filterTable(table, text) {
// Declare variables // Declare variables
var filter, tr, td, i, txtValue; var filter,
tr,
td,
i,
txtValue;
filter = text.toUpperCase(); filter = text.toUpperCase();
tr = $(table).find("tr"); tr = $(table).find("tr");
@@ -45,13 +49,12 @@ class Utils {
content: text, content: text,
delay: 500, delay: 500,
arrow: true, arrow: true,
arrowType: 'round', arrowType: "round",
size: 'large', size: "large",
duration: 500, duration: 500,
animation: 'scale' animation: "scale"
}); });
} }
} }
EthoUtils = new Utils(); EthoUtils = new Utils();

View File

@@ -1,11 +1,10 @@
const {ipcRenderer} = require('electron'); const {ipcRenderer} = require("electron");
class Wallets { class Wallets {
constructor() { constructor() {
this.addressList = []; this.addressList = [];
$.getJSON("https://min-api.cryptocompare.com/data/price?fsym=ETHO&tsyms=USD", function( price ) $.getJSON("https://min-api.cryptocompare.com/data/price?fsym=ETHO&tsyms=USD", function (price) {
{
EthoWallets._setPrice(price.USD); EthoWallets._setPrice(price.USD);
}); });
} }
@@ -69,17 +68,15 @@ class Wallets {
} else { } else {
return false; return false;
} }
} }
renderWalletsState() { renderWalletsState() {
// clear the list of addresses // clear the list of addresses
EthoWallets.clearAddressList(); EthoWallets.clearAddressList();
EthoBlockchain.getAccountsData( EthoBlockchain.getAccountsData(function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (data) {
function(data) {
data.addressData.forEach(element => { data.addressData.forEach(element => {
EthoWallets.addAddressToList(element.address); EthoWallets.addAddressToList(element.address);
}); });
@@ -89,69 +86,63 @@ renderWalletsState() {
$(document).trigger("render_wallets"); $(document).trigger("render_wallets");
EthoWallets.enableButtonTooltips(); EthoWallets.enableButtonTooltips();
$("#labelSumDollars").html(vsprintf("/ %.2f $ / %.4f $ per ETHO", [data.sumBalance * EthoWallets._getPrice(), EthoWallets._getPrice()])); $("#labelSumDollars").html(vsprintf("/ %.2f $ / %.4f $ per ETHO", [
} data.sumBalance * EthoWallets._getPrice(),
); EthoWallets._getPrice()
]));
});
} }
} }
// the event to tell us that the wallets are rendered // the event to tell us that the wallets are rendered
$(document).on("render_wallets", function() { $(document).on("render_wallets", function () {
$('#addressTable').floatThead(); $("#addressTable").floatThead();
$("#btnNewAddress").off('click').on('click', function() { $("#btnNewAddress").off("click").on("click", function () {
$("#dlgCreateWalletPassword").iziModal(); $("#dlgCreateWalletPassword").iziModal();
$("#walletPasswordFirst").val(""); $("#walletPasswordFirst").val("");
$("#walletPasswordSecond").val(""); $("#walletPasswordSecond").val("");
$('#dlgCreateWalletPassword').iziModal('open'); $("#dlgCreateWalletPassword").iziModal("open");
function doCreateNewWallet() { function doCreateNewWallet() {
$('#dlgCreateWalletPassword').iziModal('close'); $("#dlgCreateWalletPassword").iziModal("close");
if (EthoWallets.validateNewAccountForm()) { if (EthoWallets.validateNewAccountForm()) {
EthoBlockchain.createNewAccount($("#walletPasswordFirst").val(), EthoBlockchain.createNewAccount($("#walletPasswordFirst").val(), function (error) {
function(error) {
EthoMainGUI.showGeneralError(error); EthoMainGUI.showGeneralError(error);
}, }, function (account) {
function(account) {
EthoWallets.addAddressToList(account); EthoWallets.addAddressToList(account);
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
iziToast.success({ iziToast.success({title: "Created", message: "New wallet was successfully created", position: "topRight", timeout: 5000});
title: 'Created',
message: 'New wallet was successfully created',
position: 'topRight',
timeout: 5000
}); });
} }
);
}
} }
$("#btnCreateWalletConfirm").off('click').on('click', function() { $("#btnCreateWalletConfirm").off("click").on("click", function () {
doCreateNewWallet(); doCreateNewWallet();
}); });
$("#dlgCreateWalletPassword").off('keypress').on('keypress', function(e) { $("#dlgCreateWalletPassword").off("keypress").on("keypress", function (e) {
if(e.which == 13) { if (e.which == 13) {
doCreateNewWallet(); doCreateNewWallet();
} }
}); });
}); });
$(".btnShowAddressTransactions").off('click').on('click', function() { $(".btnShowAddressTransactions").off("click").on("click", function () {
EthoTransactions.setFilter($(this).attr('data-wallet')); EthoTransactions.setFilter($(this).attr("data-wallet"));
EthoMainGUI.changeAppState("transactions"); EthoMainGUI.changeAppState("transactions");
EthoTransactions.renderTransactions(); EthoTransactions.renderTransactions();
}); });
$(".btnChangWalletName").off('click').on('click', function() { $(".btnChangWalletName").off("click").on("click", function () {
var walletAddress = $(this).attr('data-wallet'); var walletAddress = $(this).attr("data-wallet");
var walletName = $(this).attr('data-name'); var walletName = $(this).attr("data-name");
$("#dlgChangeWalletName").iziModal(); $("#dlgChangeWalletName").iziModal();
$("#inputWalletName").val(walletName); $("#inputWalletName").val(walletName);
$('#dlgChangeWalletName').iziModal('open'); $("#dlgChangeWalletName").iziModal("open");
function doChangeWalletName() { function doChangeWalletName() {
var wallets = EthoDatatabse.getWallets(); var wallets = EthoDatatabse.getWallets();
@@ -160,100 +151,83 @@ $(document).on("render_wallets", function() {
wallets.names[walletAddress] = $("#inputWalletName").val(); wallets.names[walletAddress] = $("#inputWalletName").val();
EthoDatatabse.setWallets(wallets); EthoDatatabse.setWallets(wallets);
$('#dlgChangeWalletName').iziModal('close'); $("#dlgChangeWalletName").iziModal("close");
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
} }
$("#btnChangeWalletNameConfirm").off('click').on('click', function() { $("#btnChangeWalletNameConfirm").off("click").on("click", function () {
doChangeWalletName(); doChangeWalletName();
}); });
$("#dlgChangeWalletName").off('keypress').on('keypress', function(e) { $("#dlgChangeWalletName").off("keypress").on("keypress", function (e) {
if(e.which == 13) { if (e.which == 13) {
doChangeWalletName(); doChangeWalletName();
} }
}); });
}); });
$("#btnRefreshAddress").off('click').on('click', function() { $("#btnRefreshAddress").off("click").on("click", function () {
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
}); });
$("#btnExportAccounts").off('click').on('click', function() { $("#btnExportAccounts").off("click").on("click", function () {
ipcRenderer.send('exportAccounts', {}); ipcRenderer.send("exportAccounts", {});
}); });
$("#btnImportAccounts").off('click').on('click', function() { $("#btnImportAccounts").off("click").on("click", function () {
var ImportResult = ipcRenderer.sendSync('importAccounts', {}); var ImportResult = ipcRenderer.sendSync("importAccounts", {});
if (ImportResult.success) { if (ImportResult.success) {
iziToast.success({ iziToast.success({title: "Imported", message: ImportResult.text, position: "topRight", timeout: 2000});
title: 'Imported',
message: ImportResult.text,
position: 'topRight',
timeout: 2000
});
} else if (ImportResult.success == false) { } else if (ImportResult.success == false) {
EthoMainGUI.showGeneralError(ImportResult.text); EthoMainGUI.showGeneralError(ImportResult.text);
} }
}); });
$("#btnImportFromPrivateKey").off('click').on('click', function() { $("#btnImportFromPrivateKey").off("click").on("click", function () {
$("#dlgImportFromPrivateKey").iziModal(); $("#dlgImportFromPrivateKey").iziModal();
$("#inputPrivateKey").val(""); $("#inputPrivateKey").val("");
$('#dlgImportFromPrivateKey').iziModal('open'); $("#dlgImportFromPrivateKey").iziModal("open");
function doImportFromPrivateKeys() { function doImportFromPrivateKeys() {
var account = EthoBlockchain.importFromPrivateKey($("#inputPrivateKey").val()); var account = EthoBlockchain.importFromPrivateKey($("#inputPrivateKey").val());
$('#dlgImportFromPrivateKey').iziModal('close'); $("#dlgImportFromPrivateKey").iziModal("close");
if (account) { if (account) {
ipcRenderer.sendSync('saveAccount', account[0]); ipcRenderer.sendSync("saveAccount", account[0]);
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
iziToast.success({ iziToast.success({title: "Imported", message: "Account was succesfully imported", position: "topRight", timeout: 2000});
title: 'Imported',
message: "Account was succesfully imported",
position: 'topRight',
timeout: 2000
});
} else { } else {
EthoMainGUI.showGeneralError("Error importing account from private key!"); EthoMainGUI.showGeneralError("Error importing account from private key!");
} }
} }
$("#btnImportFromPrivateKeyConfirm").off('click').on('click', function() { $("#btnImportFromPrivateKeyConfirm").off("click").on("click", function () {
doImportFromPrivateKeys(); doImportFromPrivateKeys();
}); });
$("#dlgImportFromPrivateKey").off('keypress').on('keypress', function(e) { $("#dlgImportFromPrivateKey").off("keypress").on("keypress", function (e) {
if(e.which == 13) { if (e.which == 13) {
doImportFromPrivateKeys(); doImportFromPrivateKeys();
} }
}); });
}); });
$(".textAddress").off('click').on('click', function() { $(".textAddress").off("click").on("click", function () {
EthoMainGUI.copyToClipboard($(this).html()); EthoMainGUI.copyToClipboard($(this).html());
iziToast.success({ iziToast.success({title: "Copied", message: "Address was copied to clipboard", position: "topRight", timeout: 2000});
title: 'Copied',
message: 'Address was copied to clipboard',
position: 'topRight',
timeout: 2000
});
}); });
}); });
// event that tells us that geth is ready and up // event that tells us that geth is ready and up
$(document).on("onGethReady", function() { $(document).on("onGethReady", function () {
EthoMainGUI.changeAppState("account"); EthoMainGUI.changeAppState("account");
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
}); });
$(document).on("onNewAccountTransaction", function() { $(document).on("onNewAccountTransaction", function () {
if (EthoMainGUI.getAppState() == "account") { if (EthoMainGUI.getAppState() == "account") {
EthoWallets.renderWalletsState(); EthoWallets.renderWalletsState();
} }