Skip to content

Commit

Permalink
add support for fungible asset queries (#9747)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan authored Aug 24, 2023
1 parent db59233 commit b60a1ee
Show file tree
Hide file tree
Showing 8 changed files with 1,358 additions and 646 deletions.
2 changes: 2 additions & 0 deletions ecosystem/typescript/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the Aptos Node SDK will be captured in this file. This ch

## Unreleased

- Add fungible asset queries support - `getAccountCoinsData`, `getAccountCoinsDataCount`

## 1.18.0 (2023-08-10)

- Fix default behavior for coin client to transfer and create account by default
Expand Down
12 changes: 10 additions & 2 deletions ecosystem/typescript/sdk/src/indexer/generated/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import * as Types from './types';

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

export type GetAccountCoinsDataCountQueryVariables = Types.Exact<{
address?: Types.InputMaybe<Types.Scalars['String']>;
}>;


export type GetAccountCoinsDataCountQuery = { __typename?: 'query_root', current_fungible_asset_balances_aggregate: { __typename?: 'current_fungible_asset_balances_aggregate', aggregate?: { __typename?: 'current_fungible_asset_balances_aggregate_fields', count: number } | null } };

export type GetAccountCoinsDataQueryVariables = Types.Exact<{
owner_address?: Types.InputMaybe<Types.Scalars['String']>;
where_condition: Types.Current_Fungible_Asset_Balances_Bool_Exp;
offset?: Types.InputMaybe<Types.Scalars['Int']>;
limit?: Types.InputMaybe<Types.Scalars['Int']>;
order_by?: Types.InputMaybe<Array<Types.Current_Fungible_Asset_Balances_Order_By> | Types.Current_Fungible_Asset_Balances_Order_By>;
}>;


export type GetAccountCoinsDataQuery = { __typename?: 'query_root', current_coin_balances: Array<{ __typename?: 'current_coin_balances', amount: any, coin_type: string, coin_type_hash: string, last_transaction_timestamp: any, last_transaction_version: any, owner_address: string, coin_info?: { __typename?: 'coin_infos', coin_type: string, coin_type_hash: string, creator_address: string, decimals: number, name: string, supply_aggregator_table_handle?: string | null, supply_aggregator_table_key?: string | null, symbol: string, transaction_created_timestamp: any, transaction_version_created: any } | null }> };
export type GetAccountCoinsDataQuery = { __typename?: 'query_root', current_fungible_asset_balances: Array<{ __typename?: 'current_fungible_asset_balances', amount: any, asset_type: string, is_frozen: boolean, is_primary: boolean, last_transaction_timestamp: any, last_transaction_version: any, owner_address: string, storage_id: string, token_standard: string, metadata?: { __typename?: 'fungible_asset_metadata', token_standard: string, symbol: string, supply_aggregator_table_key_v1?: string | null, supply_aggregator_table_handle_v1?: string | null, project_uri?: string | null, name: string, last_transaction_version: any, last_transaction_timestamp: any, icon_uri?: string | null, decimals: number, creator_address: string, asset_type: string } | null }> };

export type GetAccountCurrentTokensQueryVariables = Types.Exact<{
address: Types.Scalars['String'];
Expand Down
52 changes: 36 additions & 16 deletions ecosystem/typescript/sdk/src/indexer/generated/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,47 @@ export const TokenActivitiesFieldsFragmentDoc = `
type
}
`;
export const GetAccountCoinsDataCount = `
query getAccountCoinsDataCount($address: String) {
current_fungible_asset_balances_aggregate(
where: {owner_address: {_eq: $address}}
) {
aggregate {
count
}
}
}
`;
export const GetAccountCoinsData = `
query getAccountCoinsData($owner_address: String, $offset: Int, $limit: Int) {
current_coin_balances(
where: {owner_address: {_eq: $owner_address}}
query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
current_fungible_asset_balances(
where: $where_condition
offset: $offset
limit: $limit
order_by: $order_by
) {
amount
coin_type
coin_type_hash
asset_type
is_frozen
is_primary
last_transaction_timestamp
last_transaction_version
owner_address
coin_info {
coin_type
coin_type_hash
creator_address
decimals
name
supply_aggregator_table_handle
supply_aggregator_table_key
storage_id
token_standard
metadata {
token_standard
symbol
transaction_created_timestamp
transaction_version_created
supply_aggregator_table_key_v1
supply_aggregator_table_handle_v1
project_uri
name
last_transaction_version
last_transaction_timestamp
icon_uri
decimals
creator_address
asset_type
}
}
}
Expand Down Expand Up @@ -417,7 +434,10 @@ const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationTy

export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
getAccountCoinsData(variables?: Types.GetAccountCoinsDataQueryVariables, requestHeaders?: Dom.RequestInit["headers"]): Promise<Types.GetAccountCoinsDataQuery> {
getAccountCoinsDataCount(variables?: Types.GetAccountCoinsDataCountQueryVariables, requestHeaders?: Dom.RequestInit["headers"]): Promise<Types.GetAccountCoinsDataCountQuery> {
return withWrapper((wrappedRequestHeaders) => client.request<Types.GetAccountCoinsDataCountQuery>(GetAccountCoinsDataCount, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getAccountCoinsDataCount', 'query');
},
getAccountCoinsData(variables: Types.GetAccountCoinsDataQueryVariables, requestHeaders?: Dom.RequestInit["headers"]): Promise<Types.GetAccountCoinsDataQuery> {
return withWrapper((wrappedRequestHeaders) => client.request<Types.GetAccountCoinsDataQuery>(GetAccountCoinsData, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'getAccountCoinsData', 'query');
},
getAccountCurrentTokens(variables: Types.GetAccountCurrentTokensQueryVariables, requestHeaders?: Dom.RequestInit["headers"]): Promise<Types.GetAccountCurrentTokensQuery> {
Expand Down
Loading

0 comments on commit b60a1ee

Please sign in to comment.