Skip to content

feat(amount): route remaining display sites through the amount layer - #893

Open
raul-oliveira wants to merge 2 commits into
raul-oliveira/feat/amount-formatfrom
raul-oliveira/feat/amount-format-sweep
Open

feat(amount): route remaining display sites through the amount layer#893
raul-oliveira wants to merge 2 commits into
raul-oliveira/feat/amount-formatfrom
raul-oliveira/feat/amount-format-sweep

Conversation

@raul-oliveira

Copy link
Copy Markdown
Contributor

Acceptance Criteria

  • Every remaining direct numberUtils.prettyValue call is routed through the shared amount layer from feat(amount): add wallet-wide amount format preference #892, so the Expanded/Compressed preference applies consistently across the whole wallet — Reown, atomic swap, nano contracts, the NFT list, token mint/melt, token import, and the send/create flows
  • numberUtils.prettyValue now survives only in InputNumber, which is always expanded by design
  • No behaviour change while the amount-format-desktop.rollout flag is off (its default)

Second of 6 PRs. Stacked on #892 — base branch is raul-oliveira/feat/amount-format, not master. Review #892 first.

What changed

18 files, all mechanical conversions onto the three PR1 APIs:

  • JSX sites render <Amount>
  • Function components needing a string use useAmountFormat()
  • Class components and plain modules use formatAmount, and mask the preference with resolveAmountFormat(...) in mapStateToProps so the feature flag can't be bypassed

Two sites needed more than a substitution:

  • Reown/CreateTokenRequestData.js defined its formatter at module scope; it moved inside the component to use the hook, and keeps a null / try-catch guard around the amount because the payload arrives from an external dApp over Reown — an unguarded prettyValue does BigInt(), which throws on a malformed value.
  • utils/tokens.js getDepositAmount gained an optional amountFormat parameter (last, so it stays backward-compatible), threaded from its two wrapper callers.

HTR fee and deposit amounts are never given a token's isNFT — a fee is always HTR.

Testing

Suite unchanged from #892: 33/33 pass, same 7 pre-existing suites failing on the Jest/axios ESM issue (see #892 for detail). No new user-facing strings, so make update_pot is a no-op.

Manual QA needed

With the flag temporarily forced on and Compressed selected, confirm small values compress everywhere and long values are consistent (Expanded elsewhere when the flag is off):

  • Reown: transaction fees, nano-contract actions, send-transaction and get-utxos modals, and a create-token request
  • Atomic swap: edit-swap table, proposal balance table, the send modal
  • Nano contract detail amounts
  • NFT list balances
  • Token mint / melt success messages and deposit label
  • Token import balance column
  • Send Tokens required-amount message; Create Token deposit label
  • A create-token Reown request with a missing or malformed amount does not crash the modal (the guard renders it as empty)

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

Converts every remaining direct numberUtils.prettyValue call onto the shared
amount layer from PR1, so the format preference applies consistently across
Reown, atomic swap, nano contracts, the NFT list, token mint/melt, token
import and the send/create flows.

- JSX sites render <Amount>; string sites use useAmountFormat / formatAmount
- class components mask the preference with resolveAmountFormat in
  mapStateToProps, so the feature flag cannot be bypassed
- getDepositAmount takes an optional amountFormat, threaded from its two
  wrapper callers; HTR fee and deposit amounts never receive a token's isNFT
- CreateTokenRequestData keeps a null/try-catch guard around the amount,
  since the payload comes from an external dApp over Reown

numberUtils.prettyValue now survives only in InputNumber, which is always
expanded by design.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 831b06e1-33a3-441e-8b04-49c886ad3068

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch raul-oliveira/feat/amount-format-sweep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

Status: In Progress (WIP)

Development

Successfully merging this pull request may close these issues.

1 participant