+ create user data dir
! fixed keystore path for MacOS + check file types on import accounts and notify of success or error
This commit is contained in:
@@ -2,9 +2,19 @@ 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');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
class Accounts {
|
class Accounts {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
this.getKeyStoreLocation = function() {
|
||||||
|
switch(os.type()) {
|
||||||
|
case "Darwin":
|
||||||
|
return path.join(process.env.HOMEPATH, 'Documents/ethereum-wallet/ethereum-wallet/Classes/Business layer/Core/Services', 'keystore');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return path.join(process.env.APPDATA, 'Ether1', 'keystore');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exportAccounts() {
|
exportAccounts() {
|
||||||
@@ -13,7 +23,7 @@ class Accounts {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (savePath) {
|
if (savePath) {
|
||||||
const accPath = path.join(path.join(process.env.APPDATA, 'Ether1'), 'keystore');
|
const accPath = this.getKeyStoreLocation();
|
||||||
|
|
||||||
fs.readdir(accPath, function(err, files) {
|
fs.readdir(accPath, function(err, files) {
|
||||||
var zip = new admZip();
|
var zip = new admZip();
|
||||||
@@ -29,15 +39,52 @@ class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
importAccounts() {
|
importAccounts() {
|
||||||
const accPath = path.join(path.join(process.env.APPDATA, 'Ether1'), 'keystore');
|
const accPath = this.getKeyStoreLocation();
|
||||||
|
|
||||||
var openPath = dialog.showOpenDialog({
|
var openPath = dialog.showOpenDialog({
|
||||||
defaultPath: app.getPath('documents')
|
defaultPath: app.getPath('documents'),
|
||||||
|
"filters":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "archive",
|
||||||
|
"extensions": ["zip"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "json",
|
||||||
|
"extensions": ["json"]
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (openPath) {
|
if (openPath) {
|
||||||
|
var extName = path.extname(openPath[0]).toUpperCase();
|
||||||
|
|
||||||
|
if (extName = '.ZIP') {
|
||||||
var zip = new admZip(openPath[0]);
|
var zip = new admZip(openPath[0]);
|
||||||
zip.extractAllTo(accPath, true);
|
zip.extractAllTo(accPath, true);
|
||||||
|
|
||||||
|
iziToast.success({
|
||||||
|
title: 'Imported',
|
||||||
|
message: 'Accounts ware successfully imported.',
|
||||||
|
position: 'topRight',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
} else if (extName = '.JSON') {
|
||||||
|
fs.copyFile(openPath[0], path.join(accPath, path.basename(openPath[0])), (err) => {
|
||||||
|
if (err) {
|
||||||
|
EthoMainGUI.showGeneralError(err);
|
||||||
|
} else {
|
||||||
|
iziToast.success({
|
||||||
|
title: 'Imported',
|
||||||
|
message: 'Account was successfully imported.',
|
||||||
|
position: 'topRight',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
EthoMainGUI.showGeneralError("This is not a valid account file or arhive!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ const os = require('os');
|
|||||||
class Geth {
|
class Geth {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.gethProcess = null;
|
this.gethProcess = null;
|
||||||
|
// create the user data dir (needed for MacOS)
|
||||||
|
if (!fs.existsSync(app.getPath('userData'))) {
|
||||||
|
fs.mkdirSync(app.getPath('userData'));
|
||||||
|
}
|
||||||
this.logStream = fs.createWriteStream(path.join(app.getPath('userData'), 'gethlog.txt'));
|
this.logStream = fs.createWriteStream(path.join(app.getPath('userData'), 'gethlog.txt'));
|
||||||
|
|
||||||
if (appRoot.path.indexOf('app.asar') > -1) {
|
if (appRoot.path.indexOf('app.asar') > -1) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Ether1Wallet",
|
"name": "Ether1Wallet",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"description": "Desktop wallet for Ether1 currency",
|
"description": "Desktop wallet for Ether1 currency",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user