From d45cd77ea98043245d7b6dd65335bc3184695303 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Fri, 6 Dec 2024 16:09:30 -0800 Subject: [PATCH] handle network dependencies correctly --- leo/cli/commands/debug.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/leo/cli/commands/debug.rs b/leo/cli/commands/debug.rs index 6c47e6810f..daac18a709 100644 --- a/leo/cli/commands/debug.rs +++ b/leo/cli/commands/debug.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::path::PathBuf; +use std::{fs, path::PathBuf}; use snarkvm::prelude::{Network, ProgramID, TestnetV0}; @@ -114,7 +114,21 @@ fn handle_debug(command: &LeoDebug, context: Context) -> Result<()> }) .collect(); - leo_interpreter::interpret(&paths, &[], address, command.block_height) + let imports_directory = package_path.join("build/imports"); + + let aleo_paths: Vec = if let Ok(dir) = fs::read_dir(imports_directory) { + dir.flat_map(|maybe_filename| maybe_filename.ok()) + .filter(|entry| entry.file_type().ok().map(|filetype| filetype.is_file()).unwrap_or(false)) + .flat_map(|entry| { + let path = entry.path(); + if path.extension().map(|e| e == "aleo").unwrap_or(false) { Some(path) } else { None } + }) + .collect() + } else { + Vec::new() + }; + + leo_interpreter::interpret(&paths, &aleo_paths, address, command.block_height) } else { let private_key: PrivateKey = PrivateKey::from_str(leo_package::VALIDATOR_0_PRIVATE_KEY)?; let address = Address::try_from(&private_key)?;