Skip to content

Commit 27b99dd

Browse files
fix: replace Vec<PackagePath> with Option<PackagePath>
Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
1 parent 90c41b3 commit 27b99dd

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

bin/miden-cli/src/commands/new_account.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ pub struct NewWalletCmd {
8686
/// Optional list of files specifying additional components to add to the account.
8787
#[arg(short, long)]
8888
pub extra_components: Vec<PathBuf>,
89-
/// Optional list of files containing a Miden Package in `.masp` form from which a
90-
/// component template can be extracted.
91-
#[arg(short, long)]
92-
pub packages: Vec<PathBuf>,
9389
/// Optional file path to a TOML file containing a list of key/values used for initializing
9490
/// storage. Each of these keys should map to the templated storage values within the passed
9591
/// list of component templates. The user will be prompted to provide values for any keys not
@@ -124,7 +120,7 @@ impl NewWalletCmd {
124120
account_type,
125121
self.storage_mode.into(),
126122
&component_template_paths,
127-
&self.packages,
123+
None,
128124
self.init_storage_data_path.clone(),
129125
self.deploy,
130126
)
@@ -165,10 +161,10 @@ pub struct NewAccountCmd {
165161
/// [[`NewAccountCmd::component_templates`]] or by [[`NewAccountCmd::packages`]].
166162
#[arg(short, long)]
167163
pub component_templates: Vec<PathBuf>,
168-
/// List of files containing a Miden Package in `.masp` form from which a
169-
/// component template is extracted.
164+
/// File containing a Miden Package in `.masp` form which multiple component
165+
/// templates can be extracted.
170166
#[arg(short, long)]
171-
pub packages: Vec<PathBuf>,
167+
pub package: PathBuf,
172168
/// Optional file path to a TOML file containing a list of key/values used for initializing
173169
/// storage. Each of these keys should map to the templated storage values within the passed
174170
/// list of component templates. The user will be prompted to provide values for any keys not
@@ -193,7 +189,7 @@ impl NewAccountCmd {
193189
self.account_type.into(),
194190
self.storage_mode.into(),
195191
&self.component_templates,
196-
&self.packages,
192+
Some(&self.package),
197193
self.init_storage_data_path.clone(),
198194
self.deploy,
199195
)
@@ -218,7 +214,7 @@ type PackagePath = PathBuf;
218214
/// Reads component templates and [[`miden_core::vm::Package`]]s from the given file paths.
219215
fn load_component_templates(
220216
component_paths: &[ComponentPath],
221-
package_paths: &[PackagePath],
217+
package_path: Option<&PackagePath>,
222218
) -> Result<Vec<AccountComponentTemplate>, CliError> {
223219
let (cli_config, _) = load_config_file()?;
224220
let mut templates = Vec::new();
@@ -274,7 +270,7 @@ fn load_component_templates(
274270
}
275271

276272
let packages_dir = &cli_config.package_directory;
277-
for path in package_paths {
273+
if let Some(path) = package_path {
278274
// If a user passes in a file with the `.masp` file extension, then we
279275
// leave the passed in path as is; since it probably is a full path.
280276
// This is the case with cargo-miden, which displays the full path to
@@ -358,19 +354,19 @@ async fn create_client_account<AUTH: TransactionAuthenticator + Sync + 'static>(
358354
account_type: AccountType,
359355
storage_mode: AccountStorageMode,
360356
component_template_paths: &[PathBuf],
361-
package_paths: &[PathBuf],
357+
package_path: Option<&PathBuf>,
362358
init_storage_data_path: Option<PathBuf>,
363359
deploy: bool,
364360
) -> Result<Account, CliError> {
365-
if component_template_paths.is_empty() && package_paths.is_empty() {
361+
if component_template_paths.is_empty() && package_path.is_none() {
366362
return Err(CliError::InvalidArgument(
367363
"account must contain at least one component".into(),
368364
));
369365
}
370366

371367
// Load the component templates and initialization storage data.
372368
debug!("Loading component templates...");
373-
let component_templates = load_component_templates(component_template_paths, package_paths)?;
369+
let component_templates = load_component_templates(component_template_paths, package_path)?;
374370
debug!("Loaded {} component templates", component_templates.len());
375371
debug!("Loading initialization storage data...");
376372
let init_storage_data = load_init_storage_data(init_storage_data_path)?;

0 commit comments

Comments
 (0)