@@ -454,7 +454,29 @@ impl WalletSubcommands {
454
454
} else {
455
455
wallet. sign_message ( & Self :: hex_str_to_bytes ( & message) ?) . await ?
456
456
} ;
457
- sh_println ! ( "0x{}" , hex:: encode( sig. as_bytes( ) ) ) ?;
457
+
458
+ if shell:: verbosity ( ) > 0 {
459
+ if shell:: is_json ( ) {
460
+ sh_println ! (
461
+ "{}" ,
462
+ serde_json:: to_string_pretty( & json!( {
463
+ "message" : message,
464
+ "address" : wallet. address( ) ,
465
+ "signature" : hex:: encode( sig. as_bytes( ) ) ,
466
+ } ) ) ?
467
+ ) ?;
468
+ } else {
469
+ sh_println ! (
470
+ "Successfully signed!\n Message: {}\n Address: {}\n Signature: 0x{}" ,
471
+ message,
472
+ wallet. address( ) ,
473
+ hex:: encode( sig. as_bytes( ) ) ,
474
+ ) ?;
475
+ }
476
+ } else {
477
+ // Pipe friendly output
478
+ sh_println ! ( "0x{}" , hex:: encode( sig. as_bytes( ) ) ) ?;
479
+ }
458
480
}
459
481
Self :: SignAuth { rpc, nonce, chain, wallet, address } => {
460
482
let wallet = wallet. signer ( ) . await ?;
@@ -472,7 +494,31 @@ impl WalletSubcommands {
472
494
let auth = Authorization { chain_id : U256 :: from ( chain_id) , address, nonce } ;
473
495
let signature = wallet. sign_hash ( & auth. signature_hash ( ) ) . await ?;
474
496
let auth = auth. into_signed ( signature) ;
475
- sh_println ! ( "{}" , hex:: encode_prefixed( alloy_rlp:: encode( & auth) ) ) ?;
497
+
498
+ if shell:: verbosity ( ) > 0 {
499
+ if shell:: is_json ( ) {
500
+ sh_println ! (
501
+ "{}" ,
502
+ serde_json:: to_string_pretty( & json!( {
503
+ "nonce" : nonce,
504
+ "chain_id" : chain_id,
505
+ "address" : wallet. address( ) ,
506
+ "signature" : hex:: encode_prefixed( alloy_rlp:: encode( & auth) ) ,
507
+ } ) ) ?
508
+ ) ?;
509
+ } else {
510
+ sh_println ! (
511
+ "Successfully signed!\n Nonce: {}\n Chain ID: {}\n Address: {}\n Signature: 0x{}" ,
512
+ nonce,
513
+ chain_id,
514
+ wallet. address( ) ,
515
+ hex:: encode_prefixed( alloy_rlp:: encode( & auth) ) ,
516
+ ) ?;
517
+ }
518
+ } else {
519
+ // Pipe friendly output
520
+ sh_println ! ( "{}" , hex:: encode_prefixed( alloy_rlp:: encode( & auth) ) ) ?;
521
+ }
476
522
}
477
523
Self :: Verify { message, signature, address } => {
478
524
let recovered_address = Self :: recover_address_from_message ( & message, & signature) ?;
0 commit comments