@@ -37,6 +37,11 @@ program
3737 "--keys-path <keysPath>" ,
3838 "the path to store the keys" ,
3939 DEFAULT_KEYS_PATH
40+ )
41+ . option (
42+ "--network-id <networkId>" ,
43+ "the id of the network (use 'tc' for husky, use 'sc' for saluki)" ,
44+ "tc"
4045 ) ;
4146
4247program
@@ -102,44 +107,62 @@ function handleError(
102107async function listCommand ( args : any [ ] , option : ListOption ) {
103108 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
104109 const accountType = parseAccountType ( option . parent . accountType ) ;
105- await listKeys ( cckey , accountType ) ;
110+ const networkId = option . parent . networkId ;
111+ await listKeys ( cckey , accountType , networkId ) ;
106112}
107113
108114async function createCommand ( args : any [ ] , option : CreateOption ) {
109115 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
110116 const accountType = parseAccountType ( option . parent . accountType ) ;
111117 const passphrase = await parsePassphrase ( option . passphrase ) ;
112- await createKey ( cckey , accountType , passphrase ) ;
118+ const networkId = option . parent . networkId ;
119+ await createKey ( cckey , accountType , passphrase , networkId ) ;
113120}
114121
115122async function deleteCommand ( args : any [ ] , option : DeleteOption ) {
116123 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
117124 const accountType = parseAccountType ( option . parent . accountType ) ;
118125 const address = parseAddress ( option . address ) ;
119- await deleteKey ( cckey , accountType , address ) ;
126+ const networkId = option . parent . networkId ;
127+ await deleteKey ( cckey , accountType , address , networkId ) ;
120128}
121129
122130async function importCommand ( [ path ] : any [ ] , option : ImportOption ) {
123131 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
124132 const accountType = parseAccountType ( option . parent . accountType ) ;
125133 const passphrase = await parsePassphrase ( option . passphrase ) ;
126134 const contents = fs . readFileSync ( path , { encoding : "utf8" } ) ;
127- await importKey ( cckey , accountType , JSON . parse ( contents ) , passphrase ) ;
135+ const networkId = option . parent . networkId ;
136+ await importKey (
137+ cckey ,
138+ accountType ,
139+ JSON . parse ( contents ) ,
140+ passphrase ,
141+ networkId
142+ ) ;
128143}
129144
130145async function importRawCommand ( [ privateKey ] : any [ ] , option : ImportOption ) {
131146 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
132147 const accountType = parseAccountType ( option . parent . accountType ) ;
133148 const passphrase = await parsePassphrase ( option . passphrase ) ;
134- await importRawKey ( cckey , accountType , privateKey , passphrase ) ;
149+ const networkId = option . parent . networkId ;
150+ await importRawKey ( cckey , accountType , privateKey , passphrase , networkId ) ;
135151}
136152
137153async function exportCommand ( args : any [ ] , option : ExportOption ) {
138154 const cckey = await CCKey . create ( { dbPath : option . parent . keysPath } ) ;
139155 const accountType = parseAccountType ( option . parent . accountType ) ;
140156 const address = parseAddress ( option . address ) ;
141157 const passphrase = await parsePassphrase ( option . passphrase ) ;
142- const secret = await exportKey ( cckey , accountType , address , passphrase ) ;
158+ const networkId = option . parent . networkId ;
159+ const secret = await exportKey (
160+ cckey ,
161+ accountType ,
162+ address ,
163+ passphrase ,
164+ networkId
165+ ) ;
143166 const res = option . pretty
144167 ? JSON . stringify ( secret , null , 2 )
145168 : JSON . stringify ( secret ) ;
0 commit comments