PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm

Просмотр файла: chunk-YEWZAR76.mjs.map

{"version":3,"sources":["../../src/api/staking.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n  getDelegatedStakingActivities,\n  getNumberOfDelegators,\n  getNumberOfDelegatorsForAllPools,\n} from \"../internal/staking\";\nimport { AnyNumber, GetDelegatedStakingActivitiesResponse, GetNumberOfDelegatorsResponse, OrderByArg } from \"../types\";\nimport { AccountAddressInput } from \"../core\";\nimport { ProcessorType } from \"../utils/const\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexerOnVersion } from \"./utils\";\n\n/**\n * A class to query all `Staking` related queries on Aptos.\n */\nexport class Staking {\n  /**\n   * Creates an instance of the Aptos client with the specified configuration.\n   * This allows you 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({ network: Network.TESTNET }); // Specify your network\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   * Queries the current number of delegators in a specified pool. Throws an error if the pool is not found.\n   *\n   * @param args - The parameters for the query.\n   * @param args.poolAddress - The address of the pool to query.\n   * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n   * @returns The number of delegators for the given pool.\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 number of delegators for a specific pool\n   *   const delegators = await aptos.getNumberOfDelegators({ poolAddress: \"0x1\" }); // replace with a real pool address\n   *   console.log(`Number of delegators: ${delegators}`);\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  async getNumberOfDelegators(args: {\n    poolAddress: AccountAddressInput;\n    minimumLedgerVersion?: AnyNumber;\n  }): Promise<number> {\n    await waitForIndexerOnVersion({\n      config: this.config,\n      minimumLedgerVersion: args?.minimumLedgerVersion,\n      processorType: ProcessorType.STAKE_PROCESSOR,\n    });\n    return getNumberOfDelegators({ aptosConfig: this.config, ...args });\n  }\n\n  /**\n   * Retrieves the current number of delegators across all pools.\n   *\n   * @param args Optional parameters for the query.\n   * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n   * @param args.options Optional ordering options for the response.\n   * @returns GetNumberOfDelegatorsForAllPoolsResponse response type containing the number of delegators per pool.\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 number of delegators for all pools\n   *   const delegators = await aptos.getNumberOfDelegatorsForAllPools();\n   *   console.log(delegators);\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  async getNumberOfDelegatorsForAllPools(args?: {\n    minimumLedgerVersion?: AnyNumber;\n    options?: OrderByArg<GetNumberOfDelegatorsResponse[0]>;\n  }): Promise<GetNumberOfDelegatorsResponse> {\n    await waitForIndexerOnVersion({\n      config: this.config,\n      minimumLedgerVersion: args?.minimumLedgerVersion,\n      processorType: ProcessorType.STAKE_PROCESSOR,\n    });\n    return getNumberOfDelegatorsForAllPools({ aptosConfig: this.config, ...args });\n  }\n\n  /**\n   * Queries delegated staking activities for a specific delegator and pool.\n   *\n   * @param args - The arguments for querying delegated staking activities.\n   * @param args.delegatorAddress - The address of the delegator.\n   * @param args.poolAddress - The address of the staking pool.\n   * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n   * @returns The response containing delegated staking activities.\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 delegated staking activities for a specific delegator and pool\n   *   const activities = await aptos.getDelegatedStakingActivities({\n   *     delegatorAddress: \"0x1\", // replace with a real delegator address\n   *     poolAddress: \"0x2\", // replace with a real pool address\n   *     minimumLedgerVersion: 1, // specify your own if needed\n   *   });\n   *\n   *   console.log(activities);\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  async getDelegatedStakingActivities(args: {\n    delegatorAddress: AccountAddressInput;\n    poolAddress: AccountAddressInput;\n    minimumLedgerVersion?: AnyNumber;\n  }): Promise<GetDelegatedStakingActivitiesResponse> {\n    await waitForIndexerOnVersion({\n      config: this.config,\n      minimumLedgerVersion: args?.minimumLedgerVersion,\n      processorType: ProcessorType.STAKE_PROCESSOR,\n    });\n    return getDelegatedStakingActivities({ aptosConfig: this.config, ...args });\n  }\n}\n"],"mappings":"gGAiBO,IAAMA,EAAN,KAAc,CAyBnB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAyB3C,MAAM,sBAAsBC,EAGR,CAClB,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,+BACF,CAAC,EACME,EAAsB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CACpE,CAyBA,MAAM,iCAAiCA,EAGI,CACzC,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,+BACF,CAAC,EACMG,EAAiC,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CAC/E,CA+BA,MAAM,8BAA8BA,EAIe,CACjD,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,+BACF,CAAC,EACMI,EAA8B,CAAE,YAAa,KAAK,OAAQ,GAAGJ,CAAK,CAAC,CAC5E,CACF","names":["Staking","config","args","waitForIndexerOnVersion","getNumberOfDelegators","getNumberOfDelegatorsForAllPools","getDelegatedStakingActivities"]}

Выполнить команду


Для локальной разработки. Не используйте в интернете!