mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-19 08:08:45 +02:00
Contracts: make_outputs takes nanogrin amounts (Vec<u64>), not a string
OutputSelectionArgs.make_outputs was a comma-separated grin string parsed inside libwallet via amount_from_hr_string. Move that parsing to the CLI boundary and carry explicit nanogrin u64 amounts through the API and Context instead: - OutputSelectionArgs.make_outputs: Option<String> -> Option<Vec<u64>>; output_amounts() becomes a plain accessor, num_custom_outputs() uses len(). - The CLI (wallet_args) parses grin -> nanogrin per amount; ContractNewArgs and ContractSetupArgs carry Vec<u64> and copy it through. - Update the two tests that supplied make_outputs as a string. Addresses PR #754 review (types.rs, wallet_args.rs).
This commit is contained in:
+10
-8
@@ -1020,12 +1020,13 @@ pub fn parse_contract_new_args(
|
||||
};
|
||||
let make_outputs = match args.value_of("make-outputs") {
|
||||
Some(v) => {
|
||||
// Validate each comma-separated amount here so a bad value returns a
|
||||
// ParseError instead of panicking later in output_amounts().
|
||||
// Parse each comma-separated grin amount into nanogrin at the CLI boundary,
|
||||
// so the API and Context carry explicit u64 amounts.
|
||||
let mut amounts = Vec::new();
|
||||
for amt in v.split(',') {
|
||||
parse_grin_amount(amt, "make-outputs")?;
|
||||
amounts.push(parse_grin_amount(amt, "make-outputs")?);
|
||||
}
|
||||
Some(String::from(v))
|
||||
Some(amounts)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
@@ -1096,12 +1097,13 @@ pub fn parse_contract_setup_args(
|
||||
};
|
||||
let make_outputs = match args.value_of("make-outputs") {
|
||||
Some(v) => {
|
||||
// Validate each comma-separated amount here so a bad value returns a
|
||||
// ParseError instead of panicking later in output_amounts().
|
||||
// Parse each comma-separated grin amount into nanogrin at the CLI boundary,
|
||||
// so the API and Context carry explicit u64 amounts.
|
||||
let mut amounts = Vec::new();
|
||||
for amt in v.split(',') {
|
||||
parse_grin_amount(amt, "make-outputs")?;
|
||||
amounts.push(parse_grin_amount(amt, "make-outputs")?);
|
||||
}
|
||||
Some(String::from(v))
|
||||
Some(amounts)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user