diff --git a/.changelog/unreleased/bug-fixes/3594-client-fix.md b/.changelog/unreleased/bug-fixes/3594-client-fix.md new file mode 100644 index 0000000000..8e46318c14 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/3594-client-fix.md @@ -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)) \ No newline at end of file diff --git a/crates/apps_lib/src/client/tx.rs b/crates/apps_lib/src/client/tx.rs index 4f4269a458..481774ebd3 100644 --- a/crates/apps_lib/src/client/tx.rs +++ b/crates/apps_lib/src/client/tx.rs @@ -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?; @@ -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) = diff --git a/crates/proof_of_stake/src/error.rs b/crates/proof_of_stake/src/error.rs index c692e0decf..c8f2cfb1b0 100644 --- a/crates/proof_of_stake/src/error.rs +++ b/crates/proof_of_stake/src/error.rs @@ -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)] @@ -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 { @@ -194,12 +185,6 @@ impl From for namada_storage::Error { } } -impl From for namada_storage::Error { - fn from(err: WithdrawError) -> Self { - Self::new(err) - } -} - impl From for namada_storage::Error { fn from(err: CommissionRateChangeError) -> Self { Self::new(err) diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index ca7204fb94..8b0737bc36 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -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<