@@ -24,12 +24,19 @@ import {
24
24
25
25
const VERSION = "0.1.1" ;
26
26
27
+ const DEFAULT_KEYS_PATH = "keystore.db" ;
28
+
27
29
program
28
30
. version ( VERSION )
29
31
. option (
30
32
"-t, --account-type <accountType>" ,
31
33
"'platform' or 'asset'. The type of the key" ,
32
34
"platform"
35
+ )
36
+ . option (
37
+ "--keys-path <keysPath>" ,
38
+ "the path to store the keys" ,
39
+ DEFAULT_KEYS_PATH
33
40
) ;
34
41
35
42
program
@@ -93,42 +100,42 @@ function handleError(
93
100
}
94
101
95
102
async function listCommand ( args : any [ ] , option : ListOption ) {
96
- const cckey = await CCKey . create ( ) ;
103
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
97
104
const accountType = parseAccountType ( option . parent . accountType ) ;
98
105
await listKeys ( cckey , accountType ) ;
99
106
}
100
107
101
108
async function createCommand ( args : any [ ] , option : CreateOption ) {
102
- const cckey = await CCKey . create ( ) ;
109
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
103
110
const accountType = parseAccountType ( option . parent . accountType ) ;
104
111
const passphrase = parsePassphrase ( option . passphrase ) ;
105
112
await createKey ( cckey , accountType , passphrase ) ;
106
113
}
107
114
108
115
async function deleteCommand ( args : any [ ] , option : DeleteOption ) {
109
- const cckey = await CCKey . create ( ) ;
116
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
110
117
const accountType = parseAccountType ( option . parent . accountType ) ;
111
118
const address = parseAddress ( option . address ) ;
112
119
await deleteKey ( cckey , accountType , address ) ;
113
120
}
114
121
115
122
async function importCommand ( [ path ] : any [ ] , option : ImportOption ) {
116
- const cckey = await CCKey . create ( ) ;
123
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
117
124
const accountType = parseAccountType ( option . parent . accountType ) ;
118
125
const passphrase = parsePassphrase ( option . passphrase ) ;
119
126
const contents = fs . readFileSync ( path , { encoding : "utf8" } ) ;
120
127
await importKey ( cckey , accountType , JSON . parse ( contents ) , passphrase ) ;
121
128
}
122
129
123
130
async function importRawCommand ( [ privateKey ] : any [ ] , option : ImportOption ) {
124
- const cckey = await CCKey . create ( ) ;
131
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
125
132
const accountType = parseAccountType ( option . parent . accountType ) ;
126
133
const passphrase = parsePassphrase ( option . passphrase ) ;
127
134
await importRawKey ( cckey , accountType , privateKey , passphrase ) ;
128
135
}
129
136
130
137
async function exportCommand ( args : any [ ] , option : ExportOption ) {
131
- const cckey = await CCKey . create ( ) ;
138
+ const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
132
139
const accountType = parseAccountType ( option . parent . accountType ) ;
133
140
const address = parseAddress ( option . address ) ;
134
141
const passphrase = parsePassphrase ( option . passphrase ) ;
0 commit comments