Skip to content

Balance of tokens in /account/balance #77

@piotr-iohk

Description

@piotr-iohk

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
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions