File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1
1
use super :: { install, watch:: WatchArgs } ;
2
2
use clap:: Parser ;
3
3
use eyre:: Result ;
4
- use foundry_cli:: { opts:: BuildOpts , utils:: LoadConfig } ;
4
+ use foundry_cli:: {
5
+ opts:: BuildOpts ,
6
+ utils:: { cache_local_signatures, LoadConfig } ,
7
+ } ;
5
8
use foundry_common:: { compile:: ProjectCompiler , shell} ;
6
9
use foundry_compilers:: {
7
10
compilers:: { multi:: MultiCompilerLanguage , Language } ,
@@ -100,6 +103,9 @@ impl BuildArgs {
100
103
101
104
let output = compiler. compile ( & project) ?;
102
105
106
+ // Cache project selectors.
107
+ cache_local_signatures ( & output, & Config :: foundry_cache_dir ( ) . unwrap ( ) ) ?;
108
+
103
109
if format_json && !self . names && !self . sizes {
104
110
sh_println ! ( "{}" , serde_json:: to_string_pretty( & output. output( ) ) ?) ?;
105
111
}
Original file line number Diff line number Diff line change @@ -3828,3 +3828,41 @@ Encountered a total of 1 failing tests, 0 tests succeeded
3828
3828
3829
3829
"# ] ] ) ;
3830
3830
} ) ;
3831
+
3832
+ // This test is a copy of `error_event_decode_with_cache` in cast/tests/cli/selectors.rs
3833
+ // but it uses `forge build` to check that the project selectors are cached by default.
3834
+ forgetest_init ! ( build_with_selectors_cache, |prj, cmd| {
3835
+ prj. add_source(
3836
+ "LocalProjectContract" ,
3837
+ r#"
3838
+ contract ContractWithCustomError {
3839
+ error AnotherValueTooHigh(uint256, address);
3840
+ event MyUniqueEventWithinLocalProject(uint256 a, address b);
3841
+ }
3842
+ "# ,
3843
+ )
3844
+ . unwrap( ) ;
3845
+ // Build and cache project selectors.
3846
+ cmd. forge_fuse( ) . args( [ "build" ] ) . assert_success( ) ;
3847
+
3848
+ // Assert cast can decode custom error with local cache.
3849
+ cmd. cast_fuse( )
3850
+ . args( [ "decode-error" , "0x7191bc6200000000000000000000000000000000000000000000000000000000000000650000000000000000000000000000000000000000000000000000000000D0004F" ] )
3851
+ . assert_success( )
3852
+ . stdout_eq( str ![ [ r#"
3853
+ AnotherValueTooHigh(uint256,address)
3854
+ 101
3855
+ 0x0000000000000000000000000000000000D0004F
3856
+
3857
+ "# ] ] ) ;
3858
+ // Assert cast can decode event with local cache.
3859
+ cmd. cast_fuse( )
3860
+ . args( [ "decode-event" , "0xbd3699995dcc867b64dbb607be2c33be38df9134bef1178df13bfb9446e73104000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000dd00000004e" ] )
3861
+ . assert_success( )
3862
+ . stdout_eq( str ![ [ r#"
3863
+ MyUniqueEventWithinLocalProject(uint256,address)
3864
+ 78
3865
+ 0x00000000000000000000000000000DD00000004e
3866
+
3867
+ "# ] ] ) ;
3868
+ } ) ;
You can’t perform that action at this time.
0 commit comments