@@ -15,7 +15,6 @@ use eyre::{Context, OptionExt, Result};
15
15
use foundry_common:: fs;
16
16
use proc_macro2:: { Span , TokenStream } ;
17
17
use std:: {
18
- env:: temp_dir,
19
18
fmt:: Write ,
20
19
path:: { Path , PathBuf } ,
21
20
str:: FromStr ,
@@ -38,6 +37,7 @@ impl SolMacroGen {
38
37
let path = self . path . to_string_lossy ( ) . into_owned ( ) ;
39
38
let name = proc_macro2:: Ident :: new ( & self . name , Span :: call_site ( ) ) ;
40
39
let tokens = quote:: quote! {
40
+ #[ sol( ignore_unlinked) ]
41
41
#name,
42
42
#path
43
43
} ;
@@ -85,38 +85,7 @@ impl MultiSolMacroGen {
85
85
}
86
86
87
87
fn generate_binding ( instance : & mut SolMacroGen , all_derives : bool ) -> Result < ( ) > {
88
- // TODO: in `get_sol_input` we currently can't handle unlinked bytecode: <https://github.com/alloy-rs/core/issues/926>
89
- let input = match instance. get_sol_input ( ) {
90
- Ok ( input) => input. normalize_json ( ) ?,
91
- Err ( error) => {
92
- // TODO(mattsse): remove after <https://github.com/alloy-rs/core/issues/926>
93
- if error. to_string ( ) . contains ( "expected bytecode, found unlinked bytecode" ) {
94
- // we attempt to do a little hack here until we have this properly supported by
95
- // removing the bytecode objects from the json file and using a tmpfile (very
96
- // hacky)
97
- let content = std:: fs:: read_to_string ( & instance. path ) ?;
98
- let mut value = serde_json:: from_str :: < serde_json:: Value > ( & content) ?;
99
- let obj = value. as_object_mut ( ) . expect ( "valid abi" ) ;
100
-
101
- // clear unlinked bytecode
102
- obj. remove ( "bytecode" ) ;
103
- obj. remove ( "deployedBytecode" ) ;
104
-
105
- let tmpdir = temp_dir ( ) ;
106
- let mut tmp_file = tmpdir. join ( instance. path . file_name ( ) . unwrap ( ) ) ;
107
- std:: fs:: write ( & tmp_file, serde_json:: to_string ( & value) ?) ?;
108
-
109
- // try again
110
- std:: mem:: swap ( & mut tmp_file, & mut instance. path ) ;
111
- let input = instance. get_sol_input ( ) ?. normalize_json ( ) ?;
112
- std:: mem:: swap ( & mut tmp_file, & mut instance. path ) ;
113
- input. normalize_json ( ) ?
114
- } else {
115
- return Err ( error) ;
116
- }
117
- }
118
- } ;
119
-
88
+ let input = instance. get_sol_input ( ) ?. normalize_json ( ) ?;
120
89
let SolInput { attrs : _, path : _, kind } = input;
121
90
122
91
let tokens = match kind {
0 commit comments