Skip to content

Commit 1e428c9

Browse files
authored
Merge pull request #4544 from anoma/grarco/masp-fee-payment-msg
Improve message for failing atomic batch
2 parents ac39e39 + a456b1a commit 1e428c9

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Improved the display of a transaction's result to account
2+
for shielded fee payment in a failing atomic batch.
3+
([\#4544](https://github.com/anoma/namada/pull/4544))

crates/sdk/src/tx.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,36 @@ pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) {
480480
false
481481
};
482482
let batch_results = resp.batch_result();
483-
if !batch_results.is_empty() {
483+
// If the batch contains at least one transaction
484+
if let Some((first_inner_hash, first_result)) = batch_results.first() {
484485
if !wrapper_successful {
485-
display_line!(
486-
context.io(),
487-
"Since the batch in its entirety failed, none of the \
488-
transactions listed below have been committed. Their results \
489-
are provided for completeness.",
486+
// Check if fees were paid via the shielded pool, in this case the
487+
// first transaction of the batch was committed regardless of the
488+
// batch failure (even for atomic batches)
489+
let masp_fee_payment = matches!(
490+
first_result,
491+
InnerTxResult::Success(res)
492+
if res.events.iter().any(|event| {
493+
event.kind() == &namada_tx::event::masp_types::FEE_PAYMENT
494+
})
490495
);
496+
if masp_fee_payment {
497+
display_line!(
498+
context.io(),
499+
"The first transaction of the batch ({}) was applied to \
500+
pay the fees via the MASP. Since the batch failed, none \
501+
of the remaining transactions listed below have been \
502+
committed. Their results are provided for completeness.",
503+
first_inner_hash
504+
);
505+
} else {
506+
display_line!(
507+
context.io(),
508+
"Since the batch in its entirety failed, none of the \
509+
transactions listed below have been committed. Their \
510+
results are provided for completeness.",
511+
);
512+
}
491513
}
492514
display_line!(context.io(), "Batch results:");
493515
}

0 commit comments

Comments
 (0)