{"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  constructor(readonly config: AptosConfig) {}\n\n  /**\n   * Queries current number of delegators in a pool.  Throws an error if the pool is not found.\n   *\n   * @example\n   * const delegators = await aptos.getNumberOfDelegators({poolAddress:\"0x123\"})\n   *\n   * @param args.poolAddress Pool address\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  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   * Queries current number of delegators in a pool.  Throws an error if the pool is not found.\n   *\n   * @example\n   * const delegators = await aptos.getNumberOfDelegatorsForAllPools()\n   *\n   * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n   * @returns GetNumberOfDelegatorsForAllPoolsResponse response type\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\n   *\n   * @example\n   * const delegators = await aptos.getDelegatedStakingActivities({delegatorAddress:\"0x123\",poolAddress:\"0x456\"})\n   *\n   * @param args.delegatorAddress Delegator address\n   * @param args.poolAddress Pool address\n   * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n   * @returns GetDelegatedStakingActivitiesResponse response type\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,CACnB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAY3C,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,CAWA,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,CAaA,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"]}