@@ -38,8 +38,8 @@ mod test;
3838
3939use crate :: solana_program:: {
4040 compose_transaction, find_build_params_pda, get_all_pdas_available, get_program_pda,
41- process_close, resolve_rpc_url, upload_program_verification_data, InputParams ,
42- OtterBuildParams , OtterVerifyInstructions ,
41+ process_close, resolve_rpc_url, upload_program_verification_data, validate_config_and_keypair ,
42+ InputParams , OtterBuildParams , OtterVerifyInstructions ,
4343} ;
4444
4545const MAINNET_GENESIS_HASH : & str = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d" ;
@@ -352,9 +352,21 @@ async fn main() -> anyhow::Result<()> {
352352 )
353353 . get_matches ( ) ;
354354
355+ // Validate configuration early if custom config is provided
356+ let config_path = matches. value_of ( "config" ) . map ( |s| s. to_string ( ) ) ;
357+ if config_path. is_some ( ) {
358+ // Check if verify-from-repo subcommand has a keypair parameter
359+ let keypair_path = if let ( "verify-from-repo" , Some ( sub_m) ) = matches. subcommand ( ) {
360+ sub_m. value_of ( "keypair" ) . map ( |s| s. to_string ( ) )
361+ } else {
362+ None
363+ } ;
364+ validate_config_and_keypair ( config_path. as_deref ( ) , keypair_path. as_deref ( ) ) ?;
365+ }
366+
355367 let connection = resolve_rpc_url (
356368 matches. value_of ( "url" ) . map ( |s| s. to_string ( ) ) ,
357- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
369+ config_path . clone ( ) ,
358370 ) ?;
359371 let res = match matches. subcommand ( ) {
360372 ( "build" , Some ( sub_m) ) => {
@@ -385,7 +397,7 @@ async fn main() -> anyhow::Result<()> {
385397 executable_path. to_string ( ) ,
386398 image. to_string ( ) ,
387399 matches. value_of ( "url" ) . map ( |s| s. to_string ( ) ) ,
388- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
400+ config_path . clone ( ) ,
389401 Pubkey :: try_from ( program_id) ?,
390402 current_dir,
391403 & mut temp_dir,
@@ -458,7 +470,7 @@ async fn main() -> anyhow::Result<()> {
458470 & mut container_id,
459471 & mut temp_dir,
460472 & check_signal,
461- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
473+ config_path . clone ( ) ,
462474 )
463475 . await
464476 }
@@ -473,7 +485,7 @@ async fn main() -> anyhow::Result<()> {
473485 Pubkey :: try_from ( program_id) ?,
474486 & connection,
475487 compute_unit_price,
476- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
488+ config_path . clone ( ) ,
477489 )
478490 . await
479491 }
@@ -510,7 +522,7 @@ async fn main() -> anyhow::Result<()> {
510522
511523 let connection = resolve_rpc_url (
512524 matches. value_of ( "url" ) . map ( |s| s. to_string ( ) ) ,
513- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
525+ config_path . clone ( ) ,
514526 ) ?;
515527 println ! ( "Using connection url: {}" , connection. url( ) ) ;
516528
@@ -542,7 +554,7 @@ async fn main() -> anyhow::Result<()> {
542554 Pubkey :: try_from ( program_id) ?,
543555 signer,
544556 & connection,
545- matches . value_of ( "config" ) . map ( |s| s . to_string ( ) ) ,
557+ config_path . clone ( ) ,
546558 )
547559 . await
548560 }
0 commit comments