11use {
22 crate :: utils:: { dashboard, examples, nodes, ssh_deploy, svm_info} ,
33 clparse:: parse_command_line,
4- solana_clap_utils:: {
5- input_parsers:: pubkey_of, input_validators:: normalize_to_url_if_moniker,
6- keypair:: DefaultSigner ,
7- } ,
4+ solana_clap_utils:: input_validators:: normalize_to_url_if_moniker,
85 solana_client:: rpc_client:: RpcClient ,
96 solana_sdk:: { commitment_config:: CommitmentConfig , native_token:: Sol , signature:: Signer } ,
107 std:: { env, process:: exit, str:: FromStr } ,
@@ -61,10 +58,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6158 } ;
6259 let matches = sub_matches;
6360
64- #[ cfg( feature = "remote-wallet" ) ]
65- let mut wallet_manager: Option < Arc < RemoteWalletManager > > = None ;
66-
67- #[ cfg( not( feature = "remote-wallet" ) ) ]
6861 let mut wallet_manager = None ;
6962
7063 // Check if colors should be disabled (via flag or environment variable)
@@ -83,20 +76,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
8376 solana_cli_config:: Config :: load ( "~/.config/osvm/config.yml" ) . unwrap_or_default ( )
8477 } ;
8578
86- let default_signer = DefaultSigner :: new (
87- "keypair" ,
88- matches
89- . get_one :: < String > ( "keypair" )
90- . map ( |s| s. to_string ( ) )
91- . unwrap_or_else ( || cli_config. keypair_path . clone ( ) ) ,
92- ) ;
93-
94- // Create a compatibility wrapper for solana-clap-utils
95- let matches_compat = unsafe {
96- // This is safe because we're just reinterpreting the reference
97- // and the ArgMatchesExt struct is a transparent wrapper around ArgMatches
98- std:: mem:: transmute :: < & clap:: ArgMatches , & solana_clap_utils:: ArgMatches > ( matches)
99- } ;
79+ let keypair_path = matches
80+ . get_one :: < String > ( "keypair" )
81+ . map ( |s| s. to_string ( ) )
82+ . unwrap_or_else ( || cli_config. keypair_path . clone ( ) ) ;
83+
84+ // Create a signer directly from the keypair path
85+ let signer = solana_sdk:: signature:: read_keypair_file ( & keypair_path)
86+ . unwrap_or_else ( |err| {
87+ eprintln ! ( "Error reading keypair file {}: {}" , keypair_path, err) ;
88+ exit ( 1 ) ;
89+ } ) ;
10090
10191 Config {
10292 json_rpc_url : normalize_to_url_if_moniker (
@@ -105,20 +95,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
10595 . map ( |s| s. as_str ( ) )
10696 . unwrap_or ( & cli_config. json_rpc_url ) ,
10797 ) ,
108- #[ cfg( feature = "remote-wallet" ) ]
109- default_signer : default_signer
110- . signer_from_path ( matches_compat, & mut wallet_manager)
111- . unwrap_or_else ( |err| {
112- eprintln ! ( "error: {}" , err) ;
113- exit ( 1 ) ;
114- } ) ,
115- #[ cfg( not( feature = "remote-wallet" ) ) ]
116- default_signer : default_signer
117- . signer_from_path ( matches_compat, & mut wallet_manager)
118- . unwrap_or_else ( |err| {
119- eprintln ! ( "error: {}" , err) ;
120- exit ( 1 ) ;
121- } ) ,
98+ default_signer : Box :: new ( signer) ,
12299 // Count occurrences of the verbose flag to determine verbosity level
123100 verbose : matches. get_count ( "verbose" ) as u8 ,
124101 no_color,
@@ -160,12 +137,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
160137
161138 match sub_command {
162139 "balance" => {
163- // Create a compatibility wrapper for solana-clap-utils
164- let matches_compat = unsafe {
165- std:: mem:: transmute :: < & clap:: ArgMatches , & solana_clap_utils:: ArgMatches > ( matches)
166- } ;
167-
168- let address = pubkey_of ( matches_compat, "address" )
140+ let address = pubkey_of_checked ( matches, "address" )
169141 . unwrap_or_else ( || config. default_signer . pubkey ( ) ) ;
170142
171143 println ! (
@@ -260,25 +232,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
260232 _ => unreachable ! ( ) ,
261233 }
262234 }
263- ( "nodes" , Some ( nodes_matches) ) => {
264- let ( node_sub_command, node_sub_matches) = nodes_matches. subcommand ( ) ;
265- match ( node_sub_command, node_sub_matches) {
266- ( "list" , Some ( list_matches) ) => {
235+ "nodes" => {
236+ let Some ( ( node_sub_command, node_sub_matches) ) = matches. subcommand ( ) else {
237+ eprintln ! ( "No node subcommand provided" ) ;
238+ exit ( 1 ) ;
239+ } ;
240+
241+ match node_sub_command {
242+ "list" => {
267243 // List all nodes
268- let network = list_matches
244+ let network = node_sub_matches
269245 . get_one :: < String > ( "network" )
270246 . map ( |s| s. as_str ( ) )
271247 . unwrap_or ( "all" ) ;
272- let node_type = list_matches
248+ let node_type = node_sub_matches
273249 . get_one :: < String > ( "type" )
274250 . map ( |s| s. as_str ( ) )
275251 . unwrap_or ( "all" ) ;
276- let status = list_matches
252+ let status = node_sub_matches
277253 . get_one :: < String > ( "status" )
278254 . map ( |s| s. as_str ( ) )
279255 . unwrap_or ( "all" ) ;
280- let svm = list_matches . get_one :: < String > ( "svm" ) . map ( |s| s. as_str ( ) ) ;
281- let json_output = list_matches . contains_id ( "json" ) ;
256+ let svm = node_sub_matches . get_one :: < String > ( "svm" ) . map ( |s| s. as_str ( ) ) ;
257+ let json_output = node_sub_matches . contains_id ( "json" ) ;
282258
283259 match nodes:: list_all_nodes (
284260 & rpc_client,
@@ -302,7 +278,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
302278 }
303279 }
304280 }
305- ( "dashboard" , _ ) => {
281+ "dashboard" => {
306282 // Launch node monitoring dashboard
307283 match nodes:: run_dashboard (
308284 & rpc_client,
@@ -316,13 +292,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
316292 }
317293 }
318294 }
319- ( "status" , Some ( status_matches ) ) => {
295+ "status" => {
320296 // Check node status
321- let node_id = status_matches
297+ let node_id = node_sub_matches
322298 . get_one :: < String > ( "node-id" )
323299 . map ( |s| s. as_str ( ) )
324300 . unwrap ( ) ;
325- let json_output = status_matches . contains_id ( "json" ) ;
301+ let json_output = node_sub_matches . contains_id ( "json" ) ;
326302
327303 match nodes:: get_node_status ( node_id) {
328304 Ok ( status) => {
@@ -338,13 +314,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
338314 }
339315 }
340316 }
341- ( "get" , Some ( get_matches ) ) => {
317+ "get" => {
342318 // Get detailed node information
343- let node_id = get_matches
319+ let node_id = node_sub_matches
344320 . get_one :: < String > ( "node-id" )
345321 . map ( |s| s. as_str ( ) )
346322 . unwrap ( ) ;
347- let json_output = get_matches . contains_id ( "json" ) ;
323+ let json_output = node_sub_matches . contains_id ( "json" ) ;
348324
349325 match nodes:: get_node_info ( & rpc_client, node_id, config. commitment_config ) {
350326 Ok ( info) => {
@@ -360,9 +336,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
360336 }
361337 }
362338 }
363- ( "restart" , Some ( restart_matches ) ) => {
339+ "restart" => {
364340 // Restart a node
365- let node_id = restart_matches
341+ let node_id = node_sub_matches
366342 . get_one :: < String > ( "node-id" )
367343 . map ( |s| s. as_str ( ) )
368344 . unwrap ( ) ;
@@ -374,9 +350,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
374350 }
375351 }
376352 }
377- ( "stop" , Some ( stop_matches ) ) => {
353+ "stop" => {
378354 // Stop a node
379- let node_id = stop_matches
355+ let node_id = node_sub_matches
380356 . get_one :: < String > ( "node-id" )
381357 . map ( |s| s. as_str ( ) )
382358 . unwrap ( ) ;
@@ -388,17 +364,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
388364 }
389365 }
390366 }
391- ( "logs" , Some ( logs_matches ) ) => {
367+ "logs" => {
392368 // View node logs
393- let node_id = logs_matches
369+ let node_id = node_sub_matches
394370 . get_one :: < String > ( "node-id" )
395371 . map ( |s| s. as_str ( ) )
396372 . unwrap ( ) ;
397- let lines = logs_matches
373+ let lines = node_sub_matches
398374 . get_one :: < String > ( "lines" )
399375 . map ( |s| s. parse :: < usize > ( ) . unwrap_or ( 100 ) )
400376 . unwrap_or ( 100 ) ;
401- let follow = logs_matches . contains_id ( "follow" ) ;
377+ let follow = node_sub_matches . contains_id ( "follow" ) ;
402378
403379 match nodes:: get_node_logs ( node_id, lines, follow) {
404380 Ok ( _) => {
@@ -413,25 +389,25 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
413389 }
414390 }
415391 }
416- ( "deploy" , Some ( deploy_matches ) ) => {
392+ "deploy" => {
417393 // Deploy a new node
418- let svm = deploy_matches
394+ let svm = node_sub_matches
419395 . get_one :: < String > ( "svm" )
420396 . map ( |s| s. as_str ( ) )
421397 . unwrap ( ) ;
422- let node_type = deploy_matches
398+ let node_type = node_sub_matches
423399 . get_one :: < String > ( "type" )
424400 . map ( |s| s. as_str ( ) )
425401 . unwrap_or ( "validator" ) ;
426- let network = deploy_matches
402+ let network = node_sub_matches
427403 . get_one :: < String > ( "network" )
428404 . map ( |s| s. as_str ( ) )
429405 . unwrap_or ( "mainnet" ) ;
430- let host = deploy_matches
406+ let host = node_sub_matches
431407 . get_one :: < String > ( "host" )
432408 . map ( |s| s. as_str ( ) )
433409 . unwrap ( ) ;
434- let name = deploy_matches
410+ let name = node_sub_matches
435411 . get_one :: < String > ( "name" )
436412 . map ( |s| s. as_str ( ) )
437413 . unwrap_or ( "default" ) ;
@@ -955,4 +931,4 @@ mod test {
955931 // Assert that the deserialized data matches the original
956932 assert_eq ! ( faux, in_faux) ;
957933 }
958- }
934+ }
0 commit comments