-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add new indexer API to getAccountAllTransactionVersions and use it in getAccountTransactions #364
base: main
Are you sure you want to change the base?
Conversation
6864cc4
to
e27dd3b
Compare
src/types/generated/operations.ts
Outdated
@@ -55,7 +55,6 @@ export type CurrentTokenOwnershipFieldsFragment = { | |||
token_properties: any; | |||
token_standard: string; | |||
token_uri: string; | |||
decimals: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the result of running indexer-codegen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change - have we talked with Indexer team on why they removed it?
e27dd3b
to
11b9531
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this solution. This can increase the dapp server requests and can potentially lead to rate limit or just worst performance (like the Explorer that suffers from a bad performance - site load, etc)
I think we should push for an Indexer solution @bowenyang007
CHANGELOG.md
Outdated
@@ -21,6 +21,8 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T | |||
- [`Breaking`] Change any generate transaction function to return `SimpleTransaction` or `MultiAgentTransaction` instance | |||
- Adds `getUserTransactionHash` which can generate a transaction hash after signing, but before submission | |||
- Add function to create resource address locally | |||
- Add `getAccountAllTransactionVersions` which returns versions of all transactions related to the given address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 should be under a new dated release version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/types/generated/operations.ts
Outdated
@@ -55,7 +55,6 @@ export type CurrentTokenOwnershipFieldsFragment = { | |||
token_properties: any; | |||
token_standard: string; | |||
token_uri: string; | |||
decimals: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change - have we talked with Indexer team on why they removed it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see an indexer only solution for a single request that is paginated if we choose to go down this route.
Otherwise, this is way too costly.
src/internal/account.ts
Outdated
// TODO: Ideally indexer should provide one API that returns all transactions details in one go | ||
// But now we have to query all transaction versions first and then query each transaction by version | ||
const versions = await getAccountAllTransactionVersions({ aptosConfig, accountAddress, options }); | ||
const results = []; | ||
for (const version of versions) { | ||
const tx = getTransactionByVersion({ aptosConfig, ledgerVersion: version }); | ||
results.push(tx); | ||
} | ||
return Promise.all(results); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This significantly changes the behavior of this function from being a paginated API that is associated with an account, to having a non-paginated API across two different services.
If this is the case that this is important, it should do whatever query the explorer and wallets do, or have a dedicated query for it.
Additionally, this changes what is a 1 network call, to 1 + n network calls.
In a limited network environment, it would be slow or eat up all your bandwidth.
discussion happening in this thread |
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. |
Not sure why |
src/internal/account.ts
Outdated
return paginateWithCursor<{}, TransactionResponse[]>({ | ||
// TODO: Ideally indexer should provide one API that returns all transactions details in one go | ||
// But now we have to query all transaction versions first and then query each transaction by version | ||
const versions = await getAccountAllTransactionVersions({ aptosConfig, accountAddress, options }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep this query as is, and add another query like getAllAccountUserTransactions
that does this multiple queries? and mention it on the function comment
might be related #314 |
00e8b6f
to
618c144
Compare
|
||
// sleep for 500 ms to ensure the txns are in the ledger | ||
await new Promise((resolve) => { | ||
setTimeout(resolve, 500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the sleep tx2 wouldn't be included, pretty weird considering i already waitForTransaction on tx2
Description
getAllAccountTransactionVersions
which returns versions of all transaction versions related to the given address.getAllAccountTransactions
which returns all transactions related to given address instead of only ones sent by address. This makes the result has same length as callinggetAccountTransactionsCount
.This is a solution to #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