+ delete and re-sync transactions

+ add to address book from send screen
This commit is contained in:
Taegus
2018-12-28 10:26:32 +01:00
parent d33f90b738
commit 1c629801c4
7 changed files with 94 additions and 40 deletions

View File

@@ -55,6 +55,7 @@ class MainGUI {
$("#btnGeneralConfirmYes").click(function() {
$('#dlgGeneralConfirm').iziModal('close');
console.log(true);
callback(true);
});

View File

@@ -109,6 +109,39 @@ $(document).on("render_send", function() {
}
);
});
$("#btnAddToAddressBook").off('click').on('click', function() {
if (EthoBlockchain.isAddress($("#sendToAddress").val())) {
$("#dlgAddAddressToBook").iziModal();
$("#inputAddressName").val("");
$('#dlgAddAddressToBook').iziModal('open');
function doAddAddressToAddressBook() {
EthoAddressBook.setAddressName($("#sendToAddress").val(), $("#inputAddressName").val());
$('#dlgAddAddressToBook').iziModal('close');
iziToast.success({
title: 'Success',
message: 'Address was added to address book',
position: 'topRight',
timeout: 2000
});
}
} else {
EthoMainGUI.showGeneralError("Recipient address is not valid!");
}
$("#btnAddAddressToBookConfirm").off('click').on('click', function() {
doAddAddressToAddressBook();
});
$("#dlgAddAddressToBook").off('keypress').on('keypress', function(e) {
if(e.which == 13) {
doAddAddressToAddressBook();
}
});
});
$("#btnSendTransaction").off('click').on('click', function() {
if (EthoSend.validateSendForm()) {

View File

@@ -17,7 +17,29 @@ $(document).on("render_settings", function() {
if (EthoTransactions.getIsSyncing()) {
EthoMainGUI.showGeneralError("Transactions sync is currently in progress");
} else {
// first disable keepInSync
EthoTransactions.disableKeepInSync();
// then delete the transactions data
var counters = EthoDatatabse.getCounters();
counters.transactions = 0;
EthoDatatabse.setCounters(counters);
ipcRenderer.sendSync('deleteTransactions', null);
// sync all the transactions to the current block
web3Local.eth.getBlock("latest", function(error, localBlock) {
if (error) {
EthoMainGUI.showGeneralError(error);
} else {
EthoTransactions.enableKeepInSync();
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
iziToast.success({
title: 'Success',
message: 'Transactions are being resynced',
position: 'topRight',
timeout: 5000
});
}
});
}
}
});

View File

@@ -102,42 +102,6 @@ class Transactions {
}
enableKeepInSync() {
function processTransaction(data) {
if ((EthoWallets.getAddressExists(data.from)) || (EthoWallets.getAddressExists(data.to))) {
if (data.blockNumber) {
console.log(data.blockNumber);
}
var Transaction = {
block: null,
txhash: data.hash.toLowerCase(),
fromaddr: data.from.toLowerCase(),
timestamp: moment.unix(data.timestamp).format('YYYY-MM-DD HH:mm:ss'),
toaddr: data.to.toLowerCase(),
value: Number(data.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
});
// render transactions again to show latest
if (EthoMainGUI.getAppState() == "transactions") {
setTimeout(function() {
EthoTransactions.renderTransactions();
}, 500);
}
}
}
EthoBlockchain.subsribeNewBlockHeaders(
function(error) {
EthoMainGUI.showGeneralError(error);