File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -194,8 +194,15 @@ pub async fn run_command(args: CastArgs) -> Result<()> {
194
194
sh_println ! ( "{}" , SimpleCast :: abi_encode_packed( & sig, & args) ?) ?
195
195
}
196
196
}
197
- CastSubcommand :: DecodeCalldata { sig, calldata } => {
198
- let tokens = SimpleCast :: calldata_decode ( & sig, & calldata, true ) ?;
197
+ CastSubcommand :: DecodeCalldata { sig, calldata, file } => {
198
+ let raw_hex = if let Some ( file_path) = file {
199
+ let contents = fs:: read_to_string ( & file_path) ?;
200
+ contents. trim ( ) . to_string ( )
201
+ } else {
202
+ calldata. unwrap ( )
203
+ } ;
204
+
205
+ let tokens = SimpleCast :: calldata_decode ( & sig, & raw_hex, true ) ?;
199
206
print_tokens ( & tokens) ;
200
207
}
201
208
CastSubcommand :: CalldataEncode { sig, args, file } => {
Original file line number Diff line number Diff line change @@ -574,7 +574,12 @@ pub enum CastSubcommand {
574
574
sig : String ,
575
575
576
576
/// The ABI-encoded calldata.
577
- calldata : String ,
577
+ #[ arg( required_unless_present = "file" , index = 2 ) ]
578
+ calldata : Option < String > ,
579
+
580
+ /// Load ABI-encoded calldata from a file instead.
581
+ #[ arg( long = "file" , short = 'f' , conflicts_with = "calldata" ) ]
582
+ file : Option < PathBuf > ,
578
583
} ,
579
584
580
585
/// Decode ABI-encoded string.
You can’t perform that action at this time.
0 commit comments