Skip to content

Commit

Permalink
Merge pull request #3594 from anoma/brent/client-fix
Browse files Browse the repository at this point in the history
Client improvements
  • Loading branch information
mergify[bot] authored Aug 9, 2024
2 parents 1a8376e + 4d53afe commit c1f015c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .changelog/unreleased/bug-fixes/3594-client-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- No-op instead of error in wasm for withdraw txs if no tokens are available
to withdraw. Automatically submit reveal pk tx for source for shielding
transfers. ([\#3594](https://github.com/anoma/namada/pull/3594))
19 changes: 7 additions & 12 deletions crates/apps_lib/src/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,18 +766,9 @@ pub async fn submit_transparent_transfer(
));
}

submit_reveal_aux(
namada,
args.tx.clone(),
&args
.data
.first()
.ok_or_else(|| {
error::Error::Other("Missing transfer data".to_string())
})?
.source,
)
.await?;
for datum in args.data.iter() {
submit_reveal_aux(namada, args.tx.clone(), &datum.source).await?;
}

let (mut tx, signing_data) = args.clone().build(namada).await?;

Expand Down Expand Up @@ -810,6 +801,10 @@ pub async fn submit_shielding_transfer(
namada: &impl Namada,
args: args::TxShieldingTransfer,
) -> Result<(), error::Error> {
for datum in args.data.iter() {
submit_reveal_aux(namada, args.tx.clone(), &datum.source).await?;
}

// Repeat once if the tx fails on a crossover of an epoch
for _ in 0..2 {
let (mut tx, signing_data, tx_epoch) =
Expand Down
17 changes: 1 addition & 16 deletions crates/proof_of_stake/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use namada_core::storage::Epoch;
use thiserror::Error;

use crate::rewards;
use crate::types::{BondId, ValidatorState};
use crate::types::ValidatorState;

#[allow(missing_docs)]
#[derive(Error, Debug)]
Expand Down Expand Up @@ -67,15 +67,6 @@ pub enum UnbondError {
ValidatorIsFrozen(Address),
}

#[allow(missing_docs)]
#[derive(Error, Debug)]
pub enum WithdrawError {
#[error("No unbond could be found for {0}")]
NoUnbondFound(BondId),
#[error("No unbond may be withdrawn yet for {0}")]
NoWithdrawableUnbond(BondId),
}

#[allow(missing_docs)]
#[derive(Error, Debug)]
pub enum SlashError {
Expand Down Expand Up @@ -194,12 +185,6 @@ impl From<UnbondError> for namada_storage::Error {
}
}

impl From<WithdrawError> for namada_storage::Error {
fn from(err: WithdrawError) -> Self {
Self::new(err)
}
}

impl From<CommissionRateChangeError> for namada_storage::Error {
fn from(err: CommissionRateChangeError) -> Self {
Self::new(err)
Expand Down
6 changes: 1 addition & 5 deletions crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,11 +1478,7 @@ where

// Check that there are unbonded tokens available for withdrawal
if unbond_handle.is_empty(storage)? {
return Err(WithdrawError::NoUnbondFound(BondId {
source: source.clone(),
validator: validator.clone(),
})
.into());
return Ok(token::Amount::zero());
}

let mut unbonds_and_redelegated_unbonds: BTreeMap<
Expand Down

0 comments on commit c1f015c

Please sign in to comment.