PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm
Просмотр файла: chunk-NK67FECB.mjs.map
{"version":3,"sources":["../../src/api/general.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"./aptosConfig\";\nimport {\n getChainTopUserTransactions,\n getIndexerLastSuccessVersion,\n getLedgerInfo,\n getProcessorStatus,\n queryIndexer,\n} from \"../internal/general\";\nimport { getBlockByHeight, getBlockByVersion } from \"../internal/transaction\";\nimport { view, viewJson } from \"../internal/view\";\nimport {\n AnyNumber,\n Block,\n GetChainTopUserTransactionsResponse,\n GetProcessorStatusResponse,\n GraphqlQuery,\n LedgerInfo,\n LedgerVersionArg,\n MoveValue,\n} from \"../types\";\nimport { ProcessorType } from \"../utils/const\";\nimport { InputViewFunctionData, InputViewFunctionJsonData } from \"../transactions\";\n\n/**\n * A class to query various Aptos-related information and perform operations on the Aptos blockchain.\n */\nexport class General {\n readonly config: AptosConfig;\n\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n * This allows users to interact with the Aptos blockchain using the provided settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for the Aptos client\n * const config = new AptosConfig({\n * network: Network.TESTNET, // specify the network\n * nodeUrl: \"https://testnet.aptos.dev\" // specify the node URL\n * });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Queries for the Aptos ledger information.\n *\n * @returns The Aptos Ledger Info, which includes details such as chain ID, epoch, and ledger version.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching the ledger information\n * const ledgerInfo = await aptos.getLedgerInfo();\n *\n * console.log(ledgerInfo);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getLedgerInfo(): Promise<LedgerInfo> {\n return getLedgerInfo({ aptosConfig: this.config });\n }\n\n /**\n * Retrieves the chain ID of the Aptos blockchain.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching the chain ID\n * const chainId = await aptos.getChainId();\n * console.log(\"Chain ID:\", chainId);\n * }\n * runExample().catch(console.error);\n *\n * @returns The chain ID of the Aptos blockchain.\n * ```\n */\n async getChainId(): Promise<number> {\n const result = await this.getLedgerInfo();\n return result.chain_id;\n }\n\n /**\n * Retrieves block information by the specified ledger version.\n *\n * @param args - The arguments for retrieving the block.\n * @param args.ledgerVersion - The ledger version to lookup block information for.\n * @param args.options - Optional parameters for the request.\n * @param args.options.withTransactions - If set to true, include all transactions in the block.\n *\n * @returns Block information with optional transactions.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Retrieve block information for a specific ledger version\n * const block = await aptos.getBlockByVersion({ ledgerVersion: 5 });\n * console.log(block);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getBlockByVersion(args: {\n ledgerVersion: AnyNumber;\n options?: { withTransactions?: boolean };\n }): Promise<Block> {\n return getBlockByVersion({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieve a block by its height, allowing for the inclusion of transactions if specified.\n *\n * @param args - The parameters for the block retrieval.\n * @param args.blockHeight - The block height to look up, starting at 0.\n * @param args.options - Optional settings for the retrieval.\n * @param args.options.withTransactions - If set to true, includes all transactions in the block.\n *\n * @returns The block with optional transactions included.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Retrieve the block at height 5, including transactions\n * const block = await aptos.getBlockByHeight({ blockHeight: 5, options: { withTransactions: true } });\n * console.log(block);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getBlockByHeight(args: { blockHeight: AnyNumber; options?: { withTransactions?: boolean } }): Promise<Block> {\n return getBlockByHeight({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a Move view function\n * @param args.payload Payload for the view function\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @example\n * const data = await aptos.view({\n * payload: {\n * function: \"0x1::coin::balance\",\n * typeArguments: [\"0x1::aptos_coin::AptosCoin\"],\n * functionArguments: [accountAddress],\n * }\n * })\n *\n * @returns an array of Move values\n */\n async view<T extends Array<MoveValue>>(args: {\n payload: InputViewFunctionData;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return view<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a Move view function with JSON, this provides compatability with the old `aptos` package\n * @param args.payload Payload for the view function\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @example\n * const data = await aptos.view({\n * payload: {\n * function: \"0x1::coin::balance\",\n * typeArguments: [\"0x1::aptos_coin::AptosCoin\"],\n * functionArguments: [accountAddress.toString()],\n * }\n * })\n *\n * @returns an array of Move values\n */\n async viewJson<T extends Array<MoveValue>>(args: {\n payload: InputViewFunctionJsonData;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return viewJson<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries the top user transactions based on the specified limit.\n *\n * @param args - The arguments for querying top user transactions.\n * @param args.limit - The number of transactions to return.\n * @returns GetChainTopUserTransactionsResponse\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetch the top user transactions with a limit of 5\n * const topUserTransactions = await aptos.getChainTopUserTransactions({ limit: 5 });\n *\n * console.log(topUserTransactions);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getChainTopUserTransactions(args: { limit: number }): Promise<GetChainTopUserTransactionsResponse> {\n return getChainTopUserTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieves data from the Aptos Indexer using a GraphQL query.\n * This function allows you to execute complex queries to fetch specific data from the Aptos blockchain.\n *\n * @param args.query.query - A GraphQL query string.\n * @param args.query.variables - The variables for the query (optional).\n *\n * @return The provided T type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Querying the Aptos Indexer for ledger information\n * const topUserTransactions = await aptos.queryIndexer({\n * query: `query MyQuery {\n * ledger_infos {\n * chain_id\n * }\n * }`\n * });\n *\n * console.log(topUserTransactions);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async queryIndexer<T extends {}>(args: { query: GraphqlQuery }): Promise<T> {\n return queryIndexer<T>({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries for the last successful indexer version, providing insight into the ledger version the indexer is updated to, which\n * may lag behind the full nodes.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the last successful indexer version\n * const version = await aptos.getIndexerLastSuccessVersion();\n * console.log(`Last successful indexer version: ${version}`);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getIndexerLastSuccessVersion(): Promise<bigint> {\n return getIndexerLastSuccessVersion({ aptosConfig: this.config });\n }\n\n /**\n * Query the processor status for a specific processor type.\n *\n * @param processorType The processor type to query.\n * @returns The status of the specified processor type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the processor status for the account transactions processor\n * const status = await aptos.getProcessorStatus(\"account_transactions_processor\");\n * console.log(status);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getProcessorStatus(processorType: ProcessorType): Promise<GetProcessorStatusResponse[0]> {\n return getProcessorStatus({ aptosConfig: this.config, processorType });\n }\n}\n"],"mappings":"qKA6BO,IAAMA,EAAN,KAAc,CA8BnB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAuBA,MAAM,eAAqC,CACzC,OAAOC,EAAc,CAAE,YAAa,KAAK,MAAO,CAAC,CACnD,CAsBA,MAAM,YAA8B,CAElC,OADe,MAAM,KAAK,cAAc,GAC1B,QAChB,CA2BA,MAAM,kBAAkBC,EAGL,CACjB,OAAOC,EAAkB,CACvB,YAAa,KAAK,OAClB,GAAGD,CACL,CAAC,CACH,CA2BA,MAAM,iBAAiBA,EAA4F,CACjH,OAAOE,EAAiB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CAC/D,CAkBA,MAAM,KAAiCA,EAGxB,CACb,OAAOG,EAAQ,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CACtD,CAkBA,MAAM,SAAqCA,EAG5B,CACb,OAAOI,EAAY,CAAE,YAAa,KAAK,OAAQ,GAAGJ,CAAK,CAAC,CAC1D,CAyBA,MAAM,4BAA4BA,EAAuE,CACvG,OAAOK,EAA4B,CACjC,YAAa,KAAK,OAClB,GAAGL,CACL,CAAC,CACH,CAiCA,MAAM,aAA2BA,EAA2C,CAC1E,OAAOM,EAAgB,CACrB,YAAa,KAAK,OAClB,GAAGN,CACL,CAAC,CACH,CAqBA,MAAM,8BAAgD,CACpD,OAAOO,EAA6B,CAAE,YAAa,KAAK,MAAO,CAAC,CAClE,CAuBA,MAAM,mBAAmBC,EAAsE,CAC7F,OAAOC,EAAmB,CAAE,YAAa,KAAK,OAAQ,cAAAD,CAAc,CAAC,CACvE,CACF","names":["General","config","getLedgerInfo","args","getBlockByVersion","getBlockByHeight","view","viewJson","getChainTopUserTransactions","queryIndexer","getIndexerLastSuccessVersion","processorType","getProcessorStatus"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!