@@ -284,17 +284,18 @@ pub fn byte_size_to_type(byte_size: usize) -> (usize, Vec<String>) {
284
284
}
285
285
286
286
/// Given a string (typically a line of decompiled source code), extract a type cast if one exists.
287
- // TODO: instead of returning a String, return a ParamType
287
+ ///
288
288
/// ```
289
289
/// use heimdall_common::ether::evm::core::types::find_cast;
290
+ /// use ethers::abi::ParamType;
290
291
///
291
292
/// let line = "uint256(0x000011)";
292
293
/// let (range, cast_type) = find_cast(line).expect("failed to find type cast");
293
294
/// assert_eq!(range, 8..16);
294
295
/// assert_eq!(&line[range], "0x000011");
295
- /// assert_eq!(cast_type, "uint256" );
296
+ /// assert_eq!(cast_type, ParamType::Uint(256) );
296
297
/// ```
297
- pub fn find_cast ( line : & str ) -> Result < ( Range < usize > , String ) , Error > {
298
+ pub fn find_cast ( line : & str ) -> Result < ( Range < usize > , ParamType ) , Error > {
298
299
// find the start of the cast
299
300
match TYPE_CAST_REGEX . find ( line) . expect ( "Failed to find type cast." ) {
300
301
Some ( m) => {
@@ -304,7 +305,7 @@ pub fn find_cast(line: &str) -> Result<(Range<usize>, String), Error> {
304
305
305
306
// find where the cast ends
306
307
let range = find_balanced_encapsulator ( & line[ end..] , ( '(' , ')' ) ) ?;
307
- Ok ( ( end + range. start ..end + range. end , cast_type) )
308
+ Ok ( ( end + range. start ..end + range. end , to_type ( & cast_type) ) )
308
309
}
309
310
None => Err ( Error :: ParseError ( "failed to find type cast" . to_string ( ) ) ) ,
310
311
}
0 commit comments