This repository was archived by the owner on Feb 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +64
-2
lines changed
Expand file tree Collapse file tree 2 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { selectAction } from "./actions";
1414import { unionWith } from "lodash" ;
1515import { oraLog } from "./oraLog" ;
1616import { showTransferAll } from "./actions/transferAll/ui" ;
17+ import { extraAccount } from "./ui/extraAccount" ;
1718
1819program
1920 . name ( "Argent X CLI" )
@@ -36,16 +37,21 @@ program.parse();
3637( async ( ) => {
3738 const spinner = ora ( ) ;
3839
39- const { accounts, network, defaultPrivateKey } = await getAccountsAndNetwork (
40+ let { accounts, network, defaultPrivateKey } = await getAccountsAndNetwork (
4041 spinner
4142 ) ;
4243
44+ spinner . succeed ( "Found " + accounts . length + " wallets" ) ;
45+
46+ if ( accounts . length === 0 ) {
47+ accounts = await extraAccount ( network , defaultPrivateKey ) ;
48+ }
49+
4350 const accountInfos = await getAccountInfos (
4451 accounts . map ( ( x ) => x . address ) ,
4552 network ,
4653 spinner
4754 ) ;
48- spinner . succeed ( "Found " + accounts . length + " wallets" ) ;
4955
5056 const accountWithSigner : Account [ ] = accounts . map ( ( account , i ) => ( {
5157 ...account ,
Original file line number Diff line number Diff line change 1+ import { isString } from "lodash" ;
2+ import prompts from "prompts" ;
3+ import { ValidationError } from "yup" ;
4+ import { addressSchema } from "../schema" ;
5+
6+ export async function extraAccount (
7+ network : "mainnet-alpha" | "goerli-alpha" ,
8+ privateKey : string
9+ ) : Promise <
10+ {
11+ address : string ;
12+ networkId : string ;
13+ privateKey : string ;
14+ } [ ]
15+ > {
16+ const { extraWalletAddress } = await prompts (
17+ [
18+ {
19+ type : "text" ,
20+ name : "extraWalletAddress" ,
21+ message : "Enter wallet address you want to use" ,
22+ validate : async ( value : string , prev ) => {
23+ try {
24+ const address = value . replace ( " " , "" ) ;
25+ if ( ! address . length ) {
26+ return "You must select one account" ;
27+ }
28+ try {
29+ await addressSchema . validate ( address ) ;
30+ } catch ( e ) {
31+ return `Invalid address '${ address } '.${
32+ e instanceof ValidationError ? ` Reason: ${ e . message } ` : ""
33+ } `;
34+ }
35+ } catch ( e ) {
36+ return "Invalid address" ;
37+ }
38+ return true ;
39+ } ,
40+ } ,
41+ ] ,
42+ { onCancel : ( ) => process . exit ( 1 ) }
43+ ) ;
44+
45+ if ( ! isString ( extraWalletAddress ) ) {
46+ throw new Error ( "Invalid address" ) ;
47+ }
48+
49+ return [
50+ {
51+ address : extraWalletAddress ,
52+ networkId : network ,
53+ privateKey,
54+ } ,
55+ ] ;
56+ }
You can’t perform that action at this time.
0 commit comments