+ delete wallet data support
+ added fs-extra module + use copyFileSync
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="cleanWrapper">
|
<div class="cleanWrapper">
|
||||||
<button type="button" class="btn btn-etho btnSettingsClean" id="btnSettingsCleanWallets"><i class="far fa-trash-alt"></i></button>
|
<button type="button" class="btn btn-etho btnSettingsClean" id="btnSettingsCleanWallets"><i class="far fa-trash-alt"></i></button>
|
||||||
<span class="cleanText">Clean wallets data</span>
|
<span class="cleanText">Clean wallet names</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="cleanWrapper">
|
<div class="cleanWrapper">
|
||||||
<button type="button" class="btn btn-etho btnSettingsClean" id="btnSettingsCleanBlockchain"><i class="far fa-trash-alt"></i></button>
|
<button type="button" class="btn btn-etho btnSettingsClean" id="btnSettingsCleanBlockchain"><i class="far fa-trash-alt"></i></button>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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');
|
const fs = require('fs-extra');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
class Accounts {
|
class Accounts {
|
||||||
@@ -47,13 +47,12 @@ class Accounts {
|
|||||||
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 {
|
||||||
fs.copyFile(accountsFile, path.join(accPath, path.basename(accountsFile)), (err) => {
|
try {
|
||||||
if (err) {
|
fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
|
||||||
return { success: false, text: err};
|
return { success: true, text: "Account was successfully imported."};
|
||||||
} else {
|
} catch (err) {
|
||||||
return { success: true, text: "Account was successfully imported."};
|
return { success: false, text: err};
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,16 @@ 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 };
|
||||||
dialog.showErrorBox("Error deleting the file", err.message);
|
} else {
|
||||||
|
event.returnValue = { success: true, error: null };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('deleteWalletData', (event, arg) => {
|
||||||
|
fs.unlink(path.join(app.getPath('userData'), 'wallets.json'), (err) => {
|
||||||
|
if (err) {
|
||||||
|
event.returnValue = { success: false, error: err };
|
||||||
} else {
|
} else {
|
||||||
event.returnValue = { success: true, error: null };
|
event.returnValue = { success: true, error: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
"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",
|
||||||
"handlebars": "^4.0.12",
|
"handlebars": "^4.0.12",
|
||||||
"moment": "^2.23.0",
|
"moment": "^2.23.0",
|
||||||
"nedb": "^1.8.0",
|
"nedb": "^1.8.0",
|
||||||
|
|||||||
@@ -24,23 +24,28 @@ $(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);
|
||||||
ipcRenderer.sendSync('deleteTransactions', null);
|
ipcResult = ipcRenderer.sendSync('deleteTransactions', null);
|
||||||
// sync all the transactions to the current block
|
|
||||||
web3Local.eth.getBlock("latest", function(error, localBlock) {
|
if (ipcResult.success) {
|
||||||
if (error) {
|
// sync all the transactions to the current block
|
||||||
EthoMainGUI.showGeneralError(error);
|
web3Local.eth.getBlock("latest", function(error, localBlock) {
|
||||||
} else {
|
if (error) {
|
||||||
EthoTransactions.enableKeepInSync();
|
EthoMainGUI.showGeneralError(error);
|
||||||
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
|
} else {
|
||||||
|
EthoTransactions.enableKeepInSync();
|
||||||
iziToast.success({
|
EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
|
||||||
title: 'Success',
|
|
||||||
message: 'Transactions are being resynced',
|
iziToast.success({
|
||||||
position: 'topRight',
|
title: 'Success',
|
||||||
timeout: 5000
|
message: 'Transactions are being resynced',
|
||||||
});
|
position: 'topRight',
|
||||||
}
|
timeout: 5000
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
EthoMainGUI.showGeneralError("Error resyncing transactions: " + ipcResult.error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -55,7 +60,18 @@ $(document).on("render_settings", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#btnSettingsCleanWallets").off('click').on('click', function() {
|
$("#btnSettingsCleanWallets").off('click').on('click', function() {
|
||||||
EthoMainGUI.showGeneralError("Not implemented yet!");
|
ipcResult = ipcRenderer.sendSync('deleteWalletData', null);
|
||||||
|
|
||||||
|
if (ipcResult.success) {
|
||||||
|
iziToast.success({
|
||||||
|
title: 'Success',
|
||||||
|
message: 'Wallet names were succesfully cleaned',
|
||||||
|
position: 'topRight',
|
||||||
|
timeout: 5000
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#btnSettingsCleanBlockchain").off('click').on('click', function() {
|
$("#btnSettingsCleanBlockchain").off('click').on('click', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user