{"version":3,"sources":["../../src/api/faucet.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fundAccount } from \"../internal/faucet\";\nimport { UserTransactionResponse, WaitForTransactionOptions } from \"../types\";\nimport { AccountAddressInput } from \"../core\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexer } from \"../internal/transaction\";\nimport { ProcessorType } from \"../utils\";\n\n/**\n * A class to query all `Faucet` related queries on Aptos.\n */\nexport class Faucet {\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n *\n * @param config - The configuration settings for the Aptos client.\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({ network: Network.TESTNET }); // specify your own network if needed\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(readonly config: AptosConfig) {}\n\n /**\n * This function creates an account if it does not exist and mints the specified amount of coins into that account.\n *\n * @param args - The arguments for funding the account.\n * @param args.accountAddress - The address of the account to fund.\n * @param args.amount - The amount of tokens to fund the account with.\n * @param args.options - Configuration options for waiting for the transaction.\n * @returns Transaction hash of the transaction that funded the account.\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 * // Fund an account with a specified amount of tokens\n * const transaction = await aptos.fundAccount({\n * accountAddress: \"0x1\", // replace with your account address\n * amount: 100,\n * });\n *\n * console.log(\"Transaction hash:\", transaction.hash);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async fundAccount(args: {\n accountAddress: AccountAddressInput;\n amount: number;\n options?: WaitForTransactionOptions;\n }): Promise<UserTransactionResponse> {\n const fundTxn = await fundAccount({ aptosConfig: this.config, ...args });\n\n // If the user explicitly says to NOT wait by setting waitForIndexer to false, then we skip this.\n // But, by default we want to wait for the indexer.\n if (args.options?.waitForIndexer === undefined || args.options?.waitForIndexer) {\n await waitForIndexer({\n aptosConfig: this.config,\n minimumLedgerVersion: BigInt(fundTxn.version),\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n }\n\n return fundTxn;\n }\n}\n"],"mappings":"kFAaO,IAAMA,EAAN,KAAa,CAsBlB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CA8B3C,MAAM,YAAYC,EAImB,CACnC,IAAMC,EAAU,MAAMC,EAAY,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,EAIvE,OAAIA,EAAK,SAAS,iBAAmB,QAAaA,EAAK,SAAS,iBAC9D,MAAMG,EAAe,CACnB,YAAa,KAAK,OAClB,qBAAsB,OAAOF,EAAQ,OAAO,EAC5C,wCACF,CAAC,EAGIA,CACT,CACF","names":["Faucet","config","args","fundTxn","fundAccount","waitForIndexer"]}