PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm
Просмотр файла: chunk-ZXVN3HXB.mjs.map
{"version":3,"sources":["../../src/internal/event.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/event}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * event namespace and without having a dependency cycle error.\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { AccountAddress, AccountAddressInput } from \"../core\";\nimport { AnyNumber, GetEventsResponse, PaginationArgs, MoveStructId, OrderByArg, WhereArg } from \"../types\";\nimport { GetEventsQuery } from \"../types/generated/operations\";\nimport { GetEvents } from \"../types/generated/queries\";\nimport { EventsBoolExp, InputMaybe } from \"../types/generated/types\";\nimport { queryIndexer } from \"./general\";\n\nconst MAX_EVENT_TYPE_LENGTH = 300;\nconst checkEventTypeLength = (eventType?: InputMaybe<string>) => {\n if (eventType && eventType.length > MAX_EVENT_TYPE_LENGTH) {\n throw new Error(`Event type length exceeds the maximum length of ${MAX_EVENT_TYPE_LENGTH}`);\n }\n};\n\n/**\n * Retrieves events associated with a specific module event type.\n * This function allows you to filter events based on the event type and pagination options.\n *\n * @param args - The arguments for retrieving module events.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.eventType - The MoveStructId representing the type of event to retrieve.\n * @param [args.options] - Optional pagination and ordering parameters for the event retrieval.\n */\nexport async function getModuleEventsByEventType(args: {\n aptosConfig: AptosConfig;\n eventType: MoveStructId;\n options?: PaginationArgs & OrderByArg<GetEventsResponse[0]>;\n}): Promise<GetEventsResponse> {\n const { aptosConfig, eventType, options } = args;\n\n const whereCondition: EventsBoolExp = {\n _or: [\n // EventHandle events\n { account_address: { _eq: eventType.split(\"::\")[0] } },\n // Module events\n {\n account_address: { _eq: \"0x0000000000000000000000000000000000000000000000000000000000000000\" },\n sequence_number: { _eq: 0 },\n creation_number: { _eq: 0 },\n },\n ],\n indexed_type: { _eq: eventType },\n };\n\n return getEvents({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieve events associated with a specific account and creation number.\n *\n * @param args - The parameters for retrieving account events.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.accountAddress - The address of the account for which events are being retrieved.\n * @param args.creationNumber - The creation number to filter events.\n * @param args.options - Optional pagination and ordering parameters for the event retrieval.\n */\nexport async function getAccountEventsByCreationNumber(args: {\n aptosConfig: AptosConfig;\n accountAddress: AccountAddressInput;\n creationNumber: AnyNumber;\n options?: PaginationArgs & OrderByArg<GetEventsResponse[0]>;\n}): Promise<GetEventsResponse> {\n const { accountAddress, aptosConfig, creationNumber, options } = args;\n const address = AccountAddress.from(accountAddress);\n\n const whereCondition: EventsBoolExp = {\n account_address: { _eq: address.toStringLong() },\n creation_number: { _eq: creationNumber },\n };\n\n return getEvents({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieves events associated with a specific account and event type.\n *\n * @param args - The parameters for retrieving account events.\n * @param args.aptosConfig - The configuration for connecting to the Aptos blockchain.\n * @param args.accountAddress - The address of the account for which to retrieve events.\n * @param args.eventType - The type of event to filter by.\n * @param args.options - Optional pagination and ordering parameters for the event retrieval.\n */\nexport async function getAccountEventsByEventType(args: {\n aptosConfig: AptosConfig;\n accountAddress: AccountAddressInput;\n eventType: MoveStructId;\n options?: PaginationArgs & OrderByArg<GetEventsResponse[0]>;\n}): Promise<GetEventsResponse> {\n const { accountAddress, aptosConfig, eventType, options } = args;\n const address = AccountAddress.from(accountAddress).toStringLong();\n\n const whereCondition: EventsBoolExp = {\n account_address: { _eq: address },\n indexed_type: { _eq: eventType },\n };\n\n return getEvents({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieves a list of events based on specified filtering and pagination options.\n *\n * @param args - The arguments for retrieving events.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param [args.options] - Optional parameters for pagination and filtering.\n * @param [args.options.offset] - The number of records to skip before starting to collect the result set.\n * @param [args.options.limit] - The maximum number of records to return.\n * @param [args.options.orderBy] - Defines the order in which to return the events.\n * @param [args.options.where] - Conditions to filter the events.\n * @param [args.options.where.indexed_type] - Filters events by the indexed type.\n */\nexport async function getEvents(args: {\n aptosConfig: AptosConfig;\n options?: PaginationArgs & OrderByArg<GetEventsResponse[0]> & WhereArg<EventsBoolExp>;\n}): Promise<GetEventsResponse> {\n const { aptosConfig, options } = args;\n\n /**\n * Checks the length of event types based on the provided filtering options.\n *\n * @param options - The options for querying event types.\n * @param options.where - The conditions to filter the event types.\n * @param options.where.indexed_type - The indexed type to filter by.\n * @param options.where.indexed_type._eq - The specific value to match for the indexed type.\n * @param options.offset - The number of items to skip before starting to collect the result set.\n * @param options.limit - The maximum number of items to return.\n * @param options.orderBy - The criteria to sort the results.\n */\n // eslint-disable-next-line no-underscore-dangle\n checkEventTypeLength(options?.where?.indexed_type?._eq);\n\n const graphqlQuery = {\n query: GetEvents,\n variables: {\n where_condition: options?.where,\n offset: options?.offset,\n limit: options?.limit,\n order_by: options?.orderBy,\n },\n };\n\n const data = await queryIndexer<GetEventsQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getEvents\",\n });\n\n return data.events;\n}\n"],"mappings":"2HAkBA,IAAMA,EAAwB,IACxBC,EAAwBC,GAAmC,CAC/D,GAAIA,GAAaA,EAAU,OAASF,EAClC,MAAM,IAAI,MAAM,mDAAmDA,CAAqB,EAAE,CAE9F,EAWA,eAAsBG,EAA2BC,EAIlB,CAC7B,GAAM,CAAE,YAAAC,EAAa,UAAAH,EAAW,QAAAI,CAAQ,EAAIF,EAEtCG,EAAgC,CACpC,IAAK,CAEH,CAAE,gBAAiB,CAAE,IAAKL,EAAU,MAAM,IAAI,EAAE,CAAC,CAAE,CAAE,EAErD,CACE,gBAAiB,CAAE,IAAK,oEAAqE,EAC7F,gBAAiB,CAAE,IAAK,CAAE,EAC1B,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","aptosConfig","options","whereCondition","getEvents","getAccountEventsByCreationNumber","accountAddress","creationNumber","AccountAddress","getAccountEventsByEventType","graphqlQuery","GetEvents","queryIndexer"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!