! fixed bug in importing single account to the wallet

! fixed bug when smart contract transactions were causing problems
This commit is contained in:
Taegus
2019-01-20 20:28:24 +01:00
parent 6f78865edc
commit ffaa1a3230
3 changed files with 46 additions and 40 deletions

View File

@@ -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 = {};
}
});

View File

@@ -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,31 +130,33 @@ 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('+','')
}
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");
// 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
});
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 (EthoMainGUI.getAppState() == "transactions") {
setTimeout(function() {
EthoTransactions.renderTransactions();
}, 500);
}
}
}
});

View File

@@ -193,7 +193,7 @@ $(document).on("render_wallets", function() {
position: 'topRight',
timeout: 2000
});
} else {
} else if (ImportResult.success == false) {
EthoMainGUI.showGeneralError(ImportResult.text);
}