@@ -9,6 +9,8 @@ import { unionWith } from "lodash";
99import { showTransferAll } from "./actions/transferAll/ui" ;
1010import { askForExtraAccounts , extraAccount } from "./ui/extraAccount" ;
1111import { equalSigner , getDefaultSigners } from "./genSigners" ;
12+ import { detectAccountIssues , fixAccountIssues } from "./issues" ;
13+ import { ec } from "starknet" ;
1214
1315program
1416 . name ( "Argent X CLI" )
@@ -38,11 +40,11 @@ program.parse();
3840 spinner . succeed ( "Found " + accounts . length + " wallets" ) ;
3941
4042 if ( accounts . length === 0 ) {
41- accounts = await extraAccount ( network , privateKey ) ;
43+ accounts = await extraAccount ( network ) ;
4244 } else if ( await askForExtraAccounts ( ) ) {
4345 accounts = unionWith (
4446 accounts ,
45- await extraAccount ( network , privateKey ) ,
47+ await extraAccount ( network ) ,
4648 ( a , b ) => a . address === b . address
4749 ) ;
4850 }
@@ -59,25 +61,38 @@ program.parse();
5961 } ) ) ;
6062
6163 // find missing signers
62- if ( seed && accountWithSigner . some ( ( x ) => ! x . privateKey ) ) {
64+ if ( accountWithSigner . some ( ( x ) => ! x . privateKey ) ) {
6365 spinner . start ( "Trying to find missing private keys" ) ;
64- const defaultSigners = getDefaultSigners ( seed ) ;
65- accountWithSigner
66- . filter ( ( x ) => ! x . privateKey )
67- . forEach ( ( x ) => {
68- const signer = defaultSigners . find (
69- ( y ) => x . signer && equalSigner ( x . signer , y . signer )
70- ) ;
71- if ( signer ) {
72- x . privateKey = signer . privateKey ;
73- }
74- } ) ;
66+ if ( seed ) {
67+ const defaultSigners = getDefaultSigners ( seed ) ;
68+ accountWithSigner
69+ . filter ( ( x ) => ! x . privateKey )
70+ . forEach ( ( x ) => {
71+ const signer = defaultSigners . find (
72+ ( y ) => x . signer && equalSigner ( x . signer , y . signer )
73+ ) ;
74+ if ( signer ) {
75+ x . privateKey = signer . privateKey ;
76+ }
77+ } ) ;
78+ }
79+ if ( privateKey ) {
80+ const defaultSigner = ec . getStarkKey ( ec . getKeyPair ( privateKey ) ) ;
81+ spinner . info ( `Public key: ${ defaultSigner } ` ) ;
82+ accountWithSigner
83+ . filter ( ( x ) => ! x . privateKey )
84+ . forEach ( ( x ) => {
85+ if ( x . signer && equalSigner ( x . signer , defaultSigner ) ) {
86+ x . privateKey = privateKey ;
87+ }
88+ } ) ;
89+ }
7590 if ( accountWithSigner . some ( ( x ) => ! x . privateKey ) ) {
7691 spinner . warn (
7792 "Could not find all private keys. Continuing with missing private keys"
7893 ) ;
7994 } else {
80- spinner . succeed ( "Found all private keys " ) ;
95+ spinner . succeed ( "Found all signers " ) ;
8196 }
8297 }
8398
@@ -88,7 +103,11 @@ program.parse();
88103
89104 display ( filteredAccountWithSigner ) ;
90105
91- await showTransferAll ( filteredAccountWithSigner , network ) ;
106+ const issues = await detectAccountIssues ( filteredAccountWithSigner ) ;
107+
108+ await fixAccountIssues ( accountWithSigner , network , issues ) ;
109+
110+ await showTransferAll ( filteredAccountWithSigner ) ;
92111} ) ( ) . catch ( ( e ) => {
93112 console . error ( "An error occured" , e ) ;
94113 process . exit ( 1 ) ;
0 commit comments