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

rework the endpoints used in paima to use pagination based on txs #175

Conversation

ecioppettini
Copy link
Contributor

About

This is based on the work on #173. Mostly because the slotLimits code is re-used here in order to be able to test it with paima. Potentially the upper limit in the slot range could be removed, but it was simpler to keep it for now. This allows to replicate the current behavior by just consuming the entire range, but allows chunking and skipping empty slots.

Pagination is added to the following endpoints:

/asset/utxos
/projected-nft/range
/delegation/pool

The pagination code is the same as the transaction history endpoint, which is based in transactions. The main breaking change is that the output format is changed in order to group events by transaction. So if previously the endpoints were returning

[
  {
    txId: "tx1",
    block: "block1",
    ...dataFields1
  },
  {
    txId: "tx1",
    block: "block1",
    ...dataFields2
  }
]

Now the shape is instead:

[
  {
    txId: "tx1",
    block: "block1"
    payload: [ dataFields1, dataFields2 ]
  }
]

The reasoning for this is that otherwise you can skip the second event after seeing the first one and using that tx as the after parameter.

The only really annoying part about this is that using json_agg doesn't really play well with pgtyped, but it's the simpler way of implementing this, since grouping in js it's most likely not the best idea.

Note: I tested the projected nft endpoint only with fake data, since I didn't really have indexed that for it in my carp instance.

@ecioppettini ecioppettini self-assigned this Mar 2, 2024
@ecioppettini ecioppettini force-pushed the enzo/transaction-history-transfer-cde branch from 20ea85d to cde3ec4 Compare March 4, 2024 19:41
@ecioppettini ecioppettini force-pushed the enzo/make-pagination-system-uniform branch 2 times, most recently from cae8335 to 1ed7926 Compare March 5, 2024 03:43
@ecioppettini ecioppettini force-pushed the enzo/make-pagination-system-uniform branch from 1ed7926 to c9180ba Compare March 5, 2024 16:51
Base automatically changed from enzo/transaction-history-transfer-cde to main March 12, 2024 17:28
@SebastienGllmt
Copy link
Contributor

This needs to be rebased now

@SebastienGllmt SebastienGllmt changed the base branch from main to enzo/transaction-history-transfer-cde March 16, 2024 23:13
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