Skip to content

fix: added energy and bandwidth in transaction confirmation dialog from a dApp#355

Open
gabrieledm wants to merge 6 commits into
mainfrom
fix/WPN-454_transaction-gas-fee-estimation-is-inaccurate-and-incomplete
Open

fix: added energy and bandwidth in transaction confirmation dialog from a dApp#355
gabrieledm wants to merge 6 commits into
mainfrom
fix/WPN-454_transaction-gas-fee-estimation-is-inaccurate-and-incomplete

Conversation

@gabrieledm

@gabrieledm gabrieledm commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR fixes Tron dApp transaction confirmations so fee/resource information and balance validation are more accurate.

  • Display estimated ENERGY and BANDWIDTH usage in the transaction confirmation even when those resources are covered by available/free/staked resources.
  • Show the full estimated energy and bandwidth usage, while charging TRX only for the portion not covered by the user’s available resources.
  • Add insufficient-balance detection for dApp transaction confirmations by comparing:
    • native TRX transferred by the transaction
    • estimated TRX fees
    • current native TRX balance
  • Disable the confirmation button and show an Insufficient funds banner when the account cannot cover the transaction value plus fees.
  • Add getTransactionTrxValue helper to extract native TRX value from:
    • TransferContract.amount
    • TriggerSmartContract.call_value
  • Update confirmation context types to include isInsufficientBalance.
  • Update/add tests for fee calculation, transaction TRX value extraction, confirmation rendering, and insufficient-balance UI behavior.

References

Before

Send

WPN-454  Before - Send

Swap

WPN-454  Before - Swap

dApp - Enough funds

WPN-454  Before - dApp - Enough funds

dApp - Insufficient funds

WPN-454  Before - dApp - Insufficient funds

After

Send

WPN-454  After - Send

Swap

WPN-454  After - Swap

dApp - Enough funds

WPN-454  After - dApp - Enough funds

dApp - Insufficient funds

WPN-454  After - dApp - Insufficient funds

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [] I've communicated my changes to consumers by updating changelogs for packages I've changed
  • [] I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes the transaction signing confirmation gate and fee display for dApp flows; incorrect balance or fee logic could wrongly allow or block signatures.

Overview
Improves dApp transaction confirmations by showing the full estimated energy and bandwidth the transaction will use, even when those resources are covered by staked/free balances. TRX fee math is unchanged—users still pay TRX only for resource shortfalls.

Adds insufficient-funds protection on the confirmation screen: native TRX sent with the tx (TransferContract / TriggerSmartContract call_value) plus estimated TRX fees are compared to the account’s TRX balance. When balance is too low, an Insufficient funds banner appears and Confirm stays disabled.

Supporting updates include getTransactionTrxValue, isInsufficientBalance on confirmation context, fee-calculator test expectations, and changelog/coverage/manifest shasum tweaks.

Reviewed by Cursor Bugbot for commit 7201ce3. Bugbot is set up for automated code reviews on this repo. Configure here.

@gabrieledm gabrieledm requested a review from a team as a code owner July 10, 2026 08:01
@gabrieledm gabrieledm force-pushed the fix/WPN-454_transaction-gas-fee-estimation-is-inaccurate-and-incomplete branch from 37cff26 to e88cf2d Compare July 10, 2026 08:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e88cf2d. Configure here.

Comment thread packages/snap/snap.manifest.json Outdated
"jobs": [
{
"duration": "PT60S",
"duration": "PT30S",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regression. We want the value to be PT60S as per latest PRs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this regression.
Pushing the restored value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants