aptos-ts-sdk icon indicating copy to clipboard operation
aptos-ts-sdk copied to clipboard

Add new indexer API to getAccountAllTransactionVersions and use it in getAccountTransactions

Open 0x-j opened this issue 1 year ago • 4 comments

Description

  • Add getAllAccountTransactionVersions which returns versions of all transaction versions related to the given address.
  • Add getAllAccountTransactions which returns all transactions related to given address instead of only ones sent by address. This makes the result has same length as calling getAccountTransactionsCount.

This is a solution to https://github.com/aptos-labs/aptos-ts-sdk/issues/352. There doesn't exist an indexer API that returns the aggregated result. So I have to first call an indexer API to get all user txs' versions, then call full node API to get tx detail on each of them.

Test Plan

Updated unit test that lets user 1 transfer APT to user 2 then user 2 transfer APT back to user 1. Calling getAccountTransactions on both users should all return 2 txs.

Related Links

0x-j avatar Apr 15 '24 01:04 0x-j

discussion happening in this thread

0x-j avatar Apr 15 '24 20:04 0x-j

Synced with Bowen offline, tldr: i think we have to keep this slow approach, because user_transactions table would be gone within a month cuz it's too expensive. Indexer team might come up with a better solution in the future but for now this is the recommended way by them.

0x-j avatar Apr 15 '24 23:04 0x-j

Not sure why decimals field is removed in some queries, as I don't see it being removed on hasura. I added them back manually. We should probably investigate it later.

0x-j avatar Apr 16 '24 00:04 0x-j

Not sure why decimals field is removed in some queries, as I don't see it being removed on hasura. I added them back manually. We should probably investigate it later.

might be related https://github.com/aptos-labs/aptos-ts-sdk/pull/314 Ideally, we should not add anything manually but generate whatever is on Hasura so we wont introduce any weird/wrong behavior

0xmaayan avatar Apr 16 '24 09:04 0xmaayan