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

Balance of tokens in /account/balance #77

Open
piotr-iohk opened this issue Dec 3, 2024 · 1 comment
Open

Balance of tokens in /account/balance #77

piotr-iohk opened this issue Dec 3, 2024 · 1 comment

Comments

@piotr-iohk
Copy link
Collaborator

Atm the /balance/account only shows balance of Mina, and tokens are not included. That seems to be the case for both MinaMesh and Rosetta Ocaml. I think it would be fairly easy to add token balance support for historical lookup modifying the query maybe_account_balance_info.sql to:

SELECT DISTINCT ON (t.value)
  b.height,
  b.global_slot_since_genesis AS block_global_slot_since_genesis,
  balance,
  nonce,
  timing_id,
  t.value
FROM
  blocks b
  INNER JOIN accounts_accessed ac ON ac.block_id=b.id
  INNER JOIN account_identifiers ai ON ai.id=ac.account_identifier_id
  INNER JOIN public_keys pks ON ai.public_key_id=pks.id
  INNER JOIN tokens t ON ai.token_id=t.id
WHERE
  pks.value=$1
  AND b.height<=$2
  AND b.chain_status='canonical'
  -- AND t.value=$3
ORDER BY
  t.value, b.height DESC

which should give each token balance for the given account per row.

For the frontier balance lookup, the graphql would probably be something like this:

query QueryAllBalances($publicKey: PublicKey!) {
  accounts(publicKey: $publicKey) {
    tokenId
    nonce
    balance {
      total
      liquid
      locked
    }
  }
}
@joaosreis
Copy link
Member

This a good candidate for future work. AFAIK no user complained about missing this feature, but it's good to have it planned.

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

No branches or pull requests

2 participants