Update accounts.js
Updating accounts module to delete address locally
This commit is contained in:
@@ -61,6 +61,32 @@ class Accounts {
|
|||||||
// file was written
|
// file was written
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deteteAccount(address) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||||
|
|
||||||
|
fs.readdir(accPath, function (err, files) {
|
||||||
|
let deleteFilePath = null;
|
||||||
|
if (err) reject(err);
|
||||||
|
else {
|
||||||
|
const searchStr = String(address).substring(2, String(address).length).toLowerCase();
|
||||||
|
for (let filePath of files) {
|
||||||
|
if (String(filePath).toLowerCase().indexOf(searchStr) > -1) {
|
||||||
|
deleteFilePath = filePath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deleteFilePath) {
|
||||||
|
fs.unlink(path.join(accPath, deleteFilePath), function(error) {
|
||||||
|
if (error) reject(error);
|
||||||
|
else resolve(true);
|
||||||
|
});
|
||||||
|
} else resolve(true)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on("exportAccounts", (event, arg) => {
|
ipcMain.on("exportAccounts", (event, arg) => {
|
||||||
@@ -96,4 +122,14 @@ ipcMain.on("saveAccount", (event, arg) => {
|
|||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on("deteteAccount", (event, arg) => {
|
||||||
|
EthoAccounts.deteteAccount(arg)
|
||||||
|
.then((res) => {
|
||||||
|
event.returnValue = res;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
event.returnValue = err;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
EthoAccounts = new Accounts();
|
EthoAccounts = new Accounts();
|
||||||
|
|||||||
Reference in New Issue
Block a user