Repository navigation
feat(ramps): add Tron amount validation on BuildQuote screen [DRAFT] - #39206
wantedsystem wants to merge 1 commit into
Conversation
Add debounced balance-only validation for Tron assets on the Sell amount input screen (BuildQuote), and wire the Max button to use the Snap's getMaxSendableAmount method for precise fee-aware amounts. Changes: - core/Multichain/tron.ts: Add getMaxSendableTronAmount function, make toAddress optional in validateTronTransferAmount for balance-only validation - Aggregator/hooks/useTronAmountValidation: New debounced validation hook that calls onAmountInput without toAddress after 500ms - BuildQuote: Integrate Tron validation hook, show inline error, disable Continue button when validation fails, wire Max to Snap's getMaxSendableAmount with fallback - tests: Unit tests for tron.ts additions and useTronAmountValidation hook (8 test cases covering debounce, error states, and cancellation) All gated behind rampsOffRampNonEvm feature flag. EVM and other non-EVM (Solana) behavior unchanged. Depends on internal-snaps #554 (onAmountInput conservative estimates) and #549 (getMaxSendableAmount) being merged and released. Co-authored-by: Amine Harty <wantedsystem@users.noreply.github.com>
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
Smart E2E Test SelectionSelected E2E tags: ALL AI Confidence: 100 E2E reasoningExpand to readHard rule floor (en-locale-change): locales/languages/en.json adds a new Beyond the locale change, the PR introduces:
The combination of a locale change (hard rule), modifications to the core Ramp BuildQuote view (SmokeMoney), and Multichain/Tron changes (SmokeNetworkExpansion) justifies running ALL smoke tags. The locale change alone is sufficient to trigger the ALL floor per the hard rule. |
Accessibility (draft)Since this is still a draft, no rush here, just a heads-up for when you wrap it up. One spot in
An AI accessibility agent posted this. If this is wrong, reply here. |
Description
Draft PR: Continues non-EVM (Tron) work in the Ramps off-ramp (Sell) flow by adding debounced balance-only validation on the amount input screen (BuildQuote) and wiring the Max button to the Snap's
getMaxSendableAmountmethod.Depends on:
onAmountInputinternal-snaps#554 (WPN-2375:onAmountInputconservative fee estimates)getMaxSendableAmountclient request method internal-snaps#549 (WPN-2374:getMaxSendableAmount)These Snap PRs must be merged and released before this can be merged.
What's Done
✅ BuildQuote screen validation:
onAmountInputwithouttoAddressrampsOffRampNonEvmfeature flag✅ Max button integration:
getMaxSendableAmount✅ Core utilities:
getMaxSendableTronAmountfunction incore/Multichain/tron.tsvalidateTronTransferAmountnow accepts optionaltoAddressfor balance-only validationuseTronAmountValidationhook with debounce and error mapping✅ Tests:
getMaxSendableTronAmount(5 test cases)validateTronTransferAmountwith optionaltoAddress(1 test case)useTronAmountValidationhook (8 test cases)✅ Compilation:
What's NOT Done (Follow-ups)
❌ Integration with existing pre-send validation:
validateTronTransferAmountin SendTransaction (from PR feat(ramp): validate Tron off-ramp transfers before Snap confirmation #38249) is preserved and still runs beforeconfirmSend❌ Additional features:
❌ Other non-EVM chains:
Technical Details
Files Changed:
app/core/Multichain/tron.ts: AddedgetMaxSendableTronAmount, madetoAddressoptional invalidateTronTransferAmountapp/components/UI/Ramp/Aggregator/hooks/useTronAmountValidation.ts: New debounced validation hookapp/components/UI/Ramp/Aggregator/Views/BuildQuote/BuildQuote.tsx: Integrated validation, wired Max buttonapp/components/UI/Ramp/Aggregator/Views/BuildQuote/BuildQuote.testIds.ts: AddedTRON_VALIDATION_ERRORtest IDlocales/languages/en.json: Addedtron_validation.validation_unavailablestringapp/core/Multichain/test/tron.test.ts,app/components/UI/Ramp/Aggregator/hooks/useTronAmountValidation.test.tsxSnap API Contract:
onAmountInput({ accountId, assetId, value, toAddress? }): WhentoAddressis omitted, returns conservative fee estimate (probes to Tron zero address, includes activation reserve for native TRX)getMaxSendableAmount({ accountId, assetId, toAddress? }): Returns{ maxAmount, balance, fees, valid, errors }Gated:
rampsOffRampNonEvmfeature flagChangelog
CHANGELOG entry:
feat: Added Tron amount validation with inline errors and Max button integration on the Sell (off-ramp) amount screen
Related issues
N/A (continuation of PR #38249)
Manual testing steps
Screenshots/Recordings
N/A (draft PR, not ready for visual review)
Pre-merge author checklist
Performance checks (if applicable)
Pre-merge reviewer checklist
Note: This is a DRAFT PR. Do not mark ready for review until internal-snaps #554 and #549 are merged and released.