1
1
import { prod_app_directory , production } from './src/main/libs/config' ;
2
2
import os from 'os' ;
3
- import fs from 'fs' ;
4
3
import shell from 'shelljs' ;
4
+ import { ipcRenderer } from "electron" ;
5
5
var adapter ;
6
- // const cryptoJSON = require('crypto-json');
7
6
const low = require ( 'lowdb' )
8
7
const FileSync = require ( 'lowdb/adapters/FileSync' )
9
8
9
+ let db ;
10
+ console . log ( "Ress 3 startAppRes lowdb 2" )
11
+
10
12
if ( production ) {
11
13
let appPath = "~/Library/Application Support/" + prod_app_directory ;
12
14
if ( os . type ( ) == 'Windows_NT' ) {
13
15
appPath = "~/AppData/Roaming/" + prod_app_directory ;
14
- shell . cd ( appPath ) ;
15
-
16
+ if ( appPath ) {
17
+ shell . cd ( appPath ) ;
18
+ }
16
19
}
17
20
if ( os . type ( ) == 'Linux' ) {
18
21
appPath = "~/.config/" + prod_app_directory ;
19
22
shell . cd ( appPath ) ;
20
-
23
+
21
24
}
22
25
if ( os . type ( ) == 'Darwin' ) {
23
26
appPath = "~/Library/Application Support/" + prod_app_directory ;
24
27
shell . cd ( appPath ) ;
25
28
}
26
29
27
- // console.log("check path11111", shell.ls(''), shell.ls('') && shell.ls('').find((ele)=> console.log(ele)));
28
30
adapter = new FileSync ( 'db.json' ) ;
29
31
console . log ( adapter , "lowdbfunc" ) ;
30
-
31
32
} else {
32
33
adapter = new FileSync ( '/Users/farina/Desktop/Projects/LunaWalletVueTest/db.json' ) ;
33
34
}
34
35
35
- let db = low ( adapter ) ;
36
-
37
- //
38
- // const algorithm = 'camellia-128-cbc';
39
- // const encoding = 'hex';
40
- //
41
- // const input = {
42
- // accounts: db.get('accounts').value(),
43
- // contracts: db.get('contracts').value(),
44
- // tokens: db.get('tokens').value(),
45
- // accountsAdresses: db.get('accountsAdresses').value(),
46
- // hdWallets: db.get('hdWallets').value(),
47
- // transactions: db.get('transactions').value(),
48
- // }
49
- //
50
- // // console.log(db.get('accounts').value());
51
- //
52
- // const password = '123123123'
53
- //
54
- // // keys act like a white list, so for example if you want to encrypt a nested
55
- // // key "test" you also need to specify its parent keys,
56
- // // i.e. "b", "a", "baz", "hello" in the above input object
57
- //
58
- //
59
- //
60
- // const keys = ['accounts', 'accountTitle', 'hash', 'archive', 'isHd',
61
- // 'contracts','id','contract_name','contract_address','contract_json','constant','inputs','name','outputs','type','payable',
62
- // 'stateMutability','signature','anonymous','indexed','token_address','token_name','token_symbol','tokenType',
63
- // 'tokens', 'accountsAdresses', 'hdWallets', 'transactions', 'logs','address', 'topics' ];
64
- //
65
- // const output = cryptoJSON.encrypt(
66
- // input, password, {encoding, keys, algorithm}
67
- // );
68
- //
69
- // console.log(output);
36
+ db = low ( adapter ) ;
70
37
71
38
db . defaults ( { accounts : [ ] , contracts : [ ] , tokens : [
72
39
{
@@ -90,6 +57,7 @@ db.defaults({ accounts: [], contracts: [], tokens: [
90
57
] , accountsAdresses :[ ] , hdWallets :[ ] , transactions : [ ] } )
91
58
. write ( ) ;
92
59
60
+
93
61
export {
94
62
db , adapter , low
95
63
}
0 commit comments