diff --git a/modules/accounts.js b/modules/accounts.js index 68a5398..71948ab 100644 --- a/modules/accounts.js +++ b/modules/accounts.js @@ -42,11 +42,11 @@ class Accounts { var extName = path.extname(accountsFile).toUpperCase(); const accPath = this.getKeyStoreLocation(); - if (extName = '.ZIP') { + if (extName == '.ZIP') { var zip = new admZip(accountsFile); zip.extractAllTo(accPath, true); return { success: true, text: "Accounts ware successfully imported."}; - } else if (extName = '.JSON') { + } else { fs.copyFile(accountsFile, path.join(accPath, path.basename(accountsFile)), (err) => { if (err) { return { success: false, text: err}; @@ -54,8 +54,6 @@ class Accounts { return { success: true, text: "Account was successfully imported."}; } }); - } else { - return { success: false, text: "This is not a valid account file or arhive!"}; } } @@ -82,6 +80,10 @@ ipcMain.on('importAccounts', (event, arg) => { { "name": "json", "extensions": ["json"] + }, + { + "name": "All", + "extensions": ["*.*"] } ] }); @@ -89,7 +91,7 @@ ipcMain.on('importAccounts', (event, arg) => { if (openPath) { event.returnValue = EthoAccounts.importAccounts(openPath[0]); } else { - event.returnValue = false; + event.returnValue = {}; } }); diff --git a/renderer/transactions.js b/renderer/transactions.js index feab154..9c789a6 100644 --- a/renderer/transactions.js +++ b/renderer/transactions.js @@ -44,14 +44,16 @@ class Transactions { $.getJSON("https://richlist.ether1.org/transactions_list.php" + params, function( result ) { result.data.forEach(element => { - ipcRenderer.send('storeTransaction', { - block: element.block.toString(), - txhash: element.txhash.toLowerCase(), - fromaddr: element.fromaddr.toLowerCase(), - timestamp: element.timestamp, - toaddr: element.toaddr.toLowerCase(), - value: element.value - }); + if (element.fromaddr && element.toaddr) { + ipcRenderer.send('storeTransaction', { + block: element.block.toString(), + txhash: element.txhash.toLowerCase(), + fromaddr: element.fromaddr.toLowerCase(), + timestamp: element.timestamp, + toaddr: element.toaddr.toLowerCase(), + value: element.value + }); + } }); // call the transaction sync for the next address @@ -128,32 +130,34 @@ class Transactions { function(data) { if (data.transactions) { data.transactions.forEach(element => { - if ((EthoWallets.getAddressExists(element.from)) || (EthoWallets.getAddressExists(element.to))) { - var Transaction = { - block: element.blockNumber.toString(), - txhash: element.hash.toLowerCase(), - fromaddr: element.from.toLowerCase(), - timestamp: moment.unix(data.timestamp).format('YYYY-MM-DD HH:mm:ss'), - toaddr: element.to.toLowerCase(), - value: Number(element.value).toExponential(5).toString().replace('+','') - } - - // store transaction and notify about new transactions - ipcRenderer.send('storeTransaction', Transaction); - $(document).trigger("onNewAccountTransaction"); - - iziToast.info({ - title: 'New Transaction', - message: vsprintf('Transaction from address %s to address %s was just processed', [Transaction.fromaddr, Transaction.toaddr]), - position: 'topRight', - timeout: 10000 - }); - - if (EthoMainGUI.getAppState() == "transactions") { - setTimeout(function() { - EthoTransactions.renderTransactions(); - }, 500); - } + if (element.from && element.to) { + if ((EthoWallets.getAddressExists(element.from)) || (EthoWallets.getAddressExists(element.to))) { + var Transaction = { + block: element.blockNumber.toString(), + txhash: element.hash.toLowerCase(), + fromaddr: element.from.toLowerCase(), + timestamp: moment.unix(data.timestamp).format('YYYY-MM-DD HH:mm:ss'), + toaddr: element.to.toLowerCase(), + value: Number(element.value).toExponential(5).toString().replace('+','') + } + + // store transaction and notify about new transactions + ipcRenderer.send('storeTransaction', Transaction); + $(document).trigger("onNewAccountTransaction"); + + iziToast.info({ + title: 'New Transaction', + message: vsprintf('Transaction from address %s to address %s was just processed', [Transaction.fromaddr, Transaction.toaddr]), + position: 'topRight', + timeout: 10000 + }); + + if (EthoMainGUI.getAppState() == "transactions") { + setTimeout(function() { + EthoTransactions.renderTransactions(); + }, 500); + } + } } }); } diff --git a/renderer/wallets.js b/renderer/wallets.js index 1b44380..30e1ddf 100644 --- a/renderer/wallets.js +++ b/renderer/wallets.js @@ -193,7 +193,7 @@ $(document).on("render_wallets", function() { position: 'topRight', timeout: 2000 }); - } else { + } else if (ImportResult.success == false) { EthoMainGUI.showGeneralError(ImportResult.text); }