Skip to content

Commit

Permalink
token ownership fields fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan committed May 17, 2023
1 parent 118e39a commit 7a27ab4
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 143 deletions.
2 changes: 2 additions & 0 deletions ecosystem/typescript/sdk/src/indexer/generated/operations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as Types from './types';

export type CurrentTokenOwnershipFieldsFragment = { __typename?: 'current_token_ownerships_v2', token_standard: string, is_fungible_v2?: boolean | null, is_soulbound_v2?: boolean | null, property_version_v1: any, table_type_v1?: string | null, token_properties_mutated_v1?: any | null, amount: any, last_transaction_timestamp: any, last_transaction_version: any, storage_id: string, owner_address: string, current_token_data?: { __typename?: 'current_token_datas_v2', token_name: string, token_data_id: string, token_uri: string, token_properties: any, supply: any, maximum?: any | null, last_transaction_version: any, last_transaction_timestamp: any, largest_property_version_v1?: any | null, current_collection?: { __typename?: 'current_collections_v2', collection_name: string, creator_address: string, description: string, uri: string, collection_id: string, last_transaction_version: any, current_supply: any, mutable_description?: boolean | null, total_minted_v2?: any | null, table_handle_v1?: string | null, mutable_uri?: boolean | null } | null } | null };

export type GetAccountCoinsDataQueryVariables = Types.Exact<{
owner_address?: Types.InputMaybe<Types.Scalars['String']>;
offset?: Types.InputMaybe<Types.Scalars['Int']>;
Expand Down
115 changes: 43 additions & 72 deletions ecosystem/typescript/sdk/src/indexer/generated/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@ import * as Types from './operations';

import { GraphQLClient } from 'graphql-request';
import * as Dom from 'graphql-request/dist/types.dom';
export const CurrentTokenOwnershipFieldsFragmentDoc = `
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
}
`;
export const TokenDataFieldsFragmentDoc = `
fragment TokenDataFields on current_token_datas {
creator_address
Expand Down Expand Up @@ -149,44 +188,10 @@ export const GetOwnedTokens = `
offset: $offset
limit: $limit
) {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
...CurrentTokenOwnershipFields
}
}
`;
${CurrentTokenOwnershipFieldsFragmentDoc}`;
export const GetTokenActivities = `
query getTokenActivities($idHash: String!, $offset: Int, $limit: Int) {
token_activities(
Expand Down Expand Up @@ -245,44 +250,10 @@ export const GetTokenOwnedFromCollection = `
offset: $offset
limit: $limit
) {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
...CurrentTokenOwnershipFields
}
}
`;
${CurrentTokenOwnershipFieldsFragmentDoc}`;
export const GetTokenOwnersData = `
query getTokenOwnersData($token_id: String, $property_version: numeric) {
current_token_ownerships(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
#import "./CurrentTokenOwnershipFieldsFragment";
query getOwnedTokens($address: String!, $offset: Int, $limit: Int) {
current_token_ownerships_v2(
where: { owner_address: { _eq: $address }, amount: { _gt: 0 } }
offset: $offset
limit: $limit
) {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
...CurrentTokenOwnershipFields
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "./CurrentTokenOwnershipFieldsFragment";
query getTokenOwnedFromCollection($collection_id: String!, $owner_address: String!, $offset: Int, $limit: Int) {
current_token_ownerships_v2(
where: {
Expand All @@ -8,40 +9,6 @@ query getTokenOwnedFromCollection($collection_id: String!, $owner_address: Strin
offset: $offset
limit: $limit
) {
token_standard
is_fungible_v2
is_soulbound_v2
property_version_v1
table_type_v1
token_properties_mutated_v1
amount
last_transaction_timestamp
last_transaction_version
storage_id
owner_address
current_token_data {
token_name
token_data_id
token_uri
token_properties
supply
maximum
last_transaction_version
last_transaction_timestamp
largest_property_version_v1
current_collection {
collection_name
creator_address
description
uri
collection_id
last_transaction_version
current_supply
mutable_description
total_minted_v2
table_handle_v1
mutable_uri
}
}
...CurrentTokenOwnershipFields
}
}
1 change: 0 additions & 1 deletion ecosystem/typescript/sdk/src/tests/e2e/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ describe("Indexer", () => {
it(
"returns same result for getTokenOwnedFromCollectionNameAndCreatorAddress and getTokenOwnedFromCollectionAddress",
async () => {
console.log(alice.address().hex());
const collectionAddress = await indexerClient.getCollectionAddress(alice.address().hex(), collectionNameV2);
const tokensFromCollectionAddress = await indexerClient.getTokenOwnedFromCollectionAddress(
alice.address().hex(),
Expand Down

0 comments on commit 7a27ab4

Please sign in to comment.