-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(CLI): Generalize new account command #728
base: next
Are you sure you want to change the base?
Conversation
dcbe31c
to
ee9baf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some tests with the CLI and it seems to work correctly 👍 We should update the integration CLI tests with the new new-account command
bin/miden-cli/build.rs
Outdated
// TODO: Do we want to add this? | ||
output_filename.push(".mct"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's value in having different extensions. Just so we can differentiate templates from account files and exported notes
std::io::stdin().read_line(&mut input_value)?; | ||
let input_value = input_value.trim(); | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] | ||
pub enum CliAccountType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a small description mentioning that this is a redefinition of the AccountType
struct.
AccountType::RegularAccountImmutableCode | ||
}; | ||
|
||
// Use the provided account type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is a little out of place here, we could add it in line 247
bin/miden-cli/templates/faucet.toml
Outdated
@@ -0,0 +1,15 @@ | |||
name = "fungible_faucet" | |||
description = "This is a test component" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this template will be used in the CLI I would change this description.
const FAUCET_TEMPLATE_BYTES: &[u8] = | ||
include_bytes!(concat!(env!("OUT_DIR"), "/templates/faucet.mct")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a bit more descriptive (both the constant name and the file name) - e.g., basic_fungible_faucet.mct
.
/// Helper function to process extra component templates. | ||
/// It reads user input for each placeholder in a component template. | ||
// TODO: this could take a TOML file with key-values | ||
fn process_component_templates( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would probably move this function to the end of the file into the "HELPER FUNCTIONS" section.
print!( | ||
"Enter value for placeholder '{placeholder_key}' - {description} (type: {}): ", | ||
placeholder_type.r#type.to_string() | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this print out? Maybe it should look more like:
Enter value for 'token_metadata.max_supply' - maximum supply of the token in base units (type: felt):
140d424
to
380cace
Compare
380cace
to
4a60d04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good and I did some local tests which worked! The integration tests seem to be failing because of the CLI tests which should be updated.
bin/miden-cli/src/commands/init.rs
Outdated
CliError::Config( | ||
"failed to create account component templates directory".to_string().into(), | ||
err.to_string(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be like:
CliError::Config( | |
"failed to create account component templates directory".to_string().into(), | |
err.to_string(), | |
) | |
CliError::Config( | |
err.into() | |
"failed to create account component templates directory".to_string() | |
) |
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
…onMiden/miden-client into igamigo-general-new-acct
Closes #695
This can be tested with something like this:
miden init miden new-account --account-type fungible-faucet -c basic-fungible-faucet -i init_data.toml Succesfully created new account. To view account details execute `miden account -s 0x8318a196a267aea0000006b51e173a`
Where
init_data.toml
is:If no TOML is provided, it looks like this:
TODO:
TODOs
in these changes (removing unwraps)InitStorageData::from_toml
functionmiden-base
, we could do all of this better.