+ delete and re-sync transactions
+ add to address book from send screen
This commit is contained in:
@@ -110,11 +110,11 @@ body.pg-loaded > .inner {
|
||||
}
|
||||
|
||||
#dlgGeneralError .modalBody {
|
||||
height: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
#dlgGeneralConfirm .modalBody {
|
||||
height: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
#dlgDeleteAddressConfirm .modalBody {
|
||||
height: 100px;
|
||||
@@ -129,6 +129,7 @@ body.pg-loaded > .inner {
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
#dlgAddAddressToBook .modalBody,
|
||||
#dlgChangeWalletName .modalBody,
|
||||
#dlgChangeAddressName .modalBody {
|
||||
height: 150px;
|
||||
@@ -365,3 +366,12 @@ div.noAddressWrapper {
|
||||
#addressListFilter {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.btnSendToolButton {
|
||||
width: 40px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#btnAddToAddressBook {
|
||||
margin-right: 3px;
|
||||
}
|
||||
@@ -14,7 +14,8 @@
|
||||
<div class="input-field col s6 addressInputWrapper">
|
||||
<input id="sendToAddress" placeholder="recipient address" type="text">
|
||||
<label for="sendToAddress" class="active">To address:</label>
|
||||
<button type="button" class="btn btn-etho addressLookup" id="btnLookForToAddress"><i class="fas fa-search"></i></button>
|
||||
<button type="button" class="btn btn-etho btnSendToolButton" id="btnAddToAddressBook"><i class="fas fa-plus"></i></button>
|
||||
<button type="button" class="btn btn-etho btnSendToolButton" id="btnLookForToAddress"><i class="fas fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -92,3 +93,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- The modal to add address to address book -->
|
||||
<div id="dlgAddAddressToBook" class="modalDialog" data-iziModal-title="Address Name" data-iziModal-subtitle="Enter the name for this address" data-iziModal-icon="icon-home">
|
||||
<div class="modalBody">
|
||||
<div class="form-group">
|
||||
<label for="usr">Address Name:</label>
|
||||
<input type="text" class="form-control" id="inputAddressName">
|
||||
</div>
|
||||
<button type="button" class="btn btn-etho btn-dialog-confirm" id="btnAddAddressToBookConfirm">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const {app, ipcMain} = require('electron');
|
||||
const {app, dialog, ipcMain} = require('electron');
|
||||
const storage = require('electron-storage');
|
||||
const datastore = require('nedb');
|
||||
const moment = require('moment');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const dbPath = path.join(app.getPath('userData'), 'storage.db');
|
||||
const db = new datastore({ filename: dbPath });
|
||||
@@ -77,3 +78,14 @@ ipcMain.on('setJSONFile', (event, arg) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteTransactions', (event, arg) => {
|
||||
fs.unlink(dbPath, (err) => {
|
||||
if (err) {
|
||||
event.returnValue = { success: false, error: err };
|
||||
dialog.showErrorBox("Error deleting the file", err.message);
|
||||
} else {
|
||||
event.returnValue = { success: true, error: null };
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -55,6 +55,7 @@ class MainGUI {
|
||||
|
||||
$("#btnGeneralConfirmYes").click(function() {
|
||||
$('#dlgGeneralConfirm').iziModal('close');
|
||||
console.log(true);
|
||||
callback(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -110,6 +110,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()) {
|
||||
EthoBlockchain.getTranasctionFee($("#sendFromAddress").val(), $("#sendToAddress").val(), $("#sendAmmount").val(),
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user