fix(tron-wallet-snap): price new-account TRX sends as 1 TRX + 100 Bandwidth - #175
Open
Battambang wants to merge 6 commits into
Open
fix(tron-wallet-snap): price new-account TRX sends as 1 TRX + 100 Bandwidth#175Battambang wants to merge 6 commits into
Battambang wants to merge 6 commits into
Conversation
…dwidth Activation was billed as TransferContract byte size (~266) plus 1 TRX, which overstated Testing Day costs. Use create-account Bandwidth from chain params, staked quota only, and a 0.1 TRX shortfall instead.
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates TRON account-activation fee estimation to use protocol-defined fees and staked Bandwidth.
Changes:
- Adds dynamic activation-fee and Bandwidth calculations for TRX/TRC-10 transfers.
- Expands activation and memo-fee tests.
- Updates package metadata and changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
FeeCalculatorService.ts |
Implements activation fee estimation. |
FeeCalculatorService.test.ts |
Adds activation scenarios. |
constants/index.ts |
Adds fallback fee constants. |
snap.manifest.json |
Updates bundle checksum. |
CHANGELOG.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+806
to
+809
| const bandwidthQuota = | ||
| transactionFeeSun > 0 | ||
| ? BigNumber(createAccountFeeSun).div(transactionFeeSun) | ||
| : BigNumber(createAccountFeeSun).div(FALLBACK_GET_TRANSACTION_FEE_SUN); |
# Conflicts: # packages/tron-wallet-snap/snap.manifest.json
| const activation = await this.#assessAccountActivation({ | ||
| scope, | ||
| transaction, | ||
| }); |
Contributor
There was a problem hiding this comment.
Why do we need so much code to check activation when we have the isAccountActivated method? Do we really need to fetch transactions and all that? Am I missing something?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
This pull request updates the account activation fee logic for TRON native and TRC-10 token transfers, ensuring that fee estimation for sending to unactivated accounts aligns with the TRON protocol. Specifically, it distinguishes between using staked Bandwidth (costing 1 TRX + 100 Bandwidth) and burning 0.1 TRX when the sender lacks staked Bandwidth, instead of relying on transaction byte size. The changes also add new constants, improve test coverage, and refactor test cases for clarity and correctness.
Fee Calculation Improvements
FALLBACK_CREATE_ACCOUNT_FEE_SUN(0.1 TRX) andFALLBACK_CREATE_NEW_ACCOUNT_FEE_SUN(1 TRX) constants toconstants/index.tsfor use in fee calculations.Test Coverage and Refactoring
FeeCalculatorService.test.tsto cover scenarios for native and TRC-10 sends to unactivated accounts, including cases with and without staked Bandwidth, and with memo fees. [1] [2] [3] [4] [5] [6] [7] [8]These changes ensure more accurate and protocol-compliant fee estimates for TRON account activation scenarios.
What the UI array looks like depending of scenario:
Screenshots
BEFORE:

AFTER:

References
https://consensyssoftware.atlassian.net/browse/WPN-1408
Checklist