Skip to content

Fix amount displayed for tokens with non-8 decimals#39

Open
pawell24 wants to merge 1 commit into
LedgerHQ:developfrom
pawell24:fix/live-30542-token-decimals
Open

Fix amount displayed for tokens with non-8 decimals#39
pawell24 wants to merge 1 commit into
LedgerHQ:developfrom
pawell24:fix/live-30542-token-decimals

Conversation

@pawell24

Copy link
Copy Markdown

Checklist

  • App update process has been followed
  • Target branch is develop
  • Application version has been bumped

Fixes #17302 (LIVE-30542).

Token amounts were formatted with a hardcoded 8 decimals while the ticker came from the token registry, so tokens that do not use 8 decimals (e.g. USDT, 6) showed the wrong amount (0.01 instead of 1.0). Added a decimals field to TOKEN_MAPPING and use it when formatting coin and fungible asset transfers; native APT, gas and staking keep 8 decimals, unlisted tokens keep the 8 decimals fallback.

Snapshots updated: test_sign_fa_tx (the fix) and test_app_mainmenu (the version screen, from the bump).

@pawell24 pawell24 force-pushed the fix/live-30542-token-decimals branch from c9b0fb4 to 82d5cee Compare June 15, 2026 09:39
@pawell24 pawell24 force-pushed the fix/live-30542-token-decimals branch 2 times, most recently from 681aa93 to 7242979 Compare June 22, 2026 16:37

@cted-ledger cted-ledger 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.

Thanks Paweł — the actual decimals fix is small and correct. The blocker is that it's buried under a repo-wide reformat done with the wrong style. A few targeted comments below; the main ask is to split this into focused PRs.

Comment thread src/apdu/dispatcher.c Outdated
buf.offset = 0;

return handler_get_public_key(&buf, (bool) cmd->p1);
return handler_get_public_key(&buf, (bool)cmd->p1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This whole-repo reformat doesn't match the committed .clang-format and will fail the format CI. The repo config sets PointerAlignment: Right, SpaceAfterCStyleCast: true, SortIncludes: false, ColumnLimit: 100, but the diff does the opposite everywhere: command_t* cmd (should be command_t *cmd), (bool)cmd->p1 (should be (bool) cmd->p1), reordered includes, and wrapping at ~80 cols. Please re-run clang-format with the repo's .clang-format — that should make almost all of these ~30 files drop out of the diff.

Comment thread fuzzing/CMakeLists.txt Outdated
VERSION 1.0
DESCRIPTION "Fuzzing of transaction parser"
LANGUAGES CXX)
LANGUAGES C CXX)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Out of scope for a decimals fix: the .cc->.c rename, LANGUAGES C CXX, and LINKER_LANGUAGE CXX change the fuzzing build (ClusterFuzzLite) and can break that CI job. Please move this to its own PR.

Comment thread src/ui/nbgl_display_message.c Outdated
#include <string.h> // memset

#include "os.h"
#include "../common/user_format.h"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unrelated incidental change: this file's mode flips 100755 -> 100644. Worth reverting so the PR only contains intended changes.

Comment thread src/ui/common_display.c
// Type id
typedef struct token_info {
const char ticker[MAX_TICKER_LENG];
uint8_t decimals;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Root cause is a hardcoded static registry, so the wrong-amount bug recurs whenever the token list changes, and only one FA snapshot (test_sign_fa_tx) guards it. Could you add a short comment documenting where these decimals values come from (on-chain metadata source)? Not blocking.

@pawell24 pawell24 force-pushed the fix/live-30542-token-decimals branch from 7242979 to a8766a2 Compare June 23, 2026 19:27
@pawell24 pawell24 force-pushed the fix/live-30542-token-decimals branch from a8766a2 to e243a77 Compare June 23, 2026 19:40
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