+ delete wallet data support
+ added fs-extra module + use copyFileSync
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<div class="cleanWrapper">
|
||||
<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 class="cleanWrapper">
|
||||
<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 admZip = require('adm-zip');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
|
||||
class Accounts {
|
||||
@@ -47,13 +47,12 @@ class Accounts {
|
||||
zip.extractAllTo(accPath, true);
|
||||
return { success: true, text: "Accounts ware successfully imported."};
|
||||
} else {
|
||||
fs.copyFile(accountsFile, path.join(accPath, path.basename(accountsFile)), (err) => {
|
||||
if (err) {
|
||||
return { success: false, text: err};
|
||||
} else {
|
||||
return { success: true, text: "Account was successfully imported."};
|
||||
}
|
||||
});
|
||||
try {
|
||||
fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
|
||||
return { success: true, text: "Account was successfully imported."};
|
||||
} catch (err) {
|
||||
return { success: false, text: err};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,16 @@ 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 };
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on('deleteWalletData', (event, arg) => {
|
||||
fs.unlink(path.join(app.getPath('userData'), 'wallets.json'), (err) => {
|
||||
if (err) {
|
||||
event.returnValue = { success: false, error: err };
|
||||
} else {
|
||||
event.returnValue = { success: true, error: null };
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"adm-zip": "^0.4.13",
|
||||
"app-root-path": "^2.1.0",
|
||||
"electron-storage": "^1.0.7",
|
||||
"fs-extra": "^7.0.1",
|
||||
"handlebars": "^4.0.12",
|
||||
"moment": "^2.23.0",
|
||||
"nedb": "^1.8.0",
|
||||
|
||||
@@ -24,23 +24,28 @@ $(document).on("render_settings", function() {
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
ipcResult = ipcRenderer.sendSync('deleteTransactions', null);
|
||||
|
||||
if (ipcResult.success) {
|
||||
// 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
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
EthoMainGUI.showGeneralError("Error resyncing transactions: " + ipcResult.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -55,7 +60,18 @@ $(document).on("render_settings", 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() {
|
||||
|
||||
Reference in New Issue
Block a user