psibase icon indicating copy to clipboard operation
psibase copied to clipboard

Tokens service: GraphQL - Combined userCredits and userDebits queries

Open brandonfancher opened this issue 6 months ago • 1 comments

This is a nice to have; we're not planning immediate pagination support for Pending Transactions in the UI at the moment. But if/when we do want to paginate, we won't be able to do so with the current UI, which combines the userCredits and userDebits queries into one table.

brandonfancher avatar Oct 23 '25 21:10 brandonfancher

Proposal

Table 1: Shared Balance Table

Almost identical to today's shared-balance table

Column Type Description
shared_bal_id u64 <-- NEW!
creditor accountnumber
debitor accountnumber
token_id TID (u32)
balance quantity

Indexes:

  • Primary key = shared_bal_id

Table 2: User Pending Summary

Add two records for every shared balance record

  1. One for the creditor
  2. One for the debitor
Column Type
user string
token_id TID (u32)
shared_bal_id u64

Indexes:

  • Primary key = { User, token_id, shared_bal_id }

Notes:

  • I think that other indexes for Shared Balance Table can be removed
  • Enables efficient searches on:
    • All pending transactions that involve a user (across all tokens, either creditor or debitor)
    • All pending transactions that involve a user for a particular token (either creditor or debitor)

James-Mart avatar Nov 11 '25 22:11 James-Mart