Skip to content
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

BugFix: Adding Client side check For Requiring threshold < Noof public keys in update-account #2677

Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added Client check to not allow --threshold to be great than No.of Public keys in update-account call
([\#2677](https://github.com/anoma/namada/pull/2677))
28 changes: 17 additions & 11 deletions crates/apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4177,7 +4177,7 @@ pub mod args {
))
.arg(THRESHOLD.def().help(
"The minimum number of signature to be provided for \
authorization. Must be less then the maximum number of \
authorization. Must be less than the maximum number of \
public keys provided.",
))
}
Expand Down Expand Up @@ -4446,7 +4446,7 @@ pub mod args {
))
.arg(THRESHOLD.def().help(
"The minimum number of signature to be provided for \
authorization. Must be less then the maximum number of \
authorization. Must be less than the maximum number of \
public keys provided.",
))
}
Expand Down Expand Up @@ -4479,6 +4479,13 @@ pub mod args {
let tx_code_path = PathBuf::from(TX_UPDATE_ACCOUNT_WASM);
let public_keys = PUBLIC_KEYS.parse(matches);
let threshold = THRESHOLD.parse(matches);

let num_keys = <Vec<cli::context::FromContext<namada::ledger::pos::common::PublicKey>> as AsRef<T>>::as_ref(&public_keys).map_or(0, |keys| keys.len());
if num_keys < threshold {
eprintln!("Threshold must be less than the number of public keys provided.");
std::process::exit(1);
}

Self {
tx,
vp_code_path,
Expand All @@ -4488,29 +4495,28 @@ pub mod args {
threshold,
}
}

fn def(app: App) -> App {
app.add_args::<Tx<CliTypes>>()
.arg(
CODE_PATH_OPT.def().help(
"The path to the new validity predicate WASM code.",
),
)
.arg(CODE_PATH_OPT.def().help(
"The path to the new validity predicate WASM code.",
))
.arg(ADDRESS.def().help(
"The account's address. It's key is used to produce the \
signature.",
"The account's address. It's key is used to produce the signature.",
))
.arg(PUBLIC_KEYS.def().help(
"A list public keys to be associated with the new account \
in hexadecimal encoding.",
))
.arg(THRESHOLD.def().help(
"The minimum number of signature to be provided for \
authorization. Must be less then the maximum number of \
authorization. Must be less than the maximum number of \
public keys provided.",
))
}
}



impl CliToSdk<Bond<SdkTypes>> for Bond<CliTypes> {
fn to_sdk(self, ctx: &mut Context) -> Bond<SdkTypes> {
Expand Down
Loading