UNPKG

@aptos-labs/ts-sdk

Version:
85 lines (82 loc) 3.34 kB
import { TableItemRequest, LedgerVersionArg, AnyNumber, PaginationArgs, WhereArg, OrderByArg } from '../types/index.mjs'; import { TableItemsBoolExp, TableMetadatasBoolExp } from '../types/generated/types.mjs'; import { AptosConfig } from './aptosConfig.mjs'; import { GetTableItemsDataResponse, GetTableItemsMetadataResponse } from '../types/indexer.mjs'; import '../utils/apiEndpoints.mjs'; import '../types/generated/operations.mjs'; import '../utils/const.mjs'; /** * A class to query all `Table` Aptos related queries */ declare class Table { readonly config: AptosConfig; constructor(config: AptosConfig); /** * Queries for a table item for a table identified by the handle and the key for the item. * Key and value types need to be passed in to help with key serialization and value deserialization. * * Note, this query calls the fullnode server * * @example https://api.devnet.aptoslabs.com/v1/accounts/0x1/resource/0x1::coin::CoinInfo%3C0x1::aptos_coin::AptosCoin%3E * const tableItem = await aptos.getTableItem({ * handle: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca", * data: { * key_type: "address", // Move type of table key * value_type: "u128", // Move type of table value * key: "0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935" // Value of table key * }, * }) * * @param args.handle A pointer to where that table is stored * @param args.data Object that describes table item * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version * * @returns Table item value rendered in JSON */ getTableItem<T>(args: { handle: string; data: TableItemRequest; options?: LedgerVersionArg; }): Promise<T>; /** * Queries for a table items data. * * Optional `options.where` param can be passed to filter the response. * * Note, this query calls the indexer server * * @example * const data = await aptos.getTableItemsData({ * options: { where: { * table_handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" }, * transaction_version: { _eq: "0" } * } * }, * }); * * @returns GetTableItemsDataResponse */ getTableItemsData(args: { minimumLedgerVersion?: AnyNumber; options?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<GetTableItemsDataResponse[0]>; }): Promise<GetTableItemsDataResponse>; /** * Queries for a table items metadata. * * Optional `options.where` param can be passed to filter the response. * * Note, this query calls the indexer server * * @example * const data = await aptos.getTableItemsMetadata({ * options: { where: { handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" } } }, * }); * * @returns GetTableItemsMetadataResponse */ getTableItemsMetadata(args: { minimumLedgerVersion?: AnyNumber; options?: PaginationArgs & WhereArg<TableMetadatasBoolExp> & OrderByArg<GetTableItemsMetadataResponse[0]>; }): Promise<GetTableItemsMetadataResponse>; } export { Table };