/** * Copyright (c) 2025 weimeme * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Message, TransferDetailWithMemo } from "../types"; import { ICryptMessage } from "@eliza-dot-aes/common"; /** * Interface representing extrinsic parameters with memo message. * Used to store the association between an extrinsic index and its memo message. */ interface ExtrinsicParamsWithMemo { extrinsic_index: string; memo: Message; } /** * Options interface for making HTTP requests to the Subscan API. * Defines the structure for request configuration including method, headers, body, and redirect policy. */ export interface RequestOptions { method: "POST" | "GET"; headers: Headers; params?: Record; body?: string; redirect?: "follow"; } /** * Client class for interacting with the Subscan API. * Provides methods to query blockchain data including transfers, extrinsics, and memos. * Supports multiple networks through the network parameter in the constructor. */ export declare class SubscanApi { network: string; apiKey: string; baseUrl: string; headers: Headers; constructor(network: string, apiKey?: string); /** * Retrieves transfer details by transaction hash. * First converts the hash to an extrinsic index, then fetches the transfer information. * * @param hash - The transaction hash of the transfer * @returns Promise resolving to the TransferDetail object, or null if not found * @throws Error if the API request fails or the hash is invalid */ getTransferByHash(hash: string): Promise; /** * Decrypts memo messages for a batch of transfer transactions. * Iterates through all transfers and attempts to decrypt their memos using the provided encryption service. * If a memo is null or decryption fails, the original memo value is preserved. * * @param transfers - Array of transfer details with potentially encrypted memos * @param cryptMessage - Encryption service instance used for decrypting memo messages * @returns Promise resolving to an array of transfer details with decrypted memos * Each transfer's memo will be decrypted if possible, otherwise kept as original (null or encrypted string) * @throws Error if the decryption service is invalid or encounters critical errors */ decryptTransfersMemo(transfers: TransferDetailWithMemo[], cryptMessage: ICryptMessage): Promise; /** * Retrieves transfer history for an address or by extrinsic index. * Fetches transfer transactions and enriches them with memo messages if available. * Supports pagination and filtering by various parameters. * * @param address - The account address to query (optional if extrinsic_index is provided) * @param extrinsic_index - Specific extrinsic index to query (optional) * @param asset_symbol - Asset symbol to filter by (currently not supported by API) * @param asset_unique_id - Unique asset identifier to filter by * @param page - Page number for pagination (default: 0) * @param row - Number of results per page (default: 20) * @param filter_nft - Whether to filter NFT transfers (currently not supported by API) * @param success - Whether to include only successful transactions (default: true) * @returns Promise resolving to an array of TransferDetail objects with memo information * @throws Error if the API request fails */ addressTransferHistory(address: string | null, extrinsic_index?: string | undefined, asset_symbol?: string | undefined, asset_unique_id?: string | undefined, page?: number, row?: number, filter_nft?: boolean, success?: boolean): Promise; /** * Converts a transaction hash to an extrinsic index. * This is a private helper method used internally to query extrinsic details by hash. * * @param hash - The transaction hash to look up * @returns Promise resolving to the extrinsic index string * @throws Error if the hash is not found or the API request fails */ getExtrinsicIndexByHash(hash: string): Promise; /** * Retrieves memo messages for a batch of extrinsic indices. * Parses extrinsic parameters to extract memo messages from System.remark or System.remarkWithEvent calls. * Handles batch transactions by checking the last call in the batch. * * @param extrinsic_index - Array of extrinsic indices to query for memos * @returns Promise resolving to an array of ExtrinsicParamsWithMemo objects * Each object contains the extrinsic_index and associated memo (if found) * @throws Error if the API request fails */ getMemoByTransferExtrinsics(extrinsic_index: string[]): Promise; } export {}; //# sourceMappingURL=subscan-api.d.ts.map