diff --git a/.changelog/unreleased/improvements/2677-update-account-threshold-check.md b/.changelog/unreleased/improvements/2677-update-account-threshold-check.md new file mode 100644 index 0000000000..cd03842f50 --- /dev/null +++ b/.changelog/unreleased/improvements/2677-update-account-threshold-check.md @@ -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)) \ No newline at end of file diff --git a/crates/apps/src/lib/cli.rs b/crates/apps/src/lib/cli.rs index 109c0d78af..15bdaea566 100644 --- a/crates/apps/src/lib/cli.rs +++ b/crates/apps/src/lib/cli.rs @@ -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.", )) } @@ -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.", )) } @@ -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 = > as AsRef>::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, @@ -4488,17 +4495,14 @@ pub mod args { threshold, } } - + fn def(app: App) -> App { app.add_args::>() - .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 \ @@ -4506,11 +4510,13 @@ 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.", )) } } + + impl CliToSdk> for Bond { fn to_sdk(self, ctx: &mut Context) -> Bond {