Skip to content

Commit

Permalink
Merge branch 'tomas/no-reveal-on-force' (#3245)
Browse files Browse the repository at this point in the history
* origin/tomas/no-reveal-on-force:
  changelog: add #3245
  sdk/tx: don't send reveal PK tx on txs with `--force`
  • Loading branch information
tzemanovic committed May 21, 2024
2 parents 40e40c3 + c7ba64b commit 30a52e8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/3245-no-reveal-on-force.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Do not submit a tx to reveal a PK when `--force` flag is used with a
transaction. ([\#3245](https://github.com/anoma/namada/pull/3245))
4 changes: 1 addition & 3 deletions crates/apps_lib/src/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ pub async fn submit_reveal_aux(
.find_public_key_by_pkh(pkh)
.map_err(|e| error::Error::Other(e.to_string()))?;

if tx::is_reveal_pk_needed(context.client(), address, args.force)
.await?
{
if tx::is_reveal_pk_needed(context.client(), address).await? {
display_line!(
context.io(),
"Submitting a tx to reveal the public key for address \
Expand Down
3 changes: 1 addition & 2 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,12 @@ pub async fn process_tx(
pub async fn is_reveal_pk_needed<C: crate::queries::Client + Sync>(
client: &C,
address: &Address,
force: bool,
) -> Result<bool>
where
C: crate::queries::Client + Sync,
{
// Check if PK revealed
Ok(force || !has_revealed_pk(client, address).await?)
Ok(!has_revealed_pk(client, address).await?)
}

/// Check if the public key for the given address has been revealed
Expand Down
6 changes: 4 additions & 2 deletions crates/tests/src/integration/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::integration::helpers::{
find_address, prepare_steward_commission_update_data,
};
use crate::integration::setup;
use crate::strings::{TX_APPLIED_SUCCESS, TX_REJECTED};
use crate::strings::{
TX_APPLIED_SUCCESS, TX_INSUFFICIENT_BALANCE, TX_REJECTED,
};
use crate::tx::tx_host_env::gov_storage::proposal::{
PGFInternalTarget, PGFTarget,
};
Expand Down Expand Up @@ -397,7 +399,7 @@ fn invalid_transactions() -> Result<()> {
&validator_one_rpc,
];
let captured = CapturedOutput::of(|| run(&node, Bin::Client, tx_args));
assert!(captured.contains(TX_REJECTED));
assert!(captured.contains(TX_INSUFFICIENT_BALANCE));

Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions crates/tests/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub const TX_APPLIED_SUCCESS: &str = "was successfully applied";
/// Inner transaction rejected by VP(s).
pub const TX_REJECTED: &str = "was rejected by VPs";

/// Inner transaction failed in execution of transfer with insufficient balance
pub const TX_INSUFFICIENT_BALANCE: &str = "insufficient balance";

/// Inner transaction failed in execution (no VPs ran).
pub const TX_FAILED: &str = "failed with error";

Expand Down

0 comments on commit 30a52e8

Please sign in to comment.