PHP WebShell

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

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

{"version":3,"sources":["../../src/internal/staking.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/staking}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * faucet namespace and without having a dependency cycle error.\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { AccountAddress, AccountAddressInput } from \"../core\";\nimport { GetDelegatedStakingActivitiesResponse, GetNumberOfDelegatorsResponse, OrderByArg } from \"../types\";\nimport { GetDelegatedStakingActivitiesQuery, GetNumberOfDelegatorsQuery } from \"../types/generated/operations\";\nimport { GetDelegatedStakingActivities, GetNumberOfDelegators } from \"../types/generated/queries\";\nimport { queryIndexer } from \"./general\";\n\n/**\n * Retrieves the number of active delegators for a specified pool address.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.poolAddress - The address of the pool for which to retrieve the number of delegators.\n * @returns The number of active delegators for the specified pool address.\n */\nexport async function getNumberOfDelegators(args: {\n  aptosConfig: AptosConfig;\n  poolAddress: AccountAddressInput;\n}): Promise<number> {\n  const { aptosConfig, poolAddress } = args;\n  const address = AccountAddress.from(poolAddress).toStringLong();\n  const query = {\n    query: GetNumberOfDelegators,\n    variables: { where_condition: { pool_address: { _eq: address } } },\n  };\n  const data = await queryIndexer<GetNumberOfDelegatorsQuery>({ aptosConfig, query });\n\n  // commonjs (aka cjs) doesn't handle Nullish Coalescing for some reason\n  // might be because of how ts infer the graphql generated scheme type\n  return data.num_active_delegator_per_pool[0] ? data.num_active_delegator_per_pool[0].num_active_delegator : 0;\n}\n\n/**\n * Retrieves the number of active delegators for all pools.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration for the Aptos client.\n * @param [args.options] - Optional parameters for ordering the results.\n * @param args.options.orderBy - Specifies the order in which to return the results.\n * @returns The number of active delegators per pool.\n */\nexport async function getNumberOfDelegatorsForAllPools(args: {\n  aptosConfig: AptosConfig;\n  options?: OrderByArg<GetNumberOfDelegatorsResponse[0]>;\n}): Promise<GetNumberOfDelegatorsResponse> {\n  const { aptosConfig, options } = args;\n  const query = {\n    query: GetNumberOfDelegators,\n    variables: { order_by: options?.orderBy },\n  };\n  const data = await queryIndexer<GetNumberOfDelegatorsQuery>({\n    aptosConfig,\n    query,\n  });\n  return data.num_active_delegator_per_pool;\n}\n\n/**\n * Retrieves the delegated staking activities for a specified delegator and pool.\n *\n * @param args - The parameters for the query.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.delegatorAddress - The address of the delegator whose activities are being queried.\n * @param args.poolAddress - The address of the pool associated with the delegated staking activities.\n * @returns The delegated staking activities for the specified delegator and pool.\n */\nexport async function getDelegatedStakingActivities(args: {\n  aptosConfig: AptosConfig;\n  delegatorAddress: AccountAddressInput;\n  poolAddress: AccountAddressInput;\n}): Promise<GetDelegatedStakingActivitiesResponse> {\n  const { aptosConfig, delegatorAddress, poolAddress } = args;\n  const query = {\n    query: GetDelegatedStakingActivities,\n    variables: {\n      delegatorAddress: AccountAddress.from(delegatorAddress).toStringLong(),\n      poolAddress: AccountAddress.from(poolAddress).toStringLong(),\n    },\n  };\n  const data = await queryIndexer<GetDelegatedStakingActivitiesQuery>({ aptosConfig, query });\n  return data.delegated_staking_activities;\n}\n"],"mappings":"kIAyBA,eAAsBA,EAAsBC,EAGxB,CAClB,GAAM,CAAE,YAAAC,EAAa,YAAAC,CAAY,EAAIF,EAC/BG,EAAUC,EAAe,KAAKF,CAAW,EAAE,aAAa,EAKxDG,EAAO,MAAMC,EAAyC,CAAE,YAAAL,EAAa,MAJ7D,CACZ,MAAOM,EACP,UAAW,CAAE,gBAAiB,CAAE,aAAc,CAAE,IAAKJ,CAAQ,CAAE,CAAE,CACnE,CACiF,CAAC,EAIlF,OAAOE,EAAK,8BAA8B,CAAC,EAAIA,EAAK,8BAA8B,CAAC,EAAE,qBAAuB,CAC9G,CAWA,eAAsBG,EAAiCR,EAGZ,CACzC,GAAM,CAAE,YAAAC,EAAa,QAAAQ,CAAQ,EAAIT,EAC3BU,EAAQ,CACZ,MAAOH,EACP,UAAW,CAAE,SAAUE,GAAS,OAAQ,CAC1C,EAKA,OAJa,MAAMH,EAAyC,CAC1D,YAAAL,EACA,MAAAS,CACF,CAAC,GACW,6BACd,CAWA,eAAsBC,EAA8BX,EAID,CACjD,GAAM,CAAE,YAAAC,EAAa,iBAAAW,EAAkB,YAAAV,CAAY,EAAIF,EACjDU,EAAQ,CACZ,MAAOG,EACP,UAAW,CACT,iBAAkBT,EAAe,KAAKQ,CAAgB,EAAE,aAAa,EACrE,YAAaR,EAAe,KAAKF,CAAW,EAAE,aAAa,CAC7D,CACF,EAEA,OADa,MAAMI,EAAiD,CAAE,YAAAL,EAAa,MAAAS,CAAM,CAAC,GAC9E,4BACd","names":["getNumberOfDelegators","args","aptosConfig","poolAddress","address","AccountAddress","data","queryIndexer","GetNumberOfDelegators","getNumberOfDelegatorsForAllPools","options","query","getDelegatedStakingActivities","delegatorAddress","GetDelegatedStakingActivities"]}

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


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