@@ -249,14 +249,14 @@ bindings-add SOL_PATH: build-source
249249 mod_file=" ${rust_dir}/mod.rs"
250250 artifact=" bindings/rust/artifacts/${contract}.json"
251251
252+ # Ensure output directories exist before writing generated files.
253+ mkdir -p " bindings/rust/artifacts" " $rust_dir"
254+
252255 # 1. Strip artifact
253256 jq ' {abi, bytecode: {object: .bytecode.object}, deployedBytecode: {object: .deployedBytecode.object}}' \
254257 " forge-artifacts/${contract}.sol/${contract}.json" > " $artifact"
255258
256- # 2. Create module directory if needed
257- mkdir -p " $rust_dir"
258-
259- # 3. Create .rs file
259+ # 2. Create .rs file
260260 cat > " $rust_file" << EOF
261261 use alloy_sol_types::sol;
262262
@@ -270,19 +270,19 @@ bindings-add SOL_PATH: build-source
270270 );
271271 EOF
272272
273- # 4 . Add to mod.rs (skip if already present)
273+ # 3 . Add to mod.rs (skip if already present)
274274 if ! grep -q " mod ${snake};" " $mod_file" 2 >/ dev/ null; then
275275 echo " " >> " $mod_file"
276276 echo " mod ${snake};" >> " $mod_file"
277277 echo " pub use ${snake}::${contract};" >> " $mod_file"
278278 fi
279279
280- # 5 . Add module to lib.rs (skip if already present)
280+ # 4 . Add module to lib.rs (skip if already present)
281281 if ! grep -q " pub mod ${module};" " bindings/rust/src/lib.rs" 2 >/ dev/ null; then
282282 echo " pub mod ${module};" >> " bindings/rust/src/lib.rs"
283283 fi
284284
285- # 6 . Format generated code
285+ # 5 . Format generated code
286286 cd bindings/ rust && cargo fmt
287287
288288 echo " Added binding: ${contract} -> ${rust_file}"
0 commit comments