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

Introduce table function API. Add getTableItemsData and getTableItemsMetadata queries #385

Merged
merged 1 commit into from
May 21, 2024

Conversation

0xmaayan
Copy link
Collaborator

@0xmaayan 0xmaayan commented May 1, 2024

Description

This PR

  1. Adds decimal prop back to current_token_ownerships_v2.current_token_data response
  2. Solves [Feature Request] Decode WriteSetChangeWriteTableItem.data to not null #376 , by adding 2 new table related queries - getTableItemsData and getTableItemsMetadata.

Currently, PFN doesnt return the table item data or metadata (i.e data field is always null, see https://fullnode.mainnet.aptoslabs.com/v1/transactions/by_version/563060087 ) and Indexer doesnt have a join query that can return all the data in one response.

This PR adds the 2 different Indexer queries where one can fetch the decoded table item data.

For example, consider https://explorer.aptoslabs.com/txn/563060087/changes?network=mainnet (index 5) Indexer is able to get us the decoded values.

With this change, the SDK uses indexer to fetch the decoded values

const data = await aptos.getTableItemsData({
      options: { where: { table_handle: { _eq:"0x7a36d3935ebd2045f49fab033acad5212782ff81c4b79bd55cc1af3ce7c8418b" }, transaction_version: { _eq: "563060087" } } },
}); 

const metadata = await aptos.getTableItemsMetadata({
      options: { where: { handle: { _eq:"0x7a36d3935ebd2045f49fab033acad5212782ff81c4b79bd55cc1af3ce7c8418b" } } },
});

Can compare with aptoscan.com

Test Plan

Related Links

@0xbe1
Copy link

0xbe1 commented May 2, 2024

hey @0xmaayan i have a few questions:

  1. what does PFN mean?
  2. it looks right that indexer request returns decoded value, but wondering why is that the case? what data does indexer have while normal fullnode doesn't in order to decode the table item data?
  3. is there any delay between "table item becomes available in normal fullnode" and "table item decoded data available in indexer"?
  4. is there any chance /v1/tables/{table_handle}/item returns decoded data?

appreciate your help here!!

@0xmaayan
Copy link
Collaborator Author

0xmaayan commented May 2, 2024

hey @0xmaayan i have a few questions:

  1. what does PFN mean?
  2. it looks right that indexer request returns decoded value, but wondering why is that the case? what data does indexer have while normal fullnode doesn't in order to decode the table item data?
  3. is there any delay between "table item becomes available in normal fullnode" and "table item decoded data available in indexer"?
  4. is there any chance /v1/tables/{table_handle}/item returns decoded data?

appreciate your help here!!

  1. Public FullNode
  2. By doing its indexing magic, Indexer is able to know and store chain data that the fullnode is not able
  3. There is probably a super minimal delay, but the SDK can help with handling it
  4. /v1/tables/{table_handle}/item returns the table item by providing the types, i.e you should know the types in advanced. When querying for a transaction details (for example with getTransactionByVersion) - it queries fullnode and the response does not contain the types or decoded values of the item (see here https://fullnode.mainnet.aptoslabs.com/v1/transactions/by_version/563060087 )

@0xmaayan 0xmaayan merged commit 3cebcc7 into main May 21, 2024
8 checks passed
@0xmaayan 0xmaayan deleted the table_api branch May 21, 2024 13:07
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.

3 participants