Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIP-873: Decimals are not returned with the token balance in the new token relationship API #7386

Closed
mehcode opened this issue Dec 14, 2023 · 3 comments · Fixed by #7699
Closed
Assignees
Labels
enhancement Type: New feature rest Area: REST API
Milestone

Comments

@mehcode
Copy link

mehcode commented Dec 14, 2023

Description

A token balance without the associated number of decimals to know how to interpret that balance is dangerous to present to an end user.

Steps to reproduce

  1. Query for token balances using the new /api/v1/accounts/{id}/tokens API.
  2. See that decimal information is not returned.

Additional context

No response

Hedera network

mainnet, testnet, previewnet

Version

v1

Operating system

None

@mehcode mehcode added the bug Type: Something isn't working label Dec 14, 2023
@xin-hedera
Copy link
Collaborator

Token decimal is immutable and can be retrieved from /api/v1/tokens/{id}.

We can't change how the value is presented in the existing property since that'll be a breaking change and cause issues for applications treating it properly.

@mehcode
Copy link
Author

mehcode commented Dec 14, 2023

If I, as an end-user, fetch my balance for 50 tokens. I now need to call the mirror node 51 total times to be able to correctly use that information (balance + decimals).

It's not a breaking change to add a new decimals field to the response from /api/v1/accounts/{id}/tokens.

@steven-sheehy steven-sheehy added enhancement Type: New feature and removed bug Type: Something isn't working labels Dec 14, 2023
@steven-sheehy
Copy link
Member

It would not be performant to join on token for /api/v1/accounts/{id}/tokens to add decimal since they have different distribution columns for our sharded database.

Instead, we could fix the bug that makes /api/v1/tokens?token.id=0.0.X&token.id=0.0.Y not work by ensuring it uses an IN clause. However, the list API doesn't show decimals currently so would require a HIP to add the field. But if that was in place your use case would only require 2 queries. Also note that decimals is immutable so even though it might require 50 lookups now you could cache it indefinitely within the app.

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