PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm
Просмотр файла: chunk-ZMS3AOEZ.mjs.map
{"version":3,"sources":["../../src/api/ans.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"../account\";\nimport { AccountAddress, AccountAddressInput } from \"../core\";\nimport {\n RegisterNameParameters,\n getExpiration,\n getOwnerAddress,\n registerName,\n getPrimaryName,\n setPrimaryName,\n getTargetAddress,\n setTargetAddress,\n renewDomain,\n getName,\n getAccountDomains,\n GetAccountDomainsArgs,\n GetAccountSubdomainsArgs,\n getAccountSubdomains,\n getAccountNames,\n GetAccountNamesArgs,\n getDomainSubdomains,\n GetDomainSubdomainsArgs,\n} from \"../internal/ans\";\nimport { GetANSNameResponse } from \"../types\";\nimport { InputGenerateTransactionOptions } from \"../transactions/types\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\n\n/**\n * A class to handle all `ANS` operations.\n */\nexport class ANS {\n /**\n * Initializes a new instance of the Aptos class with the provided configuration.\n * This allows you to interact with the Aptos blockchain using the specified network settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., mainnet, testnet).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n * @param config.faucetUrl - The URL of the faucet to use for funding accounts.\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 connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\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 * Retrieve the owner address of a specified domain name or subdomain name from the contract.\n *\n * @param args - The arguments for retrieving the owner address.\n * @param args.name - A string representing the name of the domain or subdomain to retrieve the owner address for.\n *\n * @returns AccountAddress if the name is owned, undefined otherwise.\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 owner address of \"test.aptos\"\n * const owner = await aptos.getOwnerAddress({ name: \"test.aptos\" });\n * console.log(owner); // Logs the owner address or undefined if not owned\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getOwnerAddress(args: { name: string }): Promise<AccountAddress | undefined> {\n return getOwnerAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the expiration time of a domain name or subdomain name from the contract.\n *\n * @param args - The arguments for retrieving the expiration.\n * @param args.name - A string of the name to retrieve.\n *\n * @returns number as a unix timestamp in milliseconds.\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 expiration time for the domain \"test.aptos\"\n * const exp = await aptos.getExpiration({ name: \"test.aptos\" });\n *\n * // Log the expiration date\n * console.log(new Date(exp)); // Outputs the expiration date\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getExpiration(args: { name: string }): Promise<number | undefined> {\n return getExpiration({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the target address of a domain or subdomain name, which indicates the address the name points to for use on-chain.\n * Note that the target address can point to addresses that do not own the name.\n *\n * @param args - The arguments for retrieving the target address.\n * @param args.name - A string representing the name, which can be a primary name, a subdomain, or a combination (e.g.,\n * \"primary\", \"primary.apt\", \"secondary.primary\", \"secondary.primary.apt\").\n *\n * @returns AccountAddress if the name has a target, undefined otherwise.\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 target address for the specified domain name\n * const targetAddr = await aptos.getTargetAddress({ name: \"test.aptos\" });\n *\n * console.log(targetAddr); // Logs the target address, e.g., 0x123...\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getTargetAddress(args: { name: string }): Promise<AccountAddress | undefined> {\n return getTargetAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sets the target address of a domain or subdomain name, pointing it to a specified address for use on-chain.\n * The target address can be different from the owner of the name.\n *\n * @param args - The arguments for setting the target address.\n * @param args.sender - The account initiating the transaction.\n * @param args.name - A string representing the domain or subdomain name (e.g., \"test.aptos\").\n * @param args.address - The AccountAddressInput of the address to set the domain or subdomain to.\n * @param args.options - Optional settings for generating the transaction.\n *\n * @returns SimpleTransaction\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 * // Setting the target address for a domain name\n * const sender = Account.generate(); // replace with a real account\n * const address = \"0x1\"; // replace with a real account address\n *\n * await aptos.setTargetAddress({\n * sender: sender,\n * name: \"test.aptos\",\n * address: address,\n * });\n *\n * const targetAddress = await aptos.getTargetAddress({ name: \"test.aptos\" });\n * console.log(targetAddress); // Should log the address set for \"test.aptos\"\n * }\n * runExample().catch(console.error);\n * ```\n */\n async setTargetAddress(args: {\n sender: Account;\n name: string;\n address: AccountAddressInput;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return setTargetAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the primary name for an account. An account can have multiple names, but only one primary name, which may not exist.\n *\n * @param args - The arguments for retrieving the primary name.\n * @param args.address - An AccountAddressInput (address) of the account.\n *\n * @returns A string if the account has a primary name, undefined otherwise.\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 primary name for the specified account address\n * const name = await aptos.getPrimaryName({ address: \"0x1\" }); // replace with a real account address\n * console.log(name);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getPrimaryName(args: { address: AccountAddressInput }): Promise<string | undefined> {\n return getPrimaryName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sets the primary name for the sender account, allowing them to designate a single primary name among potentially multiple\n * names. An account may not have a primary name.\n *\n * @param args - The arguments for setting the primary name.\n * @param args.sender - The sender account.\n * @param args.name - A string representing the name to set as primary (e.g., \"test.aptos\").\n * @param args.options - Optional transaction options.\n *\n * @returns SimpleTransaction\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 * // Set the primary name for the sender account\n * const sender = Account.generate(); // replace with a real account\n * await aptos.setPrimaryName({ sender, name: \"test.aptos\" });\n *\n * const primaryName = await aptos.getPrimaryName({ address: sender.accountAddress });\n * console.log(\"Primary Name:\", primaryName); // Should log: \"Primary Name: test.aptos\"\n * }\n * runExample().catch(console.error);\n * ```\n */\n async setPrimaryName(args: {\n sender: Account;\n name?: string;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return setPrimaryName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Registers a new name.\n *\n * This function allows you to register a domain or subdomain name with specific expiration policies and options.\n *\n * @param args.sender - The sender account.\n * @param args.name - A string of the name to register. This can be inclusive or exclusive of the .apt suffix. Examples include:\n * \"test\", \"test.apt\", \"test.aptos.apt\", etc.\n * @param args.expiration - An object with the expiration policy of the name.\n * @param args.expiration.policy - 'domain' | 'subdomain:follow-domain' | 'subdomain:independent'.\n * - domain: Years is required and the name will expire after the given number of years.\n * - subdomain:follow-domain: The name will expire at the same time as the domain name.\n * - subdomain:independent: The name will expire at the given date.\n * @param args.expiration.expirationDate - An epoch number in milliseconds of the date when the subdomain will expire. Only\n * applicable when the policy is set to 'subdomain:independent'.\n * @param args.transferable - Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.\n * @param args.targetAddress optional - The address the domain name will resolve to. If not provided, the sender's address will\n * be used.\n * @param args.toAddress optional - The address to send the domain name to. If not provided, the transaction will be sent to the\n * router.\n *\n * @returns SimpleTransaction\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 * // Registering a subdomain name assuming def.apt is already registered and belongs to the sender alice.\n * const txn = await aptos.registerName({\n * sender: \"0x1\", // replace with a real sender account\n * name: \"test.aptos.apt\",\n * expiration: {\n * policy: \"subdomain:independent\",\n * expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000, // expires in 30 days\n * },\n * });\n *\n * console.log(\"Transaction:\", txn);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async registerName(args: Omit<RegisterNameParameters, \"aptosConfig\">): Promise<SimpleTransaction> {\n return registerName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Renews a domain name for one year.\n * If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.\n *\n * @param args - The arguments for renewing the domain.\n * @param args.sender - The sender account, which must be the domain owner.\n * @param args.name - A string representing the domain to renew. Subdomains cannot be renewed.\n * @param args.years - The number of years to renew the name. Currently, only one year is permitted.\n * @param args.options - Optional transaction options.\n *\n * @returns SimpleTransaction\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 * // Renew the domain \"test\" for one year\n * const transaction = await aptos.renewDomain({\n * sender: Account.generate(), // replace with a real account\n * name: \"test\"\n * });\n *\n * console.log(transaction);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async renewDomain(args: {\n sender: Account;\n name: string;\n years?: 1;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return renewDomain({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches a single name from the indexer based on the provided name argument.\n *\n * @param args - The arguments for retrieving the name.\n * @param args.name - A string of the name to retrieve, e.g. \"test.aptos.apt\" or \"test.apt\" or \"test\".\n * Can be inclusive or exclusive of the .apt suffix and can be a subdomain.\n *\n * @returns A promise of an ANSName or undefined if the name is not active.\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 a name from the indexer\n * const name = await aptos.getName({ name: \"test.aptos\" }); // replace with a real name\n * console.log(name);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getName(args: { name: string }): Promise<GetANSNameResponse[0] | undefined> {\n return getName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all names for an account, including both top-level domains and subdomains.\n *\n * @param args - The arguments for fetching account names.\n * @param args.accountAddress - An AccountAddressInput of the address to retrieve names for.\n * @param args.options - Optional parameters for fetching names.\n * @param args.options.offset - Optional, the offset to start from when fetching names.\n * @param args.options.limit - Optional, a number of the names to fetch per request.\n * @param args.options.orderBy - The order to sort the names by.\n * @param args.options.where - Additional filters to apply to the query.\n *\n * @returns A promise of an array of ANSName.\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 account names for a specific address\n * const accountNames = await aptos.getAccountNames({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify how many names to fetch\n * orderBy: \"name\", // specify the order by which to sort the names\n * },\n * });\n *\n * console.log(accountNames);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getAccountNames(args: GetAccountNamesArgs): Promise<GetANSNameResponse> {\n return getAccountNames({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all top-level domain names for a specified account.\n *\n * @param args - The arguments for retrieving account domains.\n * @param args.accountAddress - An AccountAddressInput of the address to retrieve domain names for.\n * @param args.options.offset - Optional, the offset to start from when fetching names.\n * @param args.options.limit - Optional, a number of the names to fetch per request.\n * @param args.options.orderBy - The order to sort the names by.\n * @param args.options.where - Additional filters to apply to the query.\n *\n * @returns A promise of an array of ANSName.\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 all top-level domain names for a specific account\n * const domains = await aptos.getAccountDomains({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify the number of names to fetch\n * offset: 0, // specify the offset for pagination\n * orderBy: \"created_at\", // specify the order by which to sort the names\n * where: {\n * // additional filters can be specified here\n * },\n * },\n * });\n *\n * console.log(domains);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getAccountDomains(args: GetAccountDomainsArgs): Promise<GetANSNameResponse> {\n return getAccountDomains({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all subdomain names for a specified account.\n *\n * @param args - The arguments for retrieving subdomains.\n * @param args.accountAddress - The address to retrieve subdomain names for.\n * @param args.options - Optional parameters for fetching subdomains.\n * @param args.options.offset - The offset to start from when fetching names.\n * @param args.options.limit - The number of names to fetch per request.\n * @param args.options.orderBy - The order to sort the names by.\n * @param args.options.where - Additional filters to apply to the query.\n *\n * @returns A promise of an array of ANSName.\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 subdomain names for a specific account\n * const subdomains = await aptos.getAccountSubdomains({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify the number of subdomains to fetch\n * offset: 0, // specify the offset for pagination\n * orderBy: \"name\", // specify the order by which to sort the names\n * },\n * });\n *\n * console.log(subdomains);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getAccountSubdomains(args: GetAccountSubdomainsArgs): Promise<GetANSNameResponse> {\n return getAccountSubdomains({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all subdomain names for a given domain, excluding the domain itself.\n *\n * @param args - The arguments for fetching subdomains.\n * @param args.domain - A string of the domain name, e.g., \"test.apt\" or \"test\" (without the suffix of .apt).\n * @param args.options - Optional parameters for fetching subdomains.\n * @param args.options.offset - Optional, the offset to start from when fetching names.\n * @param args.options.limit - Optional, the number of names to fetch per request.\n * @param args.options.orderBy - The order to sort the names by.\n * @param args.options.where - Additional filters to apply to the query.\n *\n * @returns A promise that resolves to an array of ANSName.\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 subdomains for a specific domain\n * const subdomains = await aptos.getDomainSubdomains({\n * domain: \"test\", // replace with your domain\n * options: {\n * limit: 10, // specify the number of subdomains to fetch\n * offset: 0, // specify the starting point for fetching\n * orderBy: \"name\", // specify the order by which to sort the results\n * },\n * });\n *\n * console.log(subdomains);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async getDomainSubdomains(args: GetDomainSubdomainsArgs): Promise<GetANSNameResponse> {\n return getDomainSubdomains({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"6HAiCO,IAAMA,EAAN,KAAU,CA0Bf,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAyB3C,MAAM,gBAAgBC,EAA6D,CACjF,OAAOC,EAAgB,CAAE,YAAa,KAAK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AAC,CAClE,CACF","names":["ANS","config","args","getOwnerAddress","getExpiration","getTargetAddress","setTargetAddress","getPrimaryName","setPrimaryName","registerName","renewDomain","getName","getAccountNames","getAccountDomains","getAccountSubdomains","getDomainSubdomains"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!