Skip to content

Commit

Permalink
Merge pull request #3566 from anoma/fraccaman/fix-update-account-clie…
Browse files Browse the repository at this point in the history
…nt-checks

fix client checks on update account
  • Loading branch information
mergify[bot] committed Jul 31, 2024
2 parents 34d324f + deb73e3 commit 87ac95c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improve client side checks for update-account transaction.
([\#3566](https://github.com/anoma/namada/pull/3566))
12 changes: 4 additions & 8 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3548,11 +3548,10 @@ pub async fn build_update_account(
let threshold = *threshold;

let invalid_threshold = threshold.is_zero();
let invalid_too_few_pks: bool = (public_keys.is_empty()
&& public_keys.len() < threshold as usize)
|| (account.get_all_public_keys().len() < threshold as usize);
let invalid_threshold_updated = !public_keys.is_empty() && public_keys.len() < threshold as usize;
let invalid_threshold_current = public_keys.is_empty() && account.get_all_public_keys().len() < threshold as usize;

if invalid_threshold || invalid_too_few_pks {
if invalid_threshold || invalid_threshold_updated || invalid_threshold_current {
edisplay_line!(
context.io(),
"Invalid account threshold: either the provided threshold is \
Expand All @@ -3567,10 +3566,7 @@ pub async fn build_update_account(

Some(threshold)
} else {
let invalid_too_few_pks = (!public_keys.is_empty()
&& public_keys.len() < account.threshold as usize)
|| (account.get_all_public_keys().len()
< account.threshold as usize);
let invalid_too_few_pks = !public_keys.is_empty() && public_keys.len() < account.threshold as usize;

if invalid_too_few_pks {
return Err(Error::from(TxSubmitError::InvalidAccountThreshold));
Expand Down

0 comments on commit 87ac95c

Please sign in to comment.