fix(tron-wallet-snap): price new-account TRX sends as 1 TRX + 100 Bandwidth - #175
fix(tron-wallet-snap): price new-account TRX sends as 1 TRX + 100 Bandwidth#175Battambang wants to merge 4 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.
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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.
| const bandwidthQuota = | ||
| transactionFeeSun > 0 | ||
| ? BigNumber(createAccountFeeSun).div(transactionFeeSun) | ||
| : BigNumber(createAccountFeeSun).div(FALLBACK_GET_TRANSACTION_FEE_SUN); |
# Conflicts: # packages/tron-wallet-snap/snap.manifest.json
| type ActivationAssessment = { | ||
| unactivatedCount: number; | ||
| ownerAddress: string | undefined; | ||
| }; |
There was a problem hiding this comment.
Let's move these types to types.ts, what do you think?
| const activation = await this.#assessAccountActivation({ | ||
| scope, | ||
| transaction, | ||
| }); |
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?
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