Skip to content

Commit

Permalink
[helper] add checks for if modules are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Jul 14, 2023
1 parent f8c374f commit 8e1fb38
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/rooch/src/commands/move_cli/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ impl CommandAction<ExecuteTransactionResponseView> for Publish {

// let modules = package.root_modules_map().iter_modules_owned();
let modules = package.root_modules_map();

// let pkg_address = modules..iter_modules_owned() modules[0].self_id().address().to_owned();
let pkg_address = modules.iter_modules_owned()[0]
.self_id()
.address()
.to_owned();
let empty_modules = modules.iter_modules_owned().is_empty();
let pkg_address = if !empty_modules {
let first_module = &modules.iter_modules_owned()[0];
first_module.self_id().address().to_owned()
} else {
return Err(RoochError::MoveCompilationError(format!(
"compiling move modules error! Is the project or module empty: {:?}",
empty_modules,
)));
};
let mut bundles: Vec<Vec<u8>> = vec![];
// let sorted_modules = Self::order_modules(modules)?;
let sorted_modules = sort_by_dependency_order(modules.iter_modules())?;
Expand Down

0 comments on commit 8e1fb38

Please sign in to comment.