-
Notifications
You must be signed in to change notification settings - Fork 35
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: Use AccountComponentTemplate
#680
Conversation
f69fdf5
to
1bee2f7
Compare
AccountComponentTemplate
b4ae4b1
to
3ed6e41
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.
Overall looks good. We can make use of the recently-merged CliError
enum.
568c3ca
to
40baa5a
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.
Looks good! Thank you. I left some comments inline. Some are minor and others are for bigger refactorings in the future.
Also, would be good to add some documentation about how this new functionality can be used.
#[derive(Debug, Parser, Clone)] | ||
/// Create a new wallet account. | ||
pub struct NewWalletCmd { |
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.
Same nit as above re putting comments above attributes.
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 actually meant docs/attributes on lines 213 - 214 (not for the internal fields). Re-arranging them for the fields is fine too - but let's make sure the descriptions still show up in the CLI correctly.
/// 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( | ||
extra_components: &[AccountComponentTemplate], | ||
) -> Result<Vec<AccountComponent>, CliError> { | ||
let mut account_components = vec![]; | ||
for component_template in extra_components { | ||
let mut init_storage_data = BTreeMap::new(); | ||
for (placeholder_key, placeholder_type) in | ||
component_template.metadata().get_unique_storage_placeholders() | ||
{ | ||
print!( | ||
"Enter hex value for placeholder '{}' (type: {}): ", | ||
placeholder_key, placeholder_type | ||
); | ||
std::io::stdout().flush()?; | ||
|
||
let mut input_value = String::new(); | ||
std::io::stdin().read_line(&mut input_value)?; | ||
let input_value = input_value.trim(); |
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 approach is fine for this PR, but it is actually different from how I originally thought about it. Specifically, I was imagining that we'd prompt the user to provide data for specific fields and so we'd show a filed name and a field description to the user (rather than showing placeholder and type).
This may require refactoring the structure in miden-base
- maybe to move away from placeholder-based approach and more toward specifying something like a "type" or a "kind" for a given storage slot. Let's create an issue for this.
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 see. I think we could show the storage slot metadata here (name and description), but not specifically for the values themselves although the placeholder itself does not carry this data (so it would have to be searched in the template metadata). Is this what you meant? Or did you mean more specific to the value?
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 ideally we'd iterate over all slots that require user input, show slot name/description, and allow user to enter the required values (there may be more than one value needed per slot). What we now call placeholder may need to be treated more like a "type" of the data. For example, we may have 3 slots each expecting Falcon public keys and so all 3 would have type auth::rpo_falcon512
(or something like this) - but the user should be able to provide 3 different public keys.
There are a few details to think through here - so, probably warrants a separate issue.
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.
Looks good! Thank you! I left just one nit inline. Once we address it and add some docs, we are good to merge.
#[derive(Debug, Parser, Clone)] | ||
/// Create a new wallet account. | ||
pub struct NewWalletCmd { |
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 actually meant docs/attributes on lines 213 - 214 (not for the internal fields). Re-arranging them for the fields is fine too - but let's make sure the descriptions still show up in the CLI correctly.
No description provided.