@@ -2,23 +2,24 @@ use clap::{Arg, Command};
2
2
use papyrus_storage:: utils:: dump_declared_classes_table_by_block_range;
3
3
4
4
/// This executable dumps the declared_classes table from the storage to a file.
5
-
6
5
fn main ( ) {
7
6
let cli_params = get_cli_params ( ) ;
8
7
match dump_declared_classes_table_by_block_range (
9
8
cli_params. start_block ,
10
9
cli_params. end_block ,
11
10
& cli_params. file_path ,
11
+ & cli_params. chain_id ,
12
12
) {
13
13
Ok ( _) => println ! ( "Dumped declared_classes table to file: {} ." , cli_params. file_path) ,
14
- Err ( e) => println ! ( "Failed dumping declared_classes table with error: {} . " , e) ,
14
+ Err ( e) => println ! ( "Failed dumping declared_classes table with error: {}" , e) ,
15
15
}
16
16
}
17
17
18
18
struct CliParams {
19
19
start_block : u64 ,
20
20
end_block : u64 ,
21
21
file_path : String ,
22
+ chain_id : String ,
22
23
}
23
24
24
25
/// The start_block and end_block arguments are mandatory and define the block range to dump,
@@ -47,10 +48,17 @@ fn get_cli_params() -> CliParams {
47
48
. required ( true )
48
49
. help ( "The block number to end dumping at." ) ,
49
50
)
51
+ . arg (
52
+ Arg :: new ( "chain_id" )
53
+ . short ( 'c' )
54
+ . long ( "chain_id" )
55
+ . required ( true )
56
+ . help ( "The chain id SN_MAIN/SN_GOERLI, default value is SN_MAIN." ) ,
57
+ )
50
58
. get_matches ( ) ;
51
59
52
60
let file_path =
53
- matches. get_one :: < String > ( "file_path" ) . expect ( "Failed parsing file_path" ) . as_str ( ) ;
61
+ matches. get_one :: < String > ( "file_path" ) . expect ( "Failed parsing file_path" ) . to_string ( ) ;
54
62
let start_block = matches
55
63
. get_one :: < String > ( "start_block" )
56
64
. expect ( "Failed parsing start_block" )
@@ -64,5 +72,7 @@ fn get_cli_params() -> CliParams {
64
72
if start_block >= end_block {
65
73
panic ! ( "start_block must be smaller than end_block" ) ;
66
74
}
67
- CliParams { start_block, end_block, file_path : file_path. to_string ( ) }
75
+ let chain_id =
76
+ matches. get_one :: < String > ( "chain_id" ) . expect ( "Failed parsing chain_id" ) . to_string ( ) ;
77
+ CliParams { start_block, end_block, file_path, chain_id }
68
78
}
0 commit comments