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

[TS SDK] Add TokenV2 Indexer queries #8210

Merged
merged 11 commits into from
May 18, 2023
Merged

[TS SDK] Add TokenV2 Indexer queries #8210

merged 11 commits into from
May 18, 2023

Conversation

0xmaayan
Copy link
Contributor

@0xmaayan 0xmaayan commented May 15, 2023

Description

This PR adds Indexer queries

  • getAccountTokens - get all tokens that an account owns
  • getAccountCollectionTokensByCollectionAddress - get all tokens of a specific collection that an account owns
  • getCollectionData - get the collection data (if, for some reason, a creator account has 2 collections with the same name in v1 and v2, can use an optional tokenStandard parameter to query a specific standard)
  • getCollectionAddress - get the collection address (if, for some reason, a creator account has 2 collections with the same name in v1 and v2, can use an optional tokenStandard parameter to query a specific standard)

with this,

  • Users can query for all tokens (v2) that an account owns
  • Users can query for all tokens of a specific collection that an account owns

In a next PR we will add support for (not yet supported on the indexer side)

  • Users can query for all collections that an account has tokens for
  • Users can get all the attributes (in all resources) a token has

Test Plan

tests are passing

ecosystem/typescript/sdk/src/providers/indexer.ts Outdated Show resolved Hide resolved
ecosystem/typescript/sdk/src/providers/indexer.ts Outdated Show resolved Hide resolved
* Queries all tokens of a specific collection that an account owns
*
* @param ownerAddress owner address
* @param collectionAddress the collection address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clarify what collection address means. May be with a link to the token v2 doc page as well (or a TODO if that's not complete yet) cc @gregnazario

ecosystem/typescript/sdk/src/providers/indexer.ts Outdated Show resolved Hide resolved
ecosystem/typescript/sdk/src/providers/indexer.ts Outdated Show resolved Hide resolved
* can pass an optional `tokenStandard` parameter to query a specific standard
*
* @param creatorAddress the collection creator address
* @param collectionName the collection name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be provide an example?

ecosystem/typescript/sdk/src/providers/indexer.ts Outdated Show resolved Hide resolved
creatorAddress: MaybeHexString,
collectionName: string,
extraArgs?: {
tokenStandard?: TokenStandard;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, does this mean that there could be 2 different standard from the same collection? For example, AptosMonkey v1, and AptosMonkey v2 collection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not the same collection, these are 2 different collection that were created with the same account and have the same name.
for example

Copy link
Contributor

@bowenyang007 bowenyang007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Queries make sense. The APIs look a bit long but I'm sure that we can iterate if we get feedback on ergonomics.

Copy link
Contributor

@0xmigo 0xmigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know much about TokenV2, but these query wrapper functions make sense to me

@0xmaayan 0xmaayan enabled auto-merge (squash) May 17, 2023 23:48
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

✅ Forge suite land_blocking success on 7a27ab4be8c62adfa350004713df9968b7b89202

performance benchmark : 6002 TPS, 6587 ms latency, 23800 ms p99 latency,no expired txns
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 7a27ab4be8c62adfa350004713df9968b7b89202

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 7a27ab4be8c62adfa350004713df9968b7b89202 (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 10412 TPS, 3632 ms latency, 5800 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 7a27ab4be8c62adfa350004713df9968b7b89202
compatibility::simple-validator-upgrade::single-validator-upgrade : 5756 TPS, 6840 ms latency, 9500 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 7a27ab4be8c62adfa350004713df9968b7b89202
compatibility::simple-validator-upgrade::half-validator-upgrade : 5487 TPS, 7383 ms latency, 10300 ms p99 latency,no expired txns
4. upgrading second batch to new version: 7a27ab4be8c62adfa350004713df9968b7b89202
compatibility::simple-validator-upgrade::rest-validator-upgrade : 8212 TPS, 4630 ms latency, 8400 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 7a27ab4be8c62adfa350004713df9968b7b89202 passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite framework_upgrade success on aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 7a27ab4be8c62adfa350004713df9968b7b89202

Compatibility test results for aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 7a27ab4be8c62adfa350004713df9968b7b89202 (PR)
Upgrade the nodes to version: 7a27ab4be8c62adfa350004713df9968b7b89202
framework_upgrade::framework-upgrade::full-framework-upgrade : 6126 TPS, 6426 ms latency, 10100 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 7a27ab4be8c62adfa350004713df9968b7b89202 passed
Test Ok

@0xmaayan 0xmaayan merged commit 6154840 into main May 18, 2023
@0xmaayan 0xmaayan deleted the tokenv2_queries branch May 18, 2023 00:33
gedigi pushed a commit that referenced this pull request Jun 6, 2023
* add get account token query

* add get account collection tokens

* update changelog

* add function comment

* add function comment

* fix lint

* address feedback

* update changelog

* fix lint

* typo

* token ownership fields fragment
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.

4 participants